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

View File

@ -16,7 +16,7 @@ public interface DeviceService {
* @param userLoginInfo
* @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
private IMapService iMapService;
// 修改项目编码 20221009
@Override
public PageVO<ProjectDeviceVO> pagingQuery(ProjectDevicePageQueryVO queryVO,
LoginUserInfoVO userLoginInfo) {
public PageVO<ProjectDeviceVO> pagingQuery(ProjectDevicePageQueryVO queryVO) {
ProjectDeviceExample example = new ProjectDeviceExample();
ProjectDeviceExample.Criteria criteria = example.createCriteria();
if (!Objects.equals(userLoginInfo.getProject(), Project.DEFAULT_PROJECT_CODE)) {
criteria.andProjectCodeEqualTo(userLoginInfo.getProject());
if (StringUtils.hasText(queryVO.getProjectCode())) {
criteria.andProjectCodeEqualTo(queryVO.getProjectCode());
}
if (StringUtils.hasText(queryVO.getCode())) {
criteria.andCodeLike(String.format("%%%s%%", queryVO.getCode()));
@ -77,8 +77,6 @@ public class DeviceServiceImpl implements DeviceService {
@Override
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();
example.createCriteria().andProjectCodeEqualTo(project).andCodeEqualTo(code);
if (this.projectDeviceDAO.countByExample(example) > 0) {
@ -90,9 +88,6 @@ public class DeviceServiceImpl implements DeviceService {
@Override
public String create(ProjectDeviceVO deviceVO, LoginUserInfoVO userLoginInfo) {
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.setCreateTime(LocalDateTime.now());
this.projectDeviceDAO.insert(projectDevice);

View File

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