Merge branch 'test-training2' of https://git.code.tencent.com/lian-cbtc/rtss-server into test-training2-xzb1

This commit is contained in:
xzb 2022-10-09 18:03:48 +08:00
commit ceadaccb3b
4 changed files with 44 additions and 50 deletions

View File

@ -2,6 +2,7 @@ package club.joylink.rtss.controller.project;
import club.joylink.rtss.constants.ProjectDeviceType; import club.joylink.rtss.constants.ProjectDeviceType;
import club.joylink.rtss.controller.advice.AuthenticateInterceptor; import club.joylink.rtss.controller.advice.AuthenticateInterceptor;
import club.joylink.rtss.entity.project.Project;
import club.joylink.rtss.services.project.DeviceService; import club.joylink.rtss.services.project.DeviceService;
import club.joylink.rtss.vo.AccountVO; import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.LoginUserInfoVO; import club.joylink.rtss.vo.LoginUserInfoVO;
@ -27,20 +28,17 @@ public class DeviceController {
* 分页查询项目设备 * 分页查询项目设备
*/ */
@GetMapping("/paging") @GetMapping("/paging")
public PageVO<ProjectDeviceVO> pagingQuery(ProjectDevicePageQueryVO queryVO, public PageVO<ProjectDeviceVO> pagingQuery(ProjectDevicePageQueryVO queryVO) {
@RequestAttribute(name = AuthenticateInterceptor.LOGIN_INFO_KEY) return this.deviceService.pagingQuery(queryVO);
LoginUserInfoVO userLoginInfo) {
return this.deviceService.pagingQuery(queryVO, userLoginInfo);
} }
/** /**
* 项目设备编号是否已经存在 * 项目设备编号是否已经存在
*/ */
@GetMapping("/exist/{code}") @GetMapping("/exist/{code}")
public boolean isDeviceCodeExist(@PathVariable String code, public boolean isDeviceCodeExist(@PathVariable String code, String projectCode) {
@RequestAttribute(name = AuthenticateInterceptor.LOGIN_INFO_KEY) String project = Project.isDefault(projectCode) ? Project.DEFAULT_PROJECT_CODE : projectCode;
LoginUserInfoVO userLoginInfo) { return this.deviceService.isDeviceCodeExist(project, code);
return this.deviceService.isDeviceCodeExist(userLoginInfo.getProject(), code);
} }
/** /**

View File

@ -16,7 +16,7 @@ public interface DeviceService {
* @param userLoginInfo * @param userLoginInfo
* @return * @return
*/ */
PageVO<ProjectDeviceVO> pagingQuery(ProjectDevicePageQueryVO queryVO, LoginUserInfoVO userLoginInfo); PageVO<ProjectDeviceVO> pagingQuery(ProjectDevicePageQueryVO queryVO);
/** /**
* 项目设备编码是否存在 * 项目设备编码是否存在

View File

@ -55,13 +55,13 @@ public class DeviceServiceImpl implements DeviceService {
@Autowired @Autowired
private IMapService iMapService; private IMapService iMapService;
// 修改项目编码 20221009
@Override @Override
public PageVO<ProjectDeviceVO> pagingQuery(ProjectDevicePageQueryVO queryVO, public PageVO<ProjectDeviceVO> pagingQuery(ProjectDevicePageQueryVO queryVO) {
LoginUserInfoVO userLoginInfo) {
ProjectDeviceExample example = new ProjectDeviceExample(); ProjectDeviceExample example = new ProjectDeviceExample();
ProjectDeviceExample.Criteria criteria = example.createCriteria(); ProjectDeviceExample.Criteria criteria = example.createCriteria();
if (!Objects.equals(userLoginInfo.getProject(), Project.DEFAULT_PROJECT_CODE)) { if (StringUtils.hasText(queryVO.getProjectCode())) {
criteria.andProjectCodeEqualTo(userLoginInfo.getProject()); criteria.andProjectCodeEqualTo(queryVO.getProjectCode());
} }
if (StringUtils.hasText(queryVO.getCode())) { if (StringUtils.hasText(queryVO.getCode())) {
criteria.andCodeLike(String.format("%%%s%%", queryVO.getCode())); criteria.andCodeLike(String.format("%%%s%%", queryVO.getCode()));
@ -77,8 +77,6 @@ public class DeviceServiceImpl implements DeviceService {
@Override @Override
public boolean isDeviceCodeExist(String project, String code) { public boolean isDeviceCodeExist(String project, String code) {
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotEquals(project, Project.DEFAULT_PROJECT_CODE,
String.format("项目[%s]没有权限", project));
ProjectDeviceExample example = new ProjectDeviceExample(); ProjectDeviceExample example = new ProjectDeviceExample();
example.createCriteria().andProjectCodeEqualTo(project).andCodeEqualTo(code); example.createCriteria().andProjectCodeEqualTo(project).andCodeEqualTo(code);
if (this.projectDeviceDAO.countByExample(example) > 0) { if (this.projectDeviceDAO.countByExample(example) > 0) {
@ -90,9 +88,6 @@ public class DeviceServiceImpl implements DeviceService {
@Override @Override
public String create(ProjectDeviceVO deviceVO, LoginUserInfoVO userLoginInfo) { public String create(ProjectDeviceVO deviceVO, LoginUserInfoVO userLoginInfo) {
ProjectDevice projectDevice = deviceVO.buildDB(); ProjectDevice projectDevice = deviceVO.buildDB();
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotEquals(userLoginInfo.getProject(),
Project.DEFAULT_PROJECT_CODE, String.format("项目[%s]无权添加设备", userLoginInfo.getProject()));
projectDevice.setProjectCode(userLoginInfo.getProject());
projectDevice.setCreator(userLoginInfo.getAccountVO().getId()); projectDevice.setCreator(userLoginInfo.getAccountVO().getId());
projectDevice.setCreateTime(LocalDateTime.now()); projectDevice.setCreateTime(LocalDateTime.now());
this.projectDeviceDAO.insert(projectDevice); this.projectDeviceDAO.insert(projectDevice);

View File

@ -284,6 +284,7 @@ public class ProjectDeviceVO {
@JsonIgnore @JsonIgnore
public ProjectDevice buildDB() { public ProjectDevice buildDB() {
ProjectDevice device = new ProjectDevice(); ProjectDevice device = new ProjectDevice();
device.setProjectCode(this.getProject());
device.setCode(this.getCode()); device.setCode(this.getCode());
device.setType(this.getType().name()); device.setType(this.getType().name());
return device; return device;