权限功能调整
This commit is contained in:
parent
b5c186aa13
commit
17fb69073e
@ -74,4 +74,14 @@ public class SystemAbilityController {
|
|||||||
return this.abilityService.findByPage(req);
|
return this.abilityService.findByPage(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自动生成
|
||||||
|
* @param userInfoVO
|
||||||
|
*/
|
||||||
|
@GetMapping("/autoCreate")
|
||||||
|
public void autoCreate(@RequestAttribute(value = LOGIN_INFO_KEY) LoginUserInfoVO userInfoVO){
|
||||||
|
this.abilityService.autoSynchMapSystemData(userInfoVO.getAccountVO().getId());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -47,15 +47,16 @@ public class AcPermissionService {
|
|||||||
//
|
//
|
||||||
Permission permission = new Permission();
|
Permission permission = new Permission();
|
||||||
permission.setName(name);
|
permission.setName(name);
|
||||||
permission.setName(des);
|
permission.setDes(des);
|
||||||
permission.setCreatorId(user.getId());
|
permission.setCreatorId(user.getId());
|
||||||
permission.setCreateTime(LocalDateTime.now());
|
permission.setCreateTime(LocalDateTime.now());
|
||||||
permission.setUpdateTime(LocalDateTime.now());
|
permission.setUpdateTime(LocalDateTime.now());
|
||||||
permissionDAO.insertSelective(permission);
|
permissionDAO.insertSelective(permission);
|
||||||
|
|
||||||
//
|
//
|
||||||
Permission find = findByName(name);
|
// Permission find = findByName(name);
|
||||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null != find, String.format("创建权限[name = %s]失败", name));
|
// BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null != find, String.format("创建权限[name = %s]失败", name));
|
||||||
return String.valueOf(find.getId());
|
return String.valueOf(permission.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,6 +17,8 @@ import club.joylink.rtss.vo.permission.convertor.SystemAbilityConvertor;
|
|||||||
import com.github.pagehelper.Page;
|
import com.github.pagehelper.Page;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -44,7 +46,7 @@ public class SystemAbilityService {
|
|||||||
private PermissionSystemAbilityDAO permissionSystemAbilityDAO;
|
private PermissionSystemAbilityDAO permissionSystemAbilityDAO;
|
||||||
@Resource
|
@Resource
|
||||||
@Lazy
|
@Lazy
|
||||||
private RtsMapSystemService mapSystemService;
|
private RtsMapSystemService rtsMapSystemService;
|
||||||
|
|
||||||
|
|
||||||
public SystemAbility findById(Long id){
|
public SystemAbility findById(Long id){
|
||||||
@ -110,6 +112,8 @@ public class SystemAbilityService {
|
|||||||
*/
|
*/
|
||||||
public void updateTypeAndFunc(UpdateAbilityFunctionReqVo vo){
|
public void updateTypeAndFunc(UpdateAbilityFunctionReqVo vo){
|
||||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(vo.getId()),"数据id不能为空");
|
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(vo.getId()),"数据id不能为空");
|
||||||
|
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(vo.getType()),"功能类型不能为空");
|
||||||
|
|
||||||
SystemAbility dbSA = this.findById(vo.getId());
|
SystemAbility dbSA = this.findById(vo.getId());
|
||||||
dbSA.setType(vo.getType().name());
|
dbSA.setType(vo.getType().name());
|
||||||
dbSA.setMapId(vo.getMapId());
|
dbSA.setMapId(vo.getMapId());
|
||||||
@ -161,8 +165,11 @@ public class SystemAbilityService {
|
|||||||
SystemAbilityExample example = new SystemAbilityExample();
|
SystemAbilityExample example = new SystemAbilityExample();
|
||||||
SystemAbilityExample.Criteria criteria = example.createCriteria();
|
SystemAbilityExample.Criteria criteria = example.createCriteria();
|
||||||
example.setOrderByClause(" id desc ");
|
example.setOrderByClause(" id desc ");
|
||||||
if(Objects.equals(false,filterVO.getDesc())){
|
if(Objects.nonNull(filterVO.getName())){
|
||||||
example.setOrderByClause(" id asc ");
|
criteria.andNameLike(String.format("%%%s%%", filterVO.getName()));
|
||||||
|
}
|
||||||
|
if(Objects.nonNull(filterVO.getMapId())){
|
||||||
|
criteria.andMapIdEqualTo(filterVO.getMapId());
|
||||||
}
|
}
|
||||||
Page<SystemAbility> page = (Page<SystemAbility>) this.systemAbilityDAO.selectByExample(example);
|
Page<SystemAbility> page = (Page<SystemAbility>) this.systemAbilityDAO.selectByExample(example);
|
||||||
List<SystemAbilityRspVo> questionVOS = SystemAbilityRspVo.convert2VOList(page.getResult());
|
List<SystemAbilityRspVo> questionVOS = SystemAbilityRspVo.convert2VOList(page.getResult());
|
||||||
@ -178,28 +185,36 @@ public class SystemAbilityService {
|
|||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public void autoSynchMapSystemData(Long userId){
|
public void autoSynchMapSystemData(Long userId){
|
||||||
List<RtsMapSystemVO> voList = this.mapSystemService.listQuery(new RtsMapSystemQueryVO());
|
List<RtsMapSystemVO> voList = this.rtsMapSystemService.listQuery(new RtsMapSystemQueryVO());
|
||||||
List<SystemAbility> abilities = this.systemAbilityDAO.selectByExample(new SystemAbilityExample());
|
List<SystemAbility> abilities = this.systemAbilityDAO.selectByExample(new SystemAbilityExample());
|
||||||
|
List<SystemAbility> deleteList = Lists.newArrayList();
|
||||||
|
List<RtsMapSystemVO> saveList = Lists.newArrayList();
|
||||||
|
List<SynUpdateVO> updateList = Lists.newArrayList();
|
||||||
if(CollectionUtils.isEmpty(abilities)){
|
if(CollectionUtils.isEmpty(abilities)){
|
||||||
this.batchInsert(voList,userId);
|
this.batchInsert(voList,userId);
|
||||||
}else{
|
}else{
|
||||||
Map<String,SystemAbility> abilityMap = abilities.stream().collect(Collectors.toMap(k->k.getType() + k.getAbilityId() + k.getMapId(), Function.identity()));
|
List<SystemAbility> tmpDelList = abilities.stream().filter(d->Objects.isNull(d.getType()) || Objects.isNull(d.getAbilityId()) || Objects.isNull(d.getMapId())).collect(Collectors.toList());
|
||||||
|
deleteList.addAll(tmpDelList);
|
||||||
|
|
||||||
|
Map<String,SystemAbility> abilityMap = abilities.stream().filter(d->Objects.nonNull(d.getType()) && Objects.nonNull(d.getAbilityId()) || Objects.nonNull(d.getMapId()))
|
||||||
|
.collect(Collectors.toMap(k->k.getType() + k.getAbilityId() + k.getMapId(), Function.identity()));
|
||||||
Map<String,RtsMapSystemVO> mapSystemMap = voList.stream().collect(Collectors.toMap(k->k.getSimType().name() + k.getId() + k.getMapId(), Function.identity()));
|
Map<String,RtsMapSystemVO> mapSystemMap = voList.stream().collect(Collectors.toMap(k->k.getSimType().name() + k.getId() + k.getMapId(), Function.identity()));
|
||||||
List<SystemAbility> deleteList = Lists.newArrayList();
|
|
||||||
List<RtsMapSystemVO> saveList = Lists.newArrayList();
|
|
||||||
List<RtsMapSystemVO> updateList = Lists.newArrayList();
|
|
||||||
abilityMap.forEach((k,v)->{
|
abilityMap.forEach((k,v)->{
|
||||||
if(!mapSystemMap.containsKey(k)){
|
if(!mapSystemMap.containsKey(k)){
|
||||||
deleteList.add(v);
|
deleteList.add(v);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mapSystemMap.forEach((k,v)->{
|
mapSystemMap.forEach((k,v)->{
|
||||||
if(abilityMap.containsKey(k)){
|
SystemAbility sa = abilityMap.get(k);
|
||||||
updateList.add(v);
|
if(Objects.nonNull(sa)){
|
||||||
|
updateList.add(new SynUpdateVO(v,sa.getId()));
|
||||||
}else{
|
}else{
|
||||||
saveList.add(v);
|
saveList.add(v);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
this.batchInsert(saveList,userId);
|
||||||
|
this.batchUpdate(updateList);
|
||||||
|
this.batchDelete(deleteList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,13 +224,39 @@ public class SystemAbilityService {
|
|||||||
sa.setCreateTime(LocalDateTime.now());
|
sa.setCreateTime(LocalDateTime.now());
|
||||||
sa.setUpdateTime(LocalDateTime.now());
|
sa.setUpdateTime(LocalDateTime.now());
|
||||||
sa.setCreatorId(userId);
|
sa.setCreatorId(userId);
|
||||||
|
this.systemAbilityDAO.insertSelective(sa);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void batchUpdate(List<RtsMapSystemVO> list){
|
private void batchUpdate(List<SynUpdateVO> list){
|
||||||
|
// List<SystemAbility> lists = SystemAbilityConvertor.converMapSystemVOToAbility(list);
|
||||||
|
SystemAbilityExample example = new SystemAbilityExample();
|
||||||
|
SystemAbilityExample.Criteria criteria = example.createCriteria();
|
||||||
|
for (SynUpdateVO sa : list) {
|
||||||
|
criteria.andIdEqualTo(sa.getAbilityId());
|
||||||
|
SystemAbility vo = SystemAbilityConvertor.converMapSystemVOToAbility(sa.getVo());
|
||||||
|
vo.setUpdateTime(LocalDateTime.now());
|
||||||
|
this.systemAbilityDAO.updateByExampleSelective(vo,example);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private void batchDelete(List<SystemAbility> list){
|
private void batchDelete(List<SystemAbility> list){
|
||||||
|
if(CollectionUtils.isEmpty(list)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<Long> idList = list.stream().map(SystemAbility::getId).collect(Collectors.toList());
|
||||||
|
PermissionSystemAbilityExample example = new PermissionSystemAbilityExample();
|
||||||
|
example.createCriteria().andSystemAbilityIdIn(idList);
|
||||||
|
SystemAbilityExample abilityExample = new SystemAbilityExample();
|
||||||
|
abilityExample.createCriteria().andIdIn(idList);
|
||||||
|
|
||||||
|
this.permissionSystemAbilityDAO.deleteByExample(example);
|
||||||
|
this.systemAbilityDAO.deleteByExample(abilityExample);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
public static class SynUpdateVO{
|
||||||
|
private RtsMapSystemVO vo;
|
||||||
|
private Long abilityId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,7 @@ public class RtsMapSystemVO {
|
|||||||
|
|
||||||
private LocalDateTime updateTime;
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
|
||||||
public RtsMapSystemVO(RtsMapSystem entity) {
|
public RtsMapSystemVO(RtsMapSystem entity) {
|
||||||
id = entity.getId();
|
id = entity.getId();
|
||||||
mapId = entity.getMapId();
|
mapId = entity.getMapId();
|
||||||
|
@ -5,8 +5,6 @@ import lombok.Data;
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class FindAbilityBasicByPageReqVo extends PageQueryVO {
|
public class FindAbilityBasicByPageReqVo extends PageQueryVO {
|
||||||
/**
|
private String name;
|
||||||
* 是否降序,true-降序,false-升序,默认值为true;
|
private Long mapId;
|
||||||
*/
|
|
||||||
private Boolean desc = true;
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package club.joylink.rtss.vo.permission;
|
package club.joylink.rtss.vo.permission;
|
||||||
|
|
||||||
import club.joylink.rtss.entity.permission.SystemAbility;
|
import club.joylink.rtss.entity.permission.SystemAbility;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@ -18,7 +19,7 @@ public class SystemAbilityRspVo {
|
|||||||
/**
|
/**
|
||||||
* 功能的类型
|
* 功能的类型
|
||||||
*/
|
*/
|
||||||
private SystemAbilityType type;
|
private Simulation.Type type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 关联的功能的id,由type决定关联表
|
* 关联的功能的id,由type决定关联表
|
||||||
@ -59,7 +60,7 @@ public class SystemAbilityRspVo {
|
|||||||
SystemAbilityRspVo vo = new SystemAbilityRspVo();
|
SystemAbilityRspVo vo = new SystemAbilityRspVo();
|
||||||
vo.setId(sa.getId());
|
vo.setId(sa.getId());
|
||||||
if(Objects.nonNull(sa.getType())){
|
if(Objects.nonNull(sa.getType())){
|
||||||
vo.setType(SystemAbilityType.valueOf(sa.getType()));
|
vo.setType(Simulation.Type.valueOf(sa.getType()));
|
||||||
}
|
}
|
||||||
vo.setAbilityId(sa.getAbilityId());
|
vo.setAbilityId(sa.getAbilityId());
|
||||||
vo.setName(sa.getName());
|
vo.setName(sa.getName());
|
||||||
|
Loading…
Reference in New Issue
Block a user