Merge branch 'feat-IRONFANS-231-Robin' into conf-IRONFANS-231

This commit is contained in:
Leufolium 2024-10-16 17:32:52 +08:00
commit 76574c4e18
16 changed files with 425 additions and 9 deletions

View File

@ -100,3 +100,8 @@ const (
)
const ZoneAdmissionPrice_NoZone = int64(-999999)
const (
RavenIQTestVisit_PV = 0
RavenIQTestVisit_UV = 1
)

View File

@ -259,6 +259,9 @@ var ErrCodeMsgMap = map[ErrCode]string{
ErrCodeRavenIQTestSrvFail: "瑞文智商测试表服务错误",
ErrCodeRavenIQTestNotExist: "瑞文智商测试表不存在",
ErrCodeRavenIQTestQuestionNotExist: "瑞文智商测试表题目不存在",
ErrCodeRavenIQTestVisitSrvFail: "瑞文智商测试访问表服务错误",
ErrCodeRavenIQTestVisitNotExist: "瑞文智商测试访问表不存在",
}
const (
@ -627,4 +630,9 @@ const (
ErrCodeRavenIQTestSrvFail ErrCode = -101001 // 瑞文智商测试表服务错误
ErrCodeRavenIQTestNotExist ErrCode = -101002 // 瑞文智商测试表不存在
ErrCodeRavenIQTestQuestionNotExist ErrCode = -101003 // 瑞文智商测试表题目不存在
// RavenIQTestVisit: 102xxx
ErrCodeRavenIQTestVisitSrvOk ErrCode = ErrCodeOk
ErrCodeRavenIQTestVisitSrvFail ErrCode = -102001 // 瑞文智商测试访问表服务错误
ErrCodeRavenIQTestVisitNotExist ErrCode = -102002 // 瑞文智商测试访问表不存在
)

View File

@ -0,0 +1,70 @@
package proto
import (
"service/api/base"
"service/dbstruct"
)
// op 创建
type ApiCreateReq struct {
base.BaseRequest
*dbstruct.RavenIQTestVisit
}
type ApiCreateData struct {
}
type ApiCreateResp struct {
base.BaseResponse
Data *ApiCreateData `json:"data"`
}
// op 删除
type ApiDeleteReq struct {
base.BaseRequest
Id int64 `json:"id"`
}
type ApiDeleteData struct {
}
type ApiDeleteResp struct {
base.BaseResponse
Data *ApiDeleteData `json:"data"`
}
// op 列表
type ApiListReq struct {
base.BaseRequest
Offset int `json:"offset"`
Limit int `json:"limit"`
}
type ApiListData struct {
List []*dbstruct.RavenIQTestVisit `json:"list"`
Offset int `json:"offset"`
More int `json:"more"`
}
type ApiListResp struct {
base.BaseResponse
Data *ApiListData `json:"data"`
}
// op 计数
type ApiCountReq struct {
base.BaseRequest
VType *int64 `json:"v_type" bson:"v_type"` // 访问类型
CType *int64 `json:"c_type" bson:"c_type"` // 计数类型
CtLowerBound *int64 `json:"ct_lb" bson:"ct_lb"` // 访问时间下界
CtUpperBound *int64 `json:"ct_ub" bson:"ct_ub"` // 访问时间上界
}
type ApiCountData struct {
Count int64 `json:"count" bson:"count"`
}
type ApiCountResp struct {
base.BaseResponse
Data *ApiCountData `json:"data"`
}

View File

@ -0,0 +1,52 @@
package proto
import (
"service/api/base"
"service/dbstruct"
)
// op 创建
type OpCreateReq struct {
base.BaseRequest
*dbstruct.RavenIQTestVisit
}
type OpCreateData struct {
}
type OpCreateResp struct {
base.BaseResponse
Data *OpCreateData `json:"data"`
}
// op 删除
type OpDeleteReq struct {
base.BaseRequest
Id int64 `json:"id"`
}
type OpDeleteData struct {
}
type OpDeleteResp struct {
base.BaseResponse
Data *OpDeleteData `json:"data"`
}
// op 计数
type OpCountReq struct {
base.BaseRequest
VType *int64 `json:"v_type" bson:"v_type"` // 访问类型
CType *int64 `json:"c_type" bson:"c_type"` // 计数类型
CtLowerBound *int64 `json:"ct_lb" bson:"ct_lb"` // 访问时间下界
CtUpperBound *int64 `json:"ct_ub" bson:"ct_ub"` // 访问时间上界
}
type OpCountData struct {
Count int64 `json:"count" bson:"count"`
}
type OpCountResp struct {
base.BaseResponse
Data *OpCountData `json:"data"`
}

View File

@ -0,0 +1,22 @@
package proto
import (
"service/library/validator"
)
// op 创建
func (p *OpCreateReq) ProvideNotNullValue() (params []*validator.JsonParam) {
params = make([]*validator.JsonParam, 0)
params = append(params, validator.NewStringPtrParam("请确认用户id", p.RavenIQTestVisit.UserId))
params = append(params, validator.NewInt64PtrParam("请确认访问类型", p.RavenIQTestVisit.VType))
params = append(params, validator.NewInt64PtrParam("请确认访问时间", p.RavenIQTestVisit.Ct))
return
}
// op 计数
func (p *OpCountReq) ProvideNotNullValue() (params []*validator.JsonParam) {
params = make([]*validator.JsonParam, 0)
params = append(params, validator.NewInt64PtrParam("请确认访问类型", p.VType))
params = append(params, validator.NewInt64PtrParam("请确认计数类型", p.CType))
return
}

View File

@ -0,0 +1,39 @@
package controller
import (
"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)
count, ec := service.DefaultService.ApiGetRavenIQTestVisitCount(ctx, req)
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{
Count: count,
}
ReplyOk(ctx, data)
}

View File

@ -0,0 +1,23 @@
package controller
import (
"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 OpCreateRavenIQTestVisit(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*Raven_IQ_test_visitproto.OpCreateReq)
ec := service.DefaultService.OpCreateRavenIQTestVisit(ctx, req)
if ec != errcode.ErrCodeRavenIQTestVisitSrvOk {
logger.Error("OpCreateRavenIQTestVisit fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrorMsg(ctx, "server error")
return
}
ReplyOk(ctx, nil)
}

View File

@ -5,6 +5,7 @@ import (
"fmt"
"io/ioutil"
"net/http"
Raven_IQ_test_visitproto "service/api/proto/Raven_IQ_test_visit/proto"
imageaudittaskproto "service/api/proto/imageaudittask/proto"
mediaproto "service/api/proto/media/proto"
zonesessionproto "service/api/proto/zonesession/proto"
@ -310,6 +311,11 @@ func Init(r *gin.Engine) {
apiNotificationGroup.POST("read", middleware.JSONParamValidator(notificationproto.ApiReadReq{}), middleware.JwtAuthenticator(), ApiReadNotification)
apiNotificationGroup.POST("get_unread_count_by_mid", middleware.JSONParamValidator(notificationproto.ApiCountUnreadByMidReq{}), middleware.JwtAuthenticator(), ApiGetUnreadNotificationCountByMid)
// 瑞文智商测试访问表
apiRavenIQTestVisitGroup := r.Group("/api/Raven_IQ_test_visit", PrepareToC())
apiRavenIQTestVisitGroup.POST("create", middleware.JSONParamValidator(Raven_IQ_test_visitproto.OpCreateReq{}), ApiCreateRavenIQTestVisit)
apiRavenIQTestVisitGroup.POST("count", middleware.JSONParamValidator(Raven_IQ_test_visitproto.OpCountReq{}), ApiGetRavenIQTestVisitCount)
// =============================== 以下是服务,只允许内网调用 ===============================
// op相关直接调用服务不调用gateway

View File

@ -323,9 +323,13 @@ var WithdrawFreezeMidMap = map[int64]bool{
}
func isWithdrawFreeze(mid int64) bool {
_ = getWithdrawFreezeMidMap()
return WithdrawFreezeMidMap[mid]
m := getWithdrawFreezeMidMap()
freeze := false
if _, ok := m[mid]; ok {
freeze = true
}
logger.Info("isWithdrawFreeze mid: %v, freeze: %v", mid, freeze)
return freeze
}
// 任意额度提现

View File

@ -18,6 +18,7 @@ import (
options2 "go.mongodb.org/mongo-driver/mongo/options"
Raven_IQ_testproto "service/api/proto/Raven_IQ_test/proto"
Raven_IQ_test_visitproto "service/api/proto/Raven_IQ_test_visit/proto"
accountproto "service/api/proto/account/proto"
account_cancellationproto "service/api/proto/account_cancellation/proto"
accountpunishmentproto "service/api/proto/accountpunishment/proto"
@ -250,8 +251,9 @@ const (
DBRavenIQTest = "Raven_IQ_test"
COLRavenIQTest = "Raven_IQ_test"
DBHistory = "history"
COLHistory = "history"
DBHistory = "history"
COLHistory = "history"
COLRavenIQTestVisit = "Raven_IQ_test_visit"
)
// 商品表
@ -653,6 +655,11 @@ func (m *Mongo) getColRavenIQTest() *qmgo.Collection {
return m.clientMix.Database(DBRavenIQTest).Collection(COLRavenIQTest)
}
// 瑞文智商测试访问表表
func (m *Mongo) getColRavenIQTestVisit() *qmgo.Collection {
return m.clientMix.Database(DBRavenIQTest).Collection(COLRavenIQTestVisit)
}
// 商品相关
func (m *Mongo) CreateProduct(ctx *gin.Context, product *dbstruct.Product) error {
col := m.getColProduct()
@ -6442,3 +6449,58 @@ func (m *Mongo) GetRavenIQTestById(ctx *gin.Context, id int64) (*dbstruct.RavenI
}
return test, err
}
// 瑞文智商测试访问表相关
func (m *Mongo) CreateRavenIQTestVisit(ctx *gin.Context, Raven_IQ_test_visit *dbstruct.RavenIQTestVisit) error {
col := m.getColRavenIQTestVisit()
_, err := col.InsertOne(ctx, Raven_IQ_test_visit)
return err
}
func (m *Mongo) DeleteRavenIQTestVisit(ctx *gin.Context, id int64) error {
col := m.getColRavenIQTestVisit()
update := qmgo.M{
"$set": qmgo.M{
"del_flag": 1,
},
}
err := col.UpdateId(ctx, id, update)
return err
}
func (m *Mongo) GetRavenIQTestVisitCount(ctx *gin.Context, req *Raven_IQ_test_visitproto.OpCountReq) (int64, error) {
col := m.getColRavenIQTestVisit()
filterInClause := []qmgo.M{}
if req.CtLowerBound != nil {
filterInClause = append(filterInClause, qmgo.M{
"ct": qmgo.M{
"$gte": util.DerefInt64(req.CtLowerBound),
},
})
}
if req.CtUpperBound != nil {
filterInClause = append(filterInClause, qmgo.M{
"ct": qmgo.M{
"$lte": util.DerefInt64(req.CtUpperBound),
},
})
}
if len(filterInClause) == 0 {
return 0, nil
}
query := qmgo.M{
"v_type": util.DerefInt64(req.VType),
"$and": filterInClause,
"del_flag": 0,
}
if util.DerefInt64(req.CType) == consts.RavenIQTestVisit_PV {
return col.Find(ctx, query).Count()
} else if util.DerefInt64(req.CType) == consts.RavenIQTestVisit_UV {
return col.Find(ctx, query).Count()
}
return 0, nil
}

View File

@ -9,6 +9,7 @@ import (
"service/api/errs"
"service/api/message/request"
"service/api/message/response"
Raven_IQ_test_visitproto "service/api/proto/Raven_IQ_test_visit/proto"
accountproto "service/api/proto/account/proto"
account_cancellationproto "service/api/proto/account_cancellation/proto"
accountrelationproto "service/api/proto/accountrelation/proto"
@ -4459,3 +4460,33 @@ func (s *Service) ApiGetUnreadNotificationCountByMid(ctx *gin.Context, req *noti
return
}
// RavenIQTestVisit
func (s *Service) ApiCreateRavenIQTestVisit(ctx *gin.Context, req *Raven_IQ_test_visitproto.ApiCreateReq) (ec errcode.ErrCode) {
ec = errcode.ErrCodeRavenIQTestVisitSrvOk
err := _DefaultRavenIQTestVisit.OpCreate(ctx, &Raven_IQ_test_visitproto.OpCreateReq{
RavenIQTestVisit: req.RavenIQTestVisit,
})
if err != nil {
logger.Error("OpCreate fail, req: %v, err: %v", util.ToJson(req), err)
ec = errcode.ErrCodeRavenIQTestVisitSrvFail
return
}
return
}
func (s *Service) ApiGetRavenIQTestVisitCount(ctx *gin.Context, req *Raven_IQ_test_visitproto.ApiCountReq) (count int64, ec errcode.ErrCode) {
ec = errcode.ErrCodeRavenIQTestVisitSrvOk
count, err := _DefaultRavenIQTestVisit.OpCount(ctx, &Raven_IQ_test_visitproto.OpCountReq{
VType: req.VType,
CType: req.CType,
CtLowerBound: req.CtLowerBound,
CtUpperBound: req.CtUpperBound,
})
if err != nil {
logger.Error("OpCreate fail, req: %v, err: %v", util.ToJson(req), err)
ec = errcode.ErrCodeRavenIQTestVisitSrvFail
return
}
return
}

View File

@ -0,0 +1,52 @@
package logic
import (
"service/api/consts"
Raven_IQ_test_visitproto "service/api/proto/Raven_IQ_test_visit/proto"
"service/app/mix/dao"
"service/library/idgenerator"
"service/library/logger"
"github.com/gin-gonic/gin"
goproto "google.golang.org/protobuf/proto"
)
type RavenIQTestVisit struct {
store *dao.Store
}
func NewRavenIQTestVisit(store *dao.Store) (a *RavenIQTestVisit) {
a = &RavenIQTestVisit{
store: store,
}
return
}
func (p *RavenIQTestVisit) OpCreate(ctx *gin.Context, req *Raven_IQ_test_visitproto.OpCreateReq) error {
req.RavenIQTestVisit.Id = goproto.Int64(idgenerator.GenRavenIQTestVisitId())
req.RavenIQTestVisit.DelFlag = goproto.Int64(consts.Exist)
err := p.store.CreateRavenIQTestVisit(ctx, req.RavenIQTestVisit)
if err != nil {
logger.Error("CreateRavenIQTestVisit fail, err: %v", err)
return err
}
return nil
}
func (p *RavenIQTestVisit) OpDelete(ctx *gin.Context, id int64) error {
err := p.store.DeleteRavenIQTestVisit(ctx, id)
if err != nil {
logger.Error("DeleteRavenIQTestVisit fail, err: %v", err)
return err
}
return nil
}
func (p *RavenIQTestVisit) OpCount(ctx *gin.Context, req *Raven_IQ_test_visitproto.OpCountReq) (int64, error) {
count, err := p.store.GetRavenIQTestVisitCount(ctx, req)
if err != nil {
logger.Error("GetRavenIQTestVisitCount fail, err: %v", err)
return 0, err
}
return count, err
}

View File

@ -10,6 +10,7 @@ import (
"service/api/consts"
"service/api/errcode"
"service/api/errs"
Raven_IQ_test_visitproto "service/api/proto/Raven_IQ_test_visit/proto"
accountproto "service/api/proto/account/proto"
account_cancellationproto "service/api/proto/account_cancellation/proto"
accountrelationproto "service/api/proto/accountrelation/proto"
@ -155,6 +156,7 @@ var (
_DefaultRavenIQTest *logic.RavenIQTest
_DefaultAutoResponseCreateTimes *logic.AutoResponseCreateTimes
_DefaultHistory *logic.History
_DefaultRavenIQTestVisit *logic.RavenIQTestVisit
_DefaultStreamerDecrtByEs *logic.StreamerDecrtByEs
_DefaultZoneDecrtByEs *logic.ZoneDecrtByEs
@ -262,6 +264,7 @@ func (s *Service) Init(c any) (err error) {
_DefaultNotification = logic.NewNotification(store)
_DefaultRavenIQTest = logic.NewRavenIQTest(store)
_DefaultHistory = logic.NewHistory(store)
_DefaultRavenIQTestVisit = logic.NewRavenIQTestVisit(store)
_DefaultVas = logic.NewVas(store, _DefaultStreamer, _DefaultAccount, _DefaultZone, _DefaultZoneThirdPartner, _DefaultZoneCollaborator)
_DefaultStreamerAcct = logic.NewStreamerAcct(store)
@ -5144,3 +5147,26 @@ func (s *Service) OpGetNotificationListByMid(ctx *gin.Context, req *notification
}
return
}
// RavenIQTestVisit
func (s *Service) OpCreateRavenIQTestVisit(ctx *gin.Context, req *Raven_IQ_test_visitproto.OpCreateReq) (ec errcode.ErrCode) {
ec = errcode.ErrCodeRavenIQTestVisitSrvOk
err := _DefaultRavenIQTestVisit.OpCreate(ctx, req)
if err != nil {
logger.Error("OpCreate fail, req: %v, err: %v", util.ToJson(req), err)
ec = errcode.ErrCodeRavenIQTestVisitSrvFail
return
}
return
}
func (s *Service) OpDeleteRavenIQTestVisit(ctx *gin.Context, id int64) (ec errcode.ErrCode) {
ec = errcode.ErrCodeRavenIQTestVisitSrvOk
err := _DefaultRavenIQTestVisit.OpDelete(ctx, id)
if err != nil {
logger.Error("OpDelete fail, id: %v, err: %v", id, err)
ec = errcode.ErrCodeRavenIQTestVisitSrvFail
return
}
return
}

View File

@ -9,10 +9,10 @@ import (
func main() {
genSource := &generator.GenSource{
EntityName: "Notification",
ModuleName: "notification",
EntityCNName: "系统通知表",
ErrCodeSeq: "46",
EntityName: "RavenIQTestVisit",
ModuleName: "Raven_IQ_test_visit",
EntityCNName: "瑞文智商测试访问表",
ErrCodeSeq: "102",
}
generator.CreateFileDirectory(genSource)

View File

@ -0,0 +1,9 @@
package dbstruct
type RavenIQTestVisit struct {
Id *int64 `json:"id" bson:"_id"` // 瑞文智商测试访问表id
UserId *string `json:"user_id" bson:"user_id"` // 用户id
VType *int64 `json:"v_type" bson:"v_type"` // 访问类型
Ct *int64 `json:"ct" bson:"ct"` // 创建时间
DelFlag *int64 `json:"del_flag" bson:"del_flag"` // 删除标记
}

View File

@ -58,6 +58,7 @@ const (
NodeSingleDistributeHis // node 慧用工下发打款历史表
NodeEmail // node 电子邮件表
NodeNotification // node 系统通知表
NodeRavenIQTestVisit // node 瑞文智商测试访问表
)
func GenIdInt64(node int64) (int64, error) {
@ -287,3 +288,9 @@ func GenNotificationId() int64 {
id, _ := GenIdInt64(NodeNotification)
return id
}
// Raven_IQ_test_visit
func GenRavenIQTestVisitId() int64 {
id, _ := GenIdInt64(NodeRavenIQTestVisit)
return id
}