parent
c0f08da047
commit
3b2f45600d
22 changed files with 547 additions and 43 deletions
@ -0,0 +1,84 @@ |
||||
package cn.soul2.demo.controller; |
||||
|
||||
import cn.soul2.demo.dto.QnSubjectRefItemDTO; |
||||
import cn.soul2.demo.dto.SubjectDTO; |
||||
import cn.soul2.demo.dto.base.UpdateStatusDTO; |
||||
import cn.soul2.demo.entity.SubjectItemsDO; |
||||
import cn.soul2.demo.entity.sqlresult.SubjectChooseListDO; |
||||
import cn.soul2.demo.repository.IRefSubjectItemsRepository; |
||||
import cn.soul2.demo.repository.ISubjectItemsRepository; |
||||
import cn.soul2.demo.repository.ISubjectRepository; |
||||
import cn.soul2.demo.utils.base.BackUtils; |
||||
import cn.soul2.demo.vo.SubjectItemVO; |
||||
import cn.soul2.demo.vo.SubjectVO; |
||||
import cn.soul2.demo.vo.base.Back; |
||||
import cn.soul2.demo.vo.base.VPage; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.beans.BeanUtils; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.PostMapping; |
||||
import org.springframework.web.bind.annotation.RequestBody; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import java.util.Collection; |
||||
import java.util.List; |
||||
import java.util.stream.Collectors; |
||||
|
||||
/** |
||||
* @author Soul2 |
||||
* @date 2024-03-14 17:36 |
||||
*/ |
||||
|
||||
@Slf4j |
||||
@RestController |
||||
@RequestMapping("/subject") |
||||
public class SubjectController { |
||||
|
||||
@Autowired |
||||
private ISubjectRepository subjectRepository; |
||||
|
||||
@Autowired |
||||
private ISubjectItemsRepository itemsRepository; |
||||
|
||||
@Autowired |
||||
private IRefSubjectItemsRepository refSubjectItemsRepository; |
||||
|
||||
@PostMapping("saveOrUpdate") |
||||
public Back<Boolean> saveOrUpdate(@RequestBody SubjectDTO dto) { |
||||
return BackUtils.success(subjectRepository.saveOrUpdate(dto)); |
||||
} |
||||
|
||||
@PostMapping("page") |
||||
public Back<VPage<SubjectVO>> page(@RequestBody SubjectDTO dto) { |
||||
return BackUtils.success(subjectRepository.page(dto)); |
||||
} |
||||
|
||||
@PostMapping("remove") |
||||
public Back<Boolean> remove(Collection<String> ids) { |
||||
return BackUtils.success(subjectRepository.removeAndItems(ids)); |
||||
} |
||||
|
||||
@PostMapping("status") |
||||
public Back<Boolean> status(@RequestBody UpdateStatusDTO dto) { |
||||
return BackUtils.success(subjectRepository.status(dto)); |
||||
} |
||||
|
||||
@PostMapping("items") |
||||
public Back<SubjectVO> item(@RequestBody SubjectDTO dto) { |
||||
SubjectVO vo = new SubjectVO(); |
||||
BeanUtils.copyProperties(dto, vo); |
||||
List<SubjectItemsDO> items = itemsRepository.listBySubjectId(dto.getId()); |
||||
return BackUtils.success(vo.setItems(items.stream().map(o -> { |
||||
SubjectItemVO itemVo = new SubjectItemVO(); |
||||
BeanUtils.copyProperties(o, itemVo); |
||||
return itemVo; |
||||
}).collect(Collectors.toList()))); |
||||
} |
||||
|
||||
@PostMapping("chooseList") |
||||
public Back<VPage<SubjectChooseListDO>> chooseList(@RequestBody QnSubjectRefItemDTO dto) { |
||||
return BackUtils.success(subjectRepository.chooseList(dto)); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,52 @@ |
||||
package cn.soul2.demo.dto; |
||||
|
||||
import cn.soul2.demo.dto.base.PageParams; |
||||
import lombok.Data; |
||||
import lombok.experimental.Accessors; |
||||
|
||||
/** |
||||
* @author Soul2 |
||||
* @date 2024-03-16 19:20 |
||||
*/ |
||||
|
||||
@Data |
||||
@Accessors(chain = true) |
||||
public class QnSubjectRefItemDTO extends PageParams { |
||||
|
||||
/** |
||||
* 问题Id |
||||
*/ |
||||
private String subjectId; |
||||
|
||||
/** |
||||
* 问卷id |
||||
*/ |
||||
private String qnId; |
||||
|
||||
/** |
||||
* 题目标题 |
||||
*/ |
||||
private String title; |
||||
|
||||
/** |
||||
* 题目内容 |
||||
*/ |
||||
private String content; |
||||
|
||||
/** |
||||
* 排列序号 |
||||
*/ |
||||
private Short sort; |
||||
|
||||
|
||||
/** |
||||
* 题目类型:0-单选;1-多选;2-文字 |
||||
*/ |
||||
private Short type; |
||||
|
||||
/** |
||||
* 已选中 |
||||
*/ |
||||
private Boolean selected; |
||||
|
||||
} |
@ -0,0 +1,24 @@ |
||||
package cn.soul2.demo.entity.sqlresult; |
||||
|
||||
import lombok.Data; |
||||
import lombok.experimental.Accessors; |
||||
|
||||
/** |
||||
* @author Soul2 |
||||
* @date 2024-03-16 15:04 |
||||
*/ |
||||
|
||||
@Data |
||||
@Accessors(chain = true) |
||||
public class RefQuestionnaireSubjectUseCountDO { |
||||
|
||||
/** |
||||
* 题目id |
||||
*/ |
||||
private String subjectId; |
||||
|
||||
/** |
||||
* 被问卷使用的次数 |
||||
*/ |
||||
private Integer useCount; |
||||
} |
@ -0,0 +1,50 @@ |
||||
package cn.soul2.demo.entity.sqlresult; |
||||
|
||||
import lombok.Data; |
||||
import lombok.experimental.Accessors; |
||||
|
||||
/** |
||||
* @author Soul2 |
||||
* @date 2024-03-16 13:22 |
||||
*/ |
||||
|
||||
@Data |
||||
@Accessors(chain = true) |
||||
public class SubjectChooseListDO { |
||||
|
||||
/** |
||||
* id |
||||
*/ |
||||
private String id; |
||||
|
||||
/** |
||||
* 题目标题 |
||||
*/ |
||||
private String title; |
||||
|
||||
/** |
||||
* 题目内容 |
||||
*/ |
||||
private String content; |
||||
|
||||
/** |
||||
* 排列序号 |
||||
*/ |
||||
private Short sort; |
||||
|
||||
/** |
||||
* 题目类型:0-单选;1-多选;2-文字 |
||||
*/ |
||||
private Short type; |
||||
|
||||
/** |
||||
* 被问卷使用的次数 |
||||
*/ |
||||
private Integer useCount; |
||||
|
||||
/** |
||||
* 已选中 |
||||
*/ |
||||
private Integer selected; |
||||
|
||||
} |
Loading…
Reference in new issue