fusenapi/server/data-transfer/internal/logic/getstandardlogolistlogic.go
laodaming 33600c48eb fix
2023-06-15 12:00:32 +08:00

49 lines
1.3 KiB
Go

package logic
import (
"context"
"fusenapi/model/gmodel"
svc2 "fusenapi/server/data-transfer/internal/svc"
types2 "fusenapi/server/data-transfer/internal/types"
"fusenapi/utils/auth"
"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(userinfo *auth.UserInfo) (resp *basic.Response) {
if userinfo.GetIdType() != auth.IDTYPE_User {
return resp.SetStatusWithMessage(basic.CodeServiceErr, "please login first")
}
standardLogoModel := gmodel.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)
}