53 lines
1.6 KiB
Go
53 lines
1.6 KiB
Go
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
|
|
}
|