mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-20 18:15:56 +08:00
up
This commit is contained in:
parent
3e69a02f7d
commit
23e6f41941
@ -42,7 +42,7 @@ public class TitleController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("question:title:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<TitleVo> list(TitleBo bo, PageQuery pageQuery) {
|
||||
public TableDataInfo<TitleResp> list(TitleBo bo, PageQuery pageQuery) {
|
||||
return titleService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@ public class TitleResp implements Serializable {
|
||||
/**
|
||||
* 题目标签类型
|
||||
*/
|
||||
private Long labelName;
|
||||
private String labelName;
|
||||
|
||||
private List<OptionVo> optionVoList;
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@ public interface ITitleService {
|
||||
/**
|
||||
* 查询题目列表
|
||||
*/
|
||||
TableDataInfo<TitleVo> queryPageList(TitleBo bo, PageQuery pageQuery);
|
||||
TableDataInfo<TitleResp> queryPageList(TitleBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询题目列表
|
||||
|
||||
@ -1,27 +1,30 @@
|
||||
package org.dromara.question.service.impl;
|
||||
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.question.domain.Options;
|
||||
import org.dromara.question.domain.bo.TitleResp;
|
||||
import org.dromara.question.domain.vo.OptionVo;
|
||||
import org.dromara.question.mapper.OptionMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.dromara.question.domain.bo.TitleBo;
|
||||
import org.dromara.question.domain.vo.TitleVo;
|
||||
import org.dromara.question.domain.Title;
|
||||
import org.dromara.question.domain.bo.TitleBo;
|
||||
import org.dromara.question.domain.bo.TitleResp;
|
||||
import org.dromara.question.domain.vo.LabelsVo;
|
||||
import org.dromara.question.domain.vo.OptionVo;
|
||||
import org.dromara.question.domain.vo.TitleVo;
|
||||
import org.dromara.question.mapper.LabelsMapper;
|
||||
import org.dromara.question.mapper.OptionMapper;
|
||||
import org.dromara.question.mapper.TitleMapper;
|
||||
import org.dromara.question.service.ITitleService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 题目Service业务层处理
|
||||
@ -37,11 +40,13 @@ public class TitleServiceImpl implements ITitleService {
|
||||
|
||||
private final OptionMapper optionMapper;
|
||||
|
||||
private final LabelsMapper labelsMapper;
|
||||
|
||||
/**
|
||||
* 查询题目
|
||||
*/
|
||||
@Override
|
||||
public TitleResp queryById(Long id){
|
||||
public TitleResp queryById(Long id) {
|
||||
TitleVo titleVo = baseMapper.selectVoById(id);
|
||||
List<OptionVo> options = optionMapper.selectVoList(new LambdaQueryWrapper<Options>()
|
||||
.eq(Options::getQuestionId, titleVo.getId()));
|
||||
@ -55,10 +60,39 @@ public class TitleServiceImpl implements ITitleService {
|
||||
* 查询题目列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<TitleVo> queryPageList(TitleBo bo, PageQuery pageQuery) {
|
||||
public TableDataInfo<TitleResp> queryPageList(TitleBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<Title> lqw = buildQueryWrapper(bo);
|
||||
Page<TitleVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
// 获取标签id,获取选项id
|
||||
List<TitleVo> records = result.getRecords();
|
||||
List<Long> labels = records.stream().map(TitleVo::getLabelId).collect(Collectors.toList());
|
||||
List<LabelsVo> labelsVos = labelsMapper.selectVoBatchIds(labels);
|
||||
Map<Long, List<LabelsVo>> labelsVoMap = labelsVos.stream().collect(Collectors.groupingBy(LabelsVo::getId));
|
||||
List<Long> recordIds = records.stream().map(TitleVo::getId).collect(Collectors.toList());
|
||||
|
||||
List<OptionVo> optionVos = optionMapper.selectVoList(new LambdaQueryWrapper<Options>()
|
||||
.in(Options::getQuestionId, recordIds));
|
||||
|
||||
Map<Long, List<OptionVo>> optionsMap = optionVos.stream().collect(Collectors.groupingBy(OptionVo::getQuestionId));
|
||||
|
||||
List<TitleResp> resp = records.stream().map(p -> {
|
||||
TitleResp dto = new TitleResp();
|
||||
dto.setId(p.getId());
|
||||
dto.setQuestion(p.getQuestion());
|
||||
List<LabelsVo> labelsVos1 = labelsVoMap.get(p.getLabelId());
|
||||
dto.setLabelName(labelsVos1.get(0).getLabel());
|
||||
List<OptionVo> optionVos1 = optionsMap.get(p.getId());
|
||||
dto.setOptionVoList(optionVos1);
|
||||
return dto;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
Page<TitleResp> respPage = new Page<>();
|
||||
respPage.setRecords(resp);
|
||||
respPage.setCurrent(pageQuery.getPageNum());
|
||||
respPage.setTotal(result.getTotal());
|
||||
respPage.setSize(result.getSize());
|
||||
|
||||
return TableDataInfo.build(respPage);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -104,7 +138,7 @@ public class TitleServiceImpl implements ITitleService {
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(Title entity){
|
||||
private void validEntityBeforeSave(Title entity) {
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
@ -113,7 +147,7 @@ public class TitleServiceImpl implements ITitleService {
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
if (isValid) {
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user