66 lines
2.1 KiB
Go
66 lines
2.1 KiB
Go
package logic
|
|
|
|
import (
|
|
"context"
|
|
"fusenapi/utils/basic"
|
|
"net/http"
|
|
|
|
"fusenapi/server/product-templatev2/internal/svc"
|
|
"fusenapi/server/product-templatev2/internal/types"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type GetTemplatevDetailLogic struct {
|
|
logx.Logger
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
func NewGetTemplatevDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetTemplatevDetailLogic {
|
|
return &GetTemplatevDetailLogic{
|
|
Logger: logx.WithContext(ctx),
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
}
|
|
}
|
|
|
|
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 {
|
|
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")
|
|
}
|
|
//查询产品模型并肩测数据完整性
|
|
productModel3dModel := gmodel.NewFsProductModel3dModel(l.svcCtx.MysqlConn)
|
|
model3dInfo, err := productModel3dModel.FindOne(l.ctx, req.ModelId)
|
|
if err != nil {
|
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
|
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "product model info is not exists")
|
|
}
|
|
logx.Error(err)
|
|
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get product model info")
|
|
}
|
|
//配件ids
|
|
partIds, err := format.StrSlicToIntSlice(strings.Split(*model3dInfo.PartList, ","))
|
|
//产品模型数据解析model_info
|
|
if model3dInfo.ModelInfo != nil && *model3dInfo.ModelInfo != "" {
|
|
|
|
}*/
|
|
return resp.SetStatus(basic.CodeOK)
|
|
}
|