fusenapi/server/product-template/internal/logic/getbasemaplistlogic.go

48 lines
1.2 KiB
Go
Raw Normal View History

2023-06-21 07:06:09 +00:00
package logic
import (
2023-06-25 06:11:47 +00:00
"fusenapi/server/product-template/internal/types"
2023-06-26 10:27:38 +00:00
"fusenapi/utils/auth"
2023-06-21 07:06:09 +00:00
"fusenapi/utils/basic"
"time"
"context"
2023-06-25 06:11:47 +00:00
"fusenapi/server/product-template/internal/svc"
2023-06-21 07:06:09 +00:00
"github.com/zeromicro/go-zero/core/logx"
)
type GetBaseMapListLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewGetBaseMapListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetBaseMapListLogic {
return &GetBaseMapListLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *GetBaseMapListLogic) GetBaseMapList(req *types.Request, userinfo *auth.BackendUserInfo) (resp *basic.Response) {
2023-06-21 07:06:09 +00:00
baseMapFields := "id,name,url,ctime"
baseMapList, err := l.svcCtx.AllModels.FsProductTemplateBasemap.GetAllEnabledList(l.ctx, baseMapFields)
if err != nil {
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product base map list")
}
list := make([]types.GetBaseMapListRsp, 0, len(baseMapList))
for _, v := range baseMapList {
list = append(list, types.GetBaseMapListRsp{
Id: v.Id,
Name: *v.Name,
Url: *v.Url,
Ctime: time.Unix(*v.Ctime, 0).Format("2006-01-02 15:04:05"),
})
}
return resp.SetStatusWithMessage(basic.CodeOK, "success", list)
}