fusenapi/server/data-transfer/internal/logic/getstandardlogolistlogic.go
laodaming a9e0f6b98e fix
2023-06-08 11:03:20 +08:00

45 lines
1.2 KiB
Go

package logic
import (
"context"
"fusenapi/model"
svc2 "fusenapi/server/data-transfer/internal/svc"
types2 "fusenapi/server/data-transfer/internal/types"
"fusenapi/utils/basic"
"github.com/zeromicro/go-zero/core/logx"
)
type GetStandardLogoListLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc2.ServiceContext
}
func NewGetStandardLogoListLogic(ctx context.Context, svcCtx *svc2.ServiceContext) *GetStandardLogoListLogic {
return &GetStandardLogoListLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
// 获取标准logo列表
func (l *GetStandardLogoListLogic) GetStandardLogoList() (resp *types2.Response) {
standardLogoModel := model.NewFsStandardLogoModel(l.svcCtx.MysqlConn)
logoList, err := standardLogoModel.GetAll(l.ctx)
if err != nil {
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get standard logo list")
}
list := make([]types2.GetStandardLogoListRsp, 0, len(logoList))
for _, v := range logoList {
list = append(list, types2.GetStandardLogoListRsp{
Id: v.Id,
Name: v.Name,
Url: v.Image,
})
}
return resp.SetStatusWithMessage(basic.CodeOK, "success", list)
}