Alex преди 4 години
родител
ревизия
5292c6acdb

+ 124 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TbMyProfileController.java

@@ -0,0 +1,124 @@
+package com.ruoyi.web.controller.api;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+
+import java.util.List;
+import java.util.Arrays;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import com.ruoyi.common.utils.StringUtils;
+import lombok.RequiredArgsConstructor;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.app.domain.TbMyProfile;
+import com.ruoyi.app.service.ITbMyProfileService;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.common.core.page.TableDataInfo;
+
+/**
+ * 个人详情
+ * 
+ * @author Alex
+ * @date 2020-11-06
+ */
+@Api(value = "个人详情", tags = "个人详情")
+@RequiredArgsConstructor(onConstructor_ = @Autowired)
+@RestController
+@RequestMapping("/system/profile" )
+public class TbMyProfileController extends BaseController {
+
+    private final ITbMyProfileService iTbMyProfileService;
+
+    /**
+     * 查询个人详情列表
+     */
+    @ApiOperation("查询个人详情列表")
+    @PreAuthorize("@ss.hasPermi('system:profile:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(TbMyProfile tbMyProfile)
+    {
+        startPage();
+        LambdaQueryWrapper<TbMyProfile> lqw = new LambdaQueryWrapper<TbMyProfile>();
+        if (tbMyProfile.getAppUserId() != null){
+            lqw.eq(TbMyProfile::getAppUserId ,tbMyProfile.getAppUserId());
+        }
+        if (StringUtils.isNotBlank(tbMyProfile.getTitle())){
+            lqw.eq(TbMyProfile::getTitle ,tbMyProfile.getTitle());
+        }
+        if (StringUtils.isNotBlank(tbMyProfile.getCotents())){
+            lqw.eq(TbMyProfile::getCotents ,tbMyProfile.getCotents());
+        }
+        List<TbMyProfile> list = iTbMyProfileService.list(lqw);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出个人详情列表
+     */
+    @ApiOperation("导出个人详情列表")
+    @PreAuthorize("@ss.hasPermi('system:profile:export')" )
+    @Log(title = "个人详情" , businessType = BusinessType.EXPORT)
+    @GetMapping("/export" )
+    public AjaxResult export(TbMyProfile tbMyProfile) {
+        LambdaQueryWrapper<TbMyProfile> lqw = new LambdaQueryWrapper<TbMyProfile>(tbMyProfile);
+        List<TbMyProfile> list = iTbMyProfileService.list(lqw);
+        ExcelUtil<TbMyProfile> util = new ExcelUtil<TbMyProfile>(TbMyProfile. class);
+        return util.exportExcel(list, "profile" );
+    }
+
+    /**
+     * 获取个人详情详细信息
+     */
+    @ApiOperation("获取个人详情详细信息")
+    @PreAuthorize("@ss.hasPermi('system:profile:query')" )
+    @GetMapping(value = "/{id}" )
+    public AjaxResult getInfo(@PathVariable("id" ) Long id) {
+        return AjaxResult.success(iTbMyProfileService.getById(id));
+    }
+
+    /**
+     * 新增个人详情
+     */
+    @ApiOperation("新增个人详情")
+    @PreAuthorize("@ss.hasPermi('system:profile:add')" )
+    @Log(title = "个人详情" , businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody TbMyProfile tbMyProfile) {
+        return toAjax(iTbMyProfileService.save(tbMyProfile) ? 1 : 0);
+    }
+
+    /**
+     * 修改个人详情
+     */
+    @ApiOperation("修改个人详情")
+    @PreAuthorize("@ss.hasPermi('system:profile:edit')" )
+    @Log(title = "个人详情" , businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody TbMyProfile tbMyProfile) {
+        return toAjax(iTbMyProfileService.updateById(tbMyProfile) ? 1 : 0);
+    }
+
+    /**
+     * 删除个人详情
+     */
+    @ApiOperation("删除个人详情")
+    @PreAuthorize("@ss.hasPermi('system:profile:remove')" )
+    @Log(title = "个人详情" , businessType = BusinessType.DELETE)
+    @DeleteMapping("/{ids}" )
+    public AjaxResult remove(@PathVariable Long[] ids) {
+        return toAjax(iTbMyProfileService.removeByIds(Arrays.asList(ids)) ? 1 : 0);
+    }
+}

+ 54 - 4
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TbProfileImgController.java

@@ -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());
+        }
+    }
 }

+ 3 - 2
ruoyi-app/src/main/java/com/ruoyi/app/controller/MyProfileController.java

@@ -18,6 +18,7 @@ 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.*;
 
 import java.util.Date;
@@ -129,8 +130,8 @@ public class MyProfileController extends AppBaseController {
 
     @ApiOperation("获取个人详情 图片列表")
     @ApiImplicitParam(name = "profileId", value = "详情id",paramType="Long")
-    @GetMapping("/profileId")
-    public AjaxResult listImg(Long profileId) {
+    @GetMapping("/getImgByProfileId/{profileId}")
+    public AjaxResult listImg(@PathVariable Long profileId) {
         if (profileId == null){
             return AjaxResult.error("详情Id不能为空");
         }

+ 2 - 0
ruoyi-system/src/main/java/com/ruoyi/app/domain/TbMyProfile.java

@@ -1,5 +1,6 @@
 package com.ruoyi.app.domain;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import com.fasterxml.jackson.annotation.JsonFormat;
@@ -77,5 +78,6 @@ public class TbMyProfile implements Serializable {
 
     /** 图片列表 */
     @ApiModelProperty(value="图片列表")
+    @TableField(exist = false)
     private List<TbProfileImg> imgList;
 }

+ 1 - 0
ry-lineage.sh

@@ -51,4 +51,5 @@ start(){
 }
 
 start ruoyi-admin.jar "-Xms256m -Xmx500m"
+sleep 15s
 start ruoyi-app.jar "-Xms256m -Xmx500m"