feat: wecom message init
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package dao
|
||||
|
||||
// 编辑申请对象类型
|
||||
const (
|
||||
ApplyLogTypeProduct uint8 = 1 // 产品
|
||||
ApplyLogTypeStore uint8 = 2 // 门店
|
||||
ApplyLogTypeAddress uint8 = 3 // 地址
|
||||
ApplyLogTypeSales uint8 = 4 // 销售
|
||||
)
|
||||
|
||||
// 编辑申请状态
|
||||
const (
|
||||
ApplyStatusDone uint8 = 1 // 通过
|
||||
ApplyStatusNotPass uint8 = 2 // 驳回
|
||||
ApplyStatusWaitPass uint8 = 9 // 待审核
|
||||
)
|
||||
|
||||
type ActionApplyLogCreate struct {
|
||||
Id int `gorm:"column:id;primaryKey;autoIncrement"`
|
||||
AdminId int `gorm:"column:admin_id"`
|
||||
ObjId int `gorm:"column:obj_id"`
|
||||
Type uint8 `gorm:"column:type"`
|
||||
Reason string `gorm:"column:reason"`
|
||||
Status uint8 `gorm:"column:status"`
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"lone-services/pkg/utils"
|
||||
chore "lone-services/rpc/chore/pb"
|
||||
"lone-services/services/chore/internal/dao"
|
||||
"lone-services/services/chore/internal/model"
|
||||
"lone-services/services/chore/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
type InternalActionApplyLogCreateLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewInternalActionApplyLogCreateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InternalActionApplyLogCreateLogic {
|
||||
return &InternalActionApplyLogCreateLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// InternalActionApplyLogCreate 服务间写入编辑申请日志
|
||||
func (l *InternalActionApplyLogCreateLogic) InternalActionApplyLogCreate(in *chore.InternalActionApplyLogCreateReq) (*chore.InternalActionApplyLogCreateData, error) {
|
||||
if in.GetAdminId() < int64(utils.NumberOne) || in.GetObjId() < int64(utils.NumberOne) {
|
||||
return nil, status.Error(codes.InvalidArgument, utils.ErrorParams.Msg)
|
||||
}
|
||||
if in.GetType() < 1 || in.GetStatus() < 1 {
|
||||
return nil, status.Error(codes.InvalidArgument, utils.ErrorParams.Msg)
|
||||
}
|
||||
|
||||
add := dao.ActionApplyLogCreate{
|
||||
AdminId: int(in.GetAdminId()),
|
||||
ObjId: int(in.GetObjId()),
|
||||
Type: uint8(in.GetType()),
|
||||
Reason: in.GetReason(),
|
||||
Status: uint8(in.GetStatus()),
|
||||
}
|
||||
if err := (model.ActionApplyLogModel{}.Init().Create(&add)); err != nil {
|
||||
l.Errorf("action apply log create: %v", err)
|
||||
return nil, status.Error(codes.Internal, utils.Fail.Msg)
|
||||
}
|
||||
return &chore.InternalActionApplyLogCreateData{Id: int64(add.Id)}, nil
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"lone-services/pkg/modelbase"
|
||||
"lone-services/services/chore/internal/dao"
|
||||
)
|
||||
|
||||
type ActionApplyLogModel struct {
|
||||
modelbase.Base
|
||||
}
|
||||
|
||||
func (m ActionApplyLogModel) TableName() string {
|
||||
return modelbase.Prefix() + "action_apply_log"
|
||||
}
|
||||
|
||||
func (m ActionApplyLogModel) Init() ActionApplyLogModel {
|
||||
m.Table = m.TableName()
|
||||
return m
|
||||
}
|
||||
|
||||
func (m ActionApplyLogModel) Create(data *dao.ActionApplyLogCreate) error {
|
||||
return m.Base.Create(data)
|
||||
}
|
||||
@@ -98,3 +98,9 @@ func (s *ChoreServer) RegionsByIds(ctx context.Context, in *chore.RegionsByIdsRe
|
||||
l := logic.NewRegionsByIdsLogic(ctx, s.svcCtx)
|
||||
return l.RegionsByIds(in)
|
||||
}
|
||||
|
||||
// 服务间:写入编辑申请日志
|
||||
func (s *ChoreServer) InternalActionApplyLogCreate(ctx context.Context, in *chore.InternalActionApplyLogCreateReq) (*chore.InternalActionApplyLogCreateData, error) {
|
||||
l := logic.NewInternalActionApplyLogCreateLogic(ctx, s.svcCtx)
|
||||
return l.InternalActionApplyLogCreate(in)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user