Browse Source

fix(service): 修复删除错误

Go 4 years ago
parent
commit
4871cf58be

+ 2 - 2
front/project/www/routes/examination/list/page.js

@@ -193,7 +193,7 @@ export default class extends Page {
         align: 'right',
         render: record => {
           return [<div className="table-row p-t-1">
-            {record.report && record.report.isFinish && (
+            {record.report && !!record.report.isFinish && (
               <IconButton
                 className="m-r-5"
                 type="report"
@@ -361,7 +361,7 @@ export default class extends Page {
         render: record => {
           return (
             <div className="table-row p-t-1">
-              {record.report && record.report.isFinish && (
+              {record.report && !!record.report.isFinish && (
                 <IconButton
                   type="report"
                   tip="Report"

+ 1 - 1
front/project/www/routes/exercise/list/page.js

@@ -109,7 +109,7 @@ export default class extends Page {
       render: (record) => {
         return (
           <div className="table-row p-t-1">
-            {record.report && record.report.isFinish && <IconButton type="report" tip="Report" onClick={() => {
+            {record.report && !!record.report.isFinish && <IconButton type="report" tip="Report" onClick={() => {
               Question.reportLink(record);
             }} />}
           </div>

+ 2 - 2
front/project/www/routes/exercise/main/page.js

@@ -123,7 +123,7 @@ const exerciseColumns = [{
   render: record => {
     return (
       <div className="table-row p-t-1">
-        {record.report && record.report.isFinish && <IconButton type="report" tip="Report" onClick={() => {
+        {record.report && !!record.report.isFinish && <IconButton type="report" tip="Report" onClick={() => {
           Question.reportLink(record);
         }} />}
       </div>
@@ -253,7 +253,7 @@ export default class extends Page {
       render: record => {
         return (
           <div className="table-row p-t-1">
-            {record.report && record.report.isFinish > 0 && <IconButton type="report" tip="Report" onClick={() => {
+            {record.report && !!record.report.isFinish > 0 && <IconButton type="report" tip="Report" onClick={() => {
               User.needLogin()
                 .then(() => {
                   Question.reportLink(record);

+ 9 - 3
front/project/www/routes/paper/report/page.js

@@ -131,6 +131,9 @@ function BarOption2(title, data, legend, color) {
     },
     tooltip: {
       trigger: 'item',
+      formatter: (params) => {
+        return `${params.value[params.seriesIndex + 1]}%`;
+      },
     },
     legend: {
       show: legend.length > 1,
@@ -625,7 +628,10 @@ export default class extends Page {
       if (aValue === bValue) {
         return b.no - a.no;
       }
-      return aValue > bValue ? -1 : 1;
+      if (order === 'no') {
+        return b.no - a.no;
+      }
+      return bValue > aValue ? -1 : 1;
     });
     // if (direction === 'desc') {
     //   list.reverse();
@@ -829,7 +835,7 @@ export default class extends Page {
                 return <tr>
                   <td>{row.no}</td>
                   <td>
-                    <div className='n'><Link to={`/paper/question/${row.id}`}>{row.questionNo.title}</Link></div>
+                    <div className='n'><Link to={`/paper/question/${row.id}`}>{(row.questionNo || {}).title}</Link></div>
                     <div className='desc'>{row.question.description}</div>
                   </td>
                   <td><GIcon name={row.detail.subject && row.detail.predicate && row.detail.object ? 'right' : 'error'} noHover /></td>
@@ -953,7 +959,7 @@ export default class extends Page {
                 return <tr>
                   <td>{row.no}</td>
                   <td>
-                    <div className='n'><Link to={`/paper/question/${row.id}`}>{row.questionNo.title}</Link></div>
+                    <div className='n'><Link to={`/paper/question/${row.id}`}>{(row.questionNo || {}).title}</Link></div>
                     <div className='desc'>{row.question.description}</div>
                   </td>
                   <td><GIcon name={row.isCorrect ? 'right' : 'error'} noHover /></td>

+ 1 - 1
front/project/www/routes/textbook/list/page.js

@@ -105,7 +105,7 @@ export default class extends Page {
       render: (record) => {
         return (
           <div className="table-row p-t-1">
-            {record.report && record.report.isFinish && <IconButton type="report" tip="Report" onClick={() => {
+            {record.report && !!record.report.isFinish && <IconButton type="report" tip="Report" onClick={() => {
               Question.reportLink(record);
             }} />}
           </div>

+ 5 - 5
server/data/src/main/java/com/qxgmat/data/relation/mapping/QuestionNoRelationMapper.xml

@@ -52,7 +52,7 @@
     left join `question` q on q.`id` = qn.`question_id`
       and MATCH (q.`description`) AGAINST (#{stem, jdbcType=VARCHAR} IN NATURAL LANGUAGE MODE) > 0.8
     where
-      q.`id` &gt; 0
+      q.`id` &gt; 0 and qn.`delete_time` is null
   </select>
 
   <!--
@@ -83,7 +83,7 @@
       </foreach>
     </if>
     where
-    q.id &gt; 0 and qn.question_id &gt; 0
+    q.id &gt; 0 and qn.question_id &gt; 0 and qn.`delete_time` is null
     <if test="keyword">
       and (qn.`title` = #{keyword, jdbcType=VARCHAR} or MATCH (q.`description`) AGAINST (#{keyword, jdbcType=VARCHAR} IN NATURAL LANGUAGE MODE))
     </if>
@@ -113,7 +113,7 @@
     <include refid="Id_Column_List" />,
     MATCH (qn.`title`) AGAINST (#{keyword, jdbcType=VARCHAR} IN NATURAL LANGUAGE MODE) as `relation_score`
     from `question_no` qn
-    where qn.question_id &gt; 0 and
+    where qn.question_id &gt; 0 and qn.`delete_time` is null and
     (MATCH (qn.`title`) AGAINST (#{keyword, jdbcType=VARCHAR} IN NATURAL LANGUAGE MODE) or qn.`title` like #{keywordLike,jdbcType=VARCHAR})
     <if test="module != null">
       and qn.`module` = #{module,jdbcType=VARCHAR}
@@ -133,7 +133,7 @@
     from `question_no` qn
     left join `question` q on q.`id` = qn.`question_id`
     where
-    q.id &gt; 0 and qn.question_id &gt; 0
+    q.id &gt; 0 and qn.question_id &gt; 0 and qn.`delete_time` is null
     and qn.`module` = 'examination'
     <if test="structId != null">
       and find_in_set(#{structId,jdbcType=VARCHAR}, qn.`module_struct`)
@@ -163,7 +163,7 @@
     from `question_no` qn
     left join `question` q on q.`id` = qn.`question_id`
     where
-    q.id &gt; 0 and qn.question_id &gt; 0
+    q.id &gt; 0 and qn.question_id &gt; 0 and qn.`delete_time` is null
     and qn.`module` = 'examination'
     <if test="structId != null">
       and find_in_set(#{structId,jdbcType=VARCHAR}, qn.`module_struct`)

+ 3 - 3
server/data/src/main/java/com/qxgmat/data/relation/mapping/UserPaperRelationMapper.xml

@@ -41,7 +41,7 @@
     ur.`user_number` / up.`question_number` as `progress`
     from `user_paper` up
     left join `user_report` ur on ur.`id`= up.`latest_report_id`
-    where up.`user_id` = #{userId,jdbcType=VARCHAR}
+    where up.`user_id` = #{userId,jdbcType=VARCHAR} and ur.`id` is not null
     <if test="paperOrigin != null">
     and up.`paper_origin` = #{paperOrigin,jdbcType=VARCHAR}
     </if>
@@ -108,7 +108,7 @@
       </foreach>
     </if>
     left join `preview_paper` pp on pa.`paper_id` = pp.`id`
-    where up.`user_id` = #{userId,jdbcType=VARCHAR}
+    where up.`user_id` = #{userId,jdbcType=VARCHAR} and ur.`id` is not null
     <if test="keyword != null">
       and (ep.`title` like #{keywordLike,jdbcType=VARCHAR}
       or pa.`title like #{keywordLike,jdbcType=VARCHAR}`
@@ -166,7 +166,7 @@
       <if test="year != null">
         and tp.`year` = #{year,jdbcType=VARCHAR}
       </if>
-    where up.`user_id` = #{userId,jdbcType=VARCHAR}
+    where up.`user_id` = #{userId,jdbcType=VARCHAR} and ur.`id` is not null
     <if test="keyword != null">
       and (ep.`title` like #{keywordLike,jdbcType=VARCHAR}
       or tp.`title like #{keywordLike,jdbcType=VARCHAR}`)

+ 29 - 1
server/gateway-api/src/main/java/com/qxgmat/service/inline/QuestionNoService.java

@@ -87,6 +87,10 @@ public class QuestionNoService extends AbstractService {
                     example.createCriteria()
                             .andIn("id", Arrays.stream(ids).collect(Collectors.toList()))
             );
+        example.and(
+                example.createCriteria()
+                    .andIsNull("deleteTime")
+        );
         example.orderBy("id").asc();
         Page<QuestionNo> p = page(()->select(questionNoMapper, example), page, size);
         logger.info("SearchNo result: {}", p.toString());
@@ -153,6 +157,10 @@ public class QuestionNoService extends AbstractService {
                         .andGreaterThan("questionId", 0)
                         .andCondition(String.format(formatSet, structId, "module_struct"))
         );
+        example.and(
+                example.createCriteria()
+                        .andIsNull("deleteTime")
+        );
         example.orderBy("no").asc();
         return select(questionNoMapper, example);
     }
@@ -177,6 +185,10 @@ public class QuestionNoService extends AbstractService {
             }
             example.and(criteria);
         }
+        example.and(
+                example.createCriteria()
+                        .andIsNull("deleteTime")
+        );
         example.orderBy("no").asc();
         return select(questionNoMapper, example);
     }
@@ -209,6 +221,11 @@ public class QuestionNoService extends AbstractService {
                     example.createCriteria()
                             .andEqualTo("module", module)
             );
+
+        example.and(
+                example.createCriteria()
+                        .andIsNull("deleteTime")
+        );
         List<QuestionNo> p = select(questionNoMapper, example);
         return relation(p);
     }
@@ -224,6 +241,10 @@ public class QuestionNoService extends AbstractService {
                 example.createCriteria()
                         .andEqualTo("questionId", questionId)
         );
+        example.and(
+                example.createCriteria()
+                        .andIsNull("deleteTime")
+        );
         return select(questionNoMapper, example);
     }
 
@@ -324,6 +345,10 @@ public class QuestionNoService extends AbstractService {
                 .andEqualTo("relationNumber", number)
                 .andNotIn("id", filterIds)
         );
+        example.and(
+                example.createCriteria()
+                        .andIsNull("deleteTime")
+        );
         example.setOrderByClause("RAND()");
         QuestionNo questionNo = one(questionNoMapper, example);
         if (questionNo == null){
@@ -383,6 +408,7 @@ public class QuestionNoService extends AbstractService {
         Integer totalNumber = 0;
         Integer totalCorrect = 0;
         for(QuestionNo questionNo : questionNoList){
+            if (questionNo == null) continue;
             totalTime += questionNo.getTotalTime();
             totalNumber += questionNo.getTotalNumber();
             totalCorrect += questionNo.getTotalCorrect();
@@ -453,6 +479,8 @@ public class QuestionNoService extends AbstractService {
             List<String> l = new ArrayList<>();
             for (Integer questionNoId : questionNoIdsMap.get(k)){
                 QuestionNoRelation relation = (QuestionNoRelation)questionNoMap.get(questionNoId);
+                if (relation == null) continue;
+                if (relation.getQuestion() == null) continue;
                 if (!l.contains(relation.getQuestion().getQuestionType())){
                     l.add(relation.getQuestion().getQuestionType());
                 }
@@ -521,7 +549,7 @@ public class QuestionNoService extends AbstractService {
         if(in == null){
             throw new ParameterException("题目不存在");
         }
-        int result = delete(questionNoMapper, id, SOFT_FLAG);
+        int result = delete(questionNoMapper, id, true);
         return result > 0;
     }