代码调整
This commit is contained in:
@@ -21,7 +21,13 @@ public enum SystemResponseEnum {
|
||||
CODE_REPEAT("A01005", "该层级下已存在相同的编码"),
|
||||
CAN_NOT_DELETE_USED_DICT("A01006", "该字典在使用中,不能删除"),
|
||||
CAN_NOT_UPDATE_USED_DICT("A01007", "该字典在使用中,不能修改"),
|
||||
LOG_RECORD_FAILED("A01008", "日志记录失败");
|
||||
LOG_RECORD_FAILED("A01008", "日志记录失败"),
|
||||
|
||||
|
||||
GET_MAC_ADDRESS_FAILED("A01040", "获取本机MAC地址失败"),
|
||||
REGISTRATION_CODE_FORMAT_ERROR("A01041", "注册码格式错误"),
|
||||
MAC_ADDRESS_NOT_MATCH("A01042","注册码中的MAC地址与本机MAC地址不匹配"),
|
||||
REGISTRATION_CODE_EXPIRED("A01043","注册码已过期"),;
|
||||
|
||||
private final String code;
|
||||
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.njcn.gather.system.reg.pojo.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2025-02-11
|
||||
*/
|
||||
@Getter
|
||||
public enum RegResponseEnum {
|
||||
|
||||
GET_MAC_ADDRESS_FAILED("A005001", "获取本机MAC地址失败"),
|
||||
REGISTRATION_CODE_FORMAT_ERROR("A005002", "注册码格式错误"),
|
||||
MAC_ADDRESS_NOT_MATCH("A005003","注册码中的MAC地址与本机MAC地址不匹配"),
|
||||
REGISTRATION_CODE_EXPIRED("A005004","注册码已过期"),;
|
||||
|
||||
private final String code;
|
||||
private final String message;
|
||||
|
||||
RegResponseEnum(String code, String message) {
|
||||
this.message = message;
|
||||
this.code = code;
|
||||
}
|
||||
}
|
||||
@@ -12,9 +12,9 @@ import com.njcn.gather.system.cfg.service.ISysTestConfigService;
|
||||
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictData;
|
||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||
import com.njcn.gather.system.pojo.enums.SystemResponseEnum;
|
||||
import com.njcn.gather.system.reg.mapper.SysRegResMapper;
|
||||
import com.njcn.gather.system.reg.pojo.dto.RegInfoData;
|
||||
import com.njcn.gather.system.reg.pojo.enums.RegResponseEnum;
|
||||
import com.njcn.gather.system.reg.pojo.enums.RegStatusEnum;
|
||||
import com.njcn.gather.system.reg.pojo.param.SysRegResParam;
|
||||
import com.njcn.gather.system.reg.pojo.po.SysRegRes;
|
||||
@@ -102,7 +102,7 @@ public class SysRegResServiceImpl extends ServiceImpl<SysRegResMapper, SysRegRes
|
||||
// 对比Mac地址
|
||||
String mac = getMAC();
|
||||
if (!mac.equals(regInfoData.getMacAddress())) {
|
||||
throw new BusinessException(RegResponseEnum.MAC_ADDRESS_NOT_MATCH);
|
||||
throw new BusinessException(SystemResponseEnum.MAC_ADDRESS_NOT_MATCH);
|
||||
}
|
||||
|
||||
List<String> expireDateList = regInfoData.getExpireDateList();
|
||||
@@ -112,7 +112,7 @@ public class SysRegResServiceImpl extends ServiceImpl<SysRegResMapper, SysRegRes
|
||||
// 比对到期日期
|
||||
String maxExpireDate = expireDateList.stream().max((a, b) -> a.compareTo(b)).get();
|
||||
if (LocalDate.parse(maxExpireDate).isBefore(LocalDate.now())) {
|
||||
throw new BusinessException(RegResponseEnum.REGISTRATION_CODE_EXPIRED);
|
||||
throw new BusinessException(SystemResponseEnum.REGISTRATION_CODE_EXPIRED);
|
||||
}
|
||||
|
||||
sysTestConfigService.addTestConfig(regInfoData.getScene());
|
||||
@@ -254,7 +254,7 @@ public class SysRegResServiceImpl extends ServiceImpl<SysRegResMapper, SysRegRes
|
||||
try {
|
||||
inetAddress = InetAddress.getLocalHost();
|
||||
} catch (UnknownHostException e) {
|
||||
throw new BusinessException(RegResponseEnum.GET_MAC_ADDRESS_FAILED);
|
||||
throw new BusinessException(SystemResponseEnum.GET_MAC_ADDRESS_FAILED);
|
||||
}
|
||||
return NetUtil.getMacAddress(inetAddress);
|
||||
}
|
||||
@@ -311,11 +311,11 @@ public class SysRegResServiceImpl extends ServiceImpl<SysRegResMapper, SysRegRes
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
RegInfoData regInfoData = objectMapper.readValue(decodedString, RegInfoData.class);
|
||||
if (ObjectUtil.isNull(regInfoData) || ObjectUtil.isNull(regInfoData.getScene()) || regInfoData.getTypeList().size() == 0 || regInfoData.getTypeList().size() != regInfoData.getExpireDateList().size()) {
|
||||
throw new BusinessException(RegResponseEnum.REGISTRATION_CODE_FORMAT_ERROR);
|
||||
throw new BusinessException(SystemResponseEnum.REGISTRATION_CODE_FORMAT_ERROR);
|
||||
}
|
||||
return regInfoData;
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException(RegResponseEnum.REGISTRATION_CODE_FORMAT_ERROR);
|
||||
throw new BusinessException(SystemResponseEnum.REGISTRATION_CODE_FORMAT_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user