This commit is contained in:
Leufolium 2024-07-19 08:43:30 +08:00
parent 9b0b943691
commit 98c6ef4f36
5 changed files with 46 additions and 80 deletions

View File

@ -26,7 +26,7 @@ type ApiListReq struct {
}
type ApiListData struct {
*dbstruct.RavenIQTest
*ApiListVO
}
type ApiListResp struct {

View File

@ -0,0 +1,39 @@
package controller
import (
"service/api/errcode"
Raven_IQ_testproto "service/api/proto/Raven_IQ_test/proto"
"service/app/mix/service"
"service/bizcommon/util"
"service/library/logger"
"github.com/gin-gonic/gin"
)
func ApiCreateRavenIQTest(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*Raven_IQ_testproto.ApiCreateReq)
ec := service.DefaultService.ApiCreateRavenIQTest(ctx, req)
if ec != errcode.ErrCodeRavenIQTestSrvOk {
logger.Error("ApiCreateRavenIQTest fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrorMsg(ctx, "server error")
return
}
ReplyOk(ctx, nil)
}
func ApiGetRavenIQTestList(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*Raven_IQ_testproto.ApiListReq)
vo, ec := service.DefaultService.ApiGetRavenIQTestList(ctx, req)
if ec != errcode.ErrCodeRavenIQTestSrvOk {
logger.Error("ApiGetRavenIQTestList fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrCodeMsg(ctx, ec)
return
}
data := &Raven_IQ_testproto.ApiListData{
ApiListVO: vo,
}
ReplyOk(ctx, data)
}

View File

@ -1,8 +0,0 @@
Raven_IQ_testproto "service/api/proto/Raven_IQ_test/proto"
// 瑞文智商测试表
opRavenIQTestGroup := r.Group("/api/Raven_IQ_test", PrepareToC())
opRavenIQTestGroup.POST("create", middleware.JSONParamValidator(Raven_IQ_testproto.OpCreateReq{}), middleware.JwtAuthenticator(), OpCreateRavenIQTest)
opRavenIQTestGroup.POST("update", middleware.JSONParamValidator(Raven_IQ_testproto.OpUpdateReq{}), middleware.JwtAuthenticator(), OpUpdateRavenIQTest)
opRavenIQTestGroup.POST("delete", middleware.JSONParamValidator(Raven_IQ_testproto.OpDeleteReq{}), middleware.JwtAuthenticator(), OpDeleteRavenIQTest)
opRavenIQTestGroup.POST("list", middleware.JSONParamValidator(Raven_IQ_testproto.OpListReq{}), middleware.JwtAuthenticator(), OpGetRavenIQTestList)

View File

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

View File

@ -19,6 +19,7 @@ import (
"service/api/base"
"service/api/consts"
"service/api/errcode"
Raven_IQ_testproto "service/api/proto/Raven_IQ_test/proto"
accountproto "service/api/proto/account/proto"
account_cancellationproto "service/api/proto/account_cancellation/proto"
accountpunishmentproto "service/api/proto/accountpunishment/proto"
@ -269,6 +270,11 @@ func Init(r *gin.Engine) {
apiHvyogoGroup.POST("single_distribute", middleware.JSONParamValidator(hvyogoproto.ApiSingleDistributeReq{}), middleware.JwtAuthenticator(), middleware.RequestDecryptor(), ApiHvyogoSingleDistribute)
apiHvyogoGroup.POST("worker_update", middleware.JSONParamValidator(hvyogoproto.ApiWorkerUpdateReq{}), middleware.JwtAuthenticator(), middleware.RequestDecryptor(), ApiHvyogoWorkerUpdate)
// 瑞文智商测试表
apiRavenIQTestGroup := r.Group("/api/Raven_IQ_test", PrepareToC())
apiRavenIQTestGroup.POST("create", middleware.JSONParamValidator(Raven_IQ_testproto.ApiCreateReq{}), ApiCreateRavenIQTest)
apiRavenIQTestGroup.POST("list", middleware.JSONParamValidator(Raven_IQ_testproto.ApiListReq{}), ApiGetRavenIQTestList)
// =============================== 以下是服务,只允许内网调用 ===============================
// op相关直接调用服务不调用gateway