by Robin at 20240808

This commit is contained in:
Leufolium 2024-08-08 16:04:50 +08:00
parent 68be863a92
commit 50d3ab3040
7 changed files with 97 additions and 0 deletions

View File

@ -93,3 +93,8 @@ const (
MerchantWeixin = 40 //商户方微信
CPAccount = 51 //中金支付电子账户
)
const (
StreamerAuthApproval_OneOffVersion = 0
StreamerAuthApproval_SeparateVersion = 1
)

View File

@ -109,6 +109,8 @@ var ErrCodeMsgMap = map[ErrCode]string{
ErrCodeStreamerAuthApprovalDetailsInviterIsNotAStreamer: "邀请人非主播",
ErrCodeStreamerAuthApprovalDetailsNotAStreamerToBe: "该主播尚未通过“网红入驻审核”,请先前往审核",
ErrCodeStreamerAuthApprovalDetailsNotInApprovingStatus: "所选完善审批中有项目状态错误,请刷新后重试",
ErrCodeStreamerAuthApprovalOneOffVersionExist: "您已在旧版本提交入驻申请,请勿重复提交!",
ErrCodeStreamerAuthApprovalSeparateVersionExist: "您已在新版本提交入驻申请,请勿重复提交!",
ErrCodeStreamerSrvFail: "主播服务错误",
ErrCodeStreamerNotExist: "主播不存在",
@ -388,6 +390,8 @@ const (
ErrCodeStreamerAuthApprovalDetailsInviterIsNotAStreamer ErrCode = -12205 // 女神认证完善审批表邀请人非主播
ErrCodeStreamerAuthApprovalDetailsNotAStreamerToBe ErrCode = -12206 // 女神认证完善审批表申请人非准主播
ErrCodeStreamerAuthApprovalDetailsNotInApprovingStatus ErrCode = -12207 // 女神认证完善审批表非人审中状态
ErrCodeStreamerAuthApprovalOneOffVersionExist ErrCode = -12208 // 女神认证批表已提交旧表
ErrCodeStreamerAuthApprovalSeparateVersionExist ErrCode = -12209 // 女神认证批表已提交新表
// Streamer: 13xxx
ErrCodeStreamerSrvOk ErrCode = ErrCodeOk

View File

@ -144,6 +144,7 @@ const (
COLStreamerAuthApprovalHis = "streamer_auth_approval_his"
COLStreamerAuthApprovalBasicHis = "streamer_auth_approval_basic_his"
COLStreamerAuthApprovalDetailsHis = "streamer_auth_approval_details_his"
COLStreamerAuthApprovalVersion = "streamer_auth_approval_version"
DBStreamer = "streamer"
COLStreamer = "streamer"
@ -425,6 +426,11 @@ func (m *Mongo) getColStreamerAuthApprovalDetailsHis() *qmgo.Collection {
return m.clientMix.Database(DBStreamerAuthApproval).Collection(COLStreamerAuthApprovalDetailsHis)
}
// 女神认证审批版本表
func (m *Mongo) getColStreamerAuthApprovalVersion() *qmgo.Collection {
return m.clientMix.Database(DBStreamerAuthApproval).Collection(COLStreamerAuthApprovalVersion)
}
// 主播表
func (m *Mongo) getColStreamer() *qmgo.Collection {
return m.clientMix.Database(DBStreamer).Collection(COLStreamer)
@ -2353,6 +2359,26 @@ func (m *Mongo) CreateBatchStreamerAuthApprovalHis(ctx *gin.Context, streameraut
return err
}
func (m *Mongo) CreateStreamerAuthApprovalVersion(ctx *gin.Context, streamerauthapprovalversion *dbstruct.StreamerAuthApprovalVersion) error {
col := m.getColStreamerAuthApprovalVersion()
_, err := col.InsertOne(ctx, streamerauthapprovalversion)
return err
}
func (m *Mongo) GetStreamerAuthApprovalVersion(ctx *gin.Context, id int64) (*dbstruct.StreamerAuthApprovalVersion, error) {
streamerauthapprovalversion := &dbstruct.StreamerAuthApprovalVersion{}
col := m.getColStreamerAuthApprovalVersion()
query := qmgo.M{
"_id": id,
}
err := col.Find(ctx, query).One(streamerauthapprovalversion)
if err == qmgo.ErrNoSuchDocuments {
err = nil
return nil, err
}
return streamerauthapprovalversion, err
}
// 女神认证入站审批表相关
func (m *Mongo) CreateStreamerAuthApprovalBasic(ctx *gin.Context, streamerauthapprovalbasic *dbstruct.StreamerAuthApprovalBasic) error {
col := m.getColStreamerAuthApprovalBasic()

View File

@ -429,6 +429,8 @@ func (s *Service) ApiCreateStreamerAuthApprovalBusinessValidate(ctx *gin.Context
EnsureMediaIsSuccessfullyUploaded(req.StreamerAuthApproval.Album).
EnsureMediaIsSuccessfullyUploaded(req.StreamerAuthApproval.Shorts).
EnsureIsOperatingHisOwn(util.DerefInt64(req.StreamerAuthApproval.Mid)).
EnsureStreamerAuthApprovalIsUnique(_DefaultStreamerAuthApproval.OpCreateStreamerAuthApprovalVersion, _DefaultStreamerAuthApproval.GetStreamerAuthApprovalVersion,
consts.StreamerAuthApproval_OneOffVersion, util.DerefInt64(req.StreamerAuthApproval.Mid)).
Validate().
Collect()
if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk {
@ -490,6 +492,8 @@ func (s *Service) ApiCreateStreamerAuthApprovalBasicBusinessValidate(ctx *gin.Co
EnsureIsNotThisRole(consts.Streamer).
EnsureMediaIsSuccessfullyUploaded(req.StreamerAuthApprovalBasic.Avatar).
EnsureMediaIsSuccessfullyUploaded(req.StreamerAuthApprovalBasic.AccountShot).
EnsureStreamerAuthApprovalIsUnique(_DefaultStreamerAuthApproval.OpCreateStreamerAuthApprovalVersion, _DefaultStreamerAuthApproval.GetStreamerAuthApprovalVersion,
consts.StreamerAuthApproval_SeparateVersion, util.DerefInt64(req.StreamerAuthApprovalBasic.Mid)).
Validate().
Collect()
if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk {

View File

@ -737,6 +737,41 @@ func (l *AuthBusinessValidator) EnsureStreamerAuthApprovalBasicCreated(fun func(
return l
}
func (l *AuthBusinessValidator) EnsureStreamerAuthApprovalIsUnique(createFunc func(*gin.Context, *dbstruct.StreamerAuthApprovalVersion) error, queryFunc func(*gin.Context, int64) (*dbstruct.StreamerAuthApprovalVersion, error),
version int64, mid int64) *AuthBusinessValidator {
l.oplist = append(l.oplist, func() {
streamerauthapprovalversion, err := queryFunc(l.ctx, mid)
if err != nil {
logger.Error("StreamerAuthApprovalVersion Get fail, err: %v", err)
l.ec = errcode.ErrCodeStreamerAuthApprovalSrvFail
return
}
if streamerauthapprovalversion == nil {
err := createFunc(l.ctx, &dbstruct.StreamerAuthApprovalVersion{
Id: mid,
Version: version,
})
if err != nil {
logger.Error("StreamerAuthApprovalVersion Create fail, err: %v", err)
l.ec = errcode.ErrCodeStreamerAuthApprovalSrvFail
return
}
return
}
if streamerauthapprovalversion.Version != version {
if streamerauthapprovalversion.Version == consts.StreamerAuthApproval_OneOffVersion {
l.ec = errcode.ErrCodeStreamerAuthApprovalOneOffVersionExist
return
}
if streamerauthapprovalversion.Version == consts.StreamerAuthApproval_SeparateVersion {
l.ec = errcode.ErrCodeStreamerAuthApprovalSeparateVersionExist
return
}
}
})
return l
}
// 执行校验
func (a *AuthBusinessValidator) Validate() *AuthBusinessValidator {
a.BusinessValidateStream.Validate()

View File

@ -154,3 +154,21 @@ func (p *StreamerAuthApproval) GetStreamerAuthApprovalListByIds(ctx *gin.Context
}
return list, nil
}
func (p *StreamerAuthApproval) OpCreateStreamerAuthApprovalVersion(ctx *gin.Context, version *dbstruct.StreamerAuthApprovalVersion) error {
err := p.store.CreateStreamerAuthApprovalVersion(ctx, version)
if err != nil {
logger.Error("CreateStreamerAuthApprovalVersion fail, err: %v", err)
return err
}
return nil
}
func (p *StreamerAuthApproval) GetStreamerAuthApprovalVersion(ctx *gin.Context, id int64) (*dbstruct.StreamerAuthApprovalVersion, error) {
version, err := p.store.GetStreamerAuthApprovalVersion(ctx, id)
if err != nil {
logger.Error("GetStreamerAuthApprovalVersion fail, err: %v", err)
return nil, err
}
return version, nil
}

View File

@ -128,3 +128,8 @@ func (p *StreamerAuthApprovalDetails) GetApproveStatus() int64 {
}
return 0
}
type StreamerAuthApprovalVersion struct {
Id int64 `json:"id" bson:"_id"` //id,主播的mid
Version int64 `json:"version" bson:"version"` //版本号
}