by Robin at 20240403
This commit is contained in:
parent
15bb43afdf
commit
ea6eea1ccf
|
@ -11,10 +11,9 @@ const (
|
|||
)
|
||||
|
||||
const (
|
||||
AccountPunishment_BlockFromCreatingMoment = 0 // 禁止发贴
|
||||
AccountPunishment_BlockFromCreatingFreeZoneMoment = 0 // 禁止发免费空间贴
|
||||
AccountPunishment_BlockFromCreatingIronfanVisibleZoneMoment = 0 // 禁止发铁粉空间贴
|
||||
AccountPunishment_BlockFromCreatingSuperfanVisibleZoneMoment = 0 // 禁止发超粉空间贴
|
||||
AccountPunishment_BlockFromCreatingMoment = 0 // 禁止发贴
|
||||
AccountPunishment_BlockFromCreatingFreeZoneMoment = 0 // 禁止发免费空间贴
|
||||
AccountPunishment_BlockFromCreatingPaidZoneMoment = 0 // 禁止发付费空间贴
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
@ -157,6 +157,12 @@ const (
|
|||
IsSuperfanshipUnlocked_Yes = 1 //是
|
||||
)
|
||||
|
||||
// 铁粉是否可以免费看
|
||||
const (
|
||||
IsIronfanVisible_No = 0 //否
|
||||
IsIronfanVisible_Yes = 1 //是
|
||||
)
|
||||
|
||||
// 是否解锁动态
|
||||
const (
|
||||
IsZoneMomentUnlocked_No = 0 //否
|
||||
|
@ -170,7 +176,7 @@ const (
|
|||
MomentManuallyReview_Rejected = 2 //已复审拒绝
|
||||
)
|
||||
|
||||
// 私密动态表audit_status状态
|
||||
// 私密动态表status
|
||||
const (
|
||||
ZoneMoment_Auditing = 0 //机审中
|
||||
ZoneMoment_ManuallyReviewing = 1 //人工复审中
|
||||
|
@ -178,11 +184,10 @@ const (
|
|||
ZoneMoment_Private = 3 //自见
|
||||
)
|
||||
|
||||
// 私密动态表status状态
|
||||
// 私密动态表c_type
|
||||
const (
|
||||
ZoneMoment_Free = 0 //免费
|
||||
ZoneMoment_IronfanVisible = 1 //铁粉可见
|
||||
ZoneMoment_SuperfanVisible = 2 //超粉可见
|
||||
ZoneMomentCType_Free = 0 //免费
|
||||
ZoneMomentCType_Paid = 1 //付费
|
||||
)
|
||||
|
||||
// 私密动态人工复审
|
||||
|
|
|
@ -16,15 +16,11 @@ func (p *ApiCreateReq) ProvideNotNullValue() (params []*validator.JsonParam) {
|
|||
params = append(params, validator.NewStructPtrParam("请确认创建动态的媒体!", p.MediaComp))
|
||||
|
||||
switch util.DerefInt64(p.ZoneMoment.CType) {
|
||||
case consts.ZoneMoment_IronfanVisible:
|
||||
case consts.ZoneMomentCType_Paid:
|
||||
params = append(params, validator.NewInt64PtrParam("请确认创建动态的文字可见范围!", p.ZoneMoment.TextVisibleRange))
|
||||
params = append(params, validator.NewInt64PtrParam("请确认创建动态的媒体可见范围!", p.ZoneMoment.MediaVisibleRange))
|
||||
params = append(params, validator.NewInt64PtrParam("请确认创建动态的价格!", p.ZoneMoment.Price))
|
||||
case consts.ZoneMoment_SuperfanVisible:
|
||||
params = append(params, validator.NewInt64PtrParam("请确认创建动态的文字可见范围!", p.ZoneMoment.TextVisibleRange))
|
||||
params = append(params, validator.NewInt64PtrParam("请确认创建动态的媒体可见范围!", p.ZoneMoment.MediaVisibleRange))
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ type ApiUpdateResp struct {
|
|||
Data *ApiUpdateData `json:"data"`
|
||||
}
|
||||
|
||||
// op 列表
|
||||
// op 列表-访客
|
||||
type ApiListByVisitorMidReq struct {
|
||||
base.BaseRequest
|
||||
CtUpperBound *int64 `json:"ct_upper_bound"` //创建时间上界,闭区间
|
||||
|
@ -67,6 +67,26 @@ type ApiListByVisitorMidResp struct {
|
|||
Data *ApiListByVisitorMidData `json:"data"`
|
||||
}
|
||||
|
||||
// op 列表-创建人
|
||||
type ApiListByCreaterMidReq struct {
|
||||
base.BaseRequest
|
||||
CtUpperBound *int64 `json:"ct_upper_bound"` //创建时间上界,闭区间
|
||||
CtLowerBound *int64 `json:"ct_lower_bound"` //创建时间下界,开区间,可为0
|
||||
Offset int `json:"offset"`
|
||||
Limit int `json:"limit"`
|
||||
}
|
||||
|
||||
type ApiListByCreaterMidData struct {
|
||||
List []*ApiZoneMomentVO `json:"list"`
|
||||
Offset int `json:"offset"`
|
||||
More int `json:"more"`
|
||||
}
|
||||
|
||||
type ApiListByCreaterMidResp struct {
|
||||
base.BaseResponse
|
||||
Data *ApiListByCreaterMidData `json:"data"`
|
||||
}
|
||||
|
||||
// op 点赞
|
||||
type ApiZoneMomentThumbsUpReq struct {
|
||||
base.BaseRequest
|
||||
|
|
|
@ -68,6 +68,26 @@ type OpListResp struct {
|
|||
Data *OpListData `json:"data"`
|
||||
}
|
||||
|
||||
// op 列表
|
||||
type OpListByMidReq struct {
|
||||
base.BaseRequest
|
||||
CtUpperBound *int64 `json:"ct_upper_bound"` //创建时间上界,闭区间
|
||||
CtLowerBound *int64 `json:"ct_lower_bound"` //创建时间下界,开区间,可为0
|
||||
Offset int `json:"offset"`
|
||||
Limit int `json:"limit"`
|
||||
}
|
||||
|
||||
type OpListByMidData struct {
|
||||
List []*dbstruct.ZoneMoment `json:"list"`
|
||||
Offset int `json:"offset"`
|
||||
More int `json:"more"`
|
||||
}
|
||||
|
||||
type OpListByMidResp struct {
|
||||
base.BaseResponse
|
||||
Data *OpListByMidData `json:"data"`
|
||||
}
|
||||
|
||||
// op 按zids查询
|
||||
type OpListByZidsReq struct {
|
||||
base.BaseRequest
|
||||
|
|
|
@ -214,10 +214,12 @@ func Init(r *gin.Engine) {
|
|||
|
||||
// 私密圈动态
|
||||
apiZoneMomentGroup := r.Group("/api/zone_moment", PrepareToC())
|
||||
apiZoneMomentGroup.POST("create", middleware.JSONParamValidator(zonemomentproto.OpCreateReq{}), middleware.JwtAuthenticator(), ApiCreateZoneMoment)
|
||||
apiZoneMomentGroup.POST("update", middleware.JSONParamValidator(zonemomentproto.OpUpdateReq{}), middleware.JwtAuthenticator(), ApiUpdateZoneMoment)
|
||||
apiZoneMomentGroup.POST("delete", middleware.JSONParamValidator(zonemomentproto.OpDeleteReq{}), middleware.JwtAuthenticator(), ApiDeleteZoneMoment)
|
||||
apiZoneMomentGroup.POST("list_by_visitor_mid", middleware.JSONParamValidator(zonemomentproto.OpListReq{}), middleware.JwtAuthenticator(), ApiGetZoneMomentListByVisitorMid)
|
||||
apiZoneMomentGroup.POST("create", middleware.JSONParamValidator(zonemomentproto.ApiCreateReq{}), middleware.JwtAuthenticator(), ApiCreateZoneMoment)
|
||||
apiZoneMomentGroup.POST("update", middleware.JSONParamValidator(zonemomentproto.ApiUpdateReq{}), middleware.JwtAuthenticator(), ApiUpdateZoneMoment)
|
||||
apiZoneMomentGroup.POST("delete", middleware.JSONParamValidator(zonemomentproto.ApiDeleteReq{}), middleware.JwtAuthenticator(), ApiDeleteZoneMoment)
|
||||
apiZoneMomentGroup.POST("list_by_visitor_mid", middleware.JSONParamValidator(zonemomentproto.ApiListByVisitorMidReq{}), middleware.JwtAuthenticator(), ApiGetZoneMomentListByVisitorMid)
|
||||
apiZoneMomentGroup.POST("list_by_creater_mid", middleware.JSONParamValidator(zonemomentproto.ApiListByCreaterMidReq{}), middleware.JwtAuthenticator(), ApiGetZoneMomentListByCreaterMid)
|
||||
apiZoneMomentGroup.POST("thumbs_up", middleware.JSONParamValidator(zonemomentproto.ApiZoneMomentThumbsUpReq{}), middleware.JwtAuthenticator(), ApiZoneMomentThumbsUpMoment)
|
||||
|
||||
// =============================== 以下是服务,只允许内网调用 ===============================
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ func ApiGetZoneMomentListByVisitorMid(ctx *gin.Context) {
|
|||
req.Limit = consts.DefaultPageSize
|
||||
}
|
||||
|
||||
list, ec := service.DefaultService.ApiGetZoneMomentList(ctx, req)
|
||||
list, ec := service.DefaultService.ApiGetZoneMomentListByVisitorMid(ctx, req)
|
||||
if ec != errcode.ErrCodeZoneMomentSrvOk {
|
||||
logger.Error("ApiGetZoneMomentList fail, req: %v, ec: %v", util.ToJson(req), ec)
|
||||
ReplyErrCodeMsg(ctx, ec)
|
||||
|
@ -77,6 +77,31 @@ func ApiGetZoneMomentListByVisitorMid(ctx *gin.Context) {
|
|||
ReplyOk(ctx, data)
|
||||
}
|
||||
|
||||
func ApiGetZoneMomentListByCreaterMid(ctx *gin.Context) {
|
||||
req := ctx.MustGet("client_req").(*zonemomentproto.ApiListByCreaterMidReq)
|
||||
|
||||
//设置默认页长
|
||||
if req.Limit == 0 {
|
||||
req.Limit = consts.DefaultPageSize
|
||||
}
|
||||
|
||||
list, ec := service.DefaultService.ApiGetZoneMomentListByCreaterMid(ctx, req)
|
||||
if ec != errcode.ErrCodeZoneMomentSrvOk {
|
||||
logger.Error("ApiGetZoneMomentList fail, req: %v, ec: %v", util.ToJson(req), ec)
|
||||
ReplyErrCodeMsg(ctx, ec)
|
||||
return
|
||||
}
|
||||
|
||||
data := &zonemomentproto.ApiListByCreaterMidData{
|
||||
List: list,
|
||||
Offset: req.Offset + len(list),
|
||||
}
|
||||
if len(list) >= req.Limit {
|
||||
data.More = 1
|
||||
}
|
||||
ReplyOk(ctx, data)
|
||||
}
|
||||
|
||||
func ApiZoneMomentThumbsUpMoment(ctx *gin.Context) {
|
||||
req := ctx.MustGet("client_req").(*zonemomentproto.ApiZoneMomentThumbsUpReq)
|
||||
ec := service.DefaultService.ApiZoneMomentThumbsUpMoment(ctx, req)
|
||||
|
|
|
@ -3909,8 +3909,33 @@ func (m *Mongo) GetZoneMomentListByZids(ctx *gin.Context, req *zonemomentproto.O
|
|||
"zid": qmgo.M{
|
||||
"$in": req.Zids,
|
||||
},
|
||||
"audit_status": consts.ZoneMoment_Public,
|
||||
"del_flag": 0,
|
||||
"status": consts.ZoneMoment_Public,
|
||||
"del_flag": 0,
|
||||
}
|
||||
ctClause := qmgo.M{}
|
||||
if req.CtLowerBound != nil {
|
||||
ctClause["$gt"] = util.DerefInt64(req.CtLowerBound)
|
||||
}
|
||||
if req.CtUpperBound != nil {
|
||||
ctClause["$lte"] = util.DerefInt64(req.CtUpperBound)
|
||||
}
|
||||
if len(ctClause) != 0 {
|
||||
query["ct"] = ctClause
|
||||
}
|
||||
err := col.Find(ctx, query).Sort("-ct").Skip(int64(req.Offset)).Limit(int64(req.Limit)).All(&list)
|
||||
if err == qmgo.ErrNoSuchDocuments {
|
||||
err = nil
|
||||
return list, err
|
||||
}
|
||||
return list, err
|
||||
}
|
||||
|
||||
func (m *Mongo) GetZoneMomentListByMid(ctx *gin.Context, req *zonemomentproto.OpListByMidReq) ([]*dbstruct.ZoneMoment, error) {
|
||||
list := make([]*dbstruct.ZoneMoment, 0)
|
||||
col := m.getColZoneMoment()
|
||||
query := qmgo.M{
|
||||
"mid": req.GetBaseRequest().Mid,
|
||||
"del_flag": 0,
|
||||
}
|
||||
ctClause := qmgo.M{}
|
||||
if req.CtLowerBound != nil {
|
||||
|
|
|
@ -2203,7 +2203,7 @@ func (s *Service) ApiDeleteZoneMoment(ctx *gin.Context, id int64) (ec errcode.Er
|
|||
return
|
||||
}
|
||||
|
||||
func (s *Service) ApiGetZoneMomentList(ctx *gin.Context, req *zonemomentproto.ApiListByVisitorMidReq) (volist []*zonemomentproto.ApiZoneMomentVO, ec errcode.ErrCode) {
|
||||
func (s *Service) ApiGetZoneMomentListByVisitorMid(ctx *gin.Context, req *zonemomentproto.ApiListByVisitorMidReq) (volist []*zonemomentproto.ApiZoneMomentVO, ec errcode.ErrCode) {
|
||||
ec = errcode.ErrCodeZoneMomentSrvOk
|
||||
|
||||
// 1.查询访客关注的空间
|
||||
|
@ -2287,6 +2287,44 @@ func (s *Service) ApiGetZoneMomentList(ctx *gin.Context, req *zonemomentproto.Ap
|
|||
return
|
||||
}
|
||||
|
||||
func (s *Service) ApiGetZoneMomentListByCreaterMid(ctx *gin.Context, req *zonemomentproto.ApiListByCreaterMidReq) (volist []*zonemomentproto.ApiZoneMomentVO, ec errcode.ErrCode) {
|
||||
ec = errcode.ErrCodeZoneMomentSrvOk
|
||||
|
||||
// 1.根据关注的zids查询得到这一轮的动态基底
|
||||
list, err := _DefaultZoneMoment.OpListByMid(ctx, &zonemomentproto.OpListByMidReq{
|
||||
CtUpperBound: req.CtUpperBound,
|
||||
CtLowerBound: req.CtLowerBound,
|
||||
Offset: req.Offset,
|
||||
Limit: req.Limit,
|
||||
})
|
||||
if err != nil {
|
||||
logger.Error("ApiGetZoneMomentList fail, req: %v, err: %v", util.ToJson(req), err)
|
||||
ec = errcode.ErrCodeZoneMomentSrvFail
|
||||
return
|
||||
}
|
||||
|
||||
// 2.通过mid获取主播信息map
|
||||
streamerExtMap, err := s.utilGetStreamerExtMapByMids(ctx, []int64{req.GetBaseRequest().Mid}, consts.InterfaceType_Api)
|
||||
if err != nil {
|
||||
logger.Error("utilGetStreamerExtMapByMids fail, req: %v, err: %v", util.ToJson(req), err)
|
||||
ec = errcode.ErrCodeStreamerSrvFail
|
||||
return
|
||||
}
|
||||
streamerExt := streamerExtMap[req.GetBaseRequest().Mid]
|
||||
|
||||
// 3.填充所有信息
|
||||
for _, zonemoment := range list {
|
||||
vo := &zonemomentproto.ApiZoneMomentVO{
|
||||
ZoneMoment: zonemoment,
|
||||
}
|
||||
// 主播信息
|
||||
vo.CopyStreamerExt(streamerExt)
|
||||
volist = append(volist, vo)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (s *Service) ApiZoneMomentThumbsUpMoment(ctx *gin.Context, req *zonemomentproto.ApiZoneMomentThumbsUpReq) (ec errcode.ErrCode) {
|
||||
ec = errcode.ErrCodeZoneMomentSrvOk
|
||||
|
||||
|
|
|
@ -549,12 +549,10 @@ func (s *Service) ApiCreateZoneMomentBusinessValidate(ctx *gin.Context, req *zon
|
|||
|
||||
pType := int64(0)
|
||||
switch util.DerefInt64(req.ZoneMoment.CType) {
|
||||
case consts.ZoneMoment_Free:
|
||||
case consts.ZoneMomentCType_Free:
|
||||
pType = consts.AccountPunishment_BlockFromCreatingFreeZoneMoment
|
||||
case consts.ZoneMoment_IronfanVisible:
|
||||
pType = consts.AccountPunishment_BlockFromCreatingIronfanVisibleZoneMoment
|
||||
case consts.ZoneMoment_SuperfanVisible:
|
||||
pType = consts.AccountPunishment_BlockFromCreatingSuperfanVisibleZoneMoment
|
||||
case consts.ZoneMomentCType_Paid:
|
||||
pType = consts.AccountPunishment_BlockFromCreatingPaidZoneMoment
|
||||
}
|
||||
|
||||
resultList := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
||||
|
|
|
@ -302,23 +302,24 @@ func (l *AuthBusinessValidator) EnsureMomentCreateTimesNotReachedDailyUpperbound
|
|||
func (l *AuthBusinessValidator) EnsureAmongZoneMomentsPaidItemsLessThanFreeItems(fun func(*gin.Context, int64, int64) (int64, error), mid int64) *AuthBusinessValidator {
|
||||
l.oplist = append(l.oplist, func() {
|
||||
|
||||
// 动态数
|
||||
freeCount, err1 := fun(l.ctx, mid, consts.ZoneMoment_Free)
|
||||
// 免费动态数
|
||||
freeCount, err1 := fun(l.ctx, mid, consts.ZoneMomentCType_Free)
|
||||
if err1 != nil {
|
||||
logger.Error("Query free zone moment count failed, err: %v", err1)
|
||||
l.ec = errcode.ErrCodeZoneMomentSrvFail
|
||||
return
|
||||
}
|
||||
|
||||
productCount, err2 := fun(l.ctx, mid, consts.ZoneMoment_Free)
|
||||
// 付费动态数
|
||||
paidCount, err2 := fun(l.ctx, mid, consts.ZoneMomentCType_Paid)
|
||||
if err2 != nil {
|
||||
logger.Error("Query product zone moment count failed, err: %v", err2)
|
||||
logger.Error("Query paid zone moment count failed, err: %v", err2)
|
||||
l.ec = errcode.ErrCodeZoneMomentSrvFail
|
||||
return
|
||||
}
|
||||
|
||||
if productCount >= freeCount {
|
||||
logger.Error("the product zone moment create times of this mid has reached its upperbound")
|
||||
if paidCount >= freeCount {
|
||||
logger.Error("the paid zone moment create times of this mid has reached its upperbound")
|
||||
l.ec = errcode.ErrCodePaidZoneMomentCreateTimesReachedUpperbound
|
||||
return
|
||||
}
|
||||
|
|
|
@ -80,6 +80,15 @@ func (p *ZoneMoment) OpListByZids(ctx *gin.Context, req *zonemomentproto.OpListB
|
|||
return list, nil
|
||||
}
|
||||
|
||||
func (p *ZoneMoment) OpListByMid(ctx *gin.Context, req *zonemomentproto.OpListByMidReq) ([]*dbstruct.ZoneMoment, error) {
|
||||
list, err := p.store.GetZoneMomentListByMid(ctx, req)
|
||||
if err != nil {
|
||||
logger.Error("GetZoneMomentListByMid fail, err: %v", err)
|
||||
return make([]*dbstruct.ZoneMoment, 0), err
|
||||
}
|
||||
return list, nil
|
||||
}
|
||||
|
||||
func (p *ZoneMoment) OpZoneMomentThumbsUp(ctx *gin.Context, req *zonemomentproto.OpZoneMomentThumbsUpReq) (err error) {
|
||||
//更新Moment中的点赞个数
|
||||
err = p.store.ThumbsUpZoneMoment(ctx, req)
|
||||
|
|
|
@ -988,23 +988,18 @@ func (s *Service) utilEncryptInaccessibleZoneMoment(vo *zonemomentproto.ApiZoneM
|
|||
// 填充动态是否解锁
|
||||
func (s *Service) utilFillIsZoneMomentUnlocked(vo *zonemomentproto.ApiZoneMomentVO) {
|
||||
switch util.DerefInt64(vo.ZoneMoment.Status) {
|
||||
case consts.ZoneMoment_Free:
|
||||
case consts.ZoneMomentCType_Free:
|
||||
vo.SetIsZoneMomentUnlocked(consts.IsZoneMomentUnlocked_Yes)
|
||||
case consts.ZoneMoment_IronfanVisible:
|
||||
if vo.IsSuperfanshipUnlocked == consts.IsIronfanshipUnlocked_Yes || vo.IsIronfanshipUnlocked == consts.IsIronfanshipUnlocked_Yes {
|
||||
case consts.ZoneMomentCType_Paid:
|
||||
if vo.IsSuperfanshipUnlocked == consts.IsIronfanshipUnlocked_Yes {
|
||||
vo.SetIsZoneMomentUnlocked(consts.IsZoneMomentUnlocked_Yes)
|
||||
} else if util.DerefInt64(vo.IsIronfanVisible) == consts.IsIronfanVisible_Yes && vo.IsIronfanshipUnlocked == consts.IsIronfanshipUnlocked_Yes {
|
||||
vo.SetIsZoneMomentUnlocked(consts.IsZoneMomentUnlocked_Yes)
|
||||
} else {
|
||||
// 是否已购买该条动态
|
||||
vo.SetIsZoneMomentUnlocked(consts.IsZoneMomentUnlocked_No)
|
||||
s.utilEncryptInaccessibleZoneMoment(vo)
|
||||
}
|
||||
case consts.ZoneMoment_SuperfanVisible:
|
||||
if vo.IsSuperfanshipUnlocked == consts.IsIronfanshipUnlocked_Yes {
|
||||
vo.SetIsZoneMomentUnlocked(consts.IsZoneMomentUnlocked_Yes)
|
||||
} else {
|
||||
vo.SetIsZoneMomentUnlocked(consts.IsZoneMomentUnlocked_No)
|
||||
s.utilEncryptInaccessibleZoneMoment(vo)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,10 +6,11 @@ type ZoneMoment struct {
|
|||
Id *int64 `json:"id" bson:"_id"` // 私密圈动态表id
|
||||
Mid *int64 `json:"mid" bson:"mid"` // 用户表id
|
||||
Zid *int64 `json:"zid" bson:"zid"` // 所属空间id
|
||||
CType *int64 `json:"c_type" bson:"c_type"` // 动态付费类型,0-免费贴,1-铁粉贴,2-超粉贴
|
||||
CType *int64 `json:"c_type" bson:"c_type"` // 动态付费类型,0-免费贴,1-付费贴
|
||||
IsIronfanVisible *int64 `json:"is_ironfan_visible" bson:"is_ironfan_visible"` // 铁粉是否可以免费看
|
||||
Text *string `json:"text" bson:"text"` // 动态文字内容
|
||||
MediaComp *MediaComponent `json:"media_comp" bson:"media_comp"` // 动态媒体内容
|
||||
MType *int64 `json:"m_type"` // 媒体类型,见: MediaType*
|
||||
MType *int64 `json:"m_type" bson:"m_type"` // 媒体类型,见: MediaType*
|
||||
TextVisibleRange *int64 `json:"text_visible_range" bson:"text_visible_range"` // 动态文字可见范围,单位行
|
||||
MediaVisibleRange *int64 `json:"media_visible_range" bson:"media_visible_range"` // 动态媒体可见范围,单位媒体个数
|
||||
TextAmount *int64 `json:"text_amount" bson:"text_amount"` // 动态文字总行
|
||||
|
|
Loading…
Reference in New Issue