Bläddra i källkod

feat(front): 目录

Go 5 år sedan
förälder
incheckning
30853b4ca6
29 ändrade filer med 349 tillägg och 12 borttagningar
  1. 1 1
      front/project/www/index.js
  2. 1 1
      front/project/www/routes/my/message/page.js
  3. 11 0
      front/project/www/routes/page/export/index.js
  4. 3 0
      front/project/www/routes/page/export/index.less
  5. 3 1
      front/project/www/routes/page/index.js
  6. 11 0
      front/project/www/routes/page/ready/index.js
  7. 3 0
      front/project/www/routes/page/ready/index.less
  8. 3 1
      front/project/www/routes/question/index.js
  9. 11 0
      front/project/www/routes/question/search/index.js
  10. 3 0
      front/project/www/routes/question/search/index.less
  11. 11 0
      front/project/www/routes/question/searchHistory/index.js
  12. 3 0
      front/project/www/routes/question/searchHistory/index.less
  13. 5 1
      front/project/www/routes/textbook/index.js
  14. 11 0
      front/project/www/routes/textbook/main/index.js
  15. 3 0
      front/project/www/routes/textbook/main/index.less
  16. 11 0
      front/project/www/routes/textbook/topic/index.js
  17. 3 0
      front/project/www/routes/textbook/topic/index.less
  18. 11 0
      front/project/www/routes/textbook/topicDetail/index.js
  19. 3 0
      front/project/www/routes/textbook/topicDetail/index.less
  20. 11 0
      front/project/www/routes/textbook/year/index.js
  21. 3 0
      front/project/www/routes/textbook/year/index.less
  22. 11 3
      server/data/src/main/java/com/qxgmat/data/constants/enums/MessageCategory.java
  23. 140 0
      server/data/src/main/java/com/qxgmat/data/dao/entity/UserMessage.java
  24. 6 1
      server/data/src/main/java/com/qxgmat/data/dao/mapping/UserMessageMapper.xml
  25. 4 0
      server/data/src/main/resources/db/migration/V1__init_table.sql
  26. 5 0
      server/gateway-api/src/main/java/com/qxgmat/controller/api/AuthController.java
  27. 1 1
      server/gateway-api/src/main/java/com/qxgmat/controller/api/MyController.java
  28. 1 1
      server/gateway-api/src/main/java/com/qxgmat/help/SmsHelp.java
  29. 56 1
      server/gateway-api/src/main/java/com/qxgmat/service/extend/MessageExtendService.java

+ 1 - 1
front/project/www/index.js

@@ -11,7 +11,7 @@ export default {
     { key: 'ready', name: 'GetReady', path: '/ready' },
     { key: 'exercise', name: '练习', path: '/exercise' },
     { key: 'examination', name: 'CAT模考', path: '/examination' },
-    { key: 'questions', name: '题库', path: '/questions' },
+    { key: 'question', name: '题库', path: '/question' },
     { key: 'textbook', name: '换库机经', path: '/textbook' },
     { key: 'course', name: '课堂', path: '/course' },
   ],

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

@@ -21,7 +21,7 @@ const columns = [
     render: (text, row) => {
       return <div>
         {!row.isRead ? <span className='dot'>{text}</span> : text}
-        {row.content && <div className=''>{row.content}{row.link && <a className='m-l-5' href={row.link} target="_blank">查看详情</a>}</div>}
+        {row.content && <div className='ws-p'>{row.content}{row.link && <a className='m-l-5' href={row.link} target="_blank">{row.linkTitle || '查看详情'}</a>}{row.linkSecond && <a className='m-l-5' href={row.linkSecond} target="_blank">{row.linkSecondTitle || '查看详情'}</a>}</div>}
       </div>;
     },
   },

+ 11 - 0
front/project/www/routes/page/export/index.js

@@ -0,0 +1,11 @@
+export default {
+  path: '/export',
+  key: 'export',
+  title: '导出',
+  needLogin: false,
+  repeat: true,
+  hideHeader: true,
+  component() {
+    return import('./page');
+  },
+};

+ 3 - 0
front/project/www/routes/page/export/index.less

@@ -0,0 +1,3 @@
+@charset "utf-8";
+
+#export {}

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

@@ -4,5 +4,7 @@ import order from './order';
 import cart from './cart';
 import demo from './demo';
 import contract from './contract';
+import ready from './ready';
+import exportDetail from './export';
 
-export default [home, login, order, cart, demo, contract];
+export default [home, login, order, cart, demo, contract, ready, exportDetail];

+ 11 - 0
front/project/www/routes/page/ready/index.js

@@ -0,0 +1,11 @@
+export default {
+  path: '/ready',
+  key: 'ready',
+  title: 'GetReady',
+  needLogin: false,
+  repeat: true,
+  tab: 'ready',
+  component() {
+    return import('./page');
+  },
+};

+ 3 - 0
front/project/www/routes/page/ready/index.less

@@ -0,0 +1,3 @@
+@charset "utf-8";
+
+#ready {}

+ 3 - 1
front/project/www/routes/question/index.js

@@ -1,3 +1,5 @@
 import detail from './detail';
+import search from './search';
+import searchHistory from './searchHistory';
 
-export default [detail];
+export default [detail, search, searchHistory];

+ 11 - 0
front/project/www/routes/question/search/index.js

@@ -0,0 +1,11 @@
+export default {
+  path: '/question/search',
+  key: 'question-search',
+  title: '题库搜索',
+  needLogin: false,
+  repeat: true,
+  tab: 'question',
+  component() {
+    return import('./page');
+  },
+};

+ 3 - 0
front/project/www/routes/question/search/index.less

@@ -0,0 +1,3 @@
+@charset "utf-8";
+
+#question-search {}

+ 11 - 0
front/project/www/routes/question/searchHistory/index.js

@@ -0,0 +1,11 @@
+export default {
+  path: '/question/search',
+  key: 'question-search',
+  title: '题库搜索历史',
+  needLogin: true,
+  repeat: true,
+  tab: 'question',
+  component() {
+    return import('./page');
+  },
+};

+ 3 - 0
front/project/www/routes/question/searchHistory/index.less

@@ -0,0 +1,3 @@
+@charset "utf-8";
+
+#question-search {}

+ 5 - 1
front/project/www/routes/textbook/index.js

@@ -1,3 +1,7 @@
 import list from './list';
+import main from './main';
+import topic from './topic';
+import topicDetail from './topicDetail';
+import year from './year';
 
-export default [list];
+export default [list, main, topic, topicDetail, year];

+ 11 - 0
front/project/www/routes/textbook/main/index.js

@@ -0,0 +1,11 @@
+export default {
+  path: '/textbook/list',
+  key: 'textbook-index',
+  title: '机经首页',
+  needLogin: false,
+  repeat: true,
+  tab: 'textbook',
+  component() {
+    return import('./page');
+  },
+};

+ 3 - 0
front/project/www/routes/textbook/main/index.less

@@ -0,0 +1,3 @@
+@charset "utf-8";
+
+#textbook-index {}

+ 11 - 0
front/project/www/routes/textbook/topic/index.js

@@ -0,0 +1,11 @@
+export default {
+  path: '/textbook/topic',
+  key: 'textbook-topic',
+  title: '机经目录',
+  needLogin: false,
+  repeat: true,
+  tab: 'textbook',
+  component() {
+    return import('./page');
+  },
+};

+ 3 - 0
front/project/www/routes/textbook/topic/index.less

@@ -0,0 +1,3 @@
+@charset "utf-8";
+
+#textbook-topic {}

+ 11 - 0
front/project/www/routes/textbook/topicDetail/index.js

@@ -0,0 +1,11 @@
+export default {
+  path: '/textbook/topic/detail',
+  key: 'textbook-topic-detail',
+  title: '机经内容页',
+  needLogin: false,
+  repeat: true,
+  tab: 'textbook',
+  component() {
+    return import('./page');
+  },
+};

+ 3 - 0
front/project/www/routes/textbook/topicDetail/index.less

@@ -0,0 +1,3 @@
+@charset "utf-8";
+
+#textbook-topic-detail {}

+ 11 - 0
front/project/www/routes/textbook/year/index.js

@@ -0,0 +1,11 @@
+export default {
+  path: '/textbook/year',
+  key: 'textbook-year',
+  title: '年份换库表',
+  needLogin: false,
+  repeat: true,
+  tab: 'textbook',
+  component() {
+    return import('./page');
+  },
+};

+ 3 - 0
front/project/www/routes/textbook/year/index.less

@@ -0,0 +1,3 @@
+@charset "utf-8";
+
+#textbook-year {}

+ 11 - 3
server/data/src/main/java/com/qxgmat/data/constants/enums/MessageCategory.java

@@ -6,9 +6,9 @@ package com.qxgmat.data.constants.enums;
 public enum MessageCategory {
     REGISTER("register", "注册消息"),
     LOGIN_ABNORMAL("login_abnormal", "登录异常"),
-    TEXTBOOK_UPDATE("textbook_update","机经更新"),
+    TEXTBOOK_LIBRARY("textbook_library","机经换库"),
     PREVIEW_NOTICE("preview_notice", "预习作业提醒"),
-    PAYED("payed", "支付成功提醒"),
+
     DATA_UPDATE("data_update", "资料更新"),
     ASK_QUESTION("ask_question", "题目提问回复"),
     ASK_COURSE("ask_course", "课程提问回复"),
@@ -18,7 +18,15 @@ public enum MessageCategory {
     INVITED("invited", "邀请好友注册"),
     EMAIL_CHANGE("email_change", "邮箱变更"),
     EMAIL_UNNBIND("email_unbind", "邮箱解绑"),
-    EMAIL_BIND("email_bind", "邮箱绑定"),
+
+    COURSE_USE_EXPIRE("course_use_expire", "课程使用到期提醒"),
+    COURSE_EXPIRE("course_expire", "课程开通到期提醒"),
+
+    TEXTBOOK_USE_EXPIRE("textbook_use_expire", "机经使用到期提醒"),
+    TEXTBOOK_EXPIRE("textbook_expire", "机经开通到期提醒"),
+
+    QX_CAT_USE_EXPIRE("qx_cat_use_expire", "模考使用到期提醒"),
+    QX_CAT_EXPIRE("qx_cat_expire", "模考开通到期提醒"),
 
     CUSTOM("custom", "自定义消息")
     ;

+ 140 - 0
server/data/src/main/java/com/qxgmat/data/dao/entity/UserMessage.java

@@ -30,6 +30,12 @@ public class UserMessage implements Serializable {
     private String messageCategory;
 
     /**
+     * 关联id
+     */
+    @Column(name = "`relation_id`")
+    private Integer relationId;
+
+    /**
      * 标题
      */
     @Column(name = "`title`")
@@ -42,6 +48,24 @@ public class UserMessage implements Serializable {
     private String link;
 
     /**
+     * 链接标题
+     */
+    @Column(name = "`link_title`")
+    private String linkTitle;
+
+    /**
+     * 链接2
+     */
+    @Column(name = "`link_second`")
+    private String linkSecond;
+
+    /**
+     * 链接2标题
+     */
+    @Column(name = "`link_second_title`")
+    private String linkSecondTitle;
+
+    /**
      * 已读状态:0未读,1已读
      */
     @Column(name = "`is_read`")
@@ -127,6 +151,24 @@ public class UserMessage implements Serializable {
     }
 
     /**
+     * 获取关联id
+     *
+     * @return relation_id - 关联id
+     */
+    public Integer getRelationId() {
+        return relationId;
+    }
+
+    /**
+     * 设置关联id
+     *
+     * @param relationId 关联id
+     */
+    public void setRelationId(Integer relationId) {
+        this.relationId = relationId;
+    }
+
+    /**
      * 获取标题
      *
      * @return title - 标题
@@ -163,6 +205,60 @@ public class UserMessage implements Serializable {
     }
 
     /**
+     * 获取链接标题
+     *
+     * @return link_title - 链接标题
+     */
+    public String getLinkTitle() {
+        return linkTitle;
+    }
+
+    /**
+     * 设置链接标题
+     *
+     * @param linkTitle 链接标题
+     */
+    public void setLinkTitle(String linkTitle) {
+        this.linkTitle = linkTitle;
+    }
+
+    /**
+     * 获取链接2
+     *
+     * @return link_second - 链接2
+     */
+    public String getLinkSecond() {
+        return linkSecond;
+    }
+
+    /**
+     * 设置链接2
+     *
+     * @param linkSecond 链接2
+     */
+    public void setLinkSecond(String linkSecond) {
+        this.linkSecond = linkSecond;
+    }
+
+    /**
+     * 获取链接2标题
+     *
+     * @return link_second_title - 链接2标题
+     */
+    public String getLinkSecondTitle() {
+        return linkSecondTitle;
+    }
+
+    /**
+     * 设置链接2标题
+     *
+     * @param linkSecondTitle 链接2标题
+     */
+    public void setLinkSecondTitle(String linkSecondTitle) {
+        this.linkSecondTitle = linkSecondTitle;
+    }
+
+    /**
      * 获取已读状态:0未读,1已读
      *
      * @return is_read - 已读状态:0未读,1已读
@@ -222,8 +318,12 @@ public class UserMessage implements Serializable {
         sb.append(", userId=").append(userId);
         sb.append(", type=").append(type);
         sb.append(", messageCategory=").append(messageCategory);
+        sb.append(", relationId=").append(relationId);
         sb.append(", title=").append(title);
         sb.append(", link=").append(link);
+        sb.append(", linkTitle=").append(linkTitle);
+        sb.append(", linkSecond=").append(linkSecond);
+        sb.append(", linkSecondTitle=").append(linkSecondTitle);
         sb.append(", isRead=").append(isRead);
         sb.append(", createTime=").append(createTime);
         sb.append(", content=").append(content);
@@ -281,6 +381,16 @@ public class UserMessage implements Serializable {
         }
 
         /**
+         * 设置关联id
+         *
+         * @param relationId 关联id
+         */
+        public Builder relationId(Integer relationId) {
+            obj.setRelationId(relationId);
+            return this;
+        }
+
+        /**
          * 设置标题
          *
          * @param title 标题
@@ -301,6 +411,36 @@ public class UserMessage implements Serializable {
         }
 
         /**
+         * 设置链接2
+         *
+         * @param linkSecond 链接2
+         */
+        public Builder linkSecond(String linkSecond) {
+            obj.setLinkSecond(linkSecond);
+            return this;
+        }
+
+        /**
+         * 设置链接2标题
+         *
+         * @param linkSecondTitle 链接2标题
+         */
+        public Builder linkSecondTitle(String linkSecondTitle) {
+            obj.setLinkSecondTitle(linkSecondTitle);
+            return this;
+        }
+
+        /**
+         * 设置链接标题
+         *
+         * @param linkTitle 链接标题
+         */
+        public Builder linkTitle(String linkTitle) {
+            obj.setLinkTitle(linkTitle);
+            return this;
+        }
+
+        /**
          * 设置已读状态:0未读,1已读
          *
          * @param isRead 已读状态:0未读,1已读

+ 6 - 1
server/data/src/main/java/com/qxgmat/data/dao/mapping/UserMessageMapper.xml

@@ -9,8 +9,12 @@
     <result column="user_id" jdbcType="INTEGER" property="userId" />
     <result column="type" jdbcType="VARCHAR" property="type" />
     <result column="message_category" jdbcType="VARCHAR" property="messageCategory" />
+    <result column="relation_id" jdbcType="INTEGER" property="relationId" />
     <result column="title" jdbcType="VARCHAR" property="title" />
     <result column="link" jdbcType="VARCHAR" property="link" />
+    <result column="link_title" jdbcType="VARCHAR" property="linkTitle" />
+    <result column="link_second" jdbcType="VARCHAR" property="linkSecond" />
+    <result column="link_second_title" jdbcType="VARCHAR" property="linkSecondTitle" />
     <result column="is_read" jdbcType="INTEGER" property="isRead" />
     <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
   </resultMap>
@@ -24,7 +28,8 @@
     <!--
       WARNING - @mbg.generated
     -->
-    `id`, `user_id`, `type`, `message_category`, `title`, `link`, `is_read`, `create_time`
+    `id`, `user_id`, `type`, `message_category`, `relation_id`, `title`, `link`, `link_title`, 
+    `link_second`, `link_second_title`, `is_read`, `create_time`
   </sql>
   <sql id="Blob_Column_List">
     <!--

+ 4 - 0
server/data/src/main/resources/db/migration/V1__init_table.sql

@@ -1183,10 +1183,14 @@ CREATE TABLE user_message (
   id int(11) unsigned NOT NULL AUTO_INCREMENT,
   user_id int(11) NOT NULL DEFAULT '0' COMMENT '用户id',
   type varchar(50) NOT NULL DEFAULT '' COMMENT '消息',
+  relation_id int(11) NOT NULL DEFAULT '0' COMMENT '关联id',
   message_category varchar(50) NOT NULL DEFAULT '' COMMENT '消息类型',
   title varchar(50) NOT NULL DEFAULT '' COMMENT '标题',
   content text COMMENT '内容',
   link varchar(255) NOT NULL DEFAULT '' COMMENT '链接',
+  link_title varchar(20) NOT NULL DEFAULT '' COMMENT '链接标题',
+  link_second varchar(255) NOT NULL DEFAULT '' COMMENT '链接2',
+  link_second_title varchar(255) NOT NULL DEFAULT '' COMMENT '链接2标题',
   is_read tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '已读状态:0未读,1已读',
   create_time datetime DEFAULT NULL,
   PRIMARY KEY (id),

+ 5 - 0
server/gateway-api/src/main/java/com/qxgmat/controller/api/AuthController.java

@@ -22,6 +22,7 @@ import com.qxgmat.help.ShiroHelp;
 import com.qxgmat.help.SmsHelp;
 import com.qxgmat.service.UsersService;
 import com.qxgmat.service.UserServiceService;
+import com.qxgmat.service.extend.MessageExtendService;
 import com.qxgmat.service.extend.PreviewService;
 import com.qxgmat.service.inline.TextbookLibraryService;
 import com.qxgmat.service.inline.UserAbnormalService;
@@ -85,6 +86,9 @@ public class AuthController {
     @Autowired
     private PreviewService previewService;
 
+    @Autowired
+    private MessageExtendService messageExtendService;
+
 
     @RequestMapping(value = "/token", method = RequestMethod.POST)
     @ApiOperation(value = "验证token", httpMethod = "POST")
@@ -274,6 +278,7 @@ public class AuthController {
         // 未读消息
         Page<UserMessage> messageList = userMessageService.list(1, 4, user.getId(), null, 0);
         dto.setMessageNumber((int)messageList.getTotal());
+        messageExtendService.refreshMessage(messageList);
         dto.setMessages(messageList);
         // 未完成作业
         List<UserOrderRecord> recordList = userOrderRecordService.listWithCourse(1, 1000, null, null, true, false, null, null);

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

@@ -405,7 +405,7 @@ public class MyController {
     )  {
         User user = (User) shiroHelp.getLoginUser();
         Page<UserMessage> p = userMessageService.list(page, size, user.getId(), MessageType.ValueOf(messageType), read);
-
+        messageExtendService.refreshMessage(p);
         return ResponseHelp.success(p, page, size, p.getTotal());
     }
 

+ 1 - 1
server/gateway-api/src/main/java/com/qxgmat/help/SmsHelp.java

@@ -29,7 +29,7 @@ public class SmsHelp {
     final public String[] VALID_TEMPLATE = new String[]{"34888",""}; // yzm: 验证码
 
     final public String[] ABNORMAL_TEMPLATE = new String[]{"34889", ""}; //time: yyyy年MM月dd日hh:mm:ss
-    final public String[] COURSE_EXPIRE_TEMPLATE = new String[]{"34891",""}; // yhnc: 用户昵称 %date%: 格式为:yyyy年MM月dd日 wktfw: 未开通的服务名称
+    final public String[] EXPIRE_TEMPLATE = new String[]{"34891",""}; // yhnc: 用户昵称 %date%: 格式为:yyyy年MM月dd日 wktfw: 未开通的服务名称
     final public String[] COURSE_USE_EXPIRE_TEMPLATE = new String[]{"34893", ""}; // yhnc: 用户昵称 %kcmc%: 课程名称 %date%: 格式为:yyyy年MM月dd日
     final public String[] LIBRARY_TEMPLATE = new String[]{}; // 最新换库时间是%zx_date%日,上次换库时间是%sc_date%日,间隔%jgts%天,库长%kcts%天。获取机经: %jjdz% ,也可搜索微信订阅号“%dyh%”查阅机经。
 

+ 56 - 1
server/gateway-api/src/main/java/com/qxgmat/service/extend/MessageExtendService.java

@@ -7,6 +7,7 @@ import com.qxgmat.data.constants.enums.MessageType;
 import com.qxgmat.data.constants.enums.status.AnswerStatus;
 import com.qxgmat.data.dao.entity.*;
 import com.qxgmat.help.MailHelp;
+import com.qxgmat.help.SmsHelp;
 import com.qxgmat.help.WechatHelp;
 import com.qxgmat.service.inline.MessageTemplateService;
 import com.qxgmat.service.inline.UserMessageService;
@@ -29,6 +30,9 @@ public class MessageExtendService {
     private WechatHelp wechatHelp;
 
     @Resource
+    private SmsHelp smsHelp;
+
+    @Resource
     private UserMessageService userMessageService;
 
     @Resource
@@ -90,6 +94,57 @@ public class MessageExtendService {
     }
 
     private void sendSms(String area, String mobile, MessageCategory category, Map<String, String> params){
+        String[] template;
+        Map<String, String> smsParams = new HashMap<>();
+        SimpleDateFormat sdf;
+        String time;
+        switch(category){
+            case LOGIN_ABNORMAL:
+                template = smsHelp.ABNORMAL_TEMPLATE;
+                // time: yyyy年MM月dd日hh:mm:ss
+                sdf = new SimpleDateFormat("yyyy年MM月dd hh:mm:ss");
+                smsParams.put("time", sdf.format(params.get("time")));
+                break;
+            case TEXTBOOK_LIBRARY:
+                template = smsHelp.LIBRARY_TEMPLATE;
+                // 最新换库时间是%zx_date%日
+                // 上次换库时间是%sc_date%日
+                // 间隔%jgts%天,库长%kcts%天
+                // 获取机经: %jjdz%
+                // 也可搜索微信订阅号“%dyh%”查阅机经。
+                smsParams.put("dyh", "");
+                smsParams.put("jjdz", pcUrl+"/textbook");
+                break;
+            case COURSE_USE_EXPIRE:
+                template = smsHelp.COURSE_USE_EXPIRE_TEMPLATE;
+                // yhnc: 用户昵称
+                // %kcmc%: 课程名称
+                // %date%: 格式为:yyyy年MM月dd日
+                sdf = new SimpleDateFormat("yyyy年MM月dd");
+                smsParams.put("date", sdf.format(params.get("time")));
+                smsParams.put("yhnc", params.get("nickname"));
+                smsParams.put("kcmc", params.get("title"));
+                break;
+            case COURSE_EXPIRE:
+            case TEXTBOOK_EXPIRE:
+            case QX_CAT_EXPIRE:
+                template = smsHelp.EXPIRE_TEMPLATE;
+                // yhnc: 用户昵称
+                // %date%: 格式为:yyyy年MM月dd日
+                // wktfw: 未开通的服务名称
+                sdf = new SimpleDateFormat("yyyy年MM月dd");
+                smsParams.put("date", sdf.format(params.get("time")));
+                smsParams.put("yhnc", params.get("nickname"));
+                smsParams.put("wktfw", params.get("title"));
+                break;
+            default:
+                // 其余没有模版id,不发送
+                return;
+        }
+        smsHelp.send(area, mobile, template, smsParams);
+    }
+
+    public void refreshMessage(List<UserMessage> messageList){
 
     }
 
@@ -128,7 +183,7 @@ public class MessageExtendService {
      */
     public void sendTextbookUpdate(User user, TextbookLibrary textbookLibrary){
         Map<String, String> map = new HashMap<>();
-        send(user, MessageCategory.TEXTBOOK_UPDATE, map);
+        send(user, MessageCategory.TEXTBOOK_LIBRARY, map);
     }
 
     /**