package logic import ( "fusenapi/server/product-template/internal/types" "fusenapi/utils/auth" "fusenapi/utils/basic" "time" "context" "fusenapi/server/product-template/internal/svc" "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(userInfo *auth.BackendUserInfo) (resp *basic.Response) { 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) }