feat: import services and standardize Go 1.26.5
This commit is contained in:
59
apps/ec/market/internal/logic/agency/create.go
Normal file
59
apps/ec/market/internal/logic/agency/create.go
Normal file
@@ -0,0 +1,59 @@
|
||||
package agency
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"git.apinb.com/bsm-ec/market/internal/models"
|
||||
pb "git.apinb.com/bsm-ec/market/pb"
|
||||
"git.apinb.com/bsm-sdk/core/errcode"
|
||||
"git.apinb.com/bsm-sdk/core/types"
|
||||
"git.apinb.com/bsm-sdk/core/utils"
|
||||
)
|
||||
|
||||
// 新增代理商
|
||||
func Create(ctx context.Context, in *pb.MarketAgenctyItem) (reply *pb.StatusReply, err error) {
|
||||
// _, err = service.ParseMetaCtx(ctx, nil)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
if in.GetName() == "" || in.GetAccount() == "" || in.GetPassword() == "" {
|
||||
return nil, errcode.ErrInvalidArgument
|
||||
}
|
||||
salt := utils.RandomString(8)
|
||||
mktModel := &models.MarketAgency{
|
||||
Std_IICUDS: types.Std_IICUDS{Identity: utils.ULID(), Status: 1},
|
||||
Name: in.GetName(),
|
||||
Avatar: in.GetAvatar(),
|
||||
Account: in.GetAccount(),
|
||||
Phone: in.GetPhone(),
|
||||
Password: utils.Md5(in.Password + salt),
|
||||
Salt: salt,
|
||||
OrgName: in.GetOrgName(),
|
||||
OrgPhoto: in.GetOrgPhoto(),
|
||||
IDName: in.GetIdName(),
|
||||
IDBefore: in.GetIdBefore(),
|
||||
IDAfter: in.GetIdAfter(),
|
||||
Remark: in.GetRemark(),
|
||||
CommissionRate: in.GetCommissionRate(),
|
||||
AgencyType: in.GetAgencyType(),
|
||||
Email: in.GetEmail(),
|
||||
Country: in.GetCountry(),
|
||||
Area: in.GetArea(),
|
||||
}
|
||||
fmt.Println("mktModel = ", mktModel)
|
||||
if err := models.DBService.Create(&mktModel).Error; err != nil {
|
||||
fmt.Println("err = ", err)
|
||||
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &pb.StatusReply{
|
||||
Code: 0,
|
||||
Message: "OK",
|
||||
Identity: mktModel.Identity,
|
||||
Timeseq: time.Now().UnixMilli(),
|
||||
}, nil
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user