Sfoglia il codice sorgente

文章列表,文章评论bug修改

xiaoming_global 5 anni fa
parent
commit
ceccd92712

+ 69 - 0
controllers/article/article_controller.go Vedi File

@@ -49,6 +49,8 @@ func ArticleRouters() {
49 49
 	beego.Router("/api/article/deleteComments",&ArticleManage{},"Delete:DeleteComments")
50 50
 	beego.Router("/api/acticle/getEditVidoInfo",&ArticleManage{},"Get:GetVidoInfo")
51 51
     beego.Router("/api/acticle/savevidodraft",&ArticleManage{},"Post:SaveVidoDraft")
52
+	beego.Router("/api/article/openDeleteReply",&ArticleManage{},"Delete:DeleteAllReply")
53
+	beego.Router("/api/article/deleteAllArticles",&ArticleManage{},"Delete:DeleteAllArticles")
52 54
 }
53 55
 
54 56
 type ArticleManage struct {
@@ -1284,4 +1286,71 @@ func (this * ArticleManage) SaveVidoDraft()  {
1284 1286
 	this.ServeSuccessJSON(map[string]interface{}{
1285 1287
 		"articls":articles,
1286 1288
 	})
1289
+}
1290
+
1291
+func (this *ArticleManage) DeleteAllReply()  {
1292
+	dataBody := make(map[string]interface{}, 0)
1293
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
1294
+	if err != nil {
1295
+		utils.ErrorLog(err.Error())
1296
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
1297
+		return
1298
+	}
1299
+	idsInters := dataBody["ids"].([]interface{})
1300
+	if len(idsInters) == 0 {
1301
+		if err != nil {
1302
+			this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除评论失败:(没有选择评论)")
1303
+			return
1304
+		}
1305
+	}
1306
+
1307
+	ids := make([]int64, 0)
1308
+	for _, idsInter := range idsInters {
1309
+		id := int64(idsInter.(float64))
1310
+		ids = append(ids, id)
1311
+	}
1312
+     fmt.Println("ids是什么",ids)
1313
+	err = article_service.DeleteAllReply(ids)
1314
+
1315
+	if err !=nil{
1316
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除失败")
1317
+		return
1318
+	}
1319
+	returnData := make(map[string]interface{}, 0)
1320
+	returnData["msg"] = "ok"
1321
+	this.ServeSuccessJSON(returnData)
1322
+	return
1323
+}
1324
+
1325
+func (this *ArticleManage) DeleteAllArticles()  {
1326
+	dataBody := make(map[string]interface{}, 0)
1327
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
1328
+	if err != nil {
1329
+		utils.ErrorLog(err.Error())
1330
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
1331
+		return
1332
+	}
1333
+	idsInters := dataBody["ids"].([]interface{})
1334
+	if len(idsInters) == 0 {
1335
+		if err != nil {
1336
+			this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除评论失败:(没有选择评论)")
1337
+			return
1338
+		}
1339
+	}
1340
+
1341
+	ids := make([]int64, 0)
1342
+	for _, idsInter := range idsInters {
1343
+		id := int64(idsInter.(float64))
1344
+		ids = append(ids, id)
1345
+	}
1346
+	fmt.Println("ids是什么",ids)
1347
+	err = article_service.DeleteAllArticles(ids)
1348
+	if err !=nil{
1349
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除失败")
1350
+		return
1351
+	}
1352
+	returnData := make(map[string]interface{}, 0)
1353
+	returnData["msg"] = "ok"
1354
+	this.ServeSuccessJSON(returnData)
1355
+	return
1287 1356
 }

+ 19 - 0
service/article_service/article_category_service.go Vedi File

@@ -307,3 +307,22 @@ func GetQueryReplyInfo(parentid int64,articleID int64)([]models.Comment,error)
307 307
 }
308 308
 
309 309
 
310
+func DeleteAllReply(ids[] int64)(err error)  {
311
+	if len(ids) ==1{
312
+		err =	service.PatientWriteDB().Model(&models.Comment{}).Where( "id=?",ids[0]).Update(map[string]interface{}{"status":0,"mtime":time.Now().Unix()}).Error
313
+	}else {
314
+		err =	service.PatientWriteDB().Model(&models.Comment{}).Where("id IN (?)",ids).Update(map[string]interface{}{"status":0,"mtime":time.Now().Unix()}).Error
315
+	}
316
+	return
317
+}
318
+
319
+func DeleteAllArticles(ids[] int64)(err error)  {
320
+	if len(ids) ==1{
321
+		err =	service.PatientWriteDB().Model(&models.Articles{}).Where( "id=?",ids[0]).Update(map[string]interface{}{"status":0,"mtime":time.Now().Unix()}).Error
322
+	}else {
323
+		err =	service.PatientWriteDB().Model(&models.Articles{}).Where("id IN (?)",ids).Update(map[string]interface{}{"status":0,"mtime":time.Now().Unix()}).Error
324
+	}
325
+	return
326
+}
327
+
328
+