Przeglądaj źródła

fix(server): 题库

Go 5 lat temu
rodzic
commit
82235e32bb

+ 1 - 1
front/project/Constant.js

@@ -112,7 +112,7 @@ export const TextbookFeedbackStatus = [{ value: 0, label: '新增' }, { value: 1
 
 export const TextbookFeedbackTarget = [{ label: '纠正解析', value: 'correct', tip: '正确的解析和答案是' }, { label: '完善已有机经', value: 'perfect', tip: '补充内容是' }, { label: '提供全新机经', value: 'new', tip: '新机经是' }];
 
-export const ContractKey = [{ label: '注册', value: 'register' }, { label: '课程购买', value: 'course' }];
+export const ContractKey = [{ label: '注册', value: 'register' }, { label: '课程购买', value: 'course' }, { label: '隐私协议', value: 'privacy' }, { label: '法律申明', value: 'legal' }];
 
 export const RoomPosition = [{ label: '北部', value: 'north' }, { label: '东部', value: 'east' }, { label: '中南', value: 'south_central' }, { label: '西部', value: 'west' }, { label: '海外', value: 'overseas' }];
 

+ 8 - 4
front/project/www/components/OtherModal/index.js

@@ -978,10 +978,14 @@ export class TextbookFeedbackModal extends Component {
     const { data } = this.state;
     if (!data.content) return;
     if (data.target !== 'new' && !data.no) return;
-    My.addTextbookFeedback(data.textbookSubject, data.target, data.no, data.content).then(() => {
-      this.setState({ data: { content: '' } });
-      if (onConfirm) onConfirm();
-    });
+    My.addTextbookFeedback(data.textbookSubject, data.target, data.no, data.content)
+      .then(() => {
+        this.setState({ data: { content: '' } });
+        if (onConfirm) onConfirm();
+      })
+      .catch((e) => {
+        asyncSMessage(e.message, 'error');
+      });
   }
 
   onCancel() {

+ 27 - 21
front/project/www/routes/question/search/page.js

@@ -54,19 +54,25 @@ export default class extends Page {
         return refreshStruct(this, 'exercise', data.one, data.two, {
           all: true,
         }).then(({ structIds }) => {
-          Question.searchStem(
-            Object.assign(
-              { questionTypes, structIds, module: 'exercise' },
-              this.state.search,
-              {
-                order: Object.keys(data.sortMap)
-                  .map(key => {
-                    return `${key} ${data.sortMap[key]}`;
-                  })
-                  .join(','),
-              },
-            ),
-          ).then(result => {
+          let handler = null;
+          if (this.state.search.keyword) {
+            handler = Question.searchStem({ keyword: this.state.search.keyword, page: this.state.search.page, size: this.state.search.size });
+          } else {
+            handler = Question.searchStem(
+              Object.assign(
+                { questionTypes, structIds, module: 'exercise' },
+                this.state.search,
+                {
+                  order: Object.keys(data.sortMap)
+                    .map(key => {
+                      return `${key} ${data.sortMap[key]}`;
+                    })
+                    .join(','),
+                },
+              ),
+            );
+          }
+          handler.then(result => {
             this.setState({ list: result.list, total: result.total, page: data.page, searchResult: !!data.keyword });
           });
         });
@@ -85,13 +91,13 @@ export default class extends Page {
     // this.initData();
   }
 
-  onSearch() {
+  onSearch(value) {
     const { keyword } = this.state;
-    User.addSearch(keyword);
+    User.addSearch(value || keyword);
     // this.search({ keyword }, false);
     // this.changeQuery({ keyword });
     // this.setState({ keyword });
-    this.refreshQuery({ keyword });
+    this.refreshQuery({ keyword: value || keyword });
     // this.initData();
   }
 
@@ -149,7 +155,7 @@ export default class extends Page {
             onFocus={() => this.setState({ focus: true })}
             onBlur={() => this.setState({ focus: false })}
           />
-          <Button width={150} onClick={() => this.onSearch()}>
+          <Button width={150} onClick={() => this.onSearch(keyword)}>
             <Icon className="m-r-5" type="search" />
             搜索题目
           </Button>
@@ -157,8 +163,8 @@ export default class extends Page {
             <div hidden={!keyword || searchList.length === 0} className="search-tip-wrapper" onMouseEnter={() => this.setState({ tip: true })} onMouseLeave={() => this.setState({ tip: false })}>
               {searchList.map(item => {
                 return <div className="t-2 t-s-16" onClick={() => {
-                  this.onChangeSearch(item, true);
-                  this.onSearch();
+                  // this.onChangeSearch(item, true);
+                  this.onSearch(item);
                 }}>{item}</div>;
               })}
             </div>
@@ -168,8 +174,8 @@ export default class extends Page {
               {searchHistoryList.map((item, index) => {
                 return (
                   <div className="t-2 t-s-16" onClick={() => {
-                    this.onChangeSearch(item, true);
-                    this.onSearch();
+                    // this.onChangeSearch(item, true);
+                    this.onSearch(item);
                   }}>
                     {item}
                     <div className="f-r t-4 t-s-12 c-p" onClick={(e) => {

+ 2 - 2
front/project/www/stores/question.js

@@ -37,8 +37,8 @@ export default class QuestionStore extends BaseStore {
     }
   }
 
-  searchStem({ keyword, questionTypes, module, structIds, place, difficult, order, direction }) {
-    return this.apiGet('/question/search/stem', { keyword, questionTypes, module, structIds, place, difficult, order, direction });
+  searchStem({ keyword, questionTypes, module, structIds, place, difficult, order, direction, page, size }) {
+    return this.apiGet('/question/search/stem', { keyword, questionTypes, module, structIds, place, difficult, order, direction, page, size });
   }
 
   searchNo({ keyword, page, size }) {

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

@@ -106,12 +106,15 @@
     按题目id查询,过滤千行cat
   -->
   <select id="searchNoFulltext" resultMap="IdMap">
+    <if test="keyword != null">
+      <bind name="keywordLike" value="'%' + keyword + '%'" />
+    </if>
     select
     <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
-    MATCH (qn.`title`) AGAINST (#{keyword, jdbcType=VARCHAR} IN NATURAL LANGUAGE MODE)
+    (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}
     </if>