Explorar o código

http://192.168.0.21/index.php?m=bug&f=view&bugID=25872 绑定修改

lyhzzz %!s(int64=3) %!d(string=hai) anos
pai
achega
80c033bd94

+ 1 - 0
platform-common/src/main/java/com/platform/dao/custom/MySysUserBrandDao.java

@@ -28,4 +28,5 @@ public interface MySysUserBrandDao extends BaseMapper<SysUserBrand> {
     List<SysUserBrand> queryList(@Param("userId") Long userId);
 
 
+    void unbindUserByBrandId(@Param("brandId")Integer brandId,@Param("userIdList") List<Long> userIdList);
 }

+ 4 - 0
platform-common/src/main/java/com/platform/service/custom/MySysUserBrandService.java

@@ -122,4 +122,8 @@ public class MySysUserBrandService extends SysUserBrandServiceImpl {
         wrapper.eq("user_id",userId);
         remove(wrapper);
     }
+
+    public void unbindUserByBrandId(Integer brandId,List<Long> userIdList) {
+        mySysUserBrandDao.unbindUserByBrandId(brandId,userIdList);
+    }
 }

+ 10 - 0
platform-common/src/main/resources/com/platform/dao/custom/MySysUserBrandDao.xml

@@ -28,5 +28,15 @@
         select brand_id from sys_user_brand where user_id = #{value} and enable = 1
     </select>
 
+	<delete id="unbindUserByBrandId" >
+        delete  from sys_user_brand where brand_id = #{brandId}
+		<if test="userIdList != null and userIdList.size() > 0">
+			and user_id not in
+			<foreach collection="userIdList" index="index" item="userId" open="(" separator="," close=")">
+				#{userId}
+			</foreach>
+		</if>
+    </delete>
+
 
 </mapper>

+ 5 - 4
platform-shop/src/main/java/com/platform/controller/BrandController.java

@@ -16,6 +16,7 @@ import com.platform.service.custom.TmBrandTypeService;
 import com.platform.service.impl.ZhiHouseService;
 import com.platform.utils.*;
 import com.platform.vo.BrandBindUserVo;
+import com.platform.vo.BrandRequestVo;
 import com.platform.vo.BrandRspVo;
 import com.platform.vos.CurrentUserLoginVo;
 import com.platform.vos.TbUser;
@@ -79,11 +80,11 @@ public class BrandController extends AbstractController{
     @PostMapping("/bindUser")
     @RequiresPermissions("brand:list")
     public Result bindUser(@ApiParam(name = "BrandBindUserVo对象", value = "传入json格式", required = true)
-                          @RequestBody List<BrandBindUserVo> brandBindUserVoList) {
-        if(CollectionUtils.isEmpty(brandBindUserVoList)){
-            return Result.failure("入参缺失");
+                          @RequestBody BrandRequestVo brandRequestVo) {
+        if(brandRequestVo == null || brandRequestVo.getBrandId() == null){
+            return Result.failure("brandId入参缺失");
         }
-        brandService.bindUsers(brandBindUserVoList);
+        brandService.bindUsers(brandRequestVo.getBrandId(),brandRequestVo.getBrandList());
 
         return Result.success();
     }

+ 1 - 1
platform-shop/src/main/java/com/platform/service/BrandService.java

@@ -102,7 +102,7 @@ public interface BrandService {
 
     BrandEntity generateDefaultLiveRoom(SceneEntity requestScene);
 
-    void bindUsers(List<BrandBindUserVo> brandBindUserVoList);
+    void bindUsers(Integer brandId,List<BrandBindUserVo> brandBindUserVoList);
 
     void bindUser(Long userId,Integer brandId,Integer canShow);
 

+ 17 - 10
platform-shop/src/main/java/com/platform/service/impl/BrandServiceImpl.java

@@ -21,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.ObjectUtils;
 import org.springframework.web.client.RestTemplate;
@@ -31,6 +32,7 @@ import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * Service实现类
@@ -365,16 +367,21 @@ public class BrandServiceImpl implements BrandService {
         return brandEntity;
     }
 //{brandId: 1, canShow: 0, type: -1, userId: "1"}
-    public void bindUsers(List<BrandBindUserVo> brandBindUserVoList) {
-        brandBindUserVoList.parallelStream().filter(vo -> !ObjectUtils.isEmpty(vo.getType())).forEach(vo -> {
-                    //绑定或者修改带看权限
-                    if (vo.getType().compareTo(1) == 0) {
-                        bindUser(vo.getUserId(), vo.getBrandId(), vo.getCanShow());
-                    } else {
-                        unbindUser(vo.getUserId(), vo.getBrandId());
-                    }
-                }
-        );
+    public void bindUsers(Integer brandId,List<BrandBindUserVo> brandBindUserVoList) {
+        List<Long> userIdList = brandBindUserVoList.stream().map(BrandBindUserVo::getUserId).collect(Collectors.toList());
+        mySysUserBrandService.unbindUserByBrandId(brandId,userIdList);
+        for (BrandBindUserVo vo : brandBindUserVoList) {
+            bindUser(vo.getUserId(), vo.getBrandId(), vo.getCanShow());
+        }
+//        brandBindUserVoList.parallelStream().filter(vo -> !ObjectUtils.isEmpty(vo.getType())).forEach(vo -> {
+//                    //绑定或者修改带看权限
+//                    if (vo.getType().compareTo(1) == 0) {
+//                        bindUser(vo.getUserId(), vo.getBrandId(), vo.getCanShow());
+//                    } else {
+//                        unbindUser(vo.getUserId(), vo.getBrandId());
+//                    }
+//                }
+//        );
     }
 
     public void bindUser(Long userId,Integer brandId,Integer canShow) {

+ 3 - 0
platform-shop/src/main/java/com/platform/service/impl/GoodsServiceImpl.java

@@ -205,6 +205,9 @@ public class GoodsServiceImpl implements GoodsService {
         GoodsSpecificationEntity goodsSpecificationEntity = null;
         if(productList != null || productList.size() > 0){
             for(ProductEntity productEntity : productList){
+                if(productEntity.getUuidLink() == null){
+                    throw new RRException("参数uuiLink为空");
+                }
                 goodsSpecificationIds = "";
                 uuidLink = productEntity.getUuidLink();
                 uuids = uuidLink.split("_");

+ 11 - 0
platform-shop/src/main/java/com/platform/vo/BrandRequestVo.java

@@ -0,0 +1,11 @@
+package com.platform.vo;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class BrandRequestVo {
+    private Integer brandId;
+    private  List<BrandBindUserVo> brandList;
+}