package hl.mhmscs.controller.admin;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import hl.mhmscs.importexport.ExcelTools;
import hl.mhmscs.importexport.QuestionListener;
import hl.mhmscs.importexport.UserListener;
import hl.mhmscs.pojo.dto.BasePageDto;
import hl.mhmscs.pojo.dto.QuestionPageDto;
import hl.mhmscs.pojo.entity.*;
import hl.mhmscs.pojo.vo.QuestionTitleIdAndNameVo;
import hl.mhmscs.service.QuestionAnswerService;
import hl.mhmscs.service.QuestionService;
import hl.mhmscs.service.QuestionTitleService;
import hl.mhmscs.service.QuestionTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import sun.java2d.pipe.SpanIterator;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
@Api(tags = "管理员-试题管理")
@RestController
@Component("adminQuestionController")
@RequestMapping("admin/question")
public class QuestionController {
@Autowired
private QuestionTypeService questionTypeService;
@Autowired
private QuestionTitleService questionTitleService;
@Autowired
private QuestionService questionService;
@Autowired
private QuestionAnswerService questionAnswerService;
@ApiOperation("获取试题类型")
@GetMapping("typeList")
public Result questionTypeList(){
return Result.success(this.questionTypeService.list());
}
@ApiOperation("修改试题类型")
@PostMapping("edit/questionType")
public Result editQuestionType(@RequestBody QuestionType questionType){
System.out.println("修改试题类型");
System.out.println(questionType);
return Result.success(this.questionTypeService.updateById(questionType));
}
@ApiOperation("添加试题类型")
@PostMapping("add/questionType")
public Result addQuestionType(@RequestBody QuestionType questionType){
System.out.println("添加试题类型");
System.out.println(questionType);
return Result.success(this.questionTypeService.save(questionType));
}
@ApiOperation("删除试题类型")
@DeleteMapping("delete/questionType/{id}")
public Result deleteQuestionType(@PathVariable Integer id){
System.out.println("删除试题类型");
System.out.println(id);
return Result.success(this.questionTypeService.removeById(id));
}
@ApiOperation("标题分页查询")
@PostMapping("/query/questionTitlePage")
public Result questionTitleQueryPage(@RequestBody BasePageDto basePageDto) {
System.out.println(basePageDto);
Page<QuestionTitle> page = new Page<>(basePageDto.getPageNum(),basePageDto.getPageSize());
Page<QuestionTitle> page1 = questionTitleService.page(page, new LambdaQueryWrapper<QuestionTitle>()
.eq(!StringUtils.isEmpty(basePageDto.getId()),QuestionTitle::getId,basePageDto.getId())
.like(!StringUtils.isEmpty(basePageDto.getName()),QuestionTitle::getName,basePageDto.getName()));
return Result.success(page1);
}
/**
* 按主键删除
* @param id
* @return
*/
@ApiOperation("按主键删除标题")
@DeleteMapping("/delete/questionTitle/{id}")
public Result deleteQuestionTitle(@PathVariable Integer id){
System.out.println("按主键删除标题");
this.questionTitleService.removeById(id);
return Result.success("删除成功",id);
}
/**
* 批量删除
* @param ids
* @return
*/
@ApiOperation("批量删除标题")
@DeleteMapping("/delete/questionTitle/ids")
public Result deleteByIds(@RequestBody String[] ids) {
System.out.println("批量删除数据");
Arrays.stream(ids).forEach(s-> System.out.println(s));
this.questionTitleService.removeByIds(Arrays.asList(ids));
return new Result(true,"操作成功",ids);
}
@ApiOperation("修改标题类型")
@PostMapping("edit/questionTitle")
public Result editQuestionTitle(@RequestBody QuestionTitle questionTitle){
System.out.println("修改标题类型");
System.out.println(questionTitle);
return Result.success(this.questionTitleService.updateById(questionTitle));
}
@ApiOperation("添加试题类型")
@PostMapping("add/questionTitle")
public Result addQuestionTitle(@RequestBody QuestionTitle questionTitle){
System.out.println("添加标题类型");
System.out.println(questionTitle);
return Result.success(this.questionTitleService.save(questionTitle));
}
@ApiOperation("获取标题名称集合")
@GetMapping("get/questionTitleIdAndName")
public Result questionTitleIdAndName(){
System.out.println("获取标题名称集合");
List<QuestionTitleIdAndNameVo> list = new ArrayList<>();
this.questionTitleService.list().stream().forEach(q->{
list.add(QuestionTitleIdAndNameVo
.builder()
.name(q.getName())
.titleId(q.getId())
.build());
});
return Result.success(list);
}
@ApiOperation("获取试题集合")
@PostMapping("/list")
public Result list(@RequestBody QuestionPageDto questionPageDto){
System.out.println("获取试题集合");
System.out.println(questionPageDto);
Page<Question> page = new Page<>(questionPageDto.getPageNum(),questionPageDto.getPageSize());
Page<Question> page1 = questionService.page(page, new LambdaQueryWrapper<Question>()
.eq(!StringUtils.isEmpty(questionPageDto.getId()),Question::getId,questionPageDto.getId())
.eq(!StringUtils.isEmpty(questionPageDto.getTitleId()),Question::getTitleId,questionPageDto.getTitleId())
.like(!StringUtils.isEmpty(questionPageDto.getName()),Question::getQuestionContent,questionPageDto.getName()));
return Result.success(page1);
}
@ApiOperation("添加试题")
@PostMapping("/add")
public Result addQuestion(@RequestBody Question question){
String modifyTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
question.setModifyTime(modifyTime);
System.out.println("添加试题");
System.out.println(question);
return Result.success(this.questionService.save(question));
}
@ApiOperation("修改试题")
@PostMapping("/edit")
public Result editQuestion(@RequestBody Question question){
String modifyTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
question.setModifyTime(modifyTime);
System.out.println("修改试题");
System.out.println(question);
return Result.success(this.questionService.updateById(question));
}
@ApiOperation("按主键删除试题")
@DeleteMapping("/delete/{id}")
public Result deleteByIdQuestion(@PathVariable Integer id){
System.out.println("删除试题");
this.questionService.removeById(id);
return Result.success("删除成功",id);
}
@ApiOperation("批量删除试题")
@DeleteMapping("/delete/ids")
public Result deleteByIdsQuestion(@RequestBody String[] ids) {
System.out.println("批量删除数据");
Arrays.stream(ids).forEach(s-> System.out.println(s));
this.questionService.removeByIds(Arrays.asList(ids));
return new Result(true,"操作成功",ids);
}
@ApiOperation("导入试题信息")
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
本项目是一款基于Java开发的心理健康监测系统源码,集成了多种编程语言和文件类型。包含1633个文件,其中Java源文件79个,JavaScript和TypeScript文件合计511个,微信小程序相关文件共计521个,以及Vue、CSS、HTML和其它相关文件。系统以简洁实用的设计理念,为用户提供心理健康监测服务。
资源推荐
资源详情
资源评论
收起资源包目录
基于Java的简单心理健康监测系统设计与实现源码 (1642个子文件)
style.css 47B
.gitignore 278B
.gitignore 253B
index.html 380B
QuestionController.java 10KB
UserController.java 6KB
AliyunOSSUtil.java 5KB
MhmscsApplicationTests.java 5KB
VideoController.java 5KB
MusicController.java 5KB
CounselorController.java 5KB
QuestionController.java 4KB
UserServiceImpl.java 4KB
SecurityConfig.java 3KB
UserController.java 3KB
AdminServiceImpl.java 3KB
AdminController.java 2KB
User.java 2KB
Demo.java 2KB
Result.java 2KB
WebMvcConfiguration.java 2KB
ExcelTools.java 2KB
CounselorController.java 1KB
QuestionServiceImpl.java 1KB
Question.java 1KB
QuestionListener.java 1KB
UserListener.java 1KB
QuestionAnswer.java 1KB
Counselor.java 1KB
Admin.java 1009B
QuestionTitleServiceImpl.java 906B
QuestionTitle.java 881B
Music.java 880B
UtilsController.java 856B
ModificationUserDto.java 850B
Video.java 848B
VideoController.java 836B
MybatisPlusConfig.java 825B
JwtUtils.java 799B
QuestionType.java 787B
MusicController.java 713B
UserService.java 710B
MusicServiceImpl.java 684B
CounselorPageDto.java 639B
VideoPageDto.java 633B
MusicPageDto.java 630B
BasePageDto.java 621B
AdminService.java 513B
QuestionVo2.java 506B
AdminTokenVo.java 456B
QuestionAnswerServiceImpl.java 450B
QuestionTypeServiceImpl.java 436B
UpdatePasswordDto.java 424B
CounselorServiceImpl.java 415B
VideoServiceImpl.java 387B
QuestionPageDto.java 383B
AddMusicDto.java 373B
QuestionAnswerVo.java 362B
UserPageDto.java 354B
RegisterDto.java 344B
QuestionVo.java 344B
LoginDto.java 342B
QuestionTitleIdAndNameVo.java 339B
MusicService.java 332B
QuestionService.java 326B
MhmscsApplication.java 314B
QuestionTitleService.java 290B
SaveAvatarDto.java 285B
AdminMapper.java 284B
VideoMapper.java 279B
QuestionResultVo.java 279B
MusicMapper.java 273B
QuestionAnswerMapper.java 267B
QuestionTitleMapper.java 263B
QuestionTypeMapper.java 259B
QuestionResultDto.java 252B
CounselorMapper.java 247B
QuestionMapper.java 244B
QuestionAnswerService.java 222B
QuestionTypeService.java 216B
CounselorService.java 207B
VideoService.java 195B
UserMapper.java 177B
index.js 13KB
index.js 13KB
index.js 12KB
index.js 12KB
index.js 12KB
index.js 12KB
index.js 12KB
index.js 10KB
index.js 10KB
index.js 9KB
index.js 9KB
index.js 8KB
index.js 8KB
index.js 8KB
index.js 8KB
index.js 8KB
index.js 8KB
共 1642 条
- 1
- 2
- 3
- 4
- 5
- 6
- 17
资源评论
lsx202406
- 粉丝: 2295
- 资源: 5554
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功