Explorar el Código

各角色显示内容优化

shenhao hace 3 años
padre
commit
3c1af0c6e4

+ 1 - 1
src/main/java/com/aijia/kmt/mapper/KmtExerciseMapper.java

@@ -72,7 +72,7 @@ public interface KmtExerciseMapper {
     List<ExerciseQuetionDto> findQuestionByBookCourseIdAndUserIdNew(
             @Param("req") ExerciseQuestionsRequest req,
             @Param("userId") String userId,
-            Page page,@Param("type") int type,@Param("searchType") int searchType);
+            Page page,@Param("type") int type,@Param("searchType") int searchType,@Param("roleType") int roleType);
 
     List<ExerciseQuetionDto> findAllQuestionByGradeDetail(@Param("req") Map<String, Object> req,  Page page);
 

+ 27 - 28
src/main/java/com/aijia/kmt/service/impl/KmtExerciseQuestionListServiceImpl.java

@@ -49,34 +49,26 @@ public class KmtExerciseQuestionListServiceImpl implements KmtExerciseQuestionLi
     public ResponseEntity findQuestionList (String userId, ExerciseQuestionsRequest request,int type) {
         TrTrainPartUser user = userServiceMapper.selectById(userId);
         String paramUserId = user.getManagerType()==1?request.getUserId():userId;
+
+        TrTrainPartUser partUser = userServiceMapper.selectById(paramUserId);
+        int roleType = partUser.getRoleType();
+        //管理员
+        if(partUser.getManagerType() == 1){
+            roleType = 0;
+        }
+
+
         ResponseEntity responseEntity = new ResponseEntity();
         Map<String, Object> data = new HashMap<>();
         Page page = new Page(request.getPageNo(), request.getPageSize());
-        List<ExerciseQuetionDto> questions = null;
-//        if (StringUtils.isNotBlank(request.getPeriodId())){
+
             if (StringUtil.isNotBlank(request.getQuestionId())){
                 //搜索题目id
-               //questions = kmtExerciseMapper.findExerciseQuestionByQuestionIdAndBookId(request.getQuestionId().trim(), request.getExerciseBookId());
                 page = new Page(1, 10, 1);
             }
-            questions = kmtExerciseMapper.findQuestionByBookCourseIdAndUserIdNew(request, paramUserId, page,user.getManagerType(), type);
-//        } else if (request.getExerciseBookId().startsWith("book_")) {
-//            //选择全部
-//            String[] param = request.getExerciseBookId().split("_");
-//            Map<String, Object> params = new HashMap<>();
-//            params.put("grade", param[1]);
-//            params.put("subject", param[2]);
-//            params.put("versionType", Integer.parseInt(param[3]));
-//            params.put("semester", Integer.parseInt(param[4]));
-//            params.put("questionType", request.getQuestionType());
-//            params.put("publishStatus", request.getPublishStatus());
-//            params.put("rollbackType", request.getRollbackType());
-//            questions = kmtExerciseMapper.findQuestionByBookCourseIdAndUserIdNew(request,userId, page);
-//        }
+        List<ExerciseQuetionDto> questions  = kmtExerciseMapper.findQuestionByBookCourseIdAndUserIdNew(request, paramUserId, page,user.getManagerType(), type,roleType);
         //管理员看到的题目列表是两层级, 老师看到的列表是一层级
-        List<QuestionListV1Dto> list = null;
-        //加工页面必显示大题,统一成两层级,如果大题目是二次查询出来的,设置为不可加工
-        list = changeDbQuestion(questions,true,paramUserId); //默认两层级的结构
+        List<QuestionListV1Dto> list = changeDbQuestion(questions,true,paramUserId,type); //默认两层级的结构
         data.put("list", list);
         data.put("pageNo", page.getCurrent());
         data.put("pageSize", page.getSize());
@@ -90,7 +82,7 @@ public class KmtExerciseQuestionListServiceImpl implements KmtExerciseQuestionLi
      * 把数据库结构的题目转成前端反参的形式
      * @param questions
      */
-    private List<QuestionListV1Dto> changeDbQuestion (List<ExerciseQuetionDto> questions, boolean isTwoLevel,String userId) {
+    private List<QuestionListV1Dto> changeDbQuestion (List<ExerciseQuetionDto> questions, boolean isTwoLevel,String userId,int type) {
         List<QuestionListV1Dto> list = new ArrayList<>();
         if (CollectionUtils.isNotEmpty(questions)){
             this.appendQuestionDtoDataFromJSONFile(questions,userId);
@@ -99,7 +91,7 @@ public class KmtExerciseQuestionListServiceImpl implements KmtExerciseQuestionLi
                     q.setQuestion("<img src='" + PropertiesUtil.getValue("STATIC_FILE_URL") + q.getQuestionImage() + "'/>");
                 }
             }
-            list = this.getQuestionGroupList(questions, isTwoLevel,userId);
+            list = this.getQuestionGroupList(questions, isTwoLevel,userId,type);
         }
         return list;
     }
@@ -128,16 +120,16 @@ public class KmtExerciseQuestionListServiceImpl implements KmtExerciseQuestionLi
                         kmtExerciseQuestion.setQuestionText(check && StringUtil.isNotBlank(userExercise.getQuestionText())?userExercise.getQuestionText():jsonObject.getString("question_text"));
                         kmtExerciseQuestion.setAnswer(check && StringUtil.isNotBlank(userExercise.getAnswer())?userExercise.getAnswer():jsonObject.getString("option_answer"));
                         kmtExerciseQuestion.setAnswerJson(check && StringUtil.isNotBlank(userExercise.getAnswerJson())?userExercise.getAnswerJson():jsonObject.getString("answer_json"));
-                        kmtExerciseQuestion.setQuestionAnalysis(check && StringUtil.isNotBlank(userExercise.getAnalysis())?userExercise.getAnalysis():jsonObject.getString("analysis"));
-                        kmtExerciseQuestion.setAnalysisJson(check && StringUtil.isNotBlank(userExercise.getAnalysisJson())?userExercise.getAnalysisJson():jsonObject.getString("analysis_json"));;
+//                        kmtExerciseQuestion.setQuestionAnalysis(check && StringUtil.isNotBlank(userExercise.getAnalysis())?userExercise.getAnalysis():jsonObject.getString("analysis"));
+//                        kmtExerciseQuestion.setAnalysisJson(check && StringUtil.isNotBlank(userExercise.getAnalysisJson())?userExercise.getAnalysisJson():jsonObject.getString("analysis_json"));
                         kmtExerciseQuestion.setOriginAnswer(check && StringUtil.isNotBlank(userExercise.getAnswerText())?userExercise.getAnswerText():jsonObject.getString("question_answer"));
                     }else{
                         kmtExerciseQuestion.setQuestion(check && StringUtil.isNotBlank(userExercise.getQuestion())?userExercise.getQuestion():"");
                         kmtExerciseQuestion.setQuestionText(check && StringUtil.isNotBlank(userExercise.getQuestionText())?userExercise.getQuestionText():"");
                         kmtExerciseQuestion.setAnswer(check && StringUtil.isNotBlank(userExercise.getAnswer())?userExercise.getAnswer():"");
                         kmtExerciseQuestion.setAnswerJson(check && StringUtil.isNotBlank(userExercise.getAnswerJson())?userExercise.getAnswerJson():"");
-                        kmtExerciseQuestion.setQuestionAnalysis(check && StringUtil.isNotBlank(userExercise.getAnalysis())?userExercise.getAnalysis():"");
-                        kmtExerciseQuestion.setAnalysisJson(check && StringUtil.isNotBlank(userExercise.getAnalysisJson())?userExercise.getAnalysisJson():"");;
+//                        kmtExerciseQuestion.setQuestionAnalysis(check && StringUtil.isNotBlank(userExercise.getAnalysis())?userExercise.getAnalysis():"");
+//                        kmtExerciseQuestion.setAnalysisJson(check && StringUtil.isNotBlank(userExercise.getAnalysisJson())?userExercise.getAnalysisJson():"");
                         kmtExerciseQuestion.setOriginAnswer(check && StringUtil.isNotBlank(userExercise.getAnswerText())?userExercise.getAnswerText():"");
                     }
                 }
@@ -199,10 +191,17 @@ public class KmtExerciseQuestionListServiceImpl implements KmtExerciseQuestionLi
      * @param isTwoLevel 是否是两层级
      * @return
      */
-    public List<QuestionListV1Dto> getQuestionGroupList (List<ExerciseQuetionDto> list, boolean isTwoLevel,String userId){
+    public List<QuestionListV1Dto> getQuestionGroupList (List<ExerciseQuetionDto> list, boolean isTwoLevel,String userId,int type){
         List<QuestionListV1Dto> result = new ArrayList<>();
         if (CollectionUtils.isNotEmpty(list)){
             List<String> questionIds = list.stream().map(ExerciseQuetionDto::getQuestionId).collect(Collectors.toList());
+
+            if(type == 1){
+                TrTrainPartUser user = userServiceMapper.selectById(userId);
+                if(user.getRoleType()==1){
+                    return result;
+                }
+            }
             List<QuestionListKnowModel> questionKnows = kmtExerciseMapper.findQuestionKnowByQuestionIds(questionIds,userId);
             List<TbLibManager> users = getDealUsers(list);
 
@@ -234,7 +233,7 @@ public class KmtExerciseQuestionListServiceImpl implements KmtExerciseQuestionLi
         //设置打回人和被打回人
         setFromUserAndToUser(tar, exerciseDto);
         //设置加工审核人
-        appendQuestionDealUser(users, tar, exerciseDto);
+//        appendQuestionDealUser(users, tar, exerciseDto);
         //状态
         tar.setQuestionStatus(this.getQuestionStatus(exerciseDto.getQuestionStatus()));
         //设置一致的字段

+ 48 - 17
src/main/resources/mybatis/mapper/KmtExerciseMapper.xml

@@ -1070,19 +1070,40 @@
 
     <!--查询题目的知识点-->
     <select id="findQuestionKnowByQuestionIds" resultType="com.aijia.kmt.dto.QuestionListKnowModel">
-        select eqk.question_id, hds.id how_details_id, hds.alias detail_name, hdks.id how_details_kd_id, hdks.alias kd_name,
-        hds.grade, hds.course_name, hds.type version_type, hds.semester, khd.is_zt module_type, hs.alias how_name, hds.num, hdks.num
-        from tr_train_user_question_know eqk
-        left join zyb_know_how_details_sort hds on eqk.how_detail_sort_id=hds.id
-        left join zyb_know_how_details_sort hs on hds.how_id=hs.how_id and hds.type=hs.type and hds.semester=hs.semester and hds.grade=hs.grade and hs.stat=1
-        left join zyb_know_how_details_sort hdks on eqk.how_detail_kd_sort_id=hdks.id
-        left join zyb_know_how_details khd on hds.how_details_id=khd.id
-        where question_id in
-        <foreach collection="questionIds" item="id" index="index" open="(" close=")" separator=",">
-            #{id}
-        </foreach>
-        and eqk.user_id = #{userId}
-        order by eqk.question_id, hds.num, hdks.num
+        SELECT * from (
+            select eqk.question_id, hds.id how_details_id, hds.alias detail_name, hdks.id how_details_kd_id, hdks.alias
+            kd_name,
+            hds.grade, hds.course_name, hds.type version_type, hds.semester, khd.is_zt module_type, hs.alias how_name,
+            hds.num, hdks.num
+            from tr_train_user_question_know eqk
+            left join zyb_know_how_details_sort hds on eqk.how_detail_sort_id=hds.id
+            left join zyb_know_how_details_sort hs on hds.how_id=hs.how_id and hds.type=hs.type and hds.semester=hs.semester
+            and hds.grade=hs.grade and hs.stat=1
+            left join zyb_know_how_details_sort hdks on eqk.how_detail_kd_sort_id=hdks.id
+            left join zyb_know_how_details khd on hds.how_details_id=khd.id
+            where question_id in
+            <foreach collection="questionIds" item="id" index="index" open="(" close=")" separator=",">
+                #{id}
+            </foreach>
+            and eqk.user_id = #{userId}
+            union all
+            select eqk1.question_id, hds1.id how_details_id, hds1.alias detail_name, hdks1.id how_details_kd_id, hdks1.alias
+            kd_name,
+            hds1.grade, hds1.course_name, hds1.type version_type, hds1.semester, khd1.is_zt module_type, hs1.alias how_name,
+            hds1.num, hdks1.num
+            from kmt_exercise_question_know eqk1
+            left join zyb_know_how_details_sort hds1 on eqk1.how_detail_sort_id=hds1.id
+            left join zyb_know_how_details_sort hs1 on hds1.how_id=hs1.how_id and hds1.type=hs1.type and
+            hds1.semester=hs1.semester and hds1.grade=hs1.grade and hs1.stat=1
+            left join zyb_know_how_details_sort hdks1 on eqk1.how_detail_kd_sort_id=hdks1.id
+            left join zyb_know_how_details khd1 on hds1.how_details_id=khd1.id
+            where question_id in
+            <foreach collection="questionIds" item="id" index="index" open="(" close=")" separator=",">
+                #{id}
+            </foreach>and question_id not in (
+                select question_id from tr_train_user_question_know where user_id = #{userId}
+            )
+        )t  order by t.question_id, t.num, t.num2
     </select>
 
     <!--查询kmt题目的知识点-->
@@ -2196,10 +2217,20 @@
 	eq.remark reason,
 	eq.from_user_id,
 	eq.to_user_id,
-	ifnull(ue.question_type,eq.question_type) question_types,
-	ifnull(ue.difficulty_level,eq.difficulty_level) difficulty_levels,
-	ifnull(ue.real_exam_type,eq.real_exam_type) real_exam_types,
-	ifnull(ue.training_skill,eq.training_skill) training_skills,
+	<if test="roleType == 1 or roleType ==2 ">
+        eq.question_type as question_types,
+        eq.difficulty_level as difficulty_levels,
+        eq.real_exam_type as real_exam_types,
+        eq.training_skill as  training_skills,
+    </if>
+    <!-- 解析或者管理员-->
+    <if test="roleType ==3 or roleType ==0 ">
+        ifnull(ue.question_type,eq.question_type) question_types,
+        ifnull(ue.difficulty_level,eq.difficulty_level) difficulty_levels,
+        ifnull(ue.real_exam_type,eq.real_exam_type) real_exam_types,
+        ifnull(ue.training_skill,eq.training_skill) training_skills,
+    </if>
+
 	eq.parent_id,
 	eq.proofread_status,
 	ifnull(ue.question_path,eq.question_path) as question_path,