Browse Source

获取直播间绑定用户名

http://192.168.0.21/index.php?m=bug&f=view&bugID=25517
lyhzzz 3 năm trước cách đây
mục cha
commit
630f6396ea

+ 0 - 147
platform-api/src/main/java/com/platform/api/ApiAddressController.java

@@ -1,147 +0,0 @@
-package com.platform.api;
-
-import com.alibaba.fastjson.JSONObject;
-import com.platform.annotation.LoginUser;
-import com.platform.entity.AddressVo;
-import com.platform.entity.UserVo;
-import com.platform.service.ApiAddressService;
-import com.platform.util.ApiBaseAction;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.util.StringUtils;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * 作者: @author Harmon <br>
- * @gitee https://gitee.com/fuyang_lipengjun/platform
- * 时间: 2017-08-11 08:32<br>
- * 描述: ApiIndexController <br>
- */
-@Api(tags = "收货地址")
-@RestController
-@RequestMapping("/api/address")
-public class ApiAddressController extends ApiBaseAction {
-    @Autowired
-    private ApiAddressService addressService;
-
-    /**
-     * 获取用户的收货地址
-     */
-    @ApiOperation(value = "获取用户的收货地址接口", response = Map.class)
-    @PostMapping("list")
-    public Object list(@LoginUser UserVo loginUser) {
-        Map<String, Object> param = new HashMap<String, Object>();
-        param.put("user_id", loginUser.getUserId());
-        List<AddressVo> addressEntities = addressService.queryList(param);
-        return toResponsSuccess(addressEntities);
-    }
-
-    /**
-     * 获取收货地址的详情
-     */
-    @ApiOperation(value = "获取收货地址的详情", response = Map.class)
-    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "收获地址ID", required = true, dataType = "Integer")})
-    @PostMapping("detail")
-    public Object detail(Integer id, @LoginUser UserVo loginUser) {
-        AddressVo entity = addressService.queryObject(id);
-        if(entity == null){
-            return toResponsFail("地址错误");
-        }
-        //判断越权行为
-        if (!entity.getUserId().equals(loginUser.getUserId())) {
-            return toResponsObject(403, "您无权查看", "");
-        }
-        return toResponsSuccess(entity);
-    }
-
-    /**
-     * 添加或更新收货地址
-     */
-    @ApiOperation(value = "添加或更新收货地址", response = Map.class)
-    @PostMapping("save")
-    public Object save(@LoginUser UserVo loginUser) {
-        JSONObject addressJson = this.getJsonRequest();
-        AddressVo entity = new AddressVo();
-        if (null != addressJson) {
-            String regex = "^[~!@#¥%……&*()——+]$";
-            entity.setId(addressJson.getLong("id"));
-            entity.setUserId(loginUser.getUserId());
-            entity.setUserName(addressJson.getString("userName"));
-            entity.setPostalCode(addressJson.getString("postalCode"));
-            entity.setProvinceName(addressJson.getString("provinceName"));
-            entity.setCityName(addressJson.getString("cityName"));
-            entity.setCountyName(addressJson.getString("countyName"));
-            entity.setDetailInfo(addressJson.getString("detailInfo"));
-            entity.setNationalCode(addressJson.getString("nationalCode"));
-            entity.setTelNumber(addressJson.getString("telNumber"));
-            entity.setIs_default(addressJson.getInteger("is_default"));
-
-            if(StringUtils.isEmpty(entity.getUserName()) || entity.getUserName().length() < 2
-                    || entity.getUserName().length() > 25 || entity.getUserName().matches(regex)){
-                return toResponsFail("收货人名字长度需要在2-25个字符之间,不能包含非法字符。");
-            }
-
-            if(StringUtils.isEmpty(entity.getDetailInfo()) || entity.getDetailInfo().length() < 5
-                    || entity.getDetailInfo().length() > 120 || entity.getDetailInfo().matches(regex)){
-                return toResponsFail("详细地址长度需要在5-120个字符之间,不能包含非法字符。");
-            }
-
-            if(StringUtils.isEmpty(entity.getTelNumber()) || entity.getTelNumber().length() > 40){
-                return toResponsFail("请正确填写号码。");
-            }
-        }
-        //若是默认地址,先清除其他默认地址状态
-        if(entity.getIs_default() == 1){
-            AddressVo updateEntity = new AddressVo();
-            updateEntity.setUserId(loginUser.getUserId());
-            updateEntity.setIs_default(0);
-            addressService.updateIsDefaultByUserId(updateEntity);
-        }
-        if (null == entity.getId() || entity.getId() == 0) {
-            entity.setId(null);
-            addressService.save(entity);
-        } else {
-            addressService.update(entity);
-        }
-        return toResponsSuccess(entity);
-    }
-
-    public static void main(String[] args) {
-        String nameRegex = "^[~!@#¥%……&*()——+]$";
-        if(!"sdawe钟文,".matches(nameRegex)){
-            System.out.println("满足:" + "sdawe钟文,".length());
-            "sdawe钟文,".length();
-        }else {
-            System.out.println("不满足");
-        }
-    }
-
-    /**
-     * 删除指定的收货地址
-     */
-    @ApiOperation(value = "删除指定的收货地址", response = Map.class)
-    @PostMapping("delete")
-    public Object delete(@LoginUser UserVo loginUser) {
-        JSONObject jsonParam = this.getJsonRequest();
-        Integer id = jsonParam.getIntValue("id");
-
-        AddressVo entity = addressService.queryObject(id);
-        //判断越权行为
-        if (!entity.getUserId().equals(loginUser.getUserId())) {
-            return toResponsObject(403, "您无权删除", "");
-        }
-        addressService.delete(id);
-        return toResponsSuccess("");
-    }
-
-
-}

+ 18 - 0
platform-common/src/main/java/com/platform/service/impl/ZhiHouseService.java

@@ -333,4 +333,22 @@ public class ZhiHouseService {
         //把信息封装为json
         return JSONObject.parseObject(JSONObject.toJSONString(responseEntity.getBody().getMessage()));
     }
+
+    public List<String> getBindUserNameList(List<Long> userIds, String token) {
+
+        Map<String, Object> mp = new HashMap<>();
+        mp.put("userIds", userIds);
+        String url = zhiHouseHost + "api/shop/getBindUserNameList";
+        ResponseEntity<ReturnDTO>  responseEntity = restTemplate.postForEntity(url, mp,ReturnDTO.class);
+        if(responseEntity.getStatusCode()!= HttpStatus.OK){
+            throw new CommonBaseException(ResultCodeEnum.D100);
+        }
+        if (responseEntity.getBody().getCode() != 200) {
+            throw new CommonBaseException(ResultCodeEnum.D100,responseEntity.getBody().getError());
+        }
+        //把信息封装为json
+
+        List<String> list = (List<String>) responseEntity.getBody().getMessage();
+        return list;
+    }
 }

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

@@ -8,6 +8,7 @@ import com.platform.annotation.CanUserUpdateRecord;
 import com.platform.entity.BrandEntity;
 import com.platform.entity.GoodsEntity;
 import com.platform.entity.Result;
+import com.platform.entity.SysUserBrand;
 import com.platform.service.BrandService;
 import com.platform.service.GoodsService;
 import com.platform.service.custom.MySysUserBrandService;
@@ -131,7 +132,9 @@ public class BrandController extends AbstractController{
         List<BrandRspVo> rspBrandList = resultPage.getRecords().parallelStream().map(brandEntity -> {
             BrandRspVo brandRspVo = new BrandRspVo();
             BeanUtils.copyProperties(brandEntity,brandRspVo);
-            List<String> nameList = mySysUserBrandService.getBindUserNameList(brandEntity.getId().longValue());
+            List<SysUserBrand> brandBindUserIdList = mySysUserBrandService.getBrandBindUserIdList(brandEntity.getId());
+            List<Long> userIds = brandBindUserIdList.parallelStream().map(SysUserBrand::getUserId).collect(Collectors.toList());
+            List<String> nameList = zhiHouseService.getBindUserNameList(userIds,token);
             if (!CollectionUtils.isEmpty(nameList)) {
                 brandRspVo.setBindShowerNameList(nameList.stream().collect(Collectors.joining(";")));
             }