|
@@ -7,19 +7,23 @@ import com.ruoyi.app.domain.TbAppUser;
|
|
|
import com.ruoyi.app.domain.TbMyPublish;
|
|
|
import com.ruoyi.app.service.ITbAppUserService;
|
|
|
import com.ruoyi.app.service.ITbMyPublishService;
|
|
|
+import com.ruoyi.common.config.RuoYiConfig;
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
+import com.ruoyi.common.utils.file.FileUploadUtils;
|
|
|
+import com.ruoyi.framework.config.ServerConfig;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* 我的近况
|
|
@@ -34,7 +38,7 @@ import java.util.List;
|
|
|
public class MyPublishController extends AppBaseController {
|
|
|
|
|
|
private final ITbMyPublishService publishService;
|
|
|
- private final ITbAppUserService userService;
|
|
|
+ private final ServerConfig serverConfig;
|
|
|
|
|
|
/**
|
|
|
* 查询家族朋友圈
|
|
@@ -58,7 +62,7 @@ public class MyPublishController extends AppBaseController {
|
|
|
*/
|
|
|
@ApiOperation("我的近况 分页列表")
|
|
|
@ApiImplicitParam(name = "userId", value = "会员ID",paramType="Long")
|
|
|
- @GetMapping("/myList")
|
|
|
+ @GetMapping("/list")
|
|
|
public TableDataInfo pageList(Long userId) {
|
|
|
if (userId == null) {
|
|
|
return new TableDataInfo();
|
|
@@ -69,14 +73,30 @@ public class MyPublishController extends AppBaseController {
|
|
|
return publishService.pageList(tbMyPublish);
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation("我的近况 上传图片")
|
|
|
+ @ResponseBody
|
|
|
+ @PostMapping("/upload")
|
|
|
+ public AjaxResult add(@RequestParam(value = "file") MultipartFile files[]) throws Exception {
|
|
|
|
|
|
- @ApiOperation("登录信息")
|
|
|
- @GetMapping("/loginUser")
|
|
|
- public AjaxResult loginUser(){
|
|
|
-
|
|
|
- TbAppUser user = getLoginUser().getUser();
|
|
|
- return AjaxResult.success(user);
|
|
|
+ // 上传文件路径
|
|
|
+ String filePath = RuoYiConfig.getUploadPath()+"/publish";
|
|
|
+ if (files != null && files.length >= 1) {
|
|
|
+ try {
|
|
|
+ AjaxResult ajax = AjaxResult.success();
|
|
|
+ for (MultipartFile file : files) {
|
|
|
+ Map<String, Object> map = new HashMap<>(2);
|
|
|
+ // 上传并返回新文件名称
|
|
|
+ String fileName = FileUploadUtils.upload(filePath, file);
|
|
|
+ String url = serverConfig.getUrl() + fileName;
|
|
|
+ map.put("fileName", fileName);
|
|
|
+ map.put("url", url);
|
|
|
+ ajax.put("files", map);
|
|
|
+ }
|
|
|
+ return ajax;
|
|
|
+ } catch (Exception e) {
|
|
|
+ return AjaxResult.error(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return AjaxResult.success("上传成功");
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|