xiaoshushu преди 4 години
родител
ревизия
394bda4068
променени са 1 файла, в които са добавени 23 реда и са изтрити 23 реда
  1. 23 23
      ruoyi-app/src/main/java/com/ruoyi/app/controller/MyProfileController.java

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

@@ -31,24 +31,24 @@ import java.util.List;
  * @author Alex
  * @date 2020-10-11
  */
-@Api(value = "个人详情",tags = "个人详情")
+@Api(value = "个人详情", tags = "个人详情")
 @RequiredArgsConstructor(onConstructor_ = @Autowired)
 @RestController
-@RequestMapping("/app/profile" )
+@RequestMapping("/app/profile")
 public class MyProfileController extends AppBaseController {
 
     private final ITbMyProfileService profileService;
     private final ITbProfileImgService profileImgService;
 
     @ApiOperation("个人详情列表")
-    @ApiImplicitParam(name = "appUserId", value = "会员ID",paramType="Long")
+    @ApiImplicitParam(name = "appUserId", value = "会员ID", paramType = "Long")
     @GetMapping("/list")
     public AjaxResult list(Long appUserId) {
-        if (appUserId == null){
+        if (appUserId == null) {
             return AjaxResult.error("参数为空");
         }
         List<TbMyProfile> profileList = profileService.list(new LambdaQueryWrapper<TbMyProfile>()
-            .eq(TbMyProfile::getAppUserId, appUserId)
+                .eq(TbMyProfile::getAppUserId, appUserId)
         );
         if (profileList.size() > 0) {
             List<Long> ids = new ArrayList<>();
@@ -56,7 +56,7 @@ public class MyProfileController extends AppBaseController {
                 ids.add(item.getId());
             });
             List<TbProfileImg> imgList = profileImgService.list(new LambdaQueryWrapper<TbProfileImg>()
-                .in(TbProfileImg::getProfileId, ids)
+                    .in(TbProfileImg::getProfileId, ids)
             );
             if (imgList.size() > 0) {
                 profileList.forEach(item -> {
@@ -93,26 +93,26 @@ public class MyProfileController extends AppBaseController {
             profile.setUpdateBy(user.getUserId());
             profile.setUpdateTime(date);
         }
-
+        profileService.saveOrUpdate(profile);
+        //先删除,在重新添加图片
+        profileImgService.remove(new LambdaQueryWrapper<TbProfileImg>()
+                .eq(TbProfileImg::getProfileId, profile.getId())
+        );
         if (profile.getImgList().size() > 0) {
-            //先删除,在重新添加图片
-            profileImgService.remove(new LambdaQueryWrapper<TbProfileImg>()
-                    .eq(TbProfileImg::getProfileId, profile.getId())
-            );
             List<TbProfileImg> imgList = profile.getImgList();
             imgList.forEach(item -> {
                 item.setProfileId(profile.getId());
             });
             profileImgService.saveBatch(imgList);
         }
-        return toAjax(profileService.saveOrUpdate(profile) ? 1 : 0);
+        return AjaxResult.success();
     }
 
     @ApiOperation("获取个人详情")
-    @ApiImplicitParam(name = "id", value = "主键id",paramType="Long")
+    @ApiImplicitParam(name = "id", value = "主键id", paramType = "Long")
     @GetMapping("/get")
-    public AjaxResult get(Long id){
-        if (id == null){
+    public AjaxResult get(Long id) {
+        if (id == null) {
             return AjaxResult.error("id不能为空");
         }
         TbMyProfile profile = profileService.getById(id);
@@ -121,7 +121,7 @@ public class MyProfileController extends AppBaseController {
         }
         // 图片列表
         List<TbProfileImg> imgList = profileImgService.list(new LambdaQueryWrapper<TbProfileImg>()
-            .eq(TbProfileImg::getProfileId, profile.getId())
+                .eq(TbProfileImg::getProfileId, profile.getId())
         );
         if (imgList.size() > 0) {
             profile.setImgList(imgList);
@@ -130,34 +130,34 @@ public class MyProfileController extends AppBaseController {
     }
 
     @ApiOperation("删除个人详情")
-    @ApiImplicitParam(name = "id", value = "主键id",paramType="Long")
+    @ApiImplicitParam(name = "id", value = "主键id", paramType = "Long")
     @GetMapping("/del")
     public AjaxResult del(Long id) {
-        if (id == null){
+        if (id == null) {
             return AjaxResult.error("id不能为空");
         }
         return toAjax(profileService.removeById(id) ? 1 : 0);
     }
 
     @ApiOperation("删除个人详情 图片")
-    @ApiImplicitParam(name = "id", value = "图片id",paramType="Long")
+    @ApiImplicitParam(name = "id", value = "图片id", paramType = "Long")
     @GetMapping("/delImg")
     public AjaxResult delImg(Long id) {
-        if (id == null){
+        if (id == null) {
             return AjaxResult.error("id不能为空");
         }
         return toAjax(profileImgService.removeById(id) ? 1 : 0);
     }
 
     @ApiOperation("获取个人详情 图片列表")
-    @ApiImplicitParam(name = "profileId", value = "详情id",paramType="Long")
+    @ApiImplicitParam(name = "profileId", value = "详情id", paramType = "Long")
     @GetMapping("/getImgByProfileId/{profileId}")
     public AjaxResult listImg(@PathVariable Long profileId) {
-        if (profileId == null){
+        if (profileId == null) {
             return AjaxResult.error("详情Id不能为空");
         }
         List<TbProfileImg> list = profileImgService.list(new LambdaQueryWrapper<TbProfileImg>()
-            .eq(TbProfileImg::getProfileId, profileId)
+                .eq(TbProfileImg::getProfileId, profileId)
         );
         return AjaxResult.success(list);
     }