|
|
|
@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
|
import io.swagger.annotations.Api; |
|
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.apache.commons.lang.StringUtils; |
|
|
|
|
import org.apache.shiro.SecurityUtils; |
|
|
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions; |
|
|
|
|
import org.apache.shiro.subject.Subject; |
|
|
|
@ -24,6 +23,8 @@ import org.jeecg.modules.demo.annualcompaward.entity.AnnualCompAward; |
|
|
|
|
import org.jeecg.modules.demo.annualcompaward.service.IAnnualCompAwardService; |
|
|
|
|
import org.jeecg.modules.demo.comp.entity.Comp; |
|
|
|
|
import org.jeecg.modules.demo.comp.service.ICompService; |
|
|
|
|
import org.jeecg.modules.system.entity.SysRole; |
|
|
|
|
import org.jeecg.modules.system.service.ISysUserRoleService; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.util.ObjectUtils; |
|
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
@ -57,6 +58,9 @@ public class AnnualCompAwardController extends JeecgController<AnnualCompAward, |
|
|
|
|
@Autowired |
|
|
|
|
private ICompService iCompService; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private ISysUserRoleService iSysUserRoleService; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 分页列表查询 |
|
|
|
|
* |
|
|
|
@ -77,30 +81,36 @@ public class AnnualCompAwardController extends JeecgController<AnnualCompAward, |
|
|
|
|
Subject subject = SecurityUtils.getSubject(); |
|
|
|
|
// 获取当前登录用户
|
|
|
|
|
LoginUser loginUser = (LoginUser) subject.getPrincipal(); |
|
|
|
|
//角色名称 管理员&教务处可以查看所有
|
|
|
|
|
String realname = loginUser.getRealname(); |
|
|
|
|
Set<String> annualCompPointIds = new TreeSet<>(); |
|
|
|
|
List<SysRole> roleList = iSysUserRoleService.getUserRoleByUserId(loginUser.getId()); |
|
|
|
|
Map<String, String> roleMap = Optional.ofNullable(roleList).orElse(new LinkedList<>()).stream().collect(Collectors.toMap(SysRole::getRoleCode, SysRole::getRoleCode)); |
|
|
|
|
//角色编码 管理员&组委会&教务处 可以看到所有,其它用户可见到所属自己数据
|
|
|
|
|
Map<String, String> efficientRoleMap = new LinkedHashMap<>(); |
|
|
|
|
efficientRoleMap.put("admin", "admin"); |
|
|
|
|
efficientRoleMap.put("committee", "committee"); |
|
|
|
|
efficientRoleMap.put("superAdmin", "superAdmin"); |
|
|
|
|
|
|
|
|
|
// QueryWrapper<AnnualCompAward> queryWrapper = QueryGenerator.initQueryWrapper(annualCompAward, req.getParameterMap());
|
|
|
|
|
LambdaQueryWrapper<AnnualCompAward> queryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
if (StringUtils.equals("管理员", realname) || StringUtils.equals("教务处", realname)) { |
|
|
|
|
} else { |
|
|
|
|
Page<AnnualCompAward> page = new Page<AnnualCompAward>(pageNo, pageSize); |
|
|
|
|
// 查询所属当前登录用户数据
|
|
|
|
|
if (!efficientRoleMap.containsValue(roleMap.get("admin")) |
|
|
|
|
&& !efficientRoleMap.containsValue(roleMap.get("committee")) |
|
|
|
|
&& !efficientRoleMap.containsValue(roleMap.get("superAdmin"))) { |
|
|
|
|
List<Comp> compList = iCompService.list(new LambdaQueryWrapper<Comp>().eq(Comp::getCompAdmin, loginUser.getUsername())); |
|
|
|
|
if (!ObjectUtils.isEmpty(compList)) { |
|
|
|
|
if (ObjectUtils.isEmpty(compList)) { |
|
|
|
|
return Result.OK(page); |
|
|
|
|
} |
|
|
|
|
Set<String> compIds = compList.stream().map(c -> c.getId()).collect(Collectors.toSet()); |
|
|
|
|
List<AnnualComp> annualCompList = annualCompService.list(new LambdaQueryWrapper<AnnualComp>().in(AnnualComp::getCompid, compIds)); |
|
|
|
|
if (!ObjectUtils.isEmpty(annualCompList)) { |
|
|
|
|
Set<String> annualCompIds = annualCompList.stream().map(d -> d.getId()).collect(Collectors.toSet()); |
|
|
|
|
List<AnnualCompPoint> annualCompPointList = annualCompPointService.list(new LambdaQueryWrapper<AnnualCompPoint>().in(AnnualCompPoint::getAnnualCompId, annualCompIds)); |
|
|
|
|
if (!ObjectUtils.isEmpty(annualCompPointList)) { |
|
|
|
|
annualCompPointIds = annualCompPointList.stream().map(e -> e.getId()).collect(Collectors.toSet()); |
|
|
|
|
} |
|
|
|
|
Set<String> annualCompPointIds = annualCompPointList.stream().map(e -> e.getId()).collect(Collectors.toSet()); |
|
|
|
|
queryWrapper.in(AnnualCompAward::getAnnucompid, annualCompPointIds); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
queryWrapper.in(AnnualCompAward::getAnnucompid, annualCompPointIds); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Page<AnnualCompAward> page = new Page<AnnualCompAward>(pageNo, pageSize); |
|
|
|
|
annualCompAwardService.page(page, queryWrapper); |
|
|
|
|
|
|
|
|
|
// Page<AnnualCompAwardvo> page1 = new Page<>();
|
|
|
|
@ -143,6 +153,7 @@ public class AnnualCompAwardController extends JeecgController<AnnualCompAward, |
|
|
|
|
return Result.OK(page); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 添加 |
|
|
|
|
* |
|
|
|
|