This commit is contained in:
caozehui
2024-11-26 10:04:01 +08:00
parent c125f20de4
commit 2cffee4287
10 changed files with 67 additions and 14 deletions

View File

@@ -2,5 +2,7 @@
设备模块主要包含以下功能:
* 被检设备管理
* 检测脚本管理
* 误差体系管理
* 检测源管理

View File

@@ -16,7 +16,7 @@ public interface DeviceValidMessage {
String NAME_FORMAT_ERROR = "名称格式错误请检查name参数";
String PATTERN_NOT_BLANK = "设备模式不能为空请检查pattern参数";
String PATTERN_NOT_BLANK = "模式不能为空请检查pattern参数";
String DEV_TYPE_NOT_BLANK = "设备类型不能为空请检查devType参数";
@@ -60,7 +60,7 @@ public interface DeviceValidMessage {
String RECHECK_NUM_FORMAT_ERROR = "复检次数格式错误请检查recheckNum参数";
String PATTERN_FORMAT_ERROR = "设备模式格式错误请检查pattern参数";
String PATTERN_FORMAT_ERROR = "模式格式错误请检查pattern参数";
String DEV_TYPE_FORMAT_ERROR = "设备类型格式错误请检查devType参数";
@@ -111,4 +111,10 @@ public interface DeviceValidMessage {
String MAX_ERROR_VALUE_NOT_NULL = "最大误差值不能为空请检查maxErrorValue参数";
String ERROR_VALUE_TYPE_NOT_BLANK = "误差值类型不能为空请检查errorValueType参数";
String PQ_SOURCE_TYPE_NOT_BLANK = "检测源类型不能为空请检查pqSourceType参数";
String PQ_SOURCE_TYPE_FORMAT_ERROR = "检测源类型格式错误请检查pqSourceType参数";
String ENABLE_NOT_NULL = "状态不能为空请检查enable参数";
}

View File

@@ -1,6 +1,9 @@
package com.njcn.gather.system.auth.controller;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.njcn.common.bean.CustomCacheUtil;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.OperateType;
import com.njcn.common.pojo.constant.SecurityConstants;
@@ -9,8 +12,8 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.JwtUtil;
import com.njcn.common.utils.LogUtil;
import com.njcn.db.mybatisplus.constant.UserConstant;
import com.njcn.gather.system.auth.pojo.Token;
import com.njcn.gather.system.pojo.constant.SystemValidMessage;
import com.njcn.gather.user.pojo.constant.UserValidMessage;
import com.njcn.gather.user.user.pojo.param.SysUserParam;
import com.njcn.gather.user.user.pojo.po.SysUser;
@@ -69,7 +72,7 @@ public class AuthController extends BaseController {
LogUtil.njcnDebug(log, "{},登录参数为:{}", methodDescribe, param);
SysUser user = sysUserService.getUserByLoginNameAndPassword(param.getUsername(), param.getPassword());
if (user == null) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL,null, UserValidMessage.LOGIN_FAILED);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, UserValidMessage.LOGIN_FAILED);
} else {
String tokenStr = JwtUtil.generateToken(user.getId());
Token token = new Token();
@@ -77,6 +80,8 @@ public class AuthController extends BaseController {
Map<String, Object> map = new HashMap<>();
map.put("name", user.getName());
token.setUserInfo(map);
CustomCacheUtil customCacheUtil = SpringUtil.getBean(CustomCacheUtil.CACHE_NAME);
customCacheUtil.putWithExpireTime(UserConstant.USER_ID, user.getId(), DateUnit.DAY.getMillis());
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, token, methodDescribe);
}
}
@@ -90,6 +95,8 @@ public class AuthController extends BaseController {
String authorization = request.getHeader(SecurityConstants.AUTHORIZATION_KEY);
if (StrUtil.isNotBlank(authorization)) {
String token = authorization.replace(SecurityConstants.AUTHORIZATION_PREFIX, Strings.EMPTY);
CustomCacheUtil customCacheUtil = SpringUtil.getBean(CustomCacheUtil.CACHE_NAME);
customCacheUtil.remove(UserConstant.USER_ID);
JwtUtil.invalidateToken(token);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}

View File

@@ -11,7 +11,6 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.LogUtil;
import com.njcn.gather.system.dictionary.pojo.param.DictDataParam;
import com.njcn.gather.system.dictionary.pojo.param.DictTypeParam;
import com.njcn.gather.system.dictionary.pojo.po.DictData;
import com.njcn.gather.system.dictionary.service.IDictDataService;
import com.njcn.web.controller.BaseController;

View File

@@ -88,4 +88,6 @@ public interface SystemValidMessage {
String AUTO_GENERATE_FORMAT_ERROR = "是否自动生成格式错误请检查autoGenerate参数";
String TOKEN_VALID_ERROR = "token校验失败";
String USER_ID_FORMAT_ERROR = "用户id格式错误请检查userId参数";
}

View File

@@ -8,6 +8,7 @@ import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.LogUtil;
import com.njcn.gather.system.reg.pojo.param.SysRegResParam;
import com.njcn.gather.system.reg.pojo.po.SysRegRes;
import com.njcn.gather.system.reg.pojo.vo.SysRegResVO;
import com.njcn.gather.system.reg.service.ISysRegResService;
import com.njcn.web.controller.BaseController;
import com.njcn.web.utils.HttpResultUtil;
@@ -19,6 +20,9 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* @author caozehui
@@ -32,6 +36,16 @@ import org.springframework.web.bind.annotation.*;
public class SysRegResController extends BaseController {
private final ISysRegResService sysRegResService;
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
@GetMapping("/list")
@ApiOperation("查询注册版本列表")
public HttpResult<Map<String,SysRegResVO>> listRegRes() {
String methodDescribe = getMethodDescribe("listRegRes");
LogUtil.njcnDebug(log, "{},查询参数为空", methodDescribe);
Map<String,SysRegResVO> result = sysRegResService.listRegRes();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
@GetMapping("/getRegResByType")
@ApiOperation("根据类型id查询配置")
@@ -47,7 +61,7 @@ public class SysRegResController extends BaseController {
@PostMapping("/add")
@ApiOperation("新增注册版本")
@ApiImplicitParam(name = "sysRegRes", value = "注册版本对象", required = true)
public HttpResult<String> addRegRes(@RequestParam @Validated SysRegResParam param) {
public HttpResult<String> addRegRes(@RequestBody @Validated SysRegResParam param) {
String methodDescribe = getMethodDescribe("addRegRes");
LogUtil.njcnDebug(log, "{},新增参数为:{}", methodDescribe, param);
boolean result = sysRegResService.addRegRes(param);

View File

@@ -15,17 +15,17 @@ import javax.validation.constraints.Pattern;
@Data
public class SysRegResParam {
@ApiModelProperty("版本类型")
@NotBlank(message = SystemValidMessage.TYPE_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = SystemValidMessage.ID_FORMAT_ERROR)
private String type;
// @ApiModelProperty("版本类型")
// @NotBlank(message = SystemValidMessage.TYPE_NOT_BLANK)
// @Pattern(regexp = PatternRegex.SYSTEM_ID, message = SystemValidMessage.ID_FORMAT_ERROR)
// private String type;
@ApiModelProperty("注册码")
@NotBlank(message = SystemValidMessage.CODE_NOT_BLANK)
private String code;
@ApiModelProperty("密钥")
private String licenseKey;
// @ApiModelProperty("密钥")
// private String licenseKey;
@Data
public static class UpdateParam {

View File

@@ -3,8 +3,10 @@ package com.njcn.gather.system.reg.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.gather.system.reg.pojo.param.SysRegResParam;
import com.njcn.gather.system.reg.pojo.po.SysRegRes;
import com.njcn.gather.system.reg.pojo.vo.SysRegResVO;
import java.util.List;
import java.util.Map;
/**
* @author caozehui
@@ -30,4 +32,10 @@ public interface ISysRegResService extends IService<SysRegRes> {
* @return 成功返回true失败返回false
*/
boolean updateRegRes(SysRegResParam.UpdateParam param);
/**
* 查询版本注册表列表
* @return 版本注册信息
*/
Map<String,SysRegResVO> listRegRes();
}

View File

@@ -6,11 +6,15 @@ import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.gather.system.reg.mapper.SysRegResMapper;
import com.njcn.gather.system.reg.pojo.param.SysRegResParam;
import com.njcn.gather.system.reg.pojo.po.SysRegRes;
import com.njcn.gather.system.reg.pojo.vo.SysRegResVO;
import com.njcn.gather.system.reg.service.ISysRegResService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
/**
* @author caozehui
* @date 2024-11-21
@@ -30,7 +34,7 @@ public class SysRegResServiceImpl extends ServiceImpl<SysRegResMapper, SysRegRes
SysRegRes sysRegRes = new SysRegRes();
BeanUtil.copyProperties(sysRegResParam, sysRegRes);
sysRegRes.setState(DataStateEnum.ENABLE.getCode());
// todo 到期时间处理
// todo 解析注册码
return this.save(sysRegRes);
}
@@ -43,4 +47,15 @@ public class SysRegResServiceImpl extends ServiceImpl<SysRegResMapper, SysRegRes
}
return this.updateById(sysRegRes);
}
@Override
public Map<String, SysRegResVO> listRegRes() {
Map<String, SysRegResVO> map = new HashMap<>();
this.list().forEach(item -> {
SysRegResVO sysRegResVO = new SysRegResVO();
BeanUtil.copyProperties(item, sysRegResVO);
map.put(item.getType(), sysRegResVO);
});
return map;
}
}

View File

@@ -37,7 +37,7 @@ import java.util.List;
@Slf4j
@Api(tags = "用户管理")
@RestController
@RequestMapping("sysUser")
@RequestMapping("/sysUser")
@RequiredArgsConstructor
public class SysUserController extends BaseController {