快递,添加、编辑、名称、列表、详情
This commit is contained in:
@@ -2,9 +2,12 @@ package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"lone-services/pkg/utils"
|
||||
"lone-services/rpc/express/pb"
|
||||
"lone-services/services/express/internal/dao"
|
||||
"lone-services/services/express/internal/model"
|
||||
"lone-services/services/express/internal/svc"
|
||||
"lone-services/services/express/validator"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
@@ -25,7 +28,46 @@ func NewCreateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateLogi
|
||||
}
|
||||
|
||||
func (l *CreateLogic) Create(in *express.CreateRequest) (*express.Response, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
var v validator.EditValidator
|
||||
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.Express{
|
||||
Name: in.Name,
|
||||
TransitId: uint8(in.TransitId),
|
||||
AppCode: in.AppCode,
|
||||
AppSecretKey: in.AppSecretKey,
|
||||
AppUrl: in.AppUrl,
|
||||
CardNumber: in.CardNumber,
|
||||
PdfCode: in.PdfCode,
|
||||
Province: in.Province,
|
||||
City: in.City,
|
||||
County: in.County,
|
||||
Address: in.Address,
|
||||
CompanyName: in.CompanyName,
|
||||
Contact: in.Contact,
|
||||
Mobile: in.Mobile,
|
||||
Other: in.Other,
|
||||
AdminId: adminInfo.ID,
|
||||
AdminName: adminInfo.Name,
|
||||
}
|
||||
|
||||
return &express.Response{}, nil
|
||||
err := model.ExpressModel{}.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.LogActionModuleExpress,
|
||||
}
|
||||
utils.SetActionLog(adminInfo, action)
|
||||
|
||||
return l.ok(data.Id)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user