|
- package user_feedback
-
- import (
- "applet/app/db"
- "applet/app/e"
- "applet/app/md"
- "applet/app/utils"
- "code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
- "code.fnuoos.com/EggPlanet/egg_models.git/src/model"
- "github.com/gin-gonic/gin"
- )
-
- func CateList(c *gin.Context) {
- var req *md.UserFeedbackCateListReq
- if err := c.ShouldBindJSON(&req); err != nil {
- e.OutErr(c, e.ERR_INVALID_ARGS, err)
- return
- }
- var resp md.UserFeedbackCateListResp
- noticeList := make([]md.UserFeedbackCateList, 0)
- NewJpushNoticeDb := implement.NewUserFeedbackCateDb(db.Db)
- notice, total, _ := NewJpushNoticeDb.FindUserFeedbackCateAndTotal(req.Page, req.Limit)
- resp.Total = total
- if notice != nil {
- for _, v := range *notice {
- tmp := md.UserFeedbackCateList{
- Id: utils.IntToStr(v.Id),
- Sort: utils.IntToStr(v.Sort),
- Name: v.Name,
- }
- noticeList = append(noticeList, tmp)
- }
- }
- resp.List = noticeList
- e.OutSuc(c, resp, nil)
- return
- }
- func CateSave(c *gin.Context) {
- var req *md.UserFeedbackCateSaveReq
- if err := c.ShouldBindJSON(&req); err != nil {
- e.OutErr(c, e.ERR_INVALID_ARGS, err)
- return
- }
- var data = new(model.UserFeedbackCate)
- if utils.StrToInt(req.Id) > 0 {
- NewUserFeedbackCateDb := implement.NewUserFeedbackCateDb(db.Db)
- notice, _ := NewUserFeedbackCateDb.GetUserFeedbackCate(req.Id)
- if notice == nil {
- e.OutErr(c, 400, e.NewErr(400, "记录不存在"))
- return
- }
- data = notice
- } else {
- db.Db.Insert(data)
- }
- data.Name = req.Name
- data.Sort = utils.StrToInt(req.Sort)
- db.Db.Where("id=?", data.Id).Update(data)
- e.OutSuc(c, "success", nil)
- return
- }
- func CateDel(c *gin.Context) {
- var req *md.UserFeedbackCateDelReq
- if err := c.ShouldBindJSON(&req); err != nil {
- e.OutErr(c, e.ERR_INVALID_ARGS, err)
- return
- }
- db.Db.In("id", req.Id).Delete(&model.UserFeedbackCate{})
- e.OutSuc(c, "success", nil)
- return
- }
|