feat: import services and standardize Go 1.26.5
This commit is contained in:
75
apps/ec/delivery/internal/logic/team/team_add_logic.go
Normal file
75
apps/ec/delivery/internal/logic/team/team_add_logic.go
Normal file
@@ -0,0 +1,75 @@
|
||||
package deliverylogic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.apinb.com/bsm-sdk/engine/exception"
|
||||
"git.apinb.com/bsm-sdk/engine/service"
|
||||
"git.apinb.com/bsm-sdk/engine/utils"
|
||||
"git.apinb.com/bsm-service-ec/delivery/external/pb/delivery"
|
||||
"git.apinb.com/bsm-service-ec/delivery/internal/models"
|
||||
"git.apinb.com/bsm-service-ec/delivery/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type TeamAddLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewTeamAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TeamAddLogic {
|
||||
return &TeamAddLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// 添加配送团队
|
||||
func (l *TeamAddLogic) TeamAdd(in *delivery.TeamItem) (*delivery.StatusReply, error) {
|
||||
_, err := service.ParseMetaCtx(l.ctx, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err = teamAddChick(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
data := models.DeliveryItem{
|
||||
Identity: utils.ULID(),
|
||||
Title: in.Title,
|
||||
Owner: in.Owner,
|
||||
Contacts: in.Contacts,
|
||||
Phone: in.Phone,
|
||||
Logo: in.Logo,
|
||||
}
|
||||
|
||||
err = models.DBService.Create(&data).Error
|
||||
if err != nil {
|
||||
l.Logger.Error(err.Error())
|
||||
return nil, exception.ErrDBFatal
|
||||
}
|
||||
|
||||
return &delivery.StatusReply{Status: 200, Identity: data.Identity, Message: ""}, nil
|
||||
}
|
||||
|
||||
func teamAddChick(in *delivery.TeamItem) error {
|
||||
if in.GetOwner() == "" {
|
||||
return exception.ErrInvalidArgument
|
||||
}
|
||||
if in.GetPhone() == "" {
|
||||
return exception.ErrInvalidArgument
|
||||
}
|
||||
if in.GetTitle() == "" {
|
||||
return exception.ErrInvalidArgument
|
||||
}
|
||||
if in.GetContacts() == "" {
|
||||
return exception.ErrInvalidArgument
|
||||
}
|
||||
if in.GetLogo() == "" {
|
||||
return exception.ErrInvalidArgument
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user