86 lines
2.2 KiB
Go
86 lines
2.2 KiB
Go
package controller
|
|
|
|
import (
|
|
"service/api/consts"
|
|
"service/api/errcode"
|
|
zonemomentproto "service/api/proto/zonemoment/proto"
|
|
"service/app/mix/service"
|
|
"service/bizcommon/util"
|
|
"service/library/logger"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func OpCreateZoneMoment(ctx *gin.Context) {
|
|
req := ctx.MustGet("client_req").(*zonemomentproto.OpCreateReq)
|
|
ec := service.DefaultService.OpCreateZoneMoment(ctx, req)
|
|
if ec != errcode.ErrCodeZoneMomentSrvOk {
|
|
logger.Error("OpCreateZoneMoment fail, req: %v, ec: %v", util.ToJson(req), ec)
|
|
ReplyErrorMsg(ctx, "server error")
|
|
return
|
|
}
|
|
|
|
ReplyOk(ctx, nil)
|
|
}
|
|
|
|
func OpUpdateZoneMoment(ctx *gin.Context) {
|
|
req := ctx.MustGet("client_req").(*zonemomentproto.OpUpdateReq)
|
|
ec := service.DefaultService.OpUpdateZoneMoment(ctx, req)
|
|
if ec != errcode.ErrCodeZoneMomentSrvOk {
|
|
logger.Error("OpUpdateZoneMoment fail, req: %v, ec: %v", util.ToJson(req), ec)
|
|
ReplyErrCodeMsg(ctx, ec)
|
|
return
|
|
}
|
|
|
|
ReplyOk(ctx, nil)
|
|
}
|
|
|
|
func OpDeleteZoneMoment(ctx *gin.Context) {
|
|
req := ctx.MustGet("client_req").(*zonemomentproto.OpDeleteReq)
|
|
ec := service.DefaultService.OpDeleteZoneMoment(ctx, util.DerefInt64(req.Id))
|
|
if ec != errcode.ErrCodeZoneMomentSrvOk {
|
|
logger.Error("OpDeleteZoneMoment fail, req: %v, ec: %v", util.ToJson(req), ec)
|
|
ReplyErrCodeMsg(ctx, ec)
|
|
return
|
|
}
|
|
|
|
ReplyOk(ctx, nil)
|
|
}
|
|
|
|
func OpGetZoneMomentList(ctx *gin.Context) {
|
|
req := ctx.MustGet("client_req").(*zonemomentproto.OpListReq)
|
|
|
|
//设置默认页长
|
|
if req.Limit == 0 {
|
|
req.Limit = consts.DefaultPageSize
|
|
}
|
|
|
|
list, ec := service.DefaultService.OpGetZoneMomentList(ctx, req)
|
|
if ec != errcode.ErrCodeZoneMomentSrvOk {
|
|
logger.Error("OpGetZoneMomentList fail, req: %v, ec: %v", util.ToJson(req), ec)
|
|
ReplyErrCodeMsg(ctx, ec)
|
|
return
|
|
}
|
|
|
|
data := &zonemomentproto.OpListData{
|
|
List: list,
|
|
Offset: req.Offset + len(list),
|
|
}
|
|
if len(list) >= req.Limit {
|
|
data.More = 1
|
|
}
|
|
ReplyOk(ctx, data)
|
|
}
|
|
|
|
func OpReviewZoneMoment(ctx *gin.Context) {
|
|
req := ctx.MustGet("client_req").(*zonemomentproto.OpReviewReq)
|
|
ec := service.DefaultService.OpReviewZoneMoment(ctx, req)
|
|
if ec != errcode.ErrCodeZoneMomentSrvOk {
|
|
logger.Error("OpReviewZoneMoment fail, req: %v, ec: %v", util.ToJson(req), ec)
|
|
ReplyErrCodeMsg(ctx, ec)
|
|
return
|
|
}
|
|
|
|
ReplyOk(ctx, nil)
|
|
}
|