service/vendor/app/mix/controller/feedback_op.go

74 lines
1.8 KiB
Go

package controller
import (
"service/api/consts"
"service/api/errcode"
feedbackproto "service/api/proto/feedback/proto"
"service/app/mix/service"
"service/bizcommon/util"
"service/library/logger"
"github.com/gin-gonic/gin"
)
func OpCreateFeedback(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*feedbackproto.OpCreateReq)
ec := service.DefaultService.OpCreateFeedback(ctx, req)
if ec != errcode.ErrCodeFeedbackSrvOk {
logger.Error("OpCreateFeedback fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrorMsg(ctx, "server error")
return
}
ReplyOk(ctx, nil)
}
func OpUpdateFeedback(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*feedbackproto.OpUpdateReq)
ec := service.DefaultService.OpUpdateFeedback(ctx, req)
if ec != errcode.ErrCodeFeedbackSrvOk {
logger.Error("OpUpdateFeedback fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrCodeMsg(ctx, ec)
return
}
ReplyOk(ctx, nil)
}
func OpDeleteFeedback(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*feedbackproto.OpDeleteReq)
ec := service.DefaultService.OpDeleteFeedback(ctx, req.Id)
if ec != errcode.ErrCodeFeedbackSrvOk {
logger.Error("OpDeleteFeedback fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrCodeMsg(ctx, ec)
return
}
ReplyOk(ctx, nil)
}
func OpGetFeedbackList(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*feedbackproto.OpListReq)
//设置默认页长
if req.Limit == 0 {
req.Limit = consts.DefaultPageSize
}
list, ec := service.DefaultService.OpGetFeedbackList(ctx, req)
if ec != errcode.ErrCodeFeedbackSrvOk {
logger.Error("OpGetFeedbackList fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrCodeMsg(ctx, ec)
return
}
data := &feedbackproto.OpListData{
List: list,
Offset: req.Offset + len(list),
}
if len(list) >= req.Limit {
data.More = 1
}
ReplyOk(ctx, data)
}