50 lines
1.0 KiB
Go
50 lines
1.0 KiB
Go
|
|
// Code scaffolded by goctl. Safe to edit.
|
||
|
|
// goctl 1.10.1
|
||
|
|
|
||
|
|
package brand
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
|
||
|
|
domusecase "haixun-backend/internal/model/brand/domain/usecase"
|
||
|
|
"haixun-backend/internal/svc"
|
||
|
|
"haixun-backend/internal/types"
|
||
|
|
|
||
|
|
"github.com/zeromicro/go-zero/core/logx"
|
||
|
|
)
|
||
|
|
|
||
|
|
type CreateBrandLogic struct {
|
||
|
|
logx.Logger
|
||
|
|
ctx context.Context
|
||
|
|
svcCtx *svc.ServiceContext
|
||
|
|
}
|
||
|
|
|
||
|
|
func NewCreateBrandLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateBrandLogic {
|
||
|
|
return &CreateBrandLogic{
|
||
|
|
Logger: logx.WithContext(ctx),
|
||
|
|
ctx: ctx,
|
||
|
|
svcCtx: svcCtx,
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func (l *CreateBrandLogic) CreateBrand(req *types.CreateBrandReq) (resp *types.BrandData, err error) {
|
||
|
|
tenantID, uid, err := actorFrom(l.ctx)
|
||
|
|
if err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
displayName := ""
|
||
|
|
if req != nil {
|
||
|
|
displayName = req.DisplayName
|
||
|
|
}
|
||
|
|
item, err := l.svcCtx.Brand.Create(l.ctx, domusecase.CreateRequest{
|
||
|
|
TenantID: tenantID,
|
||
|
|
OwnerUID: uid,
|
||
|
|
DisplayName: displayName,
|
||
|
|
})
|
||
|
|
if err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
out := toBrandData(*item)
|
||
|
|
return &out, nil
|
||
|
|
}
|