Pārlūkot izejas kodu

发布文章bug修改

xiaoming_global 5 gadus atpakaļ
vecāks
revīzija
eaf92c7351

+ 182 - 2
controllers/article/article_controller.go Parādīt failu

@@ -31,6 +31,8 @@ func ArticleRouters() {
31 31
 	beego.Router("/api/article/Delete",&ArticleManage{},"Delete:DeleteArticle")
32 32
 	beego.Router("/api/acticle/getMenus",&ArticleManage{},"Get:GetMenus")
33 33
 	beego.Router("/api/acticle/updateArticlesInfo",&ArticleManage{},"Post:UpdataArticleInfo")
34
+	beego.Router("/api/acticle/saveArticleDraft",&ArticleManage{},"Post:SaveArticleDraft")
35
+	beego.Router("/api/acticle/updateVidoInfo",&ArticleManage{},"Post:UpdateVidoInfo")
34 36
 	beego.Router("/api/acticle/previewEditArticle",&ArticleManage{},"Post:PreviewEditArticle")
35 37
 	beego.Router("/api/acticle/getPreviewInfo",&ArticleManage{},"Post:GetPreviewInfo")
36 38
 	beego.Router("/api/acticle/getAllComment",&ArticleManage{},"Get:GetAllComment")
@@ -45,6 +47,8 @@ func ArticleRouters() {
45 47
 	beego.Router("/api/article/spread",&ArticleManage{},"Get:GetSpreadInfo")
46 48
 	beego.Router("/api/article/clear",&ArticleManage{},"Delete:ClearReply")
47 49
 	beego.Router("/api/article/deleteComments",&ArticleManage{},"Delete:DeleteComments")
50
+	beego.Router("/api/acticle/getEditVidoInfo",&ArticleManage{},"Get:GetVidoInfo")
51
+    beego.Router("/api/acticle/savevidodraft",&ArticleManage{},"Post:SaveVidoDraft")
48 52
 }
49 53
 
50 54
 type ArticleManage struct {
@@ -101,6 +105,7 @@ func (this *ArticleManage) CreateArticle(){
101 105
 				Status:1,
102 106
 				Type:1,
103 107
 				ArticleStatus:1,
108
+
104 109
 		}
105 110
 		err = article_service.AddAritcle(articles)
106 111
 		if err !=nil{
@@ -148,7 +153,9 @@ func (this *ArticleManage) GetAllArticles()  {
148 153
 
149 154
 	adminUserInfo := this.GetAdminUserInfo()
150 155
 	userOrgID := adminUserInfo.CurrentOrgId
151
-
156
+	org := adminUserInfo.Orgs[adminUserInfo.CurrentOrgId]
157
+	OrgName := org.OrgName
158
+	fmt.Println("机构姓名:",OrgName)
152 159
 	if(status == 1){
153 160
 		articles, total, err := article_service.GetPublished(userOrgID, page, limit, searchKey)
154 161
 		category, err := article_service.FindCategoryList(userOrgID)
@@ -160,6 +167,7 @@ func (this *ArticleManage) GetAllArticles()  {
160 167
 			"articles":articles,
161 168
 			"total":total,
162 169
 			"category":category,
170
+			"OrgName":OrgName,
163 171
 		})
164 172
 	}
165 173
 	if(status == 2){
@@ -173,6 +181,7 @@ func (this *ArticleManage) GetAllArticles()  {
173 181
 			"articles":articles,
174 182
 			"total":total,
175 183
 			"category":category,
184
+			"OrgName":OrgName,
176 185
 		})
177 186
 	}
178 187
 
@@ -187,6 +196,7 @@ func (this *ArticleManage) GetAllArticles()  {
187 196
 			"articles":articles,
188 197
 			"total":total,
189 198
 			"category":category,
199
+			"OrgName":OrgName,
190 200
 		})
191 201
 	}
192 202
 
@@ -208,6 +218,7 @@ func (this *ArticleManage) GetAllArticles()  {
208 218
 		"articles":articles,
209 219
 		"total":total,
210 220
 		"category":category,
221
+		"OrgName":OrgName,
211 222
 	})
212 223
 	return
213 224
 }
@@ -447,6 +458,7 @@ func (this *ArticleManage) Addvido(){
447 458
        Imgs:vidpic,
448 459
        ClassId:vidtype,
449 460
        ArticleStatus:1,
461
+       Status:1,
450 462
 	}
451 463
 
452 464
 	err = article_service.AddVido(articles)
@@ -511,6 +523,7 @@ func (this *ArticleManage) SaveDraft()  {
511 523
 		Imgs:vidpic,
512 524
 		ClassId:vidtype,
513 525
 		ArticleStatus:2,
526
+		Status:1,
514 527
 	}
515 528
 
516 529
 	err = article_service.AddVido(articles)
@@ -676,6 +689,21 @@ func (this *ArticleManage) GetArticleInfo()  {
676 689
 	})
677 690
 }
678 691
 
692
+func (this *ArticleManage) GetVidoInfo()  {
693
+	id, _ := this.GetInt64("id")
694
+	fmt.Println("视频id是多少?",id)
695
+	adminUserInfo := this.GetAdminUserInfo()
696
+	userOrgID := adminUserInfo.CurrentOrgId
697
+	vidos, err := article_service.GetArticleInfo(userOrgID, id)
698
+	if err !=nil{
699
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "查询文章信息失败")
700
+		return
701
+	}
702
+	fmt.Println("内容是啥什么",vidos)
703
+	this.ServeSuccessJSON(map[string]interface{}{
704
+		"vidos":vidos,
705
+	})
706
+}
679 707
 func (this *ArticleManage) DeleteArticle()  {
680 708
 	adminUserInfo := this.GetAdminUserInfo()
681 709
 	userOrgID := adminUserInfo.CurrentOrgId
@@ -787,6 +815,7 @@ func (this * ArticleManage) UpdataArticleInfo(){
787 815
 		ClassId: classid,
788 816
 		Status:  1,
789 817
 		Mtime:   time.Now().Unix(),
818
+		ArticleStatus:1,
790 819
 	}
791 820
 	 fmt.Println("为什么",articles)
792 821
 	 article_service.UpdataArticleInfo(&articles,userOrgID, id)
@@ -795,6 +824,109 @@ func (this * ArticleManage) UpdataArticleInfo(){
795 824
 	})
796 825
 }
797 826
 
827
+func  (this * ArticleManage) SaveArticleDraft()  {
828
+	adminUserInfo := this.GetAdminUserInfo()
829
+	userOrgID := adminUserInfo.CurrentOrgId
830
+	id, _ := this.GetInt64("id")
831
+	fmt.Println("id是多少",id)
832
+	dataBody := make(map[string]interface{}, 0)
833
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
834
+	fmt.Println("视频发布是什么呢",err)
835
+
836
+	if err != nil {
837
+		utils.ErrorLog(err.Error())
838
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
839
+		return
840
+	}
841
+
842
+	title := dataBody["title"].(string)
843
+	if len(title) == 0 {
844
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章标题不能为空")
845
+		return
846
+	}
847
+	fmt.Println("title",title)
848
+	content := dataBody["content"].(string)
849
+	if len(content) == 0 {
850
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "内容不能为空")
851
+		return
852
+	}
853
+	fmt.Println("content",content)
854
+	images := dataBody["imgs"].(string)
855
+	fmt.Println("images",images)
856
+	classid :=int64( dataBody["class_id"].(float64))
857
+	if classid <=0 {
858
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "分类号不能为空")
859
+		return
860
+	}
861
+	//classid, _ := strconv.ParseInt(class_id, 10, 64)
862
+	fmt.Println("分类号",classid)
863
+	fmt.Println("标题",title,"保存文章草稿内容",content,"图片",images,"分类号",classid,"机构ID",userOrgID)
864
+
865
+	articles := models.Articles{
866
+		Title:   title,
867
+		Content: content,
868
+		Imgs:    images,
869
+		ClassId: classid,
870
+		Status:  1,
871
+		Mtime:   time.Now().Unix(),
872
+		ArticleStatus:2,
873
+	}
874
+	fmt.Println("为什么",articles)
875
+	article_service.UpdataArticleInfo(&articles,userOrgID, id)
876
+	this.ServeSuccessJSON(map[string]interface{}{
877
+		"articls":articles,
878
+	})
879
+}
880
+
881
+func (this * ArticleManage) UpdateVidoInfo()  {
882
+	adminUserInfo := this.GetAdminUserInfo()
883
+	userOrgID := adminUserInfo.CurrentOrgId
884
+	id, _ := this.GetInt64("id")
885
+	fmt.Println("id是多少",id)
886
+	dataBody := make(map[string]interface{}, 0)
887
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
888
+	fmt.Println("视频发布是什么呢",err)
889
+	if err != nil {
890
+		utils.ErrorLog(err.Error())
891
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
892
+		return
893
+	}
894
+
895
+	vidname := dataBody["vid_name"].(string)
896
+	fmt.Println("视频名称",vidname)
897
+	if len(vidname) == 0 {
898
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章标题不能为空")
899
+		return
900
+	}
901
+
902
+	vidpic := dataBody["vid_pic"].(string)
903
+	fmt.Println("视频封面",vidpic)
904
+	if len(vidpic) == 0 {
905
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章标题不能为空")
906
+		return
907
+	}
908
+
909
+	vidtype := int64( dataBody["vid_type"].(float64))
910
+	fmt.Println("视频封面",vidtype)
911
+	if vidtype <= 0 {
912
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章标题不能为空")
913
+		return
914
+	}
915
+	articles := models.Articles{
916
+		Title:   vidname,
917
+		Imgs:    vidpic,
918
+		ClassId: vidtype,
919
+		Status:  1,
920
+		Mtime:   time.Now().Unix(),
921
+		ArticleStatus:1,
922
+	}
923
+	article_service.UpdataArticleInfo(&articles,userOrgID, id)
924
+	this.ServeSuccessJSON(map[string]interface{}{
925
+		"articls":articles,
926
+	})
927
+}
928
+
929
+
798 930
 func (this * ArticleManage) PreviewEditArticle()  {
799 931
 	adminUserInfo := this.GetAdminUserInfo()
800 932
 	userOrgID := adminUserInfo.CurrentOrgId
@@ -904,7 +1036,7 @@ func (this * ArticleManage) GetArticleCommentDetail(){
904 1036
 	adminUserInfo := this.GetAdminUserInfo()
905 1037
 	userOrgID := adminUserInfo.CurrentOrgId
906 1038
 	articles, err := article_service.GetArticleCommentDetail(id, userOrgID)
907
-	comment, total, err := article_service.FindAllComments(page, limit, id)
1039
+	comment, total, err := article_service.FindAllComments(page, limit, 20142)
908 1040
 	org := adminUserInfo.Orgs[adminUserInfo.CurrentOrgId]
909 1041
 	fmt.Println("err是什么",err)
910 1042
 	fmt.Println("total",total)
@@ -1104,4 +1236,52 @@ func  (this * ArticleManage) DeleteComments()  {
1104 1236
 	returnData["msg"] = "ok"
1105 1237
 	this.ServeSuccessJSON(returnData)
1106 1238
 	return
1239
+}
1240
+
1241
+func (this * ArticleManage) SaveVidoDraft()  {
1242
+	adminUserInfo := this.GetAdminUserInfo()
1243
+	userOrgID := adminUserInfo.CurrentOrgId
1244
+	id, _ := this.GetInt64("id")
1245
+	fmt.Println("id是多少",id)
1246
+	dataBody := make(map[string]interface{}, 0)
1247
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
1248
+	fmt.Println("视频发布是什么呢",err)
1249
+	if err != nil {
1250
+		utils.ErrorLog(err.Error())
1251
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
1252
+		return
1253
+	}
1254
+
1255
+	vidname := dataBody["vid_name"].(string)
1256
+	fmt.Println("视频名称",vidname)
1257
+	if len(vidname) == 0 {
1258
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章标题不能为空")
1259
+		return
1260
+	}
1261
+
1262
+	vidpic := dataBody["vid_pic"].(string)
1263
+	fmt.Println("视频封面",vidpic)
1264
+	if len(vidpic) == 0 {
1265
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章标题不能为空")
1266
+		return
1267
+	}
1268
+
1269
+	vidtype := int64( dataBody["vid_type"].(float64))
1270
+	fmt.Println("视频封面",vidtype)
1271
+	if vidtype <= 0 {
1272
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章标题不能为空")
1273
+		return
1274
+	}
1275
+	articles := models.Articles{
1276
+		Title:   vidname,
1277
+		Imgs:    vidpic,
1278
+		ClassId: vidtype,
1279
+		Status:  1,
1280
+		Mtime:   time.Now().Unix(),
1281
+		ArticleStatus:2,
1282
+	}
1283
+	article_service.SaveVidoDraft(&articles,userOrgID,id)
1284
+	this.ServeSuccessJSON(map[string]interface{}{
1285
+		"articls":articles,
1286
+	})
1107 1287
 }

+ 5 - 1
service/article_service/article_category_service.go Parādīt failu

@@ -208,8 +208,12 @@ func GetMenus(OrgID int64)(categorys []*models.ArticleCategory,err error)  {
208 208
 }
209 209
 
210 210
 func UpdataArticleInfo(art *models.Articles,orgID int64,id int64){
211
-	service.PatientWriteDB().Model(art).Where("user_org_id = ? AND id = ? AND status = ?",orgID,id,1).Update(map[string]interface{}{"title":art.Title,"content":art.Content,"imgs":art.Imgs,"class_id":art.ClassId,"mtime":art.Mtime})
211
+	service.PatientWriteDB().Model(art).Where("user_org_id = ? AND id = ? AND status = ?",orgID,id,1).Update(map[string]interface{}{"title":art.Title,"content":art.Content,"imgs":art.Imgs,"class_id":art.ClassId,"mtime":art.Mtime,"article_status":art.ArticleStatus})
212
+
213
+}
212 214
 
215
+func SaveVidoDraft(art *models.Articles,orgID int64,id int64)  {
216
+	service.PatientWriteDB().Model(art).Where("user_org_id =? AND id = ? AND status = ?",orgID,id,1).Update(map[string]interface{}{"title":art.Title,"imgs":art.Imgs,"class_id":art.ClassId,"mtime":art.Mtime,"article_status":art.ArticleStatus})
213 217
 }
214 218
 
215 219
 func PreviewEditArticle(art models.Articles,orgID int64,id int64)  {