客观题 列表 新增 编辑 上下架 指量上下架 功能实现
parent
38ad4f9c1e
commit
a98e0ae083
@ -1,35 +1,26 @@
|
||||
package com.tz.platform.entity;
|
||||
|
||||
import com.vladmihalcea.hibernate.type.json.JsonStringType;
|
||||
import lombok.Data;
|
||||
import org.hibernate.annotations.Type;
|
||||
import org.hibernate.annotations.TypeDef;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
@Table(indexes = {@Index(columnList = "name")})
|
||||
@TypeDef(name = "json", typeClass = JsonStringType.class)
|
||||
public class Course implements Serializable {
|
||||
@Id
|
||||
@GeneratedValue(strategy= GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
private String name;
|
||||
private String type;
|
||||
private String creator;
|
||||
private Long createId;
|
||||
private Date createTime;
|
||||
private Integer learningCount;
|
||||
private String thumbnail;
|
||||
@Column(columnDefinition = "text")
|
||||
private String summary;
|
||||
@Type(type = "json")
|
||||
@Column(columnDefinition = "json" )
|
||||
private List<CourseTag> courseTag;
|
||||
@Type(type = "json")
|
||||
@Column(columnDefinition = "json" )
|
||||
private CourseCat couseCat;
|
||||
private String content;
|
||||
private Integer tagId;
|
||||
private Integer catId;
|
||||
}
|
||||
|
@ -1,18 +1,18 @@
|
||||
package com.tz.platform.exam.pc;
|
||||
package com.tz.platform.exam.feign;
|
||||
|
||||
import com.tz.platform.common.core.base.BaseController;
|
||||
import com.tz.platform.common.core.base.Result;
|
||||
import com.tz.platform.exam.pc.biz.PCQuestionBiz;
|
||||
import com.tz.platform.exam.pc.biz.FeignQuestionBiz;
|
||||
import com.tz.platform.exam.pc.dto.QuestionDTO;
|
||||
import com.tz.platform.feign.exam.vo.QuestionVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/pc/question")
|
||||
public class PCQuestionController extends BaseController {
|
||||
@RequestMapping(value = "/feign/question")
|
||||
public class FeignQuestionController extends BaseController {
|
||||
@Autowired
|
||||
private PCQuestionBiz pcQuestionBiz;
|
||||
private FeignQuestionBiz pcQuestionBiz;
|
||||
|
||||
@GetMapping(value = "list/{pageNo}")
|
||||
public Result<QuestionDTO> listQuestion(@PathVariable("pageNo") Integer pageNO){
|
@ -0,0 +1,48 @@
|
||||
package com.tz.platform.pc;
|
||||
|
||||
import com.tz.platform.common.core.base.BaseController;
|
||||
import com.tz.platform.common.core.base.Result;
|
||||
import com.tz.platform.pc.biz.PCCourseBiz;
|
||||
import com.tz.platform.pc.dto.CourseDTO;
|
||||
import com.tz.platform.pc.dto.PageCourseDTO;
|
||||
import com.tz.platform.pc.vo.CourseVO;
|
||||
import com.tz.platform.pc.vo.PageCourseVO;
|
||||
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;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/pc/course")
|
||||
public class PCCourseController extends BaseController {
|
||||
@Autowired
|
||||
private PCCourseBiz pcCourseBiz;
|
||||
|
||||
@PostMapping(value = "add")
|
||||
public Result<String> add(@RequestBody CourseVO courseVO){
|
||||
return pcCourseBiz.add(courseVO);
|
||||
}
|
||||
|
||||
@PostMapping(value = "update")
|
||||
public Result<String> update(@RequestBody CourseVO courseVO){
|
||||
return pcCourseBiz.update(courseVO);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping(value = "list")
|
||||
public Result<PageCourseDTO> list(@RequestBody PageCourseVO pageCourseVO){
|
||||
return pcCourseBiz.list(pageCourseVO);
|
||||
}
|
||||
|
||||
@PostMapping(value = "delete")
|
||||
public Result<String> del(@RequestBody CourseVO courseVO){
|
||||
return pcCourseBiz.del(courseVO);
|
||||
}
|
||||
|
||||
@PostMapping(value = "get")
|
||||
public Result<CourseDTO> get(@RequestBody CourseVO courseVO){
|
||||
return pcCourseBiz.get(courseVO.getId());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package com.tz.platform.pc;
|
||||
|
||||
import com.tz.platform.common.core.base.Result;
|
||||
import com.tz.platform.pc.biz.PCQuestionBiz;
|
||||
import com.tz.platform.pc.dto.PageQuestionDTO;
|
||||
import com.tz.platform.pc.dto.QuestionDTO;
|
||||
import com.tz.platform.pc.vo.BatchQuestionVO;
|
||||
import com.tz.platform.pc.vo.PageQuestionVO;
|
||||
import com.tz.platform.pc.vo.QuestionVO;
|
||||
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;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/pc/question")
|
||||
public class PCQuestionController {
|
||||
|
||||
@Autowired
|
||||
private PCQuestionBiz questionBiz;
|
||||
|
||||
@PostMapping(value = "list")
|
||||
public Result<PageQuestionDTO> list(@RequestBody PageQuestionVO questionVO){
|
||||
return questionBiz.list(questionVO);
|
||||
}
|
||||
|
||||
@PostMapping(value = "add")
|
||||
public Result<Long> add(@RequestBody QuestionVO questionVo){
|
||||
return questionBiz.add(questionVo);
|
||||
}
|
||||
|
||||
@PostMapping(value = "update")
|
||||
public Result<String> update(@RequestBody QuestionVO questionVo){
|
||||
return questionBiz.update(questionVo);
|
||||
}
|
||||
|
||||
@PostMapping(value = "delete")
|
||||
public Result<String> delete(@RequestBody QuestionVO questionVO){
|
||||
return questionBiz.delete(questionVO);
|
||||
}
|
||||
|
||||
@PostMapping(value = "get")
|
||||
public Result<QuestionDTO> get(@RequestBody QuestionVO questionVO){
|
||||
return questionBiz.get(questionVO);
|
||||
}
|
||||
|
||||
@PostMapping(value = "batchupdate")
|
||||
public Result<String> batchUpate(@RequestBody BatchQuestionVO vo){
|
||||
return questionBiz.batch(vo);
|
||||
}
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
package com.tz.platform.pc.biz;
|
||||
|
||||
import com.tz.platform.common.core.base.Result;
|
||||
import com.tz.platform.entity.Course;
|
||||
import com.tz.platform.feign.user.IFeignUser;
|
||||
import com.tz.platform.feign.user.vo.UserVo;
|
||||
import com.tz.platform.pc.dto.CourseDTO;
|
||||
import com.tz.platform.pc.dto.PageCourseDTO;
|
||||
import com.tz.platform.pc.vo.CourseVO;
|
||||
import com.tz.platform.pc.vo.PageCourseVO;
|
||||
import com.tz.platform.repository.CourseDao;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Component
|
||||
public class PCCourseBiz {
|
||||
@Autowired
|
||||
private CourseDao courseDao;
|
||||
|
||||
@Autowired
|
||||
private IFeignUser feignUser;
|
||||
|
||||
public Result<String> add(CourseVO courseVO){
|
||||
Result<String> v = valid(courseVO);
|
||||
if(v.getCode()!=200){
|
||||
return v;
|
||||
}
|
||||
UserVo userVo = feignUser.getByUserNo(courseVO.getUserNo());
|
||||
Course course = new Course();
|
||||
BeanUtils.copyProperties(courseVO,course);
|
||||
course.setCreateId(userVo.getId());
|
||||
course.setCreator(userVo.getName());
|
||||
course.setCreateTime(new Date());
|
||||
courseDao.save(course);
|
||||
return Result.success("成功");
|
||||
}
|
||||
|
||||
private Result<String> valid(CourseVO courseVO){
|
||||
if(StringUtils.isEmpty(courseVO.getName())){
|
||||
return Result.error("课程名不能为空");
|
||||
}
|
||||
if(StringUtils.isEmpty(courseVO.getContent())){
|
||||
return Result.error("简介不能为空");
|
||||
}
|
||||
if(courseVO.getUserNo()<=0){
|
||||
return Result.error("没有权限");
|
||||
}
|
||||
return Result.success("success");
|
||||
}
|
||||
|
||||
public Result<String> update(CourseVO courseVO){
|
||||
Result<String> v = valid(courseVO);
|
||||
if(v.getCode()!=200){
|
||||
return v;
|
||||
}
|
||||
Course course = new Course();
|
||||
BeanUtils.copyProperties(courseVO,course);
|
||||
courseDao.save(course);
|
||||
return Result.success("success");
|
||||
}
|
||||
|
||||
public Result<PageCourseDTO> list(PageCourseVO pageCourseVO){
|
||||
if(pageCourseVO.getPageNo()<0){
|
||||
pageCourseVO.setPageNo(0);
|
||||
}
|
||||
if(pageCourseVO.getPageSize() == null ||pageCourseVO.getPageSize() <=0){
|
||||
pageCourseVO.setPageSize(20);
|
||||
}
|
||||
Pageable pageable = PageRequest.of(pageCourseVO.getPageNo(),pageCourseVO.getPageSize());
|
||||
Page<Course> page = courseDao.findAll(pageable);
|
||||
PageCourseDTO pageCourseDTO = new PageCourseDTO();
|
||||
pageCourseDTO.setPage(page);
|
||||
return Result.success(pageCourseDTO);
|
||||
}
|
||||
|
||||
public Result<String> del(CourseVO courseVO){
|
||||
courseDao.deleteById(courseVO.getId());
|
||||
return Result.success("success");
|
||||
}
|
||||
|
||||
public Result<CourseDTO> get(Long id){
|
||||
Course course = courseDao.getById(id);
|
||||
CourseDTO courseDTO = new CourseDTO();
|
||||
BeanUtils.copyProperties(course,courseDTO);
|
||||
return Result.success(courseDTO);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.tz.platform.pc.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class CourseDTO implements Serializable {
|
||||
private Long id;
|
||||
private String name;
|
||||
private String creator;
|
||||
private Long createId;
|
||||
private Date createTime;
|
||||
private Integer learningCount;
|
||||
private String thumbnail;
|
||||
private String content;
|
||||
private Integer tagId;
|
||||
private Integer catId;
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.tz.platform.pc.dto;
|
||||
|
||||
import com.tz.platform.entity.Course;
|
||||
import lombok.Data;
|
||||
import org.springframework.data.domain.Page;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class PageCourseDTO implements Serializable {
|
||||
Page<Course> page;
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.tz.platform.pc.dto;
|
||||
|
||||
import com.tz.platform.entity.Question;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.springframework.data.domain.Page;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class PageQuestionDTO implements Serializable {
|
||||
private Page<Question> page;
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.tz.platform.pc.dto;
|
||||
|
||||
import com.tz.platform.common.core.vo.Answer;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class QuestionDTO implements Serializable {
|
||||
private Long userNO;
|
||||
private Long id;
|
||||
private Long courseId;
|
||||
private String courseName;
|
||||
private Long levelId;
|
||||
private String levelName;
|
||||
private Long questionType;
|
||||
private String title;
|
||||
private Long score;
|
||||
private Integer type;
|
||||
private String stem;
|
||||
private String stemImg;
|
||||
private Long creatorId;
|
||||
List<Answer> answerList;
|
||||
private String analysis;
|
||||
private List<Integer> answerId;
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package com.tz.platform.pc.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class BatchQuestionVO {
|
||||
private List<Long> ids;
|
||||
private Integer status;
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.tz.platform.pc.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
@Data
|
||||
public class CourseVO {
|
||||
private Long id;
|
||||
private Long userNo;
|
||||
private String name;
|
||||
private String creator;
|
||||
private Long createId;
|
||||
private Date createTime;
|
||||
private Integer learningCount;
|
||||
private String thumbnail;
|
||||
private String content;
|
||||
private Integer tagId;
|
||||
private Integer catId;
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package com.tz.platform.pc.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PageCourseVO {
|
||||
private Long userNo;
|
||||
private Integer pageNo;
|
||||
private Integer pageSize;
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package com.tz.platform.pc.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PageQuestionVO {
|
||||
private Integer pageNo;
|
||||
private Long courseId;
|
||||
private String stem;
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.tz.platform.pc.vo;
|
||||
|
||||
import com.tz.platform.common.core.vo.Answer;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class QuestionVO {
|
||||
private Long userNO;
|
||||
private Long id;
|
||||
private Long courseId;
|
||||
private String courseName;
|
||||
private Long levelId;
|
||||
private String levelName;
|
||||
private Long questionType;
|
||||
private String title;
|
||||
private Long score;
|
||||
private Integer type;
|
||||
private String stem;
|
||||
private String stemImg;
|
||||
private Long creatorId;
|
||||
List<Answer> answerList;
|
||||
private String analysis;
|
||||
private Integer status;
|
||||
private List<Integer> answerId;
|
||||
}
|
@ -1,9 +1,14 @@
|
||||
package com.tz.platform.repository;
|
||||
|
||||
import com.tz.platform.entity.Course;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
|
||||
@Repository
|
||||
public interface CourseDao extends JpaRepository<Course,Long> {
|
||||
Page<Course> findAll(Pageable pageable);
|
||||
Course getById(Long id);
|
||||
}
|
||||
|
@ -0,0 +1,39 @@
|
||||
package com.tz.platform.system.pc;
|
||||
|
||||
import com.tz.platform.common.core.base.Result;
|
||||
import com.tz.platform.system.pc.biz.PCStudentLevelBiz;
|
||||
import com.tz.platform.system.pc.dto.ListStudentLevelDTO;
|
||||
import com.tz.platform.system.pc.vo.StudentLevelVO;
|
||||
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;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/pc/system/level")
|
||||
public class PCStudentLevelController {
|
||||
|
||||
@Autowired
|
||||
private PCStudentLevelBiz pcStudentLevelBiz;
|
||||
|
||||
@RequestMapping(value = "list")
|
||||
public Result<ListStudentLevelDTO> list(){
|
||||
return pcStudentLevelBiz.list();
|
||||
}
|
||||
|
||||
@PostMapping(value = "add")
|
||||
public Result<Integer> add(@RequestBody StudentLevelVO studentLevelVO){
|
||||
return pcStudentLevelBiz.save(studentLevelVO);
|
||||
}
|
||||
|
||||
@PostMapping(value = "update")
|
||||
public Result<String> update(@RequestBody StudentLevelVO studentLevelVO){
|
||||
return pcStudentLevelBiz.update(studentLevelVO);
|
||||
}
|
||||
|
||||
@PostMapping(value = "delete")
|
||||
public Result<String> delete(@RequestBody StudentLevelVO studentLevelVO){
|
||||
return pcStudentLevelBiz.delete(studentLevelVO);
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package com.tz.platform.system.pc.biz;
|
||||
|
||||
import com.tz.platform.common.core.base.Result;
|
||||
import com.tz.platform.entity.StudentLevel;
|
||||
import com.tz.platform.repository.StudentLevelDao;
|
||||
import com.tz.platform.system.pc.dto.ListStudentLevelDTO;
|
||||
import com.tz.platform.system.pc.vo.StudentLevelVO;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class PCStudentLevelBiz {
|
||||
@Autowired
|
||||
private StudentLevelDao studentLevelDao;
|
||||
|
||||
public Result<ListStudentLevelDTO> list(){
|
||||
ListStudentLevelDTO studentLevelDTO = new ListStudentLevelDTO();
|
||||
List<StudentLevel> studentLevels = studentLevelDao.findAll();
|
||||
studentLevelDTO.setList(studentLevels);
|
||||
return Result.success(studentLevelDTO);
|
||||
}
|
||||
|
||||
public Result<Integer> save( StudentLevelVO studentLevelVO){
|
||||
if(StringUtils.isEmpty(studentLevelVO.getName())){
|
||||
return Result.error("层次名不能为空");
|
||||
}
|
||||
StudentLevel studentLevel = new StudentLevel();
|
||||
BeanUtils.copyProperties(studentLevelVO,studentLevel);
|
||||
studentLevel = studentLevelDao.save(studentLevel);
|
||||
return Result.success(studentLevel.getId());
|
||||
}
|
||||
|
||||
public Result<String> update(StudentLevelVO studentLevelVO){
|
||||
Result<Integer> rs= save(studentLevelVO);
|
||||
if(rs.getCode()== 200){
|
||||
return Result.success("success");
|
||||
}
|
||||
return Result.error(rs.getMsg());
|
||||
}
|
||||
|
||||
public Result<String> delete(StudentLevelVO studentLevelVO){
|
||||
studentLevelDao.deleteById(studentLevelVO.getId());
|
||||
return Result.success("success");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.tz.platform.system.pc.dto;
|
||||
|
||||
import com.tz.platform.entity.StudentLevel;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ListStudentLevelDTO implements Serializable {
|
||||
List<StudentLevel> list;
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package com.tz.platform.system.pc.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class StudentLevelDTO implements Serializable {
|
||||
private Integer id;
|
||||
private String name;
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package com.tz.platform.system.pc.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class StudentLevelVO {
|
||||
private Integer id;
|
||||
private String name;
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.tz.platform.repository;
|
||||
|
||||
import com.tz.platform.entity.StudentLevel;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
public class StudentLevelRepositoryTest {
|
||||
@Autowired
|
||||
private StudentLevelDao studentLevelDao;
|
||||
|
||||
@Test
|
||||
public void addLevelTest(){
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue