年度比赛查询接口优化 11.27

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

Loading…
Cancel
Save