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
23e6f41941
commit
f4ab05bd74
@ -6,6 +6,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.*;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import org.dromara.question.domain.bo.TitleReq;
|
||||
import org.dromara.question.domain.bo.TitleResp;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -76,7 +77,7 @@ public class TitleController extends BaseController {
|
||||
@Log(title = "题目", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody TitleBo bo) {
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody TitleReq bo) {
|
||||
return toAjax(titleService.insertByBo(bo));
|
||||
}
|
||||
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
package org.dromara.question.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author : lvxudong
|
||||
@ -15,16 +15,15 @@ import java.io.Serial;
|
||||
* @description :
|
||||
**/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("f_options")
|
||||
public class Options extends BaseEntity {
|
||||
public class Options {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId(value = "id")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
@ -40,5 +39,17 @@ public class Options extends BaseEntity {
|
||||
/**
|
||||
* 选项内容
|
||||
*/
|
||||
private Long optionContent;
|
||||
private String optionContent;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private Date updateTime;
|
||||
}
|
||||
|
||||
@ -1,11 +1,9 @@
|
||||
package org.dromara.question.domain;
|
||||
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 题目对象 f_questions
|
||||
@ -14,17 +12,13 @@ import java.io.Serial;
|
||||
* @date 2023-11-08
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("f_questions")
|
||||
public class Title extends BaseEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
public class Title {
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
@TableId(value = "id")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
@ -37,5 +31,17 @@ public class Title extends BaseEntity {
|
||||
*/
|
||||
private Long labelId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private Date updateTime;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
package org.dromara.question.domain.bo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author : lvxudong
|
||||
* @date : 2023/11/10 16:44
|
||||
* @className : OptionBo
|
||||
* @description :
|
||||
**/
|
||||
@Data
|
||||
public class OptionBo implements Serializable {
|
||||
/**
|
||||
* 选项序号
|
||||
*/
|
||||
private Integer serial;
|
||||
|
||||
/**
|
||||
* 题目id
|
||||
*/
|
||||
private Long questionId;
|
||||
|
||||
/**
|
||||
* 选项内容
|
||||
*/
|
||||
private String optionContent;
|
||||
}
|
||||
@ -1,13 +1,12 @@
|
||||
package org.dromara.question.domain.bo;
|
||||
|
||||
import org.dromara.question.domain.Title;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import jakarta.validation.constraints.*;
|
||||
import org.dromara.question.domain.Title;
|
||||
|
||||
/**
|
||||
* 题目业务对象 f_questions
|
||||
@ -16,12 +15,11 @@ import jakarta.validation.constraints.*;
|
||||
* @date 2023-11-08
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@AutoMapper(target = Title.class, reverseConvertGenerate = false)
|
||||
public class TitleBo extends BaseEntity {
|
||||
public class TitleBo {
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
@NotNull(message = "不能为空", groups = { EditGroup.class })
|
||||
private Long id;
|
||||
|
||||
@ -0,0 +1,40 @@
|
||||
package org.dromara.question.domain.bo;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.question.domain.vo.OptionVo;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author : lvxudong
|
||||
* @date : 2023/11/10 16:41
|
||||
* @className : TitleReq
|
||||
* @description :
|
||||
**/
|
||||
@Data
|
||||
public class TitleReq implements Serializable {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@NotNull(message = "不能为空", groups = { EditGroup.class })
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 题目
|
||||
*/
|
||||
@NotBlank(message = "题目不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String question;
|
||||
|
||||
/**
|
||||
* 题目标签类型
|
||||
*/
|
||||
@NotNull(message = "题目标签类型不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Long labelId;
|
||||
|
||||
List<OptionVo> optionList;
|
||||
}
|
||||
@ -1,10 +1,9 @@
|
||||
package org.dromara.question.domain.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import org.dromara.question.domain.Title;
|
||||
import org.dromara.question.domain.Options;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@ -16,7 +15,7 @@ import java.io.Serializable;
|
||||
**/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@AutoMapper(target = Title.class)
|
||||
@AutoMapper(target = Options.class)
|
||||
public class OptionVo implements Serializable {
|
||||
|
||||
/**
|
||||
@ -37,5 +36,5 @@ public class OptionVo implements Serializable {
|
||||
/**
|
||||
* 选项内容
|
||||
*/
|
||||
private Long optionContent;
|
||||
private String optionContent;
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package org.dromara.question.service;
|
||||
|
||||
import org.dromara.question.domain.Title;
|
||||
import org.dromara.question.domain.bo.TitleReq;
|
||||
import org.dromara.question.domain.bo.TitleResp;
|
||||
import org.dromara.question.domain.vo.TitleVo;
|
||||
import org.dromara.question.domain.bo.TitleBo;
|
||||
@ -36,7 +37,7 @@ public interface ITitleService {
|
||||
/**
|
||||
* 新增题目
|
||||
*/
|
||||
Boolean insertByBo(TitleBo bo);
|
||||
Boolean insertByBo(TitleReq bo);
|
||||
|
||||
/**
|
||||
* 修改题目
|
||||
|
||||
@ -4,13 +4,16 @@ 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.exception.ServiceException;
|
||||
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.Title;
|
||||
import org.dromara.question.domain.bo.OptionBo;
|
||||
import org.dromara.question.domain.bo.TitleBo;
|
||||
import org.dromara.question.domain.bo.TitleReq;
|
||||
import org.dromara.question.domain.bo.TitleResp;
|
||||
import org.dromara.question.domain.vo.LabelsVo;
|
||||
import org.dromara.question.domain.vo.OptionVo;
|
||||
@ -19,8 +22,11 @@ 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.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.rmi.server.ServerCloneException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -115,13 +121,24 @@ public class TitleServiceImpl implements ITitleService {
|
||||
* 新增题目
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(TitleBo bo) {
|
||||
Title add = MapstructUtils.convert(bo, Title.class);
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean insertByBo(TitleReq bo) {
|
||||
TitleBo titleBo = new TitleBo();
|
||||
BeanUtils.copyProperties(bo, titleBo);
|
||||
Title add = MapstructUtils.convert(titleBo, Title.class);
|
||||
if (add == null) {
|
||||
throw new ServiceException("数据获取失败");
|
||||
}
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
}
|
||||
|
||||
List<OptionVo> optionList = bo.getOptionList();
|
||||
optionList.forEach(option -> option.setQuestionId(bo.getId()));
|
||||
List<Options> options = MapstructUtils.convert(optionList, Options.class);
|
||||
optionMapper.insertBatch(options);
|
||||
return flag;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user