| 
									
										
										
										
											2023-06-21 15:06:09 +08:00
										 |  |  | package logic | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							| 
									
										
										
										
											2023-06-25 14:11:47 +08:00
										 |  |  | 	"fusenapi/server/product-template/internal/types" | 
					
						
							| 
									
										
										
										
											2023-06-26 18:27:38 +08:00
										 |  |  | 	"fusenapi/utils/auth" | 
					
						
							| 
									
										
										
										
											2023-06-21 15:06:09 +08:00
										 |  |  | 	"fusenapi/utils/basic" | 
					
						
							|  |  |  | 	"time" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	"context" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-25 14:11:47 +08:00
										 |  |  | 	"fusenapi/server/product-template/internal/svc" | 
					
						
							| 
									
										
										
										
											2023-07-21 15:20:18 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-21 15:06:09 +08: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, | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-21 15:20:18 +08:00
										 |  |  | func (l *GetBaseMapListLogic) GetBaseMapList(req *types.Request, userinfo *auth.BackendUserInfo) (resp *basic.Response) { | 
					
						
							| 
									
										
										
										
											2023-06-21 15:06:09 +08: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) | 
					
						
							|  |  |  | } |