Browse Source

各角色显示内容优化

shenhao 3 years ago
parent
commit
9487797be7

+ 3 - 2
src/main/java/com/aijia/kmt/controller/KmtExerciseController.java

@@ -133,9 +133,10 @@ public class KmtExerciseController extends BaseController {
             String  userId = tokenManager.getUserId(accessToken);
             //是管理员
             int type = 1;
-            if(!request.getUserId().equals(userId)){
-               type = 2;
+            if(!userId.equals(request.getUserId())){
+                type = 2;
             }
+
             data.put("units", kmtExerciseMapperService.findExerciseBookDetail(request, userId,type));
             responseEntity.success(data, "成功");
         } catch (Exception e) {

+ 10 - 13
src/main/java/com/aijia/kmt/service/impl/KmtExerciseQuestionListServiceImpl.java

@@ -175,7 +175,7 @@ public class KmtExerciseQuestionListServiceImpl implements KmtExerciseQuestionLi
             List<TbLibManager> users = getDealUsers(list);
 
             list.forEach(temp -> {
-                QuestionListV1Dto tar = changeExerciseDto2QuestionListDto(temp, questionKnows, users);
+                QuestionListV1Dto tar = changeExerciseDto2QuestionListDto(temp, questionKnows, users,null);
                 if (isTwoLevel && StringUtil.isNotBlank(temp.getParentId())){
                     addTar2Result(tar, result, temp.getParentId(), temp.getExerciseBookId(),null);
                 } else {
@@ -196,17 +196,11 @@ public class KmtExerciseQuestionListServiceImpl implements KmtExerciseQuestionLi
         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);
 
             list.forEach(temp -> {
-                QuestionListV1Dto tar = changeExerciseDto2QuestionListDto(temp, questionKnows, users);
+                QuestionListV1Dto tar = changeExerciseDto2QuestionListDto(temp, questionKnows, users,userId);
                 if (isTwoLevel && StringUtil.isNotBlank(temp.getParentId())){
                     addTar2Result(tar, result, temp.getParentId(), temp.getExerciseBookId(),userId);
                 } else {
@@ -225,11 +219,14 @@ public class KmtExerciseQuestionListServiceImpl implements KmtExerciseQuestionLi
      * @return
      */
     private QuestionListV1Dto changeExerciseDto2QuestionListDto (ExerciseQuetionDto exerciseDto, List<QuestionListKnowModel> questionKnows,
-                                                                 List<TbLibManager> users) {
+                                                                 List<TbLibManager> users,String userId) {
         QuestionListV1Dto tar = new QuestionListV1Dto();
-        //设置知识点
-        setQuestionKnowledge(tar, questionKnows.stream().filter(map ->
-                exerciseDto.getQuestionId().equals(map.getQuestionId())).collect(Collectors.toList()));
+            TrTrainPartUser user = userServiceMapper.selectById(userId);
+            if(user.getRoleType()>1){
+                //设置知识点
+                setQuestionKnowledge(tar, questionKnows.stream().filter(map ->
+                        exerciseDto.getQuestionId().equals(map.getQuestionId())).collect(Collectors.toList()));
+            }
         //设置打回人和被打回人
         setFromUserAndToUser(tar, exerciseDto);
         //设置加工审核人
@@ -285,7 +282,7 @@ public class KmtExerciseQuestionListServiceImpl implements KmtExerciseQuestionLi
                         q.setQuestion("<img src='" + PropertiesUtil.getValue("STATIC_FILE_URL") + q.getQuestionImage() + "'/>");
                     }
                 }
-                parent = changeExerciseDto2QuestionListDto(questions.get(0), questionKnows, users);
+                parent = changeExerciseDto2QuestionListDto(questions.get(0), questionKnows, users,userId);
             }
         }
 

+ 6 - 6
src/main/resources/mybatis/mapper/KmtExerciseMapper.xml

@@ -1074,7 +1074,7 @@
             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
+            hds.num, hdks.num as num2
             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
@@ -1090,7 +1090,7 @@
             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
+            hds1.num, hdks1.num as num2
             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
@@ -2218,10 +2218,10 @@
 	eq.from_user_id,
 	eq.to_user_id,
 	<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,
+        ue.question_type as question_types,
+        ue.difficulty_level as difficulty_levels,
+        ue.real_exam_type as real_exam_types,
+        ue.training_skill as  training_skills,
     </if>
     <!-- 解析或者管理员-->
     <if test="roleType ==3 or roleType ==0 ">