用户权限支持查看已很配领取的权限,答题试卷在创建的时候及有开始时间

This commit is contained in:
tiger_zhou 2022-10-21 17:14:56 +08:00
parent e398d0c364
commit 231171b6c8
5 changed files with 58 additions and 7 deletions

View File

@ -12,6 +12,8 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/** /**
* 主体(用户或组织)的权限管理接口V2<br> * 主体(用户或组织)的权限管理接口V2<br>
*/ */
@ -29,8 +31,22 @@ public class PermissionSubjectController {
return this.subjectService.page(req); return this.subjectService.page(req);
} }
/**
* 用户权限失效设置
* @param subjectId
*/
@GetMapping(path = "/inValid/{subjectId}") @GetMapping(path = "/inValid/{subjectId}")
public void statusForInValid(@PathVariable Long subjectId){ public void statusForInValid(@PathVariable Long subjectId){
this.subjectService.subjectAndDistributeStatusForInValid(subjectId); this.subjectService.subjectAndDistributeStatusForInValid(subjectId);
} }
/**
* 查看用户分发的下级所有用户权限
* @param subjectId
*/
@GetMapping(path = "/distribute/{subjectId}")
public List<PermissionSubjectVO> distributePermission(@PathVariable Long subjectId){
List<PermissionSubjectVO> list = this.subjectService.findDistributePermission(subjectId);
return list;
}
} }

View File

@ -1,7 +1,5 @@
package club.joylink.rtss.dao.permission; package club.joylink.rtss.dao.permission;
import java.util.List;
import club.joylink.rtss.entity.permission.PermissionSubject; import club.joylink.rtss.entity.permission.PermissionSubject;
import club.joylink.rtss.entity.permission.PermissionSubjectExample; import club.joylink.rtss.entity.permission.PermissionSubjectExample;
import club.joylink.rtss.vo.permission.subject.PermissionSubjectQueryVO; import club.joylink.rtss.vo.permission.subject.PermissionSubjectQueryVO;
@ -9,14 +7,31 @@ import club.joylink.rtss.vo.permission.subject.PermissionSubjectVO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List;
@Mapper @Mapper
@Repository @Repository
public interface PermissionSubjectDAO { public interface PermissionSubjectDAO {
@Select("<script>" +
"select A.id,A.subject_type,A.subject_id, " +
"(case when A.subject_type = 'user' then C.name when A.subject_type = 'org' then D.name end) as named," +
"(case when A.subject_type = 'user' then C.nickname else '' end) as nick_name," +
"B.name as permission_name,A.permission_id " +
" from rts_permission_subject A left join rts_permission B on A.permission_id = B.id" +
" left join sys_account C on A.subject_type = 'user' and A.subject_id = C.id " +
" left join org D on A.subject_type = 'org' and A.subject_id = C.id " +
" where 1 = 1 and A.parent_id in " +
"<if test=\"idList != null and idList.size > 0\"> " +
" <foreach collection=\"lable\" open=\"(\" close=\")\" item=\"d\" separator=\" , \"> "+
" #{d}"+
" </foreach>" +
"</if> " +
"order by id asc" +
"</script>")
List<PermissionSubjectVO> findDistributePermission(List<Long> idList);
/* @Select("<script>" + /* @Select("<script>" +
"select t4.* from " + "select t4.* from " +
"(" + "(" +

View File

@ -80,6 +80,7 @@ public class PaperUserCreateService {
paper.setPcId(pcId); paper.setPcId(pcId);
paper.setOrgId(orgId); paper.setOrgId(orgId);
paper.setCreateTime(LocalDateTime.now()); paper.setCreateTime(LocalDateTime.now());
paper.setStartTime(LocalDateTime.now());
paperUserDAO.insertSelective(paper); paperUserDAO.insertSelective(paper);
paper = paperUserService.findByUserIdAndPcId(user.getId(), pcId); paper = paperUserService.findByUserIdAndPcId(user.getId(), pcId);
// //

View File

@ -39,7 +39,7 @@ public class PermissionSubjectService {
public PageVO<PermissionSubjectVO> page(PermissionSubjectQueryVO queryVO){ public PageVO<PermissionSubjectVO> page(PermissionSubjectQueryVO queryVO){
PageHelper.startPage(queryVO.getPageNum(),queryVO.getPageSize()); PageHelper.startPage(queryVO.getPageNum(),queryVO.getPageSize());
Page<PermissionSubjectVO> page = (Page<PermissionSubjectVO>) this.subjectDAO.customerQuery(queryVO); Page<PermissionSubjectVO> page = (Page<PermissionSubjectVO>) this.subjectDAO.customerQuery(queryVO);
List<Long> permissionList = page.getResult().stream().filter(Objects::nonNull).map(PermissionSubjectVO::getPermissionId).collect(Collectors.toList()); List<Long> permissionList = page.getResult().stream().map(PermissionSubjectVO::getPermissionId).filter(Objects::nonNull).collect(Collectors.toList());
List<PermissionSystemAbilityVO> abilityVOList = this.systemAbilityService.findSystemAbilityByPermissionId(permissionList); List<PermissionSystemAbilityVO> abilityVOList = this.systemAbilityService.findSystemAbilityByPermissionId(permissionList);
Map<Long,List<PermissionSystemAbilityVO>> permissionMapList = abilityVOList.stream().collect(Collectors.groupingBy(PermissionSystemAbilityVO::getPermissionId)); Map<Long,List<PermissionSystemAbilityVO>> permissionMapList = abilityVOList.stream().collect(Collectors.groupingBy(PermissionSystemAbilityVO::getPermissionId));
for (PermissionSubjectVO subjectVO : page.getResult()) { for (PermissionSubjectVO subjectVO : page.getResult()) {
@ -53,15 +53,15 @@ public class PermissionSubjectService {
public PermissionSubject findById(Long subjectId){ public PermissionSubject findById(Long subjectId){
PermissionSubject ps = this.subjectDAO.selectByPrimaryKey(subjectId); PermissionSubject ps = this.subjectDAO.selectByPrimaryKey(subjectId);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(Objects.nonNull(ps),""); BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(Objects.nonNull(ps),"未找到对应的数据");
return ps; return ps;
} }
@Transactional @Transactional
public void subjectAndDistributeStatusForInValid(Long subjectId){ public void subjectAndDistributeStatusForInValid(Long subjectId){
List<PermissionSubject> allList = Lists.newArrayList();
PermissionSubject ps = this.findById(subjectId); PermissionSubject ps = this.findById(subjectId);
List<PermissionSubject> allList = Lists.newArrayList();
allList.add(ps); allList.add(ps);
if(Objects.equals(ps.getSubjectType(),PermissionSubjectTypeEnum.user.name())){ if(Objects.equals(ps.getSubjectType(),PermissionSubjectTypeEnum.user.name())){
this.circleFindChildSubject(allList, Arrays.asList(ps.getId())); this.circleFindChildSubject(allList, Arrays.asList(ps.getId()));
@ -82,11 +82,27 @@ public class PermissionSubjectService {
private void circleFindChildSubject(List<PermissionSubject> subjectList,List<Long> ids){ private void circleFindChildSubject(List<PermissionSubject> subjectList,List<Long> ids){
PermissionSubjectExample example = new PermissionSubjectExample(); PermissionSubjectExample example = new PermissionSubjectExample();
example.createCriteria().andParentIdIn(ids); example.createCriteria().andParentIdIn(ids);
example.setOrderByClause(" id desc");
List<PermissionSubject> list = this.subjectDAO.selectByExample(example); List<PermissionSubject> list = this.subjectDAO.selectByExample(example);
if(!CollectionUtils.isEmpty(list)){ if(!CollectionUtils.isEmpty(list)){
subjectList.addAll(list); subjectList.addAll(list);
List<Long> childIdList = list.stream().map(PermissionSubject::getId).collect(Collectors.toList()); List<Long> childIdList = list.stream().map(PermissionSubject::getId).collect(Collectors.toList());
this.circleFindChildSubject(subjectList,childIdList); this.circleFindChildSubject(subjectList,childIdList);
} }
} }
public List<PermissionSubjectVO> findDistributePermission(Long subjectId){
PermissionSubject ps = this.findById(subjectId);
List<PermissionSubjectVO> voList = Lists.newArrayList();
this.distributePermission(voList,Arrays.asList(ps.getId()));
return voList;
}
private void distributePermission(List<PermissionSubjectVO> lists,List<Long> ids){
List<PermissionSubjectVO> voList = this.subjectDAO.findDistributePermission(ids);
if(!CollectionUtils.isEmpty(voList)){
lists.addAll(voList);
}
}
} }

View File

@ -28,6 +28,9 @@ public class PermissionSubjectVO {
* 用户昵称 * 用户昵称
*/ */
private String nickName; private String nickName;
/**
* 重量权限数
*/
private Integer amount; private Integer amount;
/** /**
* 主体对该权限的剩余数量 * 主体对该权限的剩余数量