瀏覽代碼

文章评论

xiaoming_global 6 年之前
父節點
當前提交
dfcee5237d

+ 100 - 2
controllers/article/article_controller.go 查看文件

35
 	beego.Router("/api/acticle/getPreviewInfo",&ArticleManage{},"Post:GetPreviewInfo")
35
 	beego.Router("/api/acticle/getPreviewInfo",&ArticleManage{},"Post:GetPreviewInfo")
36
 	beego.Router("/api/acticle/getAllComment",&ArticleManage{},"Get:GetAllComment")
36
 	beego.Router("/api/acticle/getAllComment",&ArticleManage{},"Get:GetAllComment")
37
 	beego.Router("/api/acticle/getArticleCommentDetail",&ArticleManage{},"Get:GetArticleCommentDetail")
37
 	beego.Router("/api/acticle/getArticleCommentDetail",&ArticleManage{},"Get:GetArticleCommentDetail")
38
+	beego.Router("/api/article/deleteArticle",&ArticleManage{},"Get:DeleteArticles")
39
+	beego.Router("/api/acticle/send",&ArticleManage{},"Get:SendReplycontent")
40
+	beego.Router("/api/acticle/getReplyAllComents",&ArticleManage{},"Get:GetReplyAllComents")
38
 }
41
 }
39
 
42
 
40
 type ArticleManage struct {
43
 type ArticleManage struct {
123
 	limit, _ := this.GetInt64("limit", 10)
126
 	limit, _ := this.GetInt64("limit", 10)
124
 	fmt.Println("限制",limit)
127
 	fmt.Println("限制",limit)
125
 	searchKey := this.GetString("keyword", "")
128
 	searchKey := this.GetString("keyword", "")
129
+	fmt.Println("搜索字",searchKey)
126
 	classId,_ := this.GetInt64("id",0)
130
 	classId,_ := this.GetInt64("id",0)
127
 	status, _ := this.GetInt64("status")
131
 	status, _ := this.GetInt64("status")
128
 	fmt.Println("页面",page,"限制",limit,"关键字",searchKey,"分类号",classId,"状态值:",status)
132
 	fmt.Println("页面",page,"限制",limit,"关键字",searchKey,"分类号",classId,"状态值:",status)
200
 	})
204
 	})
201
 	return
205
 	return
202
 }
206
 }
203
-
204
 func (this *ArticleManage) AddCategory(){
207
 func (this *ArticleManage) AddCategory(){
205
 
208
 
206
 	dataBody := make(map[string]interface{}, 0)
209
 	dataBody := make(map[string]interface{}, 0)
262
 	adminUserInfo := this.GetAdminUserInfo()
265
 	adminUserInfo := this.GetAdminUserInfo()
263
 	userOrgID := adminUserInfo.CurrentOrgId
266
 	userOrgID := adminUserInfo.CurrentOrgId
264
 	page, _ := this.GetInt64("page", 1)
267
 	page, _ := this.GetInt64("page", 1)
268
+	fmt.Println("页面",page)
265
 	limit, _ := this.GetInt64("limit", 10)
269
 	limit, _ := this.GetInt64("limit", 10)
270
+	fmt.Println("限制",limit)
266
 	if page <= 0 {
271
 	if page <= 0 {
267
 		page = 1
272
 		page = 1
268
 	}
273
 	}
701
 	return
706
 	return
702
 }
707
 }
703
 
708
 
709
+func (this *ArticleManage) DeleteArticles()  {
710
+	id, _:= this.GetInt64("id")
711
+	fmt.Println("id是多少呢",id)
712
+	adminUserInfo := this.GetAdminUserInfo()
713
+	userOrgID := adminUserInfo.CurrentOrgId
714
+	err := article_service.DeleteArticles(id, userOrgID)
715
+	if err !=nil{
716
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除失败")
717
+		return
718
+	}
719
+	returnData := make(map[string]interface{}, 0)
720
+	returnData["msg"] = "ok"
721
+	this.ServeSuccessJSON(returnData)
722
+	return
723
+}
724
+
704
 func (this *ArticleManage) GetMenus(){
725
 func (this *ArticleManage) GetMenus(){
705
 	adminUserInfo := this.GetAdminUserInfo()
726
 	adminUserInfo := this.GetAdminUserInfo()
706
 	userOrgID := adminUserInfo.CurrentOrgId
727
 	userOrgID := adminUserInfo.CurrentOrgId
863
 func (this * ArticleManage) GetArticleCommentDetail(){
884
 func (this * ArticleManage) GetArticleCommentDetail(){
864
 	id, _ := this.GetInt64("id")
885
 	id, _ := this.GetInt64("id")
865
 	fmt.Println("id是多少",id)
886
 	fmt.Println("id是多少",id)
887
+	page, _ := this.GetInt64("page", 1)
888
+	fmt.Println("页面",page)
889
+	limit, _ := this.GetInt64("limit", 10)
890
+	fmt.Println("限制",limit)
891
+	if page <= 0 {
892
+		page = 1
893
+	}
894
+	if limit <= 0 {
895
+		limit = 10
896
+	}
866
 	adminUserInfo := this.GetAdminUserInfo()
897
 	adminUserInfo := this.GetAdminUserInfo()
867
 	userOrgID := adminUserInfo.CurrentOrgId
898
 	userOrgID := adminUserInfo.CurrentOrgId
868
 	articles, err := article_service.GetArticleCommentDetail(id, userOrgID)
899
 	articles, err := article_service.GetArticleCommentDetail(id, userOrgID)
900
+	comment, total, err := article_service.FindAllComments(page, limit, 20142)
901
+	org := adminUserInfo.Orgs[adminUserInfo.CurrentOrgId]
902
+	fmt.Println("err是什么",err)
903
+	fmt.Println("total",total)
869
 	if err !=nil{
904
 	if err !=nil{
870
 		this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取预览失败")
905
 		this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取预览失败")
871
 		return
906
 		return
872
 	}
907
 	}
873
 	this.ServeSuccessJSON(map[string]interface{}{
908
 	this.ServeSuccessJSON(map[string]interface{}{
874
 		"articles":articles,
909
 		"articles":articles,
910
+		"comment":comment,
911
+		"total":total,
912
+		"orgName":org.OrgName,
913
+		"orgID":userOrgID,
875
 	})
914
 	})
876
-}
915
+}
916
+
917
+func  (this * ArticleManage) SendReplycontent()  {
918
+	replycontent := this.GetString("replycontent")
919
+	actilcid, _ := this.GetInt64("acticlid")
920
+	parentid, _ := this.GetInt64("parentid")
921
+	fmt.Println("回复的内容",replycontent)
922
+	fmt.Println("文章ID",actilcid)
923
+	fmt.Println("父类ID",parentid)
924
+	adminUserInfo := this.GetAdminUserInfo()
925
+	userOrgID := adminUserInfo.CurrentOrgId
926
+	org := adminUserInfo.Orgs[adminUserInfo.CurrentOrgId]
927
+	orgName := org.OrgName
928
+	orgLogo := org.OrgLogo
929
+	fmt.Println("logo",orgLogo)
930
+	comment := models.Comment{
931
+		Content: replycontent,
932
+		ParentId: parentid,
933
+		ArticleId: actilcid,
934
+		Ctime: time.Now().Unix(),
935
+		CommentUserId:userOrgID,
936
+		Status:1,
937
+		CommentUserAvater: orgLogo,
938
+		CommentUserName:orgName,
939
+	}
940
+	err := article_service.AddComment(&comment)
941
+	fmt.Println("错误是什么",err)
942
+	if err !=nil{
943
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加回复内容失败")
944
+		return
945
+	}
946
+	this.ServeSuccessJSON(map[string]interface{}{
947
+		"comment":comment,
948
+	})
949
+}
950
+
951
+func (this * ArticleManage) GetReplyAllComents()  {
952
+	page, _ := this.GetInt64("page", 1)
953
+	fmt.Println("页面",page)
954
+	limit, _ := this.GetInt64("limit", 10)
955
+	fmt.Println("限制",limit)
956
+	if page <= 0 {
957
+		page = 1
958
+	}
959
+	if limit <= 0 {
960
+		limit = 10
961
+	}
962
+	adminUserInfo := this.GetAdminUserInfo()
963
+	userOrgID := adminUserInfo.CurrentOrgId
964
+	fmt.Println("机构ID",userOrgID)
965
+	comment, total, err := article_service.GetReplyAllComents(page, limit)
966
+	if err !=nil{
967
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取评论列表失败")
968
+		return
969
+	}
970
+	this.ServeSuccessJSON(map[string]interface{}{
971
+	    "comments":comment,
972
+	    "total":total,
973
+	})
974
+}

+ 1 - 0
controllers/base_view_controller.go 查看文件

1
 package controllers
1
 package controllers
2
+
2
 type BaseViewController struct {
3
 type BaseViewController struct {
3
 	BaseController
4
 	BaseController
4
 }
5
 }

+ 133 - 1
controllers/staff/staff_controller.go 查看文件

15
 	 
15
 	 
16
 	beego.Router("/api/staff/addStaffInfo",&StaffManage{},"Post:AddStaffInfo")
16
 	beego.Router("/api/staff/addStaffInfo",&StaffManage{},"Post:AddStaffInfo")
17
 	beego.Router("/api/staff/getAllStaffInfo",&StaffManage{},"Get:GetAllStaffInfo")
17
 	beego.Router("/api/staff/getAllStaffInfo",&StaffManage{},"Get:GetAllStaffInfo")
18
+	beego.Router("/api/staff/EditStaffInfo",&StaffManage{},"Post:EditStaffInfo")
19
+	beego.Router("/api/staff/DeleteStaffs",&StaffManage{},"Delete:DeleteStaffs")
18
 }
20
 }
19
 
21
 
20
 type StaffManage struct {
22
 type StaffManage struct {
102
 		Gender:gender,
104
 		Gender:gender,
103
 		Content:content,
105
 		Content:content,
104
 		UserType:  userType,
106
 		UserType:  userType,
105
-		UserTitle: userType,
107
+		UserTitle: userTitle,
106
 		Dochead:   dochead,
108
 		Dochead:   dochead,
107
 		Status: 1,
109
 		Status: 1,
108
 		UserOrgId:userOrgID,
110
 		UserOrgId:userOrgID,
147
 		"userStaffInfo":userStaffInfo,
149
 		"userStaffInfo":userStaffInfo,
148
 		"total":total,
150
 		"total":total,
149
 	})
151
 	})
152
+}
153
+
154
+func (this *StaffManage) EditStaffInfo()  {
155
+	id, _ := this.GetInt64("id")
156
+    fmt.Println("ID是多少?",id)
157
+	adminUserInfo := this.GetAdminUserInfo()
158
+	userOrgID := int64(adminUserInfo.CurrentOrgId)
159
+	fmt.Println("机构ID",userOrgID)
160
+	dataBody := make(map[string]interface{}, 0)
161
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
162
+	fmt.Println("视频发布是什么呢",err)
163
+
164
+	if err != nil {
165
+		utils.ErrorLog(err.Error())
166
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
167
+		return
168
+	}
169
+	staffname := dataBody["name"].(string)
170
+	if len(staffname) == 0 {
171
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "姓名不能为空")
172
+		return
173
+	}
174
+
175
+	phone := dataBody["phone"].(string)
176
+	if len(phone) == 0 {
177
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "手机不能为空")
178
+		return
179
+	}
180
+
181
+	gender := int64(dataBody["gender"].(float64))
182
+	if gender <= 0{
183
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "性别不能为空")
184
+		return
185
+	}
186
+
187
+	birthday, _ := dataBody["birthday"].(string)
188
+	if len(birthday) == 0 {
189
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "生日格式不正确")
190
+		return
191
+	}
192
+
193
+	timeLayout := "2006-01-02 15:04:05"
194
+	theTime, err := utils.ParseTimeStringToTime(timeLayout, birthday+" 00:00:00")
195
+	if err != nil {
196
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "生日格式不正确")
197
+		return
198
+	}
199
+
200
+	var staffbirthday = theTime.Unix()
201
+	fmt.Println("生日",staffbirthday)
202
+
203
+	userType := int64(dataBody["user_type"].(float64))
204
+
205
+	if userType <= 0 {
206
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "职称类型不正确")
207
+		return
208
+	}
209
+	userTitle :=int64(dataBody["user_title"].(float64))
210
+	if userTitle <= 0 {
211
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "职称名称不正确")
212
+		return
213
+	}
214
+	dochead := dataBody["dochead"].(string)
215
+	if len(dochead) == 0 {
216
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "头像不正确")
217
+		return
218
+	}
219
+	content := dataBody["content"].(string)
220
+	if len(content) == 0 {
221
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "头像不正确")
222
+		return
223
+	}
224
+
225
+	fmt.Println("姓名",staffname,"性别" ,gender,"生日",staffbirthday,"职称类型",userType,"职称名称",userTitle,"头像",dochead,"内容",content)
226
+
227
+	StaffInfo := models.SgjUserStaffInfo{
228
+		Name:      staffname,
229
+		Phone:     phone,
230
+		Birthday:  staffbirthday,
231
+		Gender:gender,
232
+		Content:content,
233
+		UserType:  userType,
234
+		UserTitle: userTitle,
235
+		Dochead:   dochead,
236
+		Status: 1,
237
+		UserOrgId:userOrgID,
238
+		Mtime:time.Now().Unix(),
239
+	}
240
+	fmt.Println(StaffInfo)
241
+	staff_service.UpdateStaffInfo(StaffInfo,userOrgID,id)
242
+	this.ServeSuccessJSON(map[string]interface{}{
243
+		"userStaffInfo":StaffInfo,
244
+	})
245
+}
246
+
247
+func (this *StaffManage) DeleteStaffs()  {
248
+	adminUserInfo := this.GetAdminUserInfo()
249
+	OrgID := adminUserInfo.CurrentOrgId
250
+	dataBody := make(map[string]interface{}, 0)
251
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
252
+	if err != nil {
253
+		utils.ErrorLog(err.Error())
254
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
255
+		return
256
+	}
257
+
258
+	idsInters := dataBody["ids"].([]interface{})
259
+	if len(idsInters) == 0 {
260
+		if err != nil {
261
+			this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除会员失败:(没有选择会员)")
262
+			return
263
+		}
264
+	}
265
+
266
+	ids := make([]int64, 0)
267
+	for _, idsInter := range idsInters {
268
+		id := int64(idsInter.(float64))
269
+		ids = append(ids, id)
270
+	}
271
+
272
+	err = staff_service.DeleteStaffs(OrgID, ids)
273
+	fmt.Println("错误",err)
274
+	if err != nil {
275
+		this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败:("+err.Error()+")")
276
+		return
277
+	}
278
+	returnData := make(map[string]interface{}, 0)
279
+	returnData["msg"] = "ok"
280
+	this.ServeSuccessJSON(returnData)
281
+	return
150
 }
282
 }

+ 19 - 14
models/article_models.go 查看文件

69
 }
69
 }
70
 
70
 
71
 type Parents struct {
71
 type Parents struct {
72
-	ID                int64  `gorm:"-" json:"id"`
73
-	ArticleId         int64  `gorm:"-" json:"article_id"`
74
-	CommentUserId     int64  `gorm:"-" json:"comment_user_id"`
75
-	ParentId          int64  `gorm:"-" json:"parent_id"`
76
-	Content           string `gorm:"-" json:"content"`
77
-	Ctime             int64  `gorm:"-" json:"ctime"`
78
-	Mtime             int64  `gorm:"-" json:"mtime"`
79
-	Status            int64  `gorm:"-" json:"status"`
80
-	StarNum           int64  `gorm:"-" json:"star_num"`
81
-	CommentNum        int64  `gorm:"-" json:"comment_num"`
82
-	CommentId         int64  `gorm:"-" json:"comment_id"`
83
-	CommentUserName   string `gorm:"-" json:"comment_user_name"`
84
-	CommentUserAvater string `gorm:"-" json:"comment_user_avater"`
85
-	CommentTime       string `gorm:"-" json:"commentTime"`
72
+	ID int64 `gorm:"column:id" json:"id" form:"id"`
73
+	ArticleId int64 `gorm:"column:article_id" json:"article_id" form:"article_id"`
74
+	CommentUserId int64 `gorm:"column:comment_user_id" json:"comment_user_id" form:"comment_user_id"`
75
+	ParentId int64 `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
76
+	Content string `gorm:"column:content" json:"content" form:"content"`
77
+	Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
78
+	Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
79
+	Status int64 `gorm:"column:status" json:"status" form:"status"`
80
+	StarNum int64 `gorm:"column:star_num" json:"star_num" form:"star_num"`
81
+	CommentNum int64 `gorm:"column:comment_num" json:"comment_num" form:"comment_num"`
82
+	CommentId int64 `gorm:"column:comment_id" json:"comment_id" form:"comment_id"`
83
+	CommentUserName string `gorm:"column:comment_user_name" json:"comment_user_name" form:"comment_user_name"`
84
+	CommentUserAvater string `gorm:"column:comment_user_avater" json:"comment_user_avater" form:"comment_user_avater"`
85
+	Source int64 `gorm:"column:source" json:"source" form:"source"`
86
+	Ttid int64 `gorm:"column:ttid" json:"ttid" form:"ttid"`
87
+	TuserId int64 `gorm:"column:tuser_id" json:"tuser_id" form:"tuser_id"`
88
+	Taid int64 `gorm:"column:taid" json:"taid" form:"taid"`
89
+	Tpid int64 `gorm:"column:tpid" json:"tpid" form:"tpid"`
90
+	Tcid int64 `gorm:"column:tcid" json:"tcid" form:"tcid"`
86
 }
91
 }
87
 
92
 
88
 func (Comment) TableName() string {
93
 func (Comment) TableName() string {

+ 38 - 1
service/article_service/article_category_service.go 查看文件

5
 	"SCRM/service"
5
 	"SCRM/service"
6
 	"fmt"
6
 	"fmt"
7
 	"github.com/jinzhu/gorm"
7
 	"github.com/jinzhu/gorm"
8
-
9
 	"time"
8
 	"time"
10
 )
9
 )
11
 
10
 
198
 	return
197
 	return
199
 }
198
 }
200
 
199
 
200
+func DeleteArticles(id int64,orgID int64)( err error)  {
201
+	err =service.PatientWriteDB().Model(&models.Articles{}).Where("id = ? and user_org_id = ?", id, orgID).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
202
+	return
203
+}
204
+
201
 func GetMenus(OrgID int64)(categorys []*models.ArticleCategory,err error)  {
205
 func GetMenus(OrgID int64)(categorys []*models.ArticleCategory,err error)  {
202
 	err = service.PatientReadDB().Where("user_org_id = ?", OrgID).Find(&categorys).Error
206
 	err = service.PatientReadDB().Where("user_org_id = ?", OrgID).Find(&categorys).Error
203
 	return  categorys ,err
207
 	return  categorys ,err
243
 	article.PublicTime = tm.Format("2006-01-02 15:04:05")
247
 	article.PublicTime = tm.Format("2006-01-02 15:04:05")
244
 	return article, err
248
 	return article, err
245
 }
249
 }
250
+
251
+func FindAllComments(page int64,limit int64,articleId int64)(comment []*models.Comment,total int64,err error)  {
252
+	db := service.PatientReadDB().Table("sgj_patient_articles_comment as a").Where("a.status = 1")
253
+	offset := (page - 1) * limit
254
+	err = db.Where("article_id = ? AND parent_id = ?", articleId, 0).Count(&total).Order("a.ctime desc").Offset(offset).Limit(limit).
255
+		Select("a.id,a.article_id,a.comment_user_id,a.parent_id,a.content,a.ctime,a.status,a.star_num,a.comment_num,a.comment_id,a.comment_user_name,a.comment_user_avater,a.source,a.ttid,a.tuser_id,a.taid,a.tpid,a.tcid").Find(&comment).Error
256
+	fmt.Println("err是啥呢?",err)
257
+	if err != nil {
258
+		return
259
+	}
260
+	return
261
+}
262
+
263
+func AddComment(comment *models.Comment)(error)  {
264
+	err := service.PatientReadDB().Create(comment).Error
265
+	return  err
266
+}
267
+
268
+func GetReplyAllComents(page int64,limit int64)(comment []*models.Comment,total int64,err error)  {
269
+	db := service.PatientReadDB().Table("sgj_patient_articles_comment as a").Where("a.status = 1")
270
+	offset := (page - 1) * limit
271
+	err = db.Count(&total).Order("a.ctime desc").Offset(offset).Limit(limit).
272
+		Select("a.id,a.article_id,a.comment_user_id,a.parent_id,a.content,a.ctime,a.status,a.star_num,a.comment_num,a.comment_id,a.comment_user_name,a.comment_user_avater,a.source,a.ttid,a.tuser_id,a.taid,a.tpid,a.tcid").Find(&comment).Error
273
+	fmt.Println("err是啥呢?",err)
274
+	if err != nil {
275
+		return
276
+	}
277
+	return
278
+}
279
+
280
+
281
+
282
+

+ 14 - 1
service/staff_service/staff_manager_service.go 查看文件

3
 import (
3
 import (
4
 	"SCRM/models"
4
 	"SCRM/models"
5
 	"SCRM/service"
5
 	"SCRM/service"
6
+	"time"
6
 )
7
 )
7
 
8
 
8
 func AddStaffInfo(info models.SgjUserStaffInfo) error  {
9
 func AddStaffInfo(info models.SgjUserStaffInfo) error  {
19
 
20
 
20
 	if len(keyword) >0{
21
 	if len(keyword) >0{
21
 		keyword = "%" + keyword + "%"
22
 		keyword = "%" + keyword + "%"
22
-		db.Where("s.name LIKE ? AND s.user_title LIEK ?",keyword,keyword)
23
+		db =db.Where("s.name LIKE ?",keyword)
23
 	}
24
 	}
24
 
25
 
25
 	offset := (page - 1) * limit
26
 	offset := (page - 1) * limit
32
 	return
33
 	return
33
 }
34
 }
34
 
35
 
36
+func UpdateStaffInfo(info models.SgjUserStaffInfo,OrgID int64,id int64)  {
37
+	 service.UserWriteDB().Model(info).Where("user_org_id = ? AND id =? AND status = ?",OrgID,id,1).Update(map[string]interface{}{"Name":info.Name,"phone":info.Phone,"birthday":info.Birthday,"gender":info.Gender,"user_type":info.UserType,"user_title":info.UserTitle,"dochead":info.Dochead,"content":info.Content,"mtime":info.Mtime})
38
+}
39
+
40
+func DeleteStaffs(orgID int64,ids[] int64)(err error) {
41
+	if len(ids) ==1{
42
+		err =	service.UserWriteDB().Model(&models.SgjUserStaffInfo{}).Where( "id=? and user_org_id = ?",ids[0],orgID).Update(map[string]interface{}{"Status":0,"mtime":time.Now().Unix()}).Error
43
+	}else {
44
+		err =	service.UserWriteDB().Model(&models.SgjUserStaffInfo{}).Where("id IN (?) and user_org_id = ?",ids,orgID).Update(map[string]interface{}{"Status":0,"mtime":time.Now().Unix()}).Error
45
+	}
46
+	return
47
+}