张涛 1 år sedan
förälder
incheckning
bb1b93f803

+ 22
- 15
pom.xml Visa fil

@@ -19,7 +19,8 @@
19 19
         <wx.version>4.4.0</wx.version>
20 20
         <lombok.version>1.18.22</lombok.version>
21 21
         <mybatis-plus.version>3.5.1</mybatis-plus.version>
22
-        <dynamic-datasource.version>3.5.1</dynamic-datasource.version>
22
+        <sa-token.version>1.34.0</sa-token.version>
23
+<!--        <dynamic-datasource.version>3.5.1</dynamic-datasource.version>-->
23 24
     </properties>
24 25
     <dependencies>
25 26
         <!--web依赖-->
@@ -39,11 +40,11 @@
39 40
         </dependency>
40 41
         <!--swagger end-->
41 42
         <!-- 企业号/企业微信 -->
42
-        <dependency>
43
-            <groupId>com.github.binarywang</groupId>
44
-            <artifactId>weixin-java-cp</artifactId>
45
-            <version>${wx.version}</version>
46
-        </dependency>
43
+<!--        <dependency>-->
44
+<!--            <groupId>com.github.binarywang</groupId>-->
45
+<!--            <artifactId>weixin-java-cp</artifactId>-->
46
+<!--            <version>${wx.version}</version>-->
47
+<!--        </dependency>-->
47 48
 
48 49
         <dependency>
49 50
             <groupId>org.projectlombok</groupId>
@@ -58,11 +59,11 @@
58 59
             <version>${mybatis-plus.version}</version>
59 60
         </dependency>
60 61
         <!-- oracle -->
61
-        <dependency>
62
-            <groupId>com.oracle.database.jdbc</groupId>
63
-            <artifactId>ojdbc8</artifactId>
64
-            <scope>runtime</scope>
65
-        </dependency>
62
+<!--        <dependency>-->
63
+<!--            <groupId>com.oracle.database.jdbc</groupId>-->
64
+<!--            <artifactId>ojdbc8</artifactId>-->
65
+<!--            <scope>runtime</scope>-->
66
+<!--        </dependency>-->
66 67
 
67 68
         <!-- mysql -->
68 69
         <dependency>
@@ -71,12 +72,18 @@
71 72
             <scope>runtime</scope>
72 73
         </dependency>
73 74
 
74
-        <!-- 多数据源 -->
75 75
         <dependency>
76
-            <groupId>com.baomidou</groupId>
77
-            <artifactId>dynamic-datasource-spring-boot-starter</artifactId>
78
-            <version>${dynamic-datasource.version}</version>
76
+            <groupId>cn.dev33</groupId>
77
+            <artifactId>sa-token-spring-boot-starter</artifactId>
78
+            <version>${sa-token.version}</version>
79 79
         </dependency>
80
+
81
+<!--        &lt;!&ndash; 多数据源 &ndash;&gt;-->
82
+<!--        <dependency>-->
83
+<!--            <groupId>com.baomidou</groupId>-->
84
+<!--            <artifactId>dynamic-datasource-spring-boot-starter</artifactId>-->
85
+<!--            <version>${dynamic-datasource.version}</version>-->
86
+<!--        </dependency>-->
80 87
     </dependencies>
81 88
 
82 89
     <build>

+ 18
- 35
src/main/java/com/lyg/tools/controller/UploadController.java Visa fil

@@ -3,13 +3,11 @@ package com.lyg.tools.controller;
3 3
 import com.lyg.tools.common.FileUtil;
4 4
 import com.lyg.tools.common.ResponseBean;
5 5
 import com.lyg.tools.common.StringUtil;
6
-import com.lyg.tools.hangxin.WxUtil;
7 6
 import io.swagger.annotations.Api;
8 7
 import org.springframework.beans.factory.annotation.Autowired;
9 8
 import org.springframework.web.bind.annotation.*;
10 9
 import org.springframework.web.multipart.MultipartFile;
11 10
 
12
-import java.io.File;
13 11
 import java.util.HashMap;
14 12
 import java.util.Map;
15 13
 
@@ -18,28 +16,33 @@ import java.util.Map;
18 16
 @RequestMapping("/")
19 17
 public class UploadController {
20 18
 
21
-    @Autowired
22
-    WxUtil wxUtil;
23
-
24 19
     @Autowired
25 20
     FileUtil fileUtil;
26 21
 
22
+    public static String getFileType(MultipartFile file) throws Exception {
23
+        String fileName = file.getOriginalFilename();
24
+        // 通过文件名获取文件后缀,并与MIME类型映射表对比获取文件类型
25
+        String fileSuffix = fileName.substring(fileName.lastIndexOf(".") + 1);
26
+        // 这里可以扩展为查询MIME类型映射表
27
+        return fileSuffix;
28
+    }
29
+
27 30
     /**
28 31
      * 通用端上传文件
29 32
      *
30
-     * @param appid 应用Id
31 33
      * @return
32 34
      * @throws Exception
33 35
      */
34
-    @PostMapping("/upload/admin/{appid}")
35
-    public ResponseBean uploadAdmin(@RequestParam(value = "file") MultipartFile multipartFile,
36
-                               @PathVariable(value = "appid") String appid
37
-    ) throws Exception {
36
+    @PostMapping("/upload/cms")
37
+    public ResponseBean uploadAdmin(@RequestParam(value = "file") MultipartFile file) throws Exception {
38
+        String fileType = getFileType(file);
38 39
 
39 40
         Map<String, Object> res = new HashMap<>();
40
-        String path = fileUtil.saveFile(multipartFile,  appid);
41
-        res.put("url", path);
42
-
41
+        String fileName = file.getOriginalFilename();
42
+        String path = fileUtil.saveFile(file, "cms");
43
+        res.put("attachUrl", path);
44
+        res.put("attachName", fileName);
45
+        res.put("fileType", fileType);
43 46
         return ResponseBean.success(res);
44 47
     }
45 48
 
@@ -52,8 +55,8 @@ public class UploadController {
52 55
      */
53 56
     @PostMapping("/upload/base64/{appid}")
54 57
     public ResponseBean uploadBase64(@PathVariable(value = "appid") String appid,
55
-                                 @RequestParam(value = "base64") String base64,
56
-                                 @RequestParam(value = "fileName", defaultValue = "unknown.jpg") String fileName
58
+                                     @RequestParam(value = "base64") String base64,
59
+                                     @RequestParam(value = "fileName", defaultValue = "unknown.jpg") String fileName
57 60
     ) throws Exception {
58 61
 
59 62
         Map<String, Object> res = new HashMap<>();
@@ -65,25 +68,5 @@ public class UploadController {
65 68
         return ResponseBean.success(res);
66 69
     }
67 70
 
68
-    /**
69
-     * 企业微信上传文件
70
-     *
71
-     * @param appid 应用Id
72
-     * @return
73
-     * @throws Exception
74
-     */
75
-    @PostMapping("/upload/h5/{appid}")
76
-    public ResponseBean uploadH5(@PathVariable(value = "appid") String appid,
77
-                               @RequestParam(value = "mediaId") String mediaId,
78
-                               @RequestParam(value = "fileName", defaultValue = "unknown.jpg") String fileName
79
-    ) throws Exception {
80
-
81
-        Map<String, Object> res = new HashMap<>();
82
-        File file = wxUtil.downloadMedia(mediaId);
83
-        String path = fileUtil.saveFile(file, fileName, appid);
84
-        res.put("url", path);
85
-
86
-        return ResponseBean.success(res);
87
-    }
88 71
 
89 72
 }

+ 0
- 42
src/main/java/com/lyg/tools/controller/WxCpController.java Visa fil

@@ -1,42 +0,0 @@
1
-package com.lyg.tools.controller;
2
-
3
-import com.lyg.tools.common.FileUtil;
4
-import com.lyg.tools.common.ResponseBean;
5
-import com.lyg.tools.hangxin.WxUtil;
6
-//import io.swagger.annotations.Api;
7
-//import io.swagger.annotations.ApiOperation;
8
-import io.swagger.annotations.Api;
9
-import io.swagger.annotations.ApiOperation;
10
-import io.swagger.annotations.ApiParam;
11
-import me.chanjar.weixin.common.bean.WxJsapiSignature;
12
-import org.springframework.beans.factory.annotation.Autowired;
13
-import org.springframework.beans.factory.annotation.Value;
14
-import org.springframework.web.bind.annotation.*;
15
-import org.springframework.web.multipart.MultipartFile;
16
-
17
-import java.io.File;
18
-import java.util.HashMap;
19
-import java.util.Map;
20
-
21
-
22
-@Api(tags = "企业微信")
23
-@RestController
24
-@RequestMapping("/")
25
-public class WxCpController {
26
-
27
-    @Autowired
28
-    WxUtil wxUtil;
29
-
30
-    @Autowired
31
-    FileUtil fileUtil;
32
-
33
-    @Value("${yz.env}")
34
-    String env;
35
-
36
-    @ApiOperation("获取 JS-SDK config")
37
-    @GetMapping("/h5/jsconfig")
38
-    public ResponseBean getJsConfig(@ApiParam("页面路径") @RequestParam("url") String url) throws Exception {
39
-        WxJsapiSignature jsconfig = wxUtil.jsconfig(url);
40
-        return ResponseBean.success(jsconfig);
41
-    }
42
-}

+ 0
- 52
src/main/java/com/lyg/tools/entity/MessageSmBox.java Visa fil

@@ -1,52 +0,0 @@
1
-package com.lyg.tools.entity;
2
-
3
-import com.baomidou.mybatisplus.annotation.IdType;
4
-import com.baomidou.mybatisplus.annotation.TableId;
5
-import com.baomidou.mybatisplus.annotation.TableName;
6
-import io.swagger.annotations.ApiModel;
7
-import io.swagger.annotations.ApiModelProperty;
8
-import lombok.Data;
9
-import lombok.EqualsAndHashCode;
10
-import lombok.experimental.Accessors;
11
-
12
-import java.io.Serializable;
13
-import java.time.LocalDateTime;
14
-
15
-/**
16
-* 消息表-mysql;
17
-* @author : http://www.chiner.pro
18
-* @date : 2023-2-7
19
-*/
20
-@Data
21
-@EqualsAndHashCode(callSuper = false)
22
-@Accessors(chain = true)
23
-@ApiModel(value = "消息表-mysql",description = "")
24
-@TableName("Message_sm_box")
25
-public class MessageSmBox implements Serializable,Cloneable{
26
-   /** 消息id */
27
-   @ApiModelProperty(name = "消息id",notes = "")
28
-   @TableId(value = "id", type = IdType.AUTO)
29
-   private Integer id ;
30
-   /** 消息内容 */
31
-   @ApiModelProperty(name = "消息内容",notes = "")
32
-   private String message ;
33
-   /** 手机号 */
34
-   @ApiModelProperty(name = "手机号",notes = "")
35
-   private String phone ;
36
-   /** 应用id;用于记录是哪个应用使用的短信 */
37
-   @ApiModelProperty(name = "应用id",notes = "用于记录是哪个应用使用的短信")
38
-   private String appid ;
39
-   /** 渠道标识;1、联通短信 ;2、行信;4、移动;3、行信和联通 */
40
-   @ApiModelProperty(name = "渠道标识",notes = "1、联通短信 ;2、行信;4、移动;3、行信和联通")
41
-   private Integer chn ;
42
-   /** 员工EHR号 */
43
-   @ApiModelProperty(name = "员工EHR号",notes = "")
44
-   private String user ;
45
-   /** 创建时间 */
46
-   @ApiModelProperty(name = "创建时间",notes = "")
47
-   private LocalDateTime dataDate ;
48
-   /** 备注 */
49
-   @ApiModelProperty(name = "备注",notes = "")
50
-   private String remark ;
51
-
52
-}

+ 62
- 0
src/main/java/com/lyg/tools/entity/TaAttach.java Visa fil

@@ -0,0 +1,62 @@
1
+package com.lyg.tools.entity;
2
+
3
+import com.baomidou.mybatisplus.annotation.*;
4
+import io.swagger.annotations.ApiModel;
5
+import io.swagger.annotations.ApiModelProperty;
6
+import lombok.Data;
7
+import lombok.EqualsAndHashCode;
8
+import lombok.experimental.Accessors;
9
+
10
+import java.io.Serializable;
11
+import java.time.LocalDateTime;
12
+
13
+/**
14
+ * 附件表;
15
+ *
16
+ * @author : http://www.chiner.pro
17
+ * @date : 2024-3-22
18
+ */
19
+@Data
20
+@EqualsAndHashCode(callSuper = false)
21
+@Accessors(chain = true)
22
+@ApiModel(value = "附件表", description = "")
23
+@TableName("ta_attach")
24
+public class TaAttach implements Serializable, Cloneable {
25
+
26
+    @ApiModelProperty(name = "附件Id", notes = "")
27
+    @TableId(value = "attach_id", type = IdType.ASSIGN_UUID)
28
+    private String attachId;
29
+
30
+    @ApiModelProperty(name = "附件名", notes = "")
31
+    private String attachName;
32
+
33
+    @ApiModelProperty(name = "附件地址", notes = "")
34
+    private String attachUrl;
35
+
36
+    @ApiModelProperty(name = "文件类型", notes = "")
37
+    private String fileType;
38
+
39
+    @ApiModelProperty(name = "状态", notes = "0 正常 1不正常")
40
+    private Integer status;
41
+
42
+    @ApiModelProperty(name = "", notes = "")
43
+    @TableField(fill = FieldFill.INSERT)
44
+    private LocalDateTime createdTime;
45
+
46
+    @ApiModelProperty(name = "", notes = "")
47
+    @TableField(fill = FieldFill.INSERT)
48
+    private String createdBy;
49
+
50
+    @ApiModelProperty(name = "", notes = "")
51
+    @TableField(fill = FieldFill.INSERT_UPDATE)
52
+    private LocalDateTime updatedTime;
53
+
54
+    @ApiModelProperty(name = "", notes = "")
55
+    @TableField(fill = FieldFill.INSERT_UPDATE)
56
+    private String updatedBy;
57
+
58
+    @ApiModelProperty(name = "", notes = "0 存在 1 删除")
59
+    @TableField(fill = FieldFill.INSERT)
60
+    private Integer deleted;
61
+
62
+}

+ 0
- 13
src/main/java/com/lyg/tools/hangxin/CpConfig.java Visa fil

@@ -1,13 +0,0 @@
1
-package com.lyg.tools.hangxin;
2
-
3
-
4
-import lombok.Data;
5
-import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl;
6
-import org.springframework.boot.context.properties.ConfigurationProperties;
7
-import org.springframework.stereotype.Component;
8
-
9
-@Data
10
-@Component
11
-@ConfigurationProperties(prefix = "wx.cp")
12
-public class CpConfig extends WxCpDefaultConfigImpl {
13
-}

+ 0
- 37
src/main/java/com/lyg/tools/hangxin/WxUtil.java Visa fil

@@ -1,37 +0,0 @@
1
-package com.lyg.tools.hangxin;
2
-
3
-
4
-import me.chanjar.weixin.common.bean.WxJsapiSignature;
5
-import me.chanjar.weixin.common.error.WxErrorException;
6
-import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl;
7
-import org.springframework.beans.factory.annotation.Autowired;
8
-import org.springframework.stereotype.Component;
9
-
10
-import java.io.File;
11
-
12
-@Component
13
-public class WxUtil {
14
-
15
-    CpConfig cpConfig;
16
-    WxCpServiceImpl wxCpService = new WxCpServiceImpl();
17
-
18
-    @Autowired
19
-    public WxUtil(CpConfig cpConfig) {
20
-        this.cpConfig = cpConfig;
21
-
22
-        initCpService(cpConfig);
23
-    }
24
-
25
-    void initCpService(CpConfig cpConfig) {
26
-        wxCpService.setWxCpConfigStorage(cpConfig);
27
-    }
28
-
29
-    public File downloadMedia(String mediaId) throws WxErrorException {
30
-        return wxCpService.getMediaService().download(mediaId);
31
-    }
32
-
33
-    public WxJsapiSignature jsconfig(String url) throws WxErrorException {
34
-        WxJsapiSignature jsapiSignature = wxCpService.createJsapiSignature(url);
35
-        return jsapiSignature;
36
-    }
37
-}

+ 0
- 15
src/main/java/com/lyg/tools/mapper/MessageSmBoxMapper.java Visa fil

@@ -1,15 +0,0 @@
1
-package com.lyg.tools.mapper;
2
-
3
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
-import com.lyg.tools.entity.MessageSmBox;
5
-import org.apache.ibatis.annotations.Mapper;
6
-
7
-/**
8
-* 消息表-mysql;(Message_sm_box)表数据库访问层
9
-* @author : http://njyunzhi.com
10
-* @date : 2023-2-7
11
-*/
12
-@Mapper
13
-public interface MessageSmBoxMapper extends BaseMapper<MessageSmBox>{
14
-
15
-}

+ 16
- 0
src/main/java/com/lyg/tools/mapper/TaAttachMapper.java Visa fil

@@ -0,0 +1,16 @@
1
+package com.lyg.tools.mapper;
2
+
3
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.lyg.tools.entity.TaAttach;
5
+import org.apache.ibatis.annotations.Mapper;
6
+
7
+/**
8
+ * 搜索附件表;(ta_search_attach)表数据库访问层
9
+ *
10
+ * @author : http://njyunzhi.com
11
+ * @date : 2024-3-22
12
+ */
13
+@Mapper
14
+public interface TaAttachMapper extends BaseMapper<TaAttach> {
15
+
16
+}

+ 0
- 16
src/main/java/com/lyg/tools/service/MessageSmBoxService.java Visa fil

@@ -1,16 +0,0 @@
1
-package com.lyg.tools.service;
2
-
3
-import com.baomidou.mybatisplus.extension.service.IService;
4
-import com.lyg.tools.entity.MessageSmBox;
5
-
6
-/**
7
- * 消息表-mysql;(Message_sm_box)表服务接口
8
- *
9
- * @author : http://njyunzhi.com
10
- * @date : 2023-2-7
11
- */
12
-
13
-public interface MessageSmBoxService extends IService<MessageSmBox> {
14
-
15
-//    void warning(List<SysUser> list, TaTask taTask);
16
-}

+ 13
- 0
src/main/java/com/lyg/tools/service/TaAttachService.java Visa fil

@@ -0,0 +1,13 @@
1
+package com.lyg.tools.service;
2
+
3
+import com.lyg.tools.entity.TaAttach;
4
+
5
+/**
6
+ * 文章附件表;(ta_post_attach)表服务接口
7
+ *
8
+ * @author : http://njyunzhi.com
9
+ * @date : 2024-3-22
10
+ */
11
+public interface TaAttachService extends IBaseService<TaAttach> {
12
+
13
+}

+ 0
- 54
src/main/java/com/lyg/tools/service/impl/MessageSmBoxServiceImpl.java Visa fil

@@ -1,54 +0,0 @@
1
-package com.lyg.tools.service.impl;
2
-
3
-import com.baomidou.dynamic.datasource.annotation.DS;
4
-import com.lyg.tools.entity.MessageSmBox;
5
-import com.lyg.tools.mapper.MessageSmBoxMapper;
6
-import com.lyg.tools.service.MessageSmBoxService;
7
-import org.springframework.beans.factory.annotation.Value;
8
-import org.springframework.stereotype.Service;
9
-
10
-/**
11
- * 消息表-mysql;(Message_sm_box)表服务实现类
12
- *
13
- * @author : http://www.chiner.pro
14
- * @date : 2023-2-7
15
- */
16
-@Service
17
-@DS("mysql")
18
-public class MessageSmBoxServiceImpl extends BaseServiceImpl<MessageSmBoxMapper, MessageSmBox> implements MessageSmBoxService {
19
-
20
-    public static final int CHN_HX = 2;
21
-    @Value("${yz.task.message.appid}")
22
-    String appid;
23
-    @Value("${yz.task.message.template}")
24
-    String template;
25
-
26
-//    @Async
27
-//    @Override
28
-//    public void warning(List<SysUser> list, TaTask taTask) {
29
-//        if (null == list || list.size() == 0) {
30
-//            return;
31
-//        }
32
-//
33
-//        LocalDateTime now = LocalDateTime.now();
34
-//
35
-//        List<MessageSmBox> messageList = new ArrayList<>();
36
-//        for (SysUser user : list) {
37
-//            MessageSmBox message = new MessageSmBox();
38
-//
39
-//            String name = user.getName();
40
-//            String taskTitle = taTask.getTitle();
41
-//            String msg = template.replace("{name}", name).replace("{taskTitle}", taskTitle);
42
-//            message.setMessage(msg);
43
-//            message.setPhone(user.getPhone());
44
-//            message.setAppid(appid);
45
-//            message.setChn(CHN_HX);
46
-//            message.setUser(user.getHxId());
47
-//            message.setDataDate(now);
48
-//            message.setRemark(null);
49
-//            messageList.add(message);
50
-//        }
51
-//
52
-//        saveBatch(messageList);
53
-//    }
54
-}

+ 17
- 0
src/main/java/com/lyg/tools/service/impl/TaAttachServiceImpl.java Visa fil

@@ -0,0 +1,17 @@
1
+package com.lyg.tools.service.impl;
2
+
3
+import com.lyg.tools.entity.TaAttach;
4
+import com.lyg.tools.mapper.TaAttachMapper;
5
+import com.lyg.tools.service.TaAttachService;
6
+import org.springframework.stereotype.Service;
7
+
8
+/**
9
+ * 文章附件表;(ta_post_attach)表服务实现类
10
+ *
11
+ * @author : http://www.chiner.pro
12
+ * @date : 2024-3-22
13
+ */
14
+@Service
15
+public class TaAttachServiceImpl extends BaseServiceImpl<TaAttachMapper, TaAttach> implements TaAttachService {
16
+
17
+}

+ 7
- 16
src/resources/application.yml Visa fil

@@ -1,5 +1,5 @@
1 1
 server:
2
-  port: 7200
2
+  port: 7201
3 3
   servlet:
4 4
     context-path: /api
5 5
 
@@ -12,22 +12,13 @@ spring:
12 12
       max-file-size: 1024MB
13 13
       max-request-size: 1024MB
14 14
   datasource:
15
-    dynamic:
16
-      primary: oracle
17
-      datasource:
18
-        oracle:
19
-          url: jdbc:oracle:thin:@192.168.89.147:1521:orcl
20
-          username: schedule_task
21
-          password: schedule_task@ABCD123
22
-          driver-class-name: oracle.jdbc.OracleDriver
23
-        mysql:
24
-          url: jdbc:mysql://192.168.89.10:3306/civilizedcity?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true&autoReconnect=true
25
-          username: civilizedcity
26
-          password: civilizedcity@ABCD1234
27
-          driver-class-name: com.mysql.cj.jdbc.Driver
15
+    url: jdbc:mysql://192.168.89.10:3306/cms?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true&autoReconnect=true
16
+    username: cms
17
+    password: cms@1234
18
+    driver-class-name: com.mysql.cj.jdbc.Driver
28 19
 
29
-      hikari:
30
-        max-pool-size: 3  # 最大连接池数
20
+    hikari:
21
+      max-pool-size: 3  # 最大连接池数
31 22
 
32 23
 
33 24
   # 配置 Redis 连接

src/resources/mapper/MessageSmBoxMapper.xml → src/resources/mapper/TaAttachMapper.xml Visa fil

@@ -1,6 +1,6 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 3
 
4
-<mapper namespace="com.lyg.tools.mapper.MessageSmBoxMapper">
5
-
4
+<mapper namespace="com.lyg.tools.mapper.TaAttachMapper">
5
+    
6 6
 </mapper>