mirror of
https://gitee.com/dromara/RuoYi-Cloud-Plus.git
synced 2025-09-06 04:18:07 +00:00
add 整合 seata 1.4.2 对接 nacos 注册中心 配置中心
This commit is contained in:
@@ -70,6 +70,11 @@
|
||||
<artifactId>ruoyi-common-dubbo</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common-seata</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common-web</artifactId>
|
||||
|
@@ -5,9 +5,8 @@ import com.ruoyi.common.core.utils.file.FileUtils;
|
||||
import com.ruoyi.file.api.domain.SysFile;
|
||||
import com.ruoyi.file.service.ISysFileService;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@@ -18,12 +17,12 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Api(tags = "文件处理")
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
public class SysFileController {
|
||||
private static final Logger log = LoggerFactory.getLogger(SysFileController.class);
|
||||
|
||||
@Autowired
|
||||
private ISysFileService sysFileService;
|
||||
private final ISysFileService sysFileService;
|
||||
|
||||
/**
|
||||
* 文件上传请求
|
||||
|
@@ -31,6 +31,9 @@ public class RemoteFileServiceImpl implements RemoteFileService {
|
||||
*/
|
||||
@Override
|
||||
public SysFile upload(String name, String originalFilename, String contentType, byte[] file) {
|
||||
// todo 临时用于测试 seata
|
||||
// throw new ServiceException("上传文件失败");
|
||||
|
||||
MultipartFile multipartFile = getMultipartFile(name, originalFilename, contentType, file);
|
||||
try {
|
||||
// 上传并返回访问地址
|
||||
|
@@ -1,19 +1,19 @@
|
||||
package com.ruoyi.file.service;
|
||||
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* 文件上传接口
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface ISysFileService {
|
||||
/**
|
||||
* 文件上传接口
|
||||
*
|
||||
* @param file 上传的文件
|
||||
* @return 访问地址
|
||||
* @throws Exception
|
||||
*/
|
||||
public String uploadFile(MultipartFile file) throws Exception;
|
||||
}
|
||||
package com.ruoyi.file.service;
|
||||
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* 文件上传接口
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface ISysFileService {
|
||||
/**
|
||||
* 文件上传接口
|
||||
*
|
||||
* @param file 上传的文件
|
||||
* @return 访问地址
|
||||
* @throws Exception
|
||||
*/
|
||||
String uploadFile(MultipartFile file) throws Exception;
|
||||
}
|
||||
|
@@ -86,6 +86,11 @@
|
||||
<artifactId>ruoyi-common-dubbo</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common-seata</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common-job</artifactId>
|
||||
|
@@ -108,9 +108,13 @@ public class SysProfileController extends BaseController {
|
||||
/**
|
||||
* 头像上传
|
||||
*/
|
||||
// @GlobalTransactional(rollbackFor = Exception.class)
|
||||
@Log(title = "用户头像", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/avatar")
|
||||
public AjaxResult avatar(@RequestParam("avatarfile") MultipartFile file) throws IOException {
|
||||
// todo 临时用于测试 seata
|
||||
// userService.insertUser(new SysUser().setUserName("test").setNickName("test"));
|
||||
|
||||
if (!file.isEmpty()) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
SysFile sysFile = remoteFileService.upload(file.getName(), file.getOriginalFilename(), file.getContentType(), file.getBytes());
|
||||
|
Reference in New Issue
Block a user