|
|
|
@ -1,15 +1,19 @@ |
|
|
|
|
package org.jeecg.modules.demo.annualcompaward.controller; |
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Arrays; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
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; |
|
|
|
|
import org.jeecg.common.api.vo.Result; |
|
|
|
|
import org.jeecg.common.system.query.QueryGenerator; |
|
|
|
|
import org.jeecg.common.aspect.annotation.AutoLog; |
|
|
|
|
import org.jeecg.common.system.base.controller.JeecgController; |
|
|
|
|
import org.jeecg.common.system.vo.LoginUser; |
|
|
|
|
import org.jeecg.modules.demo.annual.entity.Annual; |
|
|
|
|
import org.jeecg.modules.demo.annual.service.IAnnualService; |
|
|
|
|
import org.jeecg.modules.demo.annualCompPoint.entity.AnnualCompPoint; |
|
|
|
@ -17,24 +21,18 @@ import org.jeecg.modules.demo.annualCompPoint.service.IAnnualCompPointService; |
|
|
|
|
import org.jeecg.modules.demo.annualcomp.entity.AnnualComp; |
|
|
|
|
import org.jeecg.modules.demo.annualcomp.service.IAnnualCompService; |
|
|
|
|
import org.jeecg.modules.demo.annualcompaward.entity.AnnualCompAward; |
|
|
|
|
import org.jeecg.modules.demo.annualcompaward.entity.AnnualCompAwardvo; |
|
|
|
|
import org.jeecg.modules.demo.annualcompaward.service.IAnnualCompAwardService; |
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
|
|
|
|
import org.jeecg.common.system.base.controller.JeecgController; |
|
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
|
import org.jeecg.modules.demo.comp.entity.Comp; |
|
|
|
|
import org.jeecg.modules.demo.comp.service.ICompService; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.context.annotation.Bean; |
|
|
|
|
import org.springframework.util.ObjectUtils; |
|
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
import org.springframework.web.servlet.ModelAndView; |
|
|
|
|
import io.swagger.annotations.Api; |
|
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
|
import org.jeecg.common.aspect.annotation.AutoLog; |
|
|
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions; |
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @Description: 年度比赛奖项设置 |
|
|
|
@ -56,6 +54,9 @@ public class AnnualCompAwardController extends JeecgController<AnnualCompAward, |
|
|
|
|
@Autowired |
|
|
|
|
private IAnnualCompService annualCompService; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private ICompService iCompService; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 分页列表查询 |
|
|
|
|
* |
|
|
|
@ -68,36 +69,78 @@ public class AnnualCompAwardController extends JeecgController<AnnualCompAward, |
|
|
|
|
//@AutoLog(value = "年度比赛奖项设置-分页列表查询")
|
|
|
|
|
@ApiOperation(value = "年度比赛奖项设置-分页列表查询", notes = "年度比赛奖项设置-分页列表查询") |
|
|
|
|
@GetMapping(value = "/list") |
|
|
|
|
public Result<IPage<AnnualCompAwardvo>> queryPageList(AnnualCompAward annualCompAward, |
|
|
|
|
public Result<IPage<AnnualCompAward>> queryPageList(AnnualCompAward annualCompAward, |
|
|
|
|
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, |
|
|
|
|
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, |
|
|
|
|
HttpServletRequest req) { |
|
|
|
|
QueryWrapper<AnnualCompAward> queryWrapper = QueryGenerator.initQueryWrapper(annualCompAward, req.getParameterMap()); |
|
|
|
|
|
|
|
|
|
Subject subject = SecurityUtils.getSubject(); |
|
|
|
|
// 获取当前登录用户
|
|
|
|
|
LoginUser loginUser = (LoginUser) subject.getPrincipal(); |
|
|
|
|
//角色名称 管理员&教务处可以查看所有
|
|
|
|
|
String realname = loginUser.getRealname(); |
|
|
|
|
Set<String> annualCompPointIds = new TreeSet<>(); |
|
|
|
|
|
|
|
|
|
// QueryWrapper<AnnualCompAward> queryWrapper = QueryGenerator.initQueryWrapper(annualCompAward, req.getParameterMap());
|
|
|
|
|
LambdaQueryWrapper<AnnualCompAward> queryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
if (StringUtils.equals("管理员", realname) || StringUtils.equals("教务处", realname)) { |
|
|
|
|
} else { |
|
|
|
|
List<Comp> compList = iCompService.list(new LambdaQueryWrapper<Comp>().eq(Comp::getCompAdmin, loginUser.getUsername())); |
|
|
|
|
if (!ObjectUtils.isEmpty(compList)) { |
|
|
|
|
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()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
queryWrapper.in(AnnualCompAward::getAnnucompid, annualCompPointIds); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Page<AnnualCompAward> page = new Page<AnnualCompAward>(pageNo, pageSize); |
|
|
|
|
Page<AnnualCompAwardvo> page1 = new Page<>(); |
|
|
|
|
annualCompAwardService.page(page, queryWrapper); |
|
|
|
|
BeanUtils.copyProperties(page, page1,"records"); |
|
|
|
|
List<AnnualCompAward> list=page.getRecords(); |
|
|
|
|
List<AnnualCompAwardvo> list1=list.stream().map((item)->{ |
|
|
|
|
AnnualCompAwardvo annualCompAward1=new AnnualCompAwardvo(); |
|
|
|
|
BeanUtils.copyProperties(item,annualCompAward1); |
|
|
|
|
AnnualCompPoint annualCompPoint = annualCompPointService.query().eq("id", annualCompAward1.getAnnucompid()).one(); |
|
|
|
|
AnnualComp annualComp = null; |
|
|
|
|
Annual annual = null; |
|
|
|
|
if (annualCompPoint != null) { |
|
|
|
|
annualComp = annualCompService.query().eq("id", annualCompPoint.getAnnualCompId()).one(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Page<AnnualCompAwardvo> page1 = new Page<>();
|
|
|
|
|
// BeanUtils.copyProperties(page, page1, "records");
|
|
|
|
|
// List<AnnualCompAward> list = page.getRecords();
|
|
|
|
|
// List<AnnualCompAwardvo> list1 = list.stream().map((item) -> {
|
|
|
|
|
// AnnualCompAwardvo annualCompAward1 = new AnnualCompAwardvo();
|
|
|
|
|
// BeanUtils.copyProperties(item, annualCompAward1);
|
|
|
|
|
// AnnualCompPoint annualCompPoint = annualCompPointService.query().eq("id", annualCompAward1.getAnnucompid()).one();
|
|
|
|
|
// AnnualComp annualComp = null;
|
|
|
|
|
// Annual annual = null;
|
|
|
|
|
// if (annualCompPoint != null) {
|
|
|
|
|
// annualComp = annualCompService.query().eq("id", annualCompPoint.getAnnualCompId()).one();
|
|
|
|
|
// }
|
|
|
|
|
// if (annualComp != null) {
|
|
|
|
|
// annual = annualService.query().eq("id", annualComp.getAnnualid()).one();
|
|
|
|
|
// }
|
|
|
|
|
//// if (annualCompPoint != null && annualComp != null && annual != null)
|
|
|
|
|
// annualCompAward1.setAnnucompid(annualCompPoint.getObjName());
|
|
|
|
|
// annualCompAward1.setComp(annualComp.getName());
|
|
|
|
|
// annualCompAward1.setAnnual(annual.getAnnualName());
|
|
|
|
|
// return annualCompAward1;
|
|
|
|
|
// }).collect(Collectors.toList());
|
|
|
|
|
// page1.setRecords(list1);
|
|
|
|
|
|
|
|
|
|
List<AnnualCompAward> records = page.getRecords(); |
|
|
|
|
Optional.ofNullable(records).orElse(new LinkedList<>()).stream().forEach(e -> { |
|
|
|
|
AnnualCompPoint annualCompPoint = annualCompPointService.getById(e.getAnnucompid()); |
|
|
|
|
if (!ObjectUtils.isEmpty(annualCompPoint)) { |
|
|
|
|
AnnualComp annualComp = annualCompService.getById(annualCompPoint.getAnnualCompId()); |
|
|
|
|
if (annualComp != null) { |
|
|
|
|
annual = annualService.query().eq("id", annualComp.getAnnualid()).one(); |
|
|
|
|
} |
|
|
|
|
if (annualCompPoint != null && annualComp != null && annual != null) |
|
|
|
|
annualCompAward1.setAnnucompid(annualCompPoint.getObjName()); |
|
|
|
|
annualCompAward1.setComp(annualComp.getName()); |
|
|
|
|
annualCompAward1.setAnnual(annual.getAnnualName()); |
|
|
|
|
return annualCompAward1; |
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
page1.setRecords(list1); |
|
|
|
|
return Result.OK(page1); |
|
|
|
|
e.setComp(annualComp.getName()); |
|
|
|
|
Annual annual = annualService.getById(annualComp.getAnnualid()); |
|
|
|
|
if (annual != null) { |
|
|
|
|
e.setAnnual(annual.getAnnualName()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
return Result.OK(page); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|