wucl 2 anni fa
parent
commit
b0d0bbc444

+ 19 - 30
.idea/workspace.xml

@@ -5,37 +5,14 @@
   </component>
   <component name="ChangeListManager">
     <list default="true" id="298c0123-5a38-45f2-a872-7d3a74d33353" name="Changes" comment="">
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/utils/Tree.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/utils/TreeUtil.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/vo/ChildrenParentName.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/vo/MergeTableVO.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/vo/MergeVO.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/vo/QuestionTreeVO.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/resources/mapper/QuestionMapper.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/main/java/com/dayou/controller/DocumentController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dayou/controller/DocumentController.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/controller/ConfigurationController.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/entity/Configuration.java" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/src/main/java/com/dayou/controller/QuestionAnalysisController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dayou/controller/QuestionAnalysisController.java" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/main/java/com/dayou/controller/QuestionController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dayou/controller/QuestionController.java" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/main/java/com/dayou/dao/DocumentMapper.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dayou/dao/DocumentMapper.java" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/main/java/com/dayou/dao/QuestionAnalysisMapper.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dayou/dao/QuestionAnalysisMapper.java" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/main/java/com/dayou/dao/QuestionMapper.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dayou/dao/QuestionMapper.java" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/main/java/com/dayou/dto/DocumentDTO.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dayou/dto/DocumentDTO.java" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/main/java/com/dayou/entity/Document.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dayou/entity/Document.java" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/main/java/com/dayou/entity/Question.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dayou/entity/Question.java" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/main/java/com/dayou/service/IDocumentService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dayou/service/IDocumentService.java" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/main/java/com/dayou/service/IQuestionAnalysisService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dayou/service/IQuestionAnalysisService.java" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/main/java/com/dayou/service/IQuestionService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dayou/service/IQuestionService.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/dayou/dao/DocumentQuestionMapper.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dayou/dao/ConfigurationMapper.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/dayou/interceptor/LoginInterceptor.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dayou/interceptor/LoginInterceptor.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/dayou/service/IDocumentQuestionService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dayou/service/IConfigurationService.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/dayou/service/impl/DocumentQuestionServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dayou/service/impl/ConfigurationServiceImpl.java" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/src/main/java/com/dayou/service/impl/DocumentServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dayou/service/impl/DocumentServiceImpl.java" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/main/java/com/dayou/service/impl/ProfessorResultServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dayou/service/impl/ProfessorResultServiceImpl.java" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/main/java/com/dayou/service/impl/QuestionAnalysisServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dayou/service/impl/QuestionAnalysisServiceImpl.java" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/main/java/com/dayou/service/impl/QuestionServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dayou/service/impl/QuestionServiceImpl.java" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/main/java/com/dayou/vo/AnalysisResultVO.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dayou/vo/AnalysisResultVO.java" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/main/java/com/dayou/vo/CycleVO.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dayou/vo/CycleVO.java" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/main/java/com/dayou/vo/DocumentCycleVO.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dayou/vo/DocumentCycleVO.java" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/main/java/com/dayou/vo/DocumentVO.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dayou/vo/DocumentVO.java" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/main/java/com/dayou/vo/ProfessorResultVO.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dayou/vo/ProfessorResultVO.java" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/main/resources/mapper/AnalysisResultMapper.xml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/mapper/AnalysisResultMapper.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/main/resources/mapper/CycleMapper.xml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/mapper/CycleMapper.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/main/resources/mapper/DocumentMapper.xml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/mapper/DocumentMapper.xml" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/src/main/resources/mapper/ProfessorResultMapper.xml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/mapper/ProfessorResultMapper.xml" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
@@ -148,7 +125,8 @@
       <workItem from="1690246915477" duration="13083000" />
       <workItem from="1690331871855" duration="13059000" />
       <workItem from="1690420437727" duration="9737000" />
-      <workItem from="1690504907314" duration="14387000" />
+      <workItem from="1690504907314" duration="14920000" />
+      <workItem from="1690764120436" duration="8074000" />
     </task>
     <servers />
   </component>
@@ -166,4 +144,15 @@
       </map>
     </option>
   </component>
+  <component name="XDebuggerManager">
+    <breakpoint-manager>
+      <breakpoints>
+        <line-breakpoint enabled="true" type="java-line">
+          <url>file://$PROJECT_DIR$/src/main/java/com/dayou/service/impl/DocumentServiceImpl.java</url>
+          <line>54</line>
+          <option name="timeStamp" value="5" />
+        </line-breakpoint>
+      </breakpoints>
+    </breakpoint-manager>
+  </component>
 </project>

+ 40 - 0
src/main/java/com/dayou/controller/ConfigurationController.java

@@ -0,0 +1,40 @@
+package com.dayou.controller;
+
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.dayou.configuration.BaseEntity;
+import com.dayou.configuration.RestResponse;
+import com.dayou.entity.Configuration;
+import com.dayou.service.IConfigurationService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * 类说明:
+ *
+ * @author: wucl
+ * @since: 2023/7/31
+ * created with IntelliJ IDEA.
+ */
+@RestController
+@RequestMapping("/configuration")
+@Slf4j
+public class ConfigurationController {
+
+    @Autowired
+    private IConfigurationService configurationService;
+
+    @GetMapping("/{key}")
+    public RestResponse<Configuration> getValueByKey(@PathVariable("key") String key){
+        Configuration configuration = configurationService.getOne(new LambdaQueryWrapper<Configuration>()
+                .eq(StrUtil.isNotBlank(key), Configuration::getName, key).eq(BaseEntity::getDeleted, Boolean.FALSE));
+        return RestResponse.data(configuration);
+    }
+
+    @PutMapping()
+    public RestResponse<Boolean> updateById(@RequestBody Configuration configuration){
+        boolean b = configurationService.updateById(configuration);
+        return RestResponse.data(b);
+    }
+}

+ 1 - 0
src/main/java/com/dayou/controller/QuestionAnalysisController.java

@@ -43,6 +43,7 @@ public class QuestionAnalysisController {
         return RestResponse.data(list);
     }
 
+    @IgnoreAuth
     @GetMapping("/merge")
     public RestResponse<MergeVO> getMergeData(){
         MergeVO mergeVO = questionAnalysisService.getMergeData();

+ 2 - 1
src/main/java/com/dayou/dao/DocumentQuestionMapper.java

@@ -1,6 +1,7 @@
 package com.dayou.dao;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.dayou.entity.Configuration;
 import com.dayou.entity.DocumentQuestion;
 
 /**
@@ -10,5 +11,5 @@ import com.dayou.entity.DocumentQuestion;
  * @since: 2023/7/20
  * created with IntelliJ IDEA.
  */
-public interface DocumentQuestionMapper extends BaseMapper<DocumentQuestion> {
+public interface ConfigurationMapper extends BaseMapper<Configuration> {
 }

+ 19 - 0
src/main/java/com/dayou/entity/Configuration.java

@@ -0,0 +1,19 @@
+package com.dayou.entity;
+
+import com.dayou.configuration.BaseEntity;
+import lombok.Data;
+
+/**
+ * 类说明:
+ *
+ * @author: wucl
+ * @since: 2023/7/31
+ * created with IntelliJ IDEA.
+ */
+@Data
+public class Configuration extends BaseEntity {
+
+    private String name;
+
+    private String value;
+}

+ 4 - 0
src/main/java/com/dayou/interceptor/LoginInterceptor.java

@@ -43,6 +43,9 @@ public class LoginInterceptor implements HandlerInterceptor {
     public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
         Boolean ignore = checkIgnore(handler);
 
+        if (ignore){
+            return true;
+        }
         String token = request.getHeader(JwtConstants.REST_TOKEN);
 
         if (StrUtil.isBlank(token)){
@@ -52,6 +55,7 @@ public class LoginInterceptor implements HandlerInterceptor {
             ErrorCode.throwBusinessException(ErrorCode.UN_LOGIN);
         }
 
+
         User user = null;
 
         try {

+ 2 - 2
src/main/java/com/dayou/service/IDocumentQuestionService.java

@@ -1,7 +1,7 @@
 package com.dayou.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
-import com.dayou.entity.DocumentQuestion;
+import com.dayou.entity.Configuration;
 
 /**
  * 类说明:
@@ -10,5 +10,5 @@ import com.dayou.entity.DocumentQuestion;
  * @since: 2023/7/20
  * created with IntelliJ IDEA.
  */
-public interface IDocumentQuestionService extends IService<DocumentQuestion> {
+public interface IConfigurationService extends IService<Configuration> {
 }

+ 18 - 0
src/main/java/com/dayou/service/impl/ConfigurationServiceImpl.java

@@ -0,0 +1,18 @@
+package com.dayou.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.dayou.dao.ConfigurationMapper;
+import com.dayou.entity.Configuration;
+import com.dayou.service.IConfigurationService;
+import org.springframework.stereotype.Service;
+
+/**
+ * 类说明:
+ *
+ * @author: wucl
+ * @since: 2023/7/20
+ * created with IntelliJ IDEA.
+ */
+@Service
+public class ConfigurationServiceImpl extends ServiceImpl<ConfigurationMapper, Configuration> implements IConfigurationService {
+}

+ 0 - 18
src/main/java/com/dayou/service/impl/DocumentQuestionServiceImpl.java

@@ -1,18 +0,0 @@
-package com.dayou.service.impl;
-
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.dayou.dao.DocumentQuestionMapper;
-import com.dayou.entity.DocumentQuestion;
-import com.dayou.service.IDocumentQuestionService;
-import org.springframework.stereotype.Service;
-
-/**
- * 类说明:
- *
- * @author: wucl
- * @since: 2023/7/20
- * created with IntelliJ IDEA.
- */
-@Service
-public class DocumentQuestionServiceImpl extends ServiceImpl<DocumentQuestionMapper, DocumentQuestion> implements IDocumentQuestionService {
-}

+ 13 - 8
src/main/java/com/dayou/service/impl/DocumentServiceImpl.java

@@ -9,10 +9,11 @@ import com.dayou.configuration.BaseEntity;
 import com.dayou.dao.DocumentMapper;
 import com.dayou.dao.QuestionMapper;
 import com.dayou.dto.DocumentDTO;
+import com.dayou.entity.Configuration;
 import com.dayou.entity.Document;
 import com.dayou.entity.DocumentQuestion;
 import com.dayou.entity.Question;
-import com.dayou.service.IDocumentQuestionService;
+import com.dayou.service.IConfigurationService;
 import com.dayou.service.IDocumentService;
 import com.dayou.service.IQuestionService;
 import com.dayou.utils.ConvertUtil;
@@ -22,14 +23,12 @@ import com.dayou.vo.DocumentVO;
 import com.dayou.vo.QuestionTreeVO;
 import com.google.common.collect.Lists;
 import org.apache.commons.collections.CollectionUtils;
+import org.checkerframework.checker.units.qual.K;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -46,20 +45,26 @@ public class DocumentServiceImpl extends ServiceImpl<DocumentMapper, Document> i
     private DocumentMapper documentMapper;
 
     @Autowired
-    private IQuestionService questionService;
+    private QuestionMapper questionMapper;
 
     @Autowired
-    private QuestionMapper questionMapper;
+    private IConfigurationService configurationService;
 
     @Override
     public DocumentCycleVO getDocumentCycleVO() {
+        Configuration mini = configurationService.getOne(new LambdaQueryWrapper<Configuration>().eq(Configuration::getName, "mini").eq(BaseEntity::getDeleted, Boolean.FALSE));
+        if ("false".equals(mini.getValue())){
+            return new DocumentCycleVO();
+        }
         DocumentCycleVO documentCycleVO = documentMapper.getDocumentCycleVO();
         List<List<Question>> results = new ArrayList<>();
         Long typeId = documentCycleVO.getTypeId();
         List<Question> children = Lists.newArrayList();
         children = findChildren(typeId, children);
+        Map<Long,List<Question>> result = new LinkedHashMap<>();
         Map<Long, List<Question>> collect = children.stream().collect(Collectors.groupingBy(Question::getParentId));
-        for(Map.Entry<Long,List<Question>> map :collect.entrySet()){
+        collect.entrySet().stream().sorted(Map.Entry.comparingByKey()).forEachOrdered(e->result.put(e.getKey(),e.getValue()));
+        for(Map.Entry<Long,List<Question>> map :result.entrySet()){
             results.add(map.getValue());
         }
         documentCycleVO.setQuestions(results);

+ 1 - 1
src/main/resources/mapper/ProfessorResultMapper.xml

@@ -56,7 +56,7 @@
             t.document_id
         FROM
             professor_result pr
-                RIGHT JOIN ( SELECT id, document_id, cycle_name FROM cycle where id = 5 ) t ON t.id = pr.cycle_id
+                RIGHT JOIN ( SELECT id, document_id, cycle_name FROM cycle where id = #{id} ) t ON t.id = pr.cycle_id
                 LEFT JOIN question q ON q.id = pr.question_id
                 LEFT JOIN document d ON d.id = t.document_id
         where pr.deleted = 0