资源管理-课程配制 课程列表 新增课程 客观题管理-新增题目 指导入 接口定义
parent
f84503b07d
commit
ec45764eb7
@ -0,0 +1,23 @@
|
||||
package com.tz.platform.common.core.enmus;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum QuestionTypeEnum {
|
||||
//单选
|
||||
SINGLE(1,"单选"),
|
||||
//多选
|
||||
MULTY(2,"多选"),
|
||||
//判断
|
||||
JUDGE(3,"判断");
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private Integer code;
|
||||
/**
|
||||
* 类型名
|
||||
*/
|
||||
private String desc;
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package com.tz.platform.common.core.vo;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Answer {
|
||||
private Integer id;
|
||||
private String title;
|
||||
private String img;
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>exam</artifactId>
|
||||
<groupId>com.tz</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>exam-feign</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.tz</groupId>
|
||||
<artifactId>common-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -0,0 +1,43 @@
|
||||
package com.tz.platform.feign.exam;
|
||||
|
||||
import com.tz.platform.feign.exam.vo.QuestionVo;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@FeignClient(value = "tz-exam-service")
|
||||
public interface IFeignExam {
|
||||
@GetMapping(value = "/feign/exam/question/{id}")
|
||||
QuestionVo getQuestionById(@PathVariable(value = "id") Long id);
|
||||
|
||||
@GetMapping(value = "/feign/exam/question/list/{pageNo}")
|
||||
List<QuestionVo> listQuestion(@PathVariable(value = "pageNo") Long pageNo);
|
||||
|
||||
@PostMapping(value = "/feign/exam/question/update")
|
||||
int updateQuestion(@RequestBody QuestionVo questionVo);
|
||||
|
||||
@PostMapping(value = "/feign/exam/quest/save")
|
||||
int saveQuestion(@RequestBody QuestionVo questionVo);
|
||||
|
||||
@GetMapping(value = "/feign/exam/question/delete/{id}")
|
||||
int deleteQuestion(@PathVariable( value = "id") Long id);
|
||||
|
||||
@PostMapping(value = "/feign/exam/quest/batchInsert")
|
||||
int batchQuestionInsert(@RequestBody List<QuestionVo> list);
|
||||
|
||||
@PostMapping(value = "/feign/exam/question/batchOff")
|
||||
int batchQuestionOff(@RequestBody List<Integer> ids);
|
||||
|
||||
@PostMapping(value = "/feign/exam/question/batchUp")
|
||||
int batchQuestionUp(@RequestBody List<Integer> ids);
|
||||
|
||||
@GetMapping(value = "/feign/exam/question/off/{id}")
|
||||
int questionOff(@PathVariable(value = "id") Long id);
|
||||
|
||||
@GetMapping(value = "/feign/exam/question/up/{id}")
|
||||
int questionUp(@PathVariable(value = "id") Long id);
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.tz.platform.feign.exam.qo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.tz.platform.common.core.vo.Answer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class QuestionQO {
|
||||
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,23 @@
|
||||
package com.tz.platform.feign.exam.vo;
|
||||
|
||||
import com.tz.platform.common.core.vo.Answer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class QuestionVo {
|
||||
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,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>exam</artifactId>
|
||||
<groupId>com.tz</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>exam-service</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.tz</groupId>
|
||||
<artifactId>common-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.tz</groupId>
|
||||
<artifactId>common-service</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.tz</groupId>
|
||||
<artifactId>exam-feign</artifactId>
|
||||
</dependency>
|
||||
<!-- test -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -0,0 +1,15 @@
|
||||
package com.tz.platform;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableDiscoveryClient
|
||||
@EnableFeignClients
|
||||
public class ExamApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ExamApplication.class,args);
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
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 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 CouseCat couseCat;
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.tz.platform.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
public class CourseTag {
|
||||
@Id
|
||||
@GeneratedValue(strategy= GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
private String name;
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.tz.platform.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
public class CouseCat {
|
||||
@Id
|
||||
@GeneratedValue(strategy= GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
private String name;
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package com.tz.platform.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.tz.platform.common.core.vo.Answer;
|
||||
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.util.List;
|
||||
|
||||
@Entity
|
||||
@Table(name = "question",indexes = {@Index(columnList = "title,type")})
|
||||
@Data
|
||||
@TypeDef(name = "json", typeClass = JsonStringType.class)
|
||||
public class Question {
|
||||
@Id
|
||||
@GeneratedValue(strategy= GenerationType.IDENTITY)
|
||||
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;
|
||||
@Column(columnDefinition = "text")
|
||||
private String stem;
|
||||
private String stemImg;
|
||||
private Long creatorId;
|
||||
@Type(type = "json")
|
||||
@Column(columnDefinition = "json" )
|
||||
List<Answer> answerList;
|
||||
@Column( columnDefinition = "text")
|
||||
private String analysis;
|
||||
@Type(type = "json")
|
||||
@Column(columnDefinition = "json")
|
||||
@JsonIgnore
|
||||
private List<Integer> answerId;
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package com.tz.platform.exam.feign;
|
||||
|
||||
import com.tz.platform.common.core.base.BaseController;
|
||||
import com.tz.platform.exam.feign.biz.FeignExamBiz;
|
||||
import com.tz.platform.feign.exam.IFeignExam;
|
||||
import com.tz.platform.feign.exam.vo.QuestionVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
@RestController
|
||||
public class FeignExamController extends BaseController implements IFeignExam {
|
||||
|
||||
@Autowired
|
||||
private FeignExamBiz feignExamBiz;
|
||||
|
||||
@Override
|
||||
public QuestionVo getQuestionById(Long id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<QuestionVo> listQuestion(Long pageNo) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateQuestion(QuestionVo questionVo) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int saveQuestion(QuestionVo questionVo) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteQuestion(Long id) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchQuestionInsert(List<QuestionVo> list) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchQuestionOff(List<Integer> ids) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchQuestionUp(List<Integer> ids) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int questionOff(Long id) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int questionUp(Long id) {
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.tz.platform.exam.feign.biz;
|
||||
|
||||
import com.tz.platform.repository.QuestionDao;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class FeignExamBiz {
|
||||
@Autowired
|
||||
private QuestionDao questionDao;
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package com.tz.platform.repository;
|
||||
|
||||
import com.tz.platform.entity.Course;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface CourseDao extends JpaRepository<Course,Long> {
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package com.tz.platform.repository;
|
||||
|
||||
import com.tz.platform.entity.CourseTag;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface CourseTagDao extends JpaRepository<CourseTag,Long> {
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package com.tz.platform.repository;
|
||||
|
||||
import com.tz.platform.entity.CourseTag;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface CousreCatDao extends JpaRepository<CourseTag,Long> {
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package com.tz.platform.repository;
|
||||
|
||||
import com.tz.platform.entity.Question;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface QuestionDao extends JpaRepository<Question,Long> {
|
||||
Question getById(Long id);
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
server:
|
||||
port: 50013
|
||||
spring:
|
||||
application:
|
||||
name: tz-exam-service
|
||||
profiles:
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
server-addr: 127.0.0.1:8848
|
||||
username: nacos
|
||||
password: nacos
|
||||
config:
|
||||
namespace: ${spring.profiles.active}
|
||||
file-extension: yaml
|
||||
discovery:
|
||||
namespace: ${spring.profiles.active}
|
@ -0,0 +1,43 @@
|
||||
package com.tz.platform.repository;
|
||||
|
||||
import com.tz.platform.common.core.vo.Answer;
|
||||
import com.tz.platform.entity.Question;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@SpringBootTest
|
||||
public class QuestionDaoTest {
|
||||
@Autowired
|
||||
private QuestionDao questionDao;
|
||||
|
||||
@Test
|
||||
public void questionSaveTest(){
|
||||
Question question = new Question();
|
||||
question.setAnalysis("ffefadsf");
|
||||
question.setLevelId(1L);
|
||||
question.setTitle("测试题");
|
||||
question.setLevelName("本科");
|
||||
question.setQuestionType(1L);
|
||||
question.setScore(3L);
|
||||
question.setStem("天是什么颜色");
|
||||
List<Answer> answerList = new ArrayList<>();
|
||||
Answer answer = new Answer();
|
||||
answer.setId(1);
|
||||
answer.setTitle("黑色");
|
||||
answerList.add(answer);
|
||||
question.setAnswerList(answerList);
|
||||
List<Integer> ids = answerList.stream().map(answer1 -> answer.getId()).collect(Collectors.toList());
|
||||
question.setAnswerId(ids);
|
||||
questionDao.save(question);
|
||||
}
|
||||
@Test
|
||||
public void questionGetTest(){
|
||||
Question question = questionDao.getById(1L);
|
||||
System.out.println(question.getAnswerList().size());
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>platform</artifactId>
|
||||
<groupId>com.tz</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>exam</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>exam-feign</module>
|
||||
<module>exam-service</module>
|
||||
</modules>
|
||||
|
||||
|
||||
</project>
|
@ -0,0 +1,8 @@
|
||||
package com.tz.platform.system.feign;
|
||||
|
||||
import com.tz.platform.common.core.base.BaseController;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
public class FeignSystemMenuController extends BaseController {
|
||||
}
|
Loading…
Reference in New Issue