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
f4ab05bd74
commit
90bdf71982
@ -6,6 +6,7 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import jakarta.validation.constraints.*;
|
import jakarta.validation.constraints.*;
|
||||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
|
import org.dromara.question.domain.vo.LabelOptionVo;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||||
@ -45,6 +46,12 @@ public class LabelsController extends BaseController {
|
|||||||
return labelsService.queryPageList(bo, pageQuery);
|
return labelsService.queryPageList(bo, pageQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SaCheckPermission("question:label:list")
|
||||||
|
@GetMapping("queryLabels")
|
||||||
|
public R<List<LabelOptionVo>> queryLabels() {
|
||||||
|
return R.ok(labelsService.queryLabels());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出题目标签列表
|
* 导出题目标签列表
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -2,10 +2,7 @@ package org.dromara.question.domain;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
|
||||||
|
|
||||||
import java.io.Serial;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -17,7 +14,6 @@ import java.util.Date;
|
|||||||
@Data
|
@Data
|
||||||
@TableName("f_options")
|
@TableName("f_options")
|
||||||
public class Options {
|
public class Options {
|
||||||
@Serial
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -27,6 +27,7 @@ public class TitleResp implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 题目标签类型
|
* 题目标签类型
|
||||||
*/
|
*/
|
||||||
|
private Long labelId;
|
||||||
private String labelName;
|
private String labelName;
|
||||||
|
|
||||||
private List<OptionVo> optionVoList;
|
private List<OptionVo> optionVoList;
|
||||||
|
|||||||
@ -0,0 +1,17 @@
|
|||||||
|
package org.dromara.question.domain.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author : lvxudong
|
||||||
|
* @date : 2023/11/17 16:35
|
||||||
|
* @className : LabelOptionsVo
|
||||||
|
* @description :
|
||||||
|
**/
|
||||||
|
@Data
|
||||||
|
public class LabelOptionVo {
|
||||||
|
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
private String label;
|
||||||
|
}
|
||||||
@ -3,6 +3,7 @@ package org.dromara.question.service;
|
|||||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||||
import org.dromara.question.domain.bo.LabelsBo;
|
import org.dromara.question.domain.bo.LabelsBo;
|
||||||
|
import org.dromara.question.domain.vo.LabelOptionVo;
|
||||||
import org.dromara.question.domain.vo.LabelsVo;
|
import org.dromara.question.domain.vo.LabelsVo;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -42,6 +43,8 @@ public interface ILabelsService {
|
|||||||
Boolean updateByBo(LabelsBo bo);
|
Boolean updateByBo(LabelsBo bo);
|
||||||
Boolean updateStatusByBo(LabelsBo bo);
|
Boolean updateStatusByBo(LabelsBo bo);
|
||||||
|
|
||||||
|
List<LabelOptionVo> queryLabels();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验并批量删除题目标签信息
|
* 校验并批量删除题目标签信息
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
package org.dromara.question.service;
|
package org.dromara.question.service;
|
||||||
|
|
||||||
import org.dromara.question.domain.Title;
|
|
||||||
import org.dromara.question.domain.bo.TitleReq;
|
import org.dromara.question.domain.bo.TitleReq;
|
||||||
import org.dromara.question.domain.bo.TitleResp;
|
import org.dromara.question.domain.bo.TitleResp;
|
||||||
import org.dromara.question.domain.vo.TitleVo;
|
import org.dromara.question.domain.vo.TitleVo;
|
||||||
|
|||||||
@ -1,24 +1,28 @@
|
|||||||
package org.dromara.question.service.impl;
|
package org.dromara.question.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
||||||
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.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.dromara.common.core.exception.ServiceException;
|
||||||
import org.dromara.question.domain.bo.LabelsBo;
|
import org.dromara.common.core.utils.MapstructUtils;
|
||||||
import org.dromara.question.domain.vo.LabelsVo;
|
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.Labels;
|
import org.dromara.question.domain.Labels;
|
||||||
|
import org.dromara.question.domain.Title;
|
||||||
|
import org.dromara.question.domain.bo.LabelsBo;
|
||||||
|
import org.dromara.question.domain.vo.LabelOptionVo;
|
||||||
|
import org.dromara.question.domain.vo.LabelsVo;
|
||||||
|
import org.dromara.question.domain.vo.TitleVo;
|
||||||
import org.dromara.question.mapper.LabelsMapper;
|
import org.dromara.question.mapper.LabelsMapper;
|
||||||
|
import org.dromara.question.mapper.TitleMapper;
|
||||||
import org.dromara.question.service.ILabelsService;
|
import org.dromara.question.service.ILabelsService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 题目标签Service业务层处理
|
* 题目标签Service业务层处理
|
||||||
@ -32,11 +36,13 @@ public class LabelsServiceImpl implements ILabelsService {
|
|||||||
|
|
||||||
private final LabelsMapper baseMapper;
|
private final LabelsMapper baseMapper;
|
||||||
|
|
||||||
|
private final TitleMapper titleMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询题目标签
|
* 查询题目标签
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public LabelsVo queryById(Long id){
|
public LabelsVo queryById(Long id) {
|
||||||
return baseMapper.selectVoById(id);
|
return baseMapper.selectVoById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,6 +56,19 @@ public class LabelsServiceImpl implements ILabelsService {
|
|||||||
return TableDataInfo.build(result);
|
return TableDataInfo.build(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<LabelOptionVo> queryLabels() {
|
||||||
|
LambdaQueryWrapper<Labels> lqw = Wrappers.lambdaQuery();
|
||||||
|
lqw.eq(Labels::getStatus, 0);
|
||||||
|
List<LabelsVo> labelsVos = baseMapper.selectVoList(lqw);
|
||||||
|
return labelsVos.stream().map(p -> {
|
||||||
|
LabelOptionVo vo = new LabelOptionVo();
|
||||||
|
vo.setValue(p.getId().toString());
|
||||||
|
vo.setLabel(p.getLabel());
|
||||||
|
return vo;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询题目标签列表
|
* 查询题目标签列表
|
||||||
*/
|
*/
|
||||||
@ -92,6 +111,13 @@ public class LabelsServiceImpl implements ILabelsService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean updateStatusByBo(LabelsBo bo) {
|
public Boolean updateStatusByBo(LabelsBo bo) {
|
||||||
|
// 禁用标签时校验标签是否正在被使用
|
||||||
|
TitleVo titleVo = titleMapper.selectVoOne(new LambdaQueryWrapper<Title>()
|
||||||
|
.eq(Title::getLabelId, bo.getId()));
|
||||||
|
if (titleVo != null && bo.getStatus() == 1) {
|
||||||
|
throw new ServiceException("该标签已绑定题库,请先解绑再禁用");
|
||||||
|
}
|
||||||
|
|
||||||
Labels update = MapstructUtils.convert(bo, Labels.class);
|
Labels update = MapstructUtils.convert(bo, Labels.class);
|
||||||
validEntityBeforeSave(update);
|
validEntityBeforeSave(update);
|
||||||
return baseMapper.updateById(update) > 0;
|
return baseMapper.updateById(update) > 0;
|
||||||
@ -100,7 +126,7 @@ public class LabelsServiceImpl implements ILabelsService {
|
|||||||
/**
|
/**
|
||||||
* 保存前的数据校验
|
* 保存前的数据校验
|
||||||
*/
|
*/
|
||||||
private void validEntityBeforeSave(Labels entity){
|
private void validEntityBeforeSave(Labels entity) {
|
||||||
//TODO 做一些数据校验,如唯一约束
|
//TODO 做一些数据校验,如唯一约束
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,7 +135,7 @@ public class LabelsServiceImpl implements ILabelsService {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||||
if(isValid){
|
if (isValid) {
|
||||||
//TODO 做一些业务上的校验,判断是否需要校验
|
//TODO 做一些业务上的校验,判断是否需要校验
|
||||||
}
|
}
|
||||||
return baseMapper.deleteBatchIds(ids) > 0;
|
return baseMapper.deleteBatchIds(ids) > 0;
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package org.dromara.question.service.impl;
|
package org.dromara.question.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
@ -54,10 +55,15 @@ public class TitleServiceImpl implements ITitleService {
|
|||||||
@Override
|
@Override
|
||||||
public TitleResp queryById(Long id) {
|
public TitleResp queryById(Long id) {
|
||||||
TitleVo titleVo = baseMapper.selectVoById(id);
|
TitleVo titleVo = baseMapper.selectVoById(id);
|
||||||
|
LabelsVo labelsVo = labelsMapper.selectVoById(titleVo.getLabelId());
|
||||||
List<OptionVo> options = optionMapper.selectVoList(new LambdaQueryWrapper<Options>()
|
List<OptionVo> options = optionMapper.selectVoList(new LambdaQueryWrapper<Options>()
|
||||||
.eq(Options::getQuestionId, titleVo.getId()));
|
.eq(Options::getQuestionId, titleVo.getId()));
|
||||||
|
|
||||||
TitleResp resp = new TitleResp();
|
TitleResp resp = new TitleResp();
|
||||||
|
resp.setId(titleVo.getId());
|
||||||
|
resp.setQuestion(titleVo.getQuestion());
|
||||||
|
resp.setLabelName(labelsVo.getLabel());
|
||||||
|
resp.setLabelId(labelsVo.getId());
|
||||||
resp.setOptionVoList(options);
|
resp.setOptionVoList(options);
|
||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
@ -87,6 +93,7 @@ public class TitleServiceImpl implements ITitleService {
|
|||||||
dto.setQuestion(p.getQuestion());
|
dto.setQuestion(p.getQuestion());
|
||||||
List<LabelsVo> labelsVos1 = labelsVoMap.get(p.getLabelId());
|
List<LabelsVo> labelsVos1 = labelsVoMap.get(p.getLabelId());
|
||||||
dto.setLabelName(labelsVos1.get(0).getLabel());
|
dto.setLabelName(labelsVos1.get(0).getLabel());
|
||||||
|
dto.setLabelId(labelsVos1.get(0).getId());
|
||||||
List<OptionVo> optionVos1 = optionsMap.get(p.getId());
|
List<OptionVo> optionVos1 = optionsMap.get(p.getId());
|
||||||
dto.setOptionVoList(optionVos1);
|
dto.setOptionVoList(optionVos1);
|
||||||
return dto;
|
return dto;
|
||||||
@ -123,6 +130,10 @@ public class TitleServiceImpl implements ITitleService {
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Boolean insertByBo(TitleReq bo) {
|
public Boolean insertByBo(TitleReq bo) {
|
||||||
|
List<OptionVo> optionList = bo.getOptionList();
|
||||||
|
if (CollectionUtil.isEmpty(optionList)) {
|
||||||
|
throw new ServiceException("选项不能为空");
|
||||||
|
}
|
||||||
TitleBo titleBo = new TitleBo();
|
TitleBo titleBo = new TitleBo();
|
||||||
BeanUtils.copyProperties(bo, titleBo);
|
BeanUtils.copyProperties(bo, titleBo);
|
||||||
Title add = MapstructUtils.convert(titleBo, Title.class);
|
Title add = MapstructUtils.convert(titleBo, Title.class);
|
||||||
@ -135,7 +146,6 @@ public class TitleServiceImpl implements ITitleService {
|
|||||||
bo.setId(add.getId());
|
bo.setId(add.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
List<OptionVo> optionList = bo.getOptionList();
|
|
||||||
optionList.forEach(option -> option.setQuestionId(bo.getId()));
|
optionList.forEach(option -> option.setQuestionId(bo.getId()));
|
||||||
List<Options> options = MapstructUtils.convert(optionList, Options.class);
|
List<Options> options = MapstructUtils.convert(optionList, Options.class);
|
||||||
optionMapper.insertBatch(options);
|
optionMapper.insertBatch(options);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user