service/app/mix/controller/Raven_IQ_test_visit_api.go

43 lines
1.3 KiB
Go
Raw Normal View History

2024-10-16 17:25:37 +08:00
package controller
import (
2024-10-22 15:36:18 +08:00
"service/api/consts"
2024-10-16 17:25:37 +08:00
"service/api/errcode"
Raven_IQ_test_visitproto "service/api/proto/Raven_IQ_test_visit/proto"
"service/app/mix/service"
"service/bizcommon/util"
"service/library/logger"
"github.com/gin-gonic/gin"
)
func ApiCreateRavenIQTestVisit(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*Raven_IQ_test_visitproto.ApiCreateReq)
ec := service.DefaultService.ApiCreateRavenIQTestVisit(ctx, req)
if ec != errcode.ErrCodeRavenIQTestVisitSrvOk {
logger.Error("ApiCreateRavenIQTestVisit fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrorMsg(ctx, "server error")
return
}
ReplyOk(ctx, nil)
}
func ApiGetRavenIQTestVisitCount(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*Raven_IQ_test_visitproto.ApiCountReq)
2024-10-22 15:36:18 +08:00
countMap, ec := service.DefaultService.ApiGetRavenIQTestVisitCount(ctx, req)
2024-10-16 17:25:37 +08:00
if ec != errcode.ErrCodeRavenIQTestVisitSrvOk {
logger.Error("ApiCreateRavenIQTestVisit fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrCodeMsg(ctx, ec)
return
}
data := &Raven_IQ_test_visitproto.ApiCountData{
2024-10-22 15:36:18 +08:00
VisitCount: countMap[consts.RavenIQTest_VType_Visit],
PaidCount: countMap[consts.RavenIQTest_VType_Paid],
2024-10-22 15:53:41 +08:00
TotalCount: countMap[consts.RavenIQTest_VType_Visit] + countMap[consts.RavenIQTest_VType_Paid],
2024-10-16 17:25:37 +08:00
}
ReplyOk(ctx, data)
}