Merge remote-tracking branch 'origin/test-training2' into test-training2

This commit is contained in:
joylink_zhangsai 2022-10-14 14:59:21 +08:00
commit 9e0026e622
3 changed files with 13 additions and 12 deletions

View File

@ -8,6 +8,8 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import static club.joylink.rtss.controller.advice.AuthenticateInterceptor.LOGIN_INFO_KEY;
/**
* 面向权限的系统功能管理接口V2
@ -22,14 +24,14 @@ public class SystemAbilityController {
* 添加权限功能
*/
@PostMapping("/basic")
public void addAbility(@RequestBody BasicSystemAbilityVo req, @RequestAttribute LoginUserInfoVO userInfoVO){
public void addAbility(@RequestBody BasicSystemAbilityVo req, @RequestAttribute(value = LOGIN_INFO_KEY) LoginUserInfoVO userInfoVO){
this.abilityService.saveOrUpdateBasicAbility(req,userInfoVO);
}
/**
* 修改权限功能的名称和描述
*/
@PutMapping("/basic")
public void updateAbilityBasic(@RequestBody BasicSystemAbilityVo req,@RequestAttribute LoginUserInfoVO userInfoVO){
public void updateAbilityBasic(@RequestBody BasicSystemAbilityVo req,@RequestAttribute(value = LOGIN_INFO_KEY) LoginUserInfoVO userInfoVO){
this.abilityService.saveOrUpdateBasicAbility(req,userInfoVO);
}
/**
@ -64,7 +66,7 @@ public class SystemAbilityController {
/**
* 分页查询权限功能的基本信息
*/
@PostMapping("/find/basic/page")
@PostMapping("/page")
public PageVO<SystemAbilityRspVo>findByPage(FindAbilityBasicByPageReqVo req){
return this.abilityService.findByPage(req);
}

View File

@ -91,24 +91,18 @@ public class SystemAbilityService {
* @param reqVo
*/
public void remove(DeleteAbilitiesReqVo reqVo){
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(CollectionUtils.isEmpty(reqVo.getIds()),"删除数据的id不能为空");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(!CollectionUtils.isEmpty(reqVo.getIds()),"删除数据的id不能为空");
List<Long> newIds = reqVo.getIds().stream().distinct().collect(Collectors.toList());
PermissionSystemAbilityExample pe = new PermissionSystemAbilityExample();
pe.createCriteria().andSystemAbilityIdIn(newIds);
List<PermissionSystemAbility> psaList = this.permissionSystemAbilityDAO.selectByExample(pe);
Map<Long,List<PermissionSystemAbility>> psaMapList = psaList.stream()
.collect(Collectors.groupingBy(PermissionSystemAbility::getSystemAbilityId));
newIds.stream().forEach(psaMapList::remove);
StringBuilder sb = new StringBuilder();
psaMapList.forEach((k,v)->{
sb.append(String.format("id=%s有绑定的权限数量=%s,不能删除",k,v.size()));
});
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(psaMapList.isEmpty(),sb.toString());
SystemAbilityExample example = new SystemAbilityExample();
SystemAbilityExample.Criteria criteria = example.createCriteria();
criteria.andIdIn(newIds);

View File

@ -6,6 +6,7 @@ import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;
@Data
public class SystemAbilityRspVo {
@ -57,11 +58,15 @@ public class SystemAbilityRspVo {
public static SystemAbilityRspVo toVO(SystemAbility sa){
SystemAbilityRspVo vo = new SystemAbilityRspVo();
vo.setId(sa.getId());
vo.setType(SystemAbilityType.valueOf(sa.getType()));
if(Objects.nonNull(sa.getType())){
vo.setType(SystemAbilityType.valueOf(sa.getType()));
}
vo.setAbilityId(sa.getAbilityId());
vo.setName(sa.getName());
vo.setDes(sa.getDes());
vo.setStatus(SystemAbilityStatus.valueOf(sa.getStatus()));
if(Objects.nonNull(sa.getStatus())){
vo.setStatus(SystemAbilityStatus.valueOf(sa.getStatus()));
}
vo.setCreatorId(sa.getCreatorId());
vo.setCreateTime(sa.getCreateTime());
vo.setUpdateTime(sa.getUpdateTime());