init
This commit is contained in:
@@ -8,7 +8,9 @@ import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.system.domain.vo.SysOssVo;
|
||||
import com.ruoyi.system.service.ISysOssService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@@ -20,14 +22,22 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
@RestController
|
||||
@RequestMapping("/api/file")
|
||||
@Tag(name = "文件接口")
|
||||
@Slf4j
|
||||
public class FileController {
|
||||
|
||||
@Autowired
|
||||
private ISysOssService iSysOssService;
|
||||
|
||||
@Log(title = "OSS对象存储", businessType = BusinessType.INSERT)
|
||||
@PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
@Operation(summary = "上传文件")
|
||||
public R<FileResp> upload(@RequestPart("file") MultipartFile file) {
|
||||
@Operation(summary = "上传文件",
|
||||
parameters = {
|
||||
@Parameter(name = "file", description = "文件", required = true),
|
||||
@Parameter(name = "type", description = "业务类型,dynamic=动态图片,user=用户相册,头像,im=聊天,common=其他", required = false)
|
||||
})
|
||||
public R<FileResp> upload(@RequestPart("file") MultipartFile file,
|
||||
String type) {
|
||||
log.error("上传文件图片类型 type={}",type);
|
||||
if (ObjectUtil.isNull(file)) {
|
||||
return R.fail("上传文件不能为空");
|
||||
}
|
||||
@@ -38,4 +48,27 @@ public class FileController {
|
||||
resp.setOriginalName(oss.getOriginalName());
|
||||
return R.ok(resp);
|
||||
}
|
||||
|
||||
|
||||
@Log(title = "OSS对象存储", businessType = BusinessType.INSERT)
|
||||
@PostMapping(value = "/uploadImage", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
@Operation(summary = "上传图片类型的文件",
|
||||
parameters = {
|
||||
@Parameter(name = "file", description = "文件", required = true),
|
||||
@Parameter(name = "type", description = "业务类型,dynamic=动态图片,user=用户相册,头像,im=聊天,common=其他", required = false)
|
||||
})
|
||||
public R<FileResp> uploadImage(@RequestPart("file") MultipartFile file,
|
||||
String type) {
|
||||
log.error("上传文件图片类型 type={}",type);
|
||||
if (ObjectUtil.isNull(file)) {
|
||||
return R.fail("上传文件不能为空");
|
||||
}
|
||||
SysOssVo oss = iSysOssService.upload(file);
|
||||
FileResp resp = new FileResp();
|
||||
resp.setUrl(oss.getUrl());
|
||||
resp.setPath(oss.getFileName());
|
||||
resp.setOriginalName(oss.getOriginalName());
|
||||
return R.ok(resp);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,8 +26,6 @@ public class UserDynamicAppController {
|
||||
|
||||
@Autowired
|
||||
private DynamicService dynamicService;
|
||||
@Autowired
|
||||
private UserFollowDynamicService userFollowDynamicService;
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "动态查询动态")
|
||||
@@ -37,24 +35,6 @@ public class UserDynamicAppController {
|
||||
return R.ok(resp.getRecords());
|
||||
}
|
||||
|
||||
@PostMapping("/star")
|
||||
@Operation(summary = "关注动态")
|
||||
@Log(title = "关注动态", businessType = BusinessType.OTHER, isSaveDb = false)
|
||||
public R<Void> star(@RequestBody DynamicStarReq query){
|
||||
query.setUserId(LoginHelper.getUserId());
|
||||
userFollowDynamicService.star(query);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@PostMapping("/unstar")
|
||||
@Operation(summary = "取消关注动态")
|
||||
@Log(title = "取消关注动态", businessType = BusinessType.OTHER, isSaveDb = false)
|
||||
public R<Void> unStar(@RequestBody DynamicStarReq query){
|
||||
query.setUserId(LoginHelper.getUserId());
|
||||
userFollowDynamicService.unStar(query);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@PostMapping("/push")
|
||||
@Operation(summary = "发布动态")
|
||||
@Log(title = "发布动态", businessType = BusinessType.OTHER, isSaveDb = false)
|
||||
|
||||
Reference in New Issue
Block a user