微调
This commit is contained in:
@@ -28,6 +28,12 @@
|
|||||||
<artifactId>spingboot2.3.12</artifactId>
|
<artifactId>spingboot2.3.12</artifactId>
|
||||||
<version>2.3.12</version>
|
<version>2.3.12</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.njcn.gather</groupId>
|
||||||
|
<artifactId>system</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ public class PqDevController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@OperateInfo(operateType = OperateType.UPDATE)
|
@OperateInfo(operateType = OperateType.UPDATE)
|
||||||
@PutMapping("/update")
|
@PostMapping("/update")
|
||||||
@ApiOperation("修改被检设备")
|
@ApiOperation("修改被检设备")
|
||||||
@ApiImplicitParam(name = "updateParam", value = "被检设备", required = true)
|
@ApiImplicitParam(name = "updateParam", value = "被检设备", required = true)
|
||||||
public HttpResult<Object> update(@RequestBody @Validated PqDevParam.UpdateParam updateParam) {
|
public HttpResult<Object> update(@RequestBody @Validated PqDevParam.UpdateParam updateParam) {
|
||||||
@@ -90,7 +90,7 @@ public class PqDevController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@OperateInfo(operateType = OperateType.DELETE)
|
@OperateInfo(operateType = OperateType.DELETE)
|
||||||
@DeleteMapping("/delete")
|
@PostMapping("/delete")
|
||||||
@ApiOperation("删除被检设备")
|
@ApiOperation("删除被检设备")
|
||||||
@ApiImplicitParam(name = "ids", value = "被检设备id", required = true)
|
@ApiImplicitParam(name = "ids", value = "被检设备id", required = true)
|
||||||
public HttpResult<Object> delete(@RequestBody List<String> ids) {
|
public HttpResult<Object> delete(@RequestBody List<String> ids) {
|
||||||
@@ -159,7 +159,7 @@ public class PqDevController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
@PostMapping("/listBoundByPlanId")
|
@GetMapping("/listBoundByPlanId")
|
||||||
@ApiOperation("根据计划id查询出所有已绑定的设备")
|
@ApiOperation("根据计划id查询出所有已绑定的设备")
|
||||||
@ApiImplicitParam(name = "planId", value = "计划id", required = true)
|
@ApiImplicitParam(name = "planId", value = "计划id", required = true)
|
||||||
public HttpResult<List<PqDev>> listBoundByPlanId(@RequestParam("planId") String planId) {
|
public HttpResult<List<PqDev>> listBoundByPlanId(@RequestParam("planId") String planId) {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import com.njcn.web.pojo.param.BaseParam;
|
|||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import org.hibernate.validator.constraints.Range;
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
@@ -76,6 +77,7 @@ public class PqDevParam {
|
|||||||
private String ip;
|
private String ip;
|
||||||
|
|
||||||
@ApiModelProperty(value = "端口号", required = true)
|
@ApiModelProperty(value = "端口号", required = true)
|
||||||
|
@Range(min = 1, max = 65535, message = DeviceValidMessage.PORT_RANGE_ERROR)
|
||||||
@NotNull(message = DeviceValidMessage.PORT_NOT_NULL)
|
@NotNull(message = DeviceValidMessage.PORT_NOT_NULL)
|
||||||
private Integer port;
|
private Integer port;
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||||
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
import com.njcn.db.mybatisplus.constant.DbConstant;
|
import com.njcn.db.mybatisplus.constant.DbConstant;
|
||||||
import com.njcn.gather.device.device.mapper.PqDevMapper;
|
import com.njcn.gather.device.device.mapper.PqDevMapper;
|
||||||
import com.njcn.gather.device.device.pojo.param.PqDevParam;
|
import com.njcn.gather.device.device.pojo.param.PqDevParam;
|
||||||
@@ -14,6 +15,9 @@ import com.njcn.gather.device.device.pojo.po.PqDev;
|
|||||||
import com.njcn.gather.device.device.pojo.vo.PqDevExcel;
|
import com.njcn.gather.device.device.pojo.vo.PqDevExcel;
|
||||||
import com.njcn.gather.device.device.service.IPqDevService;
|
import com.njcn.gather.device.device.service.IPqDevService;
|
||||||
import com.njcn.gather.device.device.util.DeviceUtil;
|
import com.njcn.gather.device.device.util.DeviceUtil;
|
||||||
|
import com.njcn.gather.device.pojo.enums.DeviceResponseEnum;
|
||||||
|
import com.njcn.gather.system.dictionary.pojo.po.DictData;
|
||||||
|
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||||
import com.njcn.web.factory.PageFactory;
|
import com.njcn.web.factory.PageFactory;
|
||||||
import com.njcn.web.utils.ExcelUtil;
|
import com.njcn.web.utils.ExcelUtil;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@@ -34,6 +38,8 @@ import java.util.stream.Collectors;
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements IPqDevService {
|
public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements IPqDevService {
|
||||||
|
|
||||||
|
private final IDictDataService dictDataService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<PqDev> listPqDevs(PqDevParam.QueryParam queryParam) {
|
public Page<PqDev> listPqDevs(PqDevParam.QueryParam queryParam) {
|
||||||
QueryWrapper<PqDev> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<PqDev> queryWrapper = new QueryWrapper<>();
|
||||||
@@ -50,18 +56,29 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
|||||||
queryWrapper.orderBy(true, false, "pq_dev.Create_Time");
|
queryWrapper.orderBy(true, false, "pq_dev.Create_Time");
|
||||||
}
|
}
|
||||||
queryWrapper.eq("pq_dev.state", DataStateEnum.ENABLE.getCode());
|
queryWrapper.eq("pq_dev.state", DataStateEnum.ENABLE.getCode());
|
||||||
return this.page(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), queryWrapper);
|
Page<PqDev> page = this.page(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), queryWrapper);
|
||||||
|
page.getRecords().forEach(p -> {
|
||||||
|
if (ObjectUtil.isNotNull(p.getSeries())) {
|
||||||
|
p.setSeries(DeviceUtil.decoderString(1, p.getSeries()));
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotNull(p.getDevKey())) {
|
||||||
|
p.setDevKey(DeviceUtil.decoderString(1, p.getDevKey()));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return page;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addPqDev(PqDevParam pqDevParam) {
|
public boolean addPqDev(PqDevParam pqDevParam) {
|
||||||
PqDev pqDev = new PqDev();
|
PqDev pqDev = new PqDev();
|
||||||
BeanUtil.copyProperties(pqDevParam, pqDev);
|
BeanUtil.copyProperties(pqDevParam, pqDev);
|
||||||
if (Objects.nonNull(pqDev.getSeries())) {
|
if (pqDevParam.getEncryptionFlag() == 1) {
|
||||||
pqDev.setSeries(DeviceUtil.encodeString(1, pqDev.getSeries()));
|
if (StrUtil.isNotBlank(pqDevParam.getSeries()) && StrUtil.isNotBlank(pqDevParam.getDevKey())) {
|
||||||
}
|
pqDev.setSeries(DeviceUtil.encodeString(1, pqDev.getSeries()));
|
||||||
if (Objects.nonNull(pqDev.getDevKey())) {
|
pqDev.setDevKey(DeviceUtil.encodeString(1, pqDev.getDevKey()));
|
||||||
pqDev.setDevKey(DeviceUtil.encodeString(1, pqDev.getDevKey()));
|
} else {
|
||||||
|
throw new BusinessException(DeviceResponseEnum.SERIES_AND_DEVKEY_NOT_BLANK);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//todo 比对式设备处理
|
//todo 比对式设备处理
|
||||||
pqDev.setState(DataStateEnum.ENABLE.getCode());
|
pqDev.setState(DataStateEnum.ENABLE.getCode());
|
||||||
@@ -124,6 +141,7 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
|||||||
}
|
}
|
||||||
queryWrapper.eq("pq_dev.state", DataStateEnum.ENABLE.getCode());
|
queryWrapper.eq("pq_dev.state", DataStateEnum.ENABLE.getCode());
|
||||||
List<PqDev> pqDevs = this.list(queryWrapper);
|
List<PqDev> pqDevs = this.list(queryWrapper);
|
||||||
|
this.visualize(pqDevs);
|
||||||
List<PqDevExcel.ExportData> pqDevExcels = BeanUtil.copyToList(pqDevs, PqDevExcel.ExportData.class);
|
List<PqDevExcel.ExportData> pqDevExcels = BeanUtil.copyToList(pqDevs, PqDevExcel.ExportData.class);
|
||||||
ExcelUtil.exportExcel("被检设备导出数据.xlsx", "被检设备", PqDevExcel.ExportData.class, pqDevExcels);
|
ExcelUtil.exportExcel("被检设备导出数据.xlsx", "被检设备", PqDevExcel.ExportData.class, pqDevExcels);
|
||||||
}
|
}
|
||||||
@@ -155,4 +173,24 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
|||||||
|
|
||||||
return result1 && result2;
|
return result1 && result2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//可视化,各种id回显字典值,解码等操作
|
||||||
|
private void visualize(List<PqDev> sourceList) {
|
||||||
|
sourceList.forEach(pqDev -> {
|
||||||
|
//todo
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotNull(pqDev.getDevType())) {
|
||||||
|
DictData dictData = dictDataService.getDicDataById(pqDev.getDevType());
|
||||||
|
if(ObjectUtil.isNotNull(dictData)){
|
||||||
|
pqDev.setDevType(dictData.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Objects.nonNull(pqDev.getSeries())) {
|
||||||
|
pqDev.setSeries(DeviceUtil.decoderString(1, pqDev.getSeries()));
|
||||||
|
}
|
||||||
|
if (Objects.nonNull(pqDev.getDevKey())) {
|
||||||
|
pqDev.setDevKey(DeviceUtil.decoderString(1, pqDev.getDevKey()));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ public interface DeviceValidMessage {
|
|||||||
|
|
||||||
String ID_FORMAT_ERROR = "id格式错误,请检查id参数";
|
String ID_FORMAT_ERROR = "id格式错误,请检查id参数";
|
||||||
|
|
||||||
|
String PORT_RANGE_ERROR = "端口号范围错误,请检查port参数";
|
||||||
|
|
||||||
String NAME_NOT_BLANK = "名称不能为空,请检查name参数";
|
String NAME_NOT_BLANK = "名称不能为空,请检查name参数";
|
||||||
|
|
||||||
String NAME_FORMAT_ERROR = "名称格式错误,请检查name参数";
|
String NAME_FORMAT_ERROR = "名称格式错误,请检查name参数";
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ import lombok.Getter;
|
|||||||
public enum DeviceResponseEnum {
|
public enum DeviceResponseEnum {
|
||||||
//NAME_REPEAT("A001001", "名称重复"),
|
//NAME_REPEAT("A001001", "名称重复"),
|
||||||
|
|
||||||
IMPORT_DATA_FAIL("A001002", "导入数据失败");
|
IMPORT_DATA_FAIL("A001002", "导入数据失败"),
|
||||||
|
SERIES_AND_DEVKEY_NOT_BLANK("A001003", "加密设备的序列号和设备密钥不能为空");
|
||||||
|
|
||||||
private final String code;
|
private final String code;
|
||||||
|
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ public class DictDataController extends BaseController {
|
|||||||
* 修改字典数据
|
* 修改字典数据
|
||||||
*/
|
*/
|
||||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.UPDATE)
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.UPDATE)
|
||||||
@PutMapping("/update")
|
@PostMapping("/update")
|
||||||
@ApiOperation("修改字典数据")
|
@ApiOperation("修改字典数据")
|
||||||
@ApiImplicitParam(name = "updateParam", value = "字典数据", required = true)
|
@ApiImplicitParam(name = "updateParam", value = "字典数据", required = true)
|
||||||
public HttpResult<Object> update(@RequestBody @Validated DictDataParam.UpdateParam updateParam) {
|
public HttpResult<Object> update(@RequestBody @Validated DictDataParam.UpdateParam updateParam) {
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ public class DictPqController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.UPDATE)
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.UPDATE)
|
||||||
@PutMapping("/update")
|
@PostMapping("/update")
|
||||||
@ApiOperation("更新电能质量指标字典")
|
@ApiOperation("更新电能质量指标字典")
|
||||||
@ApiImplicitParam(name = "updateParam", value = "更新参数", required = true)
|
@ApiImplicitParam(name = "updateParam", value = "更新参数", required = true)
|
||||||
public HttpResult<Object> update(@RequestBody @Validated DictPqParam.UpdateParam updateParam) {
|
public HttpResult<Object> update(@RequestBody @Validated DictPqParam.UpdateParam updateParam) {
|
||||||
@@ -70,7 +70,7 @@ public class DictPqController extends BaseController {
|
|||||||
LogUtil.njcnDebug(log, "{},更新数据为:{}", methodDescribe, updateParam);
|
LogUtil.njcnDebug(log, "{},更新数据为:{}", methodDescribe, updateParam);
|
||||||
boolean result = dictPqService.updateDictPq(updateParam);
|
boolean result = dictPqService.updateDictPq(updateParam);
|
||||||
if (result) {
|
if (result) {
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
} else {
|
} else {
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ public class DictTreeController extends BaseController {
|
|||||||
* @param dicParam 修改参数
|
* @param dicParam 修改参数
|
||||||
*/
|
*/
|
||||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.UPDATE)
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.UPDATE)
|
||||||
@PutMapping("/update")
|
@PostMapping("/update")
|
||||||
@ApiOperation("修改")
|
@ApiOperation("修改")
|
||||||
@ApiImplicitParam(name = "dicParam", value = "数据", required = true)
|
@ApiImplicitParam(name = "dicParam", value = "数据", required = true)
|
||||||
public HttpResult<Boolean> update(@RequestBody @Validated DictTreeParam.UpdateParam dicParam) {
|
public HttpResult<Boolean> update(@RequestBody @Validated DictTreeParam.UpdateParam dicParam) {
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ public class DictTypeController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.UPDATE)
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.UPDATE)
|
||||||
@PutMapping("/update")
|
@PostMapping("/update")
|
||||||
@ApiOperation("修改字典类型")
|
@ApiOperation("修改字典类型")
|
||||||
@ApiImplicitParam(name = "updateParam", value = "字典类型数据", required = true)
|
@ApiImplicitParam(name = "updateParam", value = "字典类型数据", required = true)
|
||||||
public HttpResult<Object> update(@RequestBody @Validated DictTypeParam.UpdateParam updateParam) {
|
public HttpResult<Object> update(@RequestBody @Validated DictTypeParam.UpdateParam updateParam) {
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ public class DictDataServiceImpl extends ServiceImpl<DictDataMapper, DictData> i
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DictData getDicDataById(String dicIndex) {
|
public DictData getDicDataById(String dicIndex) {
|
||||||
return this.baseMapper.selectById(dicIndex);
|
return this.lambdaQuery().eq(DictData::getId, dicIndex).eq(DictData::getState, DataStateEnum.ENABLE.getCode()).one();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -109,11 +109,13 @@ public class DictDataServiceImpl extends ServiceImpl<DictDataMapper, DictData> i
|
|||||||
@Override
|
@Override
|
||||||
public List<SimpleTreeDTO> dictDataCache() {
|
public List<SimpleTreeDTO> dictDataCache() {
|
||||||
MPJLambdaWrapper<DictData> dictTypeWrapper = new MPJLambdaWrapper<DictData>()
|
MPJLambdaWrapper<DictData> dictTypeWrapper = new MPJLambdaWrapper<DictData>()
|
||||||
|
.eq(DictData::getState, DataStateEnum.ENABLE.getCode())
|
||||||
.selectAll(DictData.class)
|
.selectAll(DictData.class)
|
||||||
.selectAs(DictType::getId, DictDataCache::getTypeId)
|
.selectAs(DictType::getId, DictDataCache::getTypeId)
|
||||||
.selectAs(DictType::getName, DictDataCache::getTypeName)
|
.selectAs(DictType::getName, DictDataCache::getTypeName)
|
||||||
.selectAs(DictType::getCode, DictDataCache::getTypeCode)
|
.selectAs(DictType::getCode, DictDataCache::getTypeCode)
|
||||||
.leftJoin(DictType.class, DictType::getId, DictData::getTypeId);
|
.leftJoin(DictType.class, DictType::getId, DictData::getTypeId)
|
||||||
|
.eq(DictType::getState, DataStateEnum.ENABLE.getCode());
|
||||||
List<DictDataCache> allDictData = this.getBaseMapper().selectJoinList(DictDataCache.class, dictTypeWrapper);
|
List<DictDataCache> allDictData = this.getBaseMapper().selectJoinList(DictDataCache.class, dictTypeWrapper);
|
||||||
|
|
||||||
Map<Object, List<DictDataCache>> dictDataCacheMap = allDictData.stream()
|
Map<Object, List<DictDataCache>> dictDataCacheMap = allDictData.stream()
|
||||||
@@ -166,10 +168,9 @@ public class DictDataServiceImpl extends ServiceImpl<DictDataMapper, DictData> i
|
|||||||
*/
|
*/
|
||||||
private void checkDicDataName(DictDataParam dictDataParam, boolean isExcludeSelf) {
|
private void checkDicDataName(DictDataParam dictDataParam, boolean isExcludeSelf) {
|
||||||
LambdaQueryWrapper<DictData> dictDataLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<DictData> dictDataLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
dictDataLambdaQueryWrapper
|
dictDataLambdaQueryWrapper.eq(DictData::getTypeId, dictDataParam.getTypeId())
|
||||||
.eq(DictData::getName, dictDataParam.getName())
|
.eq(DictData::getState, DataStateEnum.ENABLE.getCode())
|
||||||
.eq(DictData::getTypeId, dictDataParam.getTypeId())
|
.and(w -> w.eq(DictData::getName, dictDataParam.getName()).or().eq(DictData::getCode, dictDataParam.getCode()));
|
||||||
.eq(DictData::getState, DataStateEnum.ENABLE.getCode());
|
|
||||||
//更新的时候,需排除当前记录
|
//更新的时候,需排除当前记录
|
||||||
if (isExcludeSelf) {
|
if (isExcludeSelf) {
|
||||||
if (dictDataParam instanceof DictDataParam.UpdateParam) {
|
if (dictDataParam instanceof DictDataParam.UpdateParam) {
|
||||||
@@ -179,7 +180,7 @@ public class DictDataServiceImpl extends ServiceImpl<DictDataMapper, DictData> i
|
|||||||
int countByAccount = this.count(dictDataLambdaQueryWrapper);
|
int countByAccount = this.count(dictDataLambdaQueryWrapper);
|
||||||
//大于等于1个则表示重复
|
//大于等于1个则表示重复
|
||||||
if (countByAccount >= 1) {
|
if (countByAccount >= 1) {
|
||||||
throw new BusinessException(SystemResponseEnum.DICT_DATA_NAME_REPEAT);
|
throw new BusinessException(SystemResponseEnum.DICT_DATA_REPEAT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,9 +103,8 @@ public class DictTypeServiceImpl extends ServiceImpl<DictTypeMapper, DictType> i
|
|||||||
*/
|
*/
|
||||||
private void checkDicTypeName(DictTypeParam dictTypeParam, boolean isExcludeSelf) {
|
private void checkDicTypeName(DictTypeParam dictTypeParam, boolean isExcludeSelf) {
|
||||||
LambdaQueryWrapper<DictType> dictTypeLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<DictType> dictTypeLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
dictTypeLambdaQueryWrapper
|
dictTypeLambdaQueryWrapper.eq(DictType::getState, DataStateEnum.ENABLE.getCode())
|
||||||
.eq(DictType::getName, dictTypeParam.getName())
|
.and(w -> w.eq(DictType::getCode, dictTypeParam.getCode()).or().eq(DictType::getName, dictTypeParam.getName()));
|
||||||
.eq(DictType::getState, DataStateEnum.ENABLE.getCode());
|
|
||||||
//更新的时候,需排除当前记录
|
//更新的时候,需排除当前记录
|
||||||
if (isExcludeSelf) {
|
if (isExcludeSelf) {
|
||||||
if (dictTypeParam instanceof DictTypeParam.UpdateParam) {
|
if (dictTypeParam instanceof DictTypeParam.UpdateParam) {
|
||||||
@@ -115,7 +114,7 @@ public class DictTypeServiceImpl extends ServiceImpl<DictTypeMapper, DictType> i
|
|||||||
int countByAccount = this.count(dictTypeLambdaQueryWrapper);
|
int countByAccount = this.count(dictTypeLambdaQueryWrapper);
|
||||||
//大于等于1个则表示重复
|
//大于等于1个则表示重复
|
||||||
if (countByAccount >= 1) {
|
if (countByAccount >= 1) {
|
||||||
throw new BusinessException(SystemResponseEnum.DICT_TYPE_NAME_REPEAT);
|
throw new BusinessException(SystemResponseEnum.DICT_TYPE_REPEAT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ public enum SystemResponseEnum {
|
|||||||
* A00350 ~ A00449
|
* A00350 ~ A00449
|
||||||
*/
|
*/
|
||||||
SYSTEM_COMMON_ERROR("A00350","系统模块异常"),
|
SYSTEM_COMMON_ERROR("A00350","系统模块异常"),
|
||||||
DICT_TYPE_NAME_REPEAT("A00351", "字典类型名称重复"),
|
DICT_TYPE_REPEAT("A00351", "字典类型名称或编码重复"),
|
||||||
DICT_DATA_NAME_REPEAT("A00352", "字典数据名称重复"),
|
DICT_DATA_REPEAT("A00352", "字典数据名称或编码重复"),
|
||||||
AREA_CODE_REPEAT("A00353","行政区域编码重复"),
|
AREA_CODE_REPEAT("A00353","行政区域编码重复"),
|
||||||
LOAD_TYPE_EMPTY("A00354","用能负荷数据为空"),
|
LOAD_TYPE_EMPTY("A00354","用能负荷数据为空"),
|
||||||
LINE_MARK_EMPTY("A00355","字典监测点评分等级数据为空"),
|
LINE_MARK_EMPTY("A00355","字典监测点评分等级数据为空"),
|
||||||
|
|||||||
@@ -14,7 +14,9 @@ public enum UserResponseEnum {
|
|||||||
REGISTER_EMAIL_FAIL("A010004", "该邮箱已被注册"),
|
REGISTER_EMAIL_FAIL("A010004", "该邮箱已被注册"),
|
||||||
NAME_OR_CODE_REPEAT("A010005", "名称或编码已存在"),
|
NAME_OR_CODE_REPEAT("A010005", "名称或编码已存在"),
|
||||||
EXISTS_SAME_MENU_CHILDREN("A010006", "当前菜单下已存在相同的子菜单"),
|
EXISTS_SAME_MENU_CHILDREN("A010006", "当前菜单下已存在相同的子菜单"),
|
||||||
EXISTS_CHILDREN("A010007", "该节点下存在子节点,请先无法删除");
|
EXISTS_CHILDREN_NOT_UPDATE("A010008", "该菜单下存在子节点,无法将菜单修改为按钮"),
|
||||||
|
EXISTS_CHILDREN_NOT_DELETE("A010007", "该节点下存在子节点,无法删除"),
|
||||||
|
ADMINSTRATOR_ROLE_CANNOT_DELETE("A010009", "超级管理员及管理员角色禁止删除"),;
|
||||||
|
|
||||||
private String code;
|
private String code;
|
||||||
private String message;
|
private String message;
|
||||||
|
|||||||
@@ -37,6 +37,17 @@ public class SysFunctionController extends BaseController {
|
|||||||
private final ISysFunctionService sysFunctionService;
|
private final ISysFunctionService sysFunctionService;
|
||||||
private final ISysRoleFunctionService sysRoleFunctionService;
|
private final ISysRoleFunctionService sysRoleFunctionService;
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||||
|
@PostMapping("/list")
|
||||||
|
@ApiOperation("分页查询菜单树")
|
||||||
|
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
|
||||||
|
public HttpResult<List<SysFunction>> list(@RequestBody @Validated SysFunctionParam.QueryParam queryParam) {
|
||||||
|
String methodDescribe = getMethodDescribe("list");
|
||||||
|
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
|
||||||
|
List<SysFunction> result = sysFunctionService.listFunction(queryParam);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||||
@GetMapping("/functionTree")
|
@GetMapping("/functionTree")
|
||||||
@ApiOperation("菜单树")
|
@ApiOperation("菜单树")
|
||||||
@@ -71,7 +82,7 @@ public class SysFunctionController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.UPDATE)
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.UPDATE)
|
||||||
@PutMapping("/update")
|
@PostMapping("/update")
|
||||||
@ApiOperation("修改菜单")
|
@ApiOperation("修改菜单")
|
||||||
@ApiImplicitParam(name = "functionParam", value = "菜单数据", required = true)
|
@ApiImplicitParam(name = "functionParam", value = "菜单数据", required = true)
|
||||||
public HttpResult<Boolean> update(@RequestBody @Validated SysFunctionParam.UpdateParam functionParam) {
|
public HttpResult<Boolean> update(@RequestBody @Validated SysFunctionParam.UpdateParam functionParam) {
|
||||||
@@ -133,11 +144,11 @@ public class SysFunctionController extends BaseController {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
@OperateInfo(operateType = OperateType.UPDATE, info = LogEnum.SYSTEM_MEDIUM)
|
@OperateInfo(operateType = OperateType.UPDATE, info = LogEnum.SYSTEM_MEDIUM)
|
||||||
@PutMapping("/assignFunctionByRoleId")
|
@PostMapping("/assignFunctionByRoleId")
|
||||||
@ApiOperation("角色分配菜单")
|
@ApiOperation("角色分配菜单")
|
||||||
@ApiImplicitParam(name = "roleFunctionComponent", value = "角色信息", required = true)
|
@ApiImplicitParam(name = "roleFunctionComponent", value = "角色信息", required = true)
|
||||||
public HttpResult<Boolean> assignFunctionByRoleIndexes(@RequestBody @Validated SysRoleParam.RoleBindFunction param) {
|
public HttpResult<Boolean> assignFunctionByRoleId(@RequestBody @Validated SysRoleParam.RoleBindFunction param) {
|
||||||
String methodDescribe = getMethodDescribe("assignFunctionByRoleIndexes");
|
String methodDescribe = getMethodDescribe("assignFunctionByRoleId");
|
||||||
LogUtil.njcnDebug(log, "{},传入的角色id和资源id集合为:{}", methodDescribe, param);
|
LogUtil.njcnDebug(log, "{},传入的角色id和资源id集合为:{}", methodDescribe, param);
|
||||||
boolean result = sysRoleFunctionService.updateRoleFunction(param.getRoleId(), param.getFunctionIds());
|
boolean result = sysRoleFunctionService.updateRoleFunction(param.getRoleId(), param.getFunctionIds());
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public class SysRoleController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.UPDATE)
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.UPDATE)
|
||||||
@PutMapping("/update")
|
@PostMapping("/update")
|
||||||
@ApiOperation("修改角色信息")
|
@ApiOperation("修改角色信息")
|
||||||
@ApiImplicitParam(name = "updateParam", value = "角色信息", required = true)
|
@ApiImplicitParam(name = "updateParam", value = "角色信息", required = true)
|
||||||
public HttpResult<Object> update(@RequestBody @Validated SysRoleParam.UpdateParam updateParam) {
|
public HttpResult<Object> update(@RequestBody @Validated SysRoleParam.UpdateParam updateParam) {
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ public class SysUserController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.UPDATE)
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.UPDATE)
|
||||||
@PutMapping("/update")
|
@PostMapping("/update")
|
||||||
@ApiOperation("修改用户")
|
@ApiOperation("修改用户")
|
||||||
@ApiImplicitParam(name = "updateUserParam", value = "修改用户", required = true)
|
@ApiImplicitParam(name = "updateUserParam", value = "修改用户", required = true)
|
||||||
public HttpResult<Boolean> update(@RequestBody @Validated SysUserParam.SysUserUpdateParam updateUserParam) {
|
public HttpResult<Boolean> update(@RequestBody @Validated SysUserParam.SysUserUpdateParam updateUserParam) {
|
||||||
@@ -123,7 +123,7 @@ public class SysUserController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.UPDATE)
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.UPDATE)
|
||||||
@PutMapping("/updatePassword")
|
@PostMapping("/updatePassword")
|
||||||
@ApiOperation("修改密码")
|
@ApiOperation("修改密码")
|
||||||
@ApiImplicitParams({
|
@ApiImplicitParams({
|
||||||
@ApiImplicitParam(name = "id", value = "用户id", required = true),
|
@ApiImplicitParam(name = "id", value = "用户id", required = true),
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
select b.*
|
select b.*
|
||||||
from sys_role_function a
|
from sys_role_function a
|
||||||
inner join sys_function b on a.Function_Id = b.id
|
inner join sys_function b on a.Function_Id = b.id
|
||||||
where a.Role_Id = #{roleId} and b.type in (1)
|
where a.Role_Id = #{roleId} and b.type in (0, 1)
|
||||||
and b.state = 1
|
and b.state = 1 order by b.sort,b.Update_Time desc
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.njcn.gather.user.user.pojo.param;
|
|||||||
|
|
||||||
import com.njcn.common.pojo.constant.PatternRegex;
|
import com.njcn.common.pojo.constant.PatternRegex;
|
||||||
import com.njcn.gather.user.pojo.constant.UserValidMessage;
|
import com.njcn.gather.user.pojo.constant.UserValidMessage;
|
||||||
|
import com.njcn.web.pojo.param.BaseParam;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
@@ -55,6 +56,18 @@ public class SysFunctionParam {
|
|||||||
@ApiModelProperty("描述")
|
@ApiModelProperty("描述")
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public static class QueryParam extends BaseParam {
|
||||||
|
@ApiModelProperty("名称")
|
||||||
|
@Pattern(regexp = PatternRegex.FUNCTION_NAME, message = UserValidMessage.NAME_FORMAT_ERROR)
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ApiModelProperty("资源类型")
|
||||||
|
@Range(min = 0, max = 3, message = UserValidMessage.PARAM_FORMAT_ERROR)
|
||||||
|
private Integer type;
|
||||||
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public static class UpdateParam extends SysFunctionParam {
|
public static class UpdateParam extends SysFunctionParam {
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package com.njcn.gather.user.user.service;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.njcn.gather.user.user.pojo.param.SysFunctionParam;
|
import com.njcn.gather.user.user.pojo.param.SysFunctionParam;
|
||||||
import com.njcn.gather.user.user.pojo.param.SysRoleParam;
|
|
||||||
import com.njcn.gather.user.user.pojo.po.SysFunction;
|
import com.njcn.gather.user.user.pojo.po.SysFunction;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -13,6 +12,14 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public interface ISysFunctionService extends IService<SysFunction> {
|
public interface ISysFunctionService extends IService<SysFunction> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取菜单(资源)列表
|
||||||
|
*
|
||||||
|
* @param queryParam 查询参数
|
||||||
|
* @return 菜单列表
|
||||||
|
*/
|
||||||
|
List<SysFunction> listFunction(SysFunctionParam.QueryParam queryParam);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加菜单(资源)
|
* 添加菜单(资源)
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package com.njcn.gather.user.user.service;
|
|||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.njcn.gather.user.user.pojo.param.SysRoleParam;
|
import com.njcn.gather.user.user.pojo.param.SysRoleParam;
|
||||||
import com.njcn.gather.user.user.pojo.po.SysFunction;
|
|
||||||
import com.njcn.gather.user.user.pojo.po.SysRole;
|
import com.njcn.gather.user.user.pojo.po.SysRole;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -45,29 +44,6 @@ public interface ISysRoleService extends IService<SysRole> {
|
|||||||
*/
|
*/
|
||||||
boolean deleteRole(List<String> ids);
|
boolean deleteRole(List<String> ids);
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询所有角色列表
|
|
||||||
*
|
|
||||||
* @return 角色列表
|
|
||||||
*/
|
|
||||||
//List<SysRole> listAllRole();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据权限类型type获取角色列表
|
|
||||||
*
|
|
||||||
* @param type 角色类型
|
|
||||||
* @return 角色列表
|
|
||||||
*/
|
|
||||||
//List<SysRole> listRoleByType(Integer type);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据用户id获取角色
|
|
||||||
*
|
|
||||||
* @param userId 用户id
|
|
||||||
* @return 角色列表
|
|
||||||
*/
|
|
||||||
//List<SysRole> listRoleByUserId(String userId);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询所有角色作为下拉框
|
* 查询所有角色作为下拉框
|
||||||
*
|
*
|
||||||
@@ -80,7 +56,5 @@ public interface ISysRoleService extends IService<SysRole> {
|
|||||||
*
|
*
|
||||||
* @param ids 角色id
|
* @param ids 角色id
|
||||||
*/
|
*/
|
||||||
// boolean selectRelevance(List<String> ids);
|
// boolean selectRelevance(List<String> ids);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.njcn.gather.user.user.service.impl;
|
package com.njcn.gather.user.user.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||||
@@ -34,6 +36,20 @@ public class SysFunctionServiceImpl extends ServiceImpl<SysFunctionMapper, SysFu
|
|||||||
|
|
||||||
private final ISysRoleFunctionService sysRoleFunctionService;
|
private final ISysRoleFunctionService sysRoleFunctionService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SysFunction> listFunction(SysFunctionParam.QueryParam queryParam) {
|
||||||
|
LambdaQueryWrapper<SysFunction> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
if (ObjectUtil.isNotNull(queryParam)) {
|
||||||
|
wrapper.like(StrUtil.isNotBlank(queryParam.getName()), SysFunction::getName, queryParam.getName()).eq(ObjectUtil.isNotNull(queryParam.getType()), SysFunction::getType, queryParam.getType());
|
||||||
|
}
|
||||||
|
wrapper.eq(SysFunction::getState, DataStateEnum.ENABLE.getCode());
|
||||||
|
List<SysFunction> allFunctions = this.list(wrapper);
|
||||||
|
return allFunctions.stream().filter(fun -> Objects.equals(FunctionConst.FATHER_PID, fun.getPid()))
|
||||||
|
.peek(funS -> funS.setChildren(getChildrenList(funS, allFunctions)))
|
||||||
|
.sorted(Comparator.comparingInt(SysFunction::getSort))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addFunction(SysFunctionParam functionParam) {
|
public boolean addFunction(SysFunctionParam functionParam) {
|
||||||
checkFunctionParam(functionParam, false);
|
checkFunctionParam(functionParam, false);
|
||||||
@@ -60,10 +76,17 @@ public class SysFunctionServiceImpl extends ServiceImpl<SysFunctionMapper, SysFu
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateFunction(SysFunctionParam.UpdateParam param) {
|
public boolean updateFunction(SysFunctionParam.UpdateParam param) {
|
||||||
|
boolean result = false;
|
||||||
checkFunctionParam(param, true);
|
checkFunctionParam(param, true);
|
||||||
SysFunction function = new SysFunction();
|
SysFunction oldFunction = this.lambdaQuery().eq(SysFunction::getId, param.getId()).eq(SysFunction::getState, DataStateEnum.ENABLE.getCode()).one();
|
||||||
BeanUtil.copyProperties(param, function);
|
List<SysFunction> childrenList = this.lambdaQuery().eq(SysFunction::getPid, param.getId()).eq(SysFunction::getState, DataStateEnum.ENABLE.getCode()).list();
|
||||||
boolean result = this.updateById(function);
|
if (oldFunction.getType().equals(FunctionConst.TYPE_MENU) && param.getType().equals(FunctionConst.TYPE_BUTTON) && !CollectionUtils.isEmpty(childrenList)) {
|
||||||
|
throw new BusinessException(UserResponseEnum.EXISTS_CHILDREN_NOT_UPDATE);
|
||||||
|
} else {
|
||||||
|
SysFunction function = new SysFunction();
|
||||||
|
BeanUtil.copyProperties(param, function);
|
||||||
|
result = this.updateById(function);
|
||||||
|
}
|
||||||
// if (result) {
|
// if (result) {
|
||||||
// refreshRolesFunctionsCache();
|
// refreshRolesFunctionsCache();
|
||||||
// }
|
// }
|
||||||
@@ -81,7 +104,7 @@ public class SysFunctionServiceImpl extends ServiceImpl<SysFunctionMapper, SysFu
|
|||||||
// refreshRolesFunctionsCache();
|
// refreshRolesFunctionsCache();
|
||||||
// }
|
// }
|
||||||
} else {
|
} else {
|
||||||
throw new BusinessException(UserResponseEnum.EXISTS_CHILDREN);
|
throw new BusinessException(UserResponseEnum.EXISTS_CHILDREN_NOT_DELETE);
|
||||||
}
|
}
|
||||||
return result1;
|
return result1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||||
import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
|
import com.njcn.gather.user.pojo.constant.RoleConst;
|
||||||
import com.njcn.gather.user.pojo.enums.UserResponseEnum;
|
import com.njcn.gather.user.pojo.enums.UserResponseEnum;
|
||||||
import com.njcn.gather.user.user.mapper.SysRoleMapper;
|
import com.njcn.gather.user.user.mapper.SysRoleMapper;
|
||||||
import com.njcn.gather.user.user.pojo.param.SysRoleParam;
|
import com.njcn.gather.user.user.pojo.param.SysRoleParam;
|
||||||
@@ -39,16 +40,14 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
|||||||
public Page<SysRole> listRole(SysRoleParam.QueryParam queryParam) {
|
public Page<SysRole> listRole(SysRoleParam.QueryParam queryParam) {
|
||||||
QueryWrapper<SysRole> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<SysRole> queryWrapper = new QueryWrapper<>();
|
||||||
if (ObjectUtil.isNotNull(queryParam)) {
|
if (ObjectUtil.isNotNull(queryParam)) {
|
||||||
queryWrapper.like(StrUtil.isNotBlank(queryParam.getName()), "sys_role.name", queryParam.getName())
|
queryWrapper.like(StrUtil.isNotBlank(queryParam.getName()), "sys_role.name", queryParam.getName()).eq(StrUtil.isNotBlank(queryParam.getCode()), "sys_role.code", queryParam.getCode()).eq(ObjectUtil.isNotNull(queryParam.getType()), "sys_role.type", queryParam.getType());
|
||||||
.eq(StrUtil.isNotBlank(queryParam.getCode()), "sys_role.code", queryParam.getCode())
|
|
||||||
.eq(ObjectUtil.isNotNull(queryParam.getType()), "sys_role.type", queryParam.getType());
|
|
||||||
}
|
}
|
||||||
// if (queryParam.getType().equals(0)) {
|
// if (queryParam.getType().equals(0)) {
|
||||||
// queryWrapper.in("sys_role.type", queryParam.getType(), 1);
|
// queryWrapper.in("sys_role.type", queryParam.getType(), 1);
|
||||||
// } else if (queryParam.getType().equals(1)) {
|
// } else if (queryParam.getType().equals(1)) {
|
||||||
// queryWrapper.eq("sys_role.type", 2);
|
// queryWrapper.eq("sys_role.type", 2);
|
||||||
// }
|
// }
|
||||||
queryWrapper.eq("sys_role.state", DataStateEnum.ENABLE.getCode());
|
queryWrapper.eq("sys_role.state", DataStateEnum.ENABLE.getCode()).orderByDesc("sys_role.Update_Time");
|
||||||
return this.baseMapper.selectPage(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), queryWrapper);
|
return this.baseMapper.selectPage(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,37 +71,24 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean deleteRole(List<String> ids) {
|
public boolean deleteRole(List<String> ids) {
|
||||||
|
//超级管理员、管理员角色不能删除
|
||||||
|
Integer count = this.lambdaQuery()
|
||||||
|
.in(SysRole::getType, RoleConst.TYPE_SUPER_ADMINISTRATOR, RoleConst.TYPE_ADMINISTRATOR)
|
||||||
|
.in(SysRole::getId, ids).eq(SysRole::getState, DataStateEnum.ENABLE.getCode()).count();
|
||||||
|
if (count > 0) {
|
||||||
|
throw new BusinessException(UserResponseEnum.ADMINSTRATOR_ROLE_CANNOT_DELETE);
|
||||||
|
}
|
||||||
// 删除角色和用户的绑定
|
// 删除角色和用户的绑定
|
||||||
sysUserRoleService.deleteUserRoleByRoleIds(ids);
|
sysUserRoleService.deleteUserRoleByRoleIds(ids);
|
||||||
//删除角色和资源的绑定
|
//删除角色和资源的绑定
|
||||||
sysRoleFunctionService.deleteRoleFunctionByRoleIds(ids);
|
sysRoleFunctionService.deleteRoleFunctionByRoleIds(ids);
|
||||||
return this.lambdaUpdate()
|
return this.lambdaUpdate().set(SysRole::getState, DataStateEnum.DELETED.getCode()).in(SysRole::getId, ids).update();
|
||||||
.set(SysRole::getState, DataStateEnum.DELETED.getCode())
|
|
||||||
.in(SysRole::getId, ids).update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public List<SysRole> listAllRole() {
|
|
||||||
// QueryWrapper<SysRole> queryWrapper = new QueryWrapper<>();
|
|
||||||
// queryWrapper.ne("sys_role.state", DataStateEnum.DELETED.getCode());
|
|
||||||
// return this.baseMapper.selectList(queryWrapper);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public List<SysRole> listRoleByType(Integer type) {
|
|
||||||
// return this.lambdaQuery().eq(SysRole::getType, type).eq(SysRole::getState, DataStateEnum.ENABLE.getCode()).list();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public List<SysRole> listRoleByUserId(String userId) {
|
|
||||||
// return sysUserRoleService.listRoleByUserId(userId);
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SysRole> simpleList() {
|
public List<SysRole> simpleList() {
|
||||||
LambdaQueryWrapper<SysRole> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SysRole> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
// lambdaQueryWrapper.select(SysRole::getId, SysRole::getName).eq(SysRole::getState, DataStateEnum.ENABLE.getCode()).eq(SysRole::getType, RoleConst.TYPE_USER);
|
lambdaQueryWrapper.select(SysRole::getId, SysRole::getName).ne(SysRole::getType, RoleConst.TYPE_SUPER_ADMINISTRATOR).eq(SysRole::getState, DataStateEnum.ENABLE.getCode());
|
||||||
lambdaQueryWrapper.select(SysRole::getId, SysRole::getName).eq(SysRole::getState, DataStateEnum.ENABLE.getCode());
|
|
||||||
return this.baseMapper.selectList(lambdaQueryWrapper);
|
return this.baseMapper.selectList(lambdaQueryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,9 +112,8 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
|||||||
private void checkRepeat(SysRoleParam roleParam, boolean isExcludeSelf) {
|
private void checkRepeat(SysRoleParam roleParam, boolean isExcludeSelf) {
|
||||||
LambdaQueryWrapper<SysRole> roleLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SysRole> roleLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
roleLambdaQueryWrapper
|
roleLambdaQueryWrapper
|
||||||
.eq(SysRole::getName, roleParam.getName())
|
.eq(SysRole::getState, DataStateEnum.ENABLE.getCode())
|
||||||
.eq(SysRole::getCode, roleParam.getCode())
|
.and(w -> w.eq(SysRole::getName, roleParam.getName()).or().eq(SysRole::getCode, roleParam.getCode()));
|
||||||
.eq(SysRole::getState, DataStateEnum.ENABLE.getCode());
|
|
||||||
//更新的时候,需排除当前记录
|
//更新的时候,需排除当前记录
|
||||||
if (isExcludeSelf) {
|
if (isExcludeSelf) {
|
||||||
if (roleParam instanceof SysRoleParam.UpdateParam) {
|
if (roleParam instanceof SysRoleParam.UpdateParam) {
|
||||||
|
|||||||
Reference in New Issue
Block a user