年度比赛查询接口优化 11.27

main
zhc077 1 year ago
parent ac090765b5
commit 45a7b7dcd4
  1. 20
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/annualcomp/controller/AnnualCompController.java

@ -24,6 +24,7 @@ import org.jeecg.modules.demo.comp.service.ICompService;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
@ -31,6 +32,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
@ -71,7 +73,6 @@ public class AnnualCompController extends JeecgController<AnnualComp, IAnnualCom
// Page<AnnualComp> page = new Page<AnnualComp>(pageNo, pageSize);
// IPage<AnnualComp> pageList = annualCompService.page(page, queryWrapper);
Subject subject = SecurityUtils.getSubject();
// 获取当前登录用户
LoginUser loginUser = (LoginUser) subject.getPrincipal();
@ -79,7 +80,7 @@ public class AnnualCompController extends JeecgController<AnnualComp, IAnnualCom
String realname = loginUser.getRealname();
String compname = annualComp.getCompname();
String compId = null;
// String compId = null;
LambdaQueryWrapper<Comp> queryWrapper1 = new LambdaQueryWrapper<>();
if (StringUtils.isNotBlank(compname)) {
queryWrapper1.eq(Comp::getCompName, compname);
@ -88,15 +89,18 @@ public class AnnualCompController extends JeecgController<AnnualComp, IAnnualCom
} else {
queryWrapper1.eq(Comp::getCompAdmin, loginUser.getUsername());
}
Comp serviceOne = compService.getOne(queryWrapper1);
if (serviceOne != null) {
compId = serviceOne.getId();
}
List<Comp> comps = compService.list(queryWrapper1);
Page<AnnualComp> page = new Page<>(pageNo, pageSize);
Page<AnnualCompVo> pageInfo = new Page<>();
if(ObjectUtils.isEmpty(comps)){
return Result.OK(pageInfo);
}
Set<String> compIds = comps.stream().map(e -> e.getId()).collect(Collectors.toSet());
LambdaQueryWrapper<AnnualComp> queryWrapper = new LambdaQueryWrapper();
if (compId != null) {
queryWrapper.eq(AnnualComp::getCompid, compId);
if (!ObjectUtils.isEmpty(compIds)) {
queryWrapper.in(AnnualComp::getCompid, compIds);
}
if (annualComp.getAnnualid() != null) {
queryWrapper.eq(AnnualComp::getAnnualid, annualComp.getAnnualid());

Loading…
Cancel
Save