瀏覽代碼

fix(fronnt): 修复操作

Go 4 年之前
父節點
當前提交
0b97f862f1

+ 1 - 2
front/project/www/routes/course/detail/page.js

@@ -604,7 +604,7 @@ export default class extends Page {
   }
 
   renderTab4() {
-    const { faqs, data = {}, showFaq, faq } = this.state;
+    const { faqs, data = {} } = this.state;
     return (
       <div className="tab-layout">
         <AnswerCarousel
@@ -612,7 +612,6 @@ export default class extends Page {
           list={faqs}
           onFaq={() => this.setState({ showFaq: true, faq: { channel: 'course-video', position: data.id } })}
         />
-        <FaqModal show={showFaq} defaultData={faq} onCancel={() => this.setState({ showFaq: false })} onConfirm={() => this.setState({ showFaq: false })} />
       </div>
     );
   }

+ 1 - 1
front/project/www/routes/course/main/page.js

@@ -145,7 +145,7 @@ export default class extends Page {
         <AnswerCarousel list={faqs} onFaq={() => this.setState({ showFaq: true, faq: { channel: 'course-index' } })} />
         <Contact data={base.contact} />
         <Footer />
-        <FaqModal show={showFaq} defaultData={faq} onCancel={() => this.setState({ showFaq: false })} onConfirm={() => this.setState({ showFaq: false })} />
+        <FaqModal show={showFaq} defaultData={faq} onCancel={() => this.setState({ showFaq: false })} onConfirm={() => this.setState({ showFaq: false, showFinish: true })} />
         <FinishModal
           show={showFinish}
           onConfirm={() => this.setState({ showFinish: false })}

+ 7 - 7
front/project/www/routes/course/note/page.js

@@ -159,7 +159,7 @@ export default class extends Page {
     this.setState({ showExportWait: true, showExportConfirm: false, showExportAuthConfirm: false });
     My.exportNoteCourse(exportInfo)
       .then((result) => {
-        openLink(`/export/${result.id}`);
+        openLink(`/export/${result}`);
         this.setState({ showExportWait: false });
       })
       .catch(e => {
@@ -194,7 +194,7 @@ export default class extends Page {
   }
 
   renderView() {
-    const { course = {}, courseNoMap = {}, list = [], sortMap, filterMap, allChecked, total, page } = this.state;
+    const { course = {}, courseNoMap = {}, list = [], selectList = [], sortMap, filterMap, allChecked, total, page } = this.state;
     const {
       user: { info },
     } = this.props;
@@ -229,7 +229,7 @@ export default class extends Page {
           />
           <div className="list">
             {list.map(item => {
-              return <Note data={item} courseNoMap={courseNoMap} onSelect={(value) => this.onSelect(value)} onClick={() => this.setState({ showDetail: true, article: item })} />;
+              return <Note data={item} selectList={selectList} courseNoMap={courseNoMap} onSelect={(value) => this.onSelect(value)} onClick={() => this.setState({ showDetail: true, article: item })} />;
             })}
           </div>
           {total > 0 && list.length > 0 && (
@@ -326,11 +326,11 @@ class Note extends Component {
   render() {
     const { data, selectList, onClick, courseNoMap = {} } = this.props;
     return (
-      <div className="note-item p-t-2 b-b" onClick={() => onClick && onClick()}>
+      <div className="note-item p-t-2 b-b">
         <div className="t-1 t-s-14 f-w-b m-b-5">
-          <CheckboxItem theme="white" value={selectList.indexOf(data.key) >= 0} onChange={() => this.onSelect()} />
-          <span className="t-2 m-l-5 m-r-5">课时{(courseNoMap[data.key] || {}).no}</span>
-          {(courseNoMap[data.key] || {}).title}
+          <CheckboxItem theme="white" checked={selectList.indexOf(data.key) >= 0} onClick={() => this.onSelect()} />
+          <span className="t-2 m-l-5 m-r-5" onClick={() => onClick && onClick()}>课时{(courseNoMap[data.key] || {}).no}</span>
+          <span onClick={() => onClick && onClick()}>{(courseNoMap[data.key] || {}).title}</span>
           <div className="f-r t-3 t-s-12 f-w-d">
             <span>{formatDate(data.updateTime, 'YYYY-MM-DD HH:mm:ss')}</span>
           </div>

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

@@ -113,10 +113,12 @@ export default class extends Page {
           const day = parseInt((new Date().getTime() - new Date(row.startDate).getTime()) / 86400000, 10);
           row.desc = [`最近换库:${formatDate(row.startDate, 'YYYY-MM-DD')} ,已换库${day}天`, `最后更新:${formatDate(row.updateTime)}`];
         }
-        if (row.unUseRecord) User.formatCheckout(row.unUseRecord);
+        if (row.unUseRecord) User.formatCheckout([row.unUseRecord]);
         return row;
       });
       this.setState({ textbookProgress: result });
+    }).catch(e => {
+      console.log(e);
     });
 
     Main.listFaq({ page: 1, size: 100, channel: 'textbook' }).then(result => {
@@ -150,7 +152,7 @@ export default class extends Page {
         row.pieValue = formatPercent(row.userNumber, row.paperNumber);
         row.pieText = formatPercent(row.userNumber, row.paperNumber, false);
         row.pieSubText = `共${row.paperNumber}套`;
-        if (row.unUseRecord) User.formatCheckout(row.unUseRecord);
+        if (row.unUseRecord) User.formatCheckout([row.unUseRecord]);
         return row;
       });
       this.setState({ examinationProgress: result });
@@ -260,6 +262,7 @@ export default class extends Page {
 
   renderTextbook() {
     const { textbookProgress = [] } = this.state;
+    console.log(textbookProgress);
     return (
       <div>
         <Division col={2}>

+ 1 - 1
front/project/www/routes/my/collect/page.js

@@ -309,7 +309,7 @@ export default class extends Page {
     this.setState({ showExportWait: true, showExportConfirm: false, showExportAuthConfirm: false });
     My.exportQuestionCollect(exportInfo)
       .then((result) => {
-        openLink(`/export/${result.id}`);
+        openLink(`/export/${result}`);
         this.setState({ showExportWait: false });
       })
       .catch(e => {

+ 1 - 1
front/project/www/routes/my/error/page.js

@@ -295,7 +295,7 @@ export default class extends Page {
     this.setState({ showExportWait: true, showExportConfirm: false, showExportAuthConfirm: false });
     My.exportQuestionError(exportInfo)
       .then((result) => {
-        openLink(`/export/${result.id}`);
+        openLink(`/export/${result}`);
         this.setState({ showExportWait: false });
       })
       .catch(e => {

+ 13 - 0
front/project/www/routes/my/note/page.js

@@ -339,6 +339,19 @@ export default class extends Page {
       });
   }
 
+  export() {
+    const { exportInfo } = this.state;
+    this.setState({ showExportWait: true, showExportConfirm: false, showExportAuthConfirm: false });
+    My.exportNoteQuestion(exportInfo)
+      .then((result) => {
+        openLink(`/export/${result}`);
+        this.setState({ showExportWait: false });
+      })
+      .catch(e => {
+        this.setState({ warn: { title: '导出', content: e.message }, showExportWait: false });
+      });
+  }
+
   renderView() {
     const { config } = this.props;
     return <UserLayout active={config.key} menu={menu} center={this.renderTable()} />;

+ 9 - 6
front/project/www/routes/page/export/page.js

@@ -1,5 +1,6 @@
 import React, { Component } from 'react';
 import './index.less';
+import { Checkbox } from 'antd';
 import Page from '@src/containers/Page';
 import Modal from '../../../components/Modal';
 import HardInput from '../../../components/HardInput';
@@ -9,7 +10,6 @@ import { My } from '../../../stores/my';
 import { User } from '../../../stores/user';
 
 import { SentenceOption } from '../../../../Constant';
-import CheckboxItem from '../../../components/CheckboxItem';
 
 const ExportType = [
   { label: '收藏', value: 'question_collect' },
@@ -29,7 +29,7 @@ export default class extends Page {
     };
   }
 
-  initDate() {
+  initData() {
     const { id } = this.params;
     My.exportDetail(id)
       .then(result => {
@@ -43,7 +43,9 @@ export default class extends Page {
     if (!nextTips) return;
     My.exportTips()
       .then(() => {
-        User.infoHandle({ exportTips: 1 });
+        const { info } = this.props.user;
+        info.exportTips = 1;
+        User.infoHandle(info);
       });
   }
 
@@ -63,7 +65,7 @@ export default class extends Page {
           btnAlign="center"
         >
           <div className="t-2 t-s-18">鼠标右键点击打印后,可直接保存为PDF或打印。</div>
-          <div className="t-2 t-s-14"><CheckboxItem checked={nextTips} onClick={() => this.setState({ nextTips: !nextTips })} />下次进入时不再提醒。</div>
+          <div className="t-2 t-s-14"><Checkbox checked={nextTips} onClick={() => this.setState({ nextTips: !nextTips })} />下次进入时不再提醒。</div>
         </Modal>
       </div>
     );
@@ -71,6 +73,7 @@ export default class extends Page {
 
   renderHead() {
     const { data = {} } = this.state;
+    const { content = {} } = data;
     const { info } = this.props.user;
     return (
       <div className="head-layout">
@@ -82,7 +85,7 @@ export default class extends Page {
           <div className="t-2 t-s-12">* 请勿外传或商用!</div>
           <div style={{ right: 0, top: 20 }} className="p-a t-r">
             <div className="t-2">第{data.no || 0}次导出{ExportTypeMap[data.type]}</div>
-            <div className="t-2">本次导出 {data.content.length} 道 </div>
+            <div className="t-2">本次导出 {(content.list || []).length} 道 </div>
             <div className="t-2">{formatDate(data.createTime, 'YYYY-MM-DD HH:mm:ss')}</div>
           </div>
         </div>
@@ -223,7 +226,7 @@ class BaseDetail extends Component {
       <div className="detail-item-block">
         <div className="title-item">千行解析</div>
         <div className="t-1 t-s-16 m-b-2" dangerouslySetInnerHTML={{ __html: question.qxContent }} />
-        {this.renderNote('官方解析', note.qxContent)}
+        {this.renderNote('千行解析', note.qxContent)}
       </div>
     );
   }

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

@@ -290,7 +290,6 @@ export default class extends Page {
         />
         <FaqModal show={showFaq} defaultData={faq} onCancel={() => this.setState({ showFaq: false })} onConfirm={() => this.setState({ showFaq: false, showFinish: true })} />
         <FinishModal
-          getContainer={() => document.getElementById(this.video.state.id)}
           show={showFinish}
           onConfirm={() => this.setState({ showFinish: false })}
         />

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

@@ -140,7 +140,9 @@ export default class extends Page {
     this.setState({ showTip: false });
     My.textbookTips()
       .then(() => {
-        User.infoHandle({ textbookTips: 1 });
+        const { info } = this.props.user;
+        info.textbookTips = 1;
+        User.infoHandle(info);
       });
   }
 

+ 4 - 0
front/project/www/stores/user.js

@@ -84,6 +84,10 @@ export default class UserStore extends BaseStore {
     return { login: !!this.adminLogin, needPay: false, needLogin: false };
   }
 
+  fixState() {
+    return { needPay: false, needLogin: false };
+  }
+
   initAfter() {
     if (this.getToken()) {
       this.refreshToken().then(() => {

+ 5 - 1
front/src/stores/base.js

@@ -13,13 +13,17 @@ export default class BaseStore {
     this.Api = Api;
     this.Cache = Cache;
     this.project = project;
-    this.state = this.local ? Object.assign(this.initState(), this.getLocal(this.key) || {}) : this.initState();
+    this.state = this.local ? Object.assign(this.initState(), this.getLocal(this.key) || {}, this.fixState()) : this.initState();
   }
 
   initState() {
     return {};
   }
 
+  fixState() {
+    return {};
+  }
+
   setStore(store) {
     this.store = store;
     if (this.initAfter) this.initAfter();

+ 1 - 0
server/data/src/main/java/com/qxgmat/data/relation/UserQuestionRelationMapper.java

@@ -36,6 +36,7 @@ public interface UserQuestionRelationMapper {
     );
 
     List<UserQuestion> listLast(
+            @Param("userId") Number userId,
             @Param("questionIds") Collection questionIds
     );
 

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

@@ -161,7 +161,7 @@
     <!--SUBSTRING_INDEX(GROUP_CONCAT(ur.`id` ORDER BY ur.`create_time` desc),',',1) as `id`-->
     max(uq.`id`) as `id`
     from `user_question` uq
-    where uq.`question_id` IN
+    where uq.`user_id` = #{userId,jdbcType=VARCHAR} and uq.`question_id` IN
     <foreach collection="questionIds" item="item" index="index" open="(" close=")" separator=",">
       #{item}
     </foreach>

+ 6 - 2
server/gateway-api/src/main/java/com/qxgmat/controller/api/MyController.java

@@ -984,7 +984,7 @@ public class MyController {
         Transform.combine(pr, stats, UserCollectQuestionInfoDto.class, "questionId", "stat");
 
         // 最近做题
-        List<UserQuestion> lastList = userQuestionService.listWithLast(questionIds);
+        List<UserQuestion> lastList = userQuestionService.listWithLast(user.getId(), questionIds);
         Map lastMap = Transform.getMap(lastList, UserQuestion.class, "id", "createTime");
         Transform.combine(pr, lastMap, UserCollectQuestionInfoDto.class, "questionId", "latestTime");
 
@@ -1054,7 +1054,7 @@ public class MyController {
         Transform.combine(pr, stats, UserQuestionErrorInfoDto.class, "questionId", "stat");
 
         // 最近做题
-        List<UserQuestion> lastList = userQuestionService.listWithLast(questionIds);
+        List<UserQuestion> lastList = userQuestionService.listWithLast(user.getId(), questionIds);
         Map lastMap = Transform.getMap(lastList, UserQuestion.class, "id", "createTime");
         Transform.combine(pr, lastMap, UserQuestionErrorInfoDto.class, "questionId", "latestTime");
 
@@ -2054,7 +2054,11 @@ public class MyController {
     @RequestMapping(value = "/export/detail", method = RequestMethod.GET)
     @ApiOperation(value = "导出详情", notes = "导出详情", httpMethod = "GET")
     public Response<UserExport> exportDetail(int id)  {
+        User user = (User) shiroHelp.getLoginUser();
         UserExport entity = userExportService.get(id);
+        if (!user.getId().equals(entity.getUserId())){
+            throw new ParameterException("记录不存在");
+        }
         return ResponseHelp.success(entity);
     }
 

+ 5 - 0
server/gateway-api/src/main/java/com/qxgmat/dto/request/UserNoteCourseDto.java

@@ -3,10 +3,15 @@ package com.qxgmat.dto.request;
 import com.nuliji.tools.annotation.Dto;
 import com.qxgmat.data.dao.entity.UserNoteCourse;
 
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+
 @Dto(entity = UserNoteCourse.class)
 public class UserNoteCourseDto {
+    @NotNull(message = "课程不能为空!")
     private Integer courseId;
 
+    @NotNull(message = "课程课时不能为空!")
     private Integer courseNoId;
 
     private String content;

+ 1 - 0
server/gateway-api/src/main/java/com/qxgmat/service/UserNoteCourseService.java

@@ -76,6 +76,7 @@ public class UserNoteCourseService extends AbstractService {
         Date now = new Date();
         if(in == null){
             // 按实际更新更改更新时间
+
             return add(note);
         }else{
             note.setId(in.getId());

+ 2 - 2
server/gateway-api/src/main/java/com/qxgmat/service/UserQuestionService.java

@@ -90,9 +90,9 @@ public class UserQuestionService extends AbstractService {
      * 查找userQuestion最后一次做题记录
      * @param questionIds
      */
-    public List<UserQuestion> listWithLast(Collection questionIds){
+    public List<UserQuestion> listWithLast(Integer userId, Collection questionIds){
         if(questionIds == null || questionIds.size() == 0) return new ArrayList<>();
-        List<UserQuestion> list = userQuestionRelationMapper.listLast(questionIds);
+        List<UserQuestion> list = userQuestionRelationMapper.listLast(userId, questionIds);
 
         Collection reportIds = Transform.getIds(list, UserQuestion.class, "id");
         Transform.replace(list, select(reportIds), UserQuestion.class, "id");

+ 16 - 8
server/gateway-api/src/main/java/com/qxgmat/service/extend/ExportService.java

@@ -14,6 +14,7 @@ import com.qxgmat.data.relation.entity.UserNoteCourseRelation;
 import com.qxgmat.data.relation.entity.UserQuestionRelation;
 import com.qxgmat.service.UserNoteCourseService;
 import com.qxgmat.service.UserNoteQuestionService;
+import com.qxgmat.service.UserQuestionService;
 import com.qxgmat.service.inline.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -42,6 +43,9 @@ public class ExportService {
     @Autowired
     private UserAskQuestionService userAskQuestionService;
 
+    @Autowired
+    private UserQuestionService userQuestionService;
+
     @Resource
     private UserExportService userExportService;
 
@@ -91,7 +95,8 @@ public class ExportService {
                 .userId(userId)
                 .type(ExportType.QUESTION_COLLECT.key)
                 .setting(setting)
-                .no(count)
+                .content(content)
+                .no(count+1)
                 .build();
         return userExportService.add(export);
     }
@@ -141,7 +146,8 @@ public class ExportService {
                 .userId(userId)
                 .type(ExportType.QUESTION_ERROR.key)
                 .setting(setting)
-                .no(count)
+                .content(content)
+                .no(count + 1)
                 .build();
         return userExportService.add(export);
     }
@@ -189,7 +195,8 @@ public class ExportService {
                 .userId(userId)
                 .type(ExportType.NOTE_QUESTION.key)
                 .setting(setting)
-                .no(count)
+                .content(content)
+                .no(count + 1)
                 .build();
         return userExportService.add(export);
     }
@@ -219,19 +226,23 @@ public class ExportService {
                 .userId(userId)
                 .type(ExportType.NOTE_COURSE.key)
                 .setting(setting)
-                .no(count)
                 .content(content)
+                .no(count + 1)
                 .build();
 
         return userExportService.add(export);
     }
 
     private List<UserQuestionRelation> listByQuestionNoIds(Integer userId, Collection questionNoIds, boolean needAnswer){
+        List<QuestionNo> questionNoList = questionNoService.select(questionNoIds);
+        Collection questionIds = Transform.getIds(questionNoList, QuestionNo.class, "questionId");
+
         List<UserQuestion> userQuestionList = null;
         if (needAnswer){
             // 查询所有id的最后一次做题记录
-
+            userQuestionList = userQuestionService.listWithLast(userId, questionIds);
         }else{
+            userQuestionList = new ArrayList<>();
             for(Object questionNoId : questionNoIds){
                 userQuestionList.add(UserQuestion.builder()
                         .questionNoId((Integer)questionNoId)
@@ -239,12 +250,9 @@ public class ExportService {
             }
         }
         List<UserQuestionRelation> relationList = Transform.convert(userQuestionList, UserQuestionRelation.class);
-
-        List<QuestionNo> questionNoList = questionNoService.select(questionNoIds);
         Transform.combine(relationList, questionNoList, UserQuestionRelation.class, "questionNoId", "questionNo", QuestionNo.class, "id");
         Map questionNoMap = Transform.getMap(questionNoList, QuestionNo.class, "id", "questionId");
         Transform.combine(relationList, questionNoMap, UserQuestionRelation.class, "questionNoId", "questionId");
-        Collection questionIds = Transform.getIds(questionNoList, QuestionNo.class, "questionId");
         List<Question> questionList = questionService.select(questionIds);
         Transform.combine(relationList, questionList, UserQuestionRelation.class, "questionId", "question", Question.class, "id");