service/app/mix/controller/contact_customer_service_ap...

54 lines
1.5 KiB
Go
Raw Permalink Normal View History

2023-12-21 22:17:40 +08:00
package controller
import (
"service/api/consts"
"service/api/errcode"
contact_customer_serviceproto "service/api/proto/contact_customer_service/proto"
"service/app/mix/service"
"service/bizcommon/util"
"service/library/logger"
"github.com/gin-gonic/gin"
)
func ApiCreateContactCustomerService(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*contact_customer_serviceproto.ApiCreateReq)
2024-07-26 12:58:48 +08:00
isAutoResponsed, ec := service.DefaultService.ApiCreateContactCustomerService(ctx, req)
2023-12-21 22:17:40 +08:00
if ec != errcode.ErrCodeContactCustomerServiceSrvOk {
logger.Error("OpCreateContactCustomerService fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrorMsg(ctx, "server error")
return
}
2024-07-26 12:58:48 +08:00
data := &contact_customer_serviceproto.ApiCreateData{
IsAutoResponsed: isAutoResponsed,
}
ReplyOk(ctx, data)
2023-12-21 22:17:40 +08:00
}
2023-12-23 22:03:53 +08:00
func ApiGetContactCustomerServiceListBySessionId(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*contact_customer_serviceproto.ApiListBySessionIdReq)
2023-12-21 22:17:40 +08:00
//设置默认页长
if req.Limit == 0 {
req.Limit = consts.DefaultPageSize
}
2023-12-23 22:03:53 +08:00
list, ec := service.DefaultService.ApiGetContactCustomerServiceListBySessionId(ctx, req)
2023-12-21 22:17:40 +08:00
if ec != errcode.ErrCodeContactCustomerServiceSrvOk {
2023-12-23 22:03:53 +08:00
logger.Error("OpGetContactCustomerServiceListBySessionId fail, req: %v, ec: %v", util.ToJson(req), ec)
2023-12-21 22:17:40 +08:00
ReplyErrCodeMsg(ctx, ec)
return
}
2023-12-23 22:03:53 +08:00
data := &contact_customer_serviceproto.ApiListBySessionIdData{
2023-12-21 22:17:40 +08:00
List: list,
Offset: req.Offset + len(list),
}
if len(list) >= req.Limit {
data.More = 1
}
ReplyOk(ctx, data)
}