epuiment
CI / changes (push) Successful in 37s
CI / ad (push) Successful in 44s
CI / admin (push) Successful in 39s
CI / bff (push) Successful in 32s
CI / chore (push) Successful in 38s
CI / express (push) Successful in 42s
CI / product (push) Successful in 43s
CI / sale (push) Successful in 42s
CI / task (push) Successful in 42s
CI / user (push) Successful in 42s
CI / wecom (push) Successful in 41s
CI / changes (push) Successful in 37s
CI / ad (push) Successful in 44s
CI / admin (push) Successful in 39s
CI / bff (push) Successful in 32s
CI / chore (push) Successful in 38s
CI / express (push) Successful in 42s
CI / product (push) Successful in 43s
CI / sale (push) Successful in 42s
CI / task (push) Successful in 42s
CI / user (push) Successful in 42s
CI / wecom (push) Successful in 41s
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"lone-services/pkg/utils"
|
||||
"lone-services/services/equipment/internal/dao"
|
||||
"lone-services/services/equipment/internal/model"
|
||||
"lone-services/services/task/validator"
|
||||
|
||||
"lone-services/rpc/equipment/pb"
|
||||
"lone-services/services/equipment/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type CreateLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
BaseLogic
|
||||
}
|
||||
|
||||
func NewCreateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateLogic {
|
||||
return &CreateLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *CreateLogic) Create(in *equipment.CreateRequest) (*equipment.Response, error) {
|
||||
var v validator.TaskCreateValidator
|
||||
if fail := l.checkParams(in, &v); fail != nil {
|
||||
return fail, nil
|
||||
}
|
||||
adminInfo := utils.GetUserFromCtx(l.ctx)
|
||||
if adminInfo.ID < utils.NumberOne {
|
||||
return l.fail(utils.ErrorNoLoginInfo)
|
||||
}
|
||||
data := dao.Version{
|
||||
Type: uint8(in.Type),
|
||||
HardwareVersion: in.HardwareVersion,
|
||||
FirmwareSrc: in.FirmwareSrc,
|
||||
SoftSrc: in.SoftSrc,
|
||||
SoftConfig: in.SoftConfig,
|
||||
Version: in.Version,
|
||||
Describe: in.Describe,
|
||||
AddSrc: in.AddSrc,
|
||||
AdminId: adminInfo.ID,
|
||||
AdminName: adminInfo.Name,
|
||||
}
|
||||
|
||||
err := model.VersionModel{}.Init().Create(&data)
|
||||
if err != nil {
|
||||
l.Logger.Error(err)
|
||||
return l.fail(utils.Fail)
|
||||
}
|
||||
|
||||
action := utils.ActionAdd{
|
||||
NewContent: data,
|
||||
Type: utils.LogActionTypeAdd,
|
||||
ModuleName: utils.LogActionModuleEquipment,
|
||||
}
|
||||
utils.SetActionLog(adminInfo, action)
|
||||
|
||||
return l.ok(data.Id)
|
||||
}
|
||||
Reference in New Issue
Block a user