蛋蛋星球 后台端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

svc_cate.go 1.8 KiB

3 days ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. package user_feedback
  2. import (
  3. "applet/app/db"
  4. "applet/app/e"
  5. "applet/app/md"
  6. "applet/app/utils"
  7. "code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
  8. "code.fnuoos.com/EggPlanet/egg_models.git/src/model"
  9. "github.com/gin-gonic/gin"
  10. )
  11. func CateList(c *gin.Context) {
  12. var req *md.UserFeedbackCateListReq
  13. if err := c.ShouldBindJSON(&req); err != nil {
  14. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  15. return
  16. }
  17. var resp md.UserFeedbackCateListResp
  18. noticeList := make([]md.UserFeedbackCateList, 0)
  19. NewJpushNoticeDb := implement.NewUserFeedbackCateDb(db.Db)
  20. notice, total, _ := NewJpushNoticeDb.FindUserFeedbackCateAndTotal(req.Page, req.Limit)
  21. resp.Total = total
  22. if notice != nil {
  23. for _, v := range *notice {
  24. tmp := md.UserFeedbackCateList{
  25. Id: utils.IntToStr(v.Id),
  26. Sort: utils.IntToStr(v.Sort),
  27. Name: v.Name,
  28. }
  29. noticeList = append(noticeList, tmp)
  30. }
  31. }
  32. resp.List = noticeList
  33. e.OutSuc(c, resp, nil)
  34. return
  35. }
  36. func CateSave(c *gin.Context) {
  37. var req *md.UserFeedbackCateSaveReq
  38. if err := c.ShouldBindJSON(&req); err != nil {
  39. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  40. return
  41. }
  42. var data = new(model.UserFeedbackCate)
  43. if utils.StrToInt(req.Id) > 0 {
  44. NewUserFeedbackCateDb := implement.NewUserFeedbackCateDb(db.Db)
  45. notice, _ := NewUserFeedbackCateDb.GetUserFeedbackCate(req.Id)
  46. if notice == nil {
  47. e.OutErr(c, 400, e.NewErr(400, "记录不存在"))
  48. return
  49. }
  50. data = notice
  51. } else {
  52. db.Db.Insert(data)
  53. }
  54. data.Name = req.Name
  55. data.Sort = utils.StrToInt(req.Sort)
  56. db.Db.Where("id=?", data.Id).AllCols().Update(data)
  57. e.OutSuc(c, "success", nil)
  58. return
  59. }
  60. func CateDel(c *gin.Context) {
  61. var req *md.UserFeedbackCateDelReq
  62. if err := c.ShouldBindJSON(&req); err != nil {
  63. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  64. return
  65. }
  66. db.Db.In("id", req.Id).Delete(&model.UserFeedbackCate{})
  67. e.OutSuc(c, "success", nil)
  68. return
  69. }