package controller import ( "context" "slogan-agent/common" "slogan-agent/styleagent/model/dto" "slogan-agent/styleagent/service" "github.com/gogf/gf/v2/frame/g" ) type user_photo struct{} var UserPhoto = new(user_photo) func (c *user_photo) Upload(ctx context.Context, req *dto.UserPhotoUploadReq) (res *dto.UserPhotoUploadRes, err error) { id, err := service.UserPhotoService.Upload(ctx, common.GetUserId(g.RequestFromCtx(ctx)), req.Type, g.RequestFromCtx(ctx).GetUploadFile("file")) if err != nil { return nil, err } return &dto.UserPhotoUploadRes{Id: id}, nil } func (c *user_photo) List(ctx context.Context, req *dto.UserPhotoListReq) (res *dto.UserPhotoListRes, err error) { list, err := service.UserPhotoService.List(ctx, common.GetUserId(g.RequestFromCtx(ctx)), req.Type) if err != nil { return nil, err } return &dto.UserPhotoListRes{List: list}, nil } func (c *user_photo) Delete(ctx context.Context, req *dto.UserPhotoDeleteReq) (res *struct{}, err error) { if err := service.UserPhotoService.Delete(ctx, common.GetUserId(g.RequestFromCtx(ctx)), req.Id); err != nil { return nil, err } return &struct{}{}, nil }