|
@@ -168,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;
|
|
|
/*
|
|
@@ -324,11 +324,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("保存授权商品成功");
|
|
|
}
|
|
|
|
|
@@ -380,6 +382,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);
|
|
|
}
|
|
@@ -443,8 +448,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();
|
|
@@ -471,8 +477,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();
|
|
@@ -527,7 +534,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;
|
|
|
/*
|
|
@@ -535,6 +542,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);
|
|
@@ -574,6 +582,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);
|
|
|
}
|
|
|
|
|
@@ -584,6 +602,7 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
return ResponseJson.error("该设备有绑定设备认证,暂时无法删除");
|
|
|
}
|
|
|
authProductMapper.deleteProductType(productTypeId);
|
|
|
+ authProductMapper.deleteParamsByProductTypeId(productTypeId);
|
|
|
return ResponseJson.success("删除设备分类成功");
|
|
|
}
|
|
|
|
|
@@ -634,4 +653,12 @@ 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);
|
|
|
+ }
|
|
|
+
|
|
|
}
|