by Robin at 20240320
This commit is contained in:
parent
7c09356ce9
commit
a364553c0c
|
@ -166,6 +166,9 @@ var ErrCodeMsgMap = map[ErrCode]string{
|
|||
|
||||
ErrCodeAccountCancellationSrvFail: "账户注销服务错误",
|
||||
ErrCodeAccountCancellationNotExist: "账户注销不存在",
|
||||
|
||||
ErrCodeZoneSrvFail: "空间服务错误",
|
||||
ErrCodeZoneNotExist: "空间不存在",
|
||||
}
|
||||
|
||||
const (
|
||||
|
@ -380,6 +383,11 @@ const (
|
|||
ErrCodeMomentAuditTaskSrvFail ErrCode = -29001 // 动态审核任务表服务错误
|
||||
ErrCodeMomentAuditTaskNotExist ErrCode = -29002 // 动态审核任务表不存在
|
||||
|
||||
// AccountCancellation: 30xxx
|
||||
ErrCodeAccountCancellationSrvOk ErrCode = ErrCodeOk
|
||||
ErrCodeAccountCancellationSrvFail ErrCode = -30001 // 账户注销服务错误
|
||||
ErrCodeAccountCancellationNotExist ErrCode = -30002 // 账户注销不存在
|
||||
|
||||
// AccountPunishment: 32xxx
|
||||
ErrCodeAccountPunishmentSrvOk ErrCode = ErrCodeOk
|
||||
ErrCodeAccountPunishmentSrvFail ErrCode = -32001 // 账号处罚服务错误
|
||||
|
@ -390,10 +398,10 @@ const (
|
|||
ErrCodeAccountPunishmentHasBeenInterrupted ErrCode = -32006 // 账号处罚已提前中止
|
||||
ErrCodeAccountPunishmentStreamerOnly ErrCode = -32007 // 该账号处罚仅能对主播进行
|
||||
|
||||
// AccountCancellation: 30xxx
|
||||
ErrCodeAccountCancellationSrvOk ErrCode = ErrCodeOk
|
||||
ErrCodeAccountCancellationSrvFail ErrCode = -30001 // 账户注销服务错误
|
||||
ErrCodeAccountCancellationNotExist ErrCode = -30002 // 账户注销不存在
|
||||
// Zone: 33xxx
|
||||
ErrCodeZoneSrvOk ErrCode = ErrCodeOk
|
||||
ErrCodeZoneSrvFail ErrCode = -33001 // 空间服务错误
|
||||
ErrCodeZoneNotExist ErrCode = -33002 // 空间不存在
|
||||
|
||||
// Media: 60xxx
|
||||
ErrCodeMediaSrvOk ErrCode = ErrCodeOk
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
package proto
|
||||
|
||||
import (
|
||||
"service/api/base"
|
||||
"service/dbstruct"
|
||||
)
|
||||
|
||||
// op 创建
|
||||
type ApiCreateReq struct {
|
||||
base.BaseRequest
|
||||
*dbstruct.Zone
|
||||
}
|
||||
|
||||
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 ApiUpdateReq struct {
|
||||
base.BaseRequest
|
||||
*dbstruct.Zone
|
||||
}
|
||||
|
||||
type ApiUpdateData struct {
|
||||
}
|
||||
|
||||
type ApiUpdateResp struct {
|
||||
base.BaseResponse
|
||||
Data *ApiUpdateData `json:"data"`
|
||||
}
|
||||
|
||||
// op 列表
|
||||
type ApiListReq struct {
|
||||
base.BaseRequest
|
||||
Offset int `json:"offset"`
|
||||
Limit int `json:"limit"`
|
||||
}
|
||||
|
||||
type ApiListData struct {
|
||||
List []*dbstruct.Zone `json:"list"`
|
||||
Offset int `json:"offset"`
|
||||
More int `json:"more"`
|
||||
}
|
||||
|
||||
type ApiListResp struct {
|
||||
base.BaseResponse
|
||||
Data *ApiListData `json:"data"`
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
package proto
|
||||
|
||||
import (
|
||||
"service/api/base"
|
||||
"service/dbstruct"
|
||||
)
|
||||
|
||||
// op 创建
|
||||
type OpCreateReq struct {
|
||||
base.BaseRequest
|
||||
*dbstruct.Zone
|
||||
}
|
||||
|
||||
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 OpUpdateReq struct {
|
||||
base.BaseRequest
|
||||
*dbstruct.Zone
|
||||
}
|
||||
|
||||
type OpUpdateData struct {
|
||||
}
|
||||
|
||||
type OpUpdateResp struct {
|
||||
base.BaseResponse
|
||||
Data *OpUpdateData `json:"data"`
|
||||
}
|
||||
|
||||
// op 列表
|
||||
type OpListReq struct {
|
||||
base.BaseRequest
|
||||
Offset int `json:"offset"`
|
||||
Limit int `json:"limit"`
|
||||
}
|
||||
|
||||
type OpListData struct {
|
||||
List []*dbstruct.Zone `json:"list"`
|
||||
Offset int `json:"offset"`
|
||||
More int `json:"more"`
|
||||
}
|
||||
|
||||
type OpListResp struct {
|
||||
base.BaseResponse
|
||||
Data *OpListData `json:"data"`
|
||||
}
|
|
@ -42,6 +42,7 @@ import (
|
|||
userwxaddcheckproto "service/api/proto/userwxaddcheck/proto"
|
||||
vasproto "service/api/proto/vas/proto"
|
||||
vericodeproto "service/api/proto/vericode/proto"
|
||||
zoneproto "service/api/proto/zone/proto"
|
||||
)
|
||||
|
||||
func Init(r *gin.Engine) {
|
||||
|
@ -202,6 +203,13 @@ func Init(r *gin.Engine) {
|
|||
apiAccountCancellationGroup := r.Group("/api/account_cancellation", PrepareToC())
|
||||
apiAccountCancellationGroup.POST("list_by_mid", middleware.JSONParamValidator(account_cancellationproto.ApiListByMidReq{}), middleware.JwtAuthenticator(), ApiGetAccountCancellationListByMid)
|
||||
|
||||
// 空间
|
||||
apiZoneGroup := r.Group("/api/zone", PrepareToC())
|
||||
apiZoneGroup.POST("create", middleware.JSONParamValidator(zoneproto.ApiCreateReq{}), middleware.JwtAuthenticator(), ApiCreateZone)
|
||||
apiZoneGroup.POST("update", middleware.JSONParamValidator(zoneproto.ApiUpdateReq{}), middleware.JwtAuthenticator(), ApiUpdateZone)
|
||||
apiZoneGroup.POST("delete", middleware.JSONParamValidator(zoneproto.ApiDeleteReq{}), middleware.JwtAuthenticator(), ApiDeleteZone)
|
||||
apiZoneGroup.POST("list", middleware.JSONParamValidator(zoneproto.ApiListReq{}), middleware.JwtAuthenticator(), ApiGetZoneList)
|
||||
|
||||
// =============================== 以下是服务,只允许内网调用 ===============================
|
||||
|
||||
// op相关,直接调用服务,不调用gateway
|
||||
|
@ -429,6 +437,13 @@ func Init(r *gin.Engine) {
|
|||
opAccountCancellationGroup := r.Group("/op/account_cancellation", PrepareOp())
|
||||
opAccountCancellationGroup.POST("list", middleware.JSONParamValidator(account_cancellationproto.OpListReq{}), middleware.JwtAuthenticator(), OpGetAccountCancellationList)
|
||||
|
||||
// 空间
|
||||
opZoneGroup := r.Group("/op/zone", PrepareOp())
|
||||
opZoneGroup.POST("create", middleware.JSONParamValidator(zoneproto.OpCreateReq{}), middleware.JwtAuthenticator(), OpCreateZone)
|
||||
opZoneGroup.POST("update", middleware.JSONParamValidator(zoneproto.OpUpdateReq{}), middleware.JwtAuthenticator(), OpUpdateZone)
|
||||
opZoneGroup.POST("delete", middleware.JSONParamValidator(zoneproto.OpDeleteReq{}), middleware.JwtAuthenticator(), OpDeleteZone)
|
||||
opZoneGroup.POST("list", middleware.JSONParamValidator(zoneproto.OpListReq{}), middleware.JwtAuthenticator(), OpGetZoneList)
|
||||
|
||||
// 账号相关
|
||||
//accountGroup := r.Group("/account")
|
||||
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
package controller
|
||||
|
||||
import (
|
||||
"service/api/consts"
|
||||
"service/api/errcode"
|
||||
zoneproto "service/api/proto/zone/proto"
|
||||
"service/app/mix/service"
|
||||
"service/bizcommon/util"
|
||||
"service/library/logger"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func ApiCreateZone(ctx *gin.Context) {
|
||||
req := ctx.MustGet("client_req").(*zoneproto.ApiCreateReq)
|
||||
ec := service.DefaultService.ApiCreateZone(ctx, req)
|
||||
if ec != errcode.ErrCodeZoneSrvOk {
|
||||
logger.Error("ApiCreateZone fail, req: %v, ec: %v", util.ToJson(req), ec)
|
||||
ReplyErrorMsg(ctx, "server error")
|
||||
return
|
||||
}
|
||||
|
||||
ReplyOk(ctx, nil)
|
||||
}
|
||||
|
||||
func ApiUpdateZone(ctx *gin.Context) {
|
||||
req := ctx.MustGet("client_req").(*zoneproto.ApiUpdateReq)
|
||||
ec := service.DefaultService.ApiUpdateZone(ctx, req)
|
||||
if ec != errcode.ErrCodeZoneSrvOk {
|
||||
logger.Error("ApiUpdateZone fail, req: %v, ec: %v", util.ToJson(req), ec)
|
||||
ReplyErrCodeMsg(ctx, ec)
|
||||
return
|
||||
}
|
||||
|
||||
ReplyOk(ctx, nil)
|
||||
}
|
||||
|
||||
func ApiDeleteZone(ctx *gin.Context) {
|
||||
req := ctx.MustGet("client_req").(*zoneproto.ApiDeleteReq)
|
||||
ec := service.DefaultService.ApiDeleteZone(ctx, req.Id)
|
||||
if ec != errcode.ErrCodeZoneSrvOk {
|
||||
logger.Error("ApiDeleteZone fail, req: %v, ec: %v", util.ToJson(req), ec)
|
||||
ReplyErrCodeMsg(ctx, ec)
|
||||
return
|
||||
}
|
||||
|
||||
ReplyOk(ctx, nil)
|
||||
}
|
||||
|
||||
func ApiGetZoneList(ctx *gin.Context) {
|
||||
req := ctx.MustGet("client_req").(*zoneproto.ApiListReq)
|
||||
|
||||
//设置默认页长
|
||||
if req.Limit == 0 {
|
||||
req.Limit = consts.DefaultPageSize
|
||||
}
|
||||
|
||||
list, ec := service.DefaultService.ApiGetZoneList(ctx, req)
|
||||
if ec != errcode.ErrCodeZoneSrvOk {
|
||||
logger.Error("ApiGetZoneList fail, req: %v, ec: %v", util.ToJson(req), ec)
|
||||
ReplyErrCodeMsg(ctx, ec)
|
||||
return
|
||||
}
|
||||
|
||||
data := &zoneproto.ApiListData{
|
||||
List: list,
|
||||
Offset: req.Offset + len(list),
|
||||
}
|
||||
if len(list) >= req.Limit {
|
||||
data.More = 1
|
||||
}
|
||||
ReplyOk(ctx, data)
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
package controller
|
||||
|
||||
import (
|
||||
"service/api/consts"
|
||||
"service/api/errcode"
|
||||
zoneproto "service/api/proto/zone/proto"
|
||||
"service/app/mix/service"
|
||||
"service/bizcommon/util"
|
||||
"service/library/logger"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func OpCreateZone(ctx *gin.Context) {
|
||||
req := ctx.MustGet("client_req").(*zoneproto.OpCreateReq)
|
||||
ec := service.DefaultService.OpCreateZone(ctx, req)
|
||||
if ec != errcode.ErrCodeZoneSrvOk {
|
||||
logger.Error("OpCreateZone fail, req: %v, ec: %v", util.ToJson(req), ec)
|
||||
ReplyErrorMsg(ctx, "server error")
|
||||
return
|
||||
}
|
||||
|
||||
ReplyOk(ctx, nil)
|
||||
}
|
||||
|
||||
func OpUpdateZone(ctx *gin.Context) {
|
||||
req := ctx.MustGet("client_req").(*zoneproto.OpUpdateReq)
|
||||
ec := service.DefaultService.OpUpdateZone(ctx, req)
|
||||
if ec != errcode.ErrCodeZoneSrvOk {
|
||||
logger.Error("OpUpdateZone fail, req: %v, ec: %v", util.ToJson(req), ec)
|
||||
ReplyErrCodeMsg(ctx, ec)
|
||||
return
|
||||
}
|
||||
|
||||
ReplyOk(ctx, nil)
|
||||
}
|
||||
|
||||
func OpDeleteZone(ctx *gin.Context) {
|
||||
req := ctx.MustGet("client_req").(*zoneproto.OpDeleteReq)
|
||||
ec := service.DefaultService.OpDeleteZone(ctx, req.Id)
|
||||
if ec != errcode.ErrCodeZoneSrvOk {
|
||||
logger.Error("OpDeleteZone fail, req: %v, ec: %v", util.ToJson(req), ec)
|
||||
ReplyErrCodeMsg(ctx, ec)
|
||||
return
|
||||
}
|
||||
|
||||
ReplyOk(ctx, nil)
|
||||
}
|
||||
|
||||
func OpGetZoneList(ctx *gin.Context) {
|
||||
req := ctx.MustGet("client_req").(*zoneproto.OpListReq)
|
||||
|
||||
//设置默认页长
|
||||
if req.Limit == 0 {
|
||||
req.Limit = consts.DefaultPageSize
|
||||
}
|
||||
|
||||
list, ec := service.DefaultService.OpGetZoneList(ctx, req)
|
||||
if ec != errcode.ErrCodeZoneSrvOk {
|
||||
logger.Error("OpGetZoneList fail, req: %v, ec: %v", util.ToJson(req), ec)
|
||||
ReplyErrCodeMsg(ctx, ec)
|
||||
return
|
||||
}
|
||||
|
||||
data := &zoneproto.OpListData{
|
||||
List: list,
|
||||
Offset: req.Offset + len(list),
|
||||
}
|
||||
if len(list) >= req.Limit {
|
||||
data.More = 1
|
||||
}
|
||||
ReplyOk(ctx, data)
|
||||
}
|
|
@ -39,6 +39,7 @@ import (
|
|||
tokenproto "service/api/proto/token/proto"
|
||||
userwxaddcheckproto "service/api/proto/userwxaddcheck/proto"
|
||||
vericodeproto "service/api/proto/vericode/proto"
|
||||
zoneproto "service/api/proto/zone/proto"
|
||||
"service/app/mix/conf"
|
||||
"service/dbstruct"
|
||||
"service/library/logger"
|
||||
|
@ -164,6 +165,9 @@ const (
|
|||
|
||||
DBAccountCancellation = "account_cancellation"
|
||||
COLAccountCancellation = "account_cancellation"
|
||||
|
||||
DBZone = "zone"
|
||||
COLZone = "zone"
|
||||
)
|
||||
|
||||
// 商品表
|
||||
|
@ -390,6 +394,11 @@ func (m *Mongo) getColAccountCancellation() *qmgo.Collection {
|
|||
return m.clientMix.Database(DBAccountCancellation).Collection(COLAccountCancellation)
|
||||
}
|
||||
|
||||
// 空间表
|
||||
func (m *Mongo) getColZone() *qmgo.Collection {
|
||||
return m.clientMix.Database(DBZone).Collection(COLZone)
|
||||
}
|
||||
|
||||
// 商品相关
|
||||
func (m *Mongo) CreateProduct(ctx *gin.Context, product *dbstruct.Product) error {
|
||||
col := m.getColProduct()
|
||||
|
@ -3592,3 +3601,46 @@ func (m *Mongo) GetAccountCancellationListByMid(ctx *gin.Context, req *account_c
|
|||
}
|
||||
return accountCancellation, err
|
||||
}
|
||||
|
||||
// 空间相关
|
||||
func (m *Mongo) CreateZone(ctx *gin.Context, zone *dbstruct.Zone) error {
|
||||
col := m.getColZone()
|
||||
_, err := col.InsertOne(ctx, zone)
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *Mongo) UpdateZone(ctx *gin.Context, zone *dbstruct.Zone) error {
|
||||
col := m.getColZone()
|
||||
set := util.EntityToM(zone)
|
||||
set["ut"] = time.Now().Unix()
|
||||
up := qmgo.M{
|
||||
"$set": set,
|
||||
}
|
||||
err := col.UpdateId(ctx, zone.Id, up)
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *Mongo) DeleteZone(ctx *gin.Context, id int64) error {
|
||||
col := m.getColZone()
|
||||
update := qmgo.M{
|
||||
"$set": qmgo.M{
|
||||
"del_flag": 1,
|
||||
},
|
||||
}
|
||||
err := col.UpdateId(ctx, id, update)
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *Mongo) GetZoneList(ctx *gin.Context, req *zoneproto.OpListReq) ([]*dbstruct.Zone, error) {
|
||||
list := make([]*dbstruct.Zone, 0)
|
||||
col := m.getColZone()
|
||||
query := qmgo.M{
|
||||
"del_flag": 0,
|
||||
}
|
||||
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
|
||||
}
|
||||
|
|
|
@ -48,6 +48,9 @@ const (
|
|||
|
||||
DBAccountPunishmentIdSeq = "account_punishment_id_seq"
|
||||
COLAccountPunishmentIdSeq = "account_punishment_id_seq"
|
||||
|
||||
DBZoneIdSeq = "zone_id_seq"
|
||||
COLZoneIdSeq = "zone_id_seq"
|
||||
)
|
||||
|
||||
// UserIdSeq序列表
|
||||
|
@ -115,6 +118,11 @@ func (m *Mongo) getColAccountPunishmentIdSeq() *qmgo.Collection {
|
|||
return m.clientMix.Database(DBAccountPunishmentIdSeq).Collection(COLAccountPunishmentIdSeq)
|
||||
}
|
||||
|
||||
// ZoneIdSeq序列表
|
||||
func (m *Mongo) getColZoneIdSeq() *qmgo.Collection {
|
||||
return m.clientMix.Database(DBZoneIdSeq).Collection(COLZoneIdSeq)
|
||||
}
|
||||
|
||||
// account_id发号器
|
||||
func (m *Mongo) GetAndUpdateAccountIdSeq(ctx *gin.Context) (accountIdSeq *dbstruct.AccountIdSeq, err error) {
|
||||
col := m.getColAccountIdSeq()
|
||||
|
@ -372,3 +380,22 @@ func (m *Mongo) GetAndUpdateAccountPunishmentIdSeq(ctx *gin.Context) (accountpun
|
|||
|
||||
return &accountpunishmentIdSeqInstance, err
|
||||
}
|
||||
|
||||
// zone_id发号器
|
||||
func (m *Mongo) GetAndUpdateZoneIdSeq(ctx *gin.Context) (zoneIdSeq *dbstruct.ZoneIdSeq, err error) {
|
||||
col := m.getColZoneIdSeq()
|
||||
|
||||
change := qmgo.Change{
|
||||
Update: qmgo.M{"$inc": qmgo.M{"seq": 1}},
|
||||
Upsert: true,
|
||||
ReturnNew: false,
|
||||
}
|
||||
|
||||
zoneIdSeqInstance := dbstruct.ZoneIdSeq{}
|
||||
if err = col.Find(ctx, qmgo.M{"_id": "zone_id_seq_id"}).Apply(change, &zoneIdSeqInstance); err != nil {
|
||||
logger.Error("change error : %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
return &zoneIdSeqInstance, err
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import (
|
|||
userwxaddcheckproto "service/api/proto/userwxaddcheck/proto"
|
||||
vasproto "service/api/proto/vas/proto"
|
||||
vericodeproto "service/api/proto/vericode/proto"
|
||||
zoneproto "service/api/proto/zone/proto"
|
||||
"service/apollostruct"
|
||||
businessvalidator "service/app/mix/service/business_validator"
|
||||
"service/bizcommon/common"
|
||||
|
@ -2106,3 +2107,61 @@ func (s *Service) ApiGetAccountCancellationListByMid(ctx *gin.Context, req *acco
|
|||
|
||||
return
|
||||
}
|
||||
|
||||
// Zone
|
||||
func (s *Service) ApiCreateZone(ctx *gin.Context, req *zoneproto.ApiCreateReq) (ec errcode.ErrCode) {
|
||||
ec = errcode.ErrCodeZoneSrvOk
|
||||
err := _DefaultZone.OpCreate(ctx, &zoneproto.OpCreateReq{
|
||||
Zone: req.Zone,
|
||||
})
|
||||
if err != nil {
|
||||
logger.Error("OpCreate fail, req: %v, err: %v", util.ToJson(req), err)
|
||||
ec = errcode.ErrCodeZoneSrvFail
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (s *Service) ApiUpdateZone(ctx *gin.Context, req *zoneproto.ApiUpdateReq) (ec errcode.ErrCode) {
|
||||
ec = errcode.ErrCodeZoneSrvOk
|
||||
err := _DefaultZone.OpUpdate(ctx, &zoneproto.OpUpdateReq{
|
||||
Zone: req.Zone,
|
||||
})
|
||||
if err == qmgo.ErrNoSuchDocuments {
|
||||
ec = errcode.ErrCodeZoneNotExist
|
||||
err = nil
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
logger.Error("OpUpdate fail, req: %v, err: %v", util.ToJson(req), err)
|
||||
ec = errcode.ErrCodeZoneSrvFail
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (s *Service) ApiDeleteZone(ctx *gin.Context, id int64) (ec errcode.ErrCode) {
|
||||
ec = errcode.ErrCodeZoneSrvOk
|
||||
err := _DefaultZone.OpDelete(ctx, id)
|
||||
if err != nil {
|
||||
logger.Error("OpDelete fail, id: %v, err: %v", id, err)
|
||||
ec = errcode.ErrCodeZoneSrvFail
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (s *Service) ApiGetZoneList(ctx *gin.Context, req *zoneproto.ApiListReq) (list []*dbstruct.Zone, ec errcode.ErrCode) {
|
||||
ec = errcode.ErrCodeZoneSrvOk
|
||||
list, err := _DefaultZone.OpList(ctx, &zoneproto.OpListReq{
|
||||
BaseRequest: req.BaseRequest,
|
||||
Offset: req.Offset,
|
||||
Limit: req.Limit,
|
||||
})
|
||||
if err != nil {
|
||||
logger.Error("OpListGetZoneList fail, req: %v, err: %v", util.ToJson(req), err)
|
||||
ec = errcode.ErrCodeZoneSrvFail
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"service/api/consts"
|
||||
zoneproto "service/api/proto/zone/proto"
|
||||
"service/app/mix/dao"
|
||||
"service/dbstruct"
|
||||
"service/library/logger"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
goproto "google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
type Zone struct {
|
||||
store *dao.Store
|
||||
}
|
||||
|
||||
func NewZone(store *dao.Store) (a *Zone) {
|
||||
a = &Zone{
|
||||
store: store,
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (p *Zone) OpCreate(ctx *gin.Context, req *zoneproto.OpCreateReq) error {
|
||||
|
||||
//产生zid
|
||||
zoneIdSeq, err := p.store.GetAndUpdateZoneIdSeq(ctx)
|
||||
if err != nil {
|
||||
logger.Error("GetAndUpdateZoneIdSeq failed : %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
req.Zone.Id = goproto.Int64(zoneIdSeq.Seq)
|
||||
req.Zone.Ct = goproto.Int64(time.Now().Unix())
|
||||
req.Zone.Ut = goproto.Int64(time.Now().Unix())
|
||||
req.Zone.DelFlag = goproto.Int64(consts.Exist)
|
||||
err = p.store.CreateZone(ctx, req.Zone)
|
||||
if err != nil {
|
||||
logger.Error("CreateZone fail, err: %v", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Zone) OpUpdate(ctx *gin.Context, req *zoneproto.OpUpdateReq) error {
|
||||
err := p.store.UpdateZone(ctx, req.Zone)
|
||||
if err != nil {
|
||||
logger.Error("UpdateZone fail, err: %v", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Zone) OpDelete(ctx *gin.Context, id int64) error {
|
||||
err := p.store.DeleteZone(ctx, id)
|
||||
if err != nil {
|
||||
logger.Error("DeleteZone fail, err: %v", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Zone) OpList(ctx *gin.Context, req *zoneproto.OpListReq) ([]*dbstruct.Zone, error) {
|
||||
list, err := p.store.GetZoneList(ctx, req)
|
||||
if err != nil {
|
||||
logger.Error("GetZoneList fail, err: %v", err)
|
||||
return make([]*dbstruct.Zone, 0), err
|
||||
}
|
||||
return list, nil
|
||||
}
|
|
@ -37,6 +37,7 @@ import (
|
|||
userwxaddcheckproto "service/api/proto/userwxaddcheck/proto"
|
||||
vasproto "service/api/proto/vas/proto"
|
||||
vericodeproto "service/api/proto/vericode/proto"
|
||||
zoneproto "service/api/proto/zone/proto"
|
||||
"service/apollostruct"
|
||||
"service/app/mix/conf"
|
||||
"service/app/mix/dao"
|
||||
|
@ -105,6 +106,7 @@ var (
|
|||
_DefaultMomentAuditTask *logic.MomentAuditTask
|
||||
_DefaultAccountPunishment *logic.AccountPunishment
|
||||
_DefaultAccountCancellation *logic.AccountCancellation
|
||||
_DefaultZone *logic.Zone
|
||||
)
|
||||
|
||||
type Service struct {
|
||||
|
@ -183,6 +185,7 @@ func (s *Service) Init(c any) (err error) {
|
|||
_DefaultMomentAuditTask = logic.NewMomentAuditTask(store)
|
||||
_DefaultAccountPunishment = logic.NewAccountPunishment(store)
|
||||
_DefaultAccountCancellation = logic.NewAccountCancellation(store)
|
||||
_DefaultZone = logic.NewZone(store)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -3069,3 +3072,53 @@ func (s *Service) OpGetAccountCancellationList(ctx *gin.Context, req *account_ca
|
|||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Zone
|
||||
func (s *Service) OpCreateZone(ctx *gin.Context, req *zoneproto.OpCreateReq) (ec errcode.ErrCode) {
|
||||
ec = errcode.ErrCodeZoneSrvOk
|
||||
err := _DefaultZone.OpCreate(ctx, req)
|
||||
if err != nil {
|
||||
logger.Error("OpCreate fail, req: %v, err: %v", util.ToJson(req), err)
|
||||
ec = errcode.ErrCodeZoneSrvFail
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (s *Service) OpUpdateZone(ctx *gin.Context, req *zoneproto.OpUpdateReq) (ec errcode.ErrCode) {
|
||||
ec = errcode.ErrCodeZoneSrvOk
|
||||
err := _DefaultZone.OpUpdate(ctx, req)
|
||||
if err == qmgo.ErrNoSuchDocuments {
|
||||
ec = errcode.ErrCodeZoneNotExist
|
||||
err = nil
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
logger.Error("OpUpdate fail, req: %v, err: %v", util.ToJson(req), err)
|
||||
ec = errcode.ErrCodeZoneSrvFail
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (s *Service) OpDeleteZone(ctx *gin.Context, id int64) (ec errcode.ErrCode) {
|
||||
ec = errcode.ErrCodeZoneSrvOk
|
||||
err := _DefaultZone.OpDelete(ctx, id)
|
||||
if err != nil {
|
||||
logger.Error("OpDelete fail, id: %v, err: %v", id, err)
|
||||
ec = errcode.ErrCodeZoneSrvFail
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (s *Service) OpGetZoneList(ctx *gin.Context, req *zoneproto.OpListReq) (list []*dbstruct.Zone, ec errcode.ErrCode) {
|
||||
ec = errcode.ErrCodeZoneSrvOk
|
||||
list, err := _DefaultZone.OpList(ctx, req)
|
||||
if err != nil {
|
||||
logger.Error("OpGetZoneList fail, req: %v, err: %v", util.ToJson(req), err)
|
||||
ec = errcode.ErrCodeZoneSrvFail
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
|
@ -9,10 +9,10 @@ import (
|
|||
func main() {
|
||||
|
||||
genSource := &generator.GenSource{
|
||||
EntityName: "AccountPunishment",
|
||||
ModuleName: "accountpunishment",
|
||||
EntityCNName: "账号处罚",
|
||||
ErrCodeSeq: "32",
|
||||
EntityName: "Zone",
|
||||
ModuleName: "zone",
|
||||
EntityCNName: "空间",
|
||||
ErrCodeSeq: "33",
|
||||
}
|
||||
|
||||
generator.CreateFileDirectory(genSource)
|
||||
|
|
|
@ -56,3 +56,7 @@ type MediaIdSeq struct {
|
|||
type AccountPunishmentIdSeq struct {
|
||||
Seq int64 //用户Id序列号
|
||||
}
|
||||
|
||||
type ZoneIdSeq struct {
|
||||
Seq int64 //用户Id序列号
|
||||
}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package dbstruct
|
||||
|
||||
type Zone struct {
|
||||
Id *int64 `json:"id" bson:"_id"` // 空间表id
|
||||
Mid *int64 `json:"mid" bson:"mid"` // 用户表id
|
||||
Profile *string `json:"profile" bson:"profile"` // 空间简介
|
||||
Ct *int64 `json:"ct" bson:"ct"` // 创建时间
|
||||
Ut *int64 `json:"ut" bson:"ut"` // 更新时间
|
||||
DelFlag *int64 `json:"del_flag" bson:"del_flag"` // 删除标记
|
||||
|
||||
}
|
Loading…
Reference in New Issue