|
@@ -11,8 +11,6 @@ import com.caimei.model.po.ProductParamPo;
|
|
|
import com.caimei.model.po.ProductPo;
|
|
|
import com.caimei.model.po.ProductTypePo;
|
|
|
import com.caimei.model.vo.*;
|
|
|
-import com.caimei.module.base.entity.vo.AuthProductVo;
|
|
|
-import com.caimei.module.base.entity.vo.StatementFileVo;
|
|
|
import com.caimei.service.auth.AuthProductService;
|
|
|
import com.caimei.service.auth.UploadService;
|
|
|
import com.caimei.utils.Base64Util;
|
|
@@ -170,9 +168,9 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
return ResponseJson.error("参数异常,请选择二维码授权牌模板", null);
|
|
|
}
|
|
|
}
|
|
|
- if (null == paramList || paramList.size() <= 0) {
|
|
|
+ /*if (null == paramList || paramList.size() <= 0) {
|
|
|
return ResponseJson.error("参数异常,商品参数列表不能为空", null);
|
|
|
- }
|
|
|
+ }*/
|
|
|
// 是否为添加操作
|
|
|
boolean insertFlag = null == productId;
|
|
|
ProductFormVo dbProduct = null;
|
|
@@ -334,11 +332,13 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
// 删除商品参数
|
|
|
authProductMapper.deleteParamsByProductId(product.getProductId());
|
|
|
// 保存商品参数
|
|
|
- paramList.forEach(param -> {
|
|
|
- if (StringUtils.isNotBlank(param.getParamName()) && StringUtils.isNotBlank(param.getParamContent())) {
|
|
|
- authProductMapper.insertProductParam(product.getProductId(), param.getParamName(), param.getParamContent());
|
|
|
- }
|
|
|
- });
|
|
|
+ if (paramList != null) {
|
|
|
+ paramList.forEach(param -> {
|
|
|
+ if (StringUtils.isNotBlank(param.getParamName()) && StringUtils.isNotBlank(param.getParamContent())) {
|
|
|
+ authProductMapper.insertProductParam(product.getProductId(), param.getParamName(), param.getParamContent());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
return ResponseJson.success("保存授权商品成功");
|
|
|
}
|
|
|
|
|
@@ -390,6 +390,9 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
return ResponseJson.error("商品不存在", null);
|
|
|
}
|
|
|
List<ProductParamPo> paramList = authProductMapper.getParamsByProductId(productId);
|
|
|
+ if (null == paramList || paramList.size() == 0) {
|
|
|
+ paramList = authProductMapper.getProductTypeParamList(productForm.getProductTypeId());
|
|
|
+ }
|
|
|
productForm.setParamList(paramList);
|
|
|
return ResponseJson.success(productForm);
|
|
|
}
|
|
@@ -453,8 +456,9 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
// 查询设备分类是否已存在
|
|
|
ProductTypePo productType = authProductMapper.getProductType(null, product.getName(), authUserId);
|
|
|
if (null == productType) {
|
|
|
+ List<ProductParamPo> paramList = authProductMapper.getParamsByProductId(productId);
|
|
|
try {
|
|
|
- ResponseJson<ProductTypePo> result = saveProductType(null, authUserId, product.getName(), product.getImage(), product.getCreateBy(), 2);
|
|
|
+ ResponseJson<ProductTypePo> result = saveProductType(null, authUserId, product.getBrandId(), product.getName(), product.getImage(), product.getCreateBy(), paramList, 2);
|
|
|
int code = result.getCode();
|
|
|
if (0 == code) {
|
|
|
productType = result.getData();
|
|
@@ -481,8 +485,9 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
// 查询设备分类是否已存在
|
|
|
ProductTypePo productType = authProductMapper.getProductType(null, product.getName(), authUserId);
|
|
|
if (null == productType) {
|
|
|
+ List<ProductParamPo> paramList = authProductMapper.getParamsByProductId(productId);
|
|
|
try {
|
|
|
- ResponseJson<ProductTypePo> result = saveProductType(null, authUserId, product.getName(), product.getImage(), product.getCreateBy(), 2);
|
|
|
+ ResponseJson<ProductTypePo> result = saveProductType(null, authUserId, product.getBrandId(), product.getName(), product.getImage(), product.getCreateBy(), paramList, 2);
|
|
|
int code = result.getCode();
|
|
|
if (0 == code) {
|
|
|
productType = result.getData();
|
|
@@ -537,7 +542,7 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public ResponseJson<ProductTypePo> saveProductType(Integer productTypeId, Integer authUserId, String name, String image, Integer createBy, Integer createSource) throws IOException {
|
|
|
+ public ResponseJson<ProductTypePo> saveProductType(Integer productTypeId, Integer authUserId, Integer brandId, String name, String image, Integer createBy, List<ProductParamPo> paramList, Integer createSource) throws IOException {
|
|
|
// 是否为添加操作
|
|
|
boolean insertFlag = null == productTypeId;
|
|
|
/*
|
|
@@ -545,6 +550,7 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
*/
|
|
|
ProductTypePo productType = new ProductTypePo();
|
|
|
productType.setAuthUserId(authUserId);
|
|
|
+ productType.setBrandId(brandId);
|
|
|
productType.setName(name);
|
|
|
productType.setImage(image);
|
|
|
productType.setCreateBy(createBy);
|
|
@@ -584,6 +590,16 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
// 更新设备分类
|
|
|
authProductMapper.updateProductType(productType);
|
|
|
}
|
|
|
+ // 删除设备分类参数
|
|
|
+ authProductMapper.deleteParamsByProductTypeId(productType.getProductTypeId());
|
|
|
+ // 保存商品参数
|
|
|
+ if (null != paramList) {
|
|
|
+ paramList.forEach(param -> {
|
|
|
+ if (StringUtils.isNotBlank(param.getParamName()) && StringUtils.isNotBlank(param.getParamContent())) {
|
|
|
+ authProductMapper.insertProductTypeParam(productType.getProductTypeId(), param.getParamName(), param.getParamContent());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
return ResponseJson.success("保存设备分类成功", productType);
|
|
|
}
|
|
|
|
|
@@ -594,6 +610,7 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
return ResponseJson.error("该设备有绑定设备认证,暂时无法删除");
|
|
|
}
|
|
|
authProductMapper.deleteProductType(productTypeId);
|
|
|
+ authProductMapper.deleteParamsByProductTypeId(productTypeId);
|
|
|
return ResponseJson.success("删除设备分类成功");
|
|
|
}
|
|
|
|
|
@@ -644,6 +661,14 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
return ResponseJson.success(pageData);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public ResponseJson<ProductTypePo> getProductTypeFromData(Integer productTypeId) {
|
|
|
+ ProductTypePo productType = authProductMapper.getProductType(productTypeId, null, null);
|
|
|
+ List<ProductParamPo> paramList = authProductMapper.getProductTypeParamList(productTypeId);
|
|
|
+ productType.setParamList(paramList);
|
|
|
+ return ResponseJson.success(productType);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public ResponseJson checkAuthProduct(Integer productId) {
|
|
|
authProductMapper.checkAuthProduct(productId);
|