组委会角色出现全部数据以及没有判空

main
王家东 4 months ago
parent 12f7958596
commit 2225ca7a31
  1. 65
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/chooseTopicPersion/controller/ChaoseTopicPersionController.java

@ -11,16 +11,21 @@ import java.net.URLDecoder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.CommonAPI;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.vo.DictModel;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.demo.anncomgrotop.entity.AnnComGroTop;
import org.jeecg.modules.demo.anncomgrotop.service.IAnnComGroTopService;
import org.jeecg.modules.demo.anncomgrotopp.entity.AnnComGroTopP;
import org.jeecg.modules.demo.anncomgrotopp.service.IAnnComGroTopPService;
import org.jeecg.modules.demo.annualCompPoint.entity.AnnualCompPoint;
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.annualcompetitionprojectregistration.entity.AnnualCompetitionProjectRegistration;
import org.jeecg.modules.demo.annualcompetitionprojectregistration.service.IAnnualCompetitionProjectRegistrationService;
import org.jeecg.modules.demo.chooseTopicPersion.entity.ChaoseTopicPersion;
@ -33,6 +38,9 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.demo.comp.entity.Comp;
import org.jeecg.modules.demo.comp.service.ICompService;
import org.jeecg.modules.demo.topic.entity.Topic;
import org.jeecg.modules.demo.topic.service.ITopicService;
import org.jeecg.modules.demo.upfile_persion.entity.UpfilePersion;
import org.jeecg.modules.demo.upfile_persion.service.IUpfilePersionService;
@ -80,6 +88,10 @@ public class ChaoseTopicPersionController extends JeecgController<ChaoseTopicPer
private IAnnComGroTopPService annComGroTopPService;
@Autowired
private IUpfilePersionService upfilePersionService;
@Autowired
private IAnnualCompService annualCompService;
@Autowired
private ICompService compService;
/**
* 分页列表查询
@ -98,6 +110,12 @@ public class ChaoseTopicPersionController extends JeecgController<ChaoseTopicPer
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<ChaoseTopicPersion> queryWrapper = QueryGenerator.initQueryWrapper(chaoseTopicPersion, req.getParameterMap());
//根据当前登录信息查询题目id,用list去接受
List<String> topicid =gettopicid();
if (topicid.isEmpty()){
return Result.error("请检查比赛流程,未发现选题信息。");
}
queryWrapper.in("timul",topicid);
Page<ChaoseTopicPersion> page = new Page<>(pageNo, pageSize);
IPage<ChaoseTopicPersion> pageList = chaoseTopicPersionService.page(page, queryWrapper);
List<ChooseDto> chooseDtos = new ArrayList<>();
@ -131,6 +149,53 @@ public class ChaoseTopicPersionController extends JeecgController<ChaoseTopicPer
return Result.OK(chooseDtos);
}
//根据当前登录信息获取题目id,返回list
private List<String> gettopicid() {
List<String> topicids = new ArrayList<>();
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
//根据登录信息查询负责比赛
List<Comp> compList =compService.query().eq("comp_admin",loginUser.getUsername()).list();
//判空
if (compList.isEmpty()){
return topicids;
}
//将比赛的id放进一个list里面
List<String> compIds = compList.stream()
.map(Comp::getId) // 使用方法引用获取每个Comp对象的id
.collect(Collectors.toList()); // 收集到List中
//根据比赛的id查询年度比赛id,这里没有去卡年度
List<AnnualComp> annualCompList = annualCompService.query().in("compid",compIds).list();
//判空
if (annualCompList.isEmpty()){
return topicids;
}
//将年度比赛id存放到一个list里面
List<String> anncompIds = annualCompList.stream()
.map(AnnualComp::getId) // 使用方法引用获取每个Comp对象的id
.collect(Collectors.toList()); // 收集到List中
List<AnnualCompPoint> annualCompPointList = annualCompPointService.query().in("annual_comp_id", anncompIds).list();
//判空
if (annualCompPointList.isEmpty()){
return topicids;
}
//将年度比赛项目id存放到一个list里面
List<String> anncomppointIds = annualCompPointList.stream()
.map(AnnualCompPoint::getId) // 使用方法引用获取每个Comp对象的id
.collect(Collectors.toList()); // 收集到List中
//根据年度比赛项目id查询题目
List<Topic> topicList = topicService.query().in("annual_compid",anncomppointIds).list();
if (topicList.isEmpty()){
return topicids;
}
topicids =topicList.stream()
.map(Topic::getId) // 使用方法引用获取每个Comp对象的id
.collect(Collectors.toList()); // 收集到List中
return topicids;
}
@GetMapping(value = "/watch")
public Result<ChaoseTopicPersion> watch(String enrollCode) {
QueryWrapper<ChaoseTopicPersion> queryWrapper = new QueryWrapper<>();

Loading…
Cancel
Save