Эх сурвалжийг харах

Merge branch 'feature-cloud' of ssh://10.10.100.21/source/smartschool-platform into feature-cloud

koul 6 жил өмнө
parent
commit
e0f686c07c
100 өөрчлөгдсөн 2007 нэмэгдсэн , 275 устгасан
  1. 45 0
      applications/device/device-client/config/inno.iss
  2. 2 0
      applications/device/device-client/src/main/java/com/usoftchina/smartschool/device/client/service/AccessControlService.java
  3. 2 2
      applications/device/device-client/src/main/resources/application.yml
  4. 81 55
      applications/device/device-sdk-dahua/src/main/java/com/usoftchina/smartschool/device/dahua/lib/DahuaLibrary.java
  5. 0 2
      applications/device/device-server/src/main/java/com/usoftchina/smartschool/device/controller/IcCardController.java
  6. 2 0
      applications/device/device-server/src/main/java/com/usoftchina/smartschool/device/po/AccessControlRecord.java
  7. 71 23
      applications/device/device-server/src/main/java/com/usoftchina/smartschool/device/po/ImageFile.java
  8. 10 8
      applications/device/device-server/src/main/java/com/usoftchina/smartschool/device/service/impl/AccessControlServiceImpl.java
  9. 6 0
      applications/device/device-server/src/main/resources/mapper/AccessControlRecordMapper.xml
  10. 25 2
      applications/device/device-server/src/test/java/com/usoftchina/smartschool/device/test/TestService.java
  11. 31 0
      applications/school/school-dto/src/main/java/com/usoftchina/smartschool/school/enums/NoticeTemplate.java
  12. 45 0
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/basic/controller/SchoolTemplateController.java
  13. 15 0
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/basic/service/SchoolTemplateService.java
  14. 1 1
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/basic/service/impl/ClassServiceImpl.java
  15. 15 17
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/basic/service/impl/CurriculumServiceImpl.java
  16. 1 0
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/basic/service/impl/GradeServiceImpl.java
  17. 73 0
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/basic/service/impl/SchoolTemplateServiceImpl.java
  18. 3 1
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/basic/service/impl/StudentServiceImpl.java
  19. 48 7
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/business/service/impl/HomeWorkServiceImpl.java
  20. 50 0
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/business/service/impl/NoticeServiceImpl.java
  21. 50 0
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/business/service/impl/ScoreServiceImpl.java
  22. 3 2
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/exception/BizExceptionCode.java
  23. 3 0
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/mapper/HomeWorkMapper.java
  24. 4 0
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/mapper/NoticeMapper.java
  25. 25 0
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/mapper/SchoolTemplateMapper.java
  26. 2 0
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/mapper/ScoreMapper.java
  27. 1 1
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/mapper/SysClazzMapper.java
  28. 2 0
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/mapper/SysTeacherMapper.java
  29. 4 0
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/po/HomeWork.java
  30. 18 0
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/po/HomeworkNoticer.java
  31. 58 0
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/po/InOutRecordDO.java
  32. 22 0
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/po/SchoolNoticer.java
  33. 55 0
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/po/SchoolTemplate.java
  34. 24 0
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/po/ScoreNoticer.java
  35. 11 0
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/po/SysStudent.java
  36. 14 4
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/wxschool/basic/controller/WxOutInRecordController.java
  37. 8 0
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/wxschool/basic/service/WxOutInRecordService.java
  38. 17 3
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/wxschool/basic/service/impl/WxOutInRecordServiceImpl.java
  39. 3 0
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/wxschool/mapper/WxOutInRecordMapper.java
  40. 29 1
      applications/school/school-server/src/main/resources/mapper/HomeWorkMapper.xml
  41. 5 0
      applications/school/school-server/src/main/resources/mapper/NotifyMapper.xml
  42. 104 0
      applications/school/school-server/src/main/resources/mapper/SchoolTemplateMapper.xml
  43. 6 0
      applications/school/school-server/src/main/resources/mapper/ScoreMapper.xml
  44. 3 3
      applications/school/school-server/src/main/resources/mapper/SysClazzMapper.xml
  45. 10 0
      applications/school/school-server/src/main/resources/mapper/SysStudentMapper.xml
  46. 4 0
      applications/school/school-server/src/main/resources/mapper/SysTeacherMapper.xml
  47. 4 0
      applications/school/school-server/src/main/resources/mapper/WxOutInRecordMapper.xml
  48. 4 0
      applications/wechat/wechat-api/src/main/java/com/usoftchina/smartschool/wechat/api/WechatApi.java
  49. 21 0
      applications/wechat/wechat-dto/src/main/java/com/usoftchina/smartschool/wechat/dto/TransferDTO.java
  50. 0 4
      applications/wechat/wechat-server/pom.xml
  51. 0 2
      applications/wechat/wechat-server/src/main/java/com/usoftchina/smartschool/wechat/WechatApplication.java
  52. 18 5
      applications/wechat/wechat-server/src/main/java/com/usoftchina/smartschool/wechat/controller/TransfersController.java
  53. 0 2
      applications/wechat/wechat-server/src/main/java/com/usoftchina/smartschool/wechat/controller/WxPushController.java
  54. 9 0
      applications/wechat/wechat-server/src/main/java/com/usoftchina/smartschool/wechat/po/MessagePackage.java
  55. 2 3
      applications/wechat/wechat-server/src/main/java/com/usoftchina/smartschool/wechat/service/ReceiveService.java
  56. 19 0
      applications/wechat/wechat-server/src/test/java/com/usoftchina/smartschool/wechat/NonSpringTest.java
  57. 20 0
      applications/wechat/wechat-server/src/test/java/com/usoftchina/smartschool/wechat/Test_service.java
  58. 3 0
      base-servers/account/account-api/src/main/java/com/usoftchina/smartschool/account/api/AccountApi.java
  59. 9 0
      base-servers/account/account-dto/src/main/java/com/usoftchina/smartschool/account/dto/AccountDTO.java
  60. 10 0
      base-servers/account/account-server/src/main/java/com/usoftchina/smartschool/account/controller/AccountController.java
  61. 8 0
      base-servers/account/account-server/src/main/java/com/usoftchina/smartschool/account/mapper/AccountMapper.java
  62. 8 0
      base-servers/account/account-server/src/main/java/com/usoftchina/smartschool/account/service/AccountService.java
  63. 5 0
      base-servers/account/account-server/src/main/java/com/usoftchina/smartschool/account/service/impl/AccountServiceImpl.java
  64. 1 1
      base-servers/account/account-server/src/main/resources/config/application-docker-cloud.yml
  65. 4 0
      base-servers/account/account-server/src/main/resources/mapper/AccountMapper.xml
  66. 3 0
      base-servers/auth/auth-server/src/main/java/com/usoftchina/smartschool/auth/controller/AuthController.java
  67. 1 1
      base-servers/auth/auth-server/src/main/resources/config/application-docker-cloud.yml
  68. 18 1
      base-servers/file/file-api/src/main/java/com/usoftchina/smartschool/file/api/FileApi.java
  69. 90 0
      base-servers/file/file-api/src/main/java/com/usoftchina/smartschool/file/api/util/ByteArrayMultipartFile.java
  70. 35 0
      base-servers/file/file-api/src/main/java/com/usoftchina/smartschool/file/api/util/FileUploadUtils.java
  71. 17 4
      base-servers/file/file-dto/src/main/java/com/usoftchina/smartschool/file/dto/FileInfoDTO.java
  72. 37 0
      base-servers/file/file-dto/src/main/java/com/usoftchina/smartschool/file/dto/ImageFile.java
  73. 41 0
      base-servers/file/file-server-fdfs/pom.xml
  74. 1 1
      base-servers/file/file-server-fdfs/src/main/docker/Dockerfile
  75. 5 8
      base-servers/file/file-server-fdfs/src/main/java/com/usoftchina/smartschool/file/fdfs/FdfsFileApplication.java
  76. 11 11
      base-servers/file/file-server-fdfs/src/main/resources/application.yml
  77. 1 4
      base-servers/file/file-server-fdfs/src/main/resources/config/application-docker-prod.yml
  78. 0 0
      base-servers/file/file-server-fdfs/src/main/resources/config/application-docker.yml
  79. 0 0
      base-servers/file/file-server-fdfs/src/main/resources/logback-spring.xml
  80. 41 0
      base-servers/file/file-server-qcloud/pom.xml
  81. 6 0
      base-servers/file/file-server-qcloud/src/main/docker/Dockerfile
  82. 26 0
      base-servers/file/file-server-qcloud/src/main/java/com/usoftchina/smartschool/file/qcloud/QCloudFileApplication.java
  83. 97 0
      base-servers/file/file-server-qcloud/src/main/resources/application.yml
  84. 29 0
      base-servers/file/file-server-qcloud/src/main/resources/config/application-docker-cloud.yml
  85. 7 0
      base-servers/file/file-server-qcloud/src/main/resources/config/application-docker-prod.yml
  86. 131 0
      base-servers/file/file-server-qcloud/src/main/resources/logback-spring.xml
  87. 2 19
      base-servers/file/file-server/pom.xml
  88. 7 16
      base-servers/file/file-server/src/main/java/com/usoftchina/smartschool/file/controller/FileController.java
  89. 31 24
      base-servers/file/file-server/src/main/java/com/usoftchina/smartschool/file/po/FileInfo.java
  90. 0 13
      base-servers/file/file-server/src/main/resources/config/application-dev.yml
  91. 0 12
      base-servers/file/file-server/src/main/resources/config/application-docker-dev.yml
  92. 0 12
      base-servers/file/file-server/src/main/resources/config/application-docker-test.yml
  93. 0 0
      base-servers/file/file-server/src/main/resources/i18n/messages_en_US.properties
  94. 0 0
      base-servers/file/file-server/src/main/resources/i18n/messages_zh_CN.properties
  95. 24 0
      base-servers/file/file-storage-fdfs/pom.xml
  96. 21 0
      base-servers/file/file-storage-fdfs/src/main/java/com/usoftchina/smartschool/file/storage/fdfs/FdfsConfig.java
  97. 50 0
      base-servers/file/file-storage-fdfs/src/main/java/com/usoftchina/smartschool/file/storage/fdfs/FdfsFileStorageClient.java
  98. 3 0
      base-servers/file/file-storage-fdfs/src/main/resources/META-INF/spring.factories
  99. 35 0
      base-servers/file/file-storage-qcloud/pom.xml
  100. 81 0
      base-servers/file/file-storage-qcloud/src/main/java/com/usoftchina/smartschool/file/storage/qcloud/COSFileStorageClient.java

+ 45 - 0
applications/device/device-client/config/inno.iss

@@ -0,0 +1,45 @@
+; Script generated by the Inno Setup Script Wizard.
+; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
+
+#define MyAppName "device-client"
+#define MyAppVersion "1.0.0.0"
+#define MyAppPublisher "usoftchina.com"
+#define MyAppURL "https://www.usoftchina.com/"
+#define MyAppExeName "device-client.exe"
+
+[Setup]
+; NOTE: The value of AppId uniquely identifies this application.
+; Do not use the same AppId value in installers for other applications.
+; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
+AppId={{B53F1479-C51D-4EC5-9E67-C6A0D6705E75}
+AppName={#MyAppName}
+AppVersion={#MyAppVersion}
+;AppVerName={#MyAppName} {#MyAppVersion}
+AppPublisher={#MyAppPublisher}
+AppPublisherURL={#MyAppURL}
+AppSupportURL={#MyAppURL}
+AppUpdatesURL={#MyAppURL}
+DefaultDirName={pf}\{#MyAppName}
+DisableProgramGroupPage=yes
+OutputBaseFilename=setup
+SetupIconFile=F:\workspace\smartschool-platform\applications\device\device-client\src\main\resources\icon.ico
+Compression=lzma
+SolidCompression=yes
+
+[Languages]
+Name: "english"; MessagesFile: "compiler:Default.isl"
+
+[Tasks]
+Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
+
+[Files]
+Source: "F:\workspace\smartschool-platform\applications\device\device-client\target\device-client.exe"; DestDir: "{app}"; Flags: ignoreversion
+; NOTE: Don't use "Flags: ignoreversion" on any shared system files
+
+[Icons]
+Name: "{commonprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
+Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
+
+[Run]
+Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
+

+ 2 - 0
applications/device/device-client/src/main/java/com/usoftchina/smartschool/device/client/service/AccessControlService.java

@@ -100,6 +100,8 @@ public class AccessControlService {
      * @param info
      */
     public void saveRecord(AccessControlInfo info) {
+        //去除cardNo末尾中的\u0000...\u0000
+        info.setCardNo(info.getCardNo().trim());
         ResponseEntity<Result> response = restTemplate.postForEntity(
                 deviceServerProperties.getAccessControlEvent(), info, Result.class);
         if (response.getStatusCode() == HttpStatus.OK) {

+ 2 - 2
applications/device/device-client/src/main/resources/application.yml

@@ -4,10 +4,10 @@ device:
     connect-time: 10000
   server:
   # 门禁事件的服务端接口
-    accessControlEvent: https://school-api.ydyhz.com/api/device/accesscontrol/event
+    accessControlEvent: https://school-api.ubtob.com/api/device/accesscontrol/event
   # IC卡传输的服务端接口
   icCard:
-    icCardUrl: https://school-api.ydyhz.com/api/device/iccard/consume/record
+    icCardUrl: https://school-api.ubtob.com/api/device/iccard/consume/record
 server:
   tomcat:
     uri-encoding: UTF-8

+ 81 - 55
applications/device/device-sdk-dahua/src/main/java/com/usoftchina/smartschool/device/dahua/lib/DahuaLibrary.java

@@ -7,6 +7,7 @@ import com.sun.jna.Structure;
 import com.sun.jna.ptr.IntByReference;
 import com.sun.jna.win32.StdCallLibrary;
 
+import java.nio.charset.Charset;
 import java.time.LocalDateTime;
 import java.time.ZoneOffset;
 import java.time.ZonedDateTime;
@@ -20,6 +21,10 @@ import java.util.Date;
  * @date 2019/3/7
  */
 public interface DahuaLibrary extends Library {
+    /**
+     * 默认编码
+     */
+    Charset DEFAULT_CHARSET = Charset.forName("GBK");
     /**
      * 通用字符串长度4
      */
@@ -283,66 +288,70 @@ public interface DahuaLibrary extends Library {
     /**
      * 登陆网络环境设置
      */
-    @Structure.FieldOrder({"bReserved", "byNetType", "byPlaybackBufSize", "byReserved1", "nConnectBufSize",
-            "nConnectTime", "nConnectTryNum", "nGetConnInfoTime", "nGetDevInfoTime", "nPicBufSize", "nSearchRecordTime",
-            "nWaittime", "nsubConnectSpaceTime", "nsubDisconnetTime"})
+    @Structure.FieldOrder({"nWaittime", "nConnectTime", "nConnectTryNum", "nSubConnectSpaceTime", "nGetDevInfoTime",
+            "nConnectBufSize", "nGetConnInfoTime", "nSearchRecordTime", "nsubDisconnetTime", "byNetType",
+            "byPlaybackBufSize", "bDetectDisconnTime", "bKeepLifeInterval", "nPicBufSize", "bReserved"})
     class NET_PARAM extends Structure {
         /**
-         * 保留字段
+         * 等待超时时间(毫秒为单位),为0默认5000ms
          */
-        public byte[] bReserved = new byte[4];
+        public int nWaittime;
         /**
-         * 网络类型,0-LAN, 1-WAN
+         * 连接超时时间(毫秒为单位),为0默认1500ms
          */
-        public byte byNetType;
+        public int nConnectTime;
         /**
-         * 回放数据接收缓冲大小(M为单位),为0默认为4M
+         * 连接尝试次数,为0默认1次
          */
-        public byte byPlaybackBufSize;
+        public int nConnectTryNum;
         /**
-         * 保留字段
+         * 子连接之间的等待时间(毫秒为单位),为0默认10ms
+         */
+        public int nSubConnectSpaceTime;
+        /**
+         * 获取设备信息超时时间,为0默认1000ms
          */
-        public byte[] byReserved1 = new byte[2];
+        public int nGetDevInfoTime;
         /**
          * 每个连接接收数据缓冲大小(字节为单位),为0默认250*1024
          */
         public int nConnectBufSize;
         /**
-         * 连接超时时间(毫秒为单位),为0默认1500ms
+         * 获取子连接信息超时时间(毫秒为单位),为0默认1000ms
          */
-        public int nConnectTime;
+        public int nGetConnInfoTime;
         /**
-         * 连接尝试次数,为0默认1次
+         * 按时间查询录像文件的超时时间(毫秒为单位),为0默认为3000ms
          */
-        public int nConnectTryNum;
+        public int nSearchRecordTime;
         /**
-         * 获取子连接信息超时时间(毫秒为单位),为0默认1000ms
+         * 检测子链接断线等待时间(毫秒为单位),为0默认为60000ms
          */
-        public int nGetConnInfoTime;
+        public int nsubDisconnetTime;
         /**
-         * 获取设备信息超时时间,为0默认1000ms
+         * 网络类型,0-LAN, 1-WAN
          */
-        public int nGetDevInfoTime;
+        public byte byNetType;
         /**
-         * 实时图片接收缓冲大小(字节为单位),为0默认为2*1024*1024
+         * 回放数据接收缓冲大小(M为单位),为0默认为4M
          */
-        public int nPicBufSize;
+        public byte byPlaybackBufSize;
         /**
-         * 按时间查询录像文件的超时时间(毫秒为单位),为0默认为3000ms
+         * 心跳检测断线时间(单位为秒),为0默认为60s,最小时间为2s
          */
-        public int nSearchRecordTime;
+        public byte bDetectDisconnTime;
         /**
-         * 等待超时时间(毫秒为单位),为0默认5000ms
+         * 心跳包发送间隔(单位为秒),为0默认为10s,最小间隔为2s
          */
-        public int nWaittime;
+        public byte bKeepLifeInterval;
         /**
-         * 子连接之间的等待时间(毫秒为单位),为0默认10ms
+         * 实时图片接收缓冲大小(字节为单位),为0默认为2*1024*1024
          */
-        public int nsubConnectSpaceTime;
+        public int nPicBufSize;
         /**
-         * 检测子链接断线等待时间(毫秒为单位),为0默认为60000ms
+         * 保留字段
          */
-        public int nsubDisconnetTime;
+        public byte[] bReserved = new byte[4];
     }
 
     /**
@@ -704,25 +713,13 @@ public interface DahuaLibrary extends Library {
     /**
      * 设备信息
      */
-    @Structure.FieldOrder({"Reserved", "bReserved", "byLeftLogTimes", "byLimitLoginTime", "nAlarmInPortNum",
-            "nAlarmOutPortNum", "nChanNum", "nDVRType", "nDiskNum", "nLockLeftTime", "sSerialNumber"})
+    @Structure.FieldOrder({"sSerialNumber", "nAlarmInPortNum", "nAlarmOutPortNum", "nDiskNum", "nDVRType",
+            "nChanNum", "byLimitLoginTime", "byLeftLogTimes", "bReserved", "nLockLeftTime", "Reserved"})
     class NET_DEVICEINFO_Ex extends Structure {
         /**
-         * 保留
-         */
-        public byte[] Reserved = new byte[24];
-        /**
-         * 保留字节
-         */
-        public byte[] bReserved = new byte[2];
-        /**
-         * 当登陆失败原因为密码错误时,通过此参数通知用户,剩余登陆次数,为0时表示此参数无效
-         */
-        public byte byLeftLogTimes;
-        /**
-         * 在线超时时间,为0表示不限制登陆,非0表示限制的分钟数
+         * 序列号
          */
-        public byte byLimitLoginTime;
+        public byte[] sSerialNumber = new byte[DH_SERIALNO_LEN];
         /**
          * DVR报警输入个数
          */
@@ -732,9 +729,9 @@ public interface DahuaLibrary extends Library {
          */
         public int nAlarmOutPortNum;
         /**
-         * DVR通道个数
+         * DVR硬盘个数
          */
-        public int nChanNum;
+        public int nDiskNum;
         /**
          * DVR类型
          *
@@ -742,17 +739,46 @@ public interface DahuaLibrary extends Library {
          */
         public int nDVRType;
         /**
-         * DVR硬盘个数
+         * DVR通道个数
          */
-        public int nDiskNum;
+        public int nChanNum;
+        /**
+         * 在线超时时间,为0表示不限制登陆,非0表示限制的分钟数
+         */
+        public byte byLimitLoginTime;
+        /**
+         * 当登陆失败原因为密码错误时,通过此参数通知用户,剩余登陆次数,为0时表示此参数无效
+         */
+        public byte byLeftLogTimes;
+        /**
+         * 保留字节
+         */
+        public byte[] bReserved = new byte[2];
         /**
          * 当登陆失败,用户解锁剩余时间(秒数), -1表示设备未设置该参数
          */
         public int nLockLeftTime;
         /**
-         * 序列号
+         * 保留
          */
-        public byte[] sSerialNumber = new byte[DH_SERIALNO_LEN];
+        public byte[] Reserved = new byte[24];
+
+        @Override
+        public String toString() {
+            return "NET_DEVICEINFO_Ex{" +
+                    "sSerialNumber=" + new String(sSerialNumber) +
+                    ", nAlarmInPortNum=" + nAlarmInPortNum +
+                    ", nAlarmOutPortNum=" + nAlarmOutPortNum +
+                    ", nDiskNum=" + nDiskNum +
+                    ", nDVRType=" + nDVRType +
+                    ", nChanNum=" + nChanNum +
+                    ", byLimitLoginTime=" + (byLimitLoginTime & 0xff) +
+                    ", byLeftLogTimes=" + (byLeftLogTimes & 0xff) +
+                    ", bReserved=" + new String(bReserved) +
+                    ", nLockLeftTime=" + nLockLeftTime +
+                    ", Reserved=" + Arrays.toString(Reserved) +
+                    '}';
+        }
     }
 
     /**
@@ -1464,8 +1490,8 @@ public interface DahuaLibrary extends Library {
                     ", emAttendanceState=" + emAttendanceState +
                     ", szClassNumber=" + new String(szClassNumber) +
                     ", szPhoneNumber=" + new String(szPhoneNumber) +
-                    ", szCardName=" + new String(szCardName) +
-                    ", uSimilarity=" + uSimilarity +
+                    ", szCardName=" + new String(szCardName, DEFAULT_CHARSET) +
+                    ", uSimilarity=" + (uSimilarity & 0x0ffffffff) +
                     '}';
         }
     }
@@ -1530,11 +1556,11 @@ public interface DahuaLibrary extends Library {
         /**
          * 图片宽度, 单位:像素
          */
-        public int wWidth;
+        public short wWidth;
         /**
          * 图片高度, 单位:像素
          */
-        public int wHeight;
+        public short wHeight;
         /**
          * 文件路径
          */

+ 0 - 2
applications/device/device-server/src/main/java/com/usoftchina/smartschool/device/controller/IcCardController.java

@@ -30,6 +30,4 @@ public class IcCardController {
         String result = icCardService.consumePush(accTransDetailList, school);
         return Result.success(result);
     }
-
-
 }

+ 2 - 0
applications/device/device-server/src/main/java/com/usoftchina/smartschool/device/po/AccessControlRecord.java

@@ -48,4 +48,6 @@ public class AccessControlRecord implements Serializable{
     private Integer record_type;
 
     private Date record_date;
+
+    private String file_id;           //图片path
 }

+ 71 - 23
applications/device/device-server/src/main/java/com/usoftchina/smartschool/device/po/ImageFile.java

@@ -1,6 +1,8 @@
 package com.usoftchina.smartschool.device.po;
 
 import org.springframework.lang.Nullable;
+import org.springframework.util.Assert;
+import org.springframework.util.FileCopyUtils;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.io.*;
@@ -9,55 +11,101 @@ import java.io.*;
  * @author: guq
  * @create: 2019-03-08 16:42
  **/
-public class ImageFile implements MultipartFile{
+public class ImageFile implements MultipartFile {
 
-    private final byte[] imgContent;
-    private final String header;
+    private final String name;
 
-    public ImageFile(byte[] imgContent, String header) {
-        this.imgContent = imgContent;
-        this.header = header.split(";")[0];
+    private String originalFilename;
+
+    @Nullable
+    private String contentType;
+
+    private final byte[] content;
+
+
+    /**
+     * Create a new MockMultipartFile with the given content.
+     * @param name the name of the file
+     * @param content the content of the file
+     */
+    public ImageFile(String name, @Nullable byte[] content) {
+        this(name, "", null, content);
+    }
+
+    /**
+     * Create a new MockMultipartFile with the given content.
+     * @param name the name of the file
+     * @param contentStream the content of the file as stream
+     * @throws IOException if reading from the stream failed
+     */
+    public ImageFile(String name, InputStream contentStream) throws IOException {
+        this(name, "", null, FileCopyUtils.copyToByteArray(contentStream));
+    }
+
+    /**
+     * Create a new MockMultipartFile with the given content.
+     * @param name the name of the file
+     * @param originalFilename the original filename (as on the client's machine)
+     * @param contentType the content type (if known)
+     * @param content the content of the file
+     */
+    public ImageFile(
+            String name, @Nullable String originalFilename, @Nullable String contentType, @Nullable byte[] content) {
+
+        Assert.hasLength(name, "Name must not be null");
+        this.name = name;
+        this.originalFilename = (originalFilename != null ? originalFilename : "");
+        this.contentType = contentType;
+        this.content = (content != null ? content : new byte[0]);
+    }
+
+    /**
+     * Create a new MockMultipartFile with the given content.
+     * @param name the name of the file
+     * @param originalFilename the original filename (as on the client's machine)
+     * @param contentType the content type (if known)
+     * @param contentStream the content of the file as stream
+     * @throws IOException if reading from the stream failed
+     */
+    public ImageFile(
+            String name, @Nullable String originalFilename, @Nullable String contentType, InputStream contentStream)
+            throws IOException {
+
+        this(name, originalFilename, contentType, FileCopyUtils.copyToByteArray(contentStream));
     }
 
-    @Override
+
     public String getName() {
-        return System.currentTimeMillis() + Math.random() + "." + header.split("/")[1];
+        return this.name;
     }
 
-    @Nullable
-    @Override
     public String getOriginalFilename() {
-        return System.currentTimeMillis() + (int)Math.random() * 10000 + "." + header.split("/")[1];
+        return this.originalFilename;
     }
 
     @Nullable
-    @Override
     public String getContentType() {
-        return header.split(":")[1];
+        return this.contentType;
     }
 
-    @Override
     public boolean isEmpty() {
-        return imgContent == null || imgContent.length == 0;
+        return (this.content.length == 0);
     }
 
-    @Override
     public long getSize() {
-        return imgContent.length;
+        return this.content.length;
     }
 
-    @Override
     public byte[] getBytes() throws IOException {
-        return imgContent;
+        return this.content;
     }
 
-    @Override
     public InputStream getInputStream() throws IOException {
-        return new ByteArrayInputStream(imgContent);
+        return new ByteArrayInputStream(this.content);
     }
 
-    @Override
     public void transferTo(File dest) throws IOException, IllegalStateException {
-        new FileOutputStream(dest).write(imgContent);
+        FileCopyUtils.copy(this.content, dest);
     }
+
 }

+ 10 - 8
applications/device/device-server/src/main/java/com/usoftchina/smartschool/device/service/impl/AccessControlServiceImpl.java

@@ -5,11 +5,11 @@ import com.usoftchina.smartschool.device.dto.AccessControlInfo;
 import com.usoftchina.smartschool.device.mapper.AccessControlRecordMapper;
 import com.usoftchina.smartschool.device.mapper.StudentInfoMapper;
 import com.usoftchina.smartschool.device.po.AccessControlRecord;
-import com.usoftchina.smartschool.device.po.ImageFile;
 import com.usoftchina.smartschool.device.po.StudentInfo;
 import com.usoftchina.smartschool.device.service.AccessControlService;
 import com.usoftchina.smartschool.file.api.FileApi;
 import com.usoftchina.smartschool.file.dto.FileInfoDTO;
+import com.usoftchina.smartschool.file.dto.ImageFile;
 import com.usoftchina.smartschool.utils.DateUtils;
 import com.usoftchina.smartschool.utils.StringUtils;
 import com.usoftchina.smartschool.wechat.api.WechatApi;
@@ -18,6 +18,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.MediaType;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -50,7 +51,7 @@ public class AccessControlServiceImpl implements AccessControlService{
 
     @Override
     public void onAccessControlEvent(AccessControlInfo info) {
-        Long fileId = null;
+        String filePath = null;
         String cardNo = info.getCardNo();
         if (StringUtils.isEmpty(cardNo)) {
             return;
@@ -68,11 +69,11 @@ public class AccessControlServiceImpl implements AccessControlService{
          */
         byte[] imageData = info.getImageData();
         if (null != imageData && imageData.length > 0) {
-            MultipartFile file = new ImageFile(imageData, information.get(0).getStuName());
+            ImageFile file = new ImageFile(information.get(0).getStuName(), imageData);
             Result<FileInfoDTO> fileInfo = null;
             try {
-                fileInfo = fileApi.upload(0L, file);
-                fileId = fileInfo.getData().getId();
+                fileInfo = fileApi.imageUpload(file);
+                filePath = fileInfo.getData().getFullPath();
             }catch (Exception ex) {
                 logger.error(ex.getMessage());
             }
@@ -94,7 +95,8 @@ public class AccessControlServiceImpl implements AccessControlService{
         record.setRecord_type(type);
         record.setStu_id(studentInfo.getStuId());
         record.setStu_number(studentInfo.getStuNumber());
-        record.setRecord_name(studentInfo.getStuName() + (type == 1 ? "进人" : "出去"));
+        record.setRecord_name(studentInfo.getStuName());
+        record.setFile_id(filePath);
         accessControlRecordMapper.insertRecordSelective(record);
         /**
          * 3、推送消息到消息服务器(微信服务监听此消息发送微信消息)
@@ -104,10 +106,10 @@ public class AccessControlServiceImpl implements AccessControlService{
         msg.setSecret(studentInfo.getSecret());
         msg.setTouser(studentInfo.getOpenId());
         msg.setTemplateId(accessControlTemplateId);
-        msg.setTitle("出入校提醒");
+        msg.setTitle((type == 1 ? "入" : "出") + "校提醒");
         msg.setKeyword1(studentInfo.getStuName());
         msg.setKeyword2(DateUtils.format());
-        msg.setRemark("您好! 你的孩子: " + studentInfo.getStuName() + (type == 1 ? " 进人" : " 出去") + "学校");
+        msg.setRemark("您好! 你的孩子: " + studentInfo.getStuName() + (type == 1 ? " 进入" : " 离开") + "学校");
         wechatApi.sendMsg(msg);
     }
 

+ 6 - 0
applications/device/device-server/src/main/resources/mapper/AccessControlRecordMapper.xml

@@ -52,6 +52,9 @@
             <if test="record_date != null" >
                 record_date,
             </if>
+            <if test="file_id != null" >
+                file_id,
+            </if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides="," >
             <if test="record_name != null" >
@@ -103,6 +106,9 @@
             <if test="record_date != null" >
                 #{record_date,jdbcType=TIMESTAMP},
             </if>
+            <if test="file_id != null" >
+              #{file_id, jdbcType=VARCHAR},
+            </if>
         </trim>
     </insert>
 

+ 25 - 2
applications/device/device-server/src/test/java/com/usoftchina/smartschool/device/test/TestService.java

@@ -1,7 +1,12 @@
 package com.usoftchina.smartschool.device.test;
 
-import com.fasterxml.jackson.annotation.JsonProperty;
+import com.alibaba.fastjson.JSON;
+import com.usoftchina.smartschool.base.Result;
+import com.usoftchina.smartschool.device.DeviceApplication;
 import com.usoftchina.smartschool.device.dto.AccessControlInfo;
+import com.usoftchina.smartschool.file.api.FileApi;
+import com.usoftchina.smartschool.file.dto.FileInfoDTO;
+import com.usoftchina.smartschool.file.dto.ImageFile;
 import com.usoftchina.smartschool.utils.DateUtils;
 import com.usoftchina.smartschool.wechat.api.WechatApi;
 import com.usoftchina.smartschool.wechat.dto.MessageInfoDTO;
@@ -11,18 +16,22 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
 
+import java.io.*;
+
 /**
  * @author: guq
  * @create: 2019-03-12 09:48
  **/
 @RunWith(SpringRunner.class)
-@SpringBootTest
+@SpringBootTest(classes = DeviceApplication.class)
 public class TestService {
 
   /*  @Autowired
     AccessService accessService;*/
     @Autowired
     WechatApi wechatApi;
+    @Autowired
+    private FileApi fileApi;
 
     @Test
     public void testa_accessservice() {
@@ -46,4 +55,18 @@ public class TestService {
         msg.setRemark("您好! 你的孩子: ");
         wechatApi.sendMsg(msg);
     }
+
+    @Test
+    public void testC() throws IOException {
+        InputStream in = new FileInputStream(new File("C:\\Users\\Administrator\\Desktop\\cw.jpg"));
+        int len = 0;
+        byte[] bytes = new byte[1024 * 1024];
+        while ((len = in.read(bytes)) != -1) {
+            in.read(bytes);
+        }
+        in.close();
+        Result<FileInfoDTO> result = fileApi.imageUpload(new ImageFile("测试", bytes));
+        System.out.println(JSON.toJSONString(result));
+    }
+
 }

+ 31 - 0
applications/school/school-dto/src/main/java/com/usoftchina/smartschool/school/enums/NoticeTemplate.java

@@ -0,0 +1,31 @@
+package com.usoftchina.smartschool.school.enums;
+
+public enum NoticeTemplate {
+
+    INOUT_NOTICE("inout", "出入校提醒"),
+    SCHOOL_NOTICE("school", "学校通知"),
+    HOMEWORK_NOTICE("homework", "作业通知"),
+    ASK4LEAVE_NOTICE("ask4leave", "学生请假申请"),
+    LEAVECONFIRM_NOTICE("leaveConfirm", "学生请假确认"),
+    SCORE_NOTICE("score", "成绩通知"),
+    UNAUDIT_NOTICE("unAudit", "待审批通知"),
+    MEETING_NOTICE("meeting", "会议提醒"),
+    MONEY_NOTICE("money", "资金异动提醒");
+
+    private String code;
+
+    private String title;
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    NoticeTemplate(String code, String title) {
+        this.code = code;
+        this.title = title;
+    }
+}

+ 45 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/basic/controller/SchoolTemplateController.java

@@ -0,0 +1,45 @@
+package com.usoftchina.smartschool.school.basic.controller;
+
+import com.github.pagehelper.PageInfo;
+import com.usoftchina.smartschool.base.Result;
+import com.usoftchina.smartschool.page.PageDefault;
+import com.usoftchina.smartschool.page.PageRequest;
+import com.usoftchina.smartschool.school.basic.service.SchoolTemplateService;
+import com.usoftchina.smartschool.school.dto.DocBaseDTO;
+import com.usoftchina.smartschool.school.dto.ListReqDTO;
+import com.usoftchina.smartschool.school.po.SchoolTemplate;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * 学校微信推送模板
+ * @author: guq
+ * @create: 2019-03-14 11:51
+ **/
+@RestController
+@RequestMapping("/template")
+public class SchoolTemplateController {
+
+
+    @Autowired
+    private SchoolTemplateService schoolTemplateService;
+
+    @GetMapping("/list")
+    public Result getList(@PageDefault PageRequest page, ListReqDTO listReqDTO) {
+        PageInfo<SchoolTemplate> data = schoolTemplateService.getListData(page, listReqDTO);
+        return Result.success(data);
+    }
+
+    @GetMapping("/read/{id}")
+    public Result getFormData(@PathVariable("id") Long id) {
+        SchoolTemplate data = schoolTemplateService.getFormData(id);
+        return Result.success(data);
+    }
+
+    @PostMapping("/save")
+    public Result saveFormData(@RequestBody SchoolTemplate data) {
+        DocBaseDTO baseDTO = schoolTemplateService.saveFormData(data);
+        return Result.success(baseDTO);
+    }
+
+}

+ 15 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/basic/service/SchoolTemplateService.java

@@ -0,0 +1,15 @@
+package com.usoftchina.smartschool.school.basic.service;
+
+import com.github.pagehelper.PageInfo;
+import com.usoftchina.smartschool.page.PageRequest;
+import com.usoftchina.smartschool.school.dto.DocBaseDTO;
+import com.usoftchina.smartschool.school.dto.ListReqDTO;
+import com.usoftchina.smartschool.school.po.SchoolTemplate;
+
+public interface SchoolTemplateService {
+    PageInfo<SchoolTemplate> getListData(PageRequest page, ListReqDTO listReqDTO);
+
+    SchoolTemplate getFormData(Long id);
+
+    DocBaseDTO saveFormData(SchoolTemplate data);
+}

+ 1 - 1
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/basic/service/impl/ClassServiceImpl.java

@@ -86,7 +86,7 @@ public class ClassServiceImpl implements ClassService{
         for (SysTeacherClazz detail : teachers) {
             detail.setClazz_id(clazz.getClazz_id());
             Integer count = 0;
-            count = sysClazzMapper.teacherClazz(detail.getSubject_name(),detail.getTeacher_id());
+            count = sysClazzMapper.teacherClazz(detail.getSubject_name(),clazz.getClazz_id());
             if(count > 0){
                 throw new BizException(BizExceptionCode.REPEAT_SUBJECTS);
             }

+ 15 - 17
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/basic/service/impl/CurriculumServiceImpl.java

@@ -243,7 +243,7 @@ public class CurriculumServiceImpl implements CurriculumService {
                     DataImportDetail singleDataImportDetail = dataImportMapper.selectMainBycode(key, id, schoolId);
                     CurriculumDTO curriculumDTO = JSON.parseObject(singleDataImportDetail.getDd_maindata(), CurriculumDTO.class);
                     //更新数据,将中文转换成ID
-                    curriculumDTO.setStatus("1");
+                    curriculumDTO.setStatus("0");
                     curriculumDTO.setCreateTime(new Date());
                     curriculumDTO.setClazzId(String.valueOf(clazzId));
                     curriculumDTO.setSchoolId(schoolId);
@@ -252,27 +252,25 @@ public class CurriculumServiceImpl implements CurriculumService {
                     //插入主表数据
                     curriculumMapper.insertSelective(curriculumDTO);
                     Long mainId = curriculumDTO.getId();
+                    int detno = 1;
+                    List<CurriculumDetailDTO> curriculumDetailDTOList = new ArrayList<>();
                     for (DataImportDetail dataImportDetail : dataImportDetailList) {
-                        List<CurriculumDetailDTO> curriculumDetailDTOList = JsonUtils.fromJsonArray(dataImportDetail.getDd_detaildata(), CurriculumDetailDTO.class);
+                        CurriculumDetailDTO curriculumDetailDTO = JsonUtils.fromJsonString(dataImportDetail.getDd_detaildata(), CurriculumDetailDTO.class);
                         //插入明细表数据
                         //1. 替换课程名称为ID
                         List<SubjectDO> subjectDOList = curriculumMapper.selectSubject(schoolId);
-                        Iterator<CurriculumDetailDTO> detailIterator = curriculumDetailDTOList.iterator();
-                        int detno = 1;
-                        while (detailIterator.hasNext()){
-                            CurriculumDetailDTO curriculumDetailDTO = detailIterator.next();
-                            curriculumDetailDTO.setmId(mainId);
-                            curriculumDetailDTO.setStatus(1);
-                            curriculumDetailDTO.setSchoolId(schoolId);
-                            curriculumDetailDTO.setClazzId(clazzId);
-                            curriculumDetailDTO.setLessons(detno++);
-                            List<String> subNameList = subjectDOList.stream().map(SubjectDO::getSubjectName).collect(Collectors.toList());
-                            checkExists(curriculumDetailDTO, subNameList);
-                            subjectDOList.forEach(subjectDO -> { convertToId(curriculumDetailDTO, subjectDO); });
-                        }
-                        //2. 插入
-                        curriculumMapper.insertDetailSelective(curriculumDetailDTOList);
+                        curriculumDetailDTO.setmId(mainId);
+                        curriculumDetailDTO.setStatus(0);
+                        curriculumDetailDTO.setSchoolId(schoolId);
+                        curriculumDetailDTO.setClazzId(clazzId);
+                        curriculumDetailDTO.setLessons(detno++);
+                        List<String> subNameList = subjectDOList.stream().map(SubjectDO::getSubjectName).collect(Collectors.toList());
+                        checkExists(curriculumDetailDTO, subNameList);
+                        subjectDOList.forEach(subjectDO -> { convertToId(curriculumDetailDTO, subjectDO); });
+                        curriculumDetailDTOList.add(curriculumDetailDTO);
                     }
+                    //2. 插入
+                    curriculumMapper.insertDetailSelective(curriculumDetailDTOList);
                 }
             }
         }

+ 1 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/basic/service/impl/GradeServiceImpl.java

@@ -121,6 +121,7 @@ public class GradeServiceImpl implements GradeService{
                     sysGrade.setGrade_status(1);
                     sysGradeMapper.insertSelective(sysGrade);
                     grade_id = sysGrade.getGrade_id();
+                    grade = sysGrade;
                     //年纪存在、需要更新
                 } else if (update){
                     grade.setSchool_id(schoolId);

+ 73 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/basic/service/impl/SchoolTemplateServiceImpl.java

@@ -0,0 +1,73 @@
+package com.usoftchina.smartschool.school.basic.service.impl;
+
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import com.usoftchina.smartschool.context.BaseContextHolder;
+import com.usoftchina.smartschool.exception.BizException;
+import com.usoftchina.smartschool.page.PageRequest;
+import com.usoftchina.smartschool.school.basic.service.SchoolTemplateService;
+import com.usoftchina.smartschool.school.dto.DocBaseDTO;
+import com.usoftchina.smartschool.school.dto.ListReqDTO;
+import com.usoftchina.smartschool.school.exception.BizExceptionCode;
+import com.usoftchina.smartschool.school.mapper.SchoolTemplateMapper;
+import com.usoftchina.smartschool.school.po.SchoolTemplate;
+import com.usoftchina.smartschool.school.po.SysSchool;
+import com.usoftchina.smartschool.school.po.SysStudent;
+import com.usoftchina.smartschool.utils.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Calendar;
+import java.util.List;
+
+/**
+ * @author: guq
+ * @create: 2019-03-14 13:56
+ **/
+@Service
+public class SchoolTemplateServiceImpl implements SchoolTemplateService {
+
+
+    @Autowired
+    private SchoolTemplateMapper schoolTemplateMapper;
+
+    @Override
+    public PageInfo<SchoolTemplate> getListData(PageRequest page, ListReqDTO listReqDTO) {
+        PageHelper.startPage(page.getNumber(), page.getSize());
+        Long schoolId = BaseContextHolder.getSchoolId();
+        //condition语句
+        String condition = listReqDTO.getFinalCondition();
+        if(condition == null){
+            condition = "1=1";
+        }
+        List<SchoolTemplate> data = schoolTemplateMapper.selectByConditon(condition, schoolId);
+        PageInfo<SchoolTemplate> list = new PageInfo<>(data);
+        return list;
+    }
+
+    @Override
+    public SchoolTemplate getFormData(Long id) {
+        if (null == id || "0".equals(id)) {
+            throw new BizException(BizExceptionCode.USELESS_DATA);
+        }
+        SchoolTemplate data = schoolTemplateMapper.selectByPrimaryKey(id);
+        return data;
+    }
+
+    @Override
+    public DocBaseDTO saveFormData(SchoolTemplate formdata) {
+        if (StringUtils.isEmpty(formdata)){
+            throw new BizException(BizExceptionCode.EMPTY_DATA);
+        }
+        Long school_id = BaseContextHolder.getSchoolId();
+        formdata.setSt_schoolid(school_id);
+        //新增
+        if (StringUtils.isEmpty(formdata.getSt_id()) || "0".equals(formdata.getSt_id().toString())) {
+            schoolTemplateMapper.insertSelective(formdata);
+        } else {
+            //更新
+            schoolTemplateMapper.updateByPrimaryKeySelective(formdata);
+        }
+        return new DocBaseDTO(formdata.getSt_id());
+    }
+}

+ 3 - 1
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/basic/service/impl/StudentServiceImpl.java

@@ -200,7 +200,9 @@ public class StudentServiceImpl implements StudentService{
                         json.put("stu_sex", 1);
                     }else if ("女".equals(json.get("stu_sex"))) {
                         json.put("stu_sex", 2);
-                    };
+                    }else if(!"男".equals(json.get("stu_sex")) && !"女".equals(json.get("stu_sex"))){
+                        throw new BizException(BizExceptionCode.ILLEGAL_Gender);
+                    }
                 }
 
                 SysStudent stu = JSONObject.parseObject(json.toJSONString(), SysStudent.class);

+ 48 - 7
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/business/service/impl/HomeWorkServiceImpl.java

@@ -9,19 +9,20 @@ import com.usoftchina.smartschool.school.business.service.HomeWorkService;
 import com.usoftchina.smartschool.school.dto.BatchDealBaseDTO;
 import com.usoftchina.smartschool.school.dto.DocBaseDTO;
 import com.usoftchina.smartschool.school.dto.ListReqDTO;
+import com.usoftchina.smartschool.school.enums.NoticeTemplate;
 import com.usoftchina.smartschool.school.exception.BizExceptionCode;
-import com.usoftchina.smartschool.school.mapper.HomeWorkMapper;
-import com.usoftchina.smartschool.school.mapper.SysClazzMapper;
-import com.usoftchina.smartschool.school.mapper.SysGradeMapper;
-import com.usoftchina.smartschool.school.mapper.SysStudentMapper;
-import com.usoftchina.smartschool.school.po.HomeWork;
-import com.usoftchina.smartschool.school.po.SysClazz;
-import com.usoftchina.smartschool.school.po.SysGrade;
+import com.usoftchina.smartschool.school.mapper.*;
+import com.usoftchina.smartschool.school.po.*;
+import com.usoftchina.smartschool.utils.DateUtils;
+import com.usoftchina.smartschool.wechat.api.WechatApi;
+import com.usoftchina.smartschool.wechat.dto.MessageInfoDTO;
+import com.usoftchina.smartschool.wechat.dto.TransferDTO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.util.ObjectUtils;
 import org.springframework.util.StringUtils;
 
+import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.List;
 
@@ -40,6 +41,14 @@ public class HomeWorkServiceImpl implements HomeWorkService{
     private SysClazzMapper sysClazzMapper;
     @Autowired
     private SysStudentMapper sysStudentMapper;
+    @Autowired
+    private SysTeacherMapper sysTeacherMapper;
+    @Autowired
+    private SysSchoolMapper sysSchoolMapper;
+    @Autowired
+    private WechatApi wechatApi;
+    @Autowired
+    private SchoolTemplateMapper schoolTemplateMapper;
 
     @Override
     public DocBaseDTO save(HomeWork formdata) {
@@ -57,6 +66,8 @@ public class HomeWorkServiceImpl implements HomeWorkService{
             //获取时间
             Calendar calendar= Calendar.getInstance();
             formdata.setCreate_date(calendar.getTime());
+            Long Creator = sysTeacherMapper.taskCreator(formdata.getTask_creator());
+            formdata.setTask_creator(Creator);
             homeWorkMapper.insertSelective(formdata);
         } else {
             //更新
@@ -119,6 +130,36 @@ public class HomeWorkServiceImpl implements HomeWorkService{
         if(StringUtils.isEmpty(id) || "0".equals(id)) {
             return;
         }
+        HomeWork data = homeWorkMapper.selectByPrimaryKey(id);
+        //学校信息
+        SysSchool school = sysSchoolMapper.selectByPrimaryKey(BaseContextHolder.getSchoolId());
+        //微信推送
+        List<HomeworkNoticer> noticers = homeWorkMapper.selectHomeworkNoticer(id);
+        //模板信息
+        SchoolTemplate template = schoolTemplateMapper.selectByCode(NoticeTemplate.HOMEWORK_NOTICE.getCode(), school.getSchool_id());
+        if (StringUtils.isEmpty(template.getSt_templateid())) {
+            throw new BizException(BizExceptionCode.NULL_TEMPLATE);
+        }
+        //消息内容
+        List<MessageInfoDTO> msgs = new ArrayList<>();
+        noticers.forEach(noticer -> {
+            MessageInfoDTO msg = new MessageInfoDTO();
+            msg.setTitle("作业提醒");
+            msg.setKeyword1(noticer.getSubject());
+            msg.setKeyword2(DateUtils.format());
+            msg.setKeyword3(data.getTask_context());
+            msg.setTouser(noticer.getOpenid());
+            msg.setAppId(school.getSchool_appid());
+            msg.setSecret(school.getSchool_secret());
+            msg.setTemplateId(template.getSt_templateid());
+            msgs.add(msg);
+        });
+        if (msgs.size() > 0) {
+            TransferDTO transferDTO = new TransferDTO();
+            transferDTO.setData(msgs);
+            //调用推送接口
+            wechatApi.largeMessages(transferDTO);
+        }
         homeWorkMapper.updateByPublish(id);
     }
 

+ 50 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/business/service/impl/NoticeServiceImpl.java

@@ -9,13 +9,24 @@ import com.usoftchina.smartschool.school.business.service.NoticeService;
 import com.usoftchina.smartschool.school.dto.BatchDealBaseDTO;
 import com.usoftchina.smartschool.school.dto.DocBaseDTO;
 import com.usoftchina.smartschool.school.dto.ListReqDTO;
+import com.usoftchina.smartschool.school.enums.NoticeTemplate;
 import com.usoftchina.smartschool.school.exception.BizExceptionCode;
 import com.usoftchina.smartschool.school.mapper.NoticeMapper;
+import com.usoftchina.smartschool.school.mapper.SchoolTemplateMapper;
+import com.usoftchina.smartschool.school.mapper.SysSchoolMapper;
 import com.usoftchina.smartschool.school.po.Notify;
+import com.usoftchina.smartschool.school.po.SchoolNoticer;
+import com.usoftchina.smartschool.school.po.SchoolTemplate;
+import com.usoftchina.smartschool.school.po.SysSchool;
+import com.usoftchina.smartschool.utils.DateUtils;
 import com.usoftchina.smartschool.utils.StringUtils;
+import com.usoftchina.smartschool.wechat.api.WechatApi;
+import com.usoftchina.smartschool.wechat.dto.MessageInfoDTO;
+import com.usoftchina.smartschool.wechat.dto.TransferDTO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.List;
 
@@ -29,6 +40,16 @@ public class NoticeServiceImpl implements NoticeService{
     @Autowired
     private NoticeMapper noticeMapper;
 
+    @Autowired
+    private SysSchoolMapper sysSchoolMapper;
+
+    @Autowired
+    private WechatApi wechatApi;
+
+    @Autowired
+    private SchoolTemplateMapper schoolTemplateMapper;
+
+
     @Override
     public DocBaseDTO save(Notify formdata) {
         if (StringUtils.isEmpty(formdata)){
@@ -105,6 +126,35 @@ public class NoticeServiceImpl implements NoticeService{
         if(StringUtils.isEmpty(id) || "0".equals(id)) {
             return;
         }
+        Notify data = noticeMapper.selectByPrimaryKey(id);
+        SysSchool school = sysSchoolMapper.selectByPrimaryKey(BaseContextHolder.getSchoolId());
+        List<MessageInfoDTO> msgs = new ArrayList<>();
+        List<SchoolNoticer> noticers = noticeMapper.selectNoticer(BaseContextHolder.getSchoolId());
+        //模板信息
+        SchoolTemplate template = schoolTemplateMapper.selectByCode(NoticeTemplate.HOMEWORK_NOTICE.getCode(), school.getSchool_id());
+        if (org.springframework.util.StringUtils.isEmpty(template.getSt_templateid())) {
+            throw new BizException(BizExceptionCode.NULL_TEMPLATE);
+        }
+        noticers.forEach(noticer -> {
+            MessageInfoDTO msg = new MessageInfoDTO();
+            msg.setTitle(data.getNotify_title());
+            msg.setKeyword1(school.getSchool_name());
+            msg.setKeyword2("校办公室");
+            msg.setKeyword3(DateUtils.format());
+            msg.setKeyword4(data.getNotify_details());
+            msg.setRemark(data.getNotify_remarks());
+            msg.setTemplateId(template.getSt_templateid());
+            msg.setTouser(noticer.getOpenid());
+            msg.setAppId(school.getSchool_appid());
+            msg.setSecret(school.getSchool_secret());
+            msgs.add(msg);
+        });
+        if (msgs.size() > 0) {
+            TransferDTO transferDTO = new TransferDTO();
+            transferDTO.setData(msgs);
+            //调用推送接口
+            wechatApi.largeMessages(transferDTO);
+        }
         noticeMapper.updateByPublish(id);
     }
 }

+ 50 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/business/service/impl/ScoreServiceImpl.java

@@ -10,10 +10,15 @@ import com.usoftchina.smartschool.school.business.service.ScoreService;
 import com.usoftchina.smartschool.school.dto.BatchDealBaseDTO;
 import com.usoftchina.smartschool.school.dto.DocBaseDTO;
 import com.usoftchina.smartschool.school.dto.ListReqDTO;
+import com.usoftchina.smartschool.school.enums.NoticeTemplate;
 import com.usoftchina.smartschool.school.exception.BizExceptionCode;
 import com.usoftchina.smartschool.school.mapper.*;
 import com.usoftchina.smartschool.school.po.*;
 import com.usoftchina.smartschool.utils.CollectionUtils;
+import com.usoftchina.smartschool.utils.DateUtils;
+import com.usoftchina.smartschool.wechat.api.WechatApi;
+import com.usoftchina.smartschool.wechat.dto.MessageInfoDTO;
+import com.usoftchina.smartschool.wechat.dto.TransferDTO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -47,6 +52,18 @@ public class ScoreServiceImpl implements ScoreService{
     @Autowired
     private SysStudentMapper sysStudentMapper;
 
+    @Autowired
+    private SysSchoolMapper sysSchoolMapper;
+
+    @Autowired
+    private WechatApi wechatApi;
+
+    @Autowired
+    private SchoolTemplateMapper schoolTemplateMapper;
+
+    @Autowired
+    private SubjectMapper subjectMapper;
+
     @Override
     public PageInfo<ScoreImportList> getListData(PageRequest page, ListReqDTO listReqDTO) {
         PageHelper.startPage(page.getNumber(), page.getSize());
@@ -202,6 +219,8 @@ public class ScoreServiceImpl implements ScoreService{
         List<StuScore> appScores = new ArrayList<StuScore>();
         StuScore appScore = null;
         Long school_id = BaseContextHolder.getSchoolId();
+        //学校信息
+        SysSchool school = sysSchoolMapper.selectByPrimaryKey(BaseContextHolder.getSchoolId());
         ScoreImport main = scoreMapper.selectByPrimaryKey(id);
         List<ScoreImportdetail> details = scoreMapper.selectDetail(id);
         for (ScoreImportdetail detail : details) {
@@ -221,6 +240,37 @@ public class ScoreServiceImpl implements ScoreService{
             appScores.add(appScore);
         }
         scoreMapper.batchInsert(appScores);
+
+        //微信推送
+        List<ScoreNoticer> noticers = scoreMapper.selectWechatMsg(id);
+        //消息内容
+        List<MessageInfoDTO> msgs = new ArrayList<>();
+        //模板信息
+        SchoolTemplate template = schoolTemplateMapper.selectByCode(NoticeTemplate.HOMEWORK_NOTICE.getCode(), school.getSchool_id());
+        if (StringUtils.isEmpty(template.getSt_templateid())) {
+            throw new BizException(BizExceptionCode.NULL_TEMPLATE);
+        }
+        noticers.forEach(noticer -> {
+            MessageInfoDTO msg = new MessageInfoDTO();
+            msg.setTitle("您好,请查收您小孩" + noticer.getStuName() + "的成绩单");
+            msg.setKeyword1(noticer.getStuName());
+            msg.setKeyword2(noticer.getStuNo());
+            msg.setKeyword3(main.getSi_examtitle());
+            msg.setKeyword4(DateUtils.format(main.getSi_examdate(),"yyyy-MM-dd"));
+            msg.setKeyword5(school.getSchool_name());
+            msg.setRemark("成绩为:" + noticer.getScore());
+            msg.setTemplateId(template.getSt_templateid());
+            msg.setTouser(noticer.getOpenid());
+            msg.setAppId(school.getSchool_appid());
+            msg.setSecret(school.getSchool_secret());
+            msgs.add(msg);
+        });
+        if (msgs.size() > 0) {
+            TransferDTO transferDTO = new TransferDTO();
+            transferDTO.setData(msgs);
+            //调用推送接口
+            wechatApi.largeMessages(transferDTO);
+        }
         //更新已转标志
         scoreMapper.updateTurnPublish(id);
     }

+ 3 - 2
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/exception/BizExceptionCode.java

@@ -17,7 +17,7 @@ public enum BizExceptionCode implements BaseExceptionCode {
     NONCLAZZ(500005, "班级名称不存在"),
     REPEAT_TEACHER_NUMBER(500006, "教师工号重复"),
     NONSTU(500006, "学生不存在"),
-    EXISTS_TEACHER(500004,"存在教师,无法删除"),
+    EXISTS_TEACHER(500004,"存在任课教师,无法删除"),
     EXISTS_CURRICULUM(500005,"存在课表,无法删除"),
     EXISTS_TEACHER_CLASS(500006,"存在任课班级,无法删除"),
     TEACHERS_EXISTS_CLASS(500006,"%s存在任课班级,无法删除"),
@@ -25,7 +25,7 @@ public enum BizExceptionCode implements BaseExceptionCode {
     EXISTS_SCORE_PUBLISH(5000013, "存在已发布成绩,禁止删除"),
     EXISTS_CLASS(500011, "存在班级,无法删除"),
     HOMEWORK_RELEASE(500012, "存在发布作业,无法删除"),
-    REPEAT_SUBJECTS(600001, "同个老师不可班带相同的课"),
+    REPEAT_SUBJECTS(600001, "课程已存在"),
     REPEAT_GRADE_NAME(600001, "年级名称重复"),
     REPEAT_CLASS_NAME(600002, "班级名称重复"),
     REPEAT_STUDENT_NUMBER(600003, "学生学号不可重复"),
@@ -34,6 +34,7 @@ public enum BizExceptionCode implements BaseExceptionCode {
     NOTICE_RELEASE_STATUS(600007, "学校通知已生效,无法删除"),
     ILLEGAL_Gender(600007, "无效性别"),
     ILLEGAL_MARRIAGE(600008, "婚姻状态无效,应为:已婚或未婚"),
+    NULL_TEMPLATE(600010, "模板ID为空"),
     NOT_EXISTS_SUBJECT(60005, "科目<u>%s</u>不存在");
 
 

+ 3 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/mapper/HomeWorkMapper.java

@@ -1,6 +1,7 @@
 package com.usoftchina.smartschool.school.mapper;
 
 import com.usoftchina.smartschool.school.po.HomeWork;
+import com.usoftchina.smartschool.school.po.HomeworkNoticer;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -34,4 +35,6 @@ public interface HomeWorkMapper {
     int taskStatus(@Param("task_status") String task_status,@Param("task_id") Long task_id);
 
     Integer homeWorkRelease(Long id);
+
+    List<HomeworkNoticer> selectHomeworkNoticer(Long id);
 }

+ 4 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/mapper/NoticeMapper.java

@@ -1,6 +1,7 @@
 package com.usoftchina.smartschool.school.mapper;
 
 import com.usoftchina.smartschool.school.po.Notify;
+import com.usoftchina.smartschool.school.po.SchoolNoticer;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -28,4 +29,7 @@ public interface NoticeMapper {
     int updateByPublish(Long notify_id);
 
     int noticeStatus(Long id);
+
+    List<SchoolNoticer> selectNoticer(Long schoolId);
+
 }

+ 25 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/mapper/SchoolTemplateMapper.java

@@ -0,0 +1,25 @@
+package com.usoftchina.smartschool.school.mapper;
+
+import com.usoftchina.smartschool.school.po.SchoolTemplate;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+@Mapper
+public interface SchoolTemplateMapper {
+    int deleteByPrimaryKey(Long st_id);
+
+    int insert(SchoolTemplate record);
+
+    int insertSelective(SchoolTemplate record);
+
+    SchoolTemplate selectByPrimaryKey(Long st_id);
+
+    int updateByPrimaryKeySelective(SchoolTemplate record);
+
+    int updateByPrimaryKey(SchoolTemplate record);
+
+    List<SchoolTemplate> selectByConditon(@Param("con") String condition, @Param("school_id") Long schoolId);
+
+    SchoolTemplate selectByCode(@Param("code") String code, @Param("school_id") Long school_id);
+}

+ 2 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/mapper/ScoreMapper.java

@@ -41,4 +41,6 @@ public interface ScoreMapper {
     Integer checkPublish(Long id);
 
     Long selectCountBySubjectAndCode(@Param("si_id") Long si_id, @Param("stu_number") String stu_number, @Param("subject")String subject);
+
+    List<ScoreNoticer> selectWechatMsg(Long id);
 }

+ 1 - 1
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/mapper/SysClazzMapper.java

@@ -35,5 +35,5 @@ public interface SysClazzMapper {
 
     int countClazz(@Param("clazz_name") String clazz_name, @Param("clazz_grade") String clazz_grade, @Param("school_id") Long school_id);
 
-    Integer teacherClazz(@Param("subject_name") String subject_name,@Param("teacher_id") Long teacher_id );
+    Integer teacherClazz(@Param("subject_name") String subject_name, @Param("clazz_id") Long clazz_id);
 }

+ 2 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/mapper/SysTeacherMapper.java

@@ -42,4 +42,6 @@ public interface SysTeacherMapper {
     int checkTeacher(@Param("teacher_id") Long teacher_id);
 
     void deleteDetail(@Param("teacher_clazz_id") Long teacher_clazz_id);
+
+    Long taskCreator(@Param("user_id") Long user_id);
 }

+ 4 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/po/HomeWork.java

@@ -46,4 +46,8 @@ public class HomeWork implements Serializable{
 
     private String accessory;   //附件
 
+    private Long task_classid;
+
+    private Long task_gradeid;
+
 }

+ 18 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/po/HomeworkNoticer.java

@@ -0,0 +1,18 @@
+package com.usoftchina.smartschool.school.po;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author: guq
+ * @create: 2019-03-13 19:11
+ **/
+@Data
+public class HomeworkNoticer implements Serializable{
+
+    private String openid;
+
+    private String subject;
+
+}

+ 58 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/po/InOutRecordDO.java

@@ -0,0 +1,58 @@
+package com.usoftchina.smartschool.school.po;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 出入校记录详细
+ * @Author chenwei
+ * @Date 2019-03-13
+ */
+public class InOutRecordDO implements Serializable {
+
+    private String recordName;
+    private Date recordDate;
+    private String recordType;
+    private String recordFile;
+    private String weekDays;
+
+    public String getWeekDays() {
+        return weekDays;
+    }
+
+    public void setWeekDays(String weekDays) {
+        this.weekDays = weekDays;
+    }
+
+    public String getRecordFile() {
+        return recordFile;
+    }
+
+    public void setRecordFile(String recordFile) {
+        this.recordFile = recordFile;
+    }
+
+    public String getRecordName() {
+        return recordName;
+    }
+
+    public void setRecordName(String recordName) {
+        this.recordName = recordName;
+    }
+
+    public Date getRecordDate() {
+        return recordDate;
+    }
+
+    public void setRecordDate(Date recordDate) {
+        this.recordDate = recordDate;
+    }
+
+    public String getRecordType() {
+        return recordType;
+    }
+
+    public void setRecordType(String recordType) {
+        this.recordType = recordType;
+    }
+}

+ 22 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/po/SchoolNoticer.java

@@ -0,0 +1,22 @@
+package com.usoftchina.smartschool.school.po;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author: guq
+ * @create: 2019-03-13 16:07
+ **/
+@Data
+public class SchoolNoticer implements Serializable{
+    /**
+     * 通知人
+     */
+    private String noticer;
+
+    /**
+     * 微信ID
+     */
+    private String openid;
+}

+ 55 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/po/SchoolTemplate.java

@@ -0,0 +1,55 @@
+package com.usoftchina.smartschool.school.po;
+
+import java.io.Serializable;
+
+public class SchoolTemplate implements Serializable{
+    private Long st_id;
+
+    private String st_code;
+
+    private String st_name;
+
+    private String st_templateid;
+
+    private Long st_schoolid;
+
+    public Long getSt_id() {
+        return st_id;
+    }
+
+    public void setSt_id(Long st_id) {
+        this.st_id = st_id;
+    }
+
+    public String getSt_code() {
+        return st_code;
+    }
+
+    public void setSt_code(String st_code) {
+        this.st_code = st_code == null ? null : st_code.trim();
+    }
+
+    public String getSt_name() {
+        return st_name;
+    }
+
+    public void setSt_name(String st_name) {
+        this.st_name = st_name == null ? null : st_name.trim();
+    }
+
+    public String getSt_templateid() {
+        return st_templateid;
+    }
+
+    public void setSt_templateid(String st_templateid) {
+        this.st_templateid = st_templateid == null ? null : st_templateid.trim();
+    }
+
+    public Long getSt_schoolid() {
+        return st_schoolid;
+    }
+
+    public void setSt_schoolid(Long st_schoolid) {
+        this.st_schoolid = st_schoolid;
+    }
+}

+ 24 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/po/ScoreNoticer.java

@@ -0,0 +1,24 @@
+package com.usoftchina.smartschool.school.po;
+
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author: guq
+ * @create: 2019-03-13 17:32
+ **/
+@Data
+public class ScoreNoticer implements Serializable{
+
+    private String stuName;
+
+    private String stuNo;
+
+    private String subject;
+
+    private Float  score;
+
+    private String openid;
+}

+ 11 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/po/SysStudent.java

@@ -49,6 +49,17 @@ public class SysStudent {
 
     private String stu_political;
 
+    private String stu_cardNo;
+
+
+    public String getStu_cardNo() {
+        return stu_cardNo;
+    }
+
+    public void setStu_cardNo(String stu_cardNo) {
+        this.stu_cardNo = stu_cardNo;
+    }
+
     public String getStu_classnickname() {
         return stu_classnickname;
     }

+ 14 - 4
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/wxschool/basic/controller/WxOutInRecordController.java

@@ -5,10 +5,7 @@ import com.usoftchina.smartschool.school.wxschool.basic.service.WxOutInRecordSer
 import com.usoftchina.smartschool.school.wxschool.utils.ResultBean;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
 import java.util.Map;
@@ -44,6 +41,19 @@ public class WxOutInRecordController {
 		}
 	}
 
+    /**
+     * 获取出入校记录
+     * @return
+     */
+    @GetMapping("/inout/detail/{id}")
+    public ResultBean getInOutDetail(@PathVariable("id") Long id){
+        try {
+            return new ResultBean(outInRecordService.getInOutRecordById(id));
+        }catch (Exception e){
+            return new ResultBean(e);
+        }
+    }
+
 	/**
 	 * 通知详情
 	 * @param recordId

+ 8 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/wxschool/basic/service/WxOutInRecordService.java

@@ -1,5 +1,6 @@
 package com.usoftchina.smartschool.school.wxschool.basic.service;
 
+import com.usoftchina.smartschool.school.po.InOutRecordDO;
 import com.usoftchina.smartschool.school.po.OutInRecordDO;
 import org.apache.ibatis.annotations.Param;
 
@@ -23,6 +24,13 @@ public interface WxOutInRecordService {
 	 */
 	public Map<String, Object> selectRecordOutgoingListByStuId(@Param("stuId") Long stuId, @Param("pageIndex") Integer pageIndex, @Param("pageSize") Integer pageSize);
 
+    /**
+     * 获取出入校详情
+     * @param id
+     * @return
+     */
+    InOutRecordDO getInOutRecordById(Long id);
+
 	/**
 	 * 通知详情
 	 * @param recordId

+ 17 - 3
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/wxschool/basic/service/impl/WxOutInRecordServiceImpl.java

@@ -1,6 +1,7 @@
 package com.usoftchina.smartschool.school.wxschool.basic.service.impl;
 
 import com.usoftchina.smartschool.school.po.ClazzDO;
+import com.usoftchina.smartschool.school.po.InOutRecordDO;
 import com.usoftchina.smartschool.school.po.OutInRecordDO;
 import com.usoftchina.smartschool.school.po.StudentDO;
 import com.usoftchina.smartschool.school.wxschool.basic.service.WxOutInRecordService;
@@ -13,9 +14,7 @@ import com.usoftchina.smartschool.school.wxschool.utils.ObjectUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 
 @Service
@@ -83,5 +82,20 @@ public class WxOutInRecordServiceImpl implements WxOutInRecordService {
 			throw new Exception("暂无数据");
 		}
 	}
+
+	@Override
+    public InOutRecordDO getInOutRecordById(Long id){
+        InOutRecordDO inOutRecordDO = outInRecordMapper.selectRecordById(id);
+        Date date = inOutRecordDO.getRecordDate();
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        String[] weekDays = { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
+        int weekday = calendar.get(Calendar.DAY_OF_WEEK) - 1;
+        if (weekday < 0) {
+            weekday = 0;
+        }
+        inOutRecordDO.setWeekDays(weekDays[weekday]);
+	    return inOutRecordDO;
+    }
 	
 }

+ 3 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/wxschool/mapper/WxOutInRecordMapper.java

@@ -1,5 +1,6 @@
 package com.usoftchina.smartschool.school.wxschool.mapper;
 
+import com.usoftchina.smartschool.school.po.InOutRecordDO;
 import com.usoftchina.smartschool.school.po.OutInRecordDO;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -18,4 +19,6 @@ public interface WxOutInRecordMapper {
 	OutInRecordDO get(Long recordId);
 
 	List<OutInRecordDO> selectOutInRecordDOListByStuId(@Param("stuId") Long stuId, @Param("pageStart") Integer pageStart, @Param("pageSize") Integer pageSize);
+
+    InOutRecordDO selectRecordById(Long id);
 }

+ 29 - 1
applications/school/school-server/src/main/resources/mapper/HomeWorkMapper.xml

@@ -19,6 +19,8 @@
         <result column="publish_date" property="publish_date" jdbcType="TIMESTAMP"/>
         <result column="creator" property="creator" jdbcType="VARCHAR"/>
         <result column="accessory" property="accessory" jdbcType="VARCHAR"/>
+        <result property="task_classid" column="task_classid" jdbcType="BIGINT"/>
+        <result property="task_gradeid" column="task_gradeid" jdbcType="BIGINT"/>
     </resultMap>
 
     <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">
@@ -96,6 +98,12 @@
             <if test="accessory != null">
                 accessory,
             </if>
+            <if test="task_classid != null">
+                task_classid,
+            </if>
+            <if test="task_gradeid != null">
+                task_gradeid,
+            </if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="subject_id != null">
@@ -143,6 +151,12 @@
             <if test="accessory != null">
                 #{accessory,jdbcType=VARCHAR},
             </if>
+            <if test="task_classid != null">
+                #{task_classid,jdbcType=BIGINT},
+            </if>
+            <if test="task_gradeid != null">
+                #{task_gradeid,jdbcType=BIGINT},
+            </if>
         </trim>
     </insert>
     <update id="updateByPrimaryKeySelective" parameterType="com.usoftchina.smartschool.school.po.HomeWork">
@@ -193,6 +207,12 @@
             <if test="accessory != null">
                 accessory = #{accessory,jdbcType=VARCHAR},
             </if>
+            <if test="task_classid != null">
+                task_classid = #{task_classid,jdbcType=BIGINT},
+            </if>
+            <if test="task_gradeid != null">
+                task_gradeid = #{task_gradeid,jdbcType=BIGINT},
+            </if>
         </set>
         where task_id = #{task_id,jdbcType=BIGINT}
     </update>
@@ -260,7 +280,15 @@
     </select>
 
     <select id="homeWorkRelease" parameterType="long" resultType="integer">
-      select count(1) from sys_clazz left join task_notify on sys_clazz.clazz_name=task_notify.classz_name
+      select count(1) from sys_clazz left join task_notify on sys_clazz.clazz_nickname= concat (task_notify.grade_name,task_notify.classz_name)
       where sys_clazz.clazz_id = #{id} and task_notify.task_status=1
   </select>
+
+    <select id="selectHomeworkNoticer" parameterType="long" resultType="com.usoftchina.smartschool.school.po.HomeworkNoticer">
+        select openid,subject_name subject from task_notify left join sys_student on task_classid = clazz_id
+        left join sys_parents_stu on  sys_parents_stu.stu_id =
+        sys_student.stu_id left join sys_parents on sys_parents.parent_id = sys_parents_stu.parent_id
+        left join subject on task_notify.subject_id = subject.subject_id
+        where  ifnull(sys_parents.openid,'') != '' and  parents_status=1 and task_id = #{id}
+    </select>
 </mapper>

+ 5 - 0
applications/school/school-server/src/main/resources/mapper/NotifyMapper.xml

@@ -225,4 +225,9 @@
     <select id="noticeStatus" parameterType="long" resultType="int">
     select count(1) from notify where notify_status=1 and notify_id=#{id}
   </select>
+
+    <select id="selectNoticer" parameterType="long" resultType="com.usoftchina.smartschool.school.po.SchoolNoticer">
+        select openid,parents_name noticer from sys_parents where school_id=#{schoolId} and ifnull(openid,'') != '' and parents_status=1 union
+				select openid,teacher_name noticer from sys_teacher where school_id=#{schoolId} and ifnull(openid,'') != '' and teacher_status=1;
+    </select>
 </mapper>

+ 104 - 0
applications/school/school-server/src/main/resources/mapper/SchoolTemplateMapper.xml

@@ -0,0 +1,104 @@
+<?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="com.usoftchina.smartschool.school.mapper.SchoolTemplateMapper" >
+  <resultMap id="BaseResultMap" type="com.usoftchina.smartschool.school.po.SchoolTemplate" >
+    <id column="st_id" property="st_id" jdbcType="BIGINT" />
+    <result column="st_code" property="st_code" jdbcType="VARCHAR" />
+    <result column="st_name" property="st_name" jdbcType="VARCHAR" />
+    <result column="st_templateid" property="st_templateid" jdbcType="VARCHAR" />
+    <result column="st_schoolid" property="st_schoolid" jdbcType="BIGINT" />
+  </resultMap>
+  <sql id="Base_Column_List" >
+    st_id, st_code, st_name, st_templateid, st_schoolid
+  </sql>
+  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
+    select 
+    <include refid="Base_Column_List" />
+    from school_template
+    where st_id = #{st_id,jdbcType=BIGINT}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
+    delete from school_template
+    where st_id = #{st_id,jdbcType=BIGINT}
+  </delete>
+  <insert id="insert" parameterType="com.usoftchina.smartschool.school.po.SchoolTemplate" >
+    insert into school_template (st_id, st_code, st_name, 
+      st_templateid, st_schoolid)
+    values (#{st_id,jdbcType=BIGINT}, #{st_code,jdbcType=VARCHAR}, #{st_name,jdbcType=VARCHAR}, 
+      #{st_templateid,jdbcType=VARCHAR}, #{st_schoolid,jdbcType=BIGINT})
+  </insert>
+  <insert id="insertSelective" parameterType="com.usoftchina.smartschool.school.po.SchoolTemplate" >
+    insert into school_template
+    <trim prefix="(" suffix=")" suffixOverrides="," >
+      <if test="st_code != null" >
+        st_code,
+      </if>
+      <if test="st_name != null" >
+        st_name,
+      </if>
+      <if test="st_templateid != null" >
+        st_templateid,
+      </if>
+      <if test="st_schoolid != null" >
+        st_schoolid,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides="," >
+      <if test="st_code != null" >
+        #{st_code,jdbcType=VARCHAR},
+      </if>
+      <if test="st_name != null" >
+        #{st_name,jdbcType=VARCHAR},
+      </if>
+      <if test="st_templateid != null" >
+        #{st_templateid,jdbcType=VARCHAR},
+      </if>
+      <if test="st_schoolid != null" >
+        #{st_schoolid,jdbcType=BIGINT},
+      </if>
+    </trim>
+  </insert>
+  <update id="updateByPrimaryKeySelective" parameterType="com.usoftchina.smartschool.school.po.SchoolTemplate" >
+    update school_template
+    <set >
+      <if test="st_code != null" >
+        st_code = #{st_code,jdbcType=VARCHAR},
+      </if>
+      <if test="st_name != null" >
+        st_name = #{st_name,jdbcType=VARCHAR},
+      </if>
+      <if test="st_templateid != null" >
+        st_templateid = #{st_templateid,jdbcType=VARCHAR},
+      </if>
+      <if test="st_schoolid != null" >
+        st_schoolid = #{st_schoolid,jdbcType=BIGINT},
+      </if>
+    </set>
+    where st_id = #{st_id,jdbcType=BIGINT}
+  </update>
+  <update id="updateByPrimaryKey" parameterType="com.usoftchina.smartschool.school.po.SchoolTemplate" >
+    update school_template
+    set st_code = #{st_code,jdbcType=VARCHAR},
+      st_name = #{st_name,jdbcType=VARCHAR},
+      st_templateid = #{st_templateid,jdbcType=VARCHAR},
+      st_schoolid = #{st_schoolid,jdbcType=BIGINT}
+    where st_id = #{st_id,jdbcType=BIGINT}
+  </update>
+
+  <select id="selectByConditon" resultMap="BaseResultMap">
+    select * from school_template <where>
+    <if test="con != null">
+      ${con}
+    </if>
+    <if test="school_id != null">
+      and  st_schoolid = #{school_id}
+    </if>
+  </where>
+    order by st_id DESC
+  </select>
+
+  <select id="selectByCode" resultMap="BaseResultMap">
+    select * from school_template where st_code=#{code} and st_schoolid=#{school_id}
+  </select>
+
+</mapper>

+ 6 - 0
applications/school/school-server/src/main/resources/mapper/ScoreMapper.xml

@@ -426,4 +426,10 @@
     and sd_subject = #{subject, jdbcType=VARCHAR}
   </select>
 
+  <select id="selectWechatMsg" parameterType="long" resultType="com.usoftchina.smartschool.school.po.ScoreNoticer">
+    select sd_stu stuName , sd_stunumber stuNo, sd_subject subject ,sd_score score ,openid from score_importdetail left join sys_parents_stu on sd_stuid = sys_parents_stu.stu_id
+	  left join sys_parents on sys_parents.parent_id = sys_parents_stu.parent_id
+	  where sd_siid=#{id}     and  ifnull(sys_parents.openid,'') != '' and  parents_status=1
+  </select>
+
 </mapper>

+ 3 - 3
applications/school/school-server/src/main/resources/mapper/SysClazzMapper.xml

@@ -254,9 +254,9 @@
       <if test="subject_name != null">
         subject_name=#{subject_name}
       </if>
-        <if test="teacher_id != null">
-            and teacher_id=#{teacher_id}
-        </if>
+      <if test="clazz_id != null">
+        and clazz_id=#{clazz_id}
+      </if>
     </where>
   </select>
 

+ 10 - 0
applications/school/school-server/src/main/resources/mapper/SysStudentMapper.xml

@@ -23,6 +23,7 @@
     <result column="stu_native" property="stu_native" jdbcType="VARCHAR" />
     <result column="stu_nation" property="stu_nation" jdbcType="VARCHAR" />
     <result column="stu_political" property="stu_political" jdbcType="VARCHAR" />
+    <result property="stu_cardNo" column="stu_cardNo" jdbcType="VARCHAR"/>
   </resultMap>
 
   <sql id="Base_Column_List" >
@@ -120,6 +121,9 @@
       <if test="stu_political != null" >
         stu_political,
       </if>
+      <if test="stu_cardNo != null" >
+        stu_cardNo,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides="," >
       <if test="stu_number != null" >
@@ -182,6 +186,9 @@
       <if test="stu_political != null" >
         #{stu_political,jdbcType=VARCHAR},
       </if>
+      <if test="stu_cardNo != null" >
+        #{stu_cardNo,jdbcType=VARCHAR},
+      </if>
     </trim>
   </insert>
   <update id="updateByPrimaryKeySelective" parameterType="com.usoftchina.smartschool.school.po.SysStudent" >
@@ -247,6 +254,9 @@
       <if test="stu_political != null" >
         stu_political = #{stu_political,jdbcType=VARCHAR},
       </if>
+      <if test="stu_cardNo != null" >
+        stu_cardNo = #{stu_cardNo,jdbcType=VARCHAR},
+      </if>
     </set>
     where stu_id = #{stu_id,jdbcType=BIGINT}
   </update>

+ 4 - 0
applications/school/school-server/src/main/resources/mapper/SysTeacherMapper.xml

@@ -406,4 +406,8 @@ where sys_teacher_clazz.teacher_id=#{id}
   <delete id="deleteDetail">
     DELETE FROM sys_teacher_clazz where teacher_clazz_id = #{teacher_clazz_id}
   </delete>
+
+  <select id="taskCreator" parameterType="long" resultType="long">
+      select teacher_id from sys_teacher where user_id = #{user_id}
+  </select>
 </mapper>

+ 4 - 0
applications/school/school-server/src/main/resources/mapper/WxOutInRecordMapper.xml

@@ -17,4 +17,8 @@
 		limit #{pageStart},#{pageSize}
 	</select>
 
+  <select id="selectRecordById" resultType="com.usoftchina.smartschool.school.po.InOutRecordDO">
+    SELECT STUDENT.stu_name recordName,RECORD.record_date recordDate, RECORD.record_type recordType,RECORD.file_id recordFile  FROM OUT_IN_RECORD RECORD LEFT JOIN SYS_STUDENT STUDENT ON RECORD.STU_ID = STUDENT.STU_ID  WHERE RECORD.RECORD_ID = #{id}
+  </select>
+
 </mapper>

+ 4 - 0
applications/wechat/wechat-api/src/main/java/com/usoftchina/smartschool/wechat/api/WechatApi.java

@@ -2,6 +2,7 @@ package com.usoftchina.smartschool.wechat.api;
 
 import com.usoftchina.smartschool.base.Result;
 import com.usoftchina.smartschool.wechat.dto.MessageInfoDTO;
+import com.usoftchina.smartschool.wechat.dto.TransferDTO;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -14,4 +15,7 @@ public interface WechatApi {
 
     @PostMapping("/send/Messages")
     Result sendOutMessages(@RequestBody String data);
+
+    @PostMapping("/send/largeMessages")
+    public Result largeMessages(@RequestBody TransferDTO data);
 }

+ 21 - 0
applications/wechat/wechat-dto/src/main/java/com/usoftchina/smartschool/wechat/dto/TransferDTO.java

@@ -0,0 +1,21 @@
+package com.usoftchina.smartschool.wechat.dto;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @author: guq
+ * @create: 2019-03-13 15:09
+ **/
+public class TransferDTO implements Serializable{
+
+    private List<MessageInfoDTO> data;
+
+    public List<MessageInfoDTO> getData() {
+        return data;
+    }
+
+    public void setData(List<MessageInfoDTO> data) {
+        this.data = data;
+    }
+}

+ 0 - 4
applications/wechat/wechat-server/pom.xml

@@ -91,10 +91,6 @@
             <groupId>com.usoftchina.smartschool</groupId>
             <artifactId>wechat-dto</artifactId>
         </dependency>
-        <dependency>
-            <groupId>com.usoftchina.smartschool</groupId>
-            <artifactId>wechat-auth</artifactId>
-        </dependency>
     </dependencies>
 
     <build>

+ 0 - 2
applications/wechat/wechat-server/src/main/java/com/usoftchina/smartschool/wechat/WechatApplication.java

@@ -1,7 +1,6 @@
 package com.usoftchina.smartschool.wechat;
 
 
-import com.usoftchina.smartschool.wechat.auth.EnableOpenApiAuthClient;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
@@ -16,7 +15,6 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
 @EnableTransactionManagement
 @EnableEurekaClient
 @EnableFeignClients({"com.usoftchina.smartschool.wechat","com.usoftchina.smartschool.school"})
-@EnableOpenApiAuthClient
 public class WechatApplication {
     public static void main(String[] args) {
         SpringApplication.run(WechatApplication.class, args);

+ 18 - 5
applications/wechat/wechat-server/src/main/java/com/usoftchina/smartschool/wechat/controller/TransfersController.java

@@ -3,8 +3,8 @@ package com.usoftchina.smartschool.wechat.controller;
 
 import com.usoftchina.smartschool.base.Result;
 import com.usoftchina.smartschool.utils.JsonUtils;
-import com.usoftchina.smartschool.wechat.auth.annotation.IgnoreOpenApiAuth;
 import com.usoftchina.smartschool.wechat.dto.MessageInfoDTO;
+import com.usoftchina.smartschool.wechat.dto.TransferDTO;
 import com.usoftchina.smartschool.wechat.service.SendService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.util.StringUtils;
@@ -33,7 +33,6 @@ public class TransfersController {
     * @Date: 2019/3/7
     */
     @PostMapping("/Message")
-    @IgnoreOpenApiAuth
     public Result sendMsg(@RequestBody MessageInfoDTO info) {
         if (StringUtils.isEmpty(info)) {
             return Result.error("信息为空");
@@ -43,22 +42,36 @@ public class TransfersController {
     }
 
     /**
-    * @Description 对外提供大量数据使用
+    * @Description
     * @Param: [data]
     * @return: com.usoftchina.smartschool.base.Result
     * @Author: guq
     * @Date: 2019/3/7
     */
     @PostMapping("/Messages")
-    @IgnoreOpenApiAuth
     public Result sendOutMessages(@RequestBody String data) throws UnsupportedEncodingException {
         if (StringUtils.isEmpty(data)) {
             return Result.error("信息为空");
         }
-        data = URLDecoder.decode(data, "UTF-8");
         List<MessageInfoDTO> messages = JsonUtils.fromJsonArray(data, MessageInfoDTO.class);
         sendService.sendOutMessages(messages);
         return Result.success();
     }
 
+    /**
+     * @Description
+     * @Param: [data]
+     * @return: com.usoftchina.smartschool.base.Result
+     * @Author: guq
+     * @Date: 2019/3/7
+     */
+    @PostMapping("/largeMessages")
+    public Result largeMessages(@RequestBody TransferDTO data) {
+        if (StringUtils.isEmpty(data) || StringUtils.isEmpty(data.getData())) {
+            return Result.error("信息为空");
+        }
+        sendService.sendOutMessages(data.getData());
+        return Result.success();
+    }
+
 }

+ 0 - 2
applications/wechat/wechat-server/src/main/java/com/usoftchina/smartschool/wechat/controller/WxPushController.java

@@ -1,6 +1,5 @@
 package com.usoftchina.smartschool.wechat.controller;
 
-import com.usoftchina.smartschool.wechat.auth.annotation.IgnoreOpenApiAuth;
 import com.usoftchina.smartschool.wechat.dto.MessageInfoDTO;
 import com.usoftchina.smartschool.wechat.service.SendService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -12,7 +11,6 @@ import org.springframework.web.bind.annotation.RestController;
  * @create: 2019-01-27 12:41
  **/
 @RestController
-@IgnoreOpenApiAuth
 public class WxPushController {
 
   /*  @Autowired

+ 9 - 0
applications/wechat/wechat-server/src/main/java/com/usoftchina/smartschool/wechat/po/MessagePackage.java

@@ -32,4 +32,13 @@ public class MessagePackage implements Serializable{
     public void addRetry() {
         this.retry ++;
     }
+
+    @Override
+    public String toString() {
+        return "MessagePackage{" +
+                "packageId='" + packageId + '\'' +
+                ", data=" + data +
+                ", retry=" + retry +
+                '}';
+    }
 }

+ 2 - 3
applications/wechat/wechat-server/src/main/java/com/usoftchina/smartschool/wechat/service/ReceiveService.java

@@ -3,7 +3,6 @@ package com.usoftchina.smartschool.wechat.service;
 import com.rabbitmq.client.Channel;
 
 import com.usoftchina.smartschool.base.Result;
-import com.usoftchina.smartschool.wechat.auth.context.TransfersContextHodler;
 import com.usoftchina.smartschool.wechat.dto.MessageInfoDTO;
 import com.usoftchina.smartschool.wechat.mapper.BrokerMessageLogMapper;
 import com.usoftchina.smartschool.wechat.po.MessageInfo;
@@ -99,7 +98,7 @@ public class ReceiveService {
         //channel.basicNack(deliveryTag,false,true);
     }
 
-    private void getOpenId(MessageInfo msg) {
+   /* private void getOpenId(MessageInfo msg) {
         String openId = msg.getTouser();
         Long school = TransfersContextHodler.getSchoolId();
         if (msg.getUserType() == MessageInfoDTO.UserType.PARENT) {
@@ -108,5 +107,5 @@ public class ReceiveService {
            openId = brokerMessageLogMapper.SelectTeacherOpenId(msg.getTouser(), school);
         }
         msg.setTouser(openId);
-    }
+    }*/
 }

+ 19 - 0
applications/wechat/wechat-server/src/test/java/com/usoftchina/smartschool/wechat/NonSpringTest.java

@@ -0,0 +1,19 @@
+package com.usoftchina.smartschool.wechat;
+
+import com.usoftchina.smartschool.utils.DateUtils;
+import org.junit.Test;
+
+import java.util.Date;
+
+/**
+ * @author: guq
+ * @create: 2019-03-13 14:58
+ **/
+public class NonSpringTest {
+
+    @Test
+    public void testF_test() {
+        String format = DateUtils.format(new Date(), "yyyy-MM-dd");
+        System.out.println(format);
+    }
+}

+ 20 - 0
applications/wechat/wechat-server/src/test/java/com/usoftchina/smartschool/wechat/Test_service.java

@@ -13,6 +13,7 @@ import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
 
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -91,4 +92,23 @@ public class Test_service {
         //sendService.sendOutMessages(msg);
     }
 
+    /*@Test
+    public void testE_bean() {
+        List<MessageInfoDTO> data = new ArrayList<>();
+        MessageInfoDTO msg = new MessageInfoDTO();
+        msg.setKeyword1("1");
+        msg.setKeyword2("2");
+        msg.setTitle("测试");
+        data.add(msg);
+        MessagePackageDTO packageDTO = new MessagePackageDTO(data);
+        MessagePackage mp = BeanMapper.map(packageDTO, MessagePackage.class);
+        System.out.println(mp);
+    }*/
+
+    @Test
+    public void testF_test() {
+        String format = DateUtils.format(new Date(), "yyyy-MM-dd");
+        System.out.println(format);
+    }
+
 }

+ 3 - 0
base-servers/account/account-api/src/main/java/com/usoftchina/smartschool/account/api/AccountApi.java

@@ -24,6 +24,9 @@ public interface AccountApi {
     @GetMapping("/account/getUsername")
     Result<String> getUsername(@RequestParam(value = "schoolId") Long schoolId, @RequestParam(value = "userId") Long userId);
 
+    @GetMapping("/account/getTeacherId")
+    Result<Long> getTeacherId(@RequestParam(value = "schoolId") Long schoolId, @RequestParam(value = "userId") Long userId);
+
     @GetMapping("/account/register")
     Result<Long> register(@RequestBody AccountRegDTO accountRegDTO);
 

+ 9 - 0
base-servers/account/account-dto/src/main/java/com/usoftchina/smartschool/account/dto/AccountDTO.java

@@ -11,6 +11,7 @@ import java.util.List;
 public class AccountDTO implements Serializable {
 
     private Long id;
+    private Long teacher_id;
     private String user_phone;
     private String user_code;
     private String salt;
@@ -18,6 +19,14 @@ public class AccountDTO implements Serializable {
     private Long school_id;
     private String username;
 
+    public Long getTeacher_id() {
+        return teacher_id;
+    }
+
+    public void setTeacher_id(Long teacher_id) {
+        this.teacher_id = teacher_id;
+    }
+
     public String getUsername() {
         return username;
     }

+ 10 - 0
base-servers/account/account-server/src/main/java/com/usoftchina/smartschool/account/controller/AccountController.java

@@ -87,6 +87,16 @@ public class AccountController {
         return Result.success(accountService.getUsername(schoolId, userId));
     }
 
+    /**
+     * 查询教师表,获取教师ID
+     * @param schoolId
+     * @param userId
+     * @return
+     */
+    @GetMapping("/getTeacherId")
+    public Result<Long> getTeacherId(Long schoolId, Long userId){
+        return Result.success(accountService.getTeacherId(schoolId, userId));
+    }
     /**
      * 重置密码
      * @param password

+ 8 - 0
base-servers/account/account-server/src/main/java/com/usoftchina/smartschool/account/mapper/AccountMapper.java

@@ -55,4 +55,12 @@ public interface AccountMapper {
      * @return
      */
     String selectTeacherName(@Param("schoolId") Long schoolId, @Param("userId") Long userId);
+
+    /**
+     * 查找教师ID
+     * @param schoolId
+     * @param userId
+     * @return
+     */
+    Long selectTeacherId(@Param("schoolId") Long schoolId, @Param("userId") Long userId);
 }

+ 8 - 0
base-servers/account/account-server/src/main/java/com/usoftchina/smartschool/account/service/AccountService.java

@@ -63,4 +63,12 @@ public interface AccountService {
      * @return
      */
     String getUsername(Long schoolId, Long userId);
+
+    /**
+     * 获取教师ID
+     * @param schoolId
+     * @param userId
+     * @return
+     */
+    Long getTeacherId(Long schoolId, Long userId);
 }

+ 5 - 0
base-servers/account/account-server/src/main/java/com/usoftchina/smartschool/account/service/impl/AccountServiceImpl.java

@@ -72,4 +72,9 @@ public class AccountServiceImpl implements AccountService {
     public String getUsername(Long schoolId, Long userId){
         return accountMapper.selectTeacherName(schoolId, userId);
     }
+
+    @Override
+    public Long getTeacherId(Long schoolId, Long userId){
+        return accountMapper.selectTeacherId(schoolId, userId);
+    }
 }

+ 1 - 1
base-servers/account/account-server/src/main/resources/config/application-docker-cloud.yml

@@ -1,6 +1,6 @@
 eureka:
   instance:
-    hostname: smartschool-school-server
+    hostname: smartschool-account-server
     prefer-ip-address: false
   client:
     serviceUrl:

+ 4 - 0
base-servers/account/account-server/src/main/resources/mapper/AccountMapper.xml

@@ -53,4 +53,8 @@
   <select id="selectTeacherName" resultType="string">
     select teacher_name from sys_teacher where school_id = #{schoolId} and user_id = #{userId}
   </select>
+
+  <select id="selectTeacherId" resultType="long">
+    select teacher_id from sys_teacher where school_id = #{schoolId} and user_id = #{userId}
+  </select>
 </mapper>

+ 3 - 0
base-servers/auth/auth-server/src/main/java/com/usoftchina/smartschool/auth/controller/AuthController.java

@@ -51,8 +51,10 @@ public class AuthController {
         if (result.isSuccess()){
             AccountDTO accountDTO = result.getData();
             Long school_id = -1L;
+            Long teacherId = -1L;
             try {
                 school_id = accountDTO.getRoleMaps().stream().filter(roleDTO -> "教师".equals(roleDTO.getRole_name())).findFirst().get().getSchool_id();
+                teacherId = accountApi.getTeacherId(school_id, accountDTO.getId()).getData();
                 if (school_id == -1){
                     throw new BizException(ExceptionCode.USER_NOT_EXIST);
                 }
@@ -60,6 +62,7 @@ public class AuthController {
                 throw new BizException(ExceptionCode.USER_NOT_EXIST);
             }
             accountDTO.setSchool_id(school_id);
+            accountDTO.setTeacher_id(teacherId);
             String realName = accountApi.getUsername(school_id, accountDTO.getId()).getData();
             accountDTO.setUsername(realName);
             JwtInfo jwtInfo = new JwtInfo("school", school_id, accountDTO.getId(), StringUtils.isEmpty(realName) ? accountDTO.getUser_phone() : realName, accountDTO.getUser_phone());

+ 1 - 1
base-servers/auth/auth-server/src/main/resources/config/application-docker-cloud.yml

@@ -1,6 +1,6 @@
 eureka:
   instance:
-    hostname: smartschool-school-server
+    hostname: smartschool-auth-server
     prefer-ip-address: false
   client:
     serviceUrl:

+ 18 - 1
base-servers/file/file-api/src/main/java/com/usoftchina/smartschool/file/api/FileApi.java

@@ -4,9 +4,14 @@ import com.usoftchina.smartschool.base.Result;
 import com.usoftchina.smartschool.file.dto.FileInfoDTO;
 import com.usoftchina.smartschool.file.dto.FolderDTO;
 import com.usoftchina.smartschool.file.dto.FolderSaveDTO;
+import com.usoftchina.smartschool.file.dto.ImageFile;
 import feign.codec.Encoder;
 import feign.form.spring.SpringFormEncoder;
+import org.springframework.beans.factory.ObjectFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
 import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.cloud.openfeign.support.SpringEncoder;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.http.MediaType;
@@ -26,9 +31,13 @@ public interface FileApi {
 
     @Configuration
     class MultipartSupportConfig {
+
+        @Autowired
+        private ObjectFactory<HttpMessageConverters> messageConverters;
+
         @Bean
         public Encoder feignFormEncoder() {
-            return new SpringFormEncoder();
+            return new SpringFormEncoder(new SpringEncoder(messageConverters));
         }
     }
 
@@ -79,6 +88,14 @@ public interface FileApi {
     @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
     Result<FileInfoDTO> upload(@RequestParam("folderId") Long folderId, @RequestPart(value = "file") MultipartFile file) throws Exception;
 
+    /**
+     * 上传图片文件
+     * @param file
+     * @return
+     */
+    @PostMapping(value = "/imageUpload")
+    Result<FileInfoDTO> imageUpload(@RequestBody ImageFile file);
+
     /**
      * 文件下载
      *

+ 90 - 0
base-servers/file/file-api/src/main/java/com/usoftchina/smartschool/file/api/util/ByteArrayMultipartFile.java

@@ -0,0 +1,90 @@
+package com.usoftchina.smartschool.file.api.util;
+
+import org.springframework.lang.Nullable;
+import org.springframework.util.Assert;
+import org.springframework.util.FileCopyUtils;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * @author yingp
+ * @date 2019/1/15
+ */
+public class ByteArrayMultipartFile implements MultipartFile {
+    private final String name;
+
+    private String originalFilename;
+
+    @Nullable
+    private String contentType;
+
+    private final byte[] content;
+
+    public ByteArrayMultipartFile(String name, byte[] content) throws IOException {
+        this(name, "", null, content);
+    }
+
+    public ByteArrayMultipartFile(String name, String contentType, byte[] content) throws IOException {
+        this(name, "", contentType, content);
+    }
+
+    public ByteArrayMultipartFile(
+            String name, @Nullable String originalFilename, @Nullable String contentType, @Nullable byte[] content) {
+        Assert.hasLength(name, "Name must not be null");
+        this.name = name;
+        this.originalFilename = (originalFilename != null ? originalFilename : "");
+        this.contentType = contentType;
+        this.content = (content != null ? content : new byte[0]);
+    }
+
+    public ByteArrayMultipartFile(
+            String name, @Nullable String originalFilename, @Nullable String contentType, InputStream contentStream)
+            throws IOException {
+        this(name, originalFilename, contentType, FileCopyUtils.copyToByteArray(contentStream));
+    }
+
+    @Override
+    public String getName() {
+        return this.name;
+    }
+
+    @Override
+    public String getOriginalFilename() {
+        return this.originalFilename;
+    }
+
+    @Override
+    @Nullable
+    public String getContentType() {
+        return this.contentType;
+    }
+
+    @Override
+    public boolean isEmpty() {
+        return this.content.length == 0;
+    }
+
+    @Override
+    public long getSize() {
+        return this.content.length;
+    }
+
+    @Override
+    public byte[] getBytes() throws IOException {
+        return this.content;
+    }
+
+    @Override
+    public InputStream getInputStream() throws IOException {
+        return new ByteArrayInputStream(this.content);
+    }
+
+    @Override
+    public void transferTo(File dest) throws IOException, IllegalStateException {
+        FileCopyUtils.copy(this.content, dest);
+    }
+}

+ 35 - 0
base-servers/file/file-api/src/main/java/com/usoftchina/smartschool/file/api/util/FileUploadUtils.java

@@ -0,0 +1,35 @@
+package com.usoftchina.smartschool.file.api.util;
+
+import com.usoftchina.smartschool.base.Result;
+import com.usoftchina.smartschool.context.SpringContextHolder;
+import com.usoftchina.smartschool.exception.BizException;
+import com.usoftchina.smartschool.file.api.FileApi;
+import com.usoftchina.smartschool.file.dto.FileInfoDTO;
+
+/**
+ * @author yingp
+ * @date 2019/1/15
+ */
+public class FileUploadUtils {
+
+    /**
+     * 文件上传
+     *
+     * @param fileName
+     * @param contentType
+     * @param content
+     * @return
+     * @throws Exception
+     */
+    public static FileInfoDTO upload(String fileName, String contentType, byte[] content) throws Exception{
+        FileApi api = SpringContextHolder.getBean(FileApi.class);
+        Result<FileInfoDTO> result = api.upload(null,
+                new ByteArrayMultipartFile(fileName, contentType, content));
+        if (result.isSuccess()) {
+            return result.getData();
+        } else {
+            throw new BizException(result.getCode(), result.getMessage());
+        }
+    }
+
+}

+ 17 - 4
base-servers/file/file-dto/src/main/java/com/usoftchina/smartschool/file/dto/FileInfoDTO.java

@@ -15,11 +15,17 @@ public class FileInfoDTO extends BaseFileInfo implements Serializable {
     private Long id;
 
     /**
-     * 链接
+     * 存储路径
      */
-    @ApiModelProperty(value = "文件path")
+    @ApiModelProperty(value = "文件存储path")
     private String fullPath;
 
+    /**
+     * 访问链接
+     */
+    @ApiModelProperty(value = "文件访问path")
+    private String accessPath;
+
     /**
      * 类型
      */
@@ -67,6 +73,14 @@ public class FileInfoDTO extends BaseFileInfo implements Serializable {
         this.mime = mime;
     }
 
+    public String getAccessPath() {
+        return accessPath;
+    }
+
+    public void setAccessPath(String accessPath) {
+        this.accessPath = accessPath;
+    }
+
     public String getExt() {
         return ext;
     }
@@ -95,9 +109,8 @@ public class FileInfoDTO extends BaseFileInfo implements Serializable {
     public String toString() {
         return "FileInfoDTO{" +
                 "id=" + id +
-                ", folderId=" + folderId +
-                ", name=" + name +
                 ", fullPath='" + fullPath + '\'' +
+                ", accessPath='" + accessPath + '\'' +
                 ", mime='" + mime + '\'' +
                 ", ext='" + ext + '\'' +
                 ", size=" + size +

+ 37 - 0
base-servers/file/file-dto/src/main/java/com/usoftchina/smartschool/file/dto/ImageFile.java

@@ -0,0 +1,37 @@
+package com.usoftchina.smartschool.file.dto;
+
+/**
+ * @Author chenwei
+ * @Date 2019-03-14
+ */
+public class ImageFile {
+
+    private String name;
+
+    private byte[] content;
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public byte[] getContent() {
+        return content;
+    }
+
+    public void setContent(byte[] content) {
+        this.content = content;
+    }
+
+    public ImageFile() {
+    }
+
+    public ImageFile(String name, byte[] content) {
+
+        this.name = name;
+        this.content = content;
+    }
+}

+ 41 - 0
base-servers/file/file-server-fdfs/pom.xml

@@ -0,0 +1,41 @@
+<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>file</artifactId>
+        <groupId>com.usoftchina.smartschool</groupId>
+        <version>1.0.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>file-server-fdfs</artifactId>
+
+    <dependencies>
+        <dependency>
+            <groupId>com.usoftchina.smartschool</groupId>
+            <artifactId>file-server</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.usoftchina.smartschool</groupId>
+            <artifactId>file-storage-fdfs</artifactId>
+        </dependency>
+        <!-- test -->
+        <dependency>
+            <groupId>com.usoftchina.smartschool</groupId>
+            <artifactId>test-starter</artifactId>
+        </dependency>
+    </dependencies>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>com.spotify</groupId>
+                <artifactId>docker-maven-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+</project>

+ 1 - 1
base-servers/file/file-server/src/main/docker/Dockerfile → base-servers/file/file-server-fdfs/src/main/docker/Dockerfile

@@ -1,6 +1,6 @@
 FROM frolvlad/alpine-oraclejdk8:slim
 VOLUME /tmp
-ADD file-server-1.0.0-SNAPSHOT.jar app.jar
+ADD file-server-fdfs-1.0.0-SNAPSHOT.jar app.jar
 RUN sh -c 'touch /app.jar'
 ENV JAVA_OPTS=""
 ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar" ]

+ 5 - 8
base-servers/file/file-server/src/main/java/com/usoftchina/smartschool/file/FileApplication.java → base-servers/file/file-server-fdfs/src/main/java/com/usoftchina/smartschool/file/fdfs/FdfsFileApplication.java

@@ -1,29 +1,26 @@
-package com.usoftchina.smartschool.file;
+package com.usoftchina.smartschool.file.fdfs;
 
-import com.github.tobato.fastdfs.FdfsClientConfig;
 import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
 import org.springframework.context.annotation.EnableMBeanExport;
-import org.springframework.context.annotation.Import;
 import org.springframework.jmx.support.RegistrationPolicy;
 import org.springframework.transaction.annotation.EnableTransactionManagement;
 import springfox.documentation.swagger2.annotations.EnableSwagger2;
 
 /**
  * @author yingp
- * @date 2018/9/29
+ * @date 2019/3/14
  */
-@SpringBootApplication
+@SpringBootApplication(scanBasePackages = "com.usoftchina.smartschool.file")
 @EnableEurekaClient
 @EnableTransactionManagement
 @MapperScan("com.usoftchina.smartschool.file.mapper")
-@Import(FdfsClientConfig.class)
 @EnableMBeanExport(registration = RegistrationPolicy.IGNORE_EXISTING)
 @EnableSwagger2
-public class FileApplication {
+public class FdfsFileApplication {
     public static void main(String[] args) {
-        SpringApplication.run(FileApplication.class, args);
+        SpringApplication.run(FdfsFileApplication.class, args);
     }
 }

+ 11 - 11
base-servers/file/file-server/src/main/resources/application.yml → base-servers/file/file-server-fdfs/src/main/resources/application.yml

@@ -1,3 +1,13 @@
+fdfs:
+  so-timeout: 1500
+  connect-timeout: 600
+  thumb-image:
+    width: 150
+    height: 150
+  tracker-list:
+    - 10.10.100.200:22122
+file:
+  base-url: http://10.1.81.1:8888/
 spring:
   application:
     name: file-server
@@ -86,14 +96,4 @@ mybatis:
   type-aliases-package: com.usoftchina.smartschool.file.po
   mapper-locations: classpath:mapper/*.xml
 auth:
-  public-key: auth/pub.key
-fdfs:
-  so-timeout: 1500
-  connect-timeout: 600
-  thumb-image:
-    width: 150
-    height: 150
-  tracker-list:
-    - 10.1.81.1:22122
-file:
-  base-url: http://10.1.81.1:8888/
+  public-key: auth/pub.key

+ 1 - 4
base-servers/file/file-server/src/main/resources/config/application-docker-prod.yml → base-servers/file/file-server-fdfs/src/main/resources/config/application-docker-prod.yml

@@ -4,7 +4,4 @@ eureka:
     prefer-ip-address: false
   client:
     serviceUrl:
-      defaultZone: http://${spring.security.user.name}:${spring.security.user.password}@smartschool-eureka-server:9500/eureka/
-fdfs:
-  tracker-list:
-    - 10.10.100.200:22122
+      defaultZone: http://${spring.security.user.name}:${spring.security.user.password}@smartschool-eureka-server:9500/eureka/

+ 0 - 0
base-servers/file/file-server/src/main/resources/config/application-docker.yml → base-servers/file/file-server-fdfs/src/main/resources/config/application-docker.yml


+ 0 - 0
base-servers/file/file-server/src/main/resources/logback-spring.xml → base-servers/file/file-server-fdfs/src/main/resources/logback-spring.xml


+ 41 - 0
base-servers/file/file-server-qcloud/pom.xml

@@ -0,0 +1,41 @@
+<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>file</artifactId>
+        <groupId>com.usoftchina.smartschool</groupId>
+        <version>1.0.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>file-server-qcloud</artifactId>
+
+    <dependencies>
+        <dependency>
+            <groupId>com.usoftchina.smartschool</groupId>
+            <artifactId>file-server</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.usoftchina.smartschool</groupId>
+            <artifactId>file-storage-qcloud</artifactId>
+        </dependency>
+        <!-- test -->
+        <dependency>
+            <groupId>com.usoftchina.smartschool</groupId>
+            <artifactId>test-starter</artifactId>
+        </dependency>
+    </dependencies>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>com.spotify</groupId>
+                <artifactId>docker-maven-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+</project>

+ 6 - 0
base-servers/file/file-server-qcloud/src/main/docker/Dockerfile

@@ -0,0 +1,6 @@
+FROM frolvlad/alpine-oraclejdk8:slim
+VOLUME /tmp
+ADD file-server-qcloud-1.0.0-SNAPSHOT.jar app.jar
+RUN sh -c 'touch /app.jar'
+ENV JAVA_OPTS=""
+ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar" ]

+ 26 - 0
base-servers/file/file-server-qcloud/src/main/java/com/usoftchina/smartschool/file/qcloud/QCloudFileApplication.java

@@ -0,0 +1,26 @@
+package com.usoftchina.smartschool.file.qcloud;
+
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
+import org.springframework.context.annotation.EnableMBeanExport;
+import org.springframework.jmx.support.RegistrationPolicy;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+/**
+ * @author yingp
+ * @date 2019/3/14
+ */
+@SpringBootApplication(scanBasePackages = "com.usoftchina.smartschool.file")
+@EnableEurekaClient
+@EnableTransactionManagement
+@MapperScan("com.usoftchina.smartschool.file.mapper")
+@EnableMBeanExport(registration = RegistrationPolicy.IGNORE_EXISTING)
+@EnableSwagger2
+public class QCloudFileApplication {
+    public static void main(String[] args) {
+        SpringApplication.run(QCloudFileApplication.class, args);
+    }
+}

+ 97 - 0
base-servers/file/file-server-qcloud/src/main/resources/application.yml

@@ -0,0 +1,97 @@
+qcloud:
+  cos:
+    secretId: AKIDngQ1QbKfRHxOcl6QxG5jIxcQ3YelYKUR
+    secretKey: ykGDn9HYAZkOs30oPxNcqgoyWvSnqfGf
+    region: ap-chengdu
+    bucketName: ydy-1258516134
+file:
+  base-url: https://${qcloud.cos.bucketName}.cos.${qcloud.cos.region}.myqcloud.com/
+spring:
+  application:
+    name: file-server
+  security:
+    user:
+      name: admin
+      password: select111***
+  rabbitmq:
+    host: 10.10.100.166
+    port: 5672
+    virtual-host: school
+    username: school
+    password: select123***
+  zipkin:
+    sender:
+      type: rabbit
+    locator:
+      discovery:
+        enabled: true
+  sleuth:
+    sampler:
+      probability: 1.0
+  datasource:
+    driver-class-name: com.mysql.cj.jdbc.Driver
+    url: jdbc:mysql://10.10.100.166:3306/smart_campus?characterEncoding=utf-8&useSSL=false
+    username: root
+    password: select111***
+    hikari:
+      minimum-idle: 5
+      maximum-pool-size: 50
+      idle-timeout: 30000
+      max-lifetime: 1800000
+      connection-timeout: 30000
+  messages:
+    basename: i18n/messages
+  redis:
+    host: 10.10.100.166
+    port: 6379
+  jackson:
+    date-format: yyyy-MM-dd HH:mm:ss
+    time-zone: GMT+8
+  profiles:
+    active: dev
+  servlet:
+    multipart:
+      enabled: true
+      #20971520 ->  20M
+      max-file-size: 20971520
+      max-request-size: 20971520
+eureka:
+  instance:
+    leaseRenewalIntervalInSeconds: 10
+    health-check-url-path: /actuator/health
+    status-page-url-path: /actuator/info
+    prefer-ip-address: true
+    metadata-map:
+      user.name: ${spring.security.user.name}
+      user.password: ${spring.security.user.password}
+  client:
+    registryFetchIntervalSeconds: 5
+    serviceUrl:
+      defaultZone: http://${spring.security.user.name}:${spring.security.user.password}@127.0.0.1:9500/eureka/
+server:
+  port: 9540
+  tomcat:
+    uri-encoding: UTF-8
+management:
+  endpoints:
+    web:
+      exposure:
+        include: "*"
+  endpoint:
+    health:
+      show-details: always
+    shutdown:
+      enabled: true
+    restart:
+      enabled: true
+info:
+  name: '@project.artifactId@'
+  description: '@project.description@'
+  version: '@project.version@'
+  spring-boot-version: '@spring.boot.version@'
+  spring-cloud-version: '@spring.cloud.version@'
+mybatis:
+  type-aliases-package: com.usoftchina.smartschool.file.po
+  mapper-locations: classpath:mapper/*.xml
+auth:
+  public-key: auth/pub.key

+ 29 - 0
base-servers/file/file-server-qcloud/src/main/resources/config/application-docker-cloud.yml

@@ -0,0 +1,29 @@
+eureka:
+  instance:
+    hostname: smartschool-file-server
+    prefer-ip-address: false
+  client:
+    serviceUrl:
+      defaultZone: http://${spring.security.user.name}:${spring.security.user.password}@smartschool-eureka-server:9500/eureka/
+  spring:
+    redis:
+      host: 172.27.0.13
+      port: 6379
+      password: select111***
+    datasource:
+        driver-class-name: com.mysql.jdbc.Driver
+        url: jdbc:mysql://172.27.0.15:3306/smart_campus?characterEncoding=utf-8&useSSL=false&allowMultiQueries=true
+        username: root
+        password: select111***
+        hikari:
+          minimum-idle: 5
+          maximum-pool-size: 50
+          idle-timeout: 30000
+          max-lifetime: 1800000
+          connection-timeout: 30000
+    rabbitmq:
+          host: 132.232.174.14
+          port: 5672
+          virtual-host: school
+          username: saas
+          password: select123***

+ 7 - 0
base-servers/file/file-server-qcloud/src/main/resources/config/application-docker-prod.yml

@@ -0,0 +1,7 @@
+eureka:
+  instance:
+    hostname: smartschool-file-server
+    prefer-ip-address: false
+  client:
+    serviceUrl:
+      defaultZone: http://${spring.security.user.name}:${spring.security.user.password}@smartschool-eureka-server:9500/eureka/

+ 131 - 0
base-servers/file/file-server-qcloud/src/main/resources/logback-spring.xml

@@ -0,0 +1,131 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+    <include resource="org/springframework/boot/logging/logback/base.xml" />
+    <jmxConfigurator/>
+
+    <!--
+    %m
+    输出代码中指定的消息
+    %p
+    输出优先级,即DEBUG,INFO,WARN,ERROR,FATAL
+    %r
+    输出自应用启动到输出该log信息耗费的毫秒数
+    %c
+    输出所属的类目,通常就是所在类的全名
+    %t
+    输出产生该日志事件的线程名
+    %n
+    输出一个回车换行符,Windows平台为“\r\n”,Unix平台为“\n”
+    %d
+    输出日志时间点的日期或时间,默认格式为ISO8601,也可以在其后指定格式,比如:%d{yyy MMM dd HH:mm:ss,SSS},
+    输出类似:2002年10月18日 22:10:28,921
+    %l
+    输出日志事件的发生位置,包括类目名、发生的线程,以及在代码中的行数。举例:Testlog4.main(TestLog4.java:10)
+    -->
+
+    <springProperty scope="context" name="log.path" source="logging.path" defaultValue="/var/log/smartschool/file-server"/>
+    <springProperty scope="context" name="spring.application.name" source="spring.application.name" defaultValue="file-server"/>
+    <springProperty scope="context" name="spring.profiles.active" source="spring.profiles.active" defaultValue="dev"/>
+    <springProperty scope="context" name="common-pattern" source="logging.common-pattern" defaultValue="%d{yyyy-MM-dd HH:mm:ss.SSS}:[%5p] [%t:%r] [%C{1}:%M:%L] --> %m%n"/>
+    <springProperty scope="context" name="log.level.console" source="logging.level.console" defaultValue="INFO"/>
+    <springProperty scope="context" name="log.destination" source="logging.destination" defaultValue="10.1.81.1:5000"/>
+
+    <contextName>${spring.application.name}-${spring.profiles.active}-logback</contextName>
+
+    <appender name="CONSOLE_APPENDER" class="ch.qos.logback.core.ConsoleAppender">
+        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+            <level>${log.level.console}</level>
+        </filter>
+        <encoder>
+            <pattern>${common-pattern}</pattern>
+        </encoder>
+    </appender>
+
+    <appender name="ROOT_APPENDER" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <file>${log.path}/root.log</file>
+        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+            <fileNamePattern>${log.path}/%d{yyyy-MM}/root-%d{yyyy-MM-dd}-%i.log.gz</fileNamePattern>
+            <maxFileSize>128MB</maxFileSize>
+            <maxHistory>7</maxHistory>
+            <totalSizeCap>20GB</totalSizeCap>
+        </rollingPolicy>
+        <encoder>
+            <pattern>${common-pattern}</pattern>
+        </encoder>
+    </appender>
+
+    <!-- Appender to log in a JSON format -->
+    <appender name="JSON_APPENDER" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
+        <destination>${log.destination}</destination>
+        <encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
+            <providers>
+                <pattern>
+                    <pattern>
+                        {
+                        "severity": "%level",
+                        "service": "${spring.application.name:-}",
+                        "trace": "%X{X-B3-TraceId:-}",
+                        "span": "%X{X-B3-SpanId:-}",
+                        "parent": "%X{X-B3-ParentSpanId:-}",
+                        "exportable": "%X{X-Span-Export:-}",
+                        "pid": "${PID:-}",
+                        "thread": "%thread",
+                        "class": "%logger{40}",
+                        "rest": "%message"
+                        }
+                    </pattern>
+                </pattern>
+            </providers>
+        </encoder>
+    </appender>
+
+    <logger name="org.springframework" level="INFO"/>
+    <logger name="com.usoftchina.smartschool" level="INFO"/>
+
+    <springProfile name="dev">
+        <root level="INFO">
+            <appender-ref ref="CONSOLE_APPENDER"/>
+        </root>
+    </springProfile>
+
+    <springProfile name="test">
+        <root level="INFO">
+            <appender-ref ref="CONSOLE_APPENDER"/>
+            <appender-ref ref="ROOT_APPENDER"/>
+        </root>
+    </springProfile>
+
+    <springProfile name="docker">
+        <logger name="org.springframework" level="WARN"/>
+        <logger name="com.usoftchina.smartschool" level="WARN"/>
+        <root level="WARN">
+            <appender-ref ref="CONSOLE_APPENDER"/>
+            <appender-ref ref="JSON_APPENDER"/>
+        </root>
+    </springProfile>
+
+    <springProfile name="docker-dev">
+        <root level="INFO">
+            <appender-ref ref="CONSOLE_APPENDER"/>
+        </root>
+    </springProfile>
+
+    <springProfile name="docker-test">
+        <logger name="org.springframework" level="WARN"/>
+        <logger name="com.usoftchina.smartschool" level="WARN"/>
+        <root level="WARN">
+            <appender-ref ref="CONSOLE_APPENDER"/>
+            <appender-ref ref="JSON_APPENDER"/>
+        </root>
+    </springProfile>
+
+    <springProfile name="docker-prod">
+        <logger name="org.springframework" level="WARN"/>
+        <logger name="com.usoftchina.smartschool" level="WARN"/>
+        <root level="WARN">
+            <appender-ref ref="CONSOLE_APPENDER"/>
+            <appender-ref ref="JSON_APPENDER"/>
+        </root>
+    </springProfile>
+
+</configuration>

+ 2 - 19
base-servers/file/file-server/pom.xml

@@ -48,8 +48,8 @@
         </dependency>
 
         <dependency>
-            <groupId>com.github.tobato</groupId>
-            <artifactId>fastdfs-client</artifactId>
+            <groupId>com.usoftchina.smartschool</groupId>
+            <artifactId>file-storage</artifactId>
         </dependency>
         <dependency>
             <groupId>org.apache.commons</groupId>
@@ -68,23 +68,6 @@
             <groupId>net.logstash.logback</groupId>
             <artifactId>logstash-logback-encoder</artifactId>
         </dependency>
-        <!-- test -->
-        <dependency>
-            <groupId>com.usoftchina.smartschool</groupId>
-            <artifactId>test-starter</artifactId>
-        </dependency>
     </dependencies>
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.springframework.boot</groupId>
-                <artifactId>spring-boot-maven-plugin</artifactId>
-            </plugin>
-            <plugin>
-                <groupId>com.spotify</groupId>
-                <artifactId>docker-maven-plugin</artifactId>
-            </plugin>
-        </plugins>
-    </build>
 
 </project>

+ 7 - 16
base-servers/file/file-server/src/main/java/com/usoftchina/smartschool/file/controller/FileController.java

@@ -1,16 +1,13 @@
 package com.usoftchina.smartschool.file.controller;
 
-import com.github.tobato.fastdfs.domain.StorePath;
-import com.github.tobato.fastdfs.service.FastFileStorageClient;
 import com.usoftchina.smartschool.base.Result;
 import com.usoftchina.smartschool.exception.BizException;
 import com.usoftchina.smartschool.exception.ExceptionCode;
 import com.usoftchina.smartschool.file.constant.FileConstant;
-import com.usoftchina.smartschool.file.dto.FileInfoDTO;
-import com.usoftchina.smartschool.file.dto.FolderDTO;
-import com.usoftchina.smartschool.file.dto.FolderSaveDTO;
+import com.usoftchina.smartschool.file.dto.*;
 import com.usoftchina.smartschool.file.po.FileInfo;
 import com.usoftchina.smartschool.file.service.FileInfoService;
+import com.usoftchina.smartschool.file.storage.FileStorageClient;
 import com.usoftchina.smartschool.utils.BeanMapper;
 import com.usoftchina.smartschool.utils.BizAssert;
 import com.usoftchina.smartschool.utils.CollectionUtils;
@@ -20,7 +17,6 @@ import io.swagger.annotations.ApiOperation;
 import org.apache.commons.compress.archivers.ArchiveOutputStream;
 import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
 import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
-import org.apache.commons.io.IOUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.MediaType;
@@ -48,7 +44,7 @@ public class FileController {
     private FileInfoService fileService;
 
     @Autowired
-    private FastFileStorageClient storageClient;
+    private FileStorageClient storageClient;
     /**
      * 文件访问服务baseUrl
      *
@@ -98,7 +94,7 @@ public class FileController {
         // 检查父文件夹
         FileInfo parent = checkFolder(folderId);
         FileInfo info = FileInfo.newFile(file).folder(parent.getId())
-                .storeBy(storageClient).build();
+                .storeBy(storageClient).baseUrl(fileBaseUrl).build();
         fileService.save(info);
         return Result.success(BeanMapper.map(info, FileInfoDTO.class));
     }
@@ -127,9 +123,7 @@ public class FileController {
             if (null != info.getFullPath()) {
                 response.setHeader("Content-disposition",
                         "attachment; filename=" + URLEncoder.encode(info.getName(), "UTF-8"));
-                StorePath path = StorePath.praseFromUrl(info.getFullPath());
-                storageClient.downloadFile(path.getGroup(), path.getPath(),
-                        in -> IOUtils.copy(in, response.getOutputStream()));
+                storageClient.downloadFile(info.getFullPath(), response.getOutputStream());
             }
         }
     }
@@ -159,9 +153,7 @@ public class FileController {
             if (!StringUtils.isEmpty(info.getMime())) {
                 response.setContentType(info.getMime());
             }
-            StorePath path = StorePath.praseFromUrl(info.getFullPath());
-            storageClient.downloadFile(path.getGroup(), path.getPath(),
-                    in -> IOUtils.copy(in, response.getOutputStream()));
+            storageClient.downloadFile(info.getFullPath(), response.getOutputStream());
         } else {
             // 无法直接查看的文件,下载到客户端
             download(info.getId(), response);
@@ -248,8 +240,7 @@ public class FileController {
             }
         } else {
             out.putArchiveEntry(new ZipArchiveEntry(directory + info.getName()));
-            StorePath path = StorePath.praseFromUrl(info.getFullPath());
-            storageClient.downloadFile(path.getGroup(), path.getPath(), in -> IOUtils.copy(in, out));
+            storageClient.downloadFile(info.getFullPath(), out);
             out.closeArchiveEntry();
         }
     }

+ 31 - 24
base-servers/file/file-server/src/main/java/com/usoftchina/smartschool/file/po/FileInfo.java

@@ -1,14 +1,14 @@
 package com.usoftchina.smartschool.file.po;
 
 import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.github.tobato.fastdfs.domain.StorePath;
-import com.github.tobato.fastdfs.service.FastFileStorageClient;
 import com.usoftchina.smartschool.base.entity.CommonBaseEntity;
 import com.usoftchina.smartschool.context.BaseContextHolder;
-import com.usoftchina.smartschool.file.constant.FileType;
-import com.usoftchina.smartschool.file.util.FileTypeUtils;
+import com.usoftchina.smartschool.file.storage.FileMetadata;
+import com.usoftchina.smartschool.file.storage.FileStorageClient;
+import com.usoftchina.smartschool.file.storage.util.FileType;
+import com.usoftchina.smartschool.file.storage.util.FileTypeUtils;
+import com.usoftchina.smartschool.file.storage.util.FilenameUtils;
 import com.usoftchina.smartschool.utils.StringUtils;
-import org.apache.commons.io.FilenameUtils;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.io.IOException;
@@ -19,7 +19,7 @@ import java.util.Date;
  * @author yingp
  * @date 2018/9/29
  */
-public class FileInfo extends CommonBaseEntity implements Serializable{
+public class FileInfo extends CommonBaseEntity implements Serializable {
     /**
      * 文件夹id
      */
@@ -33,6 +33,10 @@ public class FileInfo extends CommonBaseEntity implements Serializable{
      * 存储路径
      */
     private String fullPath;
+    /**
+     * 访问路径
+     */
+    private String accessPath;
     /**
      * Content-Type
      */
@@ -47,7 +51,8 @@ public class FileInfo extends CommonBaseEntity implements Serializable{
     private long size;
     /**
      * 类型
-     * @see com.usoftchina.smartschool.file.constant.FileType
+     *
+     * @see com.usoftchina.smartschool.file.storage.util.FileType
      */
     private String type;
 
@@ -76,10 +81,11 @@ public class FileInfo extends CommonBaseEntity implements Serializable{
         this.name = name;
     }
 
-    public FileInfo(Long folderId, String name, String fullPath, String mime, String ext, String type, long size) {
+    public FileInfo(Long folderId, String name, String fullPath, String accessPath, String mime, String ext, String type, long size) {
         this.folderId = folderId;
         this.name = name;
         this.fullPath = fullPath;
+        this.accessPath = accessPath;
         this.mime = mime;
         this.ext = ext;
         this.type = type;
@@ -142,6 +148,14 @@ public class FileInfo extends CommonBaseEntity implements Serializable{
         this.type = type;
     }
 
+    public String getAccessPath() {
+        return accessPath;
+    }
+
+    public void setAccessPath(String accessPath) {
+        this.accessPath = accessPath;
+    }
+
     public boolean isDeleted() {
         return deleted;
     }
@@ -211,7 +225,7 @@ public class FileInfo extends CommonBaseEntity implements Serializable{
         return info;
     }
 
-    public static Builder newFile(MultipartFile file){
+    public static Builder newFile(MultipartFile file) {
         return new Builder(file);
     }
 
@@ -227,7 +241,7 @@ public class FileInfo extends CommonBaseEntity implements Serializable{
         private long size;
         private String type;
         private MultipartFile multipartFile;
-        private FastFileStorageClient storageClient;
+        private FileStorageClient storageClient;
         private String baseUrl;
 
         public Builder(MultipartFile file) {
@@ -274,7 +288,7 @@ public class FileInfo extends CommonBaseEntity implements Serializable{
             return this;
         }
 
-        public Builder storeBy(FastFileStorageClient storageClient){
+        public Builder storeBy(FileStorageClient storageClient) {
             this.storageClient = storageClient;
             return this;
         }
@@ -284,21 +298,14 @@ public class FileInfo extends CommonBaseEntity implements Serializable{
             return this;
         }
 
-        public FileInfo build() throws IOException{
+        public FileInfo build() throws IOException {
             if (null != storageClient) {
-                StorePath storePath;
-                if (FileType.of(type) == FileType.IMAGE) {
-                    // 保存图片 + 生成缩略图
-                    storePath = storageClient.uploadImageAndCrtThumbImage(multipartFile.getInputStream(),
-                            size, ext, null);
-                } else {
-                    storePath = storageClient.uploadFile(multipartFile.getInputStream(),
-                            size, ext, null);
-                }
-                this.fullPath = StringUtils.nullIf(baseUrl) + storePath.getFullPath();
+                this.fullPath = storageClient.uploadFile(multipartFile.getInputStream(),
+                        new FileMetadata(mime, ext, size));
             }
 
-            return new FileInfo(folderId, name, fullPath, mime, ext, type, size);
+            String accessPath = StringUtils.nullIf(baseUrl) + fullPath;
+            return new FileInfo(folderId, name, fullPath, accessPath, mime, ext, type, size);
         }
     }
-}
+}

+ 0 - 13
base-servers/file/file-server/src/main/resources/config/application-dev.yml

@@ -1,13 +0,0 @@
-eureka:
-  instance:
-    leaseRenewalIntervalInSeconds: 10
-    health-check-url-path: /actuator/health
-    status-page-url-path: /actuator/info
-    prefer-ip-address: true
-    metadata-map:
-      user.name: ${spring.security.user.name}
-      user.password: ${spring.security.user.password}
-  client:
-    registryFetchIntervalSeconds: 5
-    serviceUrl:
-      defaultZone: http://${spring.security.user.name}:${spring.security.user.password}@127.0.0.1:9500/eureka/

+ 0 - 12
base-servers/file/file-server/src/main/resources/config/application-docker-dev.yml

@@ -1,12 +0,0 @@
-eureka:
-  instance:
-    hostname: saas-file-server-dev
-    prefer-ip-address: false
-  client:
-    serviceUrl:
-      defaultZone: http://${spring.security.user.name}:${spring.security.user.password}@saas-eureka-server-dev:8510/eureka/
-spring:
-  rabbitmq:
-    virtual-host: dev
-server:
-  port: 8650

+ 0 - 12
base-servers/file/file-server/src/main/resources/config/application-docker-test.yml

@@ -1,12 +0,0 @@
-eureka:
-  instance:
-    hostname: saas-file-server-test
-    prefer-ip-address: false
-  client:
-    serviceUrl:
-      defaultZone: http://${spring.security.user.name}:${spring.security.user.password}@saas-eureka-server-test:8515/eureka/
-spring:
-  rabbitmq:
-    virtual-host: test
-server:
-  port: 8655

+ 0 - 0
base-servers/file/file-server/src/main/resources/i18n/messages_en_US.properties


+ 0 - 0
base-servers/file/file-server/src/main/resources/i18n/messages_zh_CN.properties


+ 24 - 0
base-servers/file/file-storage-fdfs/pom.xml

@@ -0,0 +1,24 @@
+<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>file</artifactId>
+        <groupId>com.usoftchina.smartschool</groupId>
+        <version>1.0.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>file-storage-fdfs</artifactId>
+
+    <dependencies>
+        <dependency>
+            <groupId>com.github.tobato</groupId>
+            <artifactId>fastdfs-client</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.usoftchina.smartschool</groupId>
+            <artifactId>file-storage</artifactId>
+        </dependency>
+    </dependencies>
+</project>

+ 21 - 0
base-servers/file/file-storage-fdfs/src/main/java/com/usoftchina/smartschool/file/storage/fdfs/FdfsConfig.java

@@ -0,0 +1,21 @@
+package com.usoftchina.smartschool.file.storage.fdfs;
+
+import com.github.tobato.fastdfs.FdfsClientConfig;
+import com.usoftchina.smartschool.file.storage.FileStorageClient;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
+
+/**
+ * @author yingp
+ * @date 2019/3/14
+ */
+@Configuration
+@Import(FdfsClientConfig.class)
+public class FdfsConfig {
+
+    @Bean
+    public FileStorageClient fileStorageClient() {
+        return new FdfsFileStorageClient();
+    }
+}

+ 50 - 0
base-servers/file/file-storage-fdfs/src/main/java/com/usoftchina/smartschool/file/storage/fdfs/FdfsFileStorageClient.java

@@ -0,0 +1,50 @@
+package com.usoftchina.smartschool.file.storage.fdfs;
+
+import com.github.tobato.fastdfs.domain.StorePath;
+import com.github.tobato.fastdfs.service.FastFileStorageClient;
+import com.usoftchina.smartschool.file.storage.FileMetadata;
+import com.usoftchina.smartschool.file.storage.FileStorageClient;
+import com.usoftchina.smartschool.file.storage.util.FileType;
+import com.usoftchina.smartschool.file.storage.util.FileTypeUtils;
+import org.apache.commons.io.IOUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * @author yingp
+ * @date 2019/3/14
+ */
+public class FdfsFileStorageClient implements FileStorageClient{
+
+    @Autowired
+    private FastFileStorageClient storageClient;
+
+    @Override
+    public String uploadFile(InputStream inputStream, FileMetadata metadata) {
+        FileType type = FileTypeUtils.getFileType(metadata.getMime(), metadata.getExt());
+        StorePath storePath;
+        if (FileType.IMAGE == type) {
+            // 保存图片 + 生成缩略图
+            storePath = storageClient.uploadImageAndCrtThumbImage(inputStream, metadata.getSize(),
+                    metadata.getExt(), null);
+        } else {
+            storePath = storageClient.uploadFile(inputStream, metadata.getSize(),
+                    metadata.getExt(), null);
+        }
+        return storePath.getFullPath();
+    }
+
+    @Override
+    public void deleteFile(String filePath) {
+        storageClient.deleteFile(filePath);
+    }
+
+    @Override
+    public void downloadFile(String filePath, OutputStream out) throws IOException{
+        StorePath path = StorePath.praseFromUrl(filePath);
+        storageClient.downloadFile(path.getGroup(), path.getPath(), in -> IOUtils.copy(in, out));
+    }
+}

+ 3 - 0
base-servers/file/file-storage-fdfs/src/main/resources/META-INF/spring.factories

@@ -0,0 +1,3 @@
+# Auto Configuration
+org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
+com.usoftchina.smartschool.file.storage.fdfs.FdfsConfig

+ 35 - 0
base-servers/file/file-storage-qcloud/pom.xml

@@ -0,0 +1,35 @@
+<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>file</artifactId>
+        <groupId>com.usoftchina.smartschool</groupId>
+        <version>1.0.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>file-storage-qcloud</artifactId>
+
+    <dependencies>
+        <dependency>
+            <groupId>com.qcloud</groupId>
+            <artifactId>cos_api</artifactId>
+            <version>5.4.10</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.slf4j</groupId>
+                    <artifactId>slf4j-log4j12</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.usoftchina.smartschool</groupId>
+            <artifactId>file-storage</artifactId>
+        </dependency>
+    </dependencies>
+</project>

+ 81 - 0
base-servers/file/file-storage-qcloud/src/main/java/com/usoftchina/smartschool/file/storage/qcloud/COSFileStorageClient.java

@@ -0,0 +1,81 @@
+package com.usoftchina.smartschool.file.storage.qcloud;
+
+import com.qcloud.cos.COSClient;
+import com.qcloud.cos.ClientConfig;
+import com.qcloud.cos.auth.BasicCOSCredentials;
+import com.qcloud.cos.auth.COSCredentials;
+import com.qcloud.cos.model.COSObject;
+import com.qcloud.cos.model.ObjectMetadata;
+import com.qcloud.cos.region.Region;
+import com.qcloud.cos.utils.IOUtils;
+import com.usoftchina.smartschool.file.storage.FileMetadata;
+import com.usoftchina.smartschool.file.storage.FileStorageClient;
+import org.springframework.util.StringUtils;
+
+import javax.annotation.PreDestroy;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.UUID;
+
+/**
+ * @author yingp
+ * @date 2019/3/14
+ */
+public class COSFileStorageClient implements FileStorageClient {
+
+    private final CosProperties cosProperties;
+    private final COSClient client;
+
+    public COSFileStorageClient(CosProperties cosProperties) {
+        this.cosProperties = cosProperties;
+        this.client = initCOSClient();
+    }
+
+    private COSClient initCOSClient() {
+        // 1 初始化用户身份信息
+        COSCredentials cred = new BasicCOSCredentials(cosProperties.getSecretId(),
+                cosProperties.getSecretKey());
+        // 2 设置bucket的区域
+        ClientConfig clientConfig = new ClientConfig(new Region(cosProperties.getRegion()));
+        // 3 生成 cos 客户端。
+        return new COSClient(cred, clientConfig);
+    }
+
+    @Override
+    public String uploadFile(InputStream inputStream, FileMetadata metadata) {
+        ObjectMetadata objectMetadata = new ObjectMetadata();
+        objectMetadata.setContentLength(metadata.getSize());
+        if (!StringUtils.isEmpty(metadata.getMime())) {
+            objectMetadata.setContentType(metadata.getMime());
+        }
+        String filePath = generateDefaultFilePath() +
+                (StringUtils.isEmpty(metadata.getExt()) ? "" : ("." + metadata.getExt()));
+        client.putObject(cosProperties.getBucketName(), filePath, inputStream, objectMetadata);
+        return filePath;
+    }
+
+    private String generateDefaultFilePath() {
+        // 当天 + 随机串
+        return LocalDateTime.now().format(DateTimeFormatter.ISO_DATE) + "/" +
+                UUID.randomUUID().toString();
+    }
+
+    @Override
+    public void deleteFile(String filePath) {
+        client.deleteObject(cosProperties.getBucketName(), filePath);
+    }
+
+    @PreDestroy
+    public void shutdown() {
+        client.shutdown();
+    }
+
+    @Override
+    public void downloadFile(String filePath, OutputStream out) throws IOException {
+        COSObject object = client.getObject(cosProperties.getBucketName(), filePath);
+        IOUtils.copy(object.getObjectContent(), out);
+    }
+}

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно