فهرست منبع

1:springCloud-seata模块整合
2:oos-file上传名称由雪花ID改成名称加密

lengfaqiang 3 سال پیش
والد
کامیت
563cab3e8f
32فایلهای تغییر یافته به همراه1247 افزوده شده و 1136 حذف شده
  1. 26 1
      pom.xml
  2. 35 35
      sckw-modules-api/sckw-file-api/src/main/java/com/sckw/file/api/Fallback/FileApiFeignServiceFallback.java
  3. 4 1
      sckw-modules-api/sckw-file-api/src/main/java/com/sckw/file/api/dubbo/FileApiDubboService.java
  4. 11 0
      sckw-modules/sckw-example/pom.xml
  5. 137 131
      sckw-modules/sckw-example/src/main/java/com/sckw/example/controller/FileApiController.java
  6. 175 176
      sckw-modules/sckw-example/src/main/java/com/sckw/example/controller/SysUserController.java
  7. 31 31
      sckw-modules/sckw-example/src/main/java/com/sckw/example/dao/SysUserDao.java
  8. 0 24
      sckw-modules/sckw-example/src/main/java/com/sckw/example/dubbo/FileServiceImpl.java
  9. 36 36
      sckw-modules/sckw-example/src/main/java/com/sckw/example/service/SysUserService.java
  10. 30 19
      sckw-modules/sckw-example/src/main/resources/bootstrap-dev.yml
  11. 150 0
      sckw-modules/sckw-example/src/main/resources/bootstrap-local.yml
  12. 1 1
      sckw-modules/sckw-example/src/main/resources/bootstrap.yml
  13. 51 51
      sckw-modules/sckw-example/src/main/resources/mapper/SysUserDao.xml
  14. 27 10
      sckw-modules/sckw-file/pom.xml
  15. 0 33
      sckw-modules/sckw-file/src/main/java/com/sckw/file/FileApplication.java
  16. 11 9
      sckw-modules/sckw-file/src/main/java/com/sckw/file/common/enums/FileEnum.java
  17. 0 108
      sckw-modules/sckw-file/src/main/java/com/sckw/file/controller/FileApiController.java
  18. 48 0
      sckw-modules/sckw-file/src/main/java/com/sckw/file/dao/KwsFileInfoDao.java
  19. 89 0
      sckw-modules/sckw-file/src/main/java/com/sckw/file/model/FileInfo.java
  20. 0 129
      sckw-modules/sckw-file/src/main/java/com/sckw/file/service/FileService.java
  21. 246 7
      sckw-modules/sckw-file/src/main/java/com/sckw/file/utils/FileUtils.java
  22. 0 5
      sckw-modules/sckw-file/src/main/resouces/banner.txt
  23. 0 82
      sckw-modules/sckw-file/src/main/resouces/bootstrap-dev.yml
  24. 0 27
      sckw-modules/sckw-file/src/main/resouces/bootstrap.yml
  25. 136 0
      sckw-modules/sckw-file/src/main/resources/mapper/KwsFileInfoDao.xml
  26. 1 1
      sckw-modules/sckw-message/src/main/resources/bootstrap.yml
  27. 1 0
      sckw-modules/sckw-system/src/main/java/com/sckw/system/SystemApplication.java
  28. 0 130
      sckw-modules/sckw-system/src/main/java/com/sckw/system/controller/SysUserController.java
  29. 0 23
      sckw-modules/sckw-system/src/main/java/com/sckw/system/controller/TestController.java
  30. 0 31
      sckw-modules/sckw-system/src/main/java/com/sckw/system/dao/SysUserDao.java
  31. 0 34
      sckw-modules/sckw-system/src/main/java/com/sckw/system/service/SysUserService.java
  32. 1 1
      sckw-modules/sckw-system/src/main/resources/bootstrap.yml

+ 26 - 1
pom.xml

@@ -80,7 +80,18 @@
                 <version>${dubbo.version}</version>
                 <type>pom</type>
                 <scope>import</scope>
+                <exclusions>
+                    <exclusion>
+                        <groupId>com.alibaba</groupId>
+                        <artifactId>hessian-lite</artifactId>
+                    </exclusion>
+                </exclusions>
             </dependency>
+<!--&lt;!&ndash;            处理序列化问题&ndash;&gt;-->
+<!--            <dependency>-->
+<!--                <groupId>com.caucho</groupId>-->
+<!--                <artifactId>hessian</artifactId>-->
+<!--            </dependency>-->
             <!--redisson-->
             <dependency>
                 <groupId>org.redisson</groupId>
@@ -111,6 +122,20 @@
     </dependencyManagement>
 
     <dependencies>
+
+        <!--alibaba oss-->
+        <dependency>
+            <groupId>com.alibaba.cloud</groupId>
+            <artifactId>spring-cloud-starter-alicloud-oss</artifactId>
+            <version>2.2.0.RELEASE</version>
+        </dependency>
+        <!--jdk9+ 以上需要手动添加-->
+        <dependency>
+            <groupId>javax.xml.bind</groupId>
+            <artifactId>jaxb-api</artifactId>
+            <version>2.3.1</version>
+        </dependency>
+
         <dependency>
             <groupId>org.springframework.cloud</groupId>
             <artifactId>spring-cloud-loadbalancer</artifactId>
@@ -157,7 +182,7 @@
                 </exclusion>
             </exclusions>
         </dependency>
-        <!-- 上面排除掉了springcloud默认seata版本,此处引入和seata-server版本对应的seata包-->
+        <!-- 上面排除掉了springcloud默认seata版本,此处引入和seata-server版本对应的seata包-->
         <dependency>
             <groupId>io.seata</groupId>
             <artifactId>seata-spring-boot-starter</artifactId>

+ 35 - 35
sckw-modules-api/sckw-file-api/src/main/java/com/sckw/file/api/Fallback/FileApiFeignServiceFallback.java

@@ -1,35 +1,35 @@
-package com.sckw.file.api.Fallback;
-
-import com.sckw.core.web.response.HttpResult;
-import com.sckw.file.api.feign.FileApiFeignService;
-import org.springframework.stereotype.Component;
-import org.springframework.web.multipart.MultipartFile;
-
-import java.util.Map;
-
-/**
- * @author lfdc
- * @version 1.0
- * @className FileApiFeignServiceFallback
- * @description 降级
- * @company sckw
- * @date 2023-06-06 16:06:48
- */
-@Component
-public class FileApiFeignServiceFallback implements FileApiFeignService {
-
-    @Override
-    public HttpResult fileFeignUpload(MultipartFile file) {
-        return new HttpResult();
-    }
-
-    @Override
-    public String fileFeignDemo(String userName) {
-        return "fileFeignDemo";
-    }
-
-    @Override
-    public String fileFeignDemo1(Map<String, String> map) {
-        return "fileFeignDemo1";
-    }
-}
+//package com.sckw.file.api.Fallback;
+//
+//import com.sckw.core.web.response.HttpResult;
+//import com.sckw.file.api.feign.FileApiFeignService;
+//import org.springframework.stereotype.Component;
+//import org.springframework.web.multipart.MultipartFile;
+//
+//import java.util.Map;
+//
+///**
+// * @author lfdc
+// * @version 1.0
+// * @className FileApiFeignServiceFallback
+// * @description 降级
+// * @company sckw
+// * @date 2023-06-06 16:06:48
+// */
+//@Component
+//public class FileApiFeignServiceFallback implements FileApiFeignService {
+//
+//    @Override
+//    public HttpResult fileFeignUpload(MultipartFile file) {
+//        return new HttpResult();
+//    }
+//
+//    @Override
+//    public String fileFeignDemo(String userName) {
+//        return "fileFeignDemo";
+//    }
+//
+//    @Override
+//    public String fileFeignDemo1(Map<String, String> map) {
+//        return "fileFeignDemo1";
+//    }
+//}

+ 4 - 1
sckw-modules-api/sckw-file-api/src/main/java/com/sckw/file/api/dubbo/FileApiDubboService.java

@@ -1,6 +1,7 @@
 package com.sckw.file.api.dubbo;
 
 import com.sckw.core.web.response.HttpResult;
+import org.springframework.web.multipart.MultipartFile;
 
 /**
  * @author lfdc
@@ -12,5 +13,7 @@ import com.sckw.core.web.response.HttpResult;
  */
 public interface FileApiDubboService {
 
-    HttpResult fileUpload(String contentType, String oFileName, byte[] bytes);
+    HttpResult fileUpload(String str, byte[] fileByte);
+
+    HttpResult fileUploadTodubbo(MultipartFile file);
 }

+ 11 - 0
sckw-modules/sckw-example/pom.xml

@@ -90,4 +90,15 @@
 
 
     </dependencies>
+    <build>
+        <resources>
+            <resource>
+                <directory>src/main/java</directory>
+                <includes>
+                    <include>**/*.xml</include>
+                </includes>
+                <filtering>true</filtering>
+            </resource>
+        </resources>
+    </build>
 </project>

+ 137 - 131
sckw-modules/sckw-example/src/main/java/com/sckw/example/controller/FileApiController.java

@@ -1,131 +1,137 @@
-package com.sckw.example.controller;
-
-import com.sckw.core.web.response.HttpResult;
-import com.sckw.example.service.FileService;
-import com.sckw.file.api.dubbo.FileApiDubboService;
-import com.sckw.file.api.feign.FileApiFeignService;
-import lombok.AllArgsConstructor;
-import org.apache.dubbo.config.annotation.DubboReference;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
-import org.springframework.web.multipart.MultipartFile;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author lfdc
- * @version 1.0
- * @className FileApiController
- * @description alibaba-oss测试用例
- * z
- * @company sckw
- * @date 2023-06-02 16:06:43
- */
-@RestController
-@RequestMapping("/file")
-@AllArgsConstructor
-public class FileApiController {
-
-    @Autowired
-    private FileApiFeignService fileApiFeignService;
-
-    @DubboReference(version = "2.0.0", group = "design", check = false)
-    private FileApiDubboService fileApiDubboService;
-
-    @Autowired
-    private FileService fileService;
-
-    /**
-     * 上传文件至OSS
-     *
-     * @param file
-     * @return
-     */
-    @RequestMapping(value = "/fileUpload", method = RequestMethod.POST)
-    public HttpResult fileUpload(@RequestParam("file") MultipartFile file) {
-        //获取上传文件
-        String url = fileService.uploadFile(file);
-        return HttpResult.ok(url);
-
-    }
-
-    /**
-     * OSS下载文件/获取文件地址
-     *
-     * @return
-     */
-    @GetMapping("/fileDownload")
-    public HttpResult fileDownload() {
-        String fileName = "测试=JPEG.webp";
-        //获取上传文件
-        String url = fileService.fileDownload(fileName);
-        return HttpResult.ok(url);
-    }
-
-
-    /**
-     * 基于feign调用
-     *
-     * @param file
-     * @return
-     */
-    @RequestMapping (value = "/fileFeignUpload",method = RequestMethod.POST)
-    public HttpResult fileFeignUpload(@RequestParam("file") MultipartFile file) {
-        //example 服务 调用 file服务提供的feign接口
-        HttpResult result = fileApiFeignService.fileFeignUpload(file);
-        return result;
-    }
-
-    /**
-     * 基于feign调用
-     *
-     * @param
-     * @return
-     */
-    @RequestMapping (value = "/fileFeignDemo",method = RequestMethod.GET)
-    //@RequestParam("file") MultipartFile file
-    public String fileFeignDemo() {
-        //example 服务 调用 file服务提供的feign接口
-        return fileApiFeignService.fileFeignDemo("userName");
-    }
-
-    /**
-     * 基于feign调用
-     *
-     * @param
-     * @return
-     */
-    @RequestMapping (value = "/fileFeignDemo1",method = RequestMethod.POST)
-    public String fileFeignDemo1() {
-       Map<String, String> map = new HashMap<>();
-        map.put("123","456");
-        map.put("asd","asd");
-        return fileApiFeignService.fileFeignDemo1(map);
-    }
-
-
-    /**
-     * 基于dubbo调用
-     *
-     * @param file
-     * @return
-     */
-    @GetMapping("fileDubboUpload")
-    public HttpResult fileDubboUpload(@RequestParam("file") MultipartFile file) throws IOException {
-        // 调用 file服务提供的dubbo接口
-        //需要将文件转换成byte否则为空
-        //获取文件类型
-        String contentType = file.getContentType();
-        //获取上传文件的原始文件名
-        String oFileName = file.getOriginalFilename();
-        //把文件转化成byte[]
-        byte[] bytes = file.getBytes();
-
-        HttpResult result = fileApiDubboService.fileUpload(contentType,oFileName,bytes);
-        return result;
-    }
-
-
-}
+//package com.sckw.example.controller;
+//
+//import com.sckw.core.web.response.HttpResult;
+//import com.sckw.example.service.FileService;
+//import com.sckw.file.api.dubbo.FileApiDubboService;
+//import com.sckw.file.api.feign.FileApiFeignService;
+//import lombok.AllArgsConstructor;
+//import org.apache.dubbo.config.annotation.DubboReference;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.web.bind.annotation.*;
+//import org.springframework.web.multipart.MultipartFile;
+//
+//import java.io.IOException;
+//import java.util.HashMap;
+//import java.util.Map;
+//
+///**
+// * @author lfdc
+// * @version 1.0
+// * @className FileApiController
+// * @description alibaba-oss测试用例
+// * z
+// * @company sckw
+// * @date 2023-06-02 16:06:43
+// */
+//@RestController
+//@RequestMapping("/file")
+//@AllArgsConstructor
+//public class FileApiController {
+//
+//    @Autowired
+//    private FileApiFeignService fileApiFeignService;
+//
+//    @DubboReference(version = "2.0.0", group = "design", check = false)
+//    private FileApiDubboService fileApiDubboService;
+//
+//    @Autowired
+//    private FileService fileService;
+//
+//    /**
+//     * 上传文件至OSS
+//     *
+//     * @param file
+//     * @return
+//     */
+//    @RequestMapping(value = "/fileUpload", method = RequestMethod.POST)
+//    public HttpResult fileUpload(@RequestParam("file") MultipartFile file) {
+//        //获取上传文件
+//        String url = fileService.uploadFile(file);
+//        return HttpResult.ok(url);
+//
+//    }
+//
+//    /**
+//     * OSS下载文件/获取文件地址
+//     *
+//     * @return
+//     */
+//    @GetMapping("/fileDownload")
+//    public HttpResult fileDownload() {
+//        String fileName = "测试=JPEG.webp";
+//        //获取上传文件
+//        String url = fileService.fileDownload(fileName);
+//        return HttpResult.ok(url);
+//    }
+//
+//
+//    /**
+//     * 基于feign调用
+//     *
+//     * @param file
+//     * @return
+//     */
+//    @RequestMapping(value = "/fileFeignUpload", method = RequestMethod.POST)
+//    public HttpResult fileFeignUpload(@RequestParam("file") MultipartFile file) {
+//        //example 服务 调用 file服务提供的feign接口
+//        HttpResult result = fileApiFeignService.fileFeignUpload(file);
+//        return result;
+//    }
+//
+//    /**
+//     * 基于feign调用
+//     *
+//     * @param
+//     * @return
+//     */
+//    @RequestMapping(value = "/fileFeignDemo", method = RequestMethod.GET)
+//    //@RequestParam("file") MultipartFile file
+//    public String fileFeignDemo() {
+//        //example 服务 调用 file服务提供的feign接口
+//        return fileApiFeignService.fileFeignDemo("userName");
+//    }
+//
+//    /**
+//     * 基于feign调用
+//     *
+//     * @param
+//     * @return
+//     */
+//    @RequestMapping(value = "/fileFeignDemo1", method = RequestMethod.POST)
+//    public String fileFeignDemo1() {
+//        Map<String, String> map = new HashMap<>();
+//        map.put("123", "456");
+//        map.put("asd", "asd");
+//        return fileApiFeignService.fileFeignDemo1(map);
+//    }
+//
+//
+//    /**
+//     * 基于dubbo调用
+//     *
+//     * @param file
+//     * @return
+//     */
+//    @GetMapping("/fileDubboUpload")
+//    public HttpResult fileDubboUpload(@RequestParam("file") MultipartFile file) throws IOException {
+//        // 调用 file服务提供的dubbo接口
+//        //需要将文件转换成byte否则为空
+//        //获取文件类型
+//        String contentType = file.getContentType();
+//        //获取上传文件的原始文件名
+//        String oFileName = file.getOriginalFilename();
+//        //把文件转化成byte[]
+//        byte[] bytes = file.getBytes();
+////        BigDecimal fileSize = FileUtils.getFileSize(file, "KB");
+////        FileInfo fileInfo = new FileInf0;
+////        fileInfo.setOriginalName(oFileName);
+////        //获取文件后缀
+////        fileInfo.setFileSuffix(FilenameUtils.getExtension(oFileName));
+////        fileInfo.setFileSize(StringUtils.isBlank(fileSize) ? new BigDecimal("0") : fileSize);
+////        HttpResult result = fileApiDubboService.fileUpload(JSONObject.toJSONString(fileInfo), bytes);
+//        HttpResult result = fileApiDubboService.fileUploadTodubbo(file);
+//        return result;
+//    }
+//
+//
+//}

+ 175 - 176
sckw-modules/sckw-example/src/main/java/com/sckw/example/controller/SysUserController.java

@@ -1,176 +1,175 @@
-package com.sckw.example.controller;
-
-import cn.hutool.core.lang.UUID;
-import com.alibaba.csp.sentinel.annotation.SentinelResource;
-import com.alibaba.fastjson2.JSON;
-import com.sckw.core.model.page.PageResult;
-import com.sckw.core.web.exceptionHandler.CustomBlockExceptionHandler;
-import com.sckw.core.web.response.HttpResult;
-import com.sckw.example.model.SysUser;
-import com.sckw.example.model.TestSensitive;
-import com.sckw.example.service.SysUserService;
-import com.sckw.stream.enums.SmsCodeEnum;
-import com.sckw.stream.model.SckwMessage;
-import com.sckw.stream.model.SckwSms;
-import io.seata.spring.annotation.GlobalTransactional;
-import lombok.AllArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.redisson.api.RBucket;
-import org.redisson.api.RedissonClient;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.cloud.stream.function.StreamBridge;
-import org.springframework.web.bind.annotation.*;
-
-import javax.annotation.Resource;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-@Slf4j
-@AllArgsConstructor
-@RestController
-@RequestMapping("/")
-public class SysUserController {
-
-    @Autowired
-    SysUserService sysUserService;
-
-    @Autowired
-    RedissonClient redissonClient;
-
-    /*@Autowired
-    RedisService redisService;*/
-
-    @GetMapping("index")
-    public Object test(){
-        Map result = new HashMap();
-        result.put("user", System.currentTimeMillis());
-        result.put("datatime", System.currentTimeMillis());
-        result.put("database", "redis");
-
-        RBucket<Object> mytest = redissonClient.getBucket("mytest");
-        mytest.set("value");
-        System.out.println(mytest.get());//value
-        mytest.set("value2");
-        System.out.println(mytest.get());//value2
-        boolean b = mytest.compareAndSet("value2", result); //true
-        System.out.println(mytest.get());//value3
-        Object resultObj = mytest.get();
-
-        /*result.put("type", "spring boot");
-        redisService.setCacheMap("value2", result);
-        resultObj = redisService.getCacheMap("value2");*/
-
-        return String.valueOf(resultObj);
-    }
-
-    //@Override
-    public String getUserInfo(String account) {
-        return account + String.valueOf(new Date());
-    }
-
-    @PostMapping("findByAccount")
-    public HttpResult findByAccount(HashMap params) {
-        List<SysUser> data = sysUserService.findByAccount(params);
-        return HttpResult.ok(data);
-    }
-
-    @PostMapping("findPage")
-    public HttpResult findPage(Map<String, Object> params) {
-        PageResult pageResult = sysUserService.findPage(params);
-        return HttpResult.ok(pageResult);
-    }
-
-
-    /**
-     * 限流测试示例
-     * @return
-     */
-    //value将该方法定义为sentinel的资源,blockHandlerClass指明流控处理的类,blockHandler是流控时调用的方法。
-    //这里需要注意处理异常的方法必须是静态方法添加static, 并需要添加sentinel的异常参数BlockException。
-    @RequestMapping(value = "sentinelFlowDemo", method = RequestMethod.GET)
-    @SentinelResource(value = "sentinelFlowDemo", blockHandlerClass = CustomBlockExceptionHandler.class, blockHandler = "sentinelFlowBlock")
-    public HttpResult sentinelFlowDemo() {
-        return HttpResult.ok("sentinelFlowDemo正常返回");
-    }
-
-    /**
-     * 熔断测试示例
-     * @param id
-     * @return
-     */
-    @RequestMapping(value = "sentinelDegradeDemo", method = RequestMethod.GET)
-    @SentinelResource(value = "sentinelDegradeDemo", blockHandlerClass = SysUserController.class, blockHandler = "sentinelDegradeBlock")
-    public HttpResult sentinelDegradeDemo(@RequestParam("id") String id) {
-        if ("2".equals(id)){
-            try {
-                Thread.sleep(5000);
-            } catch (InterruptedException e) {
-                throw new RuntimeException(e);
-            }
-        }
-        return HttpResult.ok("sentinelDegradeDemo正常返回");
-    }
-
-    /**
-     * 分布式事务示例
-     * @return
-     */
-    @GlobalTransactional
-    @RequestMapping(value = "/globalTransactionalDemo", method = RequestMethod.GET)
-    public HttpResult globalTransactionalDemo() {
-        return HttpResult.ok("globalTransactionalDemo");
-    }
-
-
-
-
-
-
-    @GetMapping("/testSensitive")
-    public HttpResult testSensitive() {
-        TestSensitive testSensitive = new TestSensitive();
-        testSensitive.setIdCard("210397198608215431");
-        testSensitive.setPhone("17640125371");
-        testSensitive.setAddress("北京市朝阳区某某四合院1203室");
-        testSensitive.setEmail("17640125371@163.com");
-        testSensitive.setBankCard("6226456952351452853");
-        return HttpResult.ok(testSensitive);
-    }
-
-    @Resource
-    private StreamBridge streamBridge;
-
-    @GetMapping("/pushMesg")
-    public HttpResult pushMesg() {
-        String uuid = UUID.fastUUID().toString();
-        SckwSms sckwSms = new SckwSms();
-        sckwSms.setTelephone("17358629955");
-        sckwSms.setSignName("矿拉拉");
-        sckwSms.setTemplateCode(SmsCodeEnum.VERIFICATION_CODE);
-        sckwSms.setParams(new HashMap(){{put("code", "123456");}});
-        streamBridge.send("sckw-sms", JSON.toJSONString(sckwSms));
-
-
-        SckwMessage message = new SckwMessage();
-        //person.setName(String.valueOf(System.currentTimeMillis()));
-        message.setMsgUrl("---");
-        message.setPushType("====");
-        message.setClientId("111111111111111");
-        streamBridge.send("sckw-message", JSON.toJSONString(message));
-
-        return HttpResult.ok(uuid);
-    }
-
-    @GetMapping("/pushSms")
-    public HttpResult pushSms() {
-        TestSensitive testSensitive = new TestSensitive();
-        testSensitive.setIdCard("210397198608215431");
-        testSensitive.setPhone("17640125371");
-        testSensitive.setAddress("北京市朝阳区某某四合院1203室");
-        testSensitive.setEmail("17640125371@163.com");
-        testSensitive.setBankCard("6226456952351452853");
-        return HttpResult.ok(testSensitive);
-    }
-}
+//package com.sckw.example.controller;
+//
+//import cn.hutool.core.lang.UUID;
+//import com.alibaba.csp.sentinel.annotation.SentinelResource;
+//import com.alibaba.fastjson2.JSON;
+//import com.sckw.core.model.page.PageResult;
+//import com.sckw.core.web.exceptionHandler.CustomBlockExceptionHandler;
+//import com.sckw.core.web.response.HttpResult;
+//import com.sckw.example.model.SysUser;
+//import com.sckw.example.model.TestSensitive;
+//import com.sckw.example.service.SysUserService;
+//import com.sckw.stream.enums.SmsCodeEnum;
+//import com.sckw.stream.model.SckwMessage;
+//import com.sckw.stream.model.SckwSms;
+//import lombok.AllArgsConstructor;
+//import lombok.extern.slf4j.Slf4j;
+//import org.redisson.api.RBucket;
+//import org.redisson.api.RedissonClient;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.cloud.stream.function.StreamBridge;
+//import org.springframework.web.bind.annotation.*;
+//
+//import javax.annotation.Resource;
+//import java.util.Date;
+//import java.util.HashMap;
+//import java.util.List;
+//import java.util.Map;
+//
+//@Slf4j
+//@AllArgsConstructor
+//@RestController
+//@RequestMapping("/")
+//public class SysUserController {
+//
+//    @Autowired
+//    SysUserService sysUserService;
+//
+//    @Autowired
+//    RedissonClient redissonClient;
+//
+//    /*@Autowired
+//    RedisService redisService;*/
+//
+//    @GetMapping("index")
+//    public Object test(){
+//        Map result = new HashMap();
+//        result.put("user", System.currentTimeMillis());
+//        result.put("datatime", System.currentTimeMillis());
+//        result.put("database", "redis");
+//
+//        RBucket<Object> mytest = redissonClient.getBucket("mytest");
+//        mytest.set("value");
+//        System.out.println(mytest.get());//value
+//        mytest.set("value2");
+//        System.out.println(mytest.get());//value2
+//        boolean b = mytest.compareAndSet("value2", result); //true
+//        System.out.println(mytest.get());//value3
+//        Object resultObj = mytest.get();
+//
+//        /*result.put("type", "spring boot");
+//        redisService.setCacheMap("value2", result);
+//        resultObj = redisService.getCacheMap("value2");*/
+//
+//        return String.valueOf(resultObj);
+//    }
+//
+//    //@Override
+//    public String getUserInfo(String account) {
+//        return account + String.valueOf(new Date());
+//    }
+//
+//    @PostMapping("findByAccount")
+//    public HttpResult findByAccount(HashMap params) {
+//        List<SysUser> data = sysUserService.findByAccount(params);
+//        return HttpResult.ok(data);
+//    }
+//
+//    @PostMapping("findPage")
+//    public HttpResult findPage(Map<String, Object> params) {
+//        PageResult pageResult = sysUserService.findPage(params);
+//        return HttpResult.ok(pageResult);
+//    }
+//
+//
+//    /**
+//     * 限流测试示例
+//     * @return
+//     */
+//    //value将该方法定义为sentinel的资源,blockHandlerClass指明流控处理的类,blockHandler是流控时调用的方法。
+//    //这里需要注意处理异常的方法必须是静态方法添加static, 并需要添加sentinel的异常参数BlockException。
+//    @RequestMapping(value = "sentinelFlowDemo", method = RequestMethod.GET)
+//    @SentinelResource(value = "sentinelFlowDemo", blockHandlerClass = CustomBlockExceptionHandler.class, blockHandler = "sentinelFlowBlock")
+//    public HttpResult sentinelFlowDemo() {
+//        return HttpResult.ok("sentinelFlowDemo正常返回");
+//    }
+//
+//    /**
+//     * 熔断测试示例
+//     * @param id
+//     * @return
+//     */
+//    @RequestMapping(value = "sentinelDegradeDemo", method = RequestMethod.GET)
+//    @SentinelResource(value = "sentinelDegradeDemo", blockHandlerClass = SysUserController.class, blockHandler = "sentinelDegradeBlock")
+//    public HttpResult sentinelDegradeDemo(@RequestParam("id") String id) {
+//        if ("2".equals(id)){
+//            try {
+//                Thread.sleep(5000);
+//            } catch (InterruptedException e) {
+//                throw new RuntimeException(e);
+//            }
+//        }
+//        return HttpResult.ok("sentinelDegradeDemo正常返回");
+//    }
+//
+////    /**
+////     * 分布式事务示例
+////     * @return
+////     */
+////    @GlobalTransactional
+////    @RequestMapping(value = "/globalTransactionalDemo", method = RequestMethod.GET)
+////    public HttpResult globalTransactionalDemo() {
+////        return HttpResult.ok("globalTransactionalDemo");
+////    }
+//
+//
+//
+//
+//
+//
+//    @GetMapping("/testSensitive")
+//    public HttpResult testSensitive() {
+//        TestSensitive testSensitive = new TestSensitive();
+//        testSensitive.setIdCard("210397198608215431");
+//        testSensitive.setPhone("17640125371");
+//        testSensitive.setAddress("北京市朝阳区某某四合院1203室");
+//        testSensitive.setEmail("17640125371@163.com");
+//        testSensitive.setBankCard("6226456952351452853");
+//        return HttpResult.ok(testSensitive);
+//    }
+//
+//    @Resource
+//    private StreamBridge streamBridge;
+//
+//    @GetMapping("/pushMesg")
+//    public HttpResult pushMesg() {
+//        String uuid = UUID.fastUUID().toString();
+//        SckwSms sckwSms = new SckwSms();
+//        sckwSms.setTelephone("17358629955");
+//        sckwSms.setSignName("矿拉拉");
+//        sckwSms.setTemplateCode(SmsCodeEnum.VERIFICATION_CODE);
+//        sckwSms.setParams(new HashMap(){{put("code", "123456");}});
+//        streamBridge.send("sckw-sms", JSON.toJSONString(sckwSms));
+//
+//
+//        SckwMessage message = new SckwMessage();
+//        //person.setName(String.valueOf(System.currentTimeMillis()));
+//        message.setMsgUrl("---");
+//        message.setPushType("====");
+//        message.setClientId("111111111111111");
+//        streamBridge.send("sckw-message", JSON.toJSONString(message));
+//
+//        return HttpResult.ok(uuid);
+//    }
+//
+//    @GetMapping("/pushSms")
+//    public HttpResult pushSms() {
+//        TestSensitive testSensitive = new TestSensitive();
+//        testSensitive.setIdCard("210397198608215431");
+//        testSensitive.setPhone("17640125371");
+//        testSensitive.setAddress("北京市朝阳区某某四合院1203室");
+//        testSensitive.setEmail("17640125371@163.com");
+//        testSensitive.setBankCard("6226456952351452853");
+//        return HttpResult.ok(testSensitive);
+//    }
+//}

+ 31 - 31
sckw-modules/sckw-example/src/main/java/com/sckw/example/dao/SysUserDao.java

@@ -1,31 +1,31 @@
-package com.sckw.example.dao;
-
-import com.baomidou.dynamic.datasource.annotation.DS;
-import com.sckw.example.model.SysUser;
-import org.apache.ibatis.annotations.Mapper;
-import org.apache.ibatis.annotations.Select;
-import java.util.List;
-import java.util.Map;
-
-@Mapper
-public interface SysUserDao {
-
-    /**
-     * 账号查询用户信息
-     * @param params {account:账号, systemType:系统类别}
-     * @return
-     */
-    @DS("slave_1")
-    SysUser findByAccount(Map params);
-
-    @DS("master")
-    @Select("SELECT * FROM user limit 1")
-    List<SysUser> findUserByAccount(String account);
-
-    @DS("slave_1")
-    @Select("SELECT * FROM sys_user limit 10")
-    List<Map> findUserByAccount1(String account);
-
-    @DS("slave_1")
-    List<Map<String, Object>> findPage(Map<String, Object> params);
-}
+//package com.sckw.example.dao;
+//
+//import com.baomidou.dynamic.datasource.annotation.DS;
+//import com.sckw.example.model.SysUser;
+//import org.apache.ibatis.annotations.Mapper;
+//import org.apache.ibatis.annotations.Select;
+//import java.util.List;
+//import java.util.Map;
+//
+//@Mapper
+//public interface SysUserDao {
+//
+//    /**
+//     * 账号查询用户信息
+//     * @param params {account:账号, systemType:系统类别}
+//     * @return
+//     */
+//    @DS("slave_1")
+//    SysUser findByAccount(Map params);
+//
+//    @DS("master")
+//    @Select("SELECT * FROM user limit 1")
+//    List<SysUser> findUserByAccount(String account);
+//
+//    @DS("slave_1")
+//    @Select("SELECT * FROM sys_user limit 10")
+//    List<Map> findUserByAccount1(String account);
+//
+//    @DS("slave_1")
+//    List<Map<String, Object>> findPage(Map<String, Object> params);
+//}

+ 0 - 24
sckw-modules/sckw-example/src/main/java/com/sckw/example/dubbo/FileServiceImpl.java

@@ -1,24 +0,0 @@
-package com.sckw.example.dubbo;
-
-import com.sckw.core.web.response.HttpResult;
-import com.sckw.file.api.dubbo.FileApiDubboService;
-import org.apache.dubbo.config.annotation.DubboService;
-
-/**
- * @author lfdc
- * @version 1.0
- * @className FileServiceImpl
- * @description 实现File的dubbo实现类
- * @company sckw
- * @date 2023-06-06 10:06:31
- */
-@DubboService(group = "design", version = "2.0.0")
-public class FileServiceImpl implements FileApiDubboService {
-
-
-    @Override
-    public HttpResult fileUpload(String contentType, String oFileName, byte[] bytes) {
-        System.out.println("文件类型"+contentType+"文件名称"+oFileName+"文件输出流"+bytes);
-        return HttpResult.ok();
-    }
-}

+ 36 - 36
sckw-modules/sckw-example/src/main/java/com/sckw/example/service/SysUserService.java

@@ -1,36 +1,36 @@
-package com.sckw.example.service;
-
-import com.github.pagehelper.PageHelper;
-import com.github.pagehelper.PageInfo;
-import com.sckw.core.model.page.PageHelperUtil;
-import com.sckw.core.model.page.PageResult;
-import com.sckw.example.dao.SysUserDao;
-import com.sckw.example.model.SysUser;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-@Slf4j
-@Service
-public class SysUserService {
-
-    @Autowired
-    SysUserDao sysUserDao;
-
-    public List<SysUser> findByAccount(HashMap params) {
-        SysUser sysUser = sysUserDao.findByAccount(params);
-        return new ArrayList<>(){{add(sysUser);}};
-    }
-
-    public PageResult findPage(Map<String, Object> params) {
-        // 设置分页参数
-        PageHelper.startPage(PageResult.getPageNum(params), PageResult.getPageSize(params));
-        List<Map<String, Object>> list = sysUserDao.findPage(params);
-        PageResult pageResult = PageHelperUtil.getPageResult(new PageInfo(list));
-        return pageResult;
-    }
-}
+//package com.sckw.example.service;
+//
+//import com.github.pagehelper.PageHelper;
+//import com.github.pagehelper.PageInfo;
+//import com.sckw.core.model.page.PageHelperUtil;
+//import com.sckw.core.model.page.PageResult;
+//import com.sckw.example.dao.SysUserDao;
+//import com.sckw.example.model.SysUser;
+//import lombok.extern.slf4j.Slf4j;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.stereotype.Service;
+//import java.util.ArrayList;
+//import java.util.HashMap;
+//import java.util.List;
+//import java.util.Map;
+//
+//@Slf4j
+//@Service
+//public class SysUserService {
+//
+//    @Autowired
+//    SysUserDao sysUserDao;
+//
+//    public List<SysUser> findByAccount(HashMap params) {
+//        SysUser sysUser = sysUserDao.findByAccount(params);
+//        return new ArrayList<>(){{add(sysUser);}};
+//    }
+//
+//    public PageResult findPage(Map<String, Object> params) {
+//        // 设置分页参数
+//        PageHelper.startPage(PageResult.getPageNum(params), PageResult.getPageSize(params));
+//        List<Map<String, Object>> list = sysUserDao.findPage(params);
+//        PageResult pageResult = PageHelperUtil.getPageResult(new PageInfo(list));
+//        return pageResult;
+//    }
+//}

+ 30 - 19
sckw-modules/sckw-example/src/main/resources/bootstrap-dev.yml

@@ -23,6 +23,7 @@ spring:
 #        weight: 100
       config:
         # 配置中心地址
+#        server-addr: 47.108.162.14:8848
         server-addr: 127.0.0.1:8848
         # 配置文件格式
         file-extension: yaml
@@ -61,7 +62,7 @@ spring:
         port: 8719  #默认8719端口,如果被占用会向上扫描。
         #控制台地址
 #        dashboard: 47.108.162.14:19527
-        dashboard: 127.0.0.1:9527
+        dashboard: 127.0.0.1:19527
       log:
         #日志路径
         dir: logs/sentinel
@@ -97,26 +98,35 @@ spring:
             rule-type: degrade
       #取消慢加载
       eager: true
-
-#seata:
-#  # seata 服务分组,要与服务端nacos-config.txt中service.vgroup_mapping的后缀对应
-#  tx-service-group: my_test_tx_group
-#  registry:
-#    # 指定nacos作为注册中心
-#    type: nacos
-#    nacos:
-#      server-addr: 127.0.0.1:8848
-#      namespace: ""
+  datasource:
+    dynamic:
+      seata: true
+seata:
+  # seata 服务分组,要与服务端nacos-config.txt中service.vgroup_mapping的后缀对应
+  tx-service-group: example-seata-service-group
+  service:
+    vgroup-mapping:
+      example-seata-service-group: default
+  registry:
+    # 指定nacos作为注册中心
+    type: nacos
+    nacos:
+      server-addr: 127.0.0.1:8848
+#      server-addr: 47.108.162.14:8848
+      namespace: sckw-service-platform-dev
 #      group: SEATA_GROUP
-#
-#  config:
-#    # 指定nacos作为配置中心
-#    type: nacos
-#    nacos:
-#      server-addr: 127.0.0.1:8848
-##      namespace: "54433b62-df64-40f1-9527-c907219fc17f"
-#      namespace: sckw-service-platform-dev
+      group: sckw-service-platform
+
+  config:
+    # 指定nacos作为配置中心
+    type: nacos
+    nacos:
+      server-addr: 127.0.0.1:8848
+#      server-addr: 47.108.162.14:8848
+      namespace: sckw-service-platform-dev
 #      group: SEATA_GROUP
+      group: sckw-service-platform
+  application-id: ${spring.application.name}
 # 支持feign对sentinel支持
 #feign:
 #  sentinel:
@@ -129,6 +139,7 @@ dubbo:
   protocol:
     name: dubbo
     port: -1
+    prefer-serialization: java
   registry:
     # 配置dubbo的注册中心为nacos
     address: nacos://${spring.cloud.nacos.discovery.server-addr}

+ 150 - 0
sckw-modules/sckw-example/src/main/resources/bootstrap-local.yml

@@ -0,0 +1,150 @@
+spring:
+  rabbitmq:
+    username: admin
+    password: admin
+    host: 10.10.10.138
+    port: 5672
+    virtual-host: /
+  cloud:
+    nacos:
+      discovery:
+        # 服务注册地址
+        #        server-addr: 47.108.162.14:8848
+        server-addr: 127.0.0.1:8848
+        # 命名空间
+        namespace: sckw-service-platform-dev
+        # nacos用户名
+        username: nacos
+        # nacos密码
+        password: nacos
+        # 共享配置
+        group: sckw-service-platform
+        # 权重 1-100 数值越大权重越大分配的流量就越大,通常结合权重负载均衡策略
+      #        weight: 100
+      config:
+        # 配置中心地址
+        #        server-addr: 47.108.162.14:8848
+        server-addr: 127.0.0.1:8848
+        # 配置文件格式
+        file-extension: yaml
+        # 命名空间
+        namespace: sckw-service-platform-dev
+        # 共享配置
+        group: sckw-service-platform
+        enabled: true
+    stream:
+      bindings:
+        sckwSms-out-0:
+          destination: sckw-sms
+          content-type: application/json
+          default-binder: defaultRabbit
+          group: sckw
+        sckwMessage-out-0:
+          destination: sckw-message
+          content-type: application/json
+          default-binder: defaultRabbit
+          group: sckw
+      binders:
+        defaultRabbit:
+          type: rabbit
+          environment:
+            spring:
+              rabbitmq:
+                virtual-host: /
+                host: 39.104.134.114
+                port: 5672
+                username: wph
+                password: Yy123...
+    # sentinel降级配置
+    sentinel:
+      transport:
+        client-ip: ${spring.cloud.client.ip-address} # 获取本机IP地址
+        port: 8719  #默认8719端口,如果被占用会向上扫描。
+        #控制台地址
+        #dashboard: 47.108.162.14:19527
+        dashboard: 127.0.0.1:19527
+      log:
+        #日志路径
+        dir: logs/sentinel
+        # 默认将调用链路收敛,导致链路流控效果无效
+        web-context-unify: false
+        #持久化nacos配置中
+      datasource:
+        #sentinel-rule: # 唯一名称可自定义
+        #限流
+        flow:
+          nacos:
+            # 设置Nacos的连接地址、命名空间和Group ID
+            namespace:  sckw-service-platform-dev
+            server-addr:  ${spring.cloud.nacos.discovery.server-addr}
+            # username: ${spring.cloud.nacos.discovery.username}
+            # password: ${spring.cloud.nacos.discovery.password}
+            # 设置Nacos中配置文件的命名规则
+            # data-id:  ${spring.application.name}-sentinel-flow-rules
+            data-id:  sckw-example-sentinel-flow-rules
+            group-id: SENTINEL_GROUP
+            data-type: json
+            # 必填的重要字段,指定当前规则类型是"限流"
+            rule-type: flow
+        #熔断
+        degrade:
+          nacos:
+            namespace:  sckw-service-platform-dev
+            server-addr: ${spring.cloud.nacos.discovery.server-addr}
+            #data-id: ${spring.application.name}-sentinel-degrade-rules
+            data-id: sckw-example-sentinel-degrade-rules
+            group-id: SENTINEL_GROUP
+            #熔断
+            rule-type: degrade
+      #取消慢加载
+      eager: true
+  datasource:
+    dynamic:
+      seata: true
+seata:
+  # seata 服务分组,要与服务端nacos-config.txt中service.vgroup_mapping的后缀对应
+  # 事务分组名称,要和服务端对应
+  tx-service-group: example-seata-group
+  service:
+    vgroup-mapping:
+      # key是事务分组名称 value要和服务端的机房名称保持一致
+      example-seata-group: default
+  registry:
+    # 指定nacos作为注册中心
+    type: nacos
+    nacos:
+      server-addr: ${spring.cloud.nacos.discovery.server-addr}
+      #server-addr: 47.108.162.14:8848
+      namespace: ${spring.cloud.nacos.discovery.namespace}
+      #      group: SEATA_GROUP
+      group: ${spring.cloud.nacos.discovery.group}
+  config:
+    # 指定nacos作为配置中心
+    type: nacos
+    nacos:
+      server-addr: ${spring.cloud.nacos.discovery.server-addr}
+      #server-addr: 47.108.162.14:8848
+      namespace: ${spring.cloud.nacos.discovery.namespace}
+      group: ${spring.cloud.nacos.discovery.group}
+  application-id: ${spring.application.name}
+#  application-id: sckw-seata-file
+# 支持feign对sentinel支持
+#feign:
+#  sentinel:
+#    enabled: true
+
+dubbo:
+  application:
+    # 此处没有延用spring.application.name是因为当前项目本身也会注册到nacos中,如果dubbo也延用相同的名称,在nacos服务里会看到注册的producer-server服务数为2
+    name: example-dubbo-server
+  protocol:
+    name: dubbo
+    port: -1
+    prefer-serialization: java
+  registry:
+    # 配置dubbo的注册中心为nacos
+    address: nacos://${spring.cloud.nacos.discovery.server-addr}
+    group: ${spring.cloud.nacos.config.group}
+    protocol: nacos
+    #use-as-config-center: false
+    #use-as-metadata-center: false

+ 1 - 1
sckw-modules/sckw-example/src/main/resources/bootstrap.yml

@@ -5,6 +5,6 @@ spring:
   application:
     name: sckw-example
   profiles:
-    active: ${DEPLOY_MODE:dev}
+    active: ${DEPLOY_MODE:local}
   main:
     allow-bean-definition-overriding: true

+ 51 - 51
sckw-modules/sckw-example/src/main/resources/mapper/SysUserDao.xml

@@ -1,55 +1,55 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.sckw.example.dao.SysUserDao">
-  <resultMap id="BaseResultMap" type="com.sckw.example.model.SysUser">
-    <result column="id" property="id" />
-    <result column="system_type" property="systemType" />
-    <result column="account" property="account" />
-    <result column="password" property="password" />
-    <result column="name" property="name" />
-    <result column="telephone" property="telephone" />
-    <result column="photo" property="photo" />
-    <result column="email" property="email" />
-    <result column="is_main" property="isMain" />
-    <result column="remark" property="remark" />
-    <result column="status" property="status" />
-    <result column="create_by" property="createBy" />
-    <result column="create_time" property="createTime" />
-    <result column="update_by" property="updateBy" />
-    <result column="update_time" property="updateTime" />
-    <result column="del_flag" property="delFlag" />
-  </resultMap>
+<!--<?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.sckw.example.dao.SysUserDao">-->
+<!--  <resultMap id="BaseResultMap" type="com.sckw.example.model.SysUser">-->
+<!--    <result column="id" property="id" />-->
+<!--    <result column="system_type" property="systemType" />-->
+<!--    <result column="account" property="account" />-->
+<!--    <result column="password" property="password" />-->
+<!--    <result column="name" property="name" />-->
+<!--    <result column="telephone" property="telephone" />-->
+<!--    <result column="photo" property="photo" />-->
+<!--    <result column="email" property="email" />-->
+<!--    <result column="is_main" property="isMain" />-->
+<!--    <result column="remark" property="remark" />-->
+<!--    <result column="status" property="status" />-->
+<!--    <result column="create_by" property="createBy" />-->
+<!--    <result column="create_time" property="createTime" />-->
+<!--    <result column="update_by" property="updateBy" />-->
+<!--    <result column="update_time" property="updateTime" />-->
+<!--    <result column="del_flag" property="delFlag" />-->
+<!--  </resultMap>-->
 
-  <select id="findByAccount" parameterType="java.util.Map" resultType="com.sckw.example.model.SysUser">
-    SELECT
-      id, system_type systemType, account, password, name, telephone, photo, email, is_main isMain,
-      remark, status, create_by createBy, create_time createTime, update_by updateBy, update_time updateTime
-    FROM
-    sys_user
-    where del_flag = 0
-    <if test="systemType != null and systemType != ''">
-      and system_type = #{systemType, jdbcType=VARCHAR}
-    </if>
-    <if test="account != null and account != ''">
-      and account = #{account, jdbcType=VARCHAR}
-    </if>
-  </select>
+<!--  <select id="findByAccount" parameterType="java.util.Map" resultType="com.sckw.example.model.SysUser">-->
+<!--    SELECT-->
+<!--      id, system_type systemType, account, password, name, telephone, photo, email, is_main isMain,-->
+<!--      remark, status, create_by createBy, create_time createTime, update_by updateBy, update_time updateTime-->
+<!--    FROM-->
+<!--    sys_user-->
+<!--    where del_flag = 0-->
+<!--    <if test="systemType != null and systemType != ''">-->
+<!--      and system_type = #{systemType, jdbcType=VARCHAR}-->
+<!--    </if>-->
+<!--    <if test="account != null and account != ''">-->
+<!--      and account = #{account, jdbcType=VARCHAR}-->
+<!--    </if>-->
+<!--  </select>-->
 
-  <select id="findPage" resultType="java.util.Map" parameterType="java.util.Map" >
-    SELECT
-    id, system_type systemType, account, password, name, telephone, photo, email, is_main isMain,
-    remark, status, create_by createBy, create_time createTime, update_by updateBy, update_time updateTime
-    FROM
-    sys_user u
-    where del_flag = 0
-    <if test="systemType != null and systemType != ''">
-      and d.system_type = #{systemType, jdbcType=VARCHAR}
-    </if>
-    <if test="account != null and account != ''">
-      and account = #{account, jdbcType=VARCHAR}
-    </if>
-    ORDER BY create_time desc
-  </select>
+<!--  <select id="findPage" resultType="java.util.Map" parameterType="java.util.Map" >-->
+<!--    SELECT-->
+<!--    id, system_type systemType, account, password, name, telephone, photo, email, is_main isMain,-->
+<!--    remark, status, create_by createBy, create_time createTime, update_by updateBy, update_time updateTime-->
+<!--    FROM-->
+<!--    sys_user u-->
+<!--    where del_flag = 0-->
+<!--    <if test="systemType != null and systemType != ''">-->
+<!--      and d.system_type = #{systemType, jdbcType=VARCHAR}-->
+<!--    </if>-->
+<!--    <if test="account != null and account != ''">-->
+<!--      and account = #{account, jdbcType=VARCHAR}-->
+<!--    </if>-->
+<!--    ORDER BY create_time desc-->
+<!--  </select>-->
 
 
-</mapper>
+<!--</mapper>-->

+ 27 - 10
sckw-modules/sckw-file/pom.xml

@@ -34,16 +34,21 @@
             <artifactId>sckw-common-core</artifactId>
             <version>1.0.0</version>
         </dependency>
-<!--        <dependency>-->
-<!--            <groupId>com.sckw</groupId>-->
-<!--            <artifactId>sckw-common-datasource</artifactId>-->
-<!--            <version>1.0.0</version>-->
-<!--        </dependency>-->
-<!--        <dependency>-->
-<!--            <groupId>com.sckw</groupId>-->
-<!--            <artifactId>sckw-common-redis</artifactId>-->
-<!--            <version>1.0.0</version>-->
-<!--        </dependency>-->
+        <dependency>
+            <groupId>com.sckw</groupId>
+            <artifactId>sckw-common-datasource</artifactId>
+            <version>1.0.0</version>
+        </dependency>
+        <dependency>
+            <groupId>com.sckw</groupId>
+            <artifactId>sckw-common-redis</artifactId>
+            <version>1.0.0</version>
+        </dependency>
+        <dependency>
+            <groupId>com.sckw</groupId>
+            <artifactId>sckw-common-excel</artifactId>
+            <version>1.0.0</version>
+        </dependency>
 
         <dependency>
             <groupId>com.sckw</groupId>
@@ -87,6 +92,18 @@
             <groupId>org.springframework.cloud</groupId>
             <artifactId>spring-cloud-starter-bootstrap</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>easyexcel</artifactId>
+            <version>3.0.5</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.sckw</groupId>
+            <artifactId>sckw-common-excel</artifactId>
+            <version>1.0.0</version>
+            <scope>compile</scope>
+        </dependency>
     </dependencies>
 
 </project>

+ 0 - 33
sckw-modules/sckw-file/src/main/java/com/sckw/file/FileApplication.java

@@ -1,33 +0,0 @@
-package com.sckw.file;
-
-
-import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
-import org.springframework.cloud.openfeign.EnableFeignClients;
-
-/**
- * @author lfdc
- * @version 1.0
- * @className FileApplication
- * @description 文件上传下载启动类
- * @company sckw
- * @date 2023-06-02 17:06:43
- */
-@EnableDubbo
-@EnableFeignClients({"com.sckw.*.api.feign"})
-@EnableDiscoveryClient
-@SpringBootApplication
-public class FileApplication {
-
-    public static void main(String[] args) {
-        // 关闭nacos日志
-        System.setProperty("nacos.logging.default.config.enabled", "false");
-        try {
-            SpringApplication.run(FileApplication.class, args);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-}

+ 11 - 9
sckw-modules/sckw-file/src/main/java/com/sckw/file/common/enums/FileEnum.java

@@ -29,15 +29,17 @@ public enum FileEnum {
     /**
      * 文件存储地址
      */
-    DOCUMENT_ADDRESS("5","/excel", "文件存储地址"),;
-//    /**
-//     * 腾讯云的 OSS
-//     */
-//    TENCENT(4, RegionTencent.values()),
-//    /**
-//     * 百度云的OSS
-//     */
-//    BAIDU(5, RegionBaiDu.values()),
+    DOCUMENT_ADDRESS("5","/excel", "文件存储地址"),
+
+    /**
+     * 文件存储方式-上传oss
+     */
+    FILE_STORE_TYPE_OSS("OSS","OSS","上传OSS"),
+    /**
+     文件存储方式-上传七牛云
+     *
+     */
+    FILE_STORE_TYPE_ALIYUN("kodo","qiniuyun","上传七牛云");
 
     private final String fileType;
     private final String fileAddress;

+ 0 - 108
sckw-modules/sckw-file/src/main/java/com/sckw/file/controller/FileApiController.java

@@ -1,108 +0,0 @@
-package com.sckw.file.controller;
-
-import com.sckw.core.web.response.HttpResult;
-import com.sckw.file.service.FileService;
-import lombok.AllArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
-import org.springframework.web.multipart.MultipartFile;
-
-import java.util.Map;
-
-/**
- * @author lfdc
- * @version 1.0
- * @className FileApiController
- * @description alibaba-oss测试用例
- *
- * @company sckw
- * @date 2023-06-02 16:06:43
- */
-@Slf4j
-@RestController
-@RequestMapping("/file")
-@AllArgsConstructor
-public class FileApiController {
-
-    @Autowired
-    private FileService fileService;
-
-    /**
-     * 上传文件至OSS
-     *
-     * @param file
-     * @return
-     */
-    @RequestMapping(value = "/fileUpload", method = RequestMethod.POST)
-    public HttpResult fileUpload(@RequestParam("file") MultipartFile file) {
-        //获取上传文件
-//        String url = fileService.uploadFile(file);
-        return fileService.uploadFile(file);
-
-    }
-
-    /**
-     * feign接收上传文件至OSS
-     *
-     * @param file
-     * @return
-     */
-    @RequestMapping(value = "/fileFeignUpload", method = RequestMethod.POST)
-    public HttpResult fileFeignUpload(@RequestParam("file") MultipartFile file) {
-        //获取上传文件
-//        String url = fileService.uploadFile(file);
-        return fileService.uploadFile(file);
-
-    }
-
-    /**
-     * 上传文件至OSS
-     *
-     * @param file
-     * @return
-     */
-    @RequestMapping(value = "/fileUploadList", method = RequestMethod.POST)
-    public HttpResult uploadFileList(@RequestParam("file") MultipartFile[] file) {
-        //获取上传文件
-//        String url = fileService.uploadFile(file);
-        return fileService.uploadFileList(file);
-
-    }
-
-    /**
-     * OSS下载文件/获取文件地址
-     * @return
-     */
-    @GetMapping("/fileDownload")
-    public HttpResult fileDownload() {
-//        String fileName = "https://kaiwu-saas.oss-cn-chengdu.aliyuncs.com/kll/uploads/20230605/146288830649995264测试=JPEG.webp";
-//        String fileName = "https://kaiwu-saas.oss-cn-chengdu.aliyuncs.com/kll/uploads/20230605/146325493677821952598454132.jpg";
-        String fileName = "https://kaiwu-saas.oss-cn-chengdu.aliyuncs.com/kll/uploads/20230605/14633197602917990420230605demo.txt";
-        //获取上传文件
-        fileService.fileDownload(fileName);
-        return HttpResult.ok();
-    }
-
-    /**
-     * file-feign-demo
-     * @param userName
-     * @return
-     */
-    @GetMapping(value = "/fileFeignDemo")
-    public HttpResult fileFeignDemo(@RequestParam("userName") String userName) {
-        return HttpResult.ok(userName);
-    }
-
-
-    /**
-     * file-feign-demo1
-     * @param map
-     * @return
-     */
-    @RequestMapping(value = "fileFeignDemo1",method = RequestMethod.POST)
-    public HttpResult fileFeignDemo1(@RequestBody Map<String, String> map) {
-        return HttpResult.ok(map);
-    }
-
-}

+ 48 - 0
sckw-modules/sckw-file/src/main/java/com/sckw/file/dao/KwsFileInfoDao.java

@@ -0,0 +1,48 @@
+package com.sckw.file.dao;
+
+import com.sckw.file.model.FileInfo;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author lfdc
+ * @version 1.0
+ * @className KwsFileInfoDao
+ * @description
+ * @company sckw
+ * @date 2023-06-12 17:06:00
+ */
+@Mapper
+public interface KwsFileInfoDao {
+
+    /**
+     * 新增
+     * @param record
+     * @return
+     */
+    int insert(FileInfo record);
+
+    /**
+     * 更新
+     * @param record
+     * @return
+     */
+    int update(FileInfo record);
+
+    /**
+     * 详情查询
+     * @param id
+     * @return
+     */
+    FileInfo selectByKey(Long id);
+
+    /**
+     * 查询
+     * @param params
+     * @return
+     * @throws Exception
+     */
+    List<FileInfo> findList(Map<String, Object> params);
+}

+ 89 - 0
sckw-modules/sckw-file/src/main/java/com/sckw/file/model/FileInfo.java

@@ -0,0 +1,89 @@
+package com.sckw.file.model;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+/**
+ * @author lfdc
+ * @version 1.0
+ * @className KwfFileInfo
+ * @description 文件do
+ * @company sckw
+ * @date 2023-06-08 15:06:24
+ */
+@Getter
+@Setter
+@ToString
+//@Data
+public class FileInfo /**extends BaseModel*/ {
+
+    private static final long serialVersionUID = 8295075842951977226L;
+
+    private Long id;
+    /**
+     * 文件存储方式(OSS)
+     */
+    private String type;
+
+    /**
+     * 文件原名称
+     */
+    private String originalName;
+
+    /**
+     * 文件新名称
+     */
+    private String fileName;
+
+    /**
+     * 文件名md5加密
+     */
+    private String md5;
+
+    /**
+     * 文件后缀
+     */
+    private String fileSuffix;
+
+    /**
+     * 文件大小(kb)
+     */
+    private BigDecimal fileSize;
+    /**
+     * 文件服务器存储相对路径
+     */
+    private String filePath;
+    /**
+     * 备注
+     */
+    private String remark;
+    /**
+     * 状态:0正常/1锁定
+     */
+    private String status = "0";
+    /**
+     * 创建人
+     */
+    private String createBy;
+    /**
+     * 创建时间
+     */
+    private LocalDateTime createTime;
+    /**
+     * 更新人
+     */
+    private String updateBy;
+    /**
+     * 更新时间
+     */
+    private LocalDateTime updateTime;
+    /**
+     * 删除标识(0正常/1删除)
+     */
+    private Integer delFlag = 0;
+
+}

+ 0 - 129
sckw-modules/sckw-file/src/main/java/com/sckw/file/service/FileService.java

@@ -1,129 +0,0 @@
-package com.sckw.file.service;
-
-
-import com.sckw.core.utils.StringUtils;
-import com.sckw.core.web.constant.HttpStatus;
-import com.sckw.core.web.response.HttpResult;
-import com.sckw.file.common.enums.FileEnum;
-import com.sckw.file.utils.FileUtils;
-import jakarta.servlet.http.HttpServletResponse;
-import org.springframework.scheduling.annotation.Async;
-import org.springframework.stereotype.Service;
-import org.springframework.util.ObjectUtils;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.context.request.RequestContextHolder;
-import org.springframework.web.context.request.ServletRequestAttributes;
-import org.springframework.web.multipart.MultipartFile;
-
-import java.util.*;
-
-
-/**
- * @author lfdc
- * @version 1.0
- * @className FileService
- * @description 文件上传下载service
- * @company sckw
- * @date 2023-06-02 16:06:46
- */
-@Service
-public class FileService {
-    /**
-     * 上传文件至OSS
-     *
-     * @param file
-     * @return
-     */
-    public HttpResult uploadFile(@RequestParam("file") MultipartFile file) {
-        HttpResult result = new HttpResult();
-        List<Map<String,Object>> resultList=new ArrayList<>();
-        result.setCode(HttpStatus.SUCCESS_CODE);
-        boolean isEmpty = file.isEmpty();
-        if (isEmpty) {
-            result.setCode(HttpStatus.GLOBAL_EXCEPTION_CODE);
-            result.setMsg("上传请选择文件");
-        }
-        //文件大小
-        String fileSize = FileUtils.getFileSize(file);
-        //文件名称
-        String originalFilename = file.getOriginalFilename();
-        String url = FileUtils.uploadFile(file, FileEnum.DOCUMENT_ADDRESS);
-        //上传至oss文件地址
-        if (StringUtils.isNotBlank(url)){
-            String oosUrl = url;
-            result.setCode(HttpStatus.SUCCESS_CODE);
-            result.setMsg("上传成功");
-
-            Map<String, Object> map = new HashMap<>();
-            map.put("fileKey",url);
-            map.put("fileName",originalFilename);
-            resultList.add(map);
-            result.setData(resultList);
-        }else {
-            result.setCode(HttpStatus.GLOBAL_EXCEPTION_CODE);
-            result.setMsg("上传请选择文件");
-        }
-        return result;
-    }
-
-
-    /**
-     * 批量上传文件至OSS
-     *
-     * @param file
-     * @return
-     */
-    @Async
-    public HttpResult uploadFileList( MultipartFile[] file) {
-        HttpResult result = new HttpResult();
-        List<Map<String, Object>> resultList = new ArrayList<>();
-        if (!ObjectUtils.isEmpty(file) && file.length > 0) {
-            List<MultipartFile> multipartFiles = Arrays.asList(file);
-            for (MultipartFile multipartFile : multipartFiles) {
-                Map<String, Object> map = new HashMap<>();
-                //文件大小
-                String fileSize = FileUtils.getFileSize(multipartFile);
-                //文件名称
-                String originalFilename = multipartFile.getOriginalFilename();
-                map.put("code", HttpStatus.SUCCESS_CODE);
-                map.put("fileName", originalFilename);
-                map.put("message", HttpStatus.SUCCESS_MESSAGE);
-                String url = null;
-                //上传文件是否成功
-                try {
-                    url = FileUtils.uploadFile(multipartFile, FileEnum.DOCUMENT_ADDRESS);
-                } catch (Exception e) {
-                    map.put("code", HttpStatus.GLOBAL_EXCEPTION_CODE);
-                    map.put("fileName", originalFilename);
-                    map.put("message", e);
-                }
-                if (StringUtils.isBlank(url)) {
-                    map.put("code", HttpStatus.GLOBAL_EXCEPTION_CODE);
-                    map.put("fileName", originalFilename);
-                    map.put("message", HttpStatus.SUCCESS_MESSAGE);
-                }
-                //上传至oss文件地址
-                String oosUrl = url;
-                resultList.add(map);
-            }
-        } else {
-            result.setCode(HttpStatus.GLOBAL_EXCEPTION_CODE);
-            result.setMsg("上传选择文件为空");
-        }
-        result.setData(resultList);
-        return result;
-    }
-
-
-    /**
-     * OSS下载文件/获取文件地址
-     *
-     * @return
-     */
-    public void fileDownload(String fileName) {
-        HttpServletResponse response = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse();
-//        FileUtils.downloadByUrl(response,fileName);
-        FileUtils.downOSSFile(fileName,response);
-//        FileUtils.downloadByFileName(fileName);
-    }
-}

+ 246 - 7
sckw-modules/sckw-file/src/main/java/com/sckw/file/utils/FileUtils.java

@@ -1,29 +1,31 @@
 package com.sckw.file.utils;
 
 import cn.hutool.core.date.DateTime;
-import com.aliyun.oss.ClientException;
-import com.aliyun.oss.OSS;
-import com.aliyun.oss.OSSClientBuilder;
-import com.aliyun.oss.OSSException;
+import com.aliyun.oss.*;
 import com.aliyun.oss.model.*;
 import com.sckw.core.utils.IdWorker;
 import com.sckw.core.utils.PasswordUtils;
 import com.sckw.core.utils.StringUtils;
+import com.sckw.excel.common.NumberConstant;
 import com.sckw.file.common.enums.AliyunOssFileTypeEnum;
 import com.sckw.file.common.enums.FileEnum;
 import jakarta.annotation.PostConstruct;
 import jakarta.servlet.http.HttpServletResponse;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.io.FilenameUtils;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.stereotype.Component;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.io.*;
+import java.math.BigDecimal;
 import java.net.URL;
 import java.net.URLEncoder;
 import java.text.DecimalFormat;
 import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * @author lfdc
@@ -87,6 +89,69 @@ public class FileUtils {
         bucketName = this.oss_bucketName;
     }
 
+    /**
+     * 获取指定文件或文件夹的后缀名
+     * @param fileName 文件名称
+     * @return
+     */
+    public static String getFileSuffix(String fileName) {
+        return fileName.substring(fileName.lastIndexOf("."));//例如:abc.png  截取后:.png
+    }
+
+
+    /**
+     * 文件上传
+     *
+     * @param file     文件
+     * @param fileEnum 上传使用的枚举
+     * @return
+     */
+    public static Map<String, String> uploadFileByInfo(MultipartFile file, FileEnum fileEnum) {
+        Map<String, String> infoMap = new HashMap<>();
+        try {
+            //创建OSSClient实例
+            defalutOSS();
+            OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
+            //容器不存在,就创建
+            if (!ossClient.doesBucketExist(bucketName)) {
+                ossClient.createBucket(bucketName);
+                CreateBucketRequest createBucketRequest = new CreateBucketRequest(bucketName);
+                createBucketRequest.setCannedACL(CannedAccessControlList.PublicRead);
+                ossClient.createBucket(createBucketRequest);
+            }
+            //上传文件流
+            InputStream inputStream = file.getInputStream();
+            String fileName = FilenameUtils.getBaseName(file.getOriginalFilename());
+            //生成随机唯一值,使用uuid,添加到文件名称里面 改成使用加密
+//            fileName = PasswordUtils.md5(fileName);
+            fileName = PasswordUtils.md5(fileName);
+            String fileSuffix = FileUtils.getFileSuffix(file.getOriginalFilename());
+            //不带后缀
+            infoMap.put("fileMd5", fileName);
+            infoMap.put("fileName", fileName+fileSuffix);
+            //按照当前日期,创建文件夹,上传到创建文件夹里面
+            //2021/02/02/01.jpg
+            String timeUrl = new DateTime().toString("yyyyMMdd");
+            fileName = timeUrl + "/" + fileName;
+            String filePath = BASE_DIR + fileName+fileSuffix;
+            //调用方法实现上传
+            ossClient.putObject(bucketName, filePath, inputStream);
+            //上传后的文件地址
+//            String url1 = getUrl(ossClient, bucketName, filePath);
+            //关闭OSSClient。
+            ossClient.shutdown();
+            //上传之后文件路径
+            //https://yygh-atguigu.oss-cn-beijing.aliyuncs.com/01.jpg
+            String url = "https://" + bucketName + "." + endpoint + "/" + filePath;
+            //返回 上传文件地址
+            infoMap.put("filePath", url);
+        } catch (IOException e) {
+            e.printStackTrace();
+            log.error("oss-upload-file-error:{}", e.getMessage(), e);
+           throw new RuntimeException("oss-upload-file-error:"+e.getMessage());
+        }
+        return infoMap;
+    }
 
     /**
      * 上传文件
@@ -179,6 +244,35 @@ public class FileUtils {
         return fileSizeString;
     }
 
+    /**
+     * 获取文件上传大小
+     *
+     * @param file
+     * @return
+     */
+    public static BigDecimal getFileSize(MultipartFile file, String type) {
+        long size = file.getSize();
+//        DecimalFormat df = new DecimalFormat("#.00");
+        BigDecimal bigDecimal = new BigDecimal(NumberConstant.ZERO);
+        switch (type) {
+            case "B":
+                bigDecimal = new BigDecimal((double) size);
+                break;
+            case "KB":
+                bigDecimal = new BigDecimal((double) size / 1024);
+                break;
+            case "MB":
+                bigDecimal = new BigDecimal((double) size / 1048576);
+                break;
+            case "GB":
+                bigDecimal = new BigDecimal((double) size / 1073741824);
+                break;
+            default:
+                throw new RuntimeException("file size error");
+        }
+        return bigDecimal;
+    }
+
     /**
      * 获得阿里云OSS客户端对象
      *
@@ -259,7 +353,8 @@ public class FileUtils {
      * 通过文件名字下载
      *
      * @param response response
-     * @param fileName 文件名字,带后缀,例子:postman.txt 文件全路径 https://kaiwu-saas.oss-cn-chengdu.aliyuncs.com/kll/uploads/20230605/146325493677821952598454132.txt
+     * @param fileName 文件名字,带后缀,例子:postman.txt
+     *                 文件全路径 https://kaiwu-saas.oss-cn-chengdu.aliyuncs.com/kll/uploads/20230605/146325493677821952598454132.txt
      */
     public static void downloadByFileName(HttpServletResponse response, String fileName) {
         defalutOSS();
@@ -268,7 +363,7 @@ public class FileUtils {
         String contentType = ossObject.getObjectMetadata().getContentType();
         String contentType1 = getContentType(fileName);
         System.out.println("contentType:" + contentType);
-        System.out.println("contentType1:" + contentType1);
+//        System.out.println("contentType1:" + contentType1);
         //设置响应内容类型,当设置了ContentType为“image/jpg”时,浏览器可以直接显示图片;
         response.setContentType(contentType);
         BufferedInputStream in = new BufferedInputStream(ossObject.getObjectContent());
@@ -468,7 +563,7 @@ public class FileUtils {
      */
     public static String getUrl(OSS ossClient, String bucketName, String key) {
         //设置URl过期时间为99年:3600L*1000*24*365*99
-        Date expiration = new Date(new Date().getTime() + 3600l * 1000 * 24 * 365 * 99);
+        Date expiration = new Date( System.currentTimeMillis()+ 3600L * 1000 * 24 * 365 * 99);
         GeneratePresignedUrlRequest generatePresignedUrlRequest = new GeneratePresignedUrlRequest(bucketName, key);
         generatePresignedUrlRequest.setExpiration(expiration);
         URL url = ossClient.generatePresignedUrl(generatePresignedUrlRequest);
@@ -570,6 +665,40 @@ public class FileUtils {
         downloadByFileName(response, url);
     }
 
+    /**
+     * @Title:downloadToFile
+     * @Description: 下载文件到本地
+     * @param @param ossFilePath oss上的文件路径(全路径)
+     * @param @param newFilePath 本地文件路径 (全路径)
+     * @return void    返回类型
+     */
+    public static void downloadToFile(String endPoint, String accessKeyId, String accessKeySecret, String bucketName, String ossFilePath, String newFilePath){
+        //实例化OSSClient对象
+        OSSClient ossClient = (OSSClient) new OSSClientBuilder().build(endPoint, accessKeyId, accessKeySecret);
+        try {
+            // 指定路径如果没有则创建并添加
+            File file = new File(newFilePath);
+            //获取父目录
+            File fileParent = file.getParentFile();
+            //判断是否存在
+            if (!fileParent.exists()) {
+                // 创建父目录文件
+                fileParent.mkdirs();
+            }
+            file.createNewFile();
+            // 下载Object到本地文件,并保存到指定的本地路径中。如果指定的本地文件存在会覆盖,不存在则新建。
+            // 如果未指定本地路径,则下载后的文件默认保存到示例程序所属项目对应本地路径中。
+            ossClient.getObject(new GetObjectRequest(bucketName, ossFilePath), new File(newFilePath));
+
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            if (ossClient != null) {
+                ossClient.shutdown();
+            }
+        }
+    }
+
     /**
      * 判断文件是否存在
      *
@@ -604,6 +733,116 @@ public class FileUtils {
         return split[split.length - 1];
     }
 
+    /**
+     * 字符串转成file文件
+     *
+     * @param text
+     * @param file
+     * @return
+     */
+    public static File stringByFile(String text, File file) {
+        if (file.exists()) {
+            file.delete();
+        }
+        BufferedReader br = null;
+        BufferedWriter bw = null;
+        try {
+            br = new BufferedReader(new StringReader(text));
+            bw = new BufferedWriter(new FileWriter(file));
+            char[] buf = new char[1024 * 64];          //字符缓冲区
+            int len;
+            while ((len = br.read(buf)) != -1) {
+                bw.write(buf, 0, len);
+            }
+            bw.flush();
+            br.close();
+            bw.close();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return file;
+    }
+
+    /**
+     * file转byte
+     */
+    public static byte[] file2byte(File file) {
+        byte[] buffer = null;
+        try {
+            FileInputStream fis = new FileInputStream(file);
+            ByteArrayOutputStream bos = new ByteArrayOutputStream();
+            byte[] b = new byte[1024];
+            int n;
+            while ((n = fis.read(b)) != -1) {
+                bos.write(b, 0, n);
+            }
+            fis.close();
+            bos.close();
+            buffer = bos.toByteArray();
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return buffer;
+    }
+
+    /**
+     * byte 转file
+     */
+    public static File byte2File(byte[] buf, String filePath, String fileName) {
+        BufferedOutputStream bos = null;
+        FileOutputStream fos = null;
+        File file = null;
+        try {
+            File dir = new File(filePath);
+            if (!dir.exists() && dir.isDirectory()) {
+                dir.mkdirs();
+            }
+            file = new File(filePath + File.separator + fileName);
+            fos = new FileOutputStream(file);
+            bos = new BufferedOutputStream(fos);
+            bos.write(buf);
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            if (bos != null) {
+                try {
+                    bos.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            if (fos != null) {
+                try {
+                    fos.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return file;
+    }
+
+    /**
+     * multipartFile转File
+     **/
+    public static File multipartFile2File(MultipartFile multipartFile) {
+        File file = null;
+        if (multipartFile != null) {
+            try {
+                file = File.createTempFile("tmp", null);
+                multipartFile.transferTo(file);
+                System.gc();
+                file.deleteOnExit();
+            } catch (Exception e) {
+                e.printStackTrace();
+                log.warn("multipartFile转File发生异常:" + e);
+            }
+        }
+        return file;
+    }
+
 
     // 测试
     public static void main(String[] args) throws FileNotFoundException {

+ 0 - 5
sckw-modules/sckw-file/src/main/resouces/banner.txt

@@ -1,5 +0,0 @@
-====================================================================================================================
-
-                    欢迎使用 [sckw-file] 开物供应链服务平台-文件服务 - Powered By https://www.xxxx.com
-
-====================================================================================================================

+ 0 - 82
sckw-modules/sckw-file/src/main/resouces/bootstrap-dev.yml

@@ -1,82 +0,0 @@
-spring:
-  cloud:
-    nacos:
-      discovery:
-        # 服务注册地址
-        server-addr: 127.0.0.1:8848
-        # 命名空间
-        namespace: sckw-service-platform-dev
-        # 共享配置
-        group: sckw-service-platform
-      config:
-        # 配置中心地址
-        server-addr: 127.0.0.1:8848
-        # 配置文件格式
-        file-extension: yaml
-        # 命名空间
-        namespace: sckw-service-platform-dev
-        # 共享配置
-        group: sckw-service-platform
-    function:
-      definition: sckwSms;sckwMessage
-    stream:
-      bindings:
-        sckwSms-in-0:
-          destination: sckw-sms
-          content-type: application/json
-          default-binder: defaultRabbit
-          group: sckw
-        sckwSms-out-0:
-          destination: sckw-sms
-          content-type: application/json
-          default-binder: defaultRabbit
-          group: sckw
-        sckwMessage-in-0:
-          destination: sckw-message
-          content-type: application/json
-          default-binder: defaultRabbit
-          group: sckw
-        sckwMessage-out-0:
-          destination: sckw-message
-          content-type: application/json
-          default-binder: defaultRabbit
-          group: sckw
-      binders:
-        defaultRabbit:
-          type: rabbit
-          environment:
-            spring:
-              rabbitmq:
-                virtual-host: /
-                host: 39.104.134.114
-                port: 5672
-                username: wph
-                password: Yy123...
-#限制上传文件大小
-  servlet:
-    multipart:
-      max-file-size: 100MB
-      max-request-size: 100MB
-
-
-# dubbo
-dubbo:
-  application:
-    # 此处没有延用spring.application.name是因为当前项目本身也会注册到nacos中,如果dubbo也延用相同的名称,在nacos服务里会看到注册的producer-server服务数为2
-    name: file-dubbo-server
-  protocol:
-    name: dubbo
-    port: -1
-  registry:
-    # 配置dubbo的注册中心为nacos
-    address: nacos://${spring.cloud.nacos.discovery.server-addr}
-    group: ${spring.cloud.nacos.config.group}
-    protocol: nacos
-    #use-as-config-center: false
-    #use-as-metadata-center: false
-aliyun:
-  oss:
-    endpoint: oss-cn-chengdu.aliyuncs.com
-    accessKeyId: LTAI5tPEbubCGq5Rdwygbz4Q
-    secret: 7mQLWMaBJeZPRV1SRGogctYGXwppjQ
-    bucket: kaiwu-saas

+ 0 - 27
sckw-modules/sckw-file/src/main/resouces/bootstrap.yml

@@ -1,27 +0,0 @@
-server:
-  port: 10050
-
-spring:
-  application:
-    name: sckw-file
-  profiles:
-    active: ${DEPLOY_MODE:dev}
-  main:
-    allow-bean-definition-overriding: true
-# Spring
-dubbo:
-  application:
-    name: file-dubbo-server
-    # 该配置在producer-server中是没有的,但是在consumer这里要配置一下
-    # 如果不配置这个QOS的端口,它会延用dubbo自动生成的端口,在启动的时候,QOS注册就会提示该端口已经被使用的错误
-    # 虽然启动时有打印端口已经被使用的错误,但是依旧可以正常启动服务,并且dubbo也可以正常调用,但是为了解决启动报错还是加上这个端口
-    # 这个也是apache官方给出的解决方案,这个端口不能给-1,它不会自动找到一个可用的端口,给-1会报错,端口1-65535自己选择一个
-    qos-port: 3334
-  protocol:
-    name: dubbo
-    # port为-1表示自动找一个可用的端口
-    port: -1
-  registry:
-    address: nacos://${spring.cloud.nacos.discovery.server-addr}
-    group: ${spring.cloud.nacos.config.group}
-    protocol: nacos

+ 136 - 0
sckw-modules/sckw-file/src/main/resources/mapper/KwsFileInfoDao.xml

@@ -0,0 +1,136 @@
+<?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.sckw.file.dao.KwsFileInfoDao">
+    <resultMap id="BaseResultMap" type="com.sckw.file.model.FileInfo">
+        <id column="id" jdbcType="BIGINT" property="id" />
+        <result column="type" jdbcType="VARCHAR" property="type" />
+        <result column="original_name" jdbcType="VARCHAR" property="originalName" />
+        <result column="file_name" jdbcType="VARCHAR" property="fileName" />
+        <result column="md5" jdbcType="VARCHAR" property="md5" />
+        <result column="file_suffix" jdbcType="BIGINT" property="fileSuffix" />
+        <result column="file_size" jdbcType="DECIMAL" property="fileSize" />
+        <result column="file_path" jdbcType="INTEGER" property="filePath" />
+        <result column="remark" jdbcType="INTEGER" property="remark" />
+        <result column="status" jdbcType="INTEGER" property="status" />
+        <result column="create_by" jdbcType="VARCHAR" property="createBy" />
+        <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
+        <result column="update_by" jdbcType="VARCHAR" property="updateBy" />
+        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
+        <result column="del_flag" jdbcType="INTEGER" property="delFlag" />
+    </resultMap>
+
+    <sql id="Base_Column_List">
+        id, type, original_name, file_name, md5, file_suffix, file_size, file_path, remark, status,
+    create_by, create_time, update_by, update_time, del_flag
+    </sql>
+    <update id="update"></update>
+
+    <select id="selectByKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
+        select
+        <include refid="Base_Column_List" />
+        from kwf_file_info
+        where id = #{id,jdbcType=BIGINT}
+    </select>
+    <select id="findList" resultType="com.sckw.file.model.FileInfo">
+
+    </select>
+
+    <insert id="insert" parameterType="com.sckw.file.model.FileInfo">
+        insert into kwf_file_info
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="id != null">
+                id,
+            </if>
+            <if test="type != null">
+                type,
+            </if>
+            <if test="originalName != null">
+                original_name,
+            </if>
+            <if test="fileName != null">
+                file_name,
+            </if>
+            <if test="md5 != null">
+                md5,
+            </if>
+            <if test="fileSuffix != null">
+                file_suffix,
+            </if>
+            <if test="fileSize != null">
+                file_size,
+            </if>
+            <if test="filePath != null">
+                file_path,
+            </if>
+            <if test="remark != null">
+                remark,
+            </if>
+            <if test="status != null">
+                status,
+            </if>
+            <if test="createBy != null">
+                create_by,
+            </if>
+            <if test="createTime != null">
+                create_time,
+            </if>
+            <if test="updateBy != null">
+                update_by,
+            </if>
+            <if test="updateTime != null">
+                update_time,
+            </if>
+            <if test="delFlag != null">
+                del_flag,
+            </if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="id != null">
+                #{id,jdbcType=BIGINT},
+            </if>
+            <if test="type != null">
+                #{type,jdbcType=INTEGER},
+            </if>
+            <if test="originalName != null">
+                #{original_name,jdbcType=VARCHAR},
+            </if>
+            <if test="fileName != null">
+                #{file_name,jdbcType=VARCHAR},
+            </if>
+            <if test="md5 != null">
+                #{md5,jdbcType=VARCHAR},
+            </if>
+            <if test="fileSuffix != null">
+                #{file_suffix,jdbcType=VARCHAR},
+            </if>
+            <if test="fileSize != null">
+                #{file_size,jdbcType=DECIMAL},
+            </if>
+            <if test="filePath != null">
+                #{file_path,jdbcType=VARCHAR},
+            </if>
+            <if test="remark != null">
+                #{remark,jdbcType=VARCHAR},
+            </if>
+            <if test="status != null">
+                #{status,jdbcType=INTEGER},
+            </if>
+            <if test="createBy != null">
+                #{createBy,jdbcType=BIGINT},
+            </if>
+            <if test="createTime != null">
+                #{createTime,jdbcType=TIMESTAMP},
+            </if>
+            <if test="updateBy != null">
+                #{updateBy,jdbcType=BIGINT},
+            </if>
+            <if test="updateTime != null">
+                #{updateTime,jdbcType=TIMESTAMP},
+            </if>
+            <if test="delFlag != null">
+                #{delFlag,jdbcType=INTEGER},
+            </if>
+        </trim>
+    </insert>
+
+</mapper>

+ 1 - 1
sckw-modules/sckw-message/src/main/resources/bootstrap.yml

@@ -5,7 +5,7 @@ spring:
   application:
     name: sckw-message
   profiles:
-    active: ${DEPLOY_MODE:dev}
+    active: ${DEPLOY_MODE:local}
   main:
     allow-bean-definition-overriding: true
 # Spring

+ 1 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/SystemApplication.java

@@ -10,6 +10,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
 @EnableFeignClients({"com.sckw.*.api.feign"})
 @EnableDiscoveryClient
 @SpringBootApplication
+//@MapperScan("com.system.*.mapper")
 public class SystemApplication {
 
     public static void main(String[] args) {

+ 0 - 130
sckw-modules/sckw-system/src/main/java/com/sckw/system/controller/SysUserController.java

@@ -1,130 +0,0 @@
-package com.sckw.system.controller;
-
-import cn.hutool.core.lang.UUID;
-import com.alibaba.fastjson2.JSON;
-import com.sckw.core.model.page.PageResult;
-import com.sckw.core.web.response.HttpResult;
-import com.sckw.stream.enums.SmsCodeEnum;
-import com.sckw.stream.model.SckwMessage;
-import com.sckw.stream.model.SckwSms;
-import com.sckw.system.model.SysUser;
-import com.sckw.system.model.TestSensitive;
-import com.sckw.system.service.SysUserService;
-import lombok.AllArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.redisson.api.RBucket;
-import org.redisson.api.RedissonClient;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.cloud.stream.function.StreamBridge;
-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 javax.annotation.Resource;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-@Slf4j
-@AllArgsConstructor
-@RestController
-@RequestMapping("/")
-public class SysUserController {
-
-    @Autowired
-    SysUserService sysUserService;
-
-    @Resource
-    RedissonClient redissonClient;
-
-    /*@Autowired
-    RedisService redisService;*/
-
-    @GetMapping("index")
-    public Object test(){
-        Map result = new HashMap();
-        result.put("user", System.currentTimeMillis());
-        result.put("datatime", System.currentTimeMillis());
-        result.put("database", "redis");
-
-        RBucket<Object> mytest = redissonClient.getBucket("mytest");
-        mytest.set("value");
-        System.out.println(mytest.get());//value
-        mytest.set("value2");
-        System.out.println(mytest.get());//value2
-        boolean b = mytest.compareAndSet("value2", result); //true
-        System.out.println(mytest.get());//value3
-        Object resultObj = mytest.get();
-
-        /*result.put("type", "spring boot");
-        redisService.setCacheMap("value2", result);
-        resultObj = redisService.getCacheMap("value2");*/
-
-        return String.valueOf(resultObj);
-    }
-
-    //@Override
-    public String getUserInfo(String account) {
-        return account + String.valueOf(new Date());
-    }
-
-    @PostMapping("findByAccount")
-    public HttpResult findByAccount(HashMap params) {
-        List<SysUser> data = sysUserService.findByAccount(params);
-        return HttpResult.ok(data);
-    }
-
-    @PostMapping("findPage")
-    public HttpResult findPage(Map<String, Object> params) {
-        PageResult pageResult = sysUserService.findPage(params);
-        return HttpResult.ok(pageResult);
-    }
-
-    @GetMapping("/testSensitive")
-    public HttpResult testSensitive() {
-        TestSensitive testSensitive = new TestSensitive();
-        testSensitive.setIdCard("210397198608215431");
-        testSensitive.setPhone("17640125371");
-        testSensitive.setAddress("北京市朝阳区某某四合院1203室");
-        testSensitive.setEmail("17640125371@163.com");
-        testSensitive.setBankCard("6226456952351452853");
-        return HttpResult.ok(testSensitive);
-    }
-
-    @Resource
-    private StreamBridge streamBridge;
-
-    @GetMapping("/pushMesg")
-    public HttpResult pushMesg() {
-        String uuid = UUID.fastUUID().toString();
-        SckwSms sckwSms = new SckwSms();
-        sckwSms.setTelephone("17358629955");
-        sckwSms.setSignName("矿拉拉");
-        sckwSms.setTemplateCode(SmsCodeEnum.VERIFICATION_CODE);
-        sckwSms.setParams(new HashMap(){{put("code", "123456");}});
-        streamBridge.send("sckw-sms", JSON.toJSONString(sckwSms));
-
-
-        SckwMessage message = new SckwMessage();
-        //person.setName(String.valueOf(System.currentTimeMillis()));
-        message.setMsgUrl("---");
-        message.setPushType("====");
-        message.setClientId("111111111111111");
-        streamBridge.send("sckw-message", JSON.toJSONString(message));
-
-        return HttpResult.ok(uuid);
-    }
-
-    @GetMapping("/pushSms")
-    public HttpResult pushSms() {
-        TestSensitive testSensitive = new TestSensitive();
-        testSensitive.setIdCard("210397198608215431");
-        testSensitive.setPhone("17640125371");
-        testSensitive.setAddress("北京市朝阳区某某四合院1203室");
-        testSensitive.setEmail("17640125371@163.com");
-        testSensitive.setBankCard("6226456952351452853");
-        return HttpResult.ok(testSensitive);
-    }
-}

+ 0 - 23
sckw-modules/sckw-system/src/main/java/com/sckw/system/controller/TestController.java

@@ -1,23 +0,0 @@
-package com.sckw.system.controller;
-
-import com.sckw.core.web.response.HttpResult;
-import lombok.AllArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * @Author xucaiqin
- * @date 2023-06-02 17:30:32
- */
-@Slf4j
-@AllArgsConstructor
-@RestController
-@RequestMapping("/")
-public class TestController {
-    @GetMapping("get")
-    public HttpResult findByAccount(String account) {
-        return HttpResult.ok(account);
-    }
-}

+ 0 - 31
sckw-modules/sckw-system/src/main/java/com/sckw/system/dao/SysUserDao.java

@@ -1,31 +0,0 @@
-package com.sckw.system.dao;
-
-import com.baomidou.dynamic.datasource.annotation.DS;
-import com.sckw.system.model.SysUser;
-import org.apache.ibatis.annotations.Mapper;
-import org.apache.ibatis.annotations.Select;
-import java.util.List;
-import java.util.Map;
-
-@Mapper
-public interface SysUserDao {
-
-    /**
-     * 账号查询用户信息
-     * @param params {account:账号, systemType:系统类别}
-     * @return
-//     */
-    @DS("slave_1")
-    SysUser findByAccount(Map params);
-
-    @DS("master")
-    @Select("SELECT * FROM user limit 1")
-    List<SysUser> findUserByAccount(String account);
-
-    @DS("slave_1")
-    @Select("SELECT * FROM sys_user limit 10")
-    List<Map> findUserByAccount1(String account);
-
-    @DS("slave_1")
-    List<Map<String, Object>> findPage(Map<String, Object> params);
-}

+ 0 - 34
sckw-modules/sckw-system/src/main/java/com/sckw/system/service/SysUserService.java

@@ -1,34 +0,0 @@
-package com.sckw.system.service;
-import com.github.pagehelper.PageHelper;
-import com.github.pagehelper.PageInfo;
-import com.sckw.core.model.page.PageHelperUtil;
-import com.sckw.core.model.page.PageResult;
-import com.sckw.system.dao.SysUserDao;
-import com.sckw.system.model.SysUser;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-@Service
-public class SysUserService {
-
-    @Autowired
-    SysUserDao sysUserDao;
-
-    public List<SysUser> findByAccount(HashMap params) {
-        SysUser sysUser = sysUserDao.findByAccount(params);
-        return new ArrayList<>(){{add(sysUser);}};
-    }
-
-    public PageResult findPage(Map<String, Object> params) {
-        // 设置分页参数
-        PageHelper.startPage(PageResult.getPageNum(params), PageResult.getPageSize(params));
-        List<Map<String, Object>> list = sysUserDao.findPage(params);
-        PageResult pageResult = PageHelperUtil.getPageResult(new PageInfo(list));
-        return pageResult;
-    }
-}

+ 1 - 1
sckw-modules/sckw-system/src/main/resources/bootstrap.yml

@@ -5,6 +5,6 @@ spring:
   application:
     name: sckw-system
   profiles:
-    active: ${DEPLOY_MODE:dev}
+    active: ${DEPLOY_MODE:local}
   main:
     allow-bean-definition-overriding: true