|
@@ -4,12 +4,16 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.ruoyi.app.domain.TbProfileImg;
|
|
|
import com.ruoyi.app.service.ITbProfileImgService;
|
|
|
import com.ruoyi.common.annotation.Log;
|
|
|
+import com.ruoyi.common.config.RuoYiConfig;
|
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
import com.ruoyi.common.enums.BusinessType;
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
+import com.ruoyi.common.utils.file.FileUploadUtils;
|
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
|
+import com.ruoyi.framework.config.ServerConfig;
|
|
|
+import com.ruoyi.system.domain.TPersonalImg;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
@@ -17,6 +21,7 @@ import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
@@ -34,6 +39,7 @@ import java.util.List;
|
|
|
public class TbProfileImgController extends BaseController {
|
|
|
|
|
|
private final ITbProfileImgService profileImgService;
|
|
|
+ private final ServerConfig serverConfig;
|
|
|
|
|
|
|
|
|
* 查询个人详情图片列表
|
|
@@ -54,6 +60,23 @@ public class TbProfileImgController extends BaseController {
|
|
|
List<TbProfileImg> list = profileImgService.list(lqw);
|
|
|
return getDataTable(list);
|
|
|
}
|
|
|
+
|
|
|
+ * 查询个人详情图片列表 ALL
|
|
|
+ */
|
|
|
+ @ApiOperation("查询个人详情图片分页列表")
|
|
|
+ @PreAuthorize("@ss.hasPermi('system:profile:img:list')")
|
|
|
+ @GetMapping("/all")
|
|
|
+ public AjaxResult all(TbProfileImg tbProfileImg) {
|
|
|
+ LambdaQueryWrapper<TbProfileImg> lqw = new LambdaQueryWrapper<TbProfileImg>();
|
|
|
+ if (tbProfileImg.getProfileId() != null){
|
|
|
+ lqw.eq(TbProfileImg::getProfileId ,tbProfileImg.getProfileId());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(tbProfileImg.getUrl())){
|
|
|
+ lqw.eq(TbProfileImg::getUrl ,tbProfileImg.getUrl());
|
|
|
+ }
|
|
|
+ List<TbProfileImg> list = profileImgService.list(lqw);
|
|
|
+ return AjaxResult.success(list);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
* 获取个人详情图片详细信息
|
|
@@ -102,8 +125,8 @@ public class TbProfileImgController extends BaseController {
|
|
|
@PreAuthorize("@ss.hasPermi('system:profile:img:remove')" )
|
|
|
@Log(title = "个人详情图片" , businessType = BusinessType.DELETE)
|
|
|
@ApiImplicitParam(name = "id", value = "图片id",paramType="Long")
|
|
|
- @GetMapping("/delImg")
|
|
|
- public AjaxResult delImg(Long id) {
|
|
|
+ @GetMapping("/del/{id}")
|
|
|
+ public AjaxResult delImg(@PathVariable Long id) {
|
|
|
if (id == null){
|
|
|
return AjaxResult.error("id不能为空");
|
|
|
}
|
|
@@ -113,8 +136,8 @@ public class TbProfileImgController extends BaseController {
|
|
|
@ApiOperation("获取个人详情 图片列表")
|
|
|
@PreAuthorize("@ss.hasPermi('system:profile:img:list')")
|
|
|
@ApiImplicitParam(name = "profileId", value = "详情id",paramType="Long")
|
|
|
- @GetMapping("/getByProfileId/{profileId}")
|
|
|
- public AjaxResult listImg(Long profileId) {
|
|
|
+ @GetMapping("/getImgByProfileId/{profileId}")
|
|
|
+ public AjaxResult listImg(@PathVariable Long profileId) {
|
|
|
if (profileId == null){
|
|
|
return AjaxResult.error("详情Id不能为空");
|
|
|
}
|
|
@@ -123,4 +146,31 @@ public class TbProfileImgController extends BaseController {
|
|
|
);
|
|
|
return AjaxResult.success(list);
|
|
|
}
|
|
|
+
|
|
|
+ @PreAuthorize("@ss.hasPermi('system:profile:img:add')" )
|
|
|
+ @PostMapping("/upload")
|
|
|
+ public AjaxResult uploadFile(MultipartFile file, String profileId) throws Exception {
|
|
|
+ if (profileId == null) {
|
|
|
+ return AjaxResult.error("个人详情ID不能为空");
|
|
|
+ }
|
|
|
+ try {
|
|
|
+
|
|
|
+ String filePath = RuoYiConfig.getProfile() + "/profile/"+profileId;
|
|
|
+
|
|
|
+ String fileName = FileUploadUtils.upload(filePath, file);
|
|
|
+ String url = serverConfig.getUrl() + fileName;
|
|
|
+ AjaxResult ajax = AjaxResult.success();
|
|
|
+ ajax.put("fileName", fileName);
|
|
|
+ ajax.put("url", url);
|
|
|
+
|
|
|
+ TbProfileImg item = new TbProfileImg();
|
|
|
+ item.setProfileId(Long.parseLong(profileId));
|
|
|
+ item.setUrl(fileName);
|
|
|
+ profileImgService.save(item);
|
|
|
+
|
|
|
+ return ajax;
|
|
|
+ } catch (Exception e) {
|
|
|
+ return AjaxResult.error(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|