zbj//1.系统配置操作出现两个已激活状态bug修改
This commit is contained in:
@@ -38,6 +38,7 @@ public enum SystemResponseEnum {
|
|||||||
MONITORY_TYPE_EMPTY("A00366","查询字典监测对象类型为空"),
|
MONITORY_TYPE_EMPTY("A00366","查询字典监测对象类型为空"),
|
||||||
TERMINAL_WIRING_EMPTY("A00367","查询字典监测终端接线方式为空"),
|
TERMINAL_WIRING_EMPTY("A00367","查询字典监测终端接线方式为空"),
|
||||||
MONITOR_TYPE_EMPTY("A00368","查询字典监测点类别为空"),
|
MONITOR_TYPE_EMPTY("A00368","查询字典监测点类别为空"),
|
||||||
|
ACTIVATED_STATE("A00369","必须存在一个已激活的系统类型"),
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,15 @@ public class ConfigParam {
|
|||||||
@ApiModelProperty("审计日志存储时间(1-6个月,默认3个月)")
|
@ApiModelProperty("审计日志存储时间(1-6个月,默认3个月)")
|
||||||
private Integer logTime;
|
private Integer logTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统类型
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("激活状态:0-未激活;1-激活")
|
||||||
|
@NotNull(message = "激活状态不可为空")
|
||||||
|
@Max(value = 1)
|
||||||
|
@Min(value = 0)
|
||||||
|
private Integer state;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新操作实体
|
* 更新操作实体
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.njcn.system.controller;
|
package com.njcn.system.controller;
|
||||||
|
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||||
import com.njcn.common.pojo.constant.OperateType;
|
import com.njcn.common.pojo.constant.OperateType;
|
||||||
@@ -27,7 +26,6 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
|
|||||||
@@ -12,8 +12,7 @@
|
|||||||
sys_config sys_config
|
sys_config sys_config
|
||||||
LEFT JOIN sys_user sys_usera ON sys_config.create_by = sys_usera.id
|
LEFT JOIN sys_user sys_usera ON sys_config.create_by = sys_usera.id
|
||||||
LEFT JOIN sys_user sys_userb ON sys_config.update_by = sys_userb.id
|
LEFT JOIN sys_user sys_userb ON sys_config.update_by = sys_userb.id
|
||||||
WHERE
|
|
||||||
sys_config.state = 1
|
|
||||||
ORDER BY
|
ORDER BY
|
||||||
sys_config.create_time DESC
|
sys_config.create_time DESC
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
package com.njcn.system.service.impl;
|
package com.njcn.system.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
|
import com.njcn.system.enums.SystemResponseEnum;
|
||||||
import com.njcn.system.mapper.ConfigMapper;
|
import com.njcn.system.mapper.ConfigMapper;
|
||||||
import com.njcn.system.pojo.param.ConfigParam;
|
import com.njcn.system.pojo.param.ConfigParam;
|
||||||
import com.njcn.system.pojo.po.Config;
|
import com.njcn.system.pojo.po.Config;
|
||||||
@@ -8,6 +11,7 @@ import com.njcn.system.service.IConfigService;
|
|||||||
import com.njcn.web.utils.RequestUtil;
|
import com.njcn.web.utils.RequestUtil;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -15,7 +19,7 @@ import java.util.Objects;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* 服务实现类
|
* 服务实现类
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author hongawen
|
* @author hongawen
|
||||||
@@ -25,7 +29,6 @@ import java.util.Objects;
|
|||||||
public class ConfigServiceImpl extends ServiceImpl<ConfigMapper, Config> implements IConfigService {
|
public class ConfigServiceImpl extends ServiceImpl<ConfigMapper, Config> implements IConfigService {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addSysConfig(ConfigParam configParam) {
|
public boolean addSysConfig(ConfigParam configParam) {
|
||||||
Config config = new Config();
|
Config config = new Config();
|
||||||
@@ -39,14 +42,39 @@ public class ConfigServiceImpl extends ServiceImpl<ConfigMapper, Config> impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional
|
||||||
public boolean updateSysConfig(ConfigParam.ConfigUpdateParam configUpdateParam) {
|
public boolean updateSysConfig(ConfigParam.ConfigUpdateParam configUpdateParam) {
|
||||||
Config config = this.baseMapper.selectById(configUpdateParam.getId());
|
Config config = this.baseMapper.selectById(configUpdateParam.getId());
|
||||||
if (!Objects.isNull(config)) {
|
if (!Objects.isNull(config)) {
|
||||||
BeanUtils.copyProperties(configUpdateParam, config);
|
if (config.getState() == 1) {
|
||||||
config.setUpdateBy(RequestUtil.getUserIndex());
|
if (Objects.equals(configUpdateParam.getState(), config.getState())) {
|
||||||
config.setUpdateTime(LocalDateTime.now());
|
BeanUtils.copyProperties(configUpdateParam, config);
|
||||||
this.baseMapper.updateById(config);
|
config.setUpdateBy(RequestUtil.getUserIndex());
|
||||||
return true;
|
config.setUpdateTime(LocalDateTime.now());
|
||||||
|
this.baseMapper.updateById(config);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
//不可更改当前激活状态,必须保留一个激活系统
|
||||||
|
throw new BusinessException(SystemResponseEnum.ACTIVATED_STATE);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (configUpdateParam.getState() == 1) {
|
||||||
|
LambdaUpdateWrapper<Config> updateWrapper = new LambdaUpdateWrapper<>();
|
||||||
|
updateWrapper.set(Config::getState, 0);
|
||||||
|
this.baseMapper.update(null, updateWrapper);
|
||||||
|
BeanUtils.copyProperties(configUpdateParam, config);
|
||||||
|
config.setUpdateBy(RequestUtil.getUserIndex());
|
||||||
|
config.setUpdateTime(LocalDateTime.now());
|
||||||
|
this.baseMapper.updateById(config);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
BeanUtils.copyProperties(configUpdateParam, config);
|
||||||
|
config.setUpdateBy(RequestUtil.getUserIndex());
|
||||||
|
config.setUpdateTime(LocalDateTime.now());
|
||||||
|
this.baseMapper.updateById(config);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user