fix: 新增产品时productKey校验

V0.5.x
jay 2023-09-18 14:51:12 +08:00
parent de53e07304
commit c866098564
2 changed files with 7 additions and 1 deletions

View File

@ -104,7 +104,8 @@ public enum ErrCode implements IEnum {
RECORD_NOT_FOUND(00000000, "记录不存在"),
ADD_PLATFORM_USER_ERROR(00000000, "添加平台用户失败"),
UPLOAD_FILE_ERROR(00000000, "上传文件失败"),
FILE_NAME_IS_NULL(00000000, "文件名为空,获取文件名失败");
FILE_NAME_IS_NULL(00000000, "文件名为空,获取文件名失败"),
PRODUCT_KEY_EXIST(00000000, "ProductKey已存在");

View File

@ -87,6 +87,11 @@ public class ProductServiceImpl implements IProductService {
String secret = UUID.randomUUID().toString(true);
product.setProductSecret(secret);
String productKey = data.getProductKey();
Product oldProduct = productData.findByProductKey(productKey);
if(oldProduct != null){
throw new BizException(ErrCode.PRODUCT_KEY_EXIST);
}
productData.save(product);
return MapstructUtils.convert(product, ProductVo.class);