fix
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/server/product-templatev2/internal/types"
|
||||
"fusenapi/utils/basic"
|
||||
"gorm.io/gorm"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"context"
|
||||
|
||||
"fusenapi/server/product-templatev2/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(r *http.Request) (resp *basic.Response) {
|
||||
authKey := r.Header.Get("Auth-Key")
|
||||
genentModel := gmodel.NewFsGerentModel(l.svcCtx.MysqlConn)
|
||||
_, err := genentModel.Find(l.ctx, authKey)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp.SetStatusWithMessage(basic.CodeUnAuth, "please login first..")
|
||||
}
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeUnAuth, "failed to get user info")
|
||||
}
|
||||
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)
|
||||
}
|
||||
@@ -35,15 +35,6 @@ func NewGetTemplatevDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext)
|
||||
|
||||
func (l *GetTemplatevDetailLogic) GetTemplatevDetail(req *types.GetTemplatevDetailReq, r *http.Request) (resp *basic.Response) {
|
||||
authKey := r.Header.Get("Auth-Key")
|
||||
if authKey == "" {
|
||||
return resp.SetStatusWithMessage(basic.CodeUnAuth, "please login first")
|
||||
}
|
||||
if req.TemplateId <= 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "err param template_id")
|
||||
}
|
||||
if req.ModelId <= 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "err param model_id")
|
||||
}
|
||||
genentModel := gmodel.NewFsGerentModel(l.svcCtx.MysqlConn)
|
||||
_, err := genentModel.Find(l.ctx, authKey)
|
||||
if err != nil {
|
||||
@@ -53,6 +44,12 @@ func (l *GetTemplatevDetailLogic) GetTemplatevDetail(req *types.GetTemplatevDeta
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeUnAuth, "failed to get user info")
|
||||
}
|
||||
if req.TemplateId <= 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "err param template_id")
|
||||
}
|
||||
if req.ModelId <= 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "err param model_id")
|
||||
}
|
||||
//获取模型信息
|
||||
productModel3dModel := gmodel.NewFsProductModel3dModel(l.svcCtx.MysqlConn)
|
||||
model3dInfo, err := productModel3dModel.FindOne(l.ctx, req.ModelId)
|
||||
|
||||
Reference in New Issue
Block a user