|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- 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).AllCols().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
- }
|