123
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package com.ruoyi.cai.controller.app;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.ruoyi.cai.dto.FileResp;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
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.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/file")
|
||||
@Tag(name = "文件接口")
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.ruoyi.cai.controller.app;
|
||||
|
||||
import com.ruoyi.cai.dto.app.dto.ImMessageDTO;
|
||||
import com.ruoyi.cai.manager.ImService;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.helper.LoginHelper;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/im")
|
||||
@Tag(name = "IM相关的接口")
|
||||
public class ImController {
|
||||
|
||||
@Autowired
|
||||
private ImService imService;
|
||||
|
||||
@PostMapping("/send/message")
|
||||
@Operation(summary = "发送消息")
|
||||
public R<Void> sendMessage(@Validated @RequestBody ImMessageDTO imMessageDTO){
|
||||
imService.sendMessage(LoginHelper.getUserId(),imMessageDTO);
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user