Aslee 2 лет назад
Родитель
Сommit
bb8f827078

+ 1 - 0
src/main/java/com/caimei/controller/admin/auth/AuthApi.java

@@ -140,6 +140,7 @@ public class AuthApi {
         if (null == sysUser) {
             return ResponseJson.error("用户信息异常", null);
         }
+
         // 获取供应商用户id
         Integer userIdentity = sysUser.getUserIdentity();
         Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;

+ 28 - 8
src/main/java/com/caimei/controller/admin/auth/ShopApi.java

@@ -207,7 +207,7 @@ public class ShopApi {
         List<ShopInfoDto> shopInfoList = new ArrayList<>();
         List<String> brandNameList = new ArrayList<>();
         for (Map<String, Object> infoMap : shopInfoData) {
-            Integer id = (Integer) infoMap.get("id");
+            Integer infoId = (Integer) infoMap.get("info");
             String brandName = (String) infoMap.get("brandName");
             String brandLogo = (String) infoMap.get("brandLogo");
             String producePlace = (String) infoMap.get("producePlace");
@@ -221,7 +221,7 @@ public class ShopApi {
                 return ResponseJson.error("品牌名称重复");
             }
             ShopInfoDto shopInfo = new ShopInfoDto();
-            shopInfo.setId(id);
+            shopInfo.setInfoId(infoId);
             shopInfo.setBrandName(brandName);
             shopInfo.setBrandLogo(brandLogo);
             shopInfo.setProducePlace(producePlace);
@@ -377,16 +377,35 @@ public class ShopApi {
         if (null == sysUser) {
             return ResponseJson.error("用户信息异常", null);
         }
-        // 修改用户信息:供应商和子用户都可以修改个人信息,直接取id即可
-        Integer authUserId = sysUser.getId();
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
         if (null == authUserId) {
-            return ResponseJson.error("用户id不能为空", null);
+            return ResponseJson.error("供应商用户id不能为空", null);
         }
         JSONObject parseObject = JSONObject.parseObject(params);
-        String linkMan = parseObject.getString("verifyCode");
+        String linkMan = parseObject.getString("linkMan");
         return shopService.changeLinkMan(authUserId, linkMan);
     }
 
+    @ApiOperation("修改公司logo")
+    @ApiImplicitParam(name = "params", value = "logo:公司logo", required = true)
+    @PostMapping("/logo/change")
+    public ResponseJson changeLogo(@CurrentUser SysUser sysUser, @RequestBody String params) {
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+        if (null == authUserId) {
+            return ResponseJson.error("供应商用户id不能为空", null);
+        }
+        JSONObject parseObject = JSONObject.parseObject(params);
+        String logo = parseObject.getString("logo");
+        return shopService.changeLogo(authUserId, logo);
+    }
+
     @ApiOperation("登录账号绑定")
     @ApiImplicitParam(name = "params", value = "mobile:手机号;verifyCode:验证码;loginAccount:登录账号;", required = true)
     @PostMapping("/account/bind")
@@ -394,8 +413,9 @@ public class ShopApi {
         if (null == sysUser) {
             return ResponseJson.error("用户信息异常", null);
         }
-        // 修改用户信息:供应商和子用户都可以修改个人信息,直接取id即可
-        Integer authUserId = sysUser.getId();
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
         if (null == authUserId) {
             return ResponseJson.error("供应商用户id不能为空", null);
         }

+ 12 - 2
src/main/java/com/caimei/controller/admin/auth/UserApi.java

@@ -1,7 +1,9 @@
 package com.caimei.controller.admin.auth;
 
+import com.caimei.annotation.CurrentUser;
 import com.caimei.model.ResponseJson;
 import com.caimei.model.dto.PasswordDto;
+import com.caimei.model.po.SysUser;
 import com.caimei.model.vo.UserLoginVo;
 import com.caimei.service.auth.UserService;
 import io.swagger.annotations.Api;
@@ -42,7 +44,6 @@ public class UserApi {
     /**
      * 修改密码
      * @param passwordDto {
-     *                           authUserId         用户id
      *                           oldPassword        旧密码
      *                           newPassword        新密码
      *                           confirmPwd         确认密码
@@ -50,7 +51,16 @@ public class UserApi {
      */
     @ApiOperation("修改密码")
     @PostMapping("/update/password")
-    public ResponseJson updatePassword(@RequestBody PasswordDto passwordDto) {
+    public ResponseJson updatePassword(@CurrentUser SysUser sysUser, @RequestBody PasswordDto passwordDto) {
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 供应商和子用户都可以修改密码,直接取id即可
+        Integer authUserId = sysUser.getId();
+        if (null == authUserId) {
+            return ResponseJson.error("用户id不能为空", null);
+        }
+        passwordDto.setAuthUserId(authUserId);
         return userService.updatePassword(passwordDto);
     }
 }

+ 2 - 0
src/main/java/com/caimei/mapper/cmMapper/ShopMapper.java

@@ -96,4 +96,6 @@ public interface ShopMapper {
 
     void updateShopLinkMan(@Param("authUserId") Integer authUserId, @Param("linkMan") String linkMan);
 
+    void updateShopLogo(@Param("authUserId") Integer authUserId, @Param("logo") String logo);
+
 }

+ 1 - 1
src/main/java/com/caimei/model/dto/ShopInfoDto.java

@@ -8,7 +8,7 @@ import lombok.Data;
  */
 @Data
 public class ShopInfoDto {
-    private Integer id;
+    private Integer infoId;
 
     /**
      * 用户Id

+ 5 - 0
src/main/java/com/caimei/model/vo/ShopInfoVo.java

@@ -14,6 +14,11 @@ public class ShopInfoVo {
      */
     private Integer brandId;
 
+    /**
+     * 供应商信息id
+     */
+    private Integer infoId;
+
     /**
      * 所属品牌名称
      */

+ 5 - 0
src/main/java/com/caimei/service/auth/ShopService.java

@@ -175,4 +175,9 @@ public interface ShopService {
      * 更改联系人
      */
     ResponseJson changeLinkMan(Integer authUserId, String linkMan);
+
+    /**
+     * 更改logo
+     */
+    ResponseJson changeLogo(Integer authUserId, String logo);
 }

+ 9 - 2
src/main/java/com/caimei/service/auth/impl/ShopServiceImpl.java

@@ -276,7 +276,7 @@ public class ShopServiceImpl implements ShopService {
             // 数据库中品牌列表数据
             List<ShopBrandVo> dbBrandList = shopMapper.getDbInfoBrandList(shop.getAuthUserId());
             // 原品牌列表编辑后剩余的品牌id列表
-            List<Integer> newBrandList = shopInfoList.stream().filter(shopInfo -> shopInfo.getId() != null).map(ShopInfoDto::getId).collect(Collectors.toList());
+            List<Integer> newBrandList = shopInfoList.stream().filter(shopInfo -> shopInfo.getInfoId() != null).map(ShopInfoDto::getInfoId).collect(Collectors.toList());
             for (ShopBrandVo dbBrand : dbBrandList) {
                 if (!newBrandList.contains(dbBrand.getId())) {
                     // 判断被删除的品牌下是否还有未删除的商品,若存在,提示供应商需要删除后才能删除品牌
@@ -294,7 +294,7 @@ public class ShopServiceImpl implements ShopService {
             shopInfoList.forEach(shopInfoVo -> {
                 shopInfoVo.setAuthUserId(shop.getAuthUserId());
                 // 保存供应商信息数据
-                if (shopInfoVo.getId() != null) {
+                if (shopInfoVo.getInfoId() != null) {
                     // 更新
                     shopMapper.updateShopInfo(shopInfoVo);
                 } else {
@@ -486,4 +486,11 @@ public class ShopServiceImpl implements ShopService {
         shopMapper.updateShopLinkMan(authUserId, linkMan);
         return ResponseJson.success();
     }
+
+    @Override
+    public ResponseJson changeLogo(Integer authUserId, String logo) {
+        shopMapper.updateShopLogo(authUserId, logo);
+        return ResponseJson.success();
+    }
+
 }

+ 7 - 2
src/main/resources/mapper/ShopMapper.xml

@@ -50,7 +50,7 @@
             brandLogo    = #{brandLogo},
             producePlace = #{producePlace},
             manufacturer = #{manufacturer}
-        where id = #{id}
+        where id = #{infoId}
     </update>
     <update id="handleFeedback">
         update cm_brand_club_feedback
@@ -74,6 +74,11 @@
         set linkMan = #{linkMan}
         where authUserId = #{authUserId}
     </update>
+    <update id="updateShopLogo">
+        update cm_brand_auth_user
+        set logo = #{logo}
+        where authUserId = #{authUserId}
+    </update>
     <delete id="deleteStatementFile">
         delete from cm_brand_auth_file where id = #{id}
     </delete>
@@ -248,7 +253,7 @@
         where authUserId = #{authUserId}
     </select>
     <select id="getShopInfoByUserId" resultType="com.caimei.model.vo.ShopInfoVo">
-        select i.brandName,i.brandLogo,i.producePlace,i.manufacturer
+        select i.id as infoId, i.brandName,i.brandLogo,i.producePlace,i.manufacturer
         from cm_brand_auth_shop_info i
         where i.authUserId = #{authUserId}
     </select>