diff --git a/tz/common/common-core/src/main/java/com/tz/platform/common/core/enmus/QuestionTypeEnum.java b/tz/common/common-core/src/main/java/com/tz/platform/common/core/enmus/QuestionTypeEnum.java new file mode 100644 index 0000000..d0fb0a6 --- /dev/null +++ b/tz/common/common-core/src/main/java/com/tz/platform/common/core/enmus/QuestionTypeEnum.java @@ -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; +} diff --git a/tz/common/common-core/src/main/java/com/tz/platform/common/core/enmus/RedisPreEnum.java b/tz/common/common-core/src/main/java/com/tz/platform/common/core/enmus/RedisPreEnum.java index d34241b..3fdd77b 100644 --- a/tz/common/common-core/src/main/java/com/tz/platform/common/core/enmus/RedisPreEnum.java +++ b/tz/common/common-core/src/main/java/com/tz/platform/common/core/enmus/RedisPreEnum.java @@ -7,6 +7,7 @@ import lombok.Getter; @AllArgsConstructor public enum RedisPreEnum { ADMINI_MENU("admini_menu_", "管理员菜单-admini_menu_"); + private String code; private String desc; diff --git a/tz/common/common-core/src/main/java/com/tz/platform/common/core/vo/Answer.java b/tz/common/common-core/src/main/java/com/tz/platform/common/core/vo/Answer.java new file mode 100644 index 0000000..7c91fd6 --- /dev/null +++ b/tz/common/common-core/src/main/java/com/tz/platform/common/core/vo/Answer.java @@ -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; +} diff --git a/tz/common/common-service/pom.xml b/tz/common/common-service/pom.xml index 305f09f..954a27e 100644 --- a/tz/common/common-service/pom.xml +++ b/tz/common/common-service/pom.xml @@ -82,6 +82,11 @@ org.springframework.boot spring-boot-starter-data-jpa + + com.vladmihalcea + hibernate-types-52 + 2.9.4 + org.springframework.boot diff --git a/tz/exam/exam-feign/pom.xml b/tz/exam/exam-feign/pom.xml new file mode 100644 index 0000000..6f91734 --- /dev/null +++ b/tz/exam/exam-feign/pom.xml @@ -0,0 +1,23 @@ + + + + exam + com.tz + 1.0-SNAPSHOT + + 4.0.0 + + exam-feign + + + com.tz + common-core + + + org.springframework.cloud + spring-cloud-starter-openfeign + + + \ No newline at end of file diff --git a/tz/exam/exam-feign/src/main/java/com/tz/platform/feign/exam/IFeignExam.java b/tz/exam/exam-feign/src/main/java/com/tz/platform/feign/exam/IFeignExam.java new file mode 100644 index 0000000..6572759 --- /dev/null +++ b/tz/exam/exam-feign/src/main/java/com/tz/platform/feign/exam/IFeignExam.java @@ -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 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 list); + + @PostMapping(value = "/feign/exam/question/batchOff") + int batchQuestionOff(@RequestBody List ids); + + @PostMapping(value = "/feign/exam/question/batchUp") + int batchQuestionUp(@RequestBody List 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); +} diff --git a/tz/exam/exam-feign/src/main/java/com/tz/platform/feign/exam/qo/QuestionQO.java b/tz/exam/exam-feign/src/main/java/com/tz/platform/feign/exam/qo/QuestionQO.java new file mode 100644 index 0000000..24d6c71 --- /dev/null +++ b/tz/exam/exam-feign/src/main/java/com/tz/platform/feign/exam/qo/QuestionQO.java @@ -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 answerList; + private String analysis; + private List answerId; +} diff --git a/tz/exam/exam-feign/src/main/java/com/tz/platform/feign/exam/vo/QuestionVo.java b/tz/exam/exam-feign/src/main/java/com/tz/platform/feign/exam/vo/QuestionVo.java new file mode 100644 index 0000000..c474250 --- /dev/null +++ b/tz/exam/exam-feign/src/main/java/com/tz/platform/feign/exam/vo/QuestionVo.java @@ -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 answerList; + private String analysis; + private List answerId; +} diff --git a/tz/exam/exam-service/pom.xml b/tz/exam/exam-service/pom.xml new file mode 100644 index 0000000..8192a1a --- /dev/null +++ b/tz/exam/exam-service/pom.xml @@ -0,0 +1,35 @@ + + + + exam + com.tz + 1.0-SNAPSHOT + + 4.0.0 + + exam-service + + + + com.tz + common-core + + + com.tz + common-service + + + com.tz + exam-feign + + + + org.springframework.boot + spring-boot-starter-test + test + + + + \ No newline at end of file diff --git a/tz/exam/exam-service/src/main/java/com/tz/platform/ExamApplication.java b/tz/exam/exam-service/src/main/java/com/tz/platform/ExamApplication.java new file mode 100644 index 0000000..dc82b9c --- /dev/null +++ b/tz/exam/exam-service/src/main/java/com/tz/platform/ExamApplication.java @@ -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); + } +} diff --git a/tz/exam/exam-service/src/main/java/com/tz/platform/entity/Course.java b/tz/exam/exam-service/src/main/java/com/tz/platform/entity/Course.java new file mode 100644 index 0000000..4424d91 --- /dev/null +++ b/tz/exam/exam-service/src/main/java/com/tz/platform/entity/Course.java @@ -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; + @Type(type = "json") + @Column(columnDefinition = "json" ) + private CouseCat couseCat; +} diff --git a/tz/exam/exam-service/src/main/java/com/tz/platform/entity/CourseTag.java b/tz/exam/exam-service/src/main/java/com/tz/platform/entity/CourseTag.java new file mode 100644 index 0000000..27ccab6 --- /dev/null +++ b/tz/exam/exam-service/src/main/java/com/tz/platform/entity/CourseTag.java @@ -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; +} diff --git a/tz/exam/exam-service/src/main/java/com/tz/platform/entity/CouseCat.java b/tz/exam/exam-service/src/main/java/com/tz/platform/entity/CouseCat.java new file mode 100644 index 0000000..2c7e75d --- /dev/null +++ b/tz/exam/exam-service/src/main/java/com/tz/platform/entity/CouseCat.java @@ -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; +} diff --git a/tz/exam/exam-service/src/main/java/com/tz/platform/entity/Question.java b/tz/exam/exam-service/src/main/java/com/tz/platform/entity/Question.java new file mode 100644 index 0000000..cbf823b --- /dev/null +++ b/tz/exam/exam-service/src/main/java/com/tz/platform/entity/Question.java @@ -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 answerList; + @Column( columnDefinition = "text") + private String analysis; + @Type(type = "json") + @Column(columnDefinition = "json") + @JsonIgnore + private List answerId; +} diff --git a/tz/exam/exam-service/src/main/java/com/tz/platform/exam/feign/FeignExamController.java b/tz/exam/exam-service/src/main/java/com/tz/platform/exam/feign/FeignExamController.java new file mode 100644 index 0000000..2818bfb --- /dev/null +++ b/tz/exam/exam-service/src/main/java/com/tz/platform/exam/feign/FeignExamController.java @@ -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 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 list) { + return 0; + } + + @Override + public int batchQuestionOff(List ids) { + return 0; + } + + @Override + public int batchQuestionUp(List ids) { + return 0; + } + + @Override + public int questionOff(Long id) { + return 0; + } + + @Override + public int questionUp(Long id) { + return 0; + } +} diff --git a/tz/exam/exam-service/src/main/java/com/tz/platform/exam/feign/biz/FeignExamBiz.java b/tz/exam/exam-service/src/main/java/com/tz/platform/exam/feign/biz/FeignExamBiz.java new file mode 100644 index 0000000..3d0ec03 --- /dev/null +++ b/tz/exam/exam-service/src/main/java/com/tz/platform/exam/feign/biz/FeignExamBiz.java @@ -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; + +} diff --git a/tz/exam/exam-service/src/main/java/com/tz/platform/repository/CourseDao.java b/tz/exam/exam-service/src/main/java/com/tz/platform/repository/CourseDao.java new file mode 100644 index 0000000..7308461 --- /dev/null +++ b/tz/exam/exam-service/src/main/java/com/tz/platform/repository/CourseDao.java @@ -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 { +} diff --git a/tz/exam/exam-service/src/main/java/com/tz/platform/repository/CourseTagDao.java b/tz/exam/exam-service/src/main/java/com/tz/platform/repository/CourseTagDao.java new file mode 100644 index 0000000..7e829fe --- /dev/null +++ b/tz/exam/exam-service/src/main/java/com/tz/platform/repository/CourseTagDao.java @@ -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 { +} diff --git a/tz/exam/exam-service/src/main/java/com/tz/platform/repository/CousreCatDao.java b/tz/exam/exam-service/src/main/java/com/tz/platform/repository/CousreCatDao.java new file mode 100644 index 0000000..6910e1d --- /dev/null +++ b/tz/exam/exam-service/src/main/java/com/tz/platform/repository/CousreCatDao.java @@ -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 { +} diff --git a/tz/exam/exam-service/src/main/java/com/tz/platform/repository/QuestionDao.java b/tz/exam/exam-service/src/main/java/com/tz/platform/repository/QuestionDao.java new file mode 100644 index 0000000..7783199 --- /dev/null +++ b/tz/exam/exam-service/src/main/java/com/tz/platform/repository/QuestionDao.java @@ -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 getById(Long id); +} diff --git a/tz/exam/exam-service/src/main/resources/bootstrap.yml b/tz/exam/exam-service/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..dc4e8ef --- /dev/null +++ b/tz/exam/exam-service/src/main/resources/bootstrap.yml @@ -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} diff --git a/tz/exam/exam-service/src/test/java/com/tz/platform/repository/QuestionDaoTest.java b/tz/exam/exam-service/src/test/java/com/tz/platform/repository/QuestionDaoTest.java new file mode 100644 index 0000000..3312ee4 --- /dev/null +++ b/tz/exam/exam-service/src/test/java/com/tz/platform/repository/QuestionDaoTest.java @@ -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 answerList = new ArrayList<>(); + Answer answer = new Answer(); + answer.setId(1); + answer.setTitle("黑色"); + answerList.add(answer); + question.setAnswerList(answerList); + List 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()); + } +} diff --git a/tz/exam/pom.xml b/tz/exam/pom.xml new file mode 100644 index 0000000..28df968 --- /dev/null +++ b/tz/exam/pom.xml @@ -0,0 +1,20 @@ + + + + platform + com.tz + 1.0-SNAPSHOT + + 4.0.0 + + exam + pom + + exam-feign + exam-service + + + + \ No newline at end of file diff --git a/tz/pom.xml b/tz/pom.xml index 98f9b7e..ddbbb4a 100644 --- a/tz/pom.xml +++ b/tz/pom.xml @@ -14,6 +14,7 @@ gateway competition system + exam @@ -66,6 +67,16 @@ user-feign ${project.version} + + com.tz + exam-feign + 1.0-SNAPSHOT + + + com.tz + system-feign + 1.0-SNAPSHOT + diff --git a/tz/system/system-service/pom.xml b/tz/system/system-service/pom.xml index 2b9cfff..9b87b74 100644 --- a/tz/system/system-service/pom.xml +++ b/tz/system/system-service/pom.xml @@ -24,5 +24,13 @@ com.tz user-feign + + com.tz + exam-feign + + + com.tz + system-feign + \ No newline at end of file diff --git a/tz/system/system-service/src/main/java/com/tz/platform/system/feign/FeignSystemMenuController.java b/tz/system/system-service/src/main/java/com/tz/platform/system/feign/FeignSystemMenuController.java new file mode 100644 index 0000000..35fc5ac --- /dev/null +++ b/tz/system/system-service/src/main/java/com/tz/platform/system/feign/FeignSystemMenuController.java @@ -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 { +} diff --git a/tz/user/user-feign/src/main/java/com/tz/platform/feign/user/IFeignUser.java b/tz/user/user-feign/src/main/java/com/tz/platform/feign/user/IFeignUser.java index 6cf1a9f..e7786f1 100644 --- a/tz/user/user-feign/src/main/java/com/tz/platform/feign/user/IFeignUser.java +++ b/tz/user/user-feign/src/main/java/com/tz/platform/feign/user/IFeignUser.java @@ -4,6 +4,10 @@ import com.tz.platform.feign.user.vo.UserVo; 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-user-service") public interface IFeignUser { @@ -12,4 +16,8 @@ public interface IFeignUser { UserVo getByUserNo(@PathVariable(value = "userNo") Long userNo); @GetMapping(value = "/feign/user/getByMobile/{mobile}") UserVo getByMobile(@PathVariable(value = "mobile") String mobile); + + @PostMapping(value = "feign/user/batchInsert") + int batchInser(@RequestBody List userVoList); + }