tubinyan 5 лет назад
Сommit
f3781a86c9
100 измененных файлов с 7241 добавлено и 0 удалено
  1. 33 0
      .gitignore
  2. 118 0
      .mvn/wrapper/MavenWrapperDownloader.java
  3. BIN
      .mvn/wrapper/maven-wrapper.jar
  4. 2 0
      .mvn/wrapper/maven-wrapper.properties
  5. 10 0
      README.md
  6. 306 0
      courselearning.sql
  7. 310 0
      mvnw
  8. 182 0
      mvnw.cmd
  9. 113 0
      pom.xml
  10. 12 0
      src/main/java/cn/seecoder/courselearning/CourseLearningApplication.java
  11. 734 0
      src/main/java/cn/seecoder/courselearning/android/AndroidNotification.java
  12. 98 0
      src/main/java/cn/seecoder/courselearning/android/BadgeNotification.java
  13. 120 0
      src/main/java/cn/seecoder/courselearning/android/Button.java
  14. 150 0
      src/main/java/cn/seecoder/courselearning/android/ClickAction.java
  15. 105 0
      src/main/java/cn/seecoder/courselearning/android/Color.java
  16. 101 0
      src/main/java/cn/seecoder/courselearning/android/LightSettings.java
  17. 27 0
      src/main/java/cn/seecoder/courselearning/config/CorsConfig.java
  18. 89 0
      src/main/java/cn/seecoder/courselearning/config/DataSourceConfig.java
  19. 63 0
      src/main/java/cn/seecoder/courselearning/controller/CourseController.java
  20. 38 0
      src/main/java/cn/seecoder/courselearning/controller/CourseOrderController.java
  21. 29 0
      src/main/java/cn/seecoder/courselearning/controller/CourseWareController.java
  22. 27 0
      src/main/java/cn/seecoder/courselearning/controller/NotifyController.java
  23. 35 0
      src/main/java/cn/seecoder/courselearning/controller/UserController.java
  24. 21 0
      src/main/java/cn/seecoder/courselearning/controller/UserTokenController.java
  25. 5 0
      src/main/java/cn/seecoder/courselearning/enums/ExceptionType.java
  26. 48 0
      src/main/java/cn/seecoder/courselearning/enums/Importance.java
  27. 37 0
      src/main/java/cn/seecoder/courselearning/enums/TopicOperation.java
  28. 36 0
      src/main/java/cn/seecoder/courselearning/enums/Urgency.java
  29. 38 0
      src/main/java/cn/seecoder/courselearning/enums/Visibility.java
  30. 35 0
      src/main/java/cn/seecoder/courselearning/exception/HuaweiException.java
  31. 39 0
      src/main/java/cn/seecoder/courselearning/exception/HuaweiMessagingException.java
  32. 17 0
      src/main/java/cn/seecoder/courselearning/exception/MyException.java
  33. 22 0
      src/main/java/cn/seecoder/courselearning/mapper/CourseMapper.java
  34. 18 0
      src/main/java/cn/seecoder/courselearning/mapper/CourseOrderMapper.java
  35. 16 0
      src/main/java/cn/seecoder/courselearning/mapper/CourseWareMapper.java
  36. 16 0
      src/main/java/cn/seecoder/courselearning/mapper/RechargeOrderMapper.java
  37. 18 0
      src/main/java/cn/seecoder/courselearning/mapper/UserMapper.java
  38. 16 0
      src/main/java/cn/seecoder/courselearning/mapper/UserTokenMapper.java
  39. 200 0
      src/main/java/cn/seecoder/courselearning/message/AndroidConfig.java
  40. 214 0
      src/main/java/cn/seecoder/courselearning/message/Message.java
  41. 122 0
      src/main/java/cn/seecoder/courselearning/message/Notification.java
  42. 53 0
      src/main/java/cn/seecoder/courselearning/message/TokenMessage.java
  43. 96 0
      src/main/java/cn/seecoder/courselearning/message/TopicMessage.java
  44. 272 0
      src/main/java/cn/seecoder/courselearning/messaging/HuaweiApp.java
  45. 168 0
      src/main/java/cn/seecoder/courselearning/messaging/HuaweiCredential.java
  46. 39 0
      src/main/java/cn/seecoder/courselearning/messaging/HuaweiMessageClient.java
  47. 216 0
      src/main/java/cn/seecoder/courselearning/messaging/HuaweiMessageClientImpl.java
  48. 181 0
      src/main/java/cn/seecoder/courselearning/messaging/HuaweiMessaging.java
  49. 114 0
      src/main/java/cn/seecoder/courselearning/messaging/HuaweiOption.java
  50. 59 0
      src/main/java/cn/seecoder/courselearning/messaging/HuaweiScheduledExecutor.java
  51. 40 0
      src/main/java/cn/seecoder/courselearning/messaging/HuaweiService.java
  52. 96 0
      src/main/java/cn/seecoder/courselearning/messaging/HuaweiThreadManager.java
  53. 54 0
      src/main/java/cn/seecoder/courselearning/messaging/ImplHuaweiTrampolines.java
  54. 81 0
      src/main/java/cn/seecoder/courselearning/messaging/ThreadManager.java
  55. 96 0
      src/main/java/cn/seecoder/courselearning/messaging/TokenRefresher.java
  56. 95 0
      src/main/java/cn/seecoder/courselearning/model/Course.java
  57. 90 0
      src/main/java/cn/seecoder/courselearning/model/CourseOrder.java
  58. 105 0
      src/main/java/cn/seecoder/courselearning/model/CourseWare.java
  59. 57 0
      src/main/java/cn/seecoder/courselearning/model/RechargeOrder.java
  60. 69 0
      src/main/java/cn/seecoder/courselearning/model/User.java
  61. 45 0
      src/main/java/cn/seecoder/courselearning/model/UserToken.java
  62. 48 0
      src/main/java/cn/seecoder/courselearning/reponse/SendResponse.java
  63. 35 0
      src/main/java/cn/seecoder/courselearning/reponse/TopicListResponse.java
  64. 47 0
      src/main/java/cn/seecoder/courselearning/reponse/TopicSendResponse.java
  65. 12 0
      src/main/java/cn/seecoder/courselearning/service/CourseOrderService.java
  66. 17 0
      src/main/java/cn/seecoder/courselearning/service/CourseService.java
  67. 9 0
      src/main/java/cn/seecoder/courselearning/service/CourseWareService.java
  68. 7 0
      src/main/java/cn/seecoder/courselearning/service/SendNotifyService.java
  69. 11 0
      src/main/java/cn/seecoder/courselearning/service/UserService.java
  70. 5 0
      src/main/java/cn/seecoder/courselearning/service/UserTokenService.java
  71. 73 0
      src/main/java/cn/seecoder/courselearning/service/impl/CourseOrderServiceImpl.java
  72. 77 0
      src/main/java/cn/seecoder/courselearning/service/impl/CourseServiceImpl.java
  73. 39 0
      src/main/java/cn/seecoder/courselearning/service/impl/CourseWareServiceImpl.java
  74. 79 0
      src/main/java/cn/seecoder/courselearning/service/impl/SendNotifyServiceImpl.java
  75. 83 0
      src/main/java/cn/seecoder/courselearning/service/impl/UserServiceImpl.java
  76. 29 0
      src/main/java/cn/seecoder/courselearning/service/impl/UserTokenServiceImpl.java
  77. 35 0
      src/main/java/cn/seecoder/courselearning/util/CollectionUtils.java
  78. 23 0
      src/main/java/cn/seecoder/courselearning/util/Constant.java
  79. 19 0
      src/main/java/cn/seecoder/courselearning/util/DateUtil.java
  80. 79 0
      src/main/java/cn/seecoder/courselearning/util/IgnoreSSLUtils.java
  81. 35 0
      src/main/java/cn/seecoder/courselearning/util/InitAppUtils.java
  82. 52 0
      src/main/java/cn/seecoder/courselearning/util/MyBatisGeneratorUtil.java
  83. 29 0
      src/main/java/cn/seecoder/courselearning/util/PageInfoUtil.java
  84. 61 0
      src/main/java/cn/seecoder/courselearning/util/ResponceCodeProcesser.java
  85. 40 0
      src/main/java/cn/seecoder/courselearning/util/ValidatorUtils.java
  86. 37 0
      src/main/java/cn/seecoder/courselearning/vo/CourseOrderVO.java
  87. 56 0
      src/main/java/cn/seecoder/courselearning/vo/CourseVO.java
  88. 63 0
      src/main/java/cn/seecoder/courselearning/vo/CourseWareVO.java
  89. 57 0
      src/main/java/cn/seecoder/courselearning/vo/RechargeOrderVO.java
  90. 29 0
      src/main/java/cn/seecoder/courselearning/vo/ResultVO.java
  91. 26 0
      src/main/java/cn/seecoder/courselearning/vo/UserVO.java
  92. 22 0
      src/main/resources/application.yml
  93. 49 0
      src/main/resources/generatorConfig.xml
  94. 78 0
      src/main/resources/mapper/CourseMapper.xml
  95. 51 0
      src/main/resources/mapper/CourseOrderMapper.xml
  96. 55 0
      src/main/resources/mapper/CourseWareMapper.xml
  97. 36 0
      src/main/resources/mapper/RechargeOrderMapper.xml
  98. 42 0
      src/main/resources/mapper/UserMapper.xml
  99. 36 0
      src/main/resources/mapper/UserTokenMapper.xml
  100. 14 0
      src/main/resources/mybatis-config.xml

+ 33 - 0
.gitignore

@@ -0,0 +1,33 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/

+ 118 - 0
.mvn/wrapper/MavenWrapperDownloader.java

@@ -0,0 +1,118 @@
+/*
+ * Copyright 2007-present the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.net.*;
+import java.io.*;
+import java.nio.channels.*;
+import java.util.Properties;
+
+public class MavenWrapperDownloader {
+
+    private static final String WRAPPER_VERSION = "0.5.6";
+    /**
+     * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
+     */
+    private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
+            + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
+
+    /**
+     * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
+     * use instead of the default one.
+     */
+    private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
+            ".mvn/wrapper/maven-wrapper.properties";
+
+    /**
+     * Path where the maven-wrapper.jar will be saved to.
+     */
+    private static final String MAVEN_WRAPPER_JAR_PATH =
+            ".mvn/wrapper/maven-wrapper.jar";
+
+    /**
+     * Name of the property which should be used to override the default download url for the wrapper.
+     */
+    private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
+
+    public static void main(String args[]) {
+        System.out.println("- Downloader started");
+        File baseDirectory = new File(args[0]);
+        System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
+
+        // If the maven-wrapper.properties exists, read it and check if it contains a custom
+        // wrapperUrl parameter.
+        File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
+        String url = DEFAULT_DOWNLOAD_URL;
+        if (mavenWrapperPropertyFile.exists()) {
+            FileInputStream mavenWrapperPropertyFileInputStream = null;
+            try {
+                mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
+                Properties mavenWrapperProperties = new Properties();
+                mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
+                url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
+            } catch (IOException e) {
+                System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
+            } finally {
+                try {
+                    if (mavenWrapperPropertyFileInputStream != null) {
+                        mavenWrapperPropertyFileInputStream.close();
+                    }
+                } catch (IOException e) {
+                    // Ignore ...
+                }
+            }
+        }
+        System.out.println("- Downloading from: " + url);
+
+        File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
+        if (!outputFile.getParentFile().exists()) {
+            if (!outputFile.getParentFile().mkdirs()) {
+                System.out.println(
+                        "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
+            }
+        }
+        System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
+        try {
+            downloadFileFromURL(url, outputFile);
+            System.out.println("Done");
+            System.exit(0);
+        } catch (Throwable e) {
+            System.out.println("- Error downloading");
+            e.printStackTrace();
+            System.exit(1);
+        }
+    }
+
+    private static void downloadFileFromURL(String urlString, File destination) throws Exception {
+        if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
+            String username = System.getenv("MVNW_USERNAME");
+            char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
+            Authenticator.setDefault(new Authenticator() {
+                @Override
+                protected PasswordAuthentication getPasswordAuthentication() {
+                    return new PasswordAuthentication(username, password);
+                }
+            });
+        }
+        URL website = new URL(urlString);
+        ReadableByteChannel rbc;
+        rbc = Channels.newChannel(website.openStream());
+        FileOutputStream fos = new FileOutputStream(destination);
+        fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
+        fos.close();
+        rbc.close();
+    }
+
+}

BIN
.mvn/wrapper/maven-wrapper.jar


+ 2 - 0
.mvn/wrapper/maven-wrapper.properties

@@ -0,0 +1,2 @@
+distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
+wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar

+ 10 - 0
README.md

@@ -0,0 +1,10 @@
+### 项目说明
+这是为《华为HMS应用开发教程》HMS开发基础章节编写的一个案例的后端项目。
+
+该后端项目是用Java编写的Spring Boot项目,使用了mysql数据库,以MyBatis作为持久化层框架,另外为了实现华为APP的推送服务,引入了hms-push-serverdemo中的诸多工具类(可参考 https://github.com/HMS-Core/hms-push-serverdemo-java)。
+
+
+
+#### 文件说明
+
+根目录下的 courselearning.sql 存储了项目初始化需要的sql文件(包含了用于展示的部分数据),可将该文件内的所有sql语句在mysql命令行内执行后初始化数据库。

+ 306 - 0
courselearning.sql

@@ -0,0 +1,306 @@
+create database if not exists `courselearning` default charset utf8;
+
+use `courselearning` ;
+
+SET FOREIGN_KEY_CHECKS=0;
+
+-- ----------------------------
+-- Table structure for `course`
+-- ----------------------------
+DROP TABLE IF EXISTS `course`;
+CREATE TABLE `course` (
+  `id` int NOT NULL AUTO_INCREMENT,
+  `name` varchar(255) NOT NULL,
+  `type` varchar(255) DEFAULT NULL,
+  `intro` varchar(255) DEFAULT NULL,
+  `picture` varchar(255) DEFAULT NULL,
+  `provider` varchar(255) DEFAULT NULL,
+  `create_time` datetime NOT NULL,
+  `delete_time` datetime DEFAULT NULL,
+  `cost` int NOT NULL,
+  PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;
+
+-- ----------------------------
+-- Records of course
+-- ----------------------------
+INSERT INTO `course` VALUES ('1', '软件工程与计算 I', '中级', '通过Scheme、Python和Java语言,让你分别体会函数式编程范式、结构化编程范式和面向对象编程范式', 'course1.png', '南京大学', '2020-12-20 10:00:00', null, '1');
+INSERT INTO `course` VALUES ('2', '软件工程与计算 II', '中级', '基于DevOps培养团队开发中小规模软件系统的能力', 'course2.png', '南京大学', '2020-12-20 10:00:00', null, '1');
+INSERT INTO `course` VALUES ('3', '程序猿与攻城狮', '初级', '我们将由5位老师从不同的角度来说说他们对软件工程的理解。我们并非试图去覆盖所有软件工程的知识点,我们只是希望去让对软件工程有兴趣的你们了解到“我要学什么”“我应如何学”“我今后能做什么”这样一些基本的问题的部分答案。\r\n\r\n   刘钦老师会介绍软件工程的历史和软件工程建模;丁二玉老师会谈谈软件工程师和软件工程团队;冯桂焕老师会通过案例让大家体验人机交互的魅力;陈振宇老师会从概率统计讲到软件测试;刘嘉老师会娓娓道来他对最热门的移动互联网发展的本质的理解。', 'course3.jpg', '南京大学', '2020-12-20 10:00:00', null, '1');
+INSERT INTO `course` VALUES ('4', '基于Java的面向对象编程范式', '初级', '本课程完成了编程思维、结构化编程范式、面向对象编程方式的介绍,并且着重强调了面向对象编程中封装、协作和可修改性三个重要概念。通过客观题和6道编程题的训练,进一步加深对面向对象编程范式的理解,初步领略面向对象编程范式的风采。', 'course4.png', '南京大学', '2020-12-20 10:00:00', null, '1');
+INSERT INTO `course` VALUES ('5', '移动互联网软件工程', '高级', '本课程结合软件工程方法学,从移动互联网需求出发,结合现有的互联网企业产品架构分析,探讨移动互联网软件开发的各种关注点、应用架构基础。', 'no.png', '南京大学', '2020-12-20 10:00:00', null, '1');
+
+-- ----------------------------
+-- Table structure for `course_order`
+-- ----------------------------
+DROP TABLE IF EXISTS `course_order`;
+CREATE TABLE `course_order` (
+  `id` int NOT NULL AUTO_INCREMENT,
+  `cost` int NOT NULL,
+  `course_id` int NOT NULL,
+  `course_name` varchar(255) NOT NULL,
+  `create_time` datetime NOT NULL,
+  `user_id` varchar(255) NOT NULL,
+  `status` int NOT NULL,
+  PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+-- ----------------------------
+-- Table structure for `course_ware`
+-- ----------------------------
+DROP TABLE IF EXISTS `course_ware`;
+CREATE TABLE `course_ware` (
+  `id` int NOT NULL AUTO_INCREMENT,
+  `course_id` int NOT NULL,
+  `number` int NOT NULL,
+  `title` varchar(255) NOT NULL,
+  `file_name` varchar(255) DEFAULT NULL,
+  `file_type` varchar(255) DEFAULT NULL,
+  `file_size` varchar(255) DEFAULT NULL,
+  `free_flag` tinyint(1) NOT NULL DEFAULT '0',
+  `download_flag` tinyint(1) NOT NULL DEFAULT '1',
+  `upload_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
+  PRIMARY KEY (`id`),
+  KEY `FK_fk_course_courseware` (`course_id`),
+  CONSTRAINT `FK_fk_course_courseware` FOREIGN KEY (`course_id`) REFERENCES `course` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB AUTO_INCREMENT=198 DEFAULT CHARSET=utf8;
+
+-- ----------------------------
+-- Records of course_ware
+-- ----------------------------
+INSERT INTO `course_ware` VALUES ('2', '1', '1', '00 - Overview', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('3', '1', '2', '01 - 编程语言概述', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('4', '1', '3', '02 - 编程基础 I-分解与抽象', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('5', '1', '4', '03 - 编程基础 II-可计算性', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('6', '1', '5', '04 - 编程基础 III-Lambda演算', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('7', '1', '6', '05 - 编程基础 IV-函数式编程范式', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('8', '1', '7', '06 - 编程基础 V-习题课', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('9', '1', '8', '07 - 结构化编程 I - 思想', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('10', '1', '9', '08 - 结构化编程 II - 变量', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('11', '1', '10', '09 - 结构化编程 III - 方法', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('12', '1', '11', '10 - 面向对象编程 I-思想', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('13', '1', '12', '11 - 面向对象编程 II-封装', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('14', '1', '13', '12 - 面向对象编程 III-协作', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('15', '1', '14', '13 - 软件工程建模', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('16', '1', '15', '14 - JVM和字节码基础', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('17', '1', '16', '15 - 面向对象编程III-继承与多态', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('18', '1', '17', '16 - 面向对象编程 IV-可修改性', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('19', '1', '18', '17 - 面向对象编程 V-接口', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('20', '1', '19', '18 - 异常', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('21', '1', '20', '19 - Network and Thread', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('22', '1', '21', '20 - Graphical User Interface', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('23', '1', '22', 'Git介绍', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('24', '1', '23', 'Java编程基础', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('25', '1', '24', 'Lab01-环境配置', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('26', '1', '25', 'Lab02-Seec系统', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('27', '1', '26', 'Lab03-简单分支和循环的训练', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('28', '1', '27', 'Lab04-Anagram', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('29', '1', '28', 'Lab05-arrival_of_general', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('30', '1', '29', 'Lab06-Taxi', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('31', '1', '30', 'Programming-01-Basics', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('32', '1', '31', 'Programming-02-Variable & Type', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('33', '1', '32', 'Programming-03-Control Flow', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('34', '1', '33', 'Programming-04-Method', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('35', '1', '34', 'Programming-05-Module', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('36', '1', '35', 'Programming-06-Composite Data', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('37', '1', '36', 'Programming-07-Input & Output', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('38', '1', '37', 'Programming-08-Lambda and Functional Programming', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('39', '1', '38', 'Programming-09-Simulation and Calculation', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('40', '1', '39', 'Python-01-HelloWorld和Variable', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('41', '1', '40', 'Python-02-控制流', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('42', '1', '41', 'Python-03-函数', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('43', '1', '42', 'Python-04-模块', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('44', '1', '43', 'Python-05-复合数据', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('45', '1', '44', 'Python-06-输入输出', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('46', '1', '45', 'Python-07-Lambda and Functional Programming', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('47', '1', '46', 'Reference-01-Byte-of-Python', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('48', '1', '47', 'Reference-02-Turing, His Machine and Computability', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('49', '1', '48', 'Reference-03-Register Machines are Turing Machines', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('50', '1', '49', 'Reference-04-Lambda', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('51', '1', '50', 'Z总结', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('52', '1', '51', '谷歌软件工程', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('53', '1', '52', '软件工程守破离', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('54', '2', '1', '00-Overview', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('55', '2', '2', '01-软件工程基础', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('56', '2', '3', '02-软件工程的发展', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('57', '2', '4', '04-项目启动', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('58', '2', '5', '05-需求基础', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('59', '2', '6', '06-需求分析方法', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('60', '2', '7', '07-需求文档化与验证', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('61', '2', '8', '08-软件设计基础', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('62', '2', '9', '09-软件体系结构基础', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('63', '2', '10', '10-软件体系结构设计与构建', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('64', '2', '11', '11-人机交互', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('65', '2', '12', '12-详细设计', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('66', '2', '13', '13-模块化与信息隐藏', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('67', '2', '14', '14-面向对象的模块化', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('68', '2', '15', '15-面向对象的信息隐藏', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('69', '2', '16', '16-设计模式', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('70', '2', '17', '16工厂设计模式', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('71', '2', '18', '16设计模式练习', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('72', '2', '19', '17-软件构造', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('73', '2', '20', '18-代码设计', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('74', '2', '21', '19-软件测试', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('75', '2', '22', '20-软件交付', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('76', '2', '23', '21-软件维护与演化', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('77', '2', '24', '22-软件开发过程模型', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('78', '2', '25', '23-软件工程职业基础', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('79', '2', '26', 'Homework01-软工二大作业迭代一功能需求简述', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('80', '2', '27', 'Ref-01-SEEC系统课程与小组说明', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('81', '2', '28', 'Ref-02-代码作业使用说明', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('82', '2', '29', 'Review01-用例文档点评', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('83', '2', '30', 'Review02-需求规格点评', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('84', '2', '31', 'Review03-体系结构', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('85', '2', '32', 'Web开发-01-浏览器的渲染原理', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('86', '2', '33', 'Web开发-02-HTTP协议原理', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('87', '2', '34', 'Web开发-03-Tomcat和Servlet原理', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('88', '2', '35', 'Web开发-04-REST和JSON', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('89', '2', '36', 'Web开发-05-Springboot入门', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('90', '2', '37', 'Web开发-06-GUI入门', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('91', '2', '38', 'Web开发-07-数据设计', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('92', '2', '39', 'Web开发-08-MVC-MVP-MVVM', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('93', '2', '40', 'Web开发-09-Vue实战--前端', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('94', '2', '41', 'Web开发-10-Springboot+Mybatis--后端', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('95', '2', '42', '复习提纲', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('96', '3', '1', '软件工程历史和软件工程建模', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('97', '3', '2', '软件工程历史', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('98', '3', '3', '数学和计算机建模', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('99', '3', '4', '软件工程建模', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('100', '3', '5', '编程思想', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('101', '3', '6', '测试一', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('102', '3', '7', '软件工程师和软件工程团队', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('103', '3', '8', '软件工程师是做什么的 上集', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('104', '3', '9', '软件工程师是做什么的 下集', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('105', '3', '10', '软件工程团队的三驾马车', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('106', '3', '11', '软件工程团队的其他重要角色', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('107', '3', '12', '测试二', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('108', '3', '13', '人机交互', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('109', '3', '14', '人机交互概述', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('110', '3', '15', '启发式设计原则', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('111', '3', '16', '人机交互的软件工程方法—— 启发式评估', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('112', '3', '17', '测试三', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('113', '3', '18', '概率统计到软件测试', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('114', '3', '19', '数字与计算', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('115', '3', '20', '计算与概率', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('116', '3', '21', '概率与测试', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('117', '3', '22', '测试与生活', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('118', '3', '23', '生活与数字', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('119', '3', '24', '测试四', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('120', '3', '25', '移动互联网本质', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('121', '3', '26', '连接', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('122', '3', '27', '时间', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('123', '3', '28', '未来', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('124', '3', '29', '本质', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('125', '4', '1', '1 - 编程之前', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('126', '4', '2', '1-01-科学思维vs工程思维', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('127', '4', '3', '1-02-数学建模', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('128', '4', '4', '1-03-计算机建模 1', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('129', '4', '5', '1-04-计算机建模 2', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('130', '4', '6', '1-05-软件工程建模', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('131', '4', '7', '1-06-软件开发生命周期模型', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('132', '4', '8', '1-07-分解与抽象', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('133', '4', '9', '1-08-层次性', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('134', '4', '10', '1-09-HelloWorld', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('135', '4', '11', '1-10-代码是用来读的', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('136', '4', '12', '1-11-有代码就得有测试', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('137', '4', '13', '1-12-用例来给需求建模', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('138', '4', '14', '第一单元 单元测试', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('139', '4', '15', '2 - 结构化编程范式', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('140', '4', '16', '2-01-结构化编程思想', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('141', '4', '17', '2-02-数据流图', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('142', '4', '18', '2-03-结构图', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('143', '4', '19', '2-04-数据流图向结构图的转变', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('144', '4', '20', '2-05-顺序、循环、分支', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('145', '4', '21', '2-06-MatrixCalculation', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('146', '4', '22', '2-07-避免重复', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('147', '4', '23', '2-08-测试分支和循环', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('148', '4', '24', '第二单元 单元测试', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('149', '4', '25', '3 - 面向对象编程范式', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('150', '4', '26', '3-01-变更时不可以避免的', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('151', '4', '27', '3-02-大范围的修改vs有限范围', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('152', '4', '28', '3-03-面向对象的世界观', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('153', '4', '29', '3-04-类和对象', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('154', '4', '30', '3-05-BadMatrix', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('155', '4', '31', '3-06-重用', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('156', '4', '32', '3-07-测试单个类', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('157', '4', '33', '第三单元 单元测试', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('158', '4', '34', '4 - 类的封装', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('159', '4', '35', '4-01-在一起', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('160', '4', '36', '4-02-封装', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('161', '4', '37', '4-03-MyMatrix', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('162', '4', '38', '4-04-寻找类和对象', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('163', '4', '39', '4-05-用类图表达类的职责', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('164', '4', '40', '4-06-防御式编程', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('165', '4', '41', '4-07-静态变量和静态方法', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('166', '4', '42', '4-08-简单类的初始化', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('167', '4', '43', '第四单元 单元测试', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('168', '4', '44', '5 - 类的协作', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('169', '4', '45', '5-01-职责', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('170', '4', '46', '5-02-协作', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('171', '4', '47', '5-03-类之间的关系', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('172', '4', '48', '5-04-TicTacToe', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('173', '4', '49', '5-05-用顺序图表达类的协作', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('174', '4', '50', '5-06-用Mock Object来辅助测试协作', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('175', '4', '51', '第五单元 单元测验', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('176', '4', '52', '6-类的可重用和可修改', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('177', '4', '53', '6-01-可修改性', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('178', '4', '54', '6-02-继承', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('179', '4', '55', '6-03-多态', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('180', '4', '56', '6-04-抽象类和抽象方法', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('181', '4', '57', '6-05-接口', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('182', '4', '58', '6-06-NewTicTacToe', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('183', '4', '59', '6-07-继承和组合', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('184', '4', '60', '6-08-按接口编程', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('185', '4', '61', '6-09-实现可修改性', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('186', '4', '62', '6-10-复杂类的初始化', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('187', '5', '1', '00 - 关于课程', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('188', '5', '2', '01 - 软件工程方法学', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('189', '5', '3', '02 - 移动互联网需求分析', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('190', '5', '4', '03 - 移动互联网公司架构分析I - 架构视角', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('191', '5', '5', '04 - 移动互联网架构分析II - 关注点', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('192', '5', '6', '05 - 移动互联网应用App体系结构设计', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('193', '5', '7', '06 - 移动互联网商业视角', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('194', '5', '8', '07 - UI设计', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('195', '5', '9', '08 - 秒杀系统', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('196', '5', '10', '09 - 敏捷软件开发', null, null, null, '0', '1', '2020-12-18 10:00:00');
+INSERT INTO `course_ware` VALUES ('197', '5', '11', '10 - 微服务', null, null, null, '0', '1', '2020-12-18 10:00:00');
+
+-- ----------------------------
+-- Table structure for `recharge_order`
+-- ----------------------------
+DROP TABLE IF EXISTS `recharge_order`;
+CREATE TABLE `recharge_order` (
+  `order_id` varchar(255) NOT NULL,
+  `uid` varchar(255) NOT NULL,
+  `value` int NOT NULL,
+  `create_time` datetime NOT NULL,
+  PRIMARY KEY (`order_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+-- ----------------------------
+-- Table structure for `user_info`
+-- ----------------------------
+DROP TABLE IF EXISTS `user_info`;
+CREATE TABLE `user_info` (
+  `uid` varchar(255) NOT NULL,
+  `uname` varchar(255) NOT NULL,
+  `picture` varchar(255) DEFAULT NULL,
+  `create_time` datetime NOT NULL,
+  `balance` int NOT NULL,
+  PRIMARY KEY (`uid`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+-- ----------------------------------
+-- Table structure for `user_token`
+-- ----------------------------------
+
+DROP TABLE IF EXISTS `user_token`;
+CREATE TABLE `user_token` (
+  `uid` varchar(255) NOT NULL,
+  `token` varchar(255) NOT NULL,
+  `update_time` datetime NOT NULL,
+  `active` tinyint(1) NOT NULL,
+  PRIMARY KEY (`uid`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+SET FOREIGN_KEY_CHECKS=1;

+ 310 - 0
mvnw

@@ -0,0 +1,310 @@
+#!/bin/sh
+# ----------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#    https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# ----------------------------------------------------------------------------
+
+# ----------------------------------------------------------------------------
+# Maven Start Up Batch script
+#
+# Required ENV vars:
+# ------------------
+#   JAVA_HOME - location of a JDK home dir
+#
+# Optional ENV vars
+# -----------------
+#   M2_HOME - location of maven2's installed home dir
+#   MAVEN_OPTS - parameters passed to the Java VM when running Maven
+#     e.g. to debug Maven itself, use
+#       set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
+#   MAVEN_SKIP_RC - flag to disable loading of mavenrc files
+# ----------------------------------------------------------------------------
+
+if [ -z "$MAVEN_SKIP_RC" ] ; then
+
+  if [ -f /etc/mavenrc ] ; then
+    . /etc/mavenrc
+  fi
+
+  if [ -f "$HOME/.mavenrc" ] ; then
+    . "$HOME/.mavenrc"
+  fi
+
+fi
+
+# OS specific support.  $var _must_ be set to either true or false.
+cygwin=false;
+darwin=false;
+mingw=false
+case "`uname`" in
+  CYGWIN*) cygwin=true ;;
+  MINGW*) mingw=true;;
+  Darwin*) darwin=true
+    # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
+    # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
+    if [ -z "$JAVA_HOME" ]; then
+      if [ -x "/usr/libexec/java_home" ]; then
+        export JAVA_HOME="`/usr/libexec/java_home`"
+      else
+        export JAVA_HOME="/Library/Java/Home"
+      fi
+    fi
+    ;;
+esac
+
+if [ -z "$JAVA_HOME" ] ; then
+  if [ -r /etc/gentoo-release ] ; then
+    JAVA_HOME=`java-config --jre-home`
+  fi
+fi
+
+if [ -z "$M2_HOME" ] ; then
+  ## resolve links - $0 may be a link to maven's home
+  PRG="$0"
+
+  # need this for relative symlinks
+  while [ -h "$PRG" ] ; do
+    ls=`ls -ld "$PRG"`
+    link=`expr "$ls" : '.*-> \(.*\)$'`
+    if expr "$link" : '/.*' > /dev/null; then
+      PRG="$link"
+    else
+      PRG="`dirname "$PRG"`/$link"
+    fi
+  done
+
+  saveddir=`pwd`
+
+  M2_HOME=`dirname "$PRG"`/..
+
+  # make it fully qualified
+  M2_HOME=`cd "$M2_HOME" && pwd`
+
+  cd "$saveddir"
+  # echo Using m2 at $M2_HOME
+fi
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched
+if $cygwin ; then
+  [ -n "$M2_HOME" ] &&
+    M2_HOME=`cygpath --unix "$M2_HOME"`
+  [ -n "$JAVA_HOME" ] &&
+    JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+  [ -n "$CLASSPATH" ] &&
+    CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
+fi
+
+# For Mingw, ensure paths are in UNIX format before anything is touched
+if $mingw ; then
+  [ -n "$M2_HOME" ] &&
+    M2_HOME="`(cd "$M2_HOME"; pwd)`"
+  [ -n "$JAVA_HOME" ] &&
+    JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
+fi
+
+if [ -z "$JAVA_HOME" ]; then
+  javaExecutable="`which javac`"
+  if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
+    # readlink(1) is not available as standard on Solaris 10.
+    readLink=`which readlink`
+    if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
+      if $darwin ; then
+        javaHome="`dirname \"$javaExecutable\"`"
+        javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
+      else
+        javaExecutable="`readlink -f \"$javaExecutable\"`"
+      fi
+      javaHome="`dirname \"$javaExecutable\"`"
+      javaHome=`expr "$javaHome" : '\(.*\)/bin'`
+      JAVA_HOME="$javaHome"
+      export JAVA_HOME
+    fi
+  fi
+fi
+
+if [ -z "$JAVACMD" ] ; then
+  if [ -n "$JAVA_HOME"  ] ; then
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+      # IBM's JDK on AIX uses strange locations for the executables
+      JAVACMD="$JAVA_HOME/jre/sh/java"
+    else
+      JAVACMD="$JAVA_HOME/bin/java"
+    fi
+  else
+    JAVACMD="`which java`"
+  fi
+fi
+
+if [ ! -x "$JAVACMD" ] ; then
+  echo "Error: JAVA_HOME is not defined correctly." >&2
+  echo "  We cannot execute $JAVACMD" >&2
+  exit 1
+fi
+
+if [ -z "$JAVA_HOME" ] ; then
+  echo "Warning: JAVA_HOME environment variable is not set."
+fi
+
+CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
+
+# traverses directory structure from process work directory to filesystem root
+# first directory with .mvn subdirectory is considered project base directory
+find_maven_basedir() {
+
+  if [ -z "$1" ]
+  then
+    echo "Path not specified to find_maven_basedir"
+    return 1
+  fi
+
+  basedir="$1"
+  wdir="$1"
+  while [ "$wdir" != '/' ] ; do
+    if [ -d "$wdir"/.mvn ] ; then
+      basedir=$wdir
+      break
+    fi
+    # workaround for JBEAP-8937 (on Solaris 10/Sparc)
+    if [ -d "${wdir}" ]; then
+      wdir=`cd "$wdir/.."; pwd`
+    fi
+    # end of workaround
+  done
+  echo "${basedir}"
+}
+
+# concatenates all lines of a file
+concat_lines() {
+  if [ -f "$1" ]; then
+    echo "$(tr -s '\n' ' ' < "$1")"
+  fi
+}
+
+BASE_DIR=`find_maven_basedir "$(pwd)"`
+if [ -z "$BASE_DIR" ]; then
+  exit 1;
+fi
+
+##########################################################################################
+# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
+# This allows using the maven wrapper in projects that prohibit checking in binary data.
+##########################################################################################
+if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
+    if [ "$MVNW_VERBOSE" = true ]; then
+      echo "Found .mvn/wrapper/maven-wrapper.jar"
+    fi
+else
+    if [ "$MVNW_VERBOSE" = true ]; then
+      echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
+    fi
+    if [ -n "$MVNW_REPOURL" ]; then
+      jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
+    else
+      jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
+    fi
+    while IFS="=" read key value; do
+      case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
+      esac
+    done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
+    if [ "$MVNW_VERBOSE" = true ]; then
+      echo "Downloading from: $jarUrl"
+    fi
+    wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
+    if $cygwin; then
+      wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
+    fi
+
+    if command -v wget > /dev/null; then
+        if [ "$MVNW_VERBOSE" = true ]; then
+          echo "Found wget ... using wget"
+        fi
+        if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
+            wget "$jarUrl" -O "$wrapperJarPath"
+        else
+            wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath"
+        fi
+    elif command -v curl > /dev/null; then
+        if [ "$MVNW_VERBOSE" = true ]; then
+          echo "Found curl ... using curl"
+        fi
+        if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
+            curl -o "$wrapperJarPath" "$jarUrl" -f
+        else
+            curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
+        fi
+
+    else
+        if [ "$MVNW_VERBOSE" = true ]; then
+          echo "Falling back to using Java to download"
+        fi
+        javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
+        # For Cygwin, switch paths to Windows format before running javac
+        if $cygwin; then
+          javaClass=`cygpath --path --windows "$javaClass"`
+        fi
+        if [ -e "$javaClass" ]; then
+            if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
+                if [ "$MVNW_VERBOSE" = true ]; then
+                  echo " - Compiling MavenWrapperDownloader.java ..."
+                fi
+                # Compiling the Java class
+                ("$JAVA_HOME/bin/javac" "$javaClass")
+            fi
+            if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
+                # Running the downloader
+                if [ "$MVNW_VERBOSE" = true ]; then
+                  echo " - Running MavenWrapperDownloader.java ..."
+                fi
+                ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
+            fi
+        fi
+    fi
+fi
+##########################################################################################
+# End of extension
+##########################################################################################
+
+export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
+if [ "$MVNW_VERBOSE" = true ]; then
+  echo $MAVEN_PROJECTBASEDIR
+fi
+MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin; then
+  [ -n "$M2_HOME" ] &&
+    M2_HOME=`cygpath --path --windows "$M2_HOME"`
+  [ -n "$JAVA_HOME" ] &&
+    JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
+  [ -n "$CLASSPATH" ] &&
+    CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
+  [ -n "$MAVEN_PROJECTBASEDIR" ] &&
+    MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
+fi
+
+# Provide a "standardized" way to retrieve the CLI args that will
+# work with both Windows and non-Windows executions.
+MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
+export MAVEN_CMD_LINE_ARGS
+
+WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
+
+exec "$JAVACMD" \
+  $MAVEN_OPTS \
+  -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
+  "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
+  ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"

+ 182 - 0
mvnw.cmd

@@ -0,0 +1,182 @@
+@REM ----------------------------------------------------------------------------
+@REM Licensed to the Apache Software Foundation (ASF) under one
+@REM or more contributor license agreements.  See the NOTICE file
+@REM distributed with this work for additional information
+@REM regarding copyright ownership.  The ASF licenses this file
+@REM to you under the Apache License, Version 2.0 (the
+@REM "License"); you may not use this file except in compliance
+@REM with the License.  You may obtain a copy of the License at
+@REM
+@REM    https://www.apache.org/licenses/LICENSE-2.0
+@REM
+@REM Unless required by applicable law or agreed to in writing,
+@REM software distributed under the License is distributed on an
+@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+@REM KIND, either express or implied.  See the License for the
+@REM specific language governing permissions and limitations
+@REM under the License.
+@REM ----------------------------------------------------------------------------
+
+@REM ----------------------------------------------------------------------------
+@REM Maven Start Up Batch script
+@REM
+@REM Required ENV vars:
+@REM JAVA_HOME - location of a JDK home dir
+@REM
+@REM Optional ENV vars
+@REM M2_HOME - location of maven2's installed home dir
+@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
+@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
+@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
+@REM     e.g. to debug Maven itself, use
+@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
+@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
+@REM ----------------------------------------------------------------------------
+
+@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
+@echo off
+@REM set title of command window
+title %0
+@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
+@if "%MAVEN_BATCH_ECHO%" == "on"  echo %MAVEN_BATCH_ECHO%
+
+@REM set %HOME% to equivalent of $HOME
+if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
+
+@REM Execute a user defined script before this one
+if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
+@REM check for pre script, once with legacy .bat ending and once with .cmd ending
+if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
+if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
+:skipRcPre
+
+@setlocal
+
+set ERROR_CODE=0
+
+@REM To isolate internal variables from possible post scripts, we use another setlocal
+@setlocal
+
+@REM ==== START VALIDATION ====
+if not "%JAVA_HOME%" == "" goto OkJHome
+
+echo.
+echo Error: JAVA_HOME not found in your environment. >&2
+echo Please set the JAVA_HOME variable in your environment to match the >&2
+echo location of your Java installation. >&2
+echo.
+goto error
+
+:OkJHome
+if exist "%JAVA_HOME%\bin\java.exe" goto init
+
+echo.
+echo Error: JAVA_HOME is set to an invalid directory. >&2
+echo JAVA_HOME = "%JAVA_HOME%" >&2
+echo Please set the JAVA_HOME variable in your environment to match the >&2
+echo location of your Java installation. >&2
+echo.
+goto error
+
+@REM ==== END VALIDATION ====
+
+:init
+
+@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
+@REM Fallback to current working directory if not found.
+
+set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
+IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
+
+set EXEC_DIR=%CD%
+set WDIR=%EXEC_DIR%
+:findBaseDir
+IF EXIST "%WDIR%"\.mvn goto baseDirFound
+cd ..
+IF "%WDIR%"=="%CD%" goto baseDirNotFound
+set WDIR=%CD%
+goto findBaseDir
+
+:baseDirFound
+set MAVEN_PROJECTBASEDIR=%WDIR%
+cd "%EXEC_DIR%"
+goto endDetectBaseDir
+
+:baseDirNotFound
+set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
+cd "%EXEC_DIR%"
+
+:endDetectBaseDir
+
+IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
+
+@setlocal EnableExtensions EnableDelayedExpansion
+for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
+@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
+
+:endReadAdditionalConfig
+
+SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
+set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
+set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
+
+set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
+
+FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
+    IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
+)
+
+@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
+@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
+if exist %WRAPPER_JAR% (
+    if "%MVNW_VERBOSE%" == "true" (
+        echo Found %WRAPPER_JAR%
+    )
+) else (
+    if not "%MVNW_REPOURL%" == "" (
+        SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
+    )
+    if "%MVNW_VERBOSE%" == "true" (
+        echo Couldn't find %WRAPPER_JAR%, downloading it ...
+        echo Downloading from: %DOWNLOAD_URL%
+    )
+
+    powershell -Command "&{"^
+		"$webclient = new-object System.Net.WebClient;"^
+		"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
+		"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
+		"}"^
+		"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
+		"}"
+    if "%MVNW_VERBOSE%" == "true" (
+        echo Finished downloading %WRAPPER_JAR%
+    )
+)
+@REM End of extension
+
+@REM Provide a "standardized" way to retrieve the CLI args that will
+@REM work with both Windows and non-Windows executions.
+set MAVEN_CMD_LINE_ARGS=%*
+
+%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
+if ERRORLEVEL 1 goto error
+goto end
+
+:error
+set ERROR_CODE=1
+
+:end
+@endlocal & set ERROR_CODE=%ERROR_CODE%
+
+if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
+@REM check for post script, once with legacy .bat ending and once with .cmd ending
+if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
+if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
+:skipRcPost
+
+@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
+if "%MAVEN_BATCH_PAUSE%" == "on" pause
+
+if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
+
+exit /B %ERROR_CODE%

+ 113 - 0
pom.xml

@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>2.4.1</version>
+        <relativePath/> <!-- lookup parent from repository -->
+    </parent>
+    <groupId>cn.seecoder</groupId>
+    <artifactId>courselearning</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+    <name>courseLearning</name>
+    <description>Demo project for Spring Boot</description>
+
+    <properties>
+        <java.version>1.8</java.version>
+    </properties>
+
+    <dependencies>
+        <!--spring boot mybatis-->
+        <dependency>
+            <groupId>org.mybatis.spring.boot</groupId>
+            <artifactId>mybatis-spring-boot-starter</artifactId>
+            <version>2.1.4</version>
+        </dependency>
+        <!--spring boot web-->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+        <!--mysql-->
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+            <scope>runtime</scope>
+        </dependency>
+        <!--mybatis自动生成实体类、映射表 -->
+        <dependency>
+            <groupId>org.mybatis.generator</groupId>
+            <artifactId>mybatis-generator-core</artifactId>
+            <version>1.3.5</version>
+        </dependency>
+        <!--与mybatis配合使用的分页插件-->
+        <dependency>
+            <groupId>com.github.pagehelper</groupId>
+            <artifactId>pagehelper</artifactId>
+            <version>5.0.0</version>
+        </dependency>
+        <!--c3p0数据源-->
+        <!-- https://mvnrepository.com/artifact/com.mchange/c3p0 -->
+        <dependency>
+            <groupId>com.mchange</groupId>
+            <artifactId>c3p0</artifactId>
+            <version>0.9.5.2</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+            <version>3.9</version>
+        </dependency>
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+            <version>26.0-jre</version>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <version>1.7.26</version>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+            <version>1.2.62</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+            <version>4.5.7</version>
+        </dependency>
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <configuration>
+                    <excludes>
+                        <exclude>
+                            <groupId>org.projectlombok</groupId>
+                            <artifactId>lombok</artifactId>
+                        </exclude>
+                    </excludes>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

+ 12 - 0
src/main/java/cn/seecoder/courselearning/CourseLearningApplication.java

@@ -0,0 +1,12 @@
+package cn.seecoder.courselearning;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class CourseLearningApplication {
+
+    public static void main(String[] args) {
+        SpringApplication.run(CourseLearningApplication.class, args);
+    }
+
+}

+ 734 - 0
src/main/java/cn/seecoder/courselearning/android/AndroidNotification.java

@@ -0,0 +1,734 @@
+/*
+ * Copyright 2020. Huawei Technologies Co., Ltd. All rights reserved.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+ */
+package cn.seecoder.courselearning.android;
+
+import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.annotation.JSONField;
+import cn.seecoder.courselearning.message.Notification;
+import cn.seecoder.courselearning.enums.Importance;
+import cn.seecoder.courselearning.enums.Visibility;
+import cn.seecoder.courselearning.util.CollectionUtils;
+import cn.seecoder.courselearning.util.ValidatorUtils;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+
+public class AndroidNotification {
+
+    private static final String COLOR_PATTERN = "^#[0-9a-fA-F]{6}$";
+
+    private static final String URL_PATTERN = "^https.*";
+
+    private static final String VIBRATE_PATTERN = "[0-9]+|[0-9]+[sS]|[0-9]+[.][0-9]{1,9}|[0-9]+[.][0-9]{1,9}[sS]";
+
+    @JSONField(name = "title")
+    private String title;
+
+    @JSONField(name = "body")
+    private String body;
+
+    @JSONField(name = "icon")
+    private String icon;
+
+    @JSONField(name = "color")
+    private String color;
+
+    @JSONField(name = "sound")
+    private String sound;
+
+    @JSONField(name = "default_sound")
+    private boolean defaultSound;
+
+    @JSONField(name = "tag")
+    private String tag;
+
+    @JSONField(name = "click_action")
+    private ClickAction clickAction;
+
+    @JSONField(name = "body_loc_key")
+    private String bodyLocKey;
+
+    @JSONField(name = "body_loc_args")
+    private List<String> bodyLocArgs = new ArrayList<>();
+
+    @JSONField(name = "title_loc_key")
+    private String titleLocKey;
+
+    @JSONField(name = "title_loc_args")
+    private List<String> titleLocArgs = new ArrayList<>();
+
+    @JSONField(name = "multi_lang_key")
+    private JSONObject multiLangKey;
+
+    @JSONField(name = "channel_id")
+    private String channelId;
+
+    @JSONField(name = "notify_summary")
+    private String notifySummary;
+
+    @JSONField(name = "image")
+    private String image;
+
+    @JSONField(name = "style")
+    private Integer style;
+
+    @JSONField(name = "big_title")
+    private String bigTitle;
+
+    @JSONField(name = "big_body")
+    private String bigBody;
+
+    @JSONField(name = "auto_clear")
+    private Integer autoClear;
+
+    @JSONField(name = "notify_id")
+    private Integer notifyId;
+
+    @JSONField(name = "group")
+    private String group;
+
+    @JSONField(name = "badge")
+    private BadgeNotification badge;
+
+    @JSONField(name = "ticker")
+    private String ticker;
+
+    @JSONField(name = "auto_cancel")
+    private boolean autoCancel;
+
+    @JSONField(name = "when")
+    private String when;
+
+    @JSONField(name = "local_only")
+    private Boolean localOnly;
+
+    @JSONField(name = "importance")
+    private String importance;
+
+    @JSONField(name = "use_default_vibrate")
+    private boolean useDefaultVibrate;
+
+    @JSONField(name = "use_default_light")
+    private boolean useDefaultLight;
+
+    @JSONField(name = "vibrate_config")
+    private List<String> vibrateConfig = new ArrayList<>();
+
+    @JSONField(name = "visibility")
+    private String visibility;
+
+    @JSONField(name = "light_settings")
+    private LightSettings lightSettings;
+
+    @JSONField(name = "foreground_show")
+    private boolean foregroundShow;
+
+    @JSONField(name = "inbox_content")
+    private List<String> inboxContent;
+
+    @JSONField(name = "buttons")
+    private List<Button> buttons;
+
+    private AndroidNotification(Builder builder) {
+        this.title = builder.title;
+        this.body = builder.body;
+        this.icon = builder.icon;
+        this.color = builder.color;
+        this.sound = builder.sound;
+        this.defaultSound = builder.defaultSound;
+
+        this.tag = builder.tag;
+        this.clickAction = builder.clickAction;
+
+        this.bodyLocKey = builder.bodyLocKey;
+        if (!CollectionUtils.isEmpty(builder.bodyLocArgs)) {
+            this.bodyLocArgs.addAll(builder.bodyLocArgs);
+        } else {
+            this.bodyLocArgs = null;
+        }
+
+        this.titleLocKey = builder.titleLocKey;
+        if (!CollectionUtils.isEmpty(builder.titleLocArgs)) {
+            this.titleLocArgs.addAll(builder.titleLocArgs);
+        } else {
+            this.titleLocArgs = null;
+        }
+
+        if (builder.multiLangkey != null) {
+            this.multiLangKey = builder.multiLangkey;
+        } else {
+            this.multiLangKey = null;
+        }
+
+        this.channelId = builder.channelId;
+
+        this.notifySummary = builder.notifySummary;
+        this.image = builder.image;
+        this.style = builder.style;
+        this.bigTitle = builder.bigTitle;
+        this.bigBody = builder.bigBody;
+        this.autoClear = builder.autoClear;
+        this.notifyId = builder.notifyId;
+        this.group = builder.group;
+
+        if (null != builder.badge) {
+            this.badge = builder.badge;
+        } else {
+            this.badge = null;
+        }
+
+        this.ticker = builder.ticker;
+        this.autoCancel = builder.autoCancel;
+        this.when = builder.when;
+        this.importance = builder.importance;
+        this.useDefaultVibrate = builder.useDefaultVibrate;
+        this.useDefaultLight = builder.useDefaultLight;
+        if (!CollectionUtils.isEmpty(builder.vibrateConfig)) {
+            this.vibrateConfig = builder.vibrateConfig;
+        } else {
+            this.vibrateConfig = null;
+        }
+
+        this.visibility = builder.visibility;
+        this.lightSettings = builder.lightSettings;
+        this.foregroundShow = builder.foregroundShow;
+
+        if (!CollectionUtils.isEmpty(builder.inboxContent)) {
+            this.inboxContent = builder.inboxContent;
+        } else {
+            this.inboxContent = null;
+        }
+
+        if (!CollectionUtils.isEmpty(builder.buttons)) {
+            this.buttons = builder.buttons;
+        } else {
+            this.buttons = null;
+        }
+    }
+
+    /**
+     * check androidNotification's parameters
+     *
+     * @param notification which is in message
+     */
+    public void check(Notification notification) {
+        if (null != notification) {
+            ValidatorUtils.checkArgument(StringUtils.isNotEmpty(notification.getTitle()) || StringUtils.isNotEmpty(this.title), "title should be set");
+            ValidatorUtils.checkArgument(StringUtils.isNotEmpty(notification.getBody()) || StringUtils.isNotEmpty(this.body), "body should be set");
+        }
+
+        if (StringUtils.isNotEmpty(this.color)) {
+            ValidatorUtils.checkArgument(this.color.matches(AndroidNotification.COLOR_PATTERN), "Wrong color format, color must be in the form #RRGGBB");
+        }
+
+        if (this.clickAction != null) {
+            this.clickAction.check();
+        }
+
+        if (!CollectionUtils.isEmpty(this.bodyLocArgs)) {
+            ValidatorUtils.checkArgument(StringUtils.isNotEmpty(this.bodyLocKey), "bodyLocKey is required when specifying bodyLocArgs");
+        }
+
+        if (!CollectionUtils.isEmpty(this.titleLocArgs)) {
+            ValidatorUtils.checkArgument(StringUtils.isNotEmpty(this.titleLocKey), "titleLocKey is required when specifying titleLocArgs");
+        }
+
+        if (StringUtils.isNotEmpty(this.image)) {
+            ValidatorUtils.checkArgument(this.image.matches(URL_PATTERN), "notifyIcon must start with https");
+        }
+
+        //Style 0,1,2
+        if (this.style != null) {
+            boolean isTrue = this.style == 0 ||
+                    this.style == 1 ||
+                    this.style == 2 ||
+                    this.style == 3;
+            ValidatorUtils.checkArgument(isTrue, "style should be one of 0:default, 1: big text, 2: big picture");
+
+            if (this.style == 1) {
+                ValidatorUtils.checkArgument(StringUtils.isNotEmpty(this.bigTitle) && StringUtils.isNotEmpty(this.bigBody), "title and body are required when style = 1");
+            } else if (this.style == 3) {
+                ValidatorUtils.checkArgument(!CollectionUtils.isEmpty(this.inboxContent) && this.inboxContent.size() <= 5, "inboxContent is required when style = 3 and at most 5 inbox content is needed");
+            }
+        }
+
+        if (this.autoClear != null) {
+            ValidatorUtils.checkArgument(this.autoClear.intValue() > 0, "auto clear should positive value");
+        }
+
+        if (badge != null) {
+            this.badge.check();
+        }
+
+        if (this.importance != null) {
+            ValidatorUtils.checkArgument(StringUtils.equals(this.importance, Importance.LOW.getValue())
+                            || StringUtils.equals(this.importance, Importance.NORMAL.getValue())
+                            || StringUtils.equals(this.importance, Importance.HIGH.getValue()),
+                    "importance shouid be [HIGH, NORMAL, LOW]");
+        }
+
+        if (!CollectionUtils.isEmpty(this.vibrateConfig)) {
+            ValidatorUtils.checkArgument(this.vibrateConfig.size() <= 10, "vibrate_config array size cannot be more than 10");
+            for (String vibrateTiming : this.vibrateConfig) {
+                ValidatorUtils.checkArgument(vibrateTiming.matches(AndroidNotification.VIBRATE_PATTERN), "Wrong vibrate timing format");
+                long vibrateTimingValue = (long) (1000 * Double
+                        .valueOf(StringUtils.substringBefore(vibrateTiming.toLowerCase(Locale.getDefault()), "s")));
+                ValidatorUtils.checkArgument(vibrateTimingValue > 0 && vibrateTimingValue < 60000, "Vibrate timing duration must be greater than 0 and less than 60s");
+            }
+        }
+
+        if (this.visibility != null) {
+            ValidatorUtils.checkArgument(StringUtils.equals(this.visibility, Visibility.VISIBILITY_UNSPECIFIED.getValue())
+                            || StringUtils.equals(this.visibility, Visibility.PRIVATE.getValue())
+                            || StringUtils.equals(this.visibility, Visibility.PUBLIC.getValue())
+                            || StringUtils.equals(this.visibility, Visibility.SECRET.getValue()),
+                    "visibility shouid be [VISIBILITY_UNSPECIFIED, PRIVATE, PUBLIC, SECRET]");
+        }
+
+        // multiLangKey
+        if (null != this.multiLangKey) {
+            Iterator<String> keyIterator = this.multiLangKey.keySet().iterator();
+            while (keyIterator.hasNext()) {
+                String key = keyIterator.next();
+                ValidatorUtils.checkArgument((this.multiLangKey.get(key) instanceof JSONObject), "multiLangKey value should be JSONObject");
+                JSONObject contentsObj = multiLangKey.getJSONObject(key);
+                if (contentsObj != null) {
+                    ValidatorUtils.checkArgument(contentsObj.keySet().size() <= 3, "Only three lang property can carry");
+                }
+            }
+        }
+
+        if (this.lightSettings != null) {
+            this.lightSettings.check();
+        }
+
+        if (!CollectionUtils.isEmpty(this.buttons)) {
+            ValidatorUtils.checkArgument(this.buttons.size() <= 3, "Only three buttons can carry");
+            for (Button button : this.buttons) {
+                button.check();
+            }
+        }
+    }
+
+    /**
+     * getter
+     */
+    public String getTitle() {
+        return title;
+    }
+
+    public String getBody() {
+        return body;
+    }
+
+    public String getIcon() {
+        return icon;
+    }
+
+    public String getColor() {
+        return color;
+    }
+
+    public String getSound() {
+        return sound;
+    }
+
+    public Boolean isDefaultSound() {
+        return defaultSound;
+    }
+
+    public String getTag() {
+        return tag;
+    }
+
+    public ClickAction getClickAction() {
+        return clickAction;
+    }
+
+    public String getBodyLocKey() {
+        return bodyLocKey;
+    }
+
+    public List<String> getBodyLocArgs() {
+        return bodyLocArgs;
+    }
+
+    public String getTitleLocKey() {
+        return titleLocKey;
+    }
+
+    public List<String> getTitleLocArgs() {
+        return titleLocArgs;
+    }
+
+    public JSONObject getMultiLangKey() {
+        return multiLangKey;
+    }
+
+    public String getChannelId() {
+        return channelId;
+    }
+
+    public String getNotifySummary() {
+        return notifySummary;
+    }
+
+    public String getImage() {
+        return image;
+    }
+
+    public Integer getStyle() {
+        return style;
+    }
+
+    public String getBigTitle() {
+        return bigTitle;
+    }
+
+    public String getBigBody() {
+        return bigBody;
+    }
+
+    public Integer getAutoClear() {
+        return autoClear;
+    }
+
+    public Integer getNotifyId() {
+        return notifyId;
+    }
+
+    public String getGroup() {
+        return group;
+    }
+
+    public BadgeNotification getBadge() {
+        return badge;
+    }
+
+    public String getTicker() {
+        return ticker;
+    }
+
+    public String getWhen() {
+        return when;
+    }
+
+    public String getImportance() {
+        return importance;
+    }
+
+    public List<String> getVibrateConfig() {
+        return vibrateConfig;
+    }
+
+    public String getVisibility() {
+        return visibility;
+    }
+
+    public LightSettings getLightSettings() {
+        return lightSettings;
+    }
+
+    public boolean isAutoCancel() {
+        return autoCancel;
+    }
+
+    public Boolean getLocalOnly() {
+        return localOnly;
+    }
+
+    public boolean isUseDefaultVibrate() {
+        return useDefaultVibrate;
+    }
+
+    public boolean isUseDefaultLight() {
+        return useDefaultLight;
+    }
+
+    public boolean isForegroundShow() {
+        return foregroundShow;
+    }
+
+    public List<String> getInboxContent() {
+        return inboxContent;
+    }
+
+    public List<Button> getButtons() {
+        return buttons;
+    }
+
+    /**
+     * builder
+     *
+     * @return
+     */
+    public static Builder builder() {
+        return new Builder();
+    }
+
+    public static class Builder {
+
+        private String title;
+        private String body;
+        private String icon;
+        private String color;
+        private String sound;
+        private boolean defaultSound;
+        private String tag;
+        private ClickAction clickAction;
+        private String bodyLocKey;
+        private List<String> bodyLocArgs = new ArrayList<>();
+        private String titleLocKey;
+        private List<String> titleLocArgs = new ArrayList<>();
+        private JSONObject multiLangkey;
+        private String channelId;
+        private String notifySummary;
+        private String image;
+        private Integer style;
+        private String bigTitle;
+        private String bigBody;
+        private Integer autoClear;
+        private Integer notifyId;
+        private String group;
+
+        private BadgeNotification badge;
+
+        private String ticker;
+        private boolean autoCancel = true;
+        private String when;
+        private String importance;
+        private boolean useDefaultVibrate;
+        private boolean useDefaultLight;
+        private List<String> vibrateConfig = new ArrayList<>();
+        private String visibility;
+        private LightSettings lightSettings;
+        private boolean foregroundShow;
+
+        private List<String> inboxContent = new ArrayList<>();
+        private List<Button> buttons = new ArrayList<Button>();
+
+        private Builder() {
+        }
+
+        public Builder setTitle(String title) {
+            this.title = title;
+            return this;
+        }
+
+        public Builder setBody(String body) {
+            this.body = body;
+            return this;
+        }
+
+        public Builder setIcon(String icon) {
+            this.icon = icon;
+            return this;
+        }
+
+        public Builder setColor(String color) {
+            this.color = color;
+            return this;
+        }
+
+        public Builder setSound(String sound) {
+            this.sound = sound;
+            return this;
+        }
+
+        public Builder setDefaultSound(boolean defaultSound) {
+            this.defaultSound = defaultSound;
+            return this;
+        }
+
+        public Builder setTag(String tag) {
+            this.tag = tag;
+            return this;
+        }
+
+        public Builder setClickAction(ClickAction clickAction) {
+            this.clickAction = clickAction;
+            return this;
+        }
+
+        public Builder setBodyLocKey(String bodyLocKey) {
+            this.bodyLocKey = bodyLocKey;
+            return this;
+        }
+
+        public Builder addBodyLocArgs(String arg) {
+            this.bodyLocArgs.add(arg);
+            return this;
+        }
+
+        public Builder addAllBodyLocArgs(List<String> args) {
+            this.bodyLocArgs.addAll(args);
+            return this;
+        }
+
+        public Builder setTitleLocKey(String titleLocKey) {
+            this.titleLocKey = titleLocKey;
+            return this;
+        }
+
+        public Builder addTitleLocArgs(String arg) {
+            this.titleLocArgs.add(arg);
+            return this;
+        }
+
+        public Builder addAllTitleLocArgs(List<String> args) {
+            this.titleLocArgs.addAll(args);
+            return this;
+        }
+
+        public Builder setMultiLangkey(JSONObject multiLangkey) {
+            this.multiLangkey = multiLangkey;
+            return this;
+        }
+
+        public Builder setChannelId(String channelId) {
+            this.channelId = channelId;
+            return this;
+        }
+
+        public Builder setNotifySummary(String notifySummary) {
+            this.notifySummary = notifySummary;
+            return this;
+        }
+
+        public Builder setImage(String image) {
+            this.image = image;
+            return this;
+        }
+
+        public Builder setStyle(Integer style) {
+            this.style = style;
+            return this;
+        }
+
+        public Builder setBigTitle(String bigTitle) {
+            this.bigTitle = bigTitle;
+            return this;
+        }
+
+        public Builder setBigBody(String bigBody) {
+            this.bigBody = bigBody;
+            return this;
+        }
+
+        public Builder setAutoClear(Integer autoClear) {
+            this.autoClear = autoClear;
+            return this;
+        }
+
+        public Builder setNotifyId(Integer notifyId) {
+            this.notifyId = notifyId;
+            return this;
+        }
+
+        public Builder setGroup(String group) {
+            this.group = group;
+            return this;
+        }
+
+        public Builder setBadge(BadgeNotification badge) {
+            this.badge = badge;
+            return this;
+        }
+
+        public Builder setTicker(String ticker) {
+            this.ticker = ticker;
+            return this;
+        }
+
+        public Builder setAutoCancel(boolean autoCancel) {
+            this.autoCancel = autoCancel;
+            return this;
+        }
+
+        public Builder setWhen(String when) {
+            this.when = when;
+            return this;
+        }
+
+        public Builder setImportance(String importance) {
+            this.importance = importance;
+            return this;
+        }
+
+        public Builder setUseDefaultVibrate(boolean useDefaultVibrate) {
+            this.useDefaultVibrate = useDefaultVibrate;
+            return this;
+        }
+
+        public Builder setUseDefaultLight(boolean useDefaultLight) {
+            this.useDefaultLight = useDefaultLight;
+            return this;
+        }
+
+        public Builder addVibrateConfig(String vibrateTiming) {
+            this.vibrateConfig.add(vibrateTiming);
+            return this;
+        }
+
+
+        public Builder addAllVibrateConfig(List<String> vibrateTimings) {
+            this.vibrateConfig.addAll(vibrateTimings);
+            return this;
+        }
+
+        public Builder setVisibility(String visibility) {
+            this.visibility = visibility;
+            return this;
+        }
+
+        public Builder setLightSettings(LightSettings lightSettings) {
+            this.lightSettings = lightSettings;
+            return this;
+        }
+
+        public Builder setForegroundShow(boolean foregroundShow) {
+            this.foregroundShow = foregroundShow;
+            return this;
+        }
+
+        public Builder addInboxContent(String inboxContent) {
+            this.inboxContent.add(inboxContent);
+            return this;
+        }
+
+        public Builder addAllInboxContent(List<String> inboxContents) {
+            this.inboxContent.addAll(inboxContents);
+            return this;
+        }
+
+        public Builder addButton(Button button) {
+            this.buttons.add(button);
+            return this;
+        }
+
+        public Builder addAllButtons(List<Button> buttons) {
+            this.buttons.addAll(buttons);
+            return this;
+        }
+
+        public AndroidNotification build() {
+            return new AndroidNotification(this);
+        }
+    }
+}

+ 98 - 0
src/main/java/cn/seecoder/courselearning/android/BadgeNotification.java

@@ -0,0 +1,98 @@
+/*
+ * Copyright 2020. Huawei Technologies Co., Ltd. All rights reserved.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+ */
+package cn.seecoder.courselearning.android;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import cn.seecoder.courselearning.util.ValidatorUtils;
+
+public class BadgeNotification {
+    @JSONField(name = "add_num")
+    private Integer addNum;
+
+    @JSONField(name = "class")
+    private String badgeClass;
+
+    @JSONField(name = "set_num")
+    private Integer setNum;
+
+    public Integer getAddNum() {
+        return addNum;
+    }
+
+    public String getBadgeClass() {
+        return badgeClass;
+    }
+
+    public Integer getSetNum() {
+        return setNum;
+    }
+
+    public BadgeNotification(Integer addNum, String badgeClass) {
+        this.addNum = builder().addNum;
+        this.badgeClass = badgeClass;
+    }
+
+    public BadgeNotification(Builder builder) {
+        this.addNum = builder.addNum;
+        this.badgeClass = builder.badgeClass;
+        this.setNum = builder.setNum;
+    }
+
+    public void check() {
+        if (this.addNum != null) {
+            ValidatorUtils.checkArgument(this.addNum.intValue() > 0 && this.addNum.intValue() < 100, "add_num should locate between 0 and 100");
+        }
+        if (this.setNum != null) {
+            ValidatorUtils.checkArgument(this.setNum.intValue() >= 0 && this.setNum.intValue() < 100, "set_num should locate between 0 and 100");
+        }
+    }
+
+    /**
+     * builder
+     */
+    public static Builder builder() {
+        return new Builder();
+    }
+
+    public static class Builder {
+        private Integer addNum;
+
+        private String badgeClass;
+
+        private Integer setNum;
+
+        public Builder setAddNum(Integer addNum) {
+            this.addNum = addNum;
+            return this;
+        }
+
+        public Builder setSetNum(Integer setNum) {
+            this.setNum = setNum;
+            return this;
+        }
+
+        public Builder setBadgeClass(String badgeClass) {
+            this.badgeClass = badgeClass;
+            return this;
+        }
+
+        public BadgeNotification build() {
+            return new BadgeNotification(this);
+        }
+    }
+
+
+}

+ 120 - 0
src/main/java/cn/seecoder/courselearning/android/Button.java

@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) Huawei Technologies Co., Ltd. 2019-2029. All rights reserved.
+ */
+
+package cn.seecoder.courselearning.android;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import cn.seecoder.courselearning.util.ValidatorUtils;
+import org.apache.commons.lang3.StringUtils;
+
+/**
+ * 功能描述
+ *
+ * @author l00282963
+ * @since 2020-01-19
+ */
+public class Button {
+    @JSONField(name = "name")
+    private String name;
+
+    @JSONField(name = "action_type")
+    private Integer actionType;
+
+    @JSONField(name = "intent_type")
+    private Integer intentType;
+
+    @JSONField(name = "intent")
+    private String intent;
+
+    @JSONField(name = "data")
+    private String data;
+
+    public String getName() {
+        return name;
+    }
+
+    public Integer getActionType() {
+        return actionType;
+    }
+
+    public Integer getIntentType() {
+        return intentType;
+    }
+
+    public String getIntent() {
+        return intent;
+    }
+
+    public String getData() {
+        return data;
+    }
+
+
+    public Button(Builder builder) {
+        this.name = builder.name;
+        this.actionType = builder.actionType;
+        this.intentType = builder.intentType;
+        this.intent = builder.intent;
+        this.data = builder.data;
+    }
+
+    public void check() {
+        if (this.actionType != null && this.actionType == 4) {
+            ValidatorUtils.checkArgument(StringUtils.isNotEmpty(this.data), "data is needed when actionType is 4");
+        }
+    }
+
+    /**
+     * builder
+     */
+    public static Builder builder() {
+        return new Builder();
+    }
+
+    public static class Builder {
+        @JSONField(name = "name")
+        private String name;
+
+        @JSONField(name = "actionType")
+        private Integer actionType;
+
+        @JSONField(name = "intentType")
+        private Integer intentType;
+
+        @JSONField(name = "intent")
+        private String intent;
+
+        @JSONField(name = "data")
+        private String data;
+
+        public Builder setName(String name) {
+            this.name = name;
+            return this;
+        }
+
+        public Builder setActionType(Integer actionType) {
+            this.actionType = actionType;
+            return this;
+        }
+
+        public Builder setIntentType(Integer intentType) {
+            this.intentType = intentType;
+            return this;
+        }
+
+        public Builder setIntent(String intent) {
+            this.intent = intent;
+            return this;
+        }
+
+        public Builder setData(String data) {
+            this.data = data;
+            return this;
+        }
+
+        public Button build() {
+            return new Button(this);
+        }
+    }
+}

+ 150 - 0
src/main/java/cn/seecoder/courselearning/android/ClickAction.java

@@ -0,0 +1,150 @@
+/*
+ * Copyright 2020. Huawei Technologies Co., Ltd. All rights reserved.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+ */
+package cn.seecoder.courselearning.android;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import cn.seecoder.courselearning.util.ValidatorUtils;
+import org.apache.commons.lang3.StringUtils;
+
+public class ClickAction {
+    private static final String PATTERN = "^https.*";
+
+    @JSONField(name = "type")
+    private Integer type;
+
+    @JSONField(name = "intent")
+    private String intent;
+
+    @JSONField(name = "url")
+    private String url;
+
+    @JSONField(name = "rich_resource")
+    private String richResource;
+
+    @JSONField(name = "action")
+    private String action;
+
+    private ClickAction(Builder builder) {
+        this.type = builder.type;
+        switch (this.type) {
+            case 1:
+                this.intent = builder.intent;
+                this.action = builder.action;
+                break;
+            case 2:
+                this.url = builder.url;
+                break;
+            case 4:
+                this.richResource = builder.richResource;
+                break;
+        }
+    }
+
+    /**
+     * check clickAction's parameters
+     */
+    public void check() {
+        boolean isTrue = this.type == 1 ||
+                this.type == 2 ||
+                this.type == 3 ||
+                this.type == 4;
+        ValidatorUtils.checkArgument(isTrue, "click type should be one of 1: customize action, 2: open url, 3: open app, 4: open rich media");
+
+        switch (this.type) {
+            case 1:
+                ValidatorUtils.checkArgument(StringUtils.isNotEmpty(this.intent) || StringUtils.isNotEmpty(this.action), "intent or action is required when click type=1");
+                break;
+            case 2:
+                ValidatorUtils.checkArgument(StringUtils.isNotEmpty(this.url), "url is required when click type=2");
+                ValidatorUtils.checkArgument(this.url.matches(PATTERN), "url must start with https");
+                break;
+            case 4:
+                ValidatorUtils.checkArgument(StringUtils.isNotEmpty(this.richResource), "richResource is required when click type=4");
+                ValidatorUtils.checkArgument(this.richResource.matches(PATTERN), "richResource must start with https");
+                break;
+        }
+    }
+
+    /**
+     * getter
+     */
+    public int getType() {
+        return type;
+    }
+
+    public String getIntent() {
+        return intent;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public String getRichResource() {
+        return richResource;
+    }
+
+    public String getAction() {
+        return action;
+    }
+
+    /**
+     * builder
+     */
+    public static Builder builder() {
+        return new Builder();
+    }
+
+    public static class Builder {
+        private Integer type;
+        private String intent;
+        private String url;
+        private String richResource;
+        private String action;
+
+        private Builder() {
+        }
+
+        public Builder setType(Integer type) {
+            this.type = type;
+            return this;
+        }
+
+        public Builder setIntent(String intent) {
+            this.intent = intent;
+            return this;
+        }
+
+        public Builder setUrl(String url) {
+            this.url = url;
+            return this;
+        }
+
+        public Builder setRichResource(String richResource) {
+            this.richResource = richResource;
+            return this;
+        }
+
+        public Builder setAction(String action) {
+            this.action = action;
+            return this;
+        }
+
+        public ClickAction build() {
+            return new ClickAction(this);
+        }
+    }
+}

+ 105 - 0
src/main/java/cn/seecoder/courselearning/android/Color.java

@@ -0,0 +1,105 @@
+/*
+ * Copyright 2020. Huawei Technologies Co., Ltd. All rights reserved.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+ */
+package cn.seecoder.courselearning.android;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import cn.seecoder.courselearning.util.ValidatorUtils;
+
+public class Color {
+    private final float zero = -0.000001f;
+
+    private final float one = 1.000001f;
+
+    @JSONField(name = "alpha")
+    private Float alpha = new Float(1.0);
+
+    @JSONField(name = "red")
+    private Float red = new Float(0.0);
+
+    @JSONField(name = "green")
+    private Float green = new Float(0.0);
+
+    @JSONField(name = "blue")
+    private Float blue = new Float(0.0);
+
+    public Color(Builder builder) {
+        this.alpha = builder.alpha;
+        this.red = builder.red;
+        this.green = builder.green;
+        this.blue = builder.blue;
+    }
+
+    public double getAlpha() {
+        return alpha;
+    }
+
+    public Float getRed() {
+        return red;
+    }
+
+    public Float getGreen() {
+        return green;
+    }
+
+    public Float getBlue() {
+        return blue;
+    }
+
+    public void check() {
+        ValidatorUtils.checkArgument(this.alpha > zero && this.alpha < one, "Alpha shoube locate between [0,1]");
+        ValidatorUtils.checkArgument(this.red > zero && this.red < one, "Red shoube locate between [0,1]");
+        ValidatorUtils.checkArgument(this.green > zero && this.green < one, "Green shoube locate between [0,1]");
+        ValidatorUtils.checkArgument(this.blue > zero && this.blue < one, "Blue shoube locate between [0,1]");
+    }
+
+    /**
+     * builder
+     */
+    public static Builder builder() {
+        return new Builder();
+    }
+
+    public static class Builder {
+        private Float alpha = new Float(1.0);
+        private Float red = new Float(0.0);
+        private Float green = new Float(0.0);
+        private Float blue = new Float(0.0);
+
+        public Builder setAlpha(Float alpha) {
+            this.alpha = alpha;
+            return this;
+        }
+
+        public Builder setRed(Float red) {
+            this.red = red;
+            return this;
+        }
+
+        public Builder setGreen(Float green) {
+            this.green = green;
+            return this;
+        }
+
+        public Builder setBlue(Float blue) {
+            this.blue = blue;
+            return this;
+        }
+
+        public Color build() {
+            return new Color(this);
+        }
+    }
+}

+ 101 - 0
src/main/java/cn/seecoder/courselearning/android/LightSettings.java

@@ -0,0 +1,101 @@
+/*
+ * Copyright 2020. Huawei Technologies Co., Ltd. All rights reserved.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+ */
+package cn.seecoder.courselearning.android;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import cn.seecoder.courselearning.util.ValidatorUtils;
+
+public class LightSettings {
+    private static final String LIGTH_DURATION_PATTERN = "\\d+|\\d+[sS]|\\d+.\\d{1,9}|\\d+.\\d{1,9}[sS]";
+
+    @JSONField(name = "color")
+    private Color color;
+
+    @JSONField(name = "light_on_duration")
+    private String lightOnDuration;
+
+    @JSONField(name = "light_off_duration")
+    private String lightOffDuration;
+
+    public LightSettings(Builder builder) {
+        this.color = builder.color;
+        this.lightOnDuration = builder.lightOnDuration;
+        this.lightOffDuration = builder.lightOffDuration;
+    }
+
+    public Color getColor() {
+        return color;
+    }
+
+    public String getLightOnDuration() {
+        return lightOnDuration;
+    }
+
+    public String getLightOffDuration() {
+        return lightOffDuration;
+    }
+
+    /**
+     * 参数校验
+     */
+    public void check() {
+        ValidatorUtils.checkArgument(this.color != null, "color must be selected when light_settings is set");
+
+        if (this.color != null) {
+            this.color.check();
+        }
+
+        ValidatorUtils.checkArgument(this.lightOnDuration != null, "light_on_duration must be selected when light_settings is set");
+
+        ValidatorUtils.checkArgument(this.lightOffDuration != null, "light_off_duration must be selected when light_settings is set");
+
+        ValidatorUtils.checkArgument(this.lightOnDuration.matches(LIGTH_DURATION_PATTERN), "light_on_duration format is wrong");
+
+        ValidatorUtils.checkArgument(this.lightOffDuration.matches(LIGTH_DURATION_PATTERN), "light_off_duration format is wrong");
+    }
+
+    /**
+     * builder
+     */
+    public static Builder builder() {
+        return new Builder();
+    }
+
+    public static class Builder {
+        private Color color;
+        private String lightOnDuration;
+        private String lightOffDuration;
+
+        public Builder setColor(Color color) {
+            this.color = color;
+            return this;
+        }
+
+        public Builder setLightOnDuration(String lightOnDuration) {
+            this.lightOnDuration = lightOnDuration;
+            return this;
+        }
+
+        public Builder setLightOffDuration(String lightOffDuration) {
+            this.lightOffDuration = lightOffDuration;
+            return this;
+        }
+
+        public LightSettings build() {
+            return new LightSettings(this);
+        }
+    }
+}

+ 27 - 0
src/main/java/cn/seecoder/courselearning/config/CorsConfig.java

@@ -0,0 +1,27 @@
+package cn.seecoder.courselearning.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.cors.CorsConfiguration;
+import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
+import org.springframework.web.filter.CorsFilter;
+
+/**
+ * 允许跨域请求访问资源
+ */
+@Configuration
+public class CorsConfig {
+    private CorsConfiguration buildConfig() {
+        CorsConfiguration corsConfiguration = new CorsConfiguration();
+        corsConfiguration.addAllowedOrigin("*");
+        corsConfiguration.addAllowedHeader("*");
+        corsConfiguration.addAllowedMethod("*");
+        return corsConfiguration;
+    }
+    @Bean
+    public CorsFilter corsFilter() {
+        UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
+        source.registerCorsConfiguration("/**", buildConfig());
+        return new CorsFilter(source);
+    }
+}

+ 89 - 0
src/main/java/cn/seecoder/courselearning/config/DataSourceConfig.java

@@ -0,0 +1,89 @@
+package cn.seecoder.courselearning.config;
+
+import com.github.pagehelper.PageInterceptor;
+import com.mchange.v2.c3p0.ComboPooledDataSource;
+import org.apache.ibatis.plugin.Interceptor;
+import org.apache.ibatis.session.SqlSessionFactory;
+import org.mybatis.spring.SqlSessionFactoryBean;
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.io.DefaultResourceLoader;
+import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
+import org.springframework.jdbc.datasource.DataSourceTransactionManager;
+
+import javax.sql.DataSource;
+import java.beans.PropertyVetoException;
+import java.util.Properties;
+
+@Configuration
+// 扫描 Mapper 接口并容器管理
+@MapperScan(basePackages = cn.seecoder.courselearning.config.DataSourceConfig.PACKAGE,sqlSessionFactoryRef = "testDsSqlSessionFactory")
+public class DataSourceConfig {
+
+    // 精确到 cluster 目录,以便跟其他数据源隔离
+    static final String PACKAGE = "cn.seecoder.courselearning.mapper";
+    static final String MAPPER_LOCATION = "classpath:mapper/*.xml";
+    static final String ALIAS = "cn.seecoder.courselearning.model";
+
+    @Value("${spring.datasource.url}")
+    private String url;
+
+    @Value("${spring.datasource.username}")
+    private String user;
+
+    @Value("${spring.datasource.password}")
+    private String password;
+
+    @Value("${spring.datasource.driver-class-name}")
+    private String driverClass;
+
+    @Bean(name = "testDataSource")
+    public DataSource clusterDataSource()throws PropertyVetoException{
+        ComboPooledDataSource dataSource=new ComboPooledDataSource();
+        dataSource.setDriverClass(driverClass);
+        dataSource.setJdbcUrl(url);
+        dataSource.setUser(user);
+        dataSource.setPassword(password);
+        dataSource.setAutoCommitOnClose(false);
+        return dataSource;
+    }
+
+    @Bean(name = "testTransactionManager")
+    public DataSourceTransactionManager clusterTransactionManager() throws PropertyVetoException {
+        return new DataSourceTransactionManager(clusterDataSource());
+    }
+
+    // 创建SqlSessionFactory对象
+    @Bean(name = "testDsSqlSessionFactory")
+    public SqlSessionFactory testDsSqlSessionFactory(@Qualifier("testDataSource") DataSource clusterDataSource)
+            throws Exception {
+        final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
+        sessionFactory.setDataSource(clusterDataSource);
+
+        // 加载全局的配置文件
+        sessionFactory.setConfigLocation(
+                new DefaultResourceLoader().getResource("classpath:mybatis-config.xml"));
+
+        // 配置类型别名
+        sessionFactory.setTypeAliasesPackage(ALIAS);
+
+        // 分页插件
+        PageInterceptor interceptor = new PageInterceptor();
+        Properties properties = new Properties();
+        properties.setProperty("reasonable", "true");
+        properties.setProperty("supportMethodsArguments", "true");
+        properties.setProperty("returnPageInfo", "check");
+        properties.setProperty("params", "count=countSql");
+        interceptor.setProperties(properties);
+
+        // 添加插件
+        sessionFactory.setPlugins(interceptor);
+
+        sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver()
+                .getResources(DataSourceConfig.MAPPER_LOCATION));
+        return sessionFactory.getObject();
+    }
+}

+ 63 - 0
src/main/java/cn/seecoder/courselearning/controller/CourseController.java

@@ -0,0 +1,63 @@
+package cn.seecoder.courselearning.controller;
+
+import cn.seecoder.courselearning.service.CourseService;
+import cn.seecoder.courselearning.util.Constant;
+import cn.seecoder.courselearning.vo.CourseVO;
+import com.github.pagehelper.PageInfo;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@RestController
+@RequestMapping("/course")
+public class CourseController {
+    @Resource
+    private CourseService courseService;
+
+    /**
+     * 查询单一课程
+     * @param uid 用户id
+     * @param courseId 课程id
+     */
+    @GetMapping("/{courseId}")
+    public CourseVO getCoursesByKey(@RequestParam(required = false, defaultValue = "") String uid, @PathVariable Integer courseId) {
+        return courseService.getCourse(courseId, uid);
+    }
+
+    /**
+     * 获取课程列表
+     * 如果带参数uid,则需要判断该用户是否购买过课程
+     * 如果带参数key,则根据关键字返回分页查询结果
+     * @param uid 用户id
+     * @param key 关键字
+     */
+    @GetMapping("/all/{page}")
+    public PageInfo<CourseVO> getCoursesByKey(@RequestParam(required = false, defaultValue = "") String uid,
+                                                @RequestParam(required = false, defaultValue = "") String key,
+                                                @PathVariable Integer page) {
+        return courseService.getCourses(page, Constant.COURSE_PAGE_SIZE, uid, key);
+    }
+
+    /**
+     * 根据分类标签,获取课程列表
+     * 如果带参数uid,则需要判断该用户是否购买过课程
+     * @param uid 用户id
+     * @param type 课程类别
+     */
+    @GetMapping("/type/{page}")
+    public PageInfo<CourseVO> getCoursesByType(@RequestParam(required = false, defaultValue = "")  String uid,
+                                         @RequestParam String type,
+                                         @PathVariable Integer page) {
+        return courseService.getCoursesByType(page, Constant.COURSE_PAGE_SIZE, uid, type);
+    }
+
+    /**
+     * 获取用户已购买的课程列表
+     * @param uid 用户id
+     */
+    @GetMapping("/uid/{uid}")
+    public List<CourseVO> getCoursesByType(@PathVariable String uid) {
+        return courseService.getBoughtCourses(uid);
+    }
+}

+ 38 - 0
src/main/java/cn/seecoder/courselearning/controller/CourseOrderController.java

@@ -0,0 +1,38 @@
+package cn.seecoder.courselearning.controller;
+
+import cn.seecoder.courselearning.service.CourseOrderService;
+import cn.seecoder.courselearning.vo.CourseOrderVO;
+import cn.seecoder.courselearning.vo.ResultVO;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@RestController
+@RequestMapping("/course_order")
+public class CourseOrderController {
+    @Resource
+    private CourseOrderService orderService;
+
+    /**
+     * 创建课程订单
+     */
+    @PostMapping("/create")
+    public ResultVO<CourseOrderVO> createCourseOrder(@RequestBody CourseOrderVO orderVO){
+        return orderService.insertCourseOrder(orderVO);
+    }
+
+    /**
+     * 根据uid查询用户所有的订单
+     */
+    @GetMapping("/uid/{uid}")
+    public List<CourseOrderVO> getCourseOrders(@PathVariable String uid){
+        return orderService.getCourseOrders(uid);
+    }
+
+    @PostMapping("/update")
+    public ResultVO<CourseOrderVO> updateCourseOrderStatus(@RequestParam Integer orderId, @RequestParam Integer orderStatus){
+        return orderService.updateCourseOrder(orderId, orderStatus);
+    }
+
+}

+ 29 - 0
src/main/java/cn/seecoder/courselearning/controller/CourseWareController.java

@@ -0,0 +1,29 @@
+package cn.seecoder.courselearning.controller;
+
+import cn.seecoder.courselearning.service.CourseWareService;
+import cn.seecoder.courselearning.util.Constant;
+import cn.seecoder.courselearning.vo.CourseWareVO;
+import com.github.pagehelper.PageInfo;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@RestController
+@RequestMapping("/course_ware")
+public class CourseWareController {
+    @Resource
+    private CourseWareService courseWareService;
+
+    /**
+     * 获取课件列表
+     * 如果带参数uid,则需要判断该用户是否购买过课程
+     * @param uid 用户id
+     * @param courseId 课程id
+     */
+    @GetMapping("/course/{courseId}")
+    public List<CourseWareVO> getCourseWare(@RequestParam(required = false, defaultValue = "") String uid,
+                                            @PathVariable Integer courseId) {
+        return courseWareService.getCourseWare(uid, courseId);
+    }
+}

+ 27 - 0
src/main/java/cn/seecoder/courselearning/controller/NotifyController.java

@@ -0,0 +1,27 @@
+package cn.seecoder.courselearning.controller;
+
+import cn.seecoder.courselearning.exception.HuaweiMessagingException;
+import cn.seecoder.courselearning.service.SendNotifyService;
+import cn.seecoder.courselearning.util.Constant;
+import cn.seecoder.courselearning.vo.ResultVO;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+
+@RestController
+@RequestMapping("/notify")
+public class NotifyController {
+    @Resource
+    SendNotifyService sendNotifyService;
+
+    @PostMapping("/course_order_success")
+    public ResultVO<String> sendSimpleNotify(@RequestParam String uid, @RequestParam Integer courseId) {
+        try {
+            sendNotifyService.sendCourseBuySuccessNotify(uid, courseId);
+        } catch (HuaweiMessagingException e) {
+            e.printStackTrace();
+            return new ResultVO<>(Constant.REQUEST_FAIL,"发送消息失败");
+        }
+        return new ResultVO<>(Constant.REQUEST_SUCCESS, "发送消息成功", uid);
+    }
+}

+ 35 - 0
src/main/java/cn/seecoder/courselearning/controller/UserController.java

@@ -0,0 +1,35 @@
+package cn.seecoder.courselearning.controller;
+
+import cn.seecoder.courselearning.mapper.UserMapper;
+import cn.seecoder.courselearning.service.UserService;
+import cn.seecoder.courselearning.vo.RechargeOrderVO;
+import cn.seecoder.courselearning.vo.ResultVO;
+import cn.seecoder.courselearning.vo.UserVO;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+
+@RestController
+@RequestMapping("/user")
+public class UserController {
+    @Resource
+    private UserService userService;
+    @Resource
+    private UserMapper m;
+
+
+    @PostMapping("/login")
+    public UserVO login(@RequestBody UserVO user){
+        return userService.userLogin(user);
+    }
+
+    @GetMapping("/{uid}")
+    public UserVO getUser(@PathVariable String uid){
+        return userService.getUser(uid);
+    }
+
+    @PostMapping("/recharge")
+    public ResultVO<UserVO> recharge(@RequestBody RechargeOrderVO rechargeOrderVO){
+        return userService.rechargeAccount(rechargeOrderVO);
+    }
+}

+ 21 - 0
src/main/java/cn/seecoder/courselearning/controller/UserTokenController.java

@@ -0,0 +1,21 @@
+package cn.seecoder.courselearning.controller;
+
+import cn.seecoder.courselearning.service.UserTokenService;
+import cn.seecoder.courselearning.util.Constant;
+import cn.seecoder.courselearning.vo.ResultVO;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+
+@RestController
+@RequestMapping("/user_token")
+public class UserTokenController {
+    @Resource
+    private UserTokenService userTokenService;
+
+    @PostMapping("/refresh")
+    public ResultVO<String> login(@RequestParam String uid, @RequestParam String token){
+        userTokenService.refreshToken(uid, token);
+        return new ResultVO<>(Constant.REQUEST_SUCCESS, "token更新成功");
+    }
+}

+ 5 - 0
src/main/java/cn/seecoder/courselearning/enums/ExceptionType.java

@@ -0,0 +1,5 @@
+package cn.seecoder.courselearning.enums;
+
+public enum ExceptionType {
+    PARAM_ERROR, UNAUTHORIZED, NOT_FOUND, DUPLICATED_KEY
+}

+ 48 - 0
src/main/java/cn/seecoder/courselearning/enums/Importance.java

@@ -0,0 +1,48 @@
+/*
+ * Copyright 2020. Huawei Technologies Co., Ltd. All rights reserved.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+ */
+package cn.seecoder.courselearning.enums;
+
+public enum Importance {
+    /**
+     * LOW
+     */
+    LOW("LOW"),
+
+    /**
+     * NORMAL
+     */
+    NORMAL("NORMAL"),
+
+    /**
+     * HIGH
+     */
+    HIGH("HIGH");
+
+    private String value;
+
+    private Importance(String value) {
+        this.value = value;
+    }
+
+    /**
+     * Gets value *
+     *
+     * @return the value
+     */
+    public String getValue() {
+        return value;
+    }
+}

+ 37 - 0
src/main/java/cn/seecoder/courselearning/enums/TopicOperation.java

@@ -0,0 +1,37 @@
+/*
+ * Copyright 2020. Huawei Technologies Co., Ltd. All rights reserved.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+ */
+package cn.seecoder.courselearning.enums;
+
+public enum TopicOperation {
+    SUBSCRIBE("subscribe"),
+    UNSUBSCRIBE("unsubscribe"),
+    LIST("list");
+
+    private String value;
+
+    private TopicOperation(String value) {
+        this.value = value;
+    }
+
+    /**
+     * Gets value *
+     *
+     * @return the value
+     */
+    public String getValue() {
+        return value;
+    }
+}

+ 36 - 0
src/main/java/cn/seecoder/courselearning/enums/Urgency.java

@@ -0,0 +1,36 @@
+/*
+ * Copyright 2020. Huawei Technologies Co., Ltd. All rights reserved.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+ */
+package cn.seecoder.courselearning.enums;
+
+public enum Urgency {
+    HIGH("HIGH"),
+    NORMAL("NORMAL");
+
+    private String value;
+
+    private Urgency(String value) {
+        this.value = value;
+    }
+
+    /**
+     * Gets value *
+     *
+     * @return the value
+     */
+    public String getValue() {
+        return value;
+    }
+}

+ 38 - 0
src/main/java/cn/seecoder/courselearning/enums/Visibility.java

@@ -0,0 +1,38 @@
+/*
+ * Copyright 2020. Huawei Technologies Co., Ltd. All rights reserved.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+ */
+package cn.seecoder.courselearning.enums;
+
+public enum Visibility {
+    VISIBILITY_UNSPECIFIED("VISIBILITY_UNSPECIFIED"),
+    PRIVATE("PRIVATE"),
+    PUBLIC("PUBLIC"),
+    SECRET("SECRET");
+
+    private String value;
+
+    private Visibility(String value) {
+        this.value = value;
+    }
+
+    /**
+     * Gets value *
+     *
+     * @return the value
+     */
+    public String getValue() {
+        return value;
+    }
+}

+ 35 - 0
src/main/java/cn/seecoder/courselearning/exception/HuaweiException.java

@@ -0,0 +1,35 @@
+/*
+ * Copyright 2020. Huawei Technologies Co., Ltd. All rights reserved.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+ */
+package cn.seecoder.courselearning.exception;
+
+import cn.seecoder.courselearning.util.ValidatorUtils;
+import com.google.common.base.Strings;
+
+/**
+ * exceptions
+ */
+public class HuaweiException extends Exception {
+
+    public HuaweiException(String detailMessage) {
+        super(detailMessage);
+        ValidatorUtils.checkArgument(!Strings.isNullOrEmpty(detailMessage), "Detail message must not be empty");
+    }
+
+    public HuaweiException(String detailMessage, Throwable cause) {
+        super(detailMessage, cause);
+        ValidatorUtils.checkArgument(!Strings.isNullOrEmpty(detailMessage), "Detail message must not be empty");
+    }
+}

+ 39 - 0
src/main/java/cn/seecoder/courselearning/exception/HuaweiMessagingException.java

@@ -0,0 +1,39 @@
+/*
+ * Copyright 2020. Huawei Technologies Co., Ltd. All rights reserved.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+ */
+package cn.seecoder.courselearning.exception;
+
+import cn.seecoder.courselearning.util.ValidatorUtils;
+import com.google.common.base.Strings;
+
+public class HuaweiMessagingException extends cn.seecoder.courselearning.exception.HuaweiException {
+    private final String errorCode;
+
+    public HuaweiMessagingException(String errorCode, String message) {
+        super(message);
+        ValidatorUtils.checkArgument(!Strings.isNullOrEmpty(errorCode));
+        this.errorCode = errorCode;
+    }
+
+    public HuaweiMessagingException(String errorCode, String message, Throwable cause) {
+        super(message, cause);
+        ValidatorUtils.checkArgument(!Strings.isNullOrEmpty(errorCode));
+        this.errorCode = errorCode;
+    }
+
+    public String getErrorCode() {
+        return errorCode;
+    }
+}

+ 17 - 0
src/main/java/cn/seecoder/courselearning/exception/MyException.java

@@ -0,0 +1,17 @@
+package cn.seecoder.courselearning.exception;
+
+import cn.seecoder.courselearning.enums.ExceptionType;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+@Getter
+@AllArgsConstructor(staticName = "of")
+public class MyException extends RuntimeException {
+    private final ExceptionType type;
+    private final String msg;
+
+    @Override
+    public String getMessage() {
+        return msg;
+    }
+}

+ 22 - 0
src/main/java/cn/seecoder/courselearning/mapper/CourseMapper.java

@@ -0,0 +1,22 @@
+package cn.seecoder.courselearning.mapper;
+
+import cn.seecoder.courselearning.model.Course;
+import java.util.List;
+
+public interface CourseMapper {
+    int deleteByPrimaryKey(Integer id);
+
+    int insert(Course record);
+
+    Course selectByPrimaryKey(Integer id);
+
+    List<Course> selectAll();
+
+    int updateByPrimaryKey(Course record);
+
+    List<Course> selectByType(String type);
+
+    List<Course> queryAll(String key);
+
+    List<Course> selectByUserId(String userId);
+}

+ 18 - 0
src/main/java/cn/seecoder/courselearning/mapper/CourseOrderMapper.java

@@ -0,0 +1,18 @@
+package cn.seecoder.courselearning.mapper;
+
+import cn.seecoder.courselearning.model.CourseOrder;
+import java.util.List;
+
+public interface CourseOrderMapper {
+    int deleteByPrimaryKey(Integer id);
+
+    int insert(CourseOrder record);
+
+    CourseOrder selectByPrimaryKey(Integer id);
+
+    int updateByPrimaryKey(CourseOrder record);
+
+    List<CourseOrder> selectByUserId(String userId);
+
+    CourseOrder queryMostRecentOrder(String userId, Integer courseId);
+}

+ 16 - 0
src/main/java/cn/seecoder/courselearning/mapper/CourseWareMapper.java

@@ -0,0 +1,16 @@
+package cn.seecoder.courselearning.mapper;
+
+import cn.seecoder.courselearning.model.CourseWare;
+import java.util.List;
+
+public interface CourseWareMapper {
+    int deleteByPrimaryKey(Integer id);
+
+    int insert(CourseWare record);
+
+    CourseWare selectByPrimaryKey(Integer id);
+
+    List<CourseWare> selectByCourseId(Integer courseId);
+
+    int updateByPrimaryKey(CourseWare record);
+}

+ 16 - 0
src/main/java/cn/seecoder/courselearning/mapper/RechargeOrderMapper.java

@@ -0,0 +1,16 @@
+package cn.seecoder.courselearning.mapper;
+
+import cn.seecoder.courselearning.model.RechargeOrder;
+import java.util.List;
+
+public interface RechargeOrderMapper {
+    int deleteByPrimaryKey(String orderId);
+
+    int insert(RechargeOrder record);
+
+    RechargeOrder selectByPrimaryKey(String orderId);
+
+    List<RechargeOrder> selectAll();
+
+    int updateByPrimaryKey(RechargeOrder record);
+}

+ 18 - 0
src/main/java/cn/seecoder/courselearning/mapper/UserMapper.java

@@ -0,0 +1,18 @@
+package cn.seecoder.courselearning.mapper;
+
+import cn.seecoder.courselearning.model.User;
+import org.apache.ibatis.annotations.Param;
+
+public interface UserMapper {
+    int deleteByPrimaryKey(@Param(value = "uid") String uid);
+
+    int insert(User record);
+
+    int updateUnameAndPicture(User user);
+
+    void increaseBalance(@Param(value = "uid") String uid, @Param(value = "delta")Integer delta);
+
+    void decreaseBalance(@Param(value = "uid") String uid, @Param(value = "delta")Integer delta);
+
+    User selectByPrimaryKey(@Param(value = "uid") String uid);
+}

+ 16 - 0
src/main/java/cn/seecoder/courselearning/mapper/UserTokenMapper.java

@@ -0,0 +1,16 @@
+package cn.seecoder.courselearning.mapper;
+
+import cn.seecoder.courselearning.model.UserToken;
+import java.util.List;
+
+public interface UserTokenMapper {
+    int deleteByPrimaryKey(String uid);
+
+    int insert(UserToken record);
+
+    UserToken selectByPrimaryKey(String uid);
+
+    List<UserToken> selectAll();
+
+    int updateByPrimaryKey(UserToken record);
+}

+ 200 - 0
src/main/java/cn/seecoder/courselearning/message/AndroidConfig.java

@@ -0,0 +1,200 @@
+/*
+ * Copyright 2020. Huawei Technologies Co., Ltd. All rights reserved.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+ */
+package cn.seecoder.courselearning.message;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import cn.seecoder.courselearning.android.AndroidNotification;
+import cn.seecoder.courselearning.enums.Urgency;
+import cn.seecoder.courselearning.util.ValidatorUtils;
+import org.apache.commons.lang3.StringUtils;
+
+public class AndroidConfig {
+    private static final String TTL_PATTERN = "\\d+|\\d+[sS]|\\d+.\\d{1,9}|\\d+.\\d{1,9}[sS]";
+
+    @JSONField(name = "collapse_key")
+    private Integer collapseKey;
+
+    @JSONField(name = "urgency")
+    private String urgency;
+
+    @JSONField(name = "category")
+    private String category;
+
+    @JSONField(name = "ttl")
+    private String ttl;
+
+    @JSONField(name = "bi_tag")
+    private String biTag;
+
+    @JSONField(name = "fast_app_target")
+    private Integer fastAppTargetType;
+
+    @JSONField(name = "data")
+    private String data;
+
+    @JSONField(name = "notification")
+    private AndroidNotification notification;
+
+    public AndroidConfig(Builder builder) {
+        this.collapseKey = builder.collapseKey;
+        this.urgency = builder.urgency;
+        this.category = builder.category;
+
+        if (null != builder.ttl) {
+            this.ttl = builder.ttl;
+        } else {
+            this.ttl = null;
+        }
+
+        this.biTag = builder.biTag;
+        this.fastAppTargetType = builder.fastAppTargetType;
+        this.data = builder.data;
+        this.notification = builder.notification;
+    }
+
+    /**
+     * check androidConfig's parameters
+     *
+     * @param notification whcic is in message
+     */
+    public void check(Notification notification) {
+        if (this.collapseKey != null) {
+            ValidatorUtils.checkArgument((this.collapseKey >= -1 && this.collapseKey <= 100), "Collapse Key should be [-1, 100]");
+        }
+
+        if (this.urgency != null) {
+            ValidatorUtils.checkArgument(StringUtils.equals(this.urgency, Urgency.HIGH.getValue())
+                            || StringUtils.equals(this.urgency, Urgency.NORMAL.getValue()),
+                    "urgency shouid be [HIGH, NORMAL]");
+        }
+
+        if (StringUtils.isNotEmpty(this.ttl)) {
+            ValidatorUtils.checkArgument(this.ttl.matches(AndroidConfig.TTL_PATTERN), "The TTL's format is wrong");
+        }
+
+        if (this.fastAppTargetType != null) {
+            ValidatorUtils.checkArgument(this.fastAppTargetType == 1 || this.fastAppTargetType == 2, "Invalid fast app target type[one of 1 or 2]");
+        }
+
+        if (null != this.notification) {
+            this.notification.check(notification);
+        }
+    }
+
+    /**
+     * getter
+     */
+    public Integer getCollapseKey() {
+        return collapseKey;
+    }
+
+    public String getTtl() {
+        return ttl;
+    }
+
+    public String getCategory() {
+        return category;
+    }
+
+    public String getBiTag() {
+        return biTag;
+    }
+
+    public Integer getFastAppTargetType() {
+        return fastAppTargetType;
+    }
+
+    public AndroidNotification getNotification() {
+        return notification;
+    }
+
+    public String getUrgency() {
+        return urgency;
+    }
+
+    public String getData() {
+        return data;
+    }
+
+    /**
+     * builder
+     */
+    public static Builder builder() {
+        return new Builder();
+    }
+
+    public static class Builder {
+        private Integer collapseKey;
+        private String urgency;
+        private String category;
+        private String ttl;
+        private String biTag;
+        private Integer fastAppTargetType;
+        private String data;
+
+        private AndroidNotification notification;
+
+        private Builder() {
+        }
+
+        public Builder setCollapseKey(Integer collapseKey) {
+            this.collapseKey = collapseKey;
+            return this;
+        }
+
+        public Builder setUrgency(String urgency) {
+            this.urgency = urgency;
+            return this;
+        }
+
+        public Builder setCategory(String category) {
+            this.category = category;
+            return this;
+        }
+
+        /**
+         * time-to-live
+         */
+        public Builder setTtl(String ttl) {
+            this.ttl = ttl;
+            return this;
+        }
+
+        public Builder setBiTag(String biTag) {
+            this.biTag = biTag;
+            return this;
+        }
+
+        public Builder setFastAppTargetType(Integer fastAppTargetType) {
+            this.fastAppTargetType = fastAppTargetType;
+            return this;
+        }
+
+        public Builder setData(String data) {
+            this.data = data;
+            return this;
+        }
+
+        public Builder setNotification(AndroidNotification notification) {
+            this.notification = notification;
+            return this;
+        }
+
+        public AndroidConfig build() {
+            return new AndroidConfig(this);
+        }
+    }
+}

+ 214 - 0
src/main/java/cn/seecoder/courselearning/message/Message.java

@@ -0,0 +1,214 @@
+/*
+ * Copyright 2020. Huawei Technologies Co., Ltd. All rights reserved.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+ */
+package cn.seecoder.courselearning.message;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import cn.seecoder.courselearning.util.CollectionUtils;
+import cn.seecoder.courselearning.util.ValidatorUtils;
+import com.google.common.base.Strings;
+import com.google.common.primitives.Booleans;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Message {
+    @JSONField(name = "data")
+    private String data;
+
+    @JSONField(name = "notification")
+    private Notification notification;
+
+    @JSONField(name = "android")
+    private AndroidConfig androidConfig;
+
+//    @JSONField(name = "apns")
+//    private ApnsConfig apns;
+//
+//    @JSONField(name = "webpush")
+//    private WebPushConfig webpush;
+
+    @JSONField(name = "token")
+    private List<String> token = new ArrayList<>();
+
+    @JSONField(name = "topic")
+    private String topic;
+
+    @JSONField(name = "condition")
+    private String condition;
+
+    private Message(Builder builder) {
+        this.data = builder.data;
+        this.notification = builder.notification;
+        this.androidConfig = builder.androidConfig;
+//        this.apns = builder.apns;
+//        this.webpush = builder.webpush;
+
+        if (!CollectionUtils.isEmpty(builder.token)) {
+            this.token.addAll(builder.token);
+        } else {
+            this.token = null;
+        }
+
+        this.topic = builder.topic;
+        this.condition = builder.condition;
+
+        /** check after message is created */
+        check();
+    }
+
+    /**
+     * check message's parameters
+     */
+    public void check() {
+
+        int count = Booleans.countTrue(
+                !CollectionUtils.isEmpty(this.token),
+                !Strings.isNullOrEmpty(this.topic),
+                !Strings.isNullOrEmpty(this.condition)
+        );
+
+        ValidatorUtils.checkArgument(count == 1, "Exactly one of token, topic or condition must be specified");
+
+        boolean isEmptyData = StringUtils.isEmpty(data);
+
+        if (this.notification != null) {
+            this.notification.check();
+        }
+
+        if (null != this.androidConfig) {
+            this.androidConfig.check(this.notification);
+        }
+
+//        if (this.apns != null) {
+//            this.apns.check();
+//        }
+//
+//        if (this.webpush != null) {
+//            this.webpush.check();
+//        }
+    }
+
+    /**
+     * getter
+     */
+    public String getData() {
+        return data;
+    }
+
+    public Notification getNotification() {
+        return notification;
+    }
+
+    public AndroidConfig getAndroidConfig() {
+        return androidConfig;
+    }
+
+//    public ApnsConfig getApns() {
+//        return apns;
+//    }
+//
+//    public WebPushConfig getWebpush() {
+//        return webpush;
+//    }
+
+    public List<String> getToken() {
+        return token;
+    }
+
+    public String getTopic() {
+        return topic;
+    }
+
+    public String getCondition() {
+        return condition;
+    }
+
+    /**
+     * builder
+     *
+     * @return
+     */
+    public static Builder builder() {
+        return new Builder();
+    }
+
+    /**
+     * push message builder
+     */
+    public static class Builder {
+        private String data;
+        private Notification notification;
+        private AndroidConfig androidConfig;
+//        private ApnsConfig apns;
+//        private WebPushConfig webpush;
+        private List<String> token = new ArrayList<>();
+        private String topic;
+        private String condition;
+
+        private Builder() {
+        }
+
+        public Builder setData(String data) {
+            this.data = data;
+            return this;
+        }
+
+        public Builder setNotification(Notification notification) {
+            this.notification = notification;
+            return this;
+        }
+
+        public Builder setAndroidConfig(AndroidConfig androidConfig) {
+            this.androidConfig = androidConfig;
+            return this;
+        }
+
+//        public Builder setApns(ApnsConfig apns) {
+//            this.apns = apns;
+//            return this;
+//        }
+//
+//        public Builder setWebpush(WebPushConfig webpush) {
+//            this.webpush = webpush;
+//            return this;
+//        }
+
+        public Builder addToken(String token) {
+            this.token.add(token);
+            return this;
+        }
+
+        public Builder addAllToken(List<String> tokens) {
+            this.token.addAll(tokens);
+            return this;
+        }
+
+        public Builder setTopic(String topic) {
+            this.topic = topic;
+            return this;
+        }
+
+        public Builder setCondition(String condition) {
+            this.condition = condition;
+            return this;
+        }
+
+        public Message build() {
+            return new Message(this);
+        }
+    }
+}

+ 122 - 0
src/main/java/cn/seecoder/courselearning/message/Notification.java

@@ -0,0 +1,122 @@
+/*
+ * Copyright 2020. Huawei Technologies Co., Ltd. All rights reserved.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+ */
+package cn.seecoder.courselearning.message;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import cn.seecoder.courselearning.util.ValidatorUtils;
+
+import java.util.Locale;
+
+public class Notification {
+    @JSONField(name = "title")
+    private String title;
+
+    @JSONField(name = "body")
+    private String body;
+
+    @JSONField(name = "image")
+    private String image;
+
+    public Notification() {
+    }
+
+    public Notification(String title, String body) {
+        this.title = title;
+        this.body = body;
+    }
+
+    public Notification(String title, String body, String image) {
+        this.title = title;
+        this.body = body;
+        this.image = image;
+    }
+
+    public Notification(Builder builder) {
+        this.title = builder.title;
+        this.body = builder.body;
+        this.image = builder.image;
+    }
+
+    public void check() {
+        if (this.image != null) {
+            ValidatorUtils.checkArgument(this.image.toLowerCase(Locale.getDefault()).trim().startsWith("https"), "image's url should start with HTTPS");
+        }
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public String getBody() {
+        return body;
+    }
+
+    public void setBody(String body) {
+        this.body = body;
+    }
+
+    public String getImage() {
+        return image;
+    }
+
+    public void setImage(String image) {
+        this.image = image;
+    }
+
+    /**
+     * builder
+     *
+     * @return
+     */
+    public static Builder builder() {
+        return new Builder();
+    }
+
+    /**
+     * push message builder
+     */
+    public static class Builder {
+        private String title;
+
+        private String body;
+
+        private String image;
+
+        public Builder setTitle(String title) {
+            this.title = title;
+            return this;
+        }
+
+        public Builder setBody(String body) {
+            this.body = body;
+            return this;
+        }
+
+        public Builder setImage(String image) {
+            this.image = image;
+            return this;
+        }
+
+        public Notification build() {
+            return new Notification(this);
+        }
+
+    }
+}

+ 53 - 0
src/main/java/cn/seecoder/courselearning/message/TokenMessage.java

@@ -0,0 +1,53 @@
+/*
+ * Copyright 2020. Huawei Technologies Co., Ltd. All rights reserved.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+ */
+package cn.seecoder.courselearning.message;
+
+import com.alibaba.fastjson.annotation.JSONField;
+
+public class TokenMessage {
+    @JSONField(name = "token")
+    private String token;
+
+    public String getToken() {
+        return token;
+    }
+
+    public TokenMessage(Builder builder) {
+        this.token = builder.token;
+    }
+
+    /**
+     * builder
+     *
+     * @return
+     */
+    public static Builder builder() {
+        return new Builder();
+    }
+
+    public static class Builder {
+        private String token;
+
+        public Builder setToken(String token) {
+            this.token = token;
+            return this;
+        }
+
+        public TokenMessage build() {
+            return new TokenMessage(this);
+        }
+    }
+}

+ 96 - 0
src/main/java/cn/seecoder/courselearning/message/TopicMessage.java

@@ -0,0 +1,96 @@
+/*
+ * Copyright 2020. Huawei Technologies Co., Ltd. All rights reserved.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+ */
+package cn.seecoder.courselearning.message;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import cn.seecoder.courselearning.util.CollectionUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class TopicMessage {
+    @JSONField(name = "topic")
+    private String topic;
+
+    @JSONField(name = "tokenArray")
+    private List<String> tokenArray = new ArrayList<String>();
+
+    @JSONField(name = "token")
+    private String token;
+
+    public String getTopic() {
+        return topic;
+    }
+
+    public List<String> getTokenArray() {
+        return tokenArray;
+    }
+
+    public String getToken() {
+        return token;
+    }
+
+    private TopicMessage(Builder builder) {
+        this.topic = builder.topic;
+        if (!CollectionUtils.isEmpty(builder.tokenArray)) {
+            this.tokenArray.addAll(builder.tokenArray);
+        } else {
+            this.tokenArray = null;
+        }
+        this.token = builder.token;
+    }
+
+    /**
+     * builder
+     *
+     * @return
+     */
+    public static Builder builder() {
+        return new Builder();
+    }
+
+    public static class Builder {
+        private String topic;
+        private List<String> tokenArray = new ArrayList<String>();
+        private String token;
+
+        public Builder setTopic(String topic) {
+            this.topic = topic;
+            return this;
+        }
+
+        public Builder addToken(String token) {
+            this.tokenArray.add(token);
+            return this;
+        }
+
+        public Builder addAllToken(List<String> tokenArray) {
+            this.tokenArray.addAll(tokenArray);
+            return this;
+        }
+
+        public Builder setToken(String token) {
+            this.token = token;
+            return this;
+        }
+
+        public TopicMessage build() {
+            return new TopicMessage(this);
+        }
+
+    }
+
+}

+ 272 - 0
src/main/java/cn/seecoder/courselearning/messaging/HuaweiApp.java

@@ -0,0 +1,272 @@
+/* Copyright 2017 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+
+ *  2019.12.15-Changed constructor HuaweiApp
+ *  2019.12.15-Changed method initializeApp
+ *                  Huawei Technologies Co., Ltd.
+ *
+ */
+package cn.seecoder.courselearning.messaging;
+
+import cn.seecoder.courselearning.util.ValidatorUtils;
+import com.google.common.collect.ImmutableList;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.text.MessageFormat;
+import java.util.*;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/**
+ * The entry point of Huawei Java SDK.
+ * <p>{@link HuaweiApp#initializeApp(HuaweiOption)} initializes the app instance.
+ */
+public class HuaweiApp {
+    private static final Logger logger = LoggerFactory.getLogger(HuaweiApp.class);
+
+    private String appId;
+    private HuaweiOption option;
+
+    /**
+     * Global lock
+     */
+    private static final Object appsLock = new Object();
+
+    /**
+     * Store a map of <appId, HuaweiApp>
+     */
+    private static final Map<String, HuaweiApp> instances = new HashMap<>();
+
+    /**
+     * HuaweiMessaging can be added in the pattern of service, whcih is designed for Scalability
+     */
+    private final Map<String, HuaweiService> services = new HashMap<>();
+
+    private TokenRefresher tokenRefresher;
+
+    private volatile ScheduledExecutorService scheduledExecutor;
+
+    private ThreadManager threadManager;
+
+    private ThreadManager.HuaweiExecutors executors;
+
+    private final AtomicBoolean deleted = new AtomicBoolean();
+
+    /**
+     * lock for synchronizing all internal HuaweiApp state changes
+     */
+    private final Object lock = new Object();
+
+    private HuaweiApp(HuaweiOption option) {
+        ValidatorUtils.checkArgument(option != null, "HuaweiOption must not be null");
+        this.option = option;
+        this.appId = option.getCredential().getAppId();
+        this.tokenRefresher = new TokenRefresher(this);
+        this.threadManager = option.getThreadManager();
+        this.executors = threadManager.getHuaweiExecutors(this);
+    }
+
+    public HuaweiOption getOption() {
+        return option;
+    }
+
+    public String getAppId() {
+        return appId;
+    }
+
+    /**
+     * Returns the instance identified by the unique appId, or throws if it does not exist.
+     *
+     * @param appId represents the id of the {@link HuaweiApp} instance.
+     * @return the {@link HuaweiApp} corresponding to the id.
+     * @throws IllegalStateException if the {@link HuaweiApp} was not initialized, either via {@link
+     *                               #initializeApp(HuaweiOption)} or {@link #getApps()}.
+     */
+    public static HuaweiApp getInstance(HuaweiOption option) {
+        String appId = option.getCredential().getAppId();
+        synchronized (appsLock) {
+            HuaweiApp app = instances.get(appId);
+            if (app != null) {
+                return app;
+            }
+//            String errorMessage = MessageFormat.format("HuaweiApp with id {0} doesn't exist", appId);
+//            throw new IllegalStateException(errorMessage);
+            return initializeApp(option);
+        }
+    }
+
+    /**
+     * Initializes the {@link HuaweiApp} instance using the given option.
+     *
+     * @throws IllegalStateException if the app instance has already been initialized.
+     */
+    public static HuaweiApp initializeApp(HuaweiOption option) {
+        String appId = option.getCredential().getAppId();
+        final HuaweiApp app;
+        synchronized (appsLock) {
+            if (!instances.containsKey(appId)) {
+                ValidatorUtils.checkState(!instances.containsKey(appId), "HuaweiApp with id " + appId + " already exists!");
+                app = new HuaweiApp(option);
+                instances.put(appId, app);
+                app.startTokenRefresher();
+            } else {
+                app = getInstance(option);
+            }
+
+        }
+        return app;
+    }
+
+    /**
+     * Returns a list of all HuaweiApps.
+     */
+    public static List<HuaweiApp> getApps() {
+        synchronized (appsLock) {
+            return ImmutableList.copyOf(instances.values());
+        }
+    }
+
+    /**
+     * Get all appIds which are be stored in the instances
+     */
+    public static List<String> getAllAppIds() {
+        Set<String> allAppIds = new HashSet<>();
+        synchronized (appsLock) {
+            for (HuaweiApp app : instances.values()) {
+                allAppIds.add(app.getAppId());
+            }
+        }
+        List<String> sortedIdList = new ArrayList<>(allAppIds);
+        Collections.sort(sortedIdList);
+        return sortedIdList;
+    }
+
+    /**
+     * Deletes the {@link HuaweiApp} and all its data. All calls to this {@link HuaweiApp}
+     * instance will throw once it has been called.
+     *
+     * <p>A no-op if delete was called before.
+     */
+    public void delete() {
+        synchronized (lock) {
+            boolean valueChanged = deleted.compareAndSet(false /* expected */, true);
+            if (!valueChanged) {
+                return;
+            }
+
+            try {
+                this.getOption().getHttpClient().close();
+                this.getOption().getCredential().getHttpClient().close();
+            } catch (IOException e) {
+                logger.debug("Fail to close httpClient");
+            }
+
+            for (HuaweiService service : services.values()) {
+                service.destroy();
+            }
+            services.clear();
+            tokenRefresher.stop();
+
+            threadManager.releaseHuaweiExecutors(this, executors);
+            if (scheduledExecutor != null) {
+                scheduledExecutor.shutdown();
+                scheduledExecutor = null;
+            }
+        }
+
+        synchronized (appsLock) {
+            instances.remove(this.getAppId());
+        }
+    }
+
+    /**
+     * Check the app is not deleted, whcic is the premisi of some methods
+     */
+    private void checkNotDeleted() {
+        String errorMessage = MessageFormat.format("HuaweiApp with id {0} was deleted", getAppId());
+        ValidatorUtils.checkState(!deleted.get(), errorMessage);
+    }
+
+    /**
+     * Singleton mode, ensure the scheduleExecutor is singleton
+     */
+    private ScheduledExecutorService singleScheduledExecutorService() {
+        if (scheduledExecutor == null) {
+            synchronized (lock) {
+                checkNotDeleted();
+                if (scheduledExecutor == null) {
+                    scheduledExecutor = new HuaweiScheduledExecutor(getThreadFactory(), "huawei-scheduled-worker");
+                }
+            }
+        }
+        return scheduledExecutor;
+    }
+
+    public ThreadFactory getThreadFactory() {
+        return threadManager.getThreadFactory();
+    }
+
+    private ScheduledExecutorService getScheduledExecutorService() {
+        return singleScheduledExecutorService();
+    }
+
+    ScheduledFuture<?> schedule(Runnable runnable, long initialDelay, long period) {
+        return getScheduledExecutorService().scheduleWithFixedDelay(runnable, initialDelay, period, TimeUnit.MILLISECONDS);
+    }
+
+    /**
+     * Add service to the app, such as HuaweiMessaging, other services can be added if needed
+     */
+    void addService(HuaweiService service) {
+        synchronized (lock) {
+            checkNotDeleted();
+            ValidatorUtils.checkArgument(!services.containsKey(service.getId()), "service already exists");
+            services.put(service.getId(), service);
+        }
+    }
+
+    HuaweiService getService(String id) {
+        synchronized (lock) {
+            return services.get(id);
+        }
+    }
+
+    /**
+     * Start the scheduled task for refreshing token automatically
+     */
+    public void startTokenRefresher() {
+        synchronized (lock) {
+            checkNotDeleted();
+            tokenRefresher.start();
+        }
+    }
+
+    /**
+     * It is just for test
+     */
+    public static void clearInstancesForTest() {
+        synchronized (appsLock) {
+            //copy before delete
+            for (HuaweiApp app : ImmutableList.copyOf(instances.values())) {
+                app.delete();
+            }
+            instances.clear();
+        }
+    }
+}

+ 168 - 0
src/main/java/cn/seecoder/courselearning/messaging/HuaweiCredential.java

@@ -0,0 +1,168 @@
+/*
+ * Copyright 2020. Huawei Technologies Co., Ltd. All rights reserved.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+ */
+package cn.seecoder.courselearning.messaging;
+
+import com.alibaba.fastjson.JSONObject;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.util.EntityUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.text.MessageFormat;
+import java.util.ResourceBundle;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+/**
+ * Accept the appId and appSecret given by the user and build the credential
+ * Every app has a credential which is for certification
+ */
+public class HuaweiCredential {
+    private static final Logger logger = LoggerFactory.getLogger(HuaweiCredential.class);
+
+    private final String PUSH_AT_URL = ResourceBundle.getBundle("url").getString("token_server");
+
+    private String appId;
+    private String appSecret;
+
+    private String accessToken;
+    private long expireIn;
+    private Lock lock;
+    private CloseableHttpClient httpClient;
+
+    private HuaweiCredential(Builder builder) {
+        this.lock = new ReentrantLock();
+        this.appId = builder.appId;
+        this.appSecret = builder.appSecret;
+        if (builder.httpClient == null) {
+            httpClient = HttpClients.createDefault();
+        } else {
+            this.httpClient = builder.httpClient;
+        }
+    }
+
+    /**
+     * Refresh accessToken via HCM manually.
+     */
+    public final void refreshToken() {
+        try {
+            executeRefresh();
+        } catch (IOException e) {
+            logger.debug("Fail to refresh token!", e);
+        }
+    }
+
+    private void executeRefresh() throws IOException {
+        String requestBody = createRequestBody(appId, appSecret);
+
+        HttpPost httpPost = new HttpPost(PUSH_AT_URL);
+        StringEntity entity = new StringEntity(requestBody);
+        httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
+        httpPost.setEntity(entity);
+        CloseableHttpResponse response = httpClient.execute(httpPost);
+        String jsonStr = EntityUtils.toString(response.getEntity());
+        int statusCode = response.getStatusLine().getStatusCode();
+        if (statusCode == 200) {
+            JSONObject jsonObject = JSONObject.parseObject(jsonStr);
+            this.accessToken = jsonObject.getString("access_token");
+            this.expireIn = jsonObject.getLong("expires_in") * 1000L;
+        } else {
+            logger.debug("Fail to refresh token!");
+        }
+    }
+
+    private String createRequestBody(String appId, String appSecret) {
+        return MessageFormat.format("grant_type=client_credentials&client_secret={0}&client_id={1}", appSecret, appId);
+    }
+
+    /**
+     * getter
+     */
+    public final String getAccessToken() {
+        this.lock.lock();
+
+        String tmp;
+        try {
+            tmp = this.accessToken;
+        } finally {
+            this.lock.unlock();
+        }
+
+        return tmp;
+    }
+
+    public final long getExpireIn() {
+        this.lock.lock();
+
+        long tmp;
+        try {
+            tmp = this.expireIn;
+        } finally {
+            this.lock.unlock();
+        }
+
+        return tmp;
+    }
+
+    protected CloseableHttpClient getHttpClient() {
+        return httpClient;
+    }
+
+    public String getAppId() {
+        return appId;
+    }
+
+    /**
+     * Builder for constructing {@link HuaweiCredential}.
+     */
+    public static Builder builder() {
+        return new Builder();
+    }
+
+    public static class Builder {
+        private String appId;
+        private String appSecret;
+
+        private CloseableHttpClient httpClient;
+
+        private Builder() {
+        }
+
+        public Builder setAppId(String appId) {
+            this.appId = appId;
+            return this;
+        }
+
+        public Builder setAppSecret(String appSecret) {
+            this.appSecret = appSecret;
+            return this;
+        }
+
+        public Builder setHttpClient(CloseableHttpClient httpClient) {
+            this.httpClient = httpClient;
+            return this;
+        }
+
+        public HuaweiCredential build() {
+            return new HuaweiCredential(this);
+        }
+    }
+}

+ 39 - 0
src/main/java/cn/seecoder/courselearning/messaging/HuaweiMessageClient.java

@@ -0,0 +1,39 @@
+/*
+ * Copyright 2020. Huawei Technologies Co., Ltd. All rights reserved.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+ */
+package cn.seecoder.courselearning.messaging;
+
+import cn.seecoder.courselearning.exception.HuaweiMessagingException;
+import cn.seecoder.courselearning.message.Message;
+import cn.seecoder.courselearning.message.TopicMessage;
+import cn.seecoder.courselearning.reponse.SendResponse;
+
+/**
+ * sending messages interface
+ */
+public interface HuaweiMessageClient {
+
+    /**
+     * Sends the given message with HCM.
+     *
+     * @param message      message {@link Message}
+     * @param validateOnly A boolean indicating whether to send message for test. or not.
+     * @return {@link SendResponse}.
+     * @throws HuaweiMessagingException
+     */
+    SendResponse send(Message message, boolean validateOnly, String accessToken) throws HuaweiMessagingException;
+
+    SendResponse send(TopicMessage message, String operation, String accessToken) throws HuaweiMessagingException;
+}

+ 216 - 0
src/main/java/cn/seecoder/courselearning/messaging/HuaweiMessageClientImpl.java

@@ -0,0 +1,216 @@
+/*
+ * Copyright 2020. Huawei Technologies Co., Ltd. All rights reserved.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+ */
+package cn.seecoder.courselearning.messaging;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import cn.seecoder.courselearning.exception.HuaweiMessagingException;
+import cn.seecoder.courselearning.message.Message;
+import cn.seecoder.courselearning.message.TopicMessage;
+import cn.seecoder.courselearning.enums.TopicOperation;
+import cn.seecoder.courselearning.reponse.SendResponse;
+import cn.seecoder.courselearning.reponse.TopicListResponse;
+import cn.seecoder.courselearning.reponse.TopicSendResponse;
+import cn.seecoder.courselearning.util.ResponceCodeProcesser;
+import cn.seecoder.courselearning.util.ValidatorUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.http.client.HttpResponseException;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.util.EntityUtils;
+
+import java.io.IOException;
+import java.text.MessageFormat;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.ResourceBundle;
+
+public class HuaweiMessageClientImpl implements HuaweiMessageClient {
+    private static final String PUSH_URL = ResourceBundle.getBundle("url").getString("push_open_url");
+
+    private final String HcmPushUrl;
+    private String hcmTopicUrl;
+    private String hcmGroupUrl;
+    private String hcmTokenUrl;
+    private final CloseableHttpClient httpClient;
+
+    private HuaweiMessageClientImpl(Builder builder) {
+        this.HcmPushUrl = MessageFormat.format(PUSH_URL + "/v1/{0}/messages:send", builder.appId);
+        this.hcmTopicUrl = MessageFormat.format(PUSH_URL + "/v1/{0}/topic:{1}", builder.appId);
+
+        ValidatorUtils.checkArgument(builder.httpClient != null, "requestFactory must not be null");
+        this.httpClient = builder.httpClient;
+    }
+
+    /**
+     * getter
+     */
+    public String getHcmSendUrl() {
+        return HcmPushUrl;
+    }
+
+    public CloseableHttpClient getHttpClient() {
+        return httpClient;
+    }
+
+    @Override
+    public SendResponse send(Message message, boolean validateOnly, String accessToken) throws HuaweiMessagingException {
+        try {
+            return sendRequest(message, validateOnly, accessToken);
+        } catch (IOException e) {
+            throw new HuaweiMessagingException(HuaweiMessaging.INTERNAL_ERROR, "Error while calling HCM backend service", e);
+        }
+    }
+
+    @Override
+    public SendResponse send(TopicMessage message, String operation, String accessToken) throws HuaweiMessagingException {
+        try {
+            return sendRequest(message, operation, accessToken);
+        } catch (IOException e) {
+            throw new HuaweiMessagingException(HuaweiMessaging.INTERNAL_ERROR, "Error while calling HCM backend service", e);
+        }
+    }
+
+    private SendResponse sendRequest(TopicMessage message, String operation, String accessToken) throws IOException, HuaweiMessagingException {
+        this.hcmTopicUrl = MessageFormat.format(hcmTopicUrl, "", operation);
+        HttpPost httpPost = new HttpPost(this.hcmTopicUrl);
+        StringEntity entity = new StringEntity(JSON.toJSONString(message), "UTF-8");
+        httpPost.setHeader("Authorization", "Bearer " + accessToken);
+        httpPost.setHeader("Content-Type", "application/json;charset=utf-8");
+        httpPost.setEntity(entity);
+        CloseableHttpResponse response = httpClient.execute(httpPost);
+        String rpsContent = EntityUtils.toString(response.getEntity());
+        int statusCode = response.getStatusLine().getStatusCode();
+        if (statusCode == 200) {
+            JSONObject jsonObject = JSONObject.parseObject(rpsContent);
+            String code = jsonObject.getString("code");
+            String msg = jsonObject.getString("msg");
+            String requestId = jsonObject.getString("requestId");
+            if (StringUtils.equals(code, "80000000")) {
+                SendResponse sendResponse;
+                if (StringUtils.equals(operation, TopicOperation.LIST.getValue())) {
+                    JSONArray topics = jsonObject.getJSONArray("topics");
+                    sendResponse = TopicListResponse.fromCode(code, ResponceCodeProcesser.process(Integer.valueOf(code)), requestId, topics);
+                } else {
+                    Integer failureCount = jsonObject.getInteger("failureCount");
+                    Integer successCount = jsonObject.getInteger("successCount");
+                    JSONArray errors = jsonObject.getJSONArray("errors");
+                    sendResponse = TopicSendResponse.fromCode(code, ResponceCodeProcesser.process(Integer.valueOf(code)), requestId, failureCount, successCount, errors);
+                }
+                return sendResponse;
+            } else {
+                String errorMsg = MessageFormat.format("error code : {0}, error message : {1}", String.valueOf(code), ResponceCodeProcesser.process(Integer.valueOf(code)));
+                throw new HuaweiMessagingException(HuaweiMessaging.KNOWN_ERROR, errorMsg);
+            }
+        }
+        HttpResponseException exception = new HttpResponseException(statusCode, rpsContent);
+        throw createExceptionFromResponse(exception);
+    }
+
+    /**
+     * send request
+     *
+     * @param message      message {@link Message}
+     * @param validateOnly A boolean indicating whether to send message for test or not.
+     * @param accessToken  A String for oauth
+     * @return {@link SendResponse}
+     * @throws IOException If a error occurs when sending request
+     */
+    private SendResponse sendRequest(Message message, boolean validateOnly, String accessToken) throws IOException, HuaweiMessagingException {
+        Map<String, Object> map = createRequestMap(message, validateOnly);
+        HttpPost httpPost = new HttpPost(this.HcmPushUrl);
+        StringEntity entity = new StringEntity(JSON.toJSONString(map), "UTF-8");
+        httpPost.setHeader("Authorization", "Bearer " + accessToken);
+        httpPost.setHeader("Content-Type", "application/json;charset=utf-8");
+        httpPost.setEntity(entity);
+        CloseableHttpResponse response = httpClient.execute(httpPost);
+        String rpsContent = EntityUtils.toString(response.getEntity());
+        int statusCode = response.getStatusLine().getStatusCode();
+        if (statusCode == 200) {
+            JSONObject jsonObject = JSONObject.parseObject(rpsContent);
+            String code = jsonObject.getString("code");
+            String msg = jsonObject.getString("msg");
+            String requestId = jsonObject.getString("requestId");
+            if (StringUtils.equals(code, "80000000")) {
+                return SendResponse.fromCode(code, ResponceCodeProcesser.process(Integer.valueOf(code)), requestId);
+            } else {
+                String errorMsg = MessageFormat.format("error code : {0}, error message : {1}", String.valueOf(code), ResponceCodeProcesser.process(Integer.valueOf(code)));
+                throw new HuaweiMessagingException(HuaweiMessaging.KNOWN_ERROR, errorMsg);
+            }
+        }
+        HttpResponseException exception = new HttpResponseException(statusCode, rpsContent);
+        throw createExceptionFromResponse(exception);
+    }
+
+    /**
+     * create the map of the request body, mostly for wrapping the message with validate_only
+     *
+     * @param message      A non-null {@link Message} to be sent.
+     * @param validateOnly A boolean indicating whether to send message for test or not.
+     * @return a map of request
+     */
+    private Map<String, Object> createRequestMap(Message message, boolean validateOnly) {
+        return new HashMap<String, Object>() {
+            {
+                put("validate_only", validateOnly);
+                put("message", message);
+            }
+        };
+    }
+
+    private HuaweiMessagingException createExceptionFromResponse(HttpResponseException e) {
+        String msg = MessageFormat.format("Unexpected HTTP response with status : {0}, body : {1}", e.getStatusCode(), e.getMessage());
+        return new HuaweiMessagingException(HuaweiMessaging.UNKNOWN_ERROR, msg, e);
+    }
+
+    static HuaweiMessageClientImpl fromApp(HuaweiApp app) {
+        String appId = ImplHuaweiTrampolines.getAppId(app);
+        return HuaweiMessageClientImpl.builder()
+                .setAppId(appId)
+                .setHttpClient(app.getOption().getHttpClient())
+                .build();
+    }
+
+    static Builder builder() {
+        return new Builder();
+    }
+
+    static final class Builder {
+
+        private String appId;
+        private CloseableHttpClient httpClient;
+
+        private Builder() {
+        }
+
+        public Builder setAppId(String appId) {
+            this.appId = appId;
+            return this;
+        }
+
+        public Builder setHttpClient(CloseableHttpClient httpClient) {
+            this.httpClient = httpClient;
+            return this;
+        }
+
+        public HuaweiMessageClientImpl build() {
+            return new HuaweiMessageClientImpl(this);
+        }
+    }
+}

+ 181 - 0
src/main/java/cn/seecoder/courselearning/messaging/HuaweiMessaging.java

@@ -0,0 +1,181 @@
+/*
+ * Copyright 2020. Huawei Technologies Co., Ltd. All rights reserved.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+ */
+package cn.seecoder.courselearning.messaging;
+
+import cn.seecoder.courselearning.exception.HuaweiMessagingException;
+import cn.seecoder.courselearning.message.Message;
+import cn.seecoder.courselearning.message.TopicMessage;
+import cn.seecoder.courselearning.enums.TopicOperation;
+import cn.seecoder.courselearning.reponse.SendResponse;
+import cn.seecoder.courselearning.util.ValidatorUtils;
+import com.google.common.base.Supplier;
+import com.google.common.base.Suppliers;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class is the entrance for all server-side HCM actions.
+ *
+ * <p>You can get a instance of {@link cn.seecoder.courselearning.messaging.HuaweiMessaging}
+ * by a instance of {@link cn.seecoder.courselearning.messaging.HuaweiApp}, and then use it to send a message
+ */
+public class HuaweiMessaging {
+    private static final Logger logger = LoggerFactory.getLogger(HuaweiMessaging.class);
+
+    static final String INTERNAL_ERROR = "internal error";
+
+    static final String UNKNOWN_ERROR = "unknown error";
+
+    static final String KNOWN_ERROR = "known error";
+
+    private final HuaweiApp app;
+    private final Supplier<? extends HuaweiMessageClient> messagingClient;
+
+    private HuaweiMessaging(Builder builder) {
+        this.app = builder.app;
+        this.messagingClient = Suppliers.memoize(builder.messagingClient);
+    }
+
+    /**
+     * Gets the {@link HuaweiMessaging} instance for the specified {@link HuaweiApp}.
+     *
+     * @return The {@link HuaweiMessaging} instance for the specified {@link HuaweiApp}.
+     */
+    public static synchronized HuaweiMessaging getInstance(HuaweiApp app) {
+        HuaweiMessagingService service = ImplHuaweiTrampolines.getService(app, SERVICE_ID, HuaweiMessagingService.class);
+        if (service == null) {
+            service = ImplHuaweiTrampolines.addService(app, new HuaweiMessagingService(app));
+        }
+        return service.getInstance();
+    }
+
+    private static HuaweiMessaging fromApp(final HuaweiApp app) {
+        return HuaweiMessaging.builder()
+                .setApp(app)
+                .setMessagingClient(() -> HuaweiMessageClientImpl.fromApp(app))
+                .build();
+    }
+
+    HuaweiMessageClient getMessagingClient() {
+        return messagingClient.get();
+    }
+
+    /**
+     * Sends the given {@link Message} via HCM.
+     *
+     * @param message A non-null {@link Message} to be sent.
+     * @return {@link SendResponse}.
+     * @throws HuaweiMessagingException If an error occurs while handing the message off to HCM for
+     *                                   delivery.
+     */
+    public SendResponse sendMessage(Message message) throws HuaweiMessagingException {
+        return sendMessage(message, false);
+    }
+
+    /**
+     * @param topicMessage topicmessage
+     * @return topic subscribe response
+     * @throws HuaweiMessagingException
+     */
+    public SendResponse subscribeTopic(TopicMessage topicMessage) throws HuaweiMessagingException {
+        final HuaweiMessageClient messagingClient = getMessagingClient();
+        return messagingClient.send(topicMessage, TopicOperation.SUBSCRIBE.getValue(), ImplHuaweiTrampolines.getAccessToken(app));
+    }
+
+    /**
+     * @param topicMessage topic Message
+     * @return topic unsubscribe response
+     * @throws HuaweiMessagingException
+     */
+    public SendResponse unsubscribeTopic(TopicMessage topicMessage) throws HuaweiMessagingException {
+        final HuaweiMessageClient messagingClient = getMessagingClient();
+        return messagingClient.send(topicMessage, TopicOperation.UNSUBSCRIBE.getValue(), ImplHuaweiTrampolines.getAccessToken(app));
+    }
+
+    /**
+     * @param topicMessage topic Message
+     * @return topic list
+     * @throws HuaweiMessagingException
+     */
+    public SendResponse listTopic(TopicMessage topicMessage) throws HuaweiMessagingException {
+        final HuaweiMessageClient messagingClient = getMessagingClient();
+        return messagingClient.send(topicMessage, TopicOperation.LIST.getValue(), ImplHuaweiTrampolines.getAccessToken(app));
+    }
+
+
+    /**
+     * Sends message {@link Message}
+     *
+     * <p>If the {@code validateOnly} option is set to true, the message will not be actually sent. Instead
+     * HCM performs all the necessary validations, and emulates the send operation.
+     *
+     * @param message      message {@link Message} to be sent.
+     * @param validateOnly a boolean indicating whether to send message for test or not.
+     * @return {@link SendResponse}.
+     * @throws HuaweiMessagingException exception.
+     */
+    public SendResponse sendMessage(Message message, boolean validateOnly) throws HuaweiMessagingException {
+        ValidatorUtils.checkArgument(message != null, "message must not be null");
+        final HuaweiMessageClient messagingClient = getMessagingClient();
+        return messagingClient.send(message, validateOnly, ImplHuaweiTrampolines.getAccessToken(app));
+    }
+
+    /**
+     * HuaweiMessagingService
+     */
+    private static final String SERVICE_ID = HuaweiMessaging.class.getName();
+
+    private static class HuaweiMessagingService extends HuaweiService<HuaweiMessaging> {
+
+        HuaweiMessagingService(HuaweiApp app) {
+            super(SERVICE_ID, HuaweiMessaging.fromApp(app));
+        }
+
+        @Override
+        public void destroy() {
+
+        }
+    }
+
+    /**
+     * Builder for constructing {@link HuaweiMessaging}.
+     */
+    static Builder builder() {
+        return new Builder();
+    }
+
+    static class Builder {
+        private HuaweiApp app;
+        private Supplier<? extends HuaweiMessageClient> messagingClient;
+
+        private Builder() {
+        }
+
+        public Builder setApp(HuaweiApp app) {
+            this.app = app;
+            return this;
+        }
+
+        public Builder setMessagingClient(Supplier<? extends HuaweiMessageClient> messagingClient) {
+            this.messagingClient = messagingClient;
+            return this;
+        }
+
+        public HuaweiMessaging build() {
+            return new HuaweiMessaging(this);
+        }
+    }
+}

+ 114 - 0
src/main/java/cn/seecoder/courselearning/messaging/HuaweiOption.java

@@ -0,0 +1,114 @@
+/*
+ * Copyright 2020. Huawei Technologies Co., Ltd. All rights reserved.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+ */
+package cn.seecoder.courselearning.messaging;
+
+import cn.seecoder.courselearning.util.IgnoreSSLUtils;
+import cn.seecoder.courselearning.util.ValidatorUtils;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.security.KeyManagementException;
+import java.security.NoSuchAlgorithmException;
+
+/**
+ * Configurable HCM options.
+ */
+public class HuaweiOption {
+    private static final Logger logger = LoggerFactory.getLogger(HuaweiOption.class);
+
+    private final HuaweiCredential credential;
+    private final CloseableHttpClient httpClient;
+    private final ThreadManager threadManager;
+
+    private HuaweiOption(Builder builder) {
+        ValidatorUtils.checkArgument(builder.credential != null, "HuaweiOption must be initialized with setCredential()");
+        this.credential = builder.credential;
+
+        ValidatorUtils.checkArgument(builder.httpClient != null, "HuaweiOption must be initialized with a non-null httpClient");
+        this.httpClient = builder.httpClient;
+
+        ValidatorUtils.checkArgument(builder.threadManager != null, "HuaweiOption must be initialized with a non-null threadManager");
+        this.threadManager = builder.threadManager;
+    }
+
+    /**
+     * Returns a instance of HuaweiCredential used for refreshing token.
+     *
+     * @return A <code>HuaweiCredential</code> instance.
+     */
+    public HuaweiCredential getCredential() {
+        return credential;
+    }
+
+    /**
+     * Returns a instance of httpclient used for sending http request.
+     *
+     * @return A <code>httpclient</code> instance.
+     */
+    public CloseableHttpClient getHttpClient() {
+        return httpClient;
+    }
+
+    public ThreadManager getThreadManager() {
+        return threadManager;
+    }
+
+    /**
+     * Builder for constructing {@link HuaweiOption}.
+     */
+    public static Builder builder() {
+        return new Builder();
+    }
+
+    public static final class Builder {
+        private HuaweiCredential credential;
+        private CloseableHttpClient httpClient;
+
+        {
+            try {
+                httpClient = IgnoreSSLUtils.createClient();
+            } catch (KeyManagementException | NoSuchAlgorithmException e) {
+                logger.debug("Fail to create httpClient for sending message", e);
+            }
+        }
+
+        private ThreadManager threadManager = HuaweiThreadManager.DEFAULT_THREAD_MANAGER;
+
+
+        public Builder() {
+        }
+
+        public Builder setCredential(HuaweiCredential credential) {
+            this.credential = credential;
+            return this;
+        }
+
+        public Builder setHttpClient(CloseableHttpClient httpClient) {
+            this.httpClient = httpClient;
+            return this;
+        }
+
+        public Builder setThreadManager(ThreadManager threadManager) {
+            this.threadManager = threadManager;
+            return this;
+        }
+
+        public HuaweiOption build() {
+            return new HuaweiOption(this);
+        }
+    }
+}

+ 59 - 0
src/main/java/cn/seecoder/courselearning/messaging/HuaweiScheduledExecutor.java

@@ -0,0 +1,59 @@
+/* Copyright 2017 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+
+ *  2019.12.15-Changed constructor HuaweiScheduledExecutor
+ *                  Huawei Technologies Co., Ltd.
+ *
+ */
+package cn.seecoder.courselearning.messaging;
+
+import com.google.common.base.Strings;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+
+import java.util.concurrent.ScheduledThreadPoolExecutor;
+import java.util.concurrent.ThreadFactory;
+
+import static com.google.common.base.Preconditions.checkArgument;
+
+/**
+ * A single-threaded scheduled executor implementation.
+ */
+public class HuaweiScheduledExecutor extends ScheduledThreadPoolExecutor {
+
+    public HuaweiScheduledExecutor(ThreadFactory threadFactory, String name) {
+        this(threadFactory, name, null);
+    }
+
+    public HuaweiScheduledExecutor(ThreadFactory threadFactory, String name, Thread.UncaughtExceptionHandler handler) {
+        super(1, decorateThreadFactory(threadFactory, name, handler));
+        setRemoveOnCancelPolicy(true);
+    }
+
+    static ThreadFactory getThreadFactoryWithName(ThreadFactory threadFactory, String name) {
+        return decorateThreadFactory(threadFactory, name, null);
+    }
+
+    private static ThreadFactory decorateThreadFactory(
+            ThreadFactory threadFactory, String name, Thread.UncaughtExceptionHandler handler) {
+        checkArgument(!Strings.isNullOrEmpty(name));
+        ThreadFactoryBuilder builder = new ThreadFactoryBuilder()
+                .setThreadFactory(threadFactory)
+                .setNameFormat(name)
+                .setDaemon(true);
+        if (handler != null) {
+            builder.setUncaughtExceptionHandler(handler);
+        }
+        return builder.build();
+    }
+}

+ 40 - 0
src/main/java/cn/seecoder/courselearning/messaging/HuaweiService.java

@@ -0,0 +1,40 @@
+/*
+ * Copyright 2020. Huawei Technologies Co., Ltd. All rights reserved.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+ */
+package cn.seecoder.courselearning.messaging;
+
+/**
+ * the services exposed from the HCM SDK
+ * Each instance of the class is associated with one instance of the HuaweiApp
+ */
+public abstract class HuaweiService<T> {
+    private String id;
+    protected T instance;
+
+    protected HuaweiService(String id, T instance) {
+        this.id = id;
+        this.instance = instance;
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public T getInstance() {
+        return instance;
+    }
+
+    public abstract void destroy();
+}

+ 96 - 0
src/main/java/cn/seecoder/courselearning/messaging/HuaweiThreadManager.java

@@ -0,0 +1,96 @@
+/* Copyright 2017 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+
+ *  2019.12.15-Changed method releaseExecutor
+ *                  Huawei Technologies Co., Ltd.
+ *
+ */
+package cn.seecoder.courselearning.messaging;
+
+import java.util.HashSet;
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
+
+
+/**
+ * Default ThreadManager implementations used by the HCM SDK
+ */
+public class HuaweiThreadManager {
+
+    public static final ThreadManager DEFAULT_THREAD_MANAGER = new DefaultThreadManager();
+
+    /**
+     * An abstract ThreadManager implementation that uses the same executor service
+     * across all active apps. The executor service is initialized when the first app is initialized,
+     * and terminated when the last app is deleted. This class is thread safe.
+     */
+    abstract static class GlobalThreadManager extends ThreadManager {
+        private final Object lock = new Object();
+        private final Set<String> apps = new HashSet<>();
+        private ExecutorService executorService;
+
+        @Override
+        protected ExecutorService getExecutor(HuaweiApp app) {
+            synchronized (lock) {
+                if (executorService == null) {
+                    executorService = doInit();
+                }
+                apps.add(app.getOption().getCredential().getAppId());
+                return executorService;
+            }
+        }
+
+        @Override
+        protected void releaseExecutor(HuaweiApp app, ExecutorService executor) {
+            synchronized (lock) {
+                String appId = app.getOption().getCredential().getAppId();
+                if (apps.remove(appId) && apps.isEmpty()) {
+                    doCleanup(executorService);
+                    executorService = null;
+                }
+            }
+        }
+
+        /**
+         * Initializes the executor service. Called when the first application is initialized.
+         */
+        protected abstract ExecutorService doInit();
+
+        /**
+         * Cleans up the executor service. Called when the last application is deleted.
+         */
+        protected abstract void doCleanup(ExecutorService executorService);
+    }
+
+    private static class DefaultThreadManager extends GlobalThreadManager {
+
+        @Override
+        protected ExecutorService doInit() {
+            ThreadFactory threadFactory = HuaweiScheduledExecutor.getThreadFactoryWithName(getThreadFactory(), "huawei-default-%d");
+            return Executors.newCachedThreadPool(threadFactory);
+        }
+
+        @Override
+        protected void doCleanup(ExecutorService executorService) {
+            executorService.shutdown();
+        }
+
+        @Override
+        protected ThreadFactory getThreadFactory() {
+            return Executors.defaultThreadFactory();
+        }
+    }
+}

+ 54 - 0
src/main/java/cn/seecoder/courselearning/messaging/ImplHuaweiTrampolines.java

@@ -0,0 +1,54 @@
+/* Copyright 2017 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+
+ *  2019.12.15-added method getAccessToken
+ *                  Huawei Technologies Co., Ltd.
+ *
+ */
+package cn.seecoder.courselearning.messaging;
+
+import org.apache.http.client.HttpClient;
+
+/**
+ * Provides trampolines into package-private APIs used by components of HCM
+ */
+public final class ImplHuaweiTrampolines {
+    private ImplHuaweiTrampolines() {
+    }
+
+    public static HuaweiCredential getCredential(HuaweiApp app) {
+        return app.getOption().getCredential();
+    }
+
+    public static String getAccessToken(HuaweiApp app) {
+        return app.getOption().getCredential().getAccessToken();
+    }
+
+    public static String getAppId(HuaweiApp app) {
+        return app.getOption().getCredential().getAppId();
+    }
+
+    public static HttpClient getHttpClient(HuaweiApp app) {
+        return app.getOption().getHttpClient();
+    }
+
+    public static <T extends HuaweiService> T getService(HuaweiApp app, String id, Class<T> type) {
+        return type.cast(app.getService(id));
+    }
+
+    public static <T extends HuaweiService> T addService(HuaweiApp app, T service) {
+        app.addService(service);
+        return service;
+    }
+}

+ 81 - 0
src/main/java/cn/seecoder/courselearning/messaging/ThreadManager.java

@@ -0,0 +1,81 @@
+/* Copyright 2017 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+
+ *  2019.12.15-changed method getHuaweiExecutors
+ *  2019.12.15-changed method releaseHuaweiExecutors
+ *  2019.12.15-changed method getExecutor
+ *  2019.12.15-changed method releaseExecutor
+ *                  Huawei Technologies Co., Ltd.
+ *
+ */
+package cn.seecoder.courselearning.messaging;
+
+import cn.seecoder.courselearning.util.ValidatorUtils;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.ThreadFactory;
+
+/**
+ * An interface that controls the thread pools and thread factories used by the HCM SDK. Each
+ * instance of HuaweiApp uses an implementation of this interface to create and manage
+ * threads.
+ */
+public abstract class ThreadManager {
+    final HuaweiExecutors getHuaweiExecutors(HuaweiApp app) {
+        return new HuaweiExecutors(getExecutor(app));
+    }
+
+    final void releaseHuaweiExecutors(HuaweiApp app, HuaweiExecutors executor) {
+        releaseExecutor(app, executor.userExecutor);
+    }
+
+    /**
+     * Returns the main thread pool for an app.
+     *
+     * @param app A {@link HuaweiApp} instance.
+     * @return A non-null <code>ExecutorService</code> instance.
+     */
+    protected abstract ExecutorService getExecutor(HuaweiApp app);
+
+    /**
+     * Cleans up the thread pool associated with an app.
+     * This method is invoked when an app is deleted.
+     *
+     * @param app A {@link HuaweiApp} instance.
+     * @return A non-null <code>ExecutorService</code> instance.
+     */
+    protected abstract void releaseExecutor(HuaweiApp app, ExecutorService executor);
+
+    /**
+     * Returns the <code>ThreadFactory</code> to be used for creating long-lived threads. This is
+     * used mainly to create the long-lived worker threads for the scheduled (periodic) tasks started by the SDK.
+     * The SDK guarantees clean termination of all threads started via this <code>ThreadFactory</code>, when the user
+     * calls {@link HuaweiApp#delete()}.
+     *
+     * <p>If long-lived threads cannot be supported in the current runtime, this method may
+     * throw a {@code RuntimeException}.
+     *
+     * @return A non-null <code>ThreadFactory</code>.
+     */
+    protected abstract ThreadFactory getThreadFactory();
+
+    static final class HuaweiExecutors {
+        private ExecutorService userExecutor;
+
+        private HuaweiExecutors(ExecutorService userExecutor) {
+            ValidatorUtils.checkArgument(userExecutor != null, "ExecutorService must not be null");
+            this.userExecutor = userExecutor;
+        }
+    }
+}

+ 96 - 0
src/main/java/cn/seecoder/courselearning/messaging/TokenRefresher.java

@@ -0,0 +1,96 @@
+/* Copyright 2017 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+
+ *  2019.12.15-changed constructor TokenRefresher
+ *                  Huawei Technologies Co., Ltd.
+ *
+ */
+package cn.seecoder.courselearning.messaging;
+
+import cn.seecoder.courselearning.util.ValidatorUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.concurrent.Future;
+
+/**
+ * Utility class for scheduling proactive token refresh events. Each HuaweiApp should have
+ * its own instance of this class. TokenRefresher schedules token refresh events when token is expired.
+ *
+ * <p>This class is thread safe. It will handle only one token change event at a time. It also
+ * cancels any pending token refresh events, before scheduling a new one.
+ */
+public class TokenRefresher {
+    private static final Logger logger = LoggerFactory.getLogger(TokenRefresher.class);
+
+    private HuaweiApp app;
+    private HuaweiCredential credential;
+
+    private Future future;
+
+    public TokenRefresher(HuaweiApp app) {
+        ValidatorUtils.checkArgument(app != null, "app must not be null");
+        this.app = app;
+        this.credential = app.getOption().getCredential();
+    }
+
+    protected void scheduleNext(Runnable task, long initialDelay, long period) {
+        logger.debug("Scheduling next token refresh in {} milliseconds", period);
+        try {
+            future = app.schedule(task, initialDelay, period);
+        } catch (UnsupportedOperationException e) {
+            logger.debug("Failed to schedule token refresh event", e);
+        }
+    }
+
+    /**
+     * Schedule a forced token refresh to be executed after a specified period.
+     *
+     * @param period in milliseconds, after which the token should be forcibly refreshed.
+     */
+    public void scheduleRefresh(final long period) {
+        cancelPrevious();
+        scheduleNext(() -> credential.refreshToken(), period, period);
+    }
+
+    private void cancelPrevious() {
+        if (future != null) {
+            future.cancel(true);
+        }
+    }
+
+    /**
+     * Starts the TokenRefresher if not already started. Starts refreshing when token is expired. If no active
+     * token is present, or if the available token is expired soon, this will also refresh immediately.
+     */
+    final synchronized void start() {
+        logger.debug("Starting the proactive token refresher");
+        String accessToken = credential.getAccessToken();
+        long refreshDelay;
+        if (accessToken == null || StringUtils.isEmpty(accessToken)) {
+            credential.refreshToken();
+        }
+
+        refreshDelay = credential.getExpireIn();
+
+        scheduleRefresh(refreshDelay);
+    }
+
+    final synchronized void stop() {
+        cancelPrevious();
+        logger.debug("Stopped the proactive token refresher");
+    }
+
+}

+ 95 - 0
src/main/java/cn/seecoder/courselearning/model/Course.java

@@ -0,0 +1,95 @@
+package cn.seecoder.courselearning.model;
+
+import java.util.Date;
+
+public class Course {
+    private Integer id;
+
+    private String name;
+
+    private String type;
+
+    private String intro;
+
+    private String picture;
+
+    private String provider;
+
+    private Date createTime;
+
+    private Date deleteTime;
+
+    private Integer cost;
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name == null ? null : name.trim();
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type == null ? null : type.trim();
+    }
+
+    public String getIntro() {
+        return intro;
+    }
+
+    public void setIntro(String intro) {
+        this.intro = intro == null ? null : intro.trim();
+    }
+
+    public String getPicture() {
+        return picture;
+    }
+
+    public void setPicture(String picture) {
+        this.picture = picture == null ? null : picture.trim();
+    }
+
+    public String getProvider() {
+        return provider;
+    }
+
+    public void setProvider(String provider) {
+        this.provider = provider == null ? null : provider.trim();
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public Date getDeleteTime() {
+        return deleteTime;
+    }
+
+    public void setDeleteTime(Date deleteTime) {
+        this.deleteTime = deleteTime;
+    }
+
+    public Integer getCost() {
+        return cost;
+    }
+
+    public void setCost(Integer cost) {
+        this.cost = cost;
+    }
+}

+ 90 - 0
src/main/java/cn/seecoder/courselearning/model/CourseOrder.java

@@ -0,0 +1,90 @@
+package cn.seecoder.courselearning.model;
+
+import cn.seecoder.courselearning.vo.CourseOrderVO;
+
+import java.util.Date;
+
+public class CourseOrder {
+    private Integer id;
+
+    private Integer cost;
+
+    private Integer courseId;
+
+    private String courseName;
+
+    private Date createTime;
+
+    private String userId;
+
+    private Integer status;
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getCost() {
+        return cost;
+    }
+
+    public void setCost(Integer cost) {
+        this.cost = cost;
+    }
+
+    public Integer getCourseId() {
+        return courseId;
+    }
+
+    public void setCourseId(Integer courseId) {
+        this.courseId = courseId;
+    }
+
+    public String getCourseName() {
+        return courseName;
+    }
+
+    public void setCourseName(String courseName) {
+        this.courseName = courseName == null ? null : courseName.trim();
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public String getUserId() {
+        return userId;
+    }
+
+    public void setUserId(String userId) {
+        this.userId = userId == null ? null : userId.trim();
+    }
+
+    public Integer getStatus() {
+        return status;
+    }
+
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+
+    public CourseOrder() {
+    }
+
+    public CourseOrder(CourseOrderVO orderVO){
+        this.id = orderVO.getId();
+        this.cost = orderVO.getCost();
+        this.courseId = orderVO.getCourseId();
+        this.courseName = orderVO.getCourseName();
+        this.createTime = orderVO.getCreateTime()==null ? new Date():orderVO.getCreateTime();
+        this.userId = orderVO.getUserId();
+        this.status = orderVO.getStatus();
+    }
+}

+ 105 - 0
src/main/java/cn/seecoder/courselearning/model/CourseWare.java

@@ -0,0 +1,105 @@
+package cn.seecoder.courselearning.model;
+
+import java.util.Date;
+
+public class CourseWare {
+    private Integer id;
+
+    private Integer courseId;
+
+    private Integer number;
+
+    private String title;
+
+    private String fileName;
+
+    private String fileType;
+
+    private String fileSize;
+
+    private Boolean freeFlag;
+
+    private Boolean downloadFlag;
+
+    private Date uploadTime;
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getCourseId() {
+        return courseId;
+    }
+
+    public void setCourseId(Integer courseId) {
+        this.courseId = courseId;
+    }
+
+    public Integer getNumber() {
+        return number;
+    }
+
+    public void setNumber(Integer number) {
+        this.number = number;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title == null ? null : title.trim();
+    }
+
+    public String getFileName() {
+        return fileName;
+    }
+
+    public void setFileName(String fileName) {
+        this.fileName = fileName == null ? null : fileName.trim();
+    }
+
+    public String getFileType() {
+        return fileType;
+    }
+
+    public void setFileType(String fileType) {
+        this.fileType = fileType == null ? null : fileType.trim();
+    }
+
+    public String getFileSize() {
+        return fileSize;
+    }
+
+    public void setFileSize(String fileSize) {
+        this.fileSize = fileSize == null ? null : fileSize.trim();
+    }
+
+    public Boolean getFreeFlag() {
+        return freeFlag;
+    }
+
+    public void setFreeFlag(Boolean freeFlag) {
+        this.freeFlag = freeFlag;
+    }
+
+    public Boolean getDownloadFlag() {
+        return downloadFlag;
+    }
+
+    public void setDownloadFlag(Boolean downloadFlag) {
+        this.downloadFlag = downloadFlag;
+    }
+
+    public Date getUploadTime() {
+        return uploadTime;
+    }
+
+    public void setUploadTime(Date uploadTime) {
+        this.uploadTime = uploadTime;
+    }
+}

+ 57 - 0
src/main/java/cn/seecoder/courselearning/model/RechargeOrder.java

@@ -0,0 +1,57 @@
+package cn.seecoder.courselearning.model;
+
+import cn.seecoder.courselearning.vo.RechargeOrderVO;
+
+import java.util.Date;
+
+public class RechargeOrder {
+    private String orderId;
+
+    private String uid;
+
+    private Integer value;
+
+    private Date createTime;
+
+    public String getOrderId() {
+        return orderId;
+    }
+
+    public void setOrderId(String orderId) {
+        this.orderId = orderId == null ? null : orderId.trim();
+    }
+
+    public String getUid() {
+        return uid;
+    }
+
+    public void setUid(String uid) {
+        this.uid = uid == null ? null : uid.trim();
+    }
+
+    public Integer getValue() {
+        return value;
+    }
+
+    public void setValue(Integer value) {
+        this.value = value;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public RechargeOrder() {
+    }
+
+    public RechargeOrder(RechargeOrderVO rechargeOrder) {
+        this.orderId = rechargeOrder.getOrderId();
+        this.uid = rechargeOrder.getUid();
+        this.value = rechargeOrder.getValue();
+        this.createTime = rechargeOrder.getCreateTime()==null ? new Date():rechargeOrder.getCreateTime();
+    }
+}

+ 69 - 0
src/main/java/cn/seecoder/courselearning/model/User.java

@@ -0,0 +1,69 @@
+package cn.seecoder.courselearning.model;
+
+import cn.seecoder.courselearning.vo.UserVO;
+
+import java.util.Date;
+
+public class User {
+    private String uid;
+
+    private String uname;
+
+    private String picture;
+
+    private Date createTime;
+
+    private Integer balance;
+
+    public String getUid() {
+        return uid;
+    }
+
+    public void setUid(String uid) {
+        this.uid = uid == null ? null : uid.trim();
+    }
+
+    public String getUname() {
+        return uname;
+    }
+
+    public void setUname(String uname) {
+        this.uname = uname == null ? null : uname.trim();
+    }
+
+    public String getPicture() {
+        return picture;
+    }
+
+    public void setPicture(String picture) {
+        this.picture = picture == null ? null : picture.trim();
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public Integer getBalance() {
+        return balance;
+    }
+
+    public void setBalance(Integer balance) {
+        this.balance = balance;
+    }
+
+    public User() {
+    }
+
+    public User(UserVO userVO) {
+        this.uid = userVO.getUid();
+        this.uname = userVO.getUname();
+        this.picture = userVO.getPicture();
+        this.createTime = new Date();
+        // 新建的用户账号钻石余额初始值为0
+        this.balance = 0;
+    }
+}

+ 45 - 0
src/main/java/cn/seecoder/courselearning/model/UserToken.java

@@ -0,0 +1,45 @@
+package cn.seecoder.courselearning.model;
+
+import java.util.Date;
+
+public class UserToken {
+    private String uid;
+
+    private String token;
+
+    private Date updateTime;
+
+    private Boolean active;
+
+    public String getUid() {
+        return uid;
+    }
+
+    public void setUid(String uid) {
+        this.uid = uid == null ? null : uid.trim();
+    }
+
+    public String getToken() {
+        return token;
+    }
+
+    public void setToken(String token) {
+        this.token = token == null ? null : token.trim();
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public Boolean getActive() {
+        return active;
+    }
+
+    public void setActive(Boolean active) {
+        this.active = active;
+    }
+}

+ 48 - 0
src/main/java/cn/seecoder/courselearning/reponse/SendResponse.java

@@ -0,0 +1,48 @@
+/*
+ * Copyright 2020. Huawei Technologies Co., Ltd. All rights reserved.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+ */
+package cn.seecoder.courselearning.reponse;
+
+/**
+ * A class of reponse which exposed to developer
+ */
+public class SendResponse {
+    private final String code;
+    private final String msg;
+    private final String requestId;
+
+
+    protected SendResponse(String code, String msg, String requestId) {
+        this.code = code;
+        this.msg = msg;
+        this.requestId = requestId;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public String getMsg() {
+        return msg;
+    }
+
+    public String getRequestId() {
+        return requestId;
+    }
+
+    public static SendResponse fromCode(String code, String msg, String requestId) {
+        return new SendResponse(code, msg, requestId);
+    }
+}

+ 35 - 0
src/main/java/cn/seecoder/courselearning/reponse/TopicListResponse.java

@@ -0,0 +1,35 @@
+/*
+ * Copyright 2020. Huawei Technologies Co., Ltd. All rights reserved.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+ */
+package cn.seecoder.courselearning.reponse;
+
+import com.alibaba.fastjson.JSONArray;
+
+public class TopicListResponse extends SendResponse {
+    private final JSONArray topics;
+
+    public JSONArray getTopics() {
+        return topics;
+    }
+
+    private TopicListResponse(String code, String msg, String requestId, JSONArray topics) {
+        super(code, msg, requestId);
+        this.topics = topics;
+    }
+
+    public static TopicListResponse fromCode(String code, String msg, String requestId, JSONArray topics) {
+        return new TopicListResponse(code, msg, requestId, topics);
+    }
+}

+ 47 - 0
src/main/java/cn/seecoder/courselearning/reponse/TopicSendResponse.java

@@ -0,0 +1,47 @@
+/*
+ * Copyright 2020. Huawei Technologies Co., Ltd. All rights reserved.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+ */
+package cn.seecoder.courselearning.reponse;
+
+import com.alibaba.fastjson.JSONArray;
+
+public final class TopicSendResponse extends SendResponse {
+    private final Integer failureCount;
+    private final Integer successCount;
+    private final JSONArray errors;
+
+    public Integer getFailureCount() {
+        return failureCount;
+    }
+
+    public Integer getSuccessCount() {
+        return successCount;
+    }
+
+    public JSONArray getErrors() {
+        return errors;
+    }
+
+    private TopicSendResponse(String code, String msg, String requestId, Integer failureCount, Integer successCount, JSONArray errors) {
+        super(code, msg, requestId);
+        this.failureCount = failureCount;
+        this.successCount = successCount;
+        this.errors = errors;
+    }
+
+    public static TopicSendResponse fromCode(String code, String msg, String requestId, Integer failureCount, Integer successCount, JSONArray errors) {
+        return new TopicSendResponse(code, msg, requestId, failureCount, successCount, errors);
+    }
+}

+ 12 - 0
src/main/java/cn/seecoder/courselearning/service/CourseOrderService.java

@@ -0,0 +1,12 @@
+package cn.seecoder.courselearning.service;
+
+import cn.seecoder.courselearning.vo.CourseOrderVO;
+import cn.seecoder.courselearning.vo.ResultVO;
+
+import java.util.List;
+
+public interface CourseOrderService {
+    ResultVO<CourseOrderVO> insertCourseOrder(CourseOrderVO orderVO);
+    ResultVO<CourseOrderVO> updateCourseOrder(Integer orderId, Integer orderStatus);
+    List<CourseOrderVO> getCourseOrders(String uid);
+}

+ 17 - 0
src/main/java/cn/seecoder/courselearning/service/CourseService.java

@@ -0,0 +1,17 @@
+package cn.seecoder.courselearning.service;
+
+import cn.seecoder.courselearning.vo.CourseVO;
+import com.github.pagehelper.PageInfo;
+
+import java.util.List;
+
+public interface CourseService {
+    // 根据关键字,分页查询课程
+    PageInfo<CourseVO> getCourses(Integer currPage, Integer pageSize, String uid, String key);
+    // 根据分类,分页查询课程
+    PageInfo<CourseVO> getCoursesByType(Integer currPage, Integer pageSize, String uid, String type);
+    // 查询用户所有已购买的课程
+    List<CourseVO> getBoughtCourses(String uid);
+    // 查询单门课程
+    CourseVO getCourse(Integer courseId, String uid);
+}

+ 9 - 0
src/main/java/cn/seecoder/courselearning/service/CourseWareService.java

@@ -0,0 +1,9 @@
+package cn.seecoder.courselearning.service;
+
+import cn.seecoder.courselearning.vo.CourseWareVO;
+
+import java.util.List;
+
+public interface CourseWareService {
+    List<CourseWareVO> getCourseWare(String uid, Integer courseId);
+}

+ 7 - 0
src/main/java/cn/seecoder/courselearning/service/SendNotifyService.java

@@ -0,0 +1,7 @@
+package cn.seecoder.courselearning.service;
+
+import cn.seecoder.courselearning.exception.HuaweiMessagingException;
+
+public interface SendNotifyService{
+    void sendCourseBuySuccessNotify(String uid, Integer courseId) throws HuaweiMessagingException;
+}

+ 11 - 0
src/main/java/cn/seecoder/courselearning/service/UserService.java

@@ -0,0 +1,11 @@
+package cn.seecoder.courselearning.service;
+
+import cn.seecoder.courselearning.vo.RechargeOrderVO;
+import cn.seecoder.courselearning.vo.ResultVO;
+import cn.seecoder.courselearning.vo.UserVO;
+
+public interface UserService {
+    UserVO userLogin(UserVO user);
+    UserVO getUser(String uid);
+    ResultVO<UserVO> rechargeAccount(RechargeOrderVO rechargeOrderVO);
+}

+ 5 - 0
src/main/java/cn/seecoder/courselearning/service/UserTokenService.java

@@ -0,0 +1,5 @@
+package cn.seecoder.courselearning.service;
+
+public interface UserTokenService {
+    void refreshToken(String uid, String token);
+}

+ 73 - 0
src/main/java/cn/seecoder/courselearning/service/impl/CourseOrderServiceImpl.java

@@ -0,0 +1,73 @@
+package cn.seecoder.courselearning.service.impl;
+
+import cn.seecoder.courselearning.mapper.CourseOrderMapper;
+import cn.seecoder.courselearning.mapper.UserMapper;
+import cn.seecoder.courselearning.model.CourseOrder;
+import cn.seecoder.courselearning.model.User;
+import cn.seecoder.courselearning.service.CourseOrderService;
+import cn.seecoder.courselearning.util.Constant;
+import cn.seecoder.courselearning.vo.CourseOrderVO;
+import cn.seecoder.courselearning.vo.ResultVO;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+@Service
+public class CourseOrderServiceImpl implements CourseOrderService {
+    @Resource
+    CourseOrderMapper orderMapper;
+    @Resource
+    UserMapper userMapper;
+
+    @Override
+    public ResultVO<CourseOrderVO> insertCourseOrder(CourseOrderVO orderVO) {
+        CourseOrder order = new CourseOrder(orderVO);
+        try{
+            Integer status = order.getStatus();
+            if(status.equals(Constant.ORDER_STATUS_SUCCESS) || status.equals(Constant.ORDER_STATUS_WAIT)){
+                // 当订单状态为支付成功时,需扣除用户余额
+                User user = userMapper.selectByPrimaryKey(order.getUserId());
+                if(user.getBalance()>=orderVO.getCost()){
+                    userMapper.decreaseBalance(user.getUid(), order.getCost());
+                    orderMapper.insert(order);
+                }else
+                    return new ResultVO<>(Constant.REQUEST_FAIL, "用户余额不足");
+            }else if(status.equals(Constant.ORDER_STATUS_UNPAID))
+                orderMapper.insert(order);
+        }catch (Exception e){
+            return new ResultVO<>(Constant.REQUEST_FAIL, e.toString());
+        }
+        return new ResultVO<>(Constant.REQUEST_SUCCESS, "操作成功", new CourseOrderVO(order));
+    }
+
+    @Override
+    public ResultVO<CourseOrderVO> updateCourseOrder(Integer orderId, Integer orderStatus) {
+        CourseOrder order = orderMapper.selectByPrimaryKey(orderId);
+        if(order == null) return new ResultVO<>(Constant.REQUEST_FAIL, "找不到当前订单!");
+        if((orderStatus.equals(Constant.ORDER_STATUS_SUCCESS)||orderStatus.equals(Constant.ORDER_STATUS_WAIT)) &&
+                order.getStatus().equals(Constant.ORDER_STATUS_UNPAID)){
+            // 当订单状态为支付成功时,需扣除用户余额
+            User user = userMapper.selectByPrimaryKey(order.getUserId());
+            if(user.getBalance()>=order.getCost()){
+                userMapper.decreaseBalance(user.getUid(), order.getCost());
+            }else
+                return new ResultVO<>(Constant.REQUEST_FAIL, "用户余额不足");
+        }
+        order.setStatus(orderStatus);
+        orderMapper.updateByPrimaryKey(order);
+        return new ResultVO<CourseOrderVO>(Constant.REQUEST_SUCCESS, "操作成功", new CourseOrderVO(order));
+    }
+
+    @Override
+    public List<CourseOrderVO> getCourseOrders(String uid) {
+        List<CourseOrderVO> ret = new ArrayList<>();
+        List<CourseOrder> orderList = orderMapper.selectByUserId(uid);
+        for(CourseOrder order: orderList){
+            ret.add(new CourseOrderVO(order));
+        }
+        return ret;
+    }
+}

+ 77 - 0
src/main/java/cn/seecoder/courselearning/service/impl/CourseServiceImpl.java

@@ -0,0 +1,77 @@
+package cn.seecoder.courselearning.service.impl;
+
+import cn.seecoder.courselearning.mapper.CourseMapper;
+import cn.seecoder.courselearning.mapper.CourseOrderMapper;
+import cn.seecoder.courselearning.model.Course;
+import cn.seecoder.courselearning.model.CourseOrder;
+import cn.seecoder.courselearning.service.CourseService;
+import cn.seecoder.courselearning.util.Constant;
+import cn.seecoder.courselearning.util.PageInfoUtil;
+import cn.seecoder.courselearning.vo.CourseVO;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+
+@Service
+public class CourseServiceImpl implements CourseService {
+    @Resource
+    private CourseMapper courseMapper;
+    @Resource
+    private CourseOrderMapper orderMapper;
+
+    @Override
+    public PageInfo<CourseVO> getCourses(Integer currPage, Integer pageSize, String uid, String key) {
+        if(currPage==null || currPage<1) currPage=1;
+        PageHelper.startPage(currPage, pageSize);
+        PageInfo<Course> po = new PageInfo<>(courseMapper.queryAll(key));
+        return getCourseVOPageInfo(uid, po);
+    }
+
+    @Override
+    public PageInfo<CourseVO> getCoursesByType(Integer currPage, Integer pageSize, String uid, String type) {
+        if(currPage==null || currPage<1) currPage=1;
+        PageHelper.startPage(currPage, pageSize);
+        PageInfo<Course> po = new PageInfo<>(courseMapper.selectByType(type));
+        return getCourseVOPageInfo(uid, po);
+    }
+
+    @Override
+    public List<CourseVO> getBoughtCourses(String uid) {
+        List<CourseVO> ret = new ArrayList<>();
+        List<Course> courseList = courseMapper.selectByUserId(uid);
+        for(Course course: courseList){
+            ret.add(new CourseVO(course, true));
+        }
+        return ret;
+    }
+
+    @Override
+    public CourseVO getCourse(Integer courseId, String uid) {
+        boolean bought = false;
+        if(StringUtils.hasText(uid)) {
+            CourseOrder order = orderMapper.queryMostRecentOrder(uid, courseId);
+            if(order != null)
+                bought = order.getStatus().equals(Constant.ORDER_STATUS_SUCCESS);
+        }
+        return new CourseVO(courseMapper.selectByPrimaryKey(courseId), bought);
+    }
+
+    private PageInfo<CourseVO> getCourseVOPageInfo(String uid, PageInfo<Course> po) {
+        PageInfo<CourseVO> result = PageInfoUtil.convert(po, CourseVO.class);
+        if(StringUtils.hasText(uid)){
+            List<CourseVO> voList = result.getList();
+            for(CourseVO vo: voList){
+                CourseOrder order = orderMapper.queryMostRecentOrder(uid, vo.getId());
+                if(order != null)
+                    vo.setBought(order.getStatus().equals(Constant.ORDER_STATUS_SUCCESS));
+            }
+        }
+        return result;
+    }
+
+}

+ 39 - 0
src/main/java/cn/seecoder/courselearning/service/impl/CourseWareServiceImpl.java

@@ -0,0 +1,39 @@
+package cn.seecoder.courselearning.service.impl;
+
+import cn.seecoder.courselearning.mapper.CourseOrderMapper;
+import cn.seecoder.courselearning.mapper.CourseWareMapper;
+import cn.seecoder.courselearning.model.CourseOrder;
+import cn.seecoder.courselearning.model.CourseWare;
+import cn.seecoder.courselearning.service.CourseWareService;
+import cn.seecoder.courselearning.util.Constant;
+import cn.seecoder.courselearning.vo.CourseWareVO;
+import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+
+@Service
+public class CourseWareServiceImpl implements CourseWareService {
+    @Resource
+    private CourseWareMapper courseWareMapper;
+    @Resource
+    private CourseOrderMapper courseOrderMapper;
+
+    @Override
+    public List<CourseWareVO> getCourseWare(String uid, Integer courseId) {
+        boolean bought = false;
+        if (StringUtils.hasText(uid)){
+            CourseOrder order = courseOrderMapper.queryMostRecentOrder(uid, courseId);
+            if(order != null)
+                bought = order.getStatus().equals(Constant.ORDER_STATUS_SUCCESS);
+        }
+        List<CourseWare> tempList = courseWareMapper.selectByCourseId(courseId);
+        List<CourseWareVO> ret = new ArrayList<>();
+        for(CourseWare courseWare: tempList){
+            ret.add(new CourseWareVO(courseWare, bought));
+        }
+        return ret;
+    }
+}

+ 79 - 0
src/main/java/cn/seecoder/courselearning/service/impl/SendNotifyServiceImpl.java

@@ -0,0 +1,79 @@
+package cn.seecoder.courselearning.service.impl;
+
+import cn.seecoder.courselearning.android.*;
+import cn.seecoder.courselearning.enums.Importance;
+import cn.seecoder.courselearning.enums.Visibility;
+import cn.seecoder.courselearning.exception.HuaweiMessagingException;
+import cn.seecoder.courselearning.mapper.UserTokenMapper;
+import cn.seecoder.courselearning.message.AndroidConfig;
+import cn.seecoder.courselearning.message.Message;
+import cn.seecoder.courselearning.message.Notification;
+import cn.seecoder.courselearning.messaging.HuaweiApp;
+import cn.seecoder.courselearning.messaging.HuaweiMessaging;
+import cn.seecoder.courselearning.enums.Urgency;
+import cn.seecoder.courselearning.model.UserToken;
+import cn.seecoder.courselearning.reponse.SendResponse;
+import cn.seecoder.courselearning.service.SendNotifyService;
+import cn.seecoder.courselearning.util.DateUtil;
+import cn.seecoder.courselearning.util.InitAppUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+@Service
+public class SendNotifyServiceImpl implements SendNotifyService {
+    @Resource
+    private UserTokenMapper userTokenMapper;
+    private final HuaweiMessaging client;
+
+    @Autowired
+    public SendNotifyServiceImpl(){
+        HuaweiApp app = InitAppUtils.initializeApp();
+        client = HuaweiMessaging.getInstance(app);
+    }
+
+    @Override
+    public void sendCourseBuySuccessNotify(String uid, Integer courseId) throws HuaweiMessagingException {
+        List<String> tokenList = new ArrayList<>();
+        UserToken userToken = userTokenMapper.selectByPrimaryKey(uid);
+        tokenList.add(userToken.getToken());
+//        System.out.println("即将发送推送消息 token = "+ userToken.getToken());
+
+        String COURSE_INTENT = "intent://cn.seecoder.courselearning/course?#Intent;scheme=pushscheme;launchFlags=0x4000000;";
+        StringBuilder builder = new StringBuilder(COURSE_INTENT);
+        if(courseId!=null && courseId>0) {
+            builder.append("i.courseId=");
+            builder.append(courseId);
+            builder.append(";");
+        }
+        builder.append("end");
+        String intent = builder.toString();
+
+        AndroidNotification androidNotification = AndroidNotification.builder()
+                .setTitle("课程购买成功 "+ DateUtil.getDateString(new Date()))
+                .setBody("恭喜您成功解锁课程!")
+                .setClickAction(ClickAction.builder().setType(1).setIntent(intent).build())
+                .setForegroundShow(true)
+                .build();
+
+        AndroidConfig androidConfig = AndroidConfig.builder().setCollapseKey(-1)
+                .setUrgency(Urgency.HIGH.getValue())
+//                .setBiTag("the_sample_bi_tag_for_simple_notify")
+                .setNotification(androidNotification)
+                .build();
+
+        Message message = Message.builder()
+                .setAndroidConfig(androidConfig)
+                .addAllToken(tokenList)
+                .build();
+
+        SendResponse response = client.sendMessage(message);
+//        System.out.println("response code: "+response.getCode());
+//        System.out.println("response msg: "+response.getMsg());
+//        System.out.println("requestId:"+response.getRequestId());
+    }
+}

+ 83 - 0
src/main/java/cn/seecoder/courselearning/service/impl/UserServiceImpl.java

@@ -0,0 +1,83 @@
+package cn.seecoder.courselearning.service.impl;
+
+import cn.seecoder.courselearning.mapper.RechargeOrderMapper;
+import cn.seecoder.courselearning.mapper.UserMapper;
+import cn.seecoder.courselearning.model.RechargeOrder;
+import cn.seecoder.courselearning.model.User;
+import cn.seecoder.courselearning.service.UserService;
+import cn.seecoder.courselearning.util.Constant;
+import cn.seecoder.courselearning.vo.RechargeOrderVO;
+import cn.seecoder.courselearning.vo.ResultVO;
+import cn.seecoder.courselearning.vo.UserVO;
+import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+
+import javax.annotation.Resource;
+
+@Service
+public class UserServiceImpl implements UserService {
+    @Resource
+    UserMapper userMapper;
+    @Resource
+    RechargeOrderMapper rechargeOrderMapper;
+
+    @Override
+    public UserVO userLogin(UserVO user) {
+        User userFromDB = userMapper.selectByPrimaryKey(user.getUid());
+        if(userFromDB == null || user.getUid() == null){
+            User userPO = new User(user);
+            userMapper.insert(userPO);
+            return new UserVO(userPO);
+        }
+        return new UserVO(userFromDB);
+    }
+
+    @Override
+    public UserVO getUser(String uid) {
+        User userFromDB = userMapper.selectByPrimaryKey(uid);
+        if(userFromDB == null){
+            return new UserVO();
+        }else{
+            return new UserVO(userFromDB);
+        }
+    }
+
+    @Override
+    public ResultVO<UserVO> rechargeAccount(RechargeOrderVO rechargeOrderVO) {
+        ResultVO<UserVO> ret = new ResultVO<>();
+        String uid = rechargeOrderVO.getUid();
+        String orderId = rechargeOrderVO.getOrderId();
+        if(!StringUtils.hasText(uid) || !StringUtils.hasText(orderId)){
+            ret.setCode(Constant.REQUEST_FAIL);
+            ret.setMsg("uid 或 orderId 参数无效");
+        }else{
+            User user = userMapper.selectByPrimaryKey(rechargeOrderVO.getUid());
+            RechargeOrder order = rechargeOrderMapper.selectByPrimaryKey(rechargeOrderVO.getOrderId());
+            if(user != null){
+                if(order != null){
+                    // 假如查找到了orderId对应的rechargeOrder,则证明这笔钻石已经充值到账过了
+                    ret.setCode(Constant.REQUEST_SUCCESS);
+                    ret.setMsg("该订单已经充值到账");
+                }else{
+                    try{
+                        Integer value = rechargeOrderVO.getValue();
+                        // 更新用户钻石余额
+                        userMapper.increaseBalance(uid, value);
+                        if(rechargeOrderMapper.insert(new RechargeOrder(rechargeOrderVO)) > 0){
+                            ret.setCode(Constant.REQUEST_SUCCESS);
+                            ret.setMsg("充值成功");
+                        }else{
+                            ret.setCode(Constant.REQUEST_FAIL);
+                            ret.setMsg("系统错误");
+                        }
+                    } catch (Exception e){
+                        ret.setCode(Constant.REQUEST_FAIL);
+                        ret.setMsg(e.toString());
+                    }
+                }
+                ret.setData(new UserVO(userMapper.selectByPrimaryKey(uid)));
+            }
+        }
+        return ret;
+    }
+}

+ 29 - 0
src/main/java/cn/seecoder/courselearning/service/impl/UserTokenServiceImpl.java

@@ -0,0 +1,29 @@
+package cn.seecoder.courselearning.service.impl;
+
+import cn.seecoder.courselearning.mapper.UserTokenMapper;
+import cn.seecoder.courselearning.model.UserToken;
+import cn.seecoder.courselearning.service.UserTokenService;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.Date;
+
+@Service
+public class UserTokenServiceImpl implements UserTokenService {
+    @Resource
+    UserTokenMapper userTokenMapper;
+
+    @Override
+    public void refreshToken(String uid, String token) {
+        UserToken userToken = new UserToken();
+        userToken.setUid(uid);
+        userToken.setToken(token);
+        userToken.setActive(true);
+        userToken.setUpdateTime(new Date());
+        if(userTokenMapper.selectByPrimaryKey(uid) == null){
+            userTokenMapper.insert(userToken);
+        }else{
+            userTokenMapper.updateByPrimaryKey(userToken);
+        }
+    }
+}

+ 35 - 0
src/main/java/cn/seecoder/courselearning/util/CollectionUtils.java

@@ -0,0 +1,35 @@
+/*
+ * Copyright 2020. Huawei Technologies Co., Ltd. All rights reserved.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+ */
+package cn.seecoder.courselearning.util;
+
+import java.util.Collection;
+import java.util.Map;
+
+/**
+ * A tool for processing collections
+ */
+public class CollectionUtils {
+    public CollectionUtils() {
+    }
+
+    public static boolean isEmpty(Collection<?> collection) {
+        return collection == null || collection.isEmpty();
+    }
+
+    public static boolean isEmpty(Map<?, ?> map) {
+        return map == null || map.isEmpty();
+    }
+}

+ 23 - 0
src/main/java/cn/seecoder/courselearning/util/Constant.java

@@ -0,0 +1,23 @@
+package cn.seecoder.courselearning.util;
+
+/**
+ * 定义一些常量
+ */
+public class Constant {
+    // 一个展示课程的页面内包含的课程数量
+    public static final Integer COURSE_PAGE_SIZE = 3;
+    // 一个展示课件的页面内包含的课件数量
+    public static final Integer COURSE_WARE_PAGE_SIZE = 10;
+    // 请求操作成功返回码
+    public static final Integer REQUEST_SUCCESS = 1;
+    // 请求操作失败返回码
+    public static final Integer REQUEST_FAIL = 0;
+    // 订单已完成交易(支付并已发货)的状态码
+    public static final Integer ORDER_STATUS_SUCCESS = 1;
+    // 订单尚未支付的状态码
+    public static final Integer ORDER_STATUS_UNPAID = 2;
+    // 订单已支付等待发货的状态码
+    public static final Integer ORDER_STATUS_WAIT = 3;
+    // 订单已取消的状态码
+    public static final Integer ORDER_STATUS_CANCEL = 4;
+}

+ 19 - 0
src/main/java/cn/seecoder/courselearning/util/DateUtil.java

@@ -0,0 +1,19 @@
+package cn.seecoder.courselearning.util;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+
+public class DateUtil {
+    private final static DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA);
+
+    public static String getDateString(Date date){
+        return df.format(date);
+    }
+
+    public static Date toDate(String dateString) throws ParseException {
+        return df.parse(dateString);
+    }
+}

+ 79 - 0
src/main/java/cn/seecoder/courselearning/util/IgnoreSSLUtils.java

@@ -0,0 +1,79 @@
+/*
+ * Copyright 2020. Huawei Technologies Co., Ltd. All rights reserved.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+ */
+package cn.seecoder.courselearning.util;
+
+import org.apache.http.config.Registry;
+import org.apache.http.config.RegistryBuilder;
+import org.apache.http.conn.socket.ConnectionSocketFactory;
+import org.apache.http.conn.socket.PlainConnectionSocketFactory;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+import java.security.KeyManagementException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.CertificateException;
+
+/**
+ * A tool for ignoring ssl when creating httpclient
+ */
+public class IgnoreSSLUtils {
+    private static SSLContext createIgnoreVerifySSL() throws NoSuchAlgorithmException, KeyManagementException {
+        SSLContext sc = SSLContext.getInstance("SSLv3");
+
+        X509TrustManager trustManager = new X509TrustManager() {
+            @Override
+            public void checkClientTrusted(
+                    java.security.cert.X509Certificate[] paramArrayOfX509Certificate,
+                    String paramString) throws CertificateException {
+            }
+
+            @Override
+            public void checkServerTrusted(
+                    java.security.cert.X509Certificate[] paramArrayOfX509Certificate,
+                    String paramString) throws CertificateException {
+            }
+
+            @Override
+            public java.security.cert.X509Certificate[] getAcceptedIssuers() {
+                return null;
+            }
+        };
+
+        sc.init(null, new TrustManager[]{trustManager}, null);
+        return sc;
+    }
+
+    /**
+     * for ignoring verify SSL
+     */
+    public static CloseableHttpClient createClient() throws KeyManagementException, NoSuchAlgorithmException {
+        SSLContext sslcontext = createIgnoreVerifySSL();
+
+        Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create()
+                .register("http", PlainConnectionSocketFactory.INSTANCE)
+                .register("https", new SSLConnectionSocketFactory(sslcontext))
+                .build();
+        PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry);
+        HttpClients.custom().setConnectionManager(connManager);
+
+        return HttpClients.custom().setConnectionManager(connManager).build();
+    }
+}

+ 35 - 0
src/main/java/cn/seecoder/courselearning/util/InitAppUtils.java

@@ -0,0 +1,35 @@
+package cn.seecoder.courselearning.util;
+
+import cn.seecoder.courselearning.messaging.HuaweiApp;
+import cn.seecoder.courselearning.messaging.HuaweiCredential;
+import cn.seecoder.courselearning.messaging.HuaweiOption;
+
+import java.util.ResourceBundle;
+
+public class InitAppUtils {
+    /**
+     * @return HuaweiApp
+     */
+    public static HuaweiApp initializeApp() {
+        String appId = ResourceBundle.getBundle("url").getString("app_id");
+        String appSecret = ResourceBundle.getBundle("url").getString("app_secret");
+        // This appId and appSecret come from Huawei Developer Alliance
+        return initializeApp(appId, appSecret);
+    }
+
+    private static HuaweiApp initializeApp(String appId, String appSecret) {
+        // Create HuaweiCredential
+        HuaweiCredential credential = HuaweiCredential.builder()
+                .setAppId(appId)
+                .setAppSecret(appSecret)
+                .build();
+
+        // Create HuaweiOption
+        HuaweiOption option = HuaweiOption.builder()
+                .setCredential(credential)
+                .build();
+
+        // Initialize HuaweiApp
+        return HuaweiApp.getInstance(option);
+    }
+}

+ 52 - 0
src/main/java/cn/seecoder/courselearning/util/MyBatisGeneratorUtil.java

@@ -0,0 +1,52 @@
+package cn.seecoder.courselearning.util;
+
+import org.mybatis.generator.api.MyBatisGenerator;
+import org.mybatis.generator.config.Configuration;
+import org.mybatis.generator.config.xml.ConfigurationParser;
+import org.mybatis.generator.exception.InvalidConfigurationException;
+import org.mybatis.generator.exception.XMLParserException;
+import org.mybatis.generator.internal.DefaultShellCallback;
+
+import java.io.File;
+import java.io.IOException;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
+// 用于生成自动生成MyBatis相关文件的工具类
+public class MyBatisGeneratorUtil {
+	public static void main(String[] args) {
+		List<String> warnings = new ArrayList<String>();
+		boolean overwrite = true;
+		String genCfg = "/generatorConfig.xml";
+		File configFile = new File(cn.seecoder.courselearning.util.MyBatisGeneratorUtil.class.getResource(genCfg).getFile());
+		ConfigurationParser cp = new ConfigurationParser(warnings);
+		Configuration config = null;
+		try {
+			config = cp.parseConfiguration(configFile);
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (XMLParserException e) {
+			e.printStackTrace();
+		}
+		DefaultShellCallback callback = new DefaultShellCallback(overwrite);
+		MyBatisGenerator myBatisGenerator = null;
+		try {
+			myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
+		} catch (InvalidConfigurationException e) {
+			e.printStackTrace();
+		}
+		try {
+			myBatisGenerator.generate(null);
+		} catch (SQLException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (InterruptedException e) {
+			e.printStackTrace();
+		}
+	}
+
+
+
+}

+ 29 - 0
src/main/java/cn/seecoder/courselearning/util/PageInfoUtil.java

@@ -0,0 +1,29 @@
+package cn.seecoder.courselearning.util;
+
+import com.github.pagehelper.Page;
+import com.github.pagehelper.PageInfo;
+import org.springframework.beans.BeanUtils;
+
+public class PageInfoUtil {
+    /**
+     * 将PageInfo对象泛型中的PO对象转化为VO对象后返回
+     * @param <P> PO类型
+     * @param <V> VO类型
+     */
+    public static <P, V> PageInfo<V> convert(PageInfo<P> pageInfoPO, Class<V> vClass) {
+        // 创建Page对象,实际上是一个ArrayList类型的集合
+        Page<V> page = new Page<>(pageInfoPO.getPageNum(), pageInfoPO.getPageSize());
+        page.setTotal(pageInfoPO.getTotal());
+        for (P p : pageInfoPO.getList()) {
+            V v = null;
+            try {
+                v = vClass.newInstance();
+            } catch (InstantiationException | IllegalAccessException e) {
+                e.printStackTrace();
+            }
+            BeanUtils.copyProperties(p, v);
+            page.add(v);
+        }
+        return new PageInfo<>(page);
+    }
+}

+ 61 - 0
src/main/java/cn/seecoder/courselearning/util/ResponceCodeProcesser.java

@@ -0,0 +1,61 @@
+/*
+ * Copyright 2020. Huawei Technologies Co., Ltd. All rights reserved.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+ */
+package cn.seecoder.courselearning.util;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A tool for processing the responce code
+ */
+public class ResponceCodeProcesser {
+    private static final Map<Integer, String> codeMap = new HashMap<Integer, String>() {
+        {
+            put(80000000, "Success");
+            put(80100000, "Some tokens are right, the others are illegal");
+            put(80100001, "Parameters check error");
+            put(80100002, "Token number should be one when send sys message");
+            put(80100003, "Message structure error");
+            put(80100004, "TTL is less than current time, please check");
+            put(80100013, "Collapse_key is illegal, please check");
+            put(80100016, "Message contians sensitive information, please check");
+            put(80200001, "Oauth authentication error");
+            put(80200003, "Oauth Token expired");
+            put(80300002, "APP is forbidden to send");
+            put(80300007, "Invalid Token");
+            put(80300008, "The message body size exceeds the default value set by the system (4K)");
+            put(80300010, "Tokens exceed the default value");
+            put(81000001, "System inner error");
+            put(82000001, "GroupKey or groupName error");
+            put(82000002, "GroupKey and groupName do not match");
+            put(82000003, "Token array is null");
+            put(82000004, "Group do not exist");
+            put(82000005, "Group do not belond to this app");
+            put(82000006, "Token array or group number is transfinited");
+            put(82000007, "Invalid topic");
+            put(82000008, "Token array null or transfinited");
+            put(82000009, "Topic num transfinited, at most 2000");
+            put(82000010, "Some token is wrong");
+            put(82000011, "Token is null");
+            put(82000012, "Data storage location is not selected");
+            put(82000013, "Data storage location does not match the actual data");
+        }
+    };
+
+    public static String process(Integer code) {
+        return codeMap.getOrDefault(code, "Unknown code");
+    }
+}

+ 40 - 0
src/main/java/cn/seecoder/courselearning/util/ValidatorUtils.java

@@ -0,0 +1,40 @@
+/*
+ * Copyright 2020. Huawei Technologies Co., Ltd. All rights reserved.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+ */
+package cn.seecoder.courselearning.util;
+
+/**
+ * A tool for validating the parameters
+ */
+public class ValidatorUtils {
+
+    public static void checkArgument(boolean expression) {
+        if (!expression) {
+            throw new IllegalArgumentException();
+        }
+    }
+
+    public static void checkArgument(boolean expression, Object errorMessage) {
+        if (!expression) {
+            throw new IllegalArgumentException(String.valueOf(errorMessage));
+        }
+    }
+
+    public static void checkState(boolean expression, Object errorMessage) {
+        if (!expression) {
+            throw new IllegalStateException(String.valueOf(errorMessage));
+        }
+    }
+}

+ 37 - 0
src/main/java/cn/seecoder/courselearning/vo/CourseOrderVO.java

@@ -0,0 +1,37 @@
+package cn.seecoder.courselearning.vo;
+
+import cn.seecoder.courselearning.model.CourseOrder;
+import lombok.Data;
+import lombok.NonNull;
+
+import java.util.Date;
+
+@Data
+public class CourseOrderVO {
+    private Integer id;
+
+    private Integer cost;
+
+    private Integer courseId;
+
+    private String courseName;
+
+    private Date createTime;
+
+    private String userId;
+
+    private Integer status;
+
+    public CourseOrderVO() {
+    }
+
+    public CourseOrderVO(@NonNull CourseOrder order) {
+        id = order.getId();
+        cost = order.getCost();
+        courseId = order.getCourseId();
+        courseName = order.getCourseName();
+        createTime = order.getCreateTime();
+        userId = order.getUserId();
+        status = order.getStatus();
+    }
+}

+ 56 - 0
src/main/java/cn/seecoder/courselearning/vo/CourseVO.java

@@ -0,0 +1,56 @@
+package cn.seecoder.courselearning.vo;
+
+import cn.seecoder.courselearning.model.Course;
+import lombok.Data;
+import lombok.NonNull;
+
+import java.util.Date;
+
+@Data
+public class CourseVO {
+    private Integer id;
+
+    private String name;
+
+    private String type;
+
+    private String intro;
+
+    private String picture;
+
+    private String provider;
+
+    private Date createTime;
+
+    private Integer cost;
+
+    private boolean bought;
+
+    public CourseVO() {
+        bought = false;
+    }
+
+    public CourseVO(@NonNull Course course){
+        id = course.getId();
+        name = course.getName();
+        type = course.getType();
+        intro = course.getIntro();
+        picture = course.getPicture();
+        provider = course.getProvider();
+        createTime = course.getCreateTime();
+        cost = course.getCost();
+        bought = false;
+    }
+
+    public CourseVO(@NonNull Course course, boolean bought){
+        id = course.getId();
+        name = course.getName();
+        type = course.getType();
+        intro = course.getIntro();
+        picture = course.getPicture();
+        provider = course.getProvider();
+        createTime = course.getCreateTime();
+        cost = course.getCost();
+        this.bought = bought;
+    }
+}

+ 63 - 0
src/main/java/cn/seecoder/courselearning/vo/CourseWareVO.java

@@ -0,0 +1,63 @@
+package cn.seecoder.courselearning.vo;
+
+import cn.seecoder.courselearning.model.CourseWare;
+import lombok.Data;
+import lombok.NonNull;
+
+import java.util.Date;
+
+@Data
+public class CourseWareVO {
+    private Integer id;
+
+    private Integer courseId;
+
+    private Integer number;
+
+    private String title;
+
+    private String fileName;
+
+    private String fileType;
+
+    private String fileSize;
+
+    private Boolean freeFlag;
+
+    private Boolean downloadFlag;
+
+    private Boolean availableFlag;
+
+    private Date uploadTime;
+
+    public CourseWareVO(){
+    }
+
+    public CourseWareVO(@NonNull CourseWare courseWare) {
+        id = courseWare.getId();
+        courseId = courseWare.getCourseId();
+        number = courseWare.getNumber();
+        title = courseWare.getTitle();
+        fileName = courseWare.getFileName();
+        fileType = courseWare.getFileType();
+        fileSize = courseWare.getFileSize();
+        freeFlag = courseWare.getFreeFlag();
+        downloadFlag = courseWare.getDownloadFlag();
+        availableFlag = freeFlag;
+        uploadTime = courseWare.getUploadTime();
+    }
+
+    public CourseWareVO(@NonNull CourseWare courseWare, boolean isBought) {
+        id = courseWare.getId();
+        courseId = courseWare.getCourseId();
+        number = courseWare.getNumber();
+        title = courseWare.getTitle();
+        fileName = courseWare.getFileName();
+        fileType = courseWare.getFileType();
+        fileSize = courseWare.getFileSize();
+        freeFlag = courseWare.getFreeFlag();
+        downloadFlag = courseWare.getDownloadFlag();
+        availableFlag = isBought?true:freeFlag;
+        uploadTime = courseWare.getUploadTime();
+    }
+}

+ 57 - 0
src/main/java/cn/seecoder/courselearning/vo/RechargeOrderVO.java

@@ -0,0 +1,57 @@
+package cn.seecoder.courselearning.vo;
+
+import cn.seecoder.courselearning.model.RechargeOrder;
+
+import java.util.Date;
+
+public class RechargeOrderVO {
+    private String orderId;
+
+    private String uid;
+
+    private Integer value;
+
+    private Date createTime;
+
+    public String getOrderId() {
+        return orderId;
+    }
+
+    public void setOrderId(String orderId) {
+        this.orderId = orderId == null ? null : orderId.trim();
+    }
+
+    public String getUid() {
+        return uid;
+    }
+
+    public void setUid(String uid) {
+        this.uid = uid == null ? null : uid.trim();
+    }
+
+    public Integer getValue() {
+        return value;
+    }
+
+    public void setValue(Integer value) {
+        this.value = value;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public RechargeOrderVO() {
+    }
+
+    public RechargeOrderVO(RechargeOrder rechargeOrder) {
+        this.orderId = rechargeOrder.getOrderId();
+        this.uid = rechargeOrder.getUid();
+        this.value = rechargeOrder.getValue();
+        this.createTime = rechargeOrder.getCreateTime();
+    }
+}

+ 29 - 0
src/main/java/cn/seecoder/courselearning/vo/ResultVO.java

@@ -0,0 +1,29 @@
+package cn.seecoder.courselearning.vo;
+
+import lombok.Data;
+import lombok.NonNull;
+
+@Data
+public class ResultVO<T> {
+
+    private Integer code;
+
+    private String msg;
+
+    private T data;
+
+    public ResultVO(){
+
+    }
+
+    public ResultVO(Integer code, String msg){
+        this.code = code;
+        this.msg = msg;
+    }
+
+    public ResultVO(Integer code, String msg, @NonNull T data) {
+        this.code = code;
+        this.msg = msg;
+        this.data = data;
+    }
+}

+ 26 - 0
src/main/java/cn/seecoder/courselearning/vo/UserVO.java

@@ -0,0 +1,26 @@
+package cn.seecoder.courselearning.vo;
+
+import cn.seecoder.courselearning.model.User;
+import lombok.Data;
+import lombok.NonNull;
+
+@Data
+public class UserVO {
+    private String uid;
+
+    private String uname;
+
+    private String picture;
+
+    private Integer balance;
+
+    public UserVO() {
+    }
+
+    public UserVO(@NonNull User user) {
+        uid = user.getUid();
+        uname = user.getUname();
+        picture = user.getPicture();
+        balance = user.getBalance();
+    }
+}

+ 22 - 0
src/main/resources/application.yml

@@ -0,0 +1,22 @@
+server:
+  port: 8081
+
+spring:
+  datasource:
+    url: jdbc:mysql://localhost:3306/courselearning?setUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true
+    driver-class-name: com.mysql.cj.jdbc.Driver
+    username: root
+    password: 123456
+#  web:
+#    resources:
+#      static-locations: classpath:/META-INF/resources/, classpath:/resources/, classpath:/static/, classpath:/public/
+#  servlet:
+#    multipart:
+#      max-file-size: 50MB
+#      max-request-size: 100MB
+
+# 开启Mybatis日志
+logging:
+  level:
+    cn.seecoder.courselearning.mapper: DEBUG
+

+ 49 - 0
src/main/resources/generatorConfig.xml

@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+  <!DOCTYPE generatorConfiguration
+    PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
+    "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
+  <generatorConfiguration>
+
+	 <context id="MysqlContext" targetRuntime="MyBatis3Simple" defaultModelType="flat">
+        
+     
+        <property name="beginningDelimiter" value="`"/>
+        <property name="endingDelimiter" value="`"/>
+
+         <!-- suppressDate是去掉生成日期那行注释,suppressAllComments是去掉所有的注解 -->
+        <commentGenerator>
+	        <property name="suppressDate" value="true"/>
+	        <property name="suppressAllComments" value="true" />
+    	</commentGenerator>
+  
+        <jdbcConnection driverClass="com.mysql.cj.jdbc.Driver"
+                        connectionURL="jdbc:mysql://localhost:3306/courselearning?useUnicode=true&amp;characterEncoding=UTF-8&amp;userSSL=false&amp;serverTimezone=GMT%2B8"
+                        userId="root"
+                        password="123456">
+        </jdbcConnection>
+
+       		 <!--生成model类的存放位置 -->
+         <javaModelGenerator targetPackage="cn.seecoder.courselearning.model" targetProject="src/main/java">
+             <property name="enableSubPackages" value="true"/>
+             <property name="trimStrings" value="true"/>
+         </javaModelGenerator>
+        
+		 <!-- 生成映射文件的存放位置 -->
+         <sqlMapGenerator targetPackage="mapper" targetProject="src/main/resources">
+             <property name="enableSubPackages" value="true"/>
+         </sqlMapGenerator>
+      
+	     <!-- 生成Dao类的存放位置-->
+         <javaClientGenerator type="XMLMAPPER" targetPackage="cn.seecoder.courselearning.mapper" targetProject="src/main/java">
+             <property name="enableSubPackages" value="true"/>
+         </javaClientGenerator>
+         
+		 <!-- 生成对应的表及类名 -->
+<!--         <table tableName="course" domainObjectName="Course" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>-->
+<!--         <table tableName="course_ware" domainObjectName="CourseWare" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>-->
+<!--         <table tableName="user_info" domainObjectName="UserInfo" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>-->
+         <table tableName="user_token" domainObjectName="UserToken" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
+<!--         <table tableName="recharge_order" domainObjectName="RechargeOrder" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>-->
+<!--         <table tableName="course_order" domainObjectName="CourseOrder" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>-->
+     </context>
+ </generatorConfiguration>

+ 78 - 0
src/main/resources/mapper/CourseMapper.xml

@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.seecoder.courselearning.mapper.CourseMapper">
+  <resultMap id="BaseResultMap" type="cn.seecoder.courselearning.model.Course">
+    <id column="id" jdbcType="INTEGER" property="id" />
+    <result column="name" jdbcType="VARCHAR" property="name" />
+    <result column="type" jdbcType="VARCHAR" property="type" />
+    <result column="intro" jdbcType="VARCHAR" property="intro" />
+    <result column="picture" jdbcType="VARCHAR" property="picture" />
+    <result column="provider" jdbcType="VARCHAR" property="provider" />
+    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
+    <result column="delete_time" jdbcType="TIMESTAMP" property="deleteTime" />
+    <result column="cost" jdbcType="INTEGER" property="cost" />
+  </resultMap>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
+    delete from course
+    where id = #{id,jdbcType=INTEGER}
+  </delete>
+  <insert id="insert" parameterType="cn.seecoder.courselearning.model.Course">
+    insert into course (id, name, type, 
+      intro, picture, provider, 
+      create_time, delete_time, cost
+      )
+    values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, 
+      #{intro,jdbcType=VARCHAR}, #{picture,jdbcType=VARCHAR}, #{provider,jdbcType=VARCHAR}, 
+      #{createTime,jdbcType=TIMESTAMP}, #{deleteTime,jdbcType=TIMESTAMP}, #{cost,jdbcType=INTEGER}
+      )
+  </insert>
+  <update id="updateByPrimaryKey" parameterType="cn.seecoder.courselearning.model.Course">
+    update course
+    set name = #{name,jdbcType=VARCHAR},
+      type = #{type,jdbcType=VARCHAR},
+      intro = #{intro,jdbcType=VARCHAR},
+      picture = #{picture,jdbcType=VARCHAR},
+      provider = #{provider,jdbcType=VARCHAR},
+      create_time = #{createTime,jdbcType=TIMESTAMP},
+      delete_time = #{deleteTime,jdbcType=TIMESTAMP},
+      cost = #{cost,jdbcType=INTEGER}
+    where id = #{id,jdbcType=INTEGER}
+  </update>
+  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
+    select id, name, type, intro, picture, provider, create_time, delete_time, cost
+    from course
+    where id = #{id,jdbcType=INTEGER}
+  </select>
+  <select id="selectAll" resultMap="BaseResultMap">
+    select id, name, type, intro, picture, provider, create_time, delete_time, cost
+    from course
+  </select>
+  <select id="selectByType" parameterType="java.lang.String" resultMap="BaseResultMap">
+    select id, name, type, intro, picture, provider, create_time, delete_time, cost
+    from course
+    where type = #{type,jdbcType=VARCHAR}
+  </select>
+  <select id="queryAll" parameterType="java.lang.String" resultMap="BaseResultMap">
+    select id, name, type, intro, picture, provider, create_time, delete_time, cost
+    from course
+    <where>
+      <if test="name!=null and name!=''">
+        or name like concat('%',#{key},'%')
+      </if>
+      <if test="intro!=null and type!=''">
+        or intro like concat('%',#{key},'%')
+      </if>
+      <if test="provider!=null and provider!=''">
+        or provider like concat('%',#{key},'%')
+      </if>
+    </where>
+    order by create_time asc
+  </select>
+  <select id="selectByUserId" parameterType="java.lang.String" resultMap="BaseResultMap">
+    select c.id, name, type, intro, picture, provider, create_time, delete_time, cost
+    from course c
+    where exists (
+        select o.id from course_order o where o.course_id = c.id and o.user_id = #{userId}
+    )
+  </select>
+</mapper>

+ 51 - 0
src/main/resources/mapper/CourseOrderMapper.xml

@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.seecoder.courselearning.mapper.CourseOrderMapper">
+  <resultMap id="BaseResultMap" type="cn.seecoder.courselearning.model.CourseOrder">
+    <id column="id" jdbcType="INTEGER" property="id" />
+    <result column="cost" jdbcType="INTEGER" property="cost" />
+    <result column="course_id" jdbcType="INTEGER" property="courseId" />
+    <result column="course_name" jdbcType="VARCHAR" property="courseName" />
+    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
+    <result column="user_id" jdbcType="VARCHAR" property="userId" />
+    <result column="status" jdbcType="INTEGER" property="status" />
+  </resultMap>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
+    delete from course_order
+    where id = #{id,jdbcType=INTEGER}
+  </delete>
+  <insert id="insert" parameterType="cn.seecoder.courselearning.model.CourseOrder">
+    insert into course_order (id, cost, course_id, 
+      course_name, create_time, user_id, 
+      status)
+    values (#{id,jdbcType=INTEGER}, #{cost,jdbcType=INTEGER}, #{courseId,jdbcType=INTEGER}, 
+      #{courseName,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{userId,jdbcType=VARCHAR}, 
+      #{status,jdbcType=INTEGER})
+  </insert>
+  <update id="updateByPrimaryKey" parameterType="cn.seecoder.courselearning.model.CourseOrder">
+    update course_order
+    set cost = #{cost,jdbcType=INTEGER},
+      course_id = #{courseId,jdbcType=INTEGER},
+      course_name = #{courseName,jdbcType=VARCHAR},
+      create_time = #{createTime,jdbcType=TIMESTAMP},
+      user_id = #{userId,jdbcType=VARCHAR},
+      status = #{status,jdbcType=INTEGER}
+    where id = #{id,jdbcType=INTEGER}
+  </update>
+  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
+    select id, cost, course_id, course_name, create_time, user_id, status
+    from course_order
+    where id = #{id,jdbcType=INTEGER}
+  </select>
+  <select id="selectByUserId" resultMap="BaseResultMap">
+    select id, cost, course_id, course_name, create_time, user_id, status
+    from course_order
+    where user_id=#{userId}
+  </select>
+  <select id="queryMostRecentOrder" resultMap="BaseResultMap">
+    select id, cost, course_id, course_name, create_time, user_id, status
+    from course_order
+    where user_id=#{userId} and course_id=#{courseId}
+    order by create_time desc limit 1
+  </select>
+</mapper>

+ 55 - 0
src/main/resources/mapper/CourseWareMapper.xml

@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.seecoder.courselearning.mapper.CourseWareMapper">
+  <resultMap id="BaseResultMap" type="cn.seecoder.courselearning.model.CourseWare">
+    <id column="id" jdbcType="INTEGER" property="id" />
+    <result column="course_id" jdbcType="INTEGER" property="courseId" />
+    <result column="number" jdbcType="INTEGER" property="number" />
+    <result column="title" jdbcType="VARCHAR" property="title" />
+    <result column="file_name" jdbcType="VARCHAR" property="fileName" />
+    <result column="file_type" jdbcType="VARCHAR" property="fileType" />
+    <result column="file_size" jdbcType="VARCHAR" property="fileSize" />
+    <result column="free_flag" jdbcType="BIT" property="freeFlag" />
+    <result column="download_flag" jdbcType="BIT" property="downloadFlag" />
+    <result column="upload_time" jdbcType="TIMESTAMP" property="uploadTime" />
+  </resultMap>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
+    delete from course_ware
+    where id = #{id,jdbcType=INTEGER}
+  </delete>
+  <insert id="insert" parameterType="cn.seecoder.courselearning.model.CourseWare">
+    insert into course_ware (id, course_id, number, 
+      title, file_name, file_type, 
+      file_size, free_flag, download_flag, 
+      upload_time)
+    values (#{id,jdbcType=INTEGER}, #{courseId,jdbcType=INTEGER}, #{number,jdbcType=INTEGER}, 
+      #{title,jdbcType=VARCHAR}, #{fileName,jdbcType=VARCHAR}, #{fileType,jdbcType=VARCHAR}, 
+      #{fileSize,jdbcType=VARCHAR}, #{freeFlag,jdbcType=BIT}, #{downloadFlag,jdbcType=BIT}, 
+      #{uploadTime,jdbcType=TIMESTAMP})
+  </insert>
+  <update id="updateByPrimaryKey" parameterType="cn.seecoder.courselearning.model.CourseWare">
+    update course_ware
+    set course_id = #{courseId,jdbcType=INTEGER},
+      number = #{number,jdbcType=INTEGER},
+      title = #{title,jdbcType=VARCHAR},
+      file_name = #{fileName,jdbcType=VARCHAR},
+      file_type = #{fileType,jdbcType=VARCHAR},
+      file_size = #{fileSize,jdbcType=VARCHAR},
+      free_flag = #{freeFlag,jdbcType=BIT},
+      download_flag = #{downloadFlag,jdbcType=BIT},
+      upload_time = #{uploadTime,jdbcType=TIMESTAMP}
+    where id = #{id,jdbcType=INTEGER}
+  </update>
+  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
+    select id, course_id, number, title, file_name, file_type, file_size, free_flag, 
+    download_flag, upload_time
+    from course_ware
+    where id = #{id,jdbcType=INTEGER}
+  </select>
+  <select id="selectByCourseId" resultMap="BaseResultMap">
+    select id, course_id, number, title, file_name, file_type, file_size, free_flag, 
+    download_flag, upload_time
+    from course_ware
+    where course_id = #{courseId,jdbcType=INTEGER}
+  </select>
+</mapper>

+ 36 - 0
src/main/resources/mapper/RechargeOrderMapper.xml

@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.seecoder.courselearning.mapper.RechargeOrderMapper">
+  <resultMap id="BaseResultMap" type="cn.seecoder.courselearning.model.RechargeOrder">
+    <id column="order_id" jdbcType="VARCHAR" property="orderId" />
+    <result column="uid" jdbcType="VARCHAR" property="uid" />
+    <result column="value" jdbcType="INTEGER" property="value" />
+    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
+  </resultMap>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
+    delete from recharge_order
+    where order_id = #{orderId,jdbcType=VARCHAR}
+  </delete>
+  <insert id="insert" parameterType="cn.seecoder.courselearning.model.RechargeOrder">
+    insert into recharge_order (order_id, uid, value, 
+      create_time)
+    values (#{orderId,jdbcType=VARCHAR}, #{uid,jdbcType=VARCHAR}, #{value,jdbcType=INTEGER}, 
+      #{createTime,jdbcType=TIMESTAMP})
+  </insert>
+  <update id="updateByPrimaryKey" parameterType="cn.seecoder.courselearning.model.RechargeOrder">
+    update recharge_order
+    set uid = #{uid,jdbcType=VARCHAR},
+      value = #{value,jdbcType=INTEGER},
+      create_time = #{createTime,jdbcType=TIMESTAMP}
+    where order_id = #{orderId,jdbcType=VARCHAR}
+  </update>
+  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
+    select order_id, uid, value, create_time
+    from recharge_order
+    where order_id = #{orderId,jdbcType=VARCHAR}
+  </select>
+  <select id="selectAll" resultMap="BaseResultMap">
+    select order_id, uid, value, create_time
+    from recharge_order
+  </select>
+</mapper>

+ 42 - 0
src/main/resources/mapper/UserMapper.xml

@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.seecoder.courselearning.mapper.UserMapper">
+  <resultMap id="BaseResultMap" type="cn.seecoder.courselearning.model.User">
+    <id column="uid" jdbcType="VARCHAR" property="uid" />
+    <result column="uname" jdbcType="VARCHAR" property="uname" />
+    <result column="picture" jdbcType="VARCHAR" property="picture" />
+    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
+    <result column="balance" jdbcType="INTEGER" property="balance" />
+  </resultMap>
+  <insert id="insert" parameterType="cn.seecoder.courselearning.model.User">
+    insert into user_info (uid, uname, picture, 
+      create_time, balance)
+    values (#{uid,jdbcType=VARCHAR}, #{uname,jdbcType=VARCHAR}, #{picture,jdbcType=VARCHAR}, 
+      #{createTime,jdbcType=TIMESTAMP}, #{balance,jdbcType=INTEGER})
+  </insert>
+  <update id="updateUnameAndPicture" parameterType="cn.seecoder.courselearning.model.User">
+    update user_info
+    set uname = #{uname,jdbcType=VARCHAR}
+    set picture = #{picture,jdbcType=VARCHAR}
+    where uid = #{uid,jdbcType=VARCHAR}
+  </update>
+  <update id="increaseBalance">
+    update user_info
+    set balance = balance+#{delta,jdbcType=INTEGER}
+    where uid = #{uid,jdbcType=VARCHAR}
+  </update>
+  <update id="decreaseBalance">
+    update user_info
+    set balance = balance-#{delta,jdbcType=INTEGER}
+    where uid = #{uid,jdbcType=VARCHAR}
+  </update>
+  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
+    select uid, uname, picture, create_time, balance
+    from user_info
+    where uid = #{uid,jdbcType=VARCHAR}
+  </select>
+  <select id="selectAll" resultMap="BaseResultMap">
+    select uid, uname, picture, create_time, balance
+    from user_info
+  </select>
+</mapper>

+ 36 - 0
src/main/resources/mapper/UserTokenMapper.xml

@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.seecoder.courselearning.mapper.UserTokenMapper">
+  <resultMap id="BaseResultMap" type="cn.seecoder.courselearning.model.UserToken">
+    <id column="uid" jdbcType="VARCHAR" property="uid" />
+    <result column="token" jdbcType="VARCHAR" property="token" />
+    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
+    <result column="active" jdbcType="BIT" property="active" />
+  </resultMap>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
+    delete from user_token
+    where uid = #{uid,jdbcType=VARCHAR}
+  </delete>
+  <insert id="insert" parameterType="cn.seecoder.courselearning.model.UserToken">
+    insert into user_token (uid, token, update_time, 
+      active)
+    values (#{uid,jdbcType=VARCHAR}, #{token,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP}, 
+      #{active,jdbcType=BIT})
+  </insert>
+  <update id="updateByPrimaryKey" parameterType="cn.seecoder.courselearning.model.UserToken">
+    update user_token
+    set token = #{token,jdbcType=VARCHAR},
+      update_time = #{updateTime,jdbcType=TIMESTAMP},
+      active = #{active,jdbcType=BIT}
+    where uid = #{uid,jdbcType=VARCHAR}
+  </update>
+  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
+    select uid, token, update_time, active
+    from user_token
+    where uid = #{uid,jdbcType=VARCHAR}
+  </select>
+  <select id="selectAll" resultMap="BaseResultMap">
+    select uid, token, update_time, active
+    from user_token
+  </select>
+</mapper>

+ 14 - 0
src/main/resources/mybatis-config.xml

@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE configuration
+        PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-config.dtd">
+<configuration>
+    <settings>
+        <!-- 是否可以使用列的别名 (取决于驱动的兼容性) default:true -->
+        <setting name="useColumnLabel" value="true"/>
+        <!-- 允许JDBC 获取生成的主键。需要驱动器支持。如果设为了true,这个设置将强制使用被生成的主键,有一些驱动器不兼容不过仍然可以执行。 default:false -->
+        <setting name="useGeneratedKeys" value="true" />
+        <!-- 使用驼峰命名法转换字段。 -->
+        <setting name="mapUnderscoreToCamelCase" value="true" />
+    </settings>
+</configuration>

Некоторые файлы не были показаны из-за большого количества измененных файлов