1
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
||||
|
||||
"slogan-agent/common"
|
||||
"slogan-agent/styleagent/model/dto"
|
||||
"slogan-agent/styleagent/model/entity"
|
||||
"slogan-agent/styleagent/service"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
@@ -16,46 +15,17 @@ type wardrobe struct{}
|
||||
var Wardrobe = new(wardrobe)
|
||||
|
||||
func (c *wardrobe) Upload(ctx context.Context, req *dto.WardrobeUploadReq) (res *dto.WardrobeUploadRes, err error) {
|
||||
id, err := service.WardrobeService.Upload(ctx, common.GetUserId(g.RequestFromCtx(ctx)), entity.WardrobeItem{
|
||||
Category: req.Category,
|
||||
Season: req.Season,
|
||||
StyleTags: req.StyleTags,
|
||||
ColorInfo: req.ColorInfo,
|
||||
}, g.RequestFromCtx(ctx).GetUploadFile("file"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &dto.WardrobeUploadRes{Id: id}, nil
|
||||
return service.WardrobeService.Upload(ctx, common.GetUserId(g.RequestFromCtx(ctx)), req, g.RequestFromCtx(ctx).GetUploadFile("file"))
|
||||
}
|
||||
|
||||
func (c *wardrobe) List(ctx context.Context, req *dto.WardrobeListReq) (res *dto.WardrobeListRes, err error) {
|
||||
list, err := service.WardrobeService.List(ctx, common.GetUserId(g.RequestFromCtx(ctx)), req.Category)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &dto.WardrobeListRes{List: list}, nil
|
||||
return service.WardrobeService.List(ctx, common.GetUserId(g.RequestFromCtx(ctx)), req.Category)
|
||||
}
|
||||
|
||||
func (c *wardrobe) Update(ctx context.Context, req *dto.WardrobeUpdateReq) (res *struct{}, err error) {
|
||||
data := map[string]any{}
|
||||
if req.Category != "" {
|
||||
data["category"] = req.Category
|
||||
}
|
||||
if req.Season != "" {
|
||||
data["season"] = req.Season
|
||||
}
|
||||
if req.StyleTags != "" {
|
||||
data["style_tags"] = req.StyleTags
|
||||
}
|
||||
if err := service.WardrobeService.Update(ctx, common.GetUserId(g.RequestFromCtx(ctx)), req.Id, data); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &struct{}{}, nil
|
||||
func (c *wardrobe) Update(ctx context.Context, req *dto.WardrobeUpdateReq) (res *dto.WardrobeUpdateRes, err error) {
|
||||
return service.WardrobeService.Update(ctx, common.GetUserId(g.RequestFromCtx(ctx)), req)
|
||||
}
|
||||
|
||||
func (c *wardrobe) Delete(ctx context.Context, req *dto.WardrobeDeleteReq) (res *struct{}, err error) {
|
||||
if err := service.WardrobeService.Delete(ctx, common.GetUserId(g.RequestFromCtx(ctx)), req.Id); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &struct{}{}, nil
|
||||
func (c *wardrobe) Delete(ctx context.Context, req *dto.WardrobeDeleteReq) (res *dto.WardrobeDeleteRes, err error) {
|
||||
return service.WardrobeService.Delete(ctx, common.GetUserId(g.RequestFromCtx(ctx)), req.Id)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user