Browse Source

readme

master
zhaodengke 1 year ago
parent
commit
6eca7ed535
22 changed files with 66 additions and 1311 deletions
  1. +56
    -92
      README.md
  2. +0
    -1
      pom.xml
  3. +0
    -7
      ruoyi-admin/pom.xml
  4. +9
    -9
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/open/OpenFileController.java
  5. +0
    -63
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/OssController.java
  6. +1
    -1
      ruoyi-file/src/main/java/com/ruoyi/file/object/UploadForwardReq.java
  7. +0
    -36
      ruoyi-tool/pom.xml
  8. +0
    -153
      ruoyi-tool/src/main/java/com/ruoyi/tool/domain/StoreFile.java
  9. +0
    -53
      ruoyi-tool/src/main/java/com/ruoyi/tool/enums/StoreBizType.java
  10. +0
    -33
      ruoyi-tool/src/main/java/com/ruoyi/tool/enums/StoreType.java
  11. +0
    -101
      ruoyi-tool/src/main/java/com/ruoyi/tool/mapper/StoreFileMapper.java
  12. +0
    -61
      ruoyi-tool/src/main/java/com/ruoyi/tool/oss/AliOssService.java
  13. +0
    -22
      ruoyi-tool/src/main/java/com/ruoyi/tool/oss/CloudEnums.java
  14. +0
    -29
      ruoyi-tool/src/main/java/com/ruoyi/tool/oss/CloudStorageConfig.java
  15. +0
    -71
      ruoyi-tool/src/main/java/com/ruoyi/tool/oss/CloudStorageService.java
  16. +0
    -15
      ruoyi-tool/src/main/java/com/ruoyi/tool/oss/OSSFactory.java
  17. +0
    -21
      ruoyi-tool/src/main/java/com/ruoyi/tool/oss/OssResObj.java
  18. +0
    -101
      ruoyi-tool/src/main/java/com/ruoyi/tool/service/IStoreFileService.java
  19. +0
    -24
      ruoyi-tool/src/main/java/com/ruoyi/tool/service/StoreFileBizService.java
  20. +0
    -41
      ruoyi-tool/src/main/java/com/ruoyi/tool/service/impl/StoreFileBizServiceImpl.java
  21. +0
    -163
      ruoyi-tool/src/main/java/com/ruoyi/tool/service/impl/StoreFileServiceImpl.java
  22. +0
    -214
      ruoyi-tool/src/main/resources/mapper/tool/StoreFileMapper.xml

+ 56
- 92
README.md View File

@@ -1,92 +1,56 @@
# gxzb.api



## Getting started

To make it easy for you to get started with GitLab, here's a list of recommended next steps.

Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!

## Add your files

- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:

```
cd existing_repo
git remote add origin https://gitlab.cacfintech.com/project/gxzb.api.git
git branch -M main
git push -uf origin main
```

## Integrate with your tools

- [ ] [Set up project integrations](https://gitlab.cacfintech.com/project/gxzb.api/-/settings/integrations)

## Collaborate with your team

- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)

## Test and Deploy

Use the built-in continuous integration in GitLab.

- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)

***

# Editing this README

When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.

## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.

## Name
Choose a self-explaining name for your project.

## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.

## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.

## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.

## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.

## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.

## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.

## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.

## Contributing
State if you are open to contributions and what your requirements are for accepting them.

For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.

You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.

## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.

## License
For open source projects, say how it is licensed.

## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
# file_transfer



## 项目信息结构

| 名称 | 说明 | 例如 |
|:-|:-:|:-:|:-:|
| name | 项目名 | 乳山 |
| token | 项目唯一标识. 前端上传文件必须携带 | rushan |
| remote_host | 远程项目地址. 前端或后端, 如果不能跨域则使用前端地址 | 如果使用后端地址: http://127.0.0.1:8080; 如果使用前端地址: http://127.0.0.1/api |
| disk_path | 文件存储路径. application.yml中的nsgk.profile值, 路径分隔符必须使用正斜杠 | D:/NsgkSoft/files/nsgk/uploadPath |
| disabled | 是否禁用. 1 或 0 | 1 则禁止上传 |

----------------------------------------------------------------------------------
## 通用接口

* POST请求
* 单文件字段是file

> 仅上传
>> `/open/file/upload/{项目唯一标识}/{存储目录}`

> 上传并重定向
>> `/open/file/uploadForward/{项目唯一标识}/{存储目录}`
> * 必须参数: redirectUri 重定向地址, 必须是可以GET请求
> * 其他参数: 将拼接到地址中

> 上传并转发
>> `/open/file/uploadForward/{项目唯一标识}/{存储目录}`
> * 必须参数: requestUri 请求地址
> * 必须参数: method 请求方法 默认get
> * 必须参数: contentType 请求类型 get默认, post默认application/json
> * 必须参数: responseContentType 响应类型 默认application/json
> * 其他参数: data 请求数据 String

----------------------------------------------------------------------------------
## 财务项目专用接口

* POST请求
* 单文件字段是file

> 通用上传
>> `/open/ruralCollectiveAssets/common/upload`
> * 必须参数: token 项目唯一标识
> * 必须参数: bizPath 存储目录, 默认upload
> * 重定向到: `{remote_host}`/file/common/upload, 对应`{remote_host}`/common/upload

> 附件上传
>> `/open/ruralCollectiveAssets/common/attach`
> * 必须参数: token 项目唯一标识
> * 必须参数: bizPath 存储目录
> * 必须参数: tableName 表名
> * 必须参数: tableId 表ID
> * 可选参数: fileType 额外类型
> * 重定向到: `{remote_host}`/file/common/attach, 对应`{remote_host}`/common/attach

+ 0
- 1
pom.xml View File

@@ -247,7 +247,6 @@
<module>ruoyi-quartz</module>
<module>ruoyi-generator</module>
<module>ruoyi-common</module>
<module>ruoyi-tool</module>
<module>ruoyi-file</module>

</modules>


+ 0
- 7
ruoyi-admin/pom.xml View File

@@ -72,13 +72,6 @@
<artifactId>ruoyi-generator</artifactId>
</dependency>

<!-- 工具 -->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-tool</artifactId>
<version>1.0.0</version>
</dependency>

<!-- 文件 -->
<dependency>
<groupId>com.ruoyi</groupId>


+ 9
- 9
ruoyi-admin/src/main/java/com/ruoyi/web/controller/open/OpenFileController.java View File

@@ -86,10 +86,10 @@ public class OpenFileController
* 仅上传(单个)
*/
@ApiOperation("仅上传")
@PostMapping("/upload/{token}/{fileType}")
public AjaxResult upload(@PathVariable String token, @PathVariable String fileType, MultipartFile file)
@PostMapping("/upload/{token}/{directory}")
public AjaxResult upload(@PathVariable String token, @PathVariable String directory, MultipartFile file)
{
UploadResp upload = fileService.upload(file, fileType, token);
UploadResp upload = fileService.upload(file, directory, token);
return AjaxResult.success(upload);
}

@@ -97,19 +97,19 @@ public class OpenFileController
* 上传并转发(单个)
*/
@ApiOperation("上传并转发")
@PostMapping("/uploadForward/{token}/{fileType}")
public String uploadForward(@PathVariable String token, @PathVariable String fileType, MultipartFile file, @Valid UploadForwardReq req, HttpServletRequest request, HttpServletResponse response)
@PostMapping("/uploadForward/{token}/{directory}")
public String uploadForward(@PathVariable String token, @PathVariable String directory, MultipartFile file, @Valid UploadForwardReq req, HttpServletRequest request, HttpServletResponse response)
{
return fileService.uploadForward(file, fileType, token, req, request, response);
return fileService.uploadForward(file, directory, token, req, request, response);
}

/**
* 上传并重定向(单个)
*/
@ApiOperation("上传并重定向")
@PostMapping("/uploadRedirect/{token}/{fileType}")
public void uploadRedirect(@PathVariable String token, @PathVariable String fileType, MultipartFile file, @Valid UploadRedirectReq req, HttpServletRequest request, HttpServletResponse response)
@PostMapping("/uploadRedirect/{token}/{directory}")
public void uploadRedirect(@PathVariable String token, @PathVariable String directory, MultipartFile file, @Valid UploadRedirectReq req, HttpServletRequest request, HttpServletResponse response)
{
fileService.uploadRedirect(file, fileType, token, req, request, response);
fileService.uploadRedirect(file, directory, token, req, request, response);
}
}

+ 0
- 63
ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/OssController.java View File

@@ -1,63 +0,0 @@
package com.ruoyi.web.controller.tool;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.tool.enums.StoreBizType;
import com.ruoyi.tool.oss.CloudStorageConfig;
import com.ruoyi.tool.oss.OSSFactory;
import com.ruoyi.tool.oss.OssResObj;
import com.ruoyi.web.core.config.OssConfig;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
* @author wyq
* @version 1.0
* @date 2020/6/10 17:44
*/
@Api(tags = "通用请求接口")
@RestController
@RequestMapping("/open/tool")
public class OssController {

@Resource
private OssConfig ossConfig;

/**
* 上传文件
* @param file
* @param bizType
* @return
* @throws Exception
*/
@ApiOperation("上传")
@RequestMapping(value = "/uploadFile", method = RequestMethod.POST)
public R<OssResObj> uploadFile(@RequestParam("file") MultipartFile file,
@RequestParam("bizType") StoreBizType bizType) throws Exception {
if (file.isEmpty()) {
throw new ServiceException("上传文件不能为空");
}
CloudStorageConfig config = new CloudStorageConfig();
config.setType(1);
config.setAliyunAccessKeyId(ossConfig.getAccessKeyId());
config.setAliyunAccessKeySecret(ossConfig.getAccessKeySecret());
config.setAliyunBucketName(ossConfig.getPublicBucketName());
config.setAliyunEndPoint(ossConfig.getEndpointUrl());
config.setAliyunDomain(ossConfig.getDomain());
// 上传文件
String suffix =
file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
OssResObj resObj =
OSSFactory.build(config).uploadSuffix(file.getBytes(), bizType.getPath(), suffix);
return R.ok(resObj);
}

}

+ 1
- 1
ruoyi-file/src/main/java/com/ruoyi/file/object/UploadForwardReq.java View File

@@ -10,7 +10,7 @@ public final class UploadForwardReq
@NotBlank(message = "转发地址不能为空")
private String requestUri;
@NotBlank(message = "转发方式不能为空")
private String method;
private String method = "GET";
@NotBlank(message = "转发类型不能为空")
private String contentType = "application/json";
@NotBlank(message = "转发数据不能为空")


+ 0
- 36
ruoyi-tool/pom.xml View File

@@ -1,36 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>ruoyi</artifactId>
<groupId>com.ruoyi</groupId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>ruoyi-tool</artifactId>

<description>
工具模块
</description>

<dependencies>
<!-- swagger3-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
</dependency>
<!-- 通用工具-->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common</artifactId>
</dependency>
<dependency>
<groupId>com.aliyun.oss</groupId>
<artifactId>aliyun-sdk-oss</artifactId>
<version>3.8.0</version>
</dependency>
</dependencies>

</project>

+ 0
- 153
ruoyi-tool/src/main/java/com/ruoyi/tool/domain/StoreFile.java View File

@@ -1,153 +0,0 @@
package com.ruoyi.tool.domain;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;

/**
* 文件对象 td_store_file
*
* @author rongxin
* @date 2023-09-06
*/
public class StoreFile extends BaseEntity
{
private static final long serialVersionUID = 1L;

/** 主键 */
private Long id;

/** 文件编码 */
@Excel(name = "文件编码")
private String bizCode;

/** 业务类型 */
@Excel(name = "业务类型")
private Integer bizType;

/** 文件类型1图片2视频 */
@Excel(name = "文件类型1图片2视频")
private Integer type;

/** 域名 */
@Excel(name = "域名")
private String domain;

/** 文件路径 */
@Excel(name = "文件路径")
private String filePath;

/** 文件描述 */
@Excel(name = "文件描述")
private String description;

/** 文件名称 */
@Excel(name = "文件名称")
private String fileName;

/** 0未完成1已完成 */
@Excel(name = "0未完成1已完成")
private Long status;

public void setId(Long id)
{
this.id = id;
}

public Long getId()
{
return id;
}
public void setBizCode(String bizCode)
{
this.bizCode = bizCode;
}

public String getBizCode()
{
return bizCode;
}
public void setBizType(Integer bizType)
{
this.bizType = bizType;
}

public Integer getBizType()
{
return bizType;
}
public void setType(Integer type)
{
this.type = type;
}

public Integer getType()
{
return type;
}
public void setDomain(String domain)
{
this.domain = domain;
}

public String getDomain()
{
return domain;
}
public void setFilePath(String filePath)
{
this.filePath = filePath;
}

public String getFilePath()
{
return filePath;
}
public void setDescription(String description)
{
this.description = description;
}

public String getDescription()
{
return description;
}
public void setFileName(String fileName)
{
this.fileName = fileName;
}

public String getFileName()
{
return fileName;
}
public void setStatus(Long status)
{
this.status = status;
}

public Long getStatus()
{
return status;
}

@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("bizCode", getBizCode())
.append("bizType", getBizType())
.append("type", getType())
.append("domain", getDomain())
.append("filePath", getFilePath())
.append("description", getDescription())
.append("fileName", getFileName())
.append("status", getStatus())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.toString();
}
}

+ 0
- 53
ruoyi-tool/src/main/java/com/ruoyi/tool/enums/StoreBizType.java View File

@@ -1,53 +0,0 @@
package com.ruoyi.tool.enums;

/**
* @author: yjx
* @date: 2023年09月06日 15:18
* @Description:
*/
public enum StoreBizType {
PRODUCT_IMG(1, "商品图片", false, "rgvn/shop/product/"),;
private int code;
private String desc;
private boolean privateFlag;
private String path;

StoreBizType(int code, String desc, boolean flag, String path) {
this.code = code;
this.desc = desc;
this.privateFlag = flag;
this.path = path;
}

public boolean getPrivateFlag() {
return privateFlag;
}

public void setPrivateFlag(boolean privateFlag) {
this.privateFlag = privateFlag;
}

public int getCode() {
return code;
}

public void setCode(int code) {
this.code = code;
}

public String getDesc() {
return desc;
}

public void setDesc(String desc) {
this.desc = desc;
}

public String getPath() {
return path;
}

public void setPath(String path) {
this.path = path;
}
}

+ 0
- 33
ruoyi-tool/src/main/java/com/ruoyi/tool/enums/StoreType.java View File

@@ -1,33 +0,0 @@
package com.ruoyi.tool.enums;

/**
* @author: yjx
* @date: 2023年09月06日 15:18
* @Description:
*/
public enum StoreType {
IMG(1, "图片"), VIDEO(2, "视频");
private int code;
private String desc;

StoreType(int code, String desc) {
this.code = code;
this.desc = desc;
}

public int getCode() {
return code;
}

public void setCode(int code) {
this.code = code;
}

public String getDesc() {
return desc;
}

public void setDesc(String desc) {
this.desc = desc;
}
}

+ 0
- 101
ruoyi-tool/src/main/java/com/ruoyi/tool/mapper/StoreFileMapper.java View File

@@ -1,101 +0,0 @@
package com.ruoyi.tool.mapper;

import java.util.List;
import com.ruoyi.tool.domain.StoreFile;

/**
* 文件Mapper接口
*
* @author rongxin
* @date 2023-09-06
*/
public interface StoreFileMapper
{
/**
* 查询文件
*
* @param id 文件主键
* @return 文件
*/
public StoreFile selectStoreFileById(Long id);

/**
* 查询文件列表
*
* @param storeFile 文件
* @return 文件集合
*/
public List<StoreFile> selectStoreFileList(StoreFile storeFile);

/**
* 新增文件
*
* @param storeFile 文件
* @return 结果
*/
public int insertStoreFile(StoreFile storeFile);

/**
* 批量新增文件
*
* @param list 文件
* @return 结果
*/
public int insertStoreFileBatch(List<StoreFile> list);

/**
* 修改文件
*
* @param storeFile 文件
* @return 结果
*/
public int updateStoreFile(StoreFile storeFile);

/**
* 批量修改 文件
*
* @param list 文件
* @return 结果
*/
public int updateStoreFileBatch(List<StoreFile> list);

/**
* 删除文件
*
* @param id 文件主键
* @return 结果
*/
public int deleteStoreFileById(Long id);

/**
* 批量删除文件
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteStoreFileByIds(Long[] ids);

/**
* 条件单条查询文件
*
* @param storeFile 文件
* @return 文件条目
*/
public StoreFile selectStoreFile(StoreFile storeFile);

/**
* 条件查询文件数量
*
* @param storeFile 文件
* @return 文件数量
*/
public Long selectStoreFileCount(StoreFile storeFile);

/**
* 条件查询文件是否存在
*
* @param storeFile 文件
* @return 文件是否存在
*/
public int selectStoreFileExists(StoreFile storeFile);
}

+ 0
- 61
ruoyi-tool/src/main/java/com/ruoyi/tool/oss/AliOssService.java View File

@@ -1,61 +0,0 @@
package com.ruoyi.tool.oss;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;

import java.io.ByteArrayInputStream;
import java.io.InputStream;

/**
* 阿里云存储
*
* @author Mark sunlightcs@gmail.com
*/
public class AliOssService extends CloudStorageService {
private OSS client;

public AliOssService(CloudStorageConfig config) {
this.config = config;
// 初始化
init();
}

private void init() {
String transEndpoint = String.format(config.getAliyunEndPoint(), "");
client = new OSSClientBuilder().build(transEndpoint, config.getAliyunAccessKeyId(),
config.getAliyunAccessKeySecret());
}

@Override
public OssResObj upload(byte[] data, String path) {
return upload(new ByteArrayInputStream(data), path);
}

@Override
public OssResObj upload(InputStream inputStream, String path) {
try {
client.putObject(config.getAliyunBucketName(), path, inputStream);
} catch (Exception e) {
throw new RuntimeException("上传文件失败,请检查配置信息", e);
}
OssResObj resObj = new OssResObj();
resObj.setDomain(config.getAliyunDomain());
resObj.setFilePath("/" + path);
return resObj;
}

// @Override
// public OssResObj uploadSuffix(byte[] data, String suffix) {
// return upload(data, getPath(config.getAliyunPrefix(), suffix));
// }

@Override
public OssResObj uploadSuffix(byte[] data, String prefix, String suffix) {
return upload(data, getPath(prefix, suffix));
}

// @Override
// public OssResObj uploadSuffix(InputStream inputStream, String suffix) {
// return upload(inputStream, getPath(config.getAliyunPrefix(), suffix));
// }
}

+ 0
- 22
ruoyi-tool/src/main/java/com/ruoyi/tool/oss/CloudEnums.java View File

@@ -1,22 +0,0 @@
package com.ruoyi.tool.oss;

/**
* 云服务商
*
* @author
*/
public enum CloudEnums {

ALIYUN(1);

private int value;

CloudEnums(int value) {
this.value = value;
}

public int getValue() {
return value;
}

}

+ 0
- 29
ruoyi-tool/src/main/java/com/ruoyi/tool/oss/CloudStorageConfig.java View File

@@ -1,29 +0,0 @@
package com.ruoyi.tool.oss;
import lombok.Data;
import java.io.Serializable;

/**
* 云存储配置信息
*
* @author Mark
*/
@Data
public class CloudStorageConfig implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 类型 1:阿里云
*/
private Integer type;

private String aliyunDomain;

private String aliyunEndPoint;

private String aliyunAccessKeyId;

private String aliyunAccessKeySecret;

private String aliyunBucketName;


}

+ 0
- 71
ruoyi-tool/src/main/java/com/ruoyi/tool/oss/CloudStorageService.java View File

@@ -1,71 +0,0 @@
package com.ruoyi.tool.oss;

import com.alibaba.fastjson2.util.DateUtils;
import com.ruoyi.common.utils.StringUtils;

import java.io.InputStream;
import java.util.Date;
import java.util.UUID;

/**
* 云存储
*
* @author
*/
public abstract class CloudStorageService {
/** 云存储配置信息 */
CloudStorageConfig config;

/**
* 文件路径
* @param prefix 前缀
* @param suffix 后缀
* @return 返回上传路径
*/
public String getPath(String prefix, String suffix) {
//生成uuid
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
//文件路径
String path = DateUtils.format(new Date(), "yyyy/MM") + "/" + uuid;

if(StringUtils.isNotBlank(prefix)){
path = prefix + path;
}

return path + suffix;
}

/**
* 文件上传
* @param data 文件字节数组
* @param path 文件路径,包含文件名
* @return 返回http地址
*/
public abstract OssResObj upload(byte[] data, String path);

/**
* 文件上传
* @param data 文件字节数组
* @param prefix 前缀
* @param suffix 后缀
* @return
*/
public abstract OssResObj uploadSuffix(byte[] data,String prefix, String suffix);

/**
* 文件上传
* @param inputStream 字节流
* @param path 文件路径,包含文件名
* @return 返回http地址
*/
public abstract OssResObj upload(InputStream inputStream, String path);

// /**
// * 文件上传
// * @param inputStream 字节流
// * @param suffix 后缀
// * @return 返回http地址
// */
// public abstract OssResObj uploadSuffix(InputStream inputStream, String suffix);

}

+ 0
- 15
ruoyi-tool/src/main/java/com/ruoyi/tool/oss/OSSFactory.java View File

@@ -1,15 +0,0 @@
package com.ruoyi.tool.oss;
/**
* 文件上传Factory
*
* @author Mark
*/
public final class OSSFactory {
public static CloudStorageService build(CloudStorageConfig config){
if(config.getType() == CloudEnums.ALIYUN.getValue()){
return new AliOssService(config);
}
return null;
}

}

+ 0
- 21
ruoyi-tool/src/main/java/com/ruoyi/tool/oss/OssResObj.java View File

@@ -1,21 +0,0 @@
package com.ruoyi.tool.oss;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;

/**
* @author: yjx
* @date: 2023年09月11日 15:17
* @Description:
*/
@Data
public class OssResObj implements Serializable {
private static final long serialVersionUID = 7898158115625007197L;
@ApiModelProperty(value = "域名")
private String domain;

@ApiModelProperty(value = "文件路径")
private String filePath;
}

+ 0
- 101
ruoyi-tool/src/main/java/com/ruoyi/tool/service/IStoreFileService.java View File

@@ -1,101 +0,0 @@
package com.ruoyi.tool.service;

import java.util.List;
import com.ruoyi.tool.domain.StoreFile;

/**
* 文件Service接口
*
* @author rongxin
* @date 2023-09-06
*/
public interface IStoreFileService
{
/**
* 查询文件
*
* @param id 文件主键
* @return 文件
*/
public StoreFile selectStoreFileById(Long id);

/**
* 查询文件列表
*
* @param storeFile 文件
* @return 文件集合
*/
public List<StoreFile> selectStoreFileList(StoreFile storeFile);

/**
* 新增文件
*
* @param storeFile 文件
* @return 结果
*/
public int insertStoreFile(StoreFile storeFile);

/**
* 批量新增文件
*
* @param list 文件
* @return 结果
*/
public int insertStoreFileBatch(List<StoreFile> list);

/**
* 修改文件
*
* @param storeFile 文件
* @return 结果
*/
public int updateStoreFile(StoreFile storeFile);

/**
* 批量修改 文件
*
* @param list 文件
* @return 结果
*/
public int updateStoreFileBatch(List<StoreFile> list);

/**
* 批量删除文件
*
* @param ids 需要删除的文件主键集合
* @return 结果
*/
public int deleteStoreFileByIds(Long[] ids);

/**
* 删除文件信息
*
* @param id 文件主键
* @return 结果
*/
public int deleteStoreFileById(Long id);

/**
* 条件单条查询文件
*
* @param storeFile 文件
* @return 文件条目
*/
public StoreFile selectStoreFile(StoreFile storeFile);

/**
* 条件查询文件数量
*
* @param storeFile 文件
* @return 文件数量
*/
public Long selectStoreFileCount(StoreFile storeFile);

/**
* 条件查询文件是否存在
*
* @param storeFile 文件
* @return 文件是否存在
*/
public boolean selectStoreFileExists(StoreFile storeFile);
}

+ 0
- 24
ruoyi-tool/src/main/java/com/ruoyi/tool/service/StoreFileBizService.java View File

@@ -1,24 +0,0 @@
package com.ruoyi.tool.service;

import java.util.List;
import com.ruoyi.tool.domain.StoreFile;
import com.ruoyi.tool.enums.StoreBizType;
import com.ruoyi.tool.enums.StoreType;

/**
* 文件Service接口
*
* @author rongxin
* @date 2023-09-06
*/
public interface StoreFileBizService
{
/**
* 插入存储数据
*
* @param bizType
* @param type
* @param bizCode
*/
void insertStoreFile(StoreBizType bizType, StoreType type, String bizCode,String domain,String filePath);
}

+ 0
- 41
ruoyi-tool/src/main/java/com/ruoyi/tool/service/impl/StoreFileBizServiceImpl.java View File

@@ -1,41 +0,0 @@
package com.ruoyi.tool.service.impl;

import java.util.Date;
import java.util.List;
import com.ruoyi.tool.enums.StoreBizType;
import com.ruoyi.tool.enums.StoreType;
import com.ruoyi.tool.oss.OssResObj;
import com.ruoyi.tool.service.StoreFileBizService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.tool.mapper.StoreFileMapper;
import com.ruoyi.tool.domain.StoreFile;

import javax.annotation.Resource;

/**
* 文件Service业务层处理
*
* @author rongxin
* @date 2023-09-06
*/
@Service
public class StoreFileBizServiceImpl implements StoreFileBizService {
@Resource
private StoreFileMapper storeFileMapper;

@Override
public void insertStoreFile(StoreBizType bizType, StoreType type, String bizCode, String domain,
String filePath) {
Date date = new Date();
StoreFile storeFile = new StoreFile();
storeFile.setBizCode(bizCode);
storeFile.setBizType(bizType.getCode());
storeFile.setType(type.getCode());
storeFile.setDomain(domain);
storeFile.setFilePath(filePath);
storeFile.setStatus(1L);
storeFile.setCreateTime(date);
storeFileMapper.insertStoreFile(storeFile);
}
}

+ 0
- 163
ruoyi-tool/src/main/java/com/ruoyi/tool/service/impl/StoreFileServiceImpl.java View File

@@ -1,163 +0,0 @@
package com.ruoyi.tool.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.tool.mapper.StoreFileMapper;
import com.ruoyi.tool.domain.StoreFile;
import com.ruoyi.tool.service.IStoreFileService;
import org.springframework.transaction.annotation.Transactional;
import org.apache.commons.collections4.ListUtils;

/**
* 文件Service业务层处理
*
* @author rongxin
* @date 2023-09-06
*/
@Service
public class StoreFileServiceImpl implements IStoreFileService
{
@Autowired
private StoreFileMapper storeFileMapper;

/**
* 查询文件
*
* @param id 文件主键
* @return 文件
*/
@Override
public StoreFile selectStoreFileById(Long id)
{
return storeFileMapper.selectStoreFileById(id);
}

/**
* 查询文件列表
*
* @param storeFile 文件
* @return 文件
*/
@Override
public List<StoreFile> selectStoreFileList(StoreFile storeFile)
{
return storeFileMapper.selectStoreFileList(storeFile);
}

/**
* 新增文件
*
* @param storeFile 文件
* @return 结果
*/
@Override
public int insertStoreFile(StoreFile storeFile)
{
storeFile.setCreateTime(DateUtils.getNowDate());
return storeFileMapper.insertStoreFile(storeFile);
}

/**
* 批量新增文件
*
* @param list 文件
* @return 结果
*/
@Override
@Transactional
public int insertStoreFileBatch(List<StoreFile> list){
List<List<StoreFile>> splists = ListUtils.partition(list, 50);
splists.forEach(splist->{
storeFileMapper.insertStoreFileBatch(splist);
});
return 1;
}

/**
* 修改文件
*
* @param storeFile 文件
* @return 结果
*/
@Override
public int updateStoreFile(StoreFile storeFile)
{
storeFile.setUpdateTime(DateUtils.getNowDate());
return storeFileMapper.updateStoreFile(storeFile);
}

/**
* 批量修改 文件
*
* @param list 文件
* @return 结果
*/
@Override
@Transactional
public int updateStoreFileBatch(List<StoreFile> list) {
List<List<StoreFile>> splists = ListUtils.partition(list, 50);
splists.forEach(splist->{
storeFileMapper.updateStoreFileBatch(splist);
});
return 1;
}

/**
* 批量删除文件
*
* @param ids 需要删除的文件主键
* @return 结果
*/
@Override
public int deleteStoreFileByIds(Long[] ids)
{
return storeFileMapper.deleteStoreFileByIds(ids);
}

/**
* 删除文件信息
*
* @param id 文件主键
* @return 结果
*/
@Override
public int deleteStoreFileById(Long id)
{
return storeFileMapper.deleteStoreFileById(id);
}

/**
* 单条条件查询文件
*
* @param storeFile 文件
* @return 文件条目
*/
@Override
public StoreFile selectStoreFile(StoreFile storeFile) {
return storeFileMapper.selectStoreFile(storeFile);
}

/**
* 条件查询文件数量
*
* @param storeFile 文件
* @return 文件数量
*/
@Override
public Long selectStoreFileCount(StoreFile storeFile) {
return storeFileMapper.selectStoreFileCount(storeFile);
}

/**
* 条件查询文件是否存在
*
* @param storeFile 文件
* @return 文件是否存在
*/
@Override
public boolean selectStoreFileExists(StoreFile storeFile) {
return storeFileMapper.selectStoreFileExists(storeFile) > 0;
}
}

+ 0
- 214
ruoyi-tool/src/main/resources/mapper/tool/StoreFileMapper.xml View File

@@ -1,214 +0,0 @@
<?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.ruoyi.tool.mapper.StoreFileMapper">
<resultMap type="com.ruoyi.tool.domain.StoreFile" id="StoreFileResult">
<result property="id" column="id" />
<result property="bizCode" column="biz_code" />
<result property="bizType" column="biz_type" />
<result property="type" column="type" />
<result property="domain" column="domain" />
<result property="filePath" column="file_path" />
<result property="description" column="description" />
<result property="fileName" column="file_name" />
<result property="status" column="status" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>

<sql id="selectStoreFileVo">
select id, biz_code, biz_type, type, domain, file_path, description, file_name, status, create_by, create_time, update_by, update_time from td_store_file
</sql>

<select id="selectStoreFileList" parameterType="com.ruoyi.tool.domain.StoreFile" resultMap="StoreFileResult">
<include refid="selectStoreFileVo"/>
<where>
<if test="bizCode != null and bizCode != ''"> and biz_code = #{bizCode}</if>
<if test="bizType != null "> and biz_type = #{bizType}</if>
<if test="type != null "> and type = #{type}</if>
<if test="domain != null and domain != ''"> and domain = #{domain}</if>
<if test="filePath != null and filePath != ''"> and file_path = #{filePath}</if>
<if test="description != null and description != ''"> and description = #{description}</if>
<if test="fileName != null and fileName != ''"> and file_name like concat('%', #{fileName}, '%')</if>
<if test="status != null "> and status = #{status}</if>
</where>
</select>
<select id="selectStoreFileById" parameterType="Long" resultMap="StoreFileResult">
<include refid="selectStoreFileVo"/>
where id = #{id}
</select>
<insert id="insertStoreFile" parameterType="com.ruoyi.tool.domain.StoreFile" useGeneratedKeys="true" keyProperty="id">
insert into td_store_file
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="bizCode != null">biz_code,</if>
<if test="bizType != null">biz_type,</if>
<if test="type != null">type,</if>
<if test="domain != null">domain,</if>
<if test="filePath != null">file_path,</if>
<if test="description != null">description,</if>
<if test="fileName != null">file_name,</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>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="bizCode != null">#{bizCode},</if>
<if test="bizType != null">#{bizType},</if>
<if test="type != null">#{type},</if>
<if test="domain != null">#{domain},</if>
<if test="filePath != null">#{filePath},</if>
<if test="description != null">#{description},</if>
<if test="fileName != null">#{fileName},</if>
<if test="status != null">#{status},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>

<!--批量新增-->
<insert id="insertStoreFileBatch" parameterType="list" useGeneratedKeys="true" keyProperty="id">
insert into td_store_file
<trim prefix="(" suffix=")" suffixOverrides=",">
biz_code,
biz_type,
type,
domain,
file_path,
description,
file_name,
status,
create_by,
create_time,
update_by,
update_time,
</trim>
values
<foreach item="item" collection="list" separator="," >
<trim prefix="(" suffix=")" suffixOverrides=",">
#{item.bizCode},
#{item.bizType},
#{item.type},
#{item.domain},
#{item.filePath},
#{item.description},
#{item.fileName},
#{item.status},
#{item.createBy},
#{item.createTime},
#{item.updateBy},
#{item.updateTime},
</trim>
</foreach>
</insert>

<update id="updateStoreFile" parameterType="com.ruoyi.tool.domain.StoreFile">
update td_store_file
<trim prefix="SET" suffixOverrides=",">
<if test="bizCode != null">biz_code = #{bizCode},</if>
<if test="bizType != null">biz_type = #{bizType},</if>
<if test="type != null">type = #{type},</if>
<if test="domain != null">domain = #{domain},</if>
<if test="filePath != null">file_path = #{filePath},</if>
<if test="description != null">description = #{description},</if>
<if test="fileName != null">file_name = #{fileName},</if>
<if test="status != null">status = #{status},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>

<!--批量更新-->
<update id="updateStoreFileBatch" parameterType="list" >
<foreach collection="list" item="item" index="index" open="" close="" separator=";">
update td_store_file
<set>
<if test="item.bizCode != null">biz_code = #{item.bizCode},</if>
<if test="item.bizType != null">biz_type = #{item.bizType},</if>
<if test="item.type != null">type = #{item.type},</if>
<if test="item.domain != null">domain = #{item.domain},</if>
<if test="item.filePath != null">file_path = #{item.filePath},</if>
<if test="item.description != null">description = #{item.description},</if>
<if test="item.fileName != null">file_name = #{item.fileName},</if>
<if test="item.status != null">status = #{item.status},</if>
<if test="item.createBy != null">create_by = #{item.createBy},</if>
<if test="item.createTime != null">create_time = #{item.createTime},</if>
<if test="item.updateBy != null">update_by = #{item.updateBy},</if>
<if test="item.updateTime != null">update_time = #{item.updateTime},</if>
</set>
where id = #{item.id}
</foreach>
</update>

<delete id="deleteStoreFileById" parameterType="Long">
delete from td_store_file where id = #{id}
</delete>

<delete id="deleteStoreFileByIds" parameterType="String">
delete from td_store_file where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>

<!--单条条件查询-->
<select id="selectStoreFile" parameterType="com.ruoyi.tool.domain.StoreFile" resultMap="StoreFileResult">
<include refid="selectStoreFileVo"/>
<where>
<if test="bizCode != null and bizCode != ''"> and biz_code = #{bizCode}</if>
<if test="bizType != null "> and biz_type = #{bizType}</if>
<if test="type != null "> and type = #{type}</if>
<if test="domain != null and domain != ''"> and domain = #{domain}</if>
<if test="filePath != null and filePath != ''"> and file_path = #{filePath}</if>
<if test="description != null and description != ''"> and description = #{description}</if>
<if test="fileName != null and fileName != ''"> and file_name like concat('%', #{fileName}, '%')</if>
<if test="status != null "> and status = #{status}</if>
</where>
limit 1
</select>

<!--条件查询数量-->
<select id="selectStoreFileCount" parameterType="com.ruoyi.tool.domain.StoreFile" resultType="Long">
select count(*) from td_store_file
<where>
<if test="bizCode != null and bizCode != ''"> and biz_code = #{bizCode}</if>
<if test="bizType != null "> and biz_type = #{bizType}</if>
<if test="type != null "> and type = #{type}</if>
<if test="domain != null and domain != ''"> and domain = #{domain}</if>
<if test="filePath != null and filePath != ''"> and file_path = #{filePath}</if>
<if test="description != null and description != ''"> and description = #{description}</if>
<if test="fileName != null and fileName != ''"> and file_name like concat('%', #{fileName}, '%')</if>
<if test="status != null "> and status = #{status}</if>
</where>
</select>

<!--条件查询是否存在-->
<select id="selectStoreFileExists" parameterType="com.ruoyi.tool.domain.StoreFile" resultType="int">
select exists (
select 1 from td_store_file
<where>
<if test="bizCode != null and bizCode != ''"> and biz_code = #{bizCode}</if>
<if test="bizType != null "> and biz_type = #{bizType}</if>
<if test="type != null "> and type = #{type}</if>
<if test="domain != null and domain != ''"> and domain = #{domain}</if>
<if test="filePath != null and filePath != ''"> and file_path = #{filePath}</if>
<if test="description != null and description != ''"> and description = #{description}</if>
<if test="fileName != null and fileName != ''"> and file_name like concat('%', #{fileName}, '%')</if>
<if test="status != null "> and status = #{status}</if>
</where>
limit 1
)
</select>
</mapper>

Loading…
Cancel
Save