Преглед изворни кода

文章发布模块的开发

xiaoming_global пре 5 година
родитељ
комит
b700488b55

+ 41 - 0
controllers/article/article_controller.go Прегледај датотеку

@@ -0,0 +1,41 @@
1
+package article
2
+
3
+import (
4
+	"github.com/astaxie/beego"
5
+	"fmt"
6
+	"SCRM/controllers"
7
+	"SCRM/service/article_service"
8
+	"SCRM/enums"
9
+)
10
+
11
+func ArticleRouters() {
12
+
13
+	beego.Router("/api/acticle/createacticle",&ArticleManage{},"Get:CreateArticle")
14
+	beego.Router("/api/acticle/getArticleType",&ArticleManage{},"Get:GetArticleType")
15
+}
16
+
17
+type ArticleManage struct {
18
+
19
+	controllers.BaseAuthAPIController
20
+}
21
+
22
+func (this *ArticleManage) CreateArticle(){
23
+	actname := this.GetString("act_name")
24
+	fmt.Println("姓名:",actname)
25
+}
26
+
27
+func (this *ArticleManage) GetArticleType(){
28
+	adminUserInfo := this.GetAdminUserInfo()
29
+	userOrgID := adminUserInfo.CurrentOrgId
30
+	category, err := article_service.FindArticleCategoryType(userOrgID)
31
+	fmt.Println("文章分类列表",category,err)
32
+	if err !=nil{
33
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取文章分类列表失败")
34
+		return
35
+	}
36
+	this.ServeSuccessJSON(map[string]interface{}{
37
+		"category":category,
38
+	})
39
+	return
40
+}
41
+

+ 5 - 0
controllers/article/router_collector.go Прегледај датотеку

@@ -0,0 +1,5 @@
1
+package article
2
+
3
+func RegisterRouters() {
4
+	ArticleRouters()
5
+}

+ 20 - 0
models/article_models.go Прегледај датотеку

@@ -0,0 +1,20 @@
1
+package models
2
+
3
+type ArticleCategory struct{
4
+	//对应数据库中的字段
5
+	MenuId    int64  `gorm:"column:id" `
6
+	Name      string `gorm:"column:name" `
7
+	Order     int64  `gorm:"column:order" `
8
+	Status    int64  `gorm:"column:status" `
9
+	Summary   string `gorm:"column:summary" `
10
+	Type      int64  `gorm:"column:type"`
11
+	Mtime     int64  `gorm:"column:mtime"`
12
+	Ctime     int64  `gorm:"column:ctime"`
13
+	UserOrgId int64  `gorm:"column:user_org_id"`
14
+	Num       int64  `gorm:"column:num" json:"num"`
15
+
16
+}
17
+
18
+func (ArticleCategory) TableName() string  {
19
+	return "sgj_patient_articles_menu"
20
+}

+ 12 - 0
service/article_service/article_category_service.go Прегледај датотеку

@@ -0,0 +1,12 @@
1
+package article_service
2
+
3
+import (
4
+	"SCRM/models"
5
+	"SCRM/service"
6
+)
7
+
8
+func FindArticleCategoryType(userOrgId int64)(*[]models.ArticleCategory,error){
9
+   cartegory :=	&[]models.ArticleCategory{}
10
+	err := service.PatientReadDB().Where("status = ? AND user_org_id = ? ", 1, userOrgId).Find(cartegory).Error
11
+	return  cartegory,err
12
+}