Commit a35be796 by 陶光胜

Merge branch 'developer' into 'master'

Developer

See merge request !2
parents a8228683 5600b31d
...@@ -10,10 +10,12 @@ import com.gic.auth.service.ResourceApiService; ...@@ -10,10 +10,12 @@ import com.gic.auth.service.ResourceApiService;
import com.gic.auth.service.UserResourceApiService; import com.gic.auth.service.UserResourceApiService;
import com.gic.commons.util.EntityUtil; import com.gic.commons.util.EntityUtil;
import com.gic.commons.webapi.reponse.RestResponse; import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.enterprise.utils.UserDetail;
import com.gic.enterprise.utils.UserDetailUtils; import com.gic.enterprise.utils.UserDetailUtils;
import com.gic.plug.web.qo.StoreWidgetCountQO; import com.gic.plug.web.qo.StoreWidgetCountQO;
import com.gic.plug.web.qo.StoreWidgetQO; import com.gic.plug.web.qo.StoreWidgetQO;
import com.gic.plug.web.strategy.init.StrategyInit; import com.gic.plug.web.strategy.init.StrategyInit;
import com.gic.plug.web.utils.StoreRegionAuthUtil;
import com.gic.plug.web.vo.StoreRegionVO; import com.gic.plug.web.vo.StoreRegionVO;
import com.gic.plug.web.vo.StoreResourceVO; import com.gic.plug.web.vo.StoreResourceVO;
import com.gic.plug.web.vo.StoreVO; import com.gic.plug.web.vo.StoreVO;
...@@ -34,7 +36,10 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -34,7 +36,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set;
/** /**
* @author zhiwj * @author zhiwj
...@@ -59,11 +64,23 @@ public class StoreController { ...@@ -59,11 +64,23 @@ public class StoreController {
@RequestMapping("/list-store-region") @RequestMapping("/list-store-region")
public RestResponse listStoreRegion(String search) { public RestResponse listStoreRegion(String search) {
Integer enterpriseId = UserDetailUtils.getUserDetail().getEnterpriseId(); UserDetail userDetail = UserDetailUtils.getUserDetail();
Integer enterpriseId = userDetail.getEnterpriseId();
Set<String> authRegionSet = StoreRegionAuthUtil.getUserRegion(storeWidgetApiService);
ServiceResponse<List<StoreRegionDTO>> serviceResponse = storeRegionApiService.listStoreRegion(enterpriseId, search); ServiceResponse<List<StoreRegionDTO>> serviceResponse = storeRegionApiService.listStoreRegion(enterpriseId, search);
if (serviceResponse.isSuccess()) { if (serviceResponse.isSuccess()) {
List<StoreRegionDTO> result = serviceResponse.getResult(); List<StoreRegionDTO> result = serviceResponse.getResult();
return RestResponse.success(EntityUtil.changeEntityListByOrika(StoreRegionVO.class, result)); List<StoreRegionVO> regionList = new ArrayList<>();
for(StoreRegionDTO storeRegionDTO : result){
if(!authRegionSet.isEmpty()){
if(authRegionSet.contains(storeRegionDTO.getRegionId()+"")){
regionList.add(EntityUtil.changeEntityByJSON(StoreRegionVO.class, storeRegionDTO));
}
}else {
regionList.add(EntityUtil.changeEntityByJSON(StoreRegionVO.class, storeRegionDTO));
}
}
return RestResponse.success(regionList);
} else { } else {
return RestResponse.failure(serviceResponse.getCode(), serviceResponse.getMessage()); return RestResponse.failure(serviceResponse.getCode(), serviceResponse.getMessage());
} }
......
package com.gic.plug.web.controller; package com.gic.plug.web.controller;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.gic.plug.web.utils.StoreRegionAuthUtil;
import com.gic.store.service.StoreWidgetApiService;
import com.gic.store.utils.StoreRedisKeyUtils; import com.gic.store.utils.StoreRedisKeyUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -43,6 +42,8 @@ public class StoreFieldController { ...@@ -43,6 +42,8 @@ public class StoreFieldController {
private StoreFieldApiService storeFieldApiService; private StoreFieldApiService storeFieldApiService;
@Autowired @Autowired
private StoreFieldSelectApiService storeFieldSelectApiService; private StoreFieldSelectApiService storeFieldSelectApiService;
@Autowired
private StoreWidgetApiService widgetApiService;
@RequestMapping("/list-store-field-type") @RequestMapping("/list-store-field-type")
public RestResponse listStoreFieldType() { public RestResponse listStoreFieldType() {
...@@ -115,8 +116,14 @@ public class StoreFieldController { ...@@ -115,8 +116,14 @@ public class StoreFieldController {
String key = "enterprise:store:storeField:" + enterpriseId + ":"; String key = "enterprise:store:storeField:" + enterpriseId + ":";
List<StoreFieldRegionVO> voList = new ArrayList<>(dtoList.size()); List<StoreFieldRegionVO> voList = new ArrayList<>(dtoList.size());
Set<String> userRegion = StoreRegionAuthUtil.getUserRegion(widgetApiService);
for (StoreFieldDTO dto : dtoList) { for (StoreFieldDTO dto : dtoList) {
//不需要文本类型字段 //不需要文本类型字段
if(!userRegion.isEmpty()){
if(!userRegion.contains(dto.getStoreRegionId())){
continue;
}
}
if (dto.getStoreFieldType().intValue() != StoreFieldTypeEnum.TEXT.getCode()) { if (dto.getStoreFieldType().intValue() != StoreFieldTypeEnum.TEXT.getCode()) {
Object obj = RedisUtil.getCache(StoreRedisKeyUtils.getStoreFieldKey(enterpriseId, dto.getStoreFieldId())); Object obj = RedisUtil.getCache(StoreRedisKeyUtils.getStoreFieldKey(enterpriseId, dto.getStoreFieldId()));
if (obj != null) { if (obj != null) {
......
...@@ -10,11 +10,14 @@ import com.gic.commons.webapi.reponse.RestResponse; ...@@ -10,11 +10,14 @@ import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.enterprise.utils.UserDetailUtils; import com.gic.enterprise.utils.UserDetailUtils;
import com.gic.goods.api.dto.BrandDTO; import com.gic.goods.api.dto.BrandDTO;
import com.gic.goods.api.dto.GoodsRightsSelectorDTO; import com.gic.goods.api.dto.GoodsRightsSelectorDTO;
import com.gic.goods.api.dto.GoodsSelectorDTO;
import com.gic.goods.api.service.BrandApiService; import com.gic.goods.api.service.BrandApiService;
import com.gic.goods.api.service.GoodsRightsSelectorApiService; import com.gic.goods.api.service.GoodsRightsSelectorApiService;
import com.gic.goods.api.service.GoodsSelectorApiService;
import com.gic.goods.api.util.Constant; import com.gic.goods.api.util.Constant;
import com.gic.plug.web.vo.goods.GoodsBrandVO; import com.gic.plug.web.vo.goods.GoodsBrandVO;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
...@@ -32,36 +35,45 @@ public class GoodsBrandController extends BaseGoodsController { ...@@ -32,36 +35,45 @@ public class GoodsBrandController extends BaseGoodsController {
@Autowired @Autowired
private GoodsRightsSelectorApiService goodsRightsSelectorApiService; private GoodsRightsSelectorApiService goodsRightsSelectorApiService;
@Autowired
private GoodsSelectorApiService goodsSelectorApiService;
@RequestMapping("/goods-brand-list") @RequestMapping("/goods-brand-list")
public RestResponse goodsBrandList(int pageSize, int currentPage, String search, Long goodsDomainId, String channelCode) { public RestResponse goodsBrandList(int pageSize, int currentPage, String search, Long goodsDomainId, String channelCode, Long goodsSelectorId) {
Long resourceId = UserDetailUtils.getUserDetail().getUserResourceInfo() == null ? null : String goodsRightsBrands = null;
UserDetailUtils.getUserDetail().getUserResourceInfo().getGoodsResourceId(); if (goodsSelectorId != null) {
ServiceResponse<GoodsRightsSelectorDTO> selectorDTOServiceResponse = goodsRightsSelectorApiService ServiceResponse<GoodsSelectorDTO> selectorServiceResponse = goodsSelectorApiService
.getGoodsRightsSelector(resourceId, getEnterpriseId() .getGoodsSelector(goodsSelectorId, getEnterpriseId());
, UserDetailUtils.getUserDetail().getUserInfo().getSuperAdmin()); if (selectorServiceResponse.getResult() != null) {
if (!selectorDTOServiceResponse.isSuccess() || selectorDTOServiceResponse.getResult() == null || goodsRightsBrands = selectorServiceResponse.getResult().getGoodsRightsBrands();
selectorDTOServiceResponse.getResult().getHasRights() == Constant.NO) { } else {
return RestResponse.success(Collections.EMPTY_LIST); return RestResponse.success(Collections.EMPTY_LIST);
}
} else {
Long resourceId = UserDetailUtils.getUserDetail().getUserResourceInfo() == null ? null :
UserDetailUtils.getUserDetail().getUserResourceInfo().getGoodsResourceId();
ServiceResponse<GoodsRightsSelectorDTO> selectorDTOServiceResponse = goodsRightsSelectorApiService
.getGoodsRightsSelector(resourceId, getEnterpriseId()
, UserDetailUtils.getUserDetail().getUserInfo().getSuperAdmin());
if (!selectorDTOServiceResponse.isSuccess() || selectorDTOServiceResponse.getResult() == null ||
selectorDTOServiceResponse.getResult().getHasRights() == Constant.NO) {
return RestResponse.success(Collections.EMPTY_LIST);
}
goodsRightsBrands = selectorDTOServiceResponse.getResult().getGoodsRightsBrands();
} }
// 是否最高权限 // 是否最高权限
List<Long> branIdList = new ArrayList<>(); List<Long> branIdList = new ArrayList<>();
if (UserDetailUtils.getUserDetail().getUserResourceInfo() != null if (StringUtils.isNotBlank(goodsRightsBrands)) {
&& UserDetailUtils.getUserDetail().getUserResourceInfo().getGoodsResourceId() != null) { JSONObject brandRightsObject = JSONObject.parseObject(goodsRightsBrands);
if (selectorDTOServiceResponse.isSuccess()) { JSONArray array = brandRightsObject.getJSONArray(channelCode + "_" + goodsDomainId);
GoodsRightsSelectorDTO goodsRightsSelectorDTO = selectorDTOServiceResponse.getResult(); if (CollectionUtils.isNotEmpty(array)) {
if (goodsRightsSelectorDTO != null) { for (int i = 0; i < array.size(); i++) {
JSONObject brandRightsObject = JSONObject.parseObject(goodsRightsSelectorDTO.getGoodsRightsBrands()); Long brandId = array.getLong(i);
JSONArray array = brandRightsObject.getJSONArray(channelCode + "_" + goodsDomainId); branIdList.add(brandId);
if (CollectionUtils.isNotEmpty(array)) {
for (int i = 0; i < array.size(); i++) {
Long brandId = array.getLong(i);
branIdList.add(brandId);
}
}
} }
} }
} }
return findBrandListByParams(currentPage, pageSize,goodsDomainId, search, getEnterpriseId()); return findBrandListByParams(currentPage, pageSize, goodsDomainId, search, getEnterpriseId());
} }
......
...@@ -7,12 +7,15 @@ import com.gic.commons.webapi.reponse.RestResponse; ...@@ -7,12 +7,15 @@ import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.enterprise.utils.UserDetailUtils; import com.gic.enterprise.utils.UserDetailUtils;
import com.gic.goods.api.dto.GoodsDomainDTO; import com.gic.goods.api.dto.GoodsDomainDTO;
import com.gic.goods.api.dto.GoodsRightsSelectorDTO; import com.gic.goods.api.dto.GoodsRightsSelectorDTO;
import com.gic.goods.api.dto.GoodsSelectorDTO;
import com.gic.goods.api.service.GoodsDomainApiService; import com.gic.goods.api.service.GoodsDomainApiService;
import com.gic.goods.api.service.GoodsRightsSelectorApiService; import com.gic.goods.api.service.GoodsRightsSelectorApiService;
import com.gic.goods.api.service.GoodsSelectorApiService;
import com.gic.goods.api.util.Constant; import com.gic.goods.api.util.Constant;
import com.gic.plug.web.vo.goods.GoodsChannelVO; import com.gic.plug.web.vo.goods.GoodsChannelVO;
import com.gic.plug.web.vo.goods.GoodsDomainVO; import com.gic.plug.web.vo.goods.GoodsDomainVO;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
...@@ -28,12 +31,15 @@ public class GoodsDomainController extends BaseGoodsController { ...@@ -28,12 +31,15 @@ public class GoodsDomainController extends BaseGoodsController {
@Autowired @Autowired
private GoodsRightsSelectorApiService goodsRightsSelectorApiService; private GoodsRightsSelectorApiService goodsRightsSelectorApiService;
@Autowired
private GoodsSelectorApiService goodsSelectorApiService;
/** /**
* @return com.gic.commons.webapi.reponse.RestResponse
* @throws
* @Title: getAllGoodsDomianListWith * @Title: getAllGoodsDomianListWith
* @Description: 权限筛选器选择权限 * @Description: 权限筛选器选择权限
* @author majia * @author majia
* @return com.gic.commons.webapi.reponse.RestResponse
* @throws
*/ */
@RequestMapping("/get-all-goods-domain-list-for-rights") @RequestMapping("/get-all-goods-domain-list-for-rights")
public RestResponse getAllGoodsDomainListForRights() { public RestResponse getAllGoodsDomainListForRights() {
...@@ -45,21 +51,36 @@ public class GoodsDomainController extends BaseGoodsController { ...@@ -45,21 +51,36 @@ public class GoodsDomainController extends BaseGoodsController {
} }
/** /**
* @Title: getAllGoodsDomianListWith * @return com.gic.commons.webapi.reponse.RestResponse
* @Description: 查询企业下所有的域,拼接成channelVO返回 * @throws
* @author majia * @Title: getAllGoodsDomianListWith
* @return com.gic.commons.webapi.reponse.RestResponse * @Description: 查询企业下所有的域,拼接成channelVO返回
* @throws * @author majia
*/ */
@RequestMapping("/get-all-goods-domain-list") @RequestMapping("/get-all-goods-domain-list")
public RestResponse getAllGoodsDomianList() { public RestResponse getAllGoodsDomianList(Long goodsSelectorId) {
Long resourceId = UserDetailUtils.getUserDetail().getUserResourceInfo() == null ? null : String goodsDomian = null;
UserDetailUtils.getUserDetail().getUserResourceInfo().getGoodsResourceId(); Integer hasRights = 0;
ServiceResponse<GoodsRightsSelectorDTO> selectorDTOServiceResponse = goodsRightsSelectorApiService.getGoodsRightsSelector(resourceId, if (goodsSelectorId != null) {
getEnterpriseId(), UserDetailUtils.getUserDetail().getUserInfo().getSuperAdmin()); ServiceResponse<GoodsSelectorDTO> selectorServiceResponse = goodsSelectorApiService
if (!selectorDTOServiceResponse.isSuccess() || selectorDTOServiceResponse.getResult() == null || .getGoodsSelector(goodsSelectorId, getEnterpriseId());
selectorDTOServiceResponse.getResult().getHasRights() == Constant.NO) { if (selectorServiceResponse.getResult() != null) {
return RestResponse.success(Collections.EMPTY_LIST); goodsDomian = selectorServiceResponse.getResult().getGoodsRightsBrands();
hasRights = selectorServiceResponse.getResult().getHasRights();
} else {
return RestResponse.success(Collections.EMPTY_LIST);
}
} else {
Long resourceId = UserDetailUtils.getUserDetail().getUserResourceInfo() == null ? null :
UserDetailUtils.getUserDetail().getUserResourceInfo().getGoodsResourceId();
ServiceResponse<GoodsRightsSelectorDTO> selectorDTOServiceResponse = goodsRightsSelectorApiService.getGoodsRightsSelector(resourceId,
getEnterpriseId(), UserDetailUtils.getUserDetail().getUserInfo().getSuperAdmin());
if (!selectorDTOServiceResponse.isSuccess() || selectorDTOServiceResponse.getResult() == null ||
selectorDTOServiceResponse.getResult().getHasRights() == Constant.NO) {
return RestResponse.success(Collections.EMPTY_LIST);
}
goodsDomian = selectorDTOServiceResponse.getResult().getGoodsRightsDomains();
hasRights = selectorDTOServiceResponse.getResult().getHasRights();
} }
ServiceResponse<List<GoodsDomainDTO>> serviceResponse = goodsDomainApiService.listAll(getEnterpriseId(), null); ServiceResponse<List<GoodsDomainDTO>> serviceResponse = goodsDomainApiService.listAll(getEnterpriseId(), null);
// 是否最高权限 // 是否最高权限
...@@ -67,16 +88,13 @@ public class GoodsDomainController extends BaseGoodsController { ...@@ -67,16 +88,13 @@ public class GoodsDomainController extends BaseGoodsController {
JSONObject json = null; JSONObject json = null;
if (UserDetailUtils.getUserDetail().getUserInfo().getSuperAdmin() != 1) { if (UserDetailUtils.getUserDetail().getUserInfo().getSuperAdmin() != 1) {
isHighestRights = false; isHighestRights = false;
if (selectorDTOServiceResponse.isSuccess()) { if (StringUtils.isNotBlank(goodsDomian)) {
GoodsRightsSelectorDTO goodsRightsSelectorDTO = selectorDTOServiceResponse.getResult(); if (hasRights == 0) {
if (goodsRightsSelectorDTO != null) { json = JSONObject.parseObject(JSONObject.toJSONString(Collections.EMPTY_LIST));
if (goodsRightsSelectorDTO.getHasRights() == 0) { } else {
json = JSONObject.parseObject(JSONObject.toJSONString(Collections.EMPTY_LIST)); json = JSONObject.parseObject(goodsDomian);
} else { if (json.isEmpty()) {
json = JSONObject.parseObject(goodsRightsSelectorDTO.getGoodsRightsDomains()); isHighestRights = true;
if (json.isEmpty()) {
isHighestRights = true;
}
} }
} }
} }
...@@ -93,7 +111,7 @@ public class GoodsDomainController extends BaseGoodsController { ...@@ -93,7 +111,7 @@ public class GoodsDomainController extends BaseGoodsController {
return RestResponse.success(Collections.EMPTY_LIST); return RestResponse.success(Collections.EMPTY_LIST);
} }
for (GoodsDomainDTO goodsDomainDTO : goodsDomainDTOList) { for (GoodsDomainDTO goodsDomainDTO : goodsDomainDTOList) {
if (CollectionUtils.isNotEmpty(goodsDomainDTO.getChannels())){ if (CollectionUtils.isNotEmpty(goodsDomainDTO.getChannels())) {
for (String channelCode : goodsDomainDTO.getChannels()) { for (String channelCode : goodsDomainDTO.getChannels()) {
if (isHighestRights) { // 最高权限所有都显示 if (isHighestRights) { // 最高权限所有都显示
map.putIfAbsent(channelCode, new ArrayList<>()); map.putIfAbsent(channelCode, new ArrayList<>());
......
...@@ -3,13 +3,14 @@ package com.gic.plug.web.controller.goods; ...@@ -3,13 +3,14 @@ package com.gic.plug.web.controller.goods;
import com.gic.api.base.commons.ServiceResponse; import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.EntityUtil; import com.gic.commons.util.EntityUtil;
import com.gic.commons.webapi.reponse.RestResponse; import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.enterprise.utils.UserDetailUtils;
import com.gic.goods.api.dto.GoodsRightsSelectorDTO; import com.gic.goods.api.dto.GoodsRightsSelectorDTO;
import com.gic.goods.api.service.GoodsRightsSelectorApiService; import com.gic.goods.api.service.GoodsRightsSelectorApiService;
import com.gic.goods.api.util.Constant; import com.gic.goods.api.util.Constant;
import com.gic.plug.web.qo.goods.GoodsRightsSelectorSaveQO; import com.gic.plug.web.qo.goods.GoodsRightsSelectorSaveQO;
import com.gic.plug.web.qo.goods.GoodsRightsSelectorUpdateQO; import com.gic.plug.web.qo.goods.GoodsRightsSelectorUpdateQO;
import com.gic.plug.web.vo.goods.GoodsRightsSelectorVO; import com.gic.plug.web.vo.goods.GoodsRightsSelectorVO;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
...@@ -20,6 +21,8 @@ public class GoodsRightsSelectorController extends BaseGoodsController { ...@@ -20,6 +21,8 @@ public class GoodsRightsSelectorController extends BaseGoodsController {
@Autowired @Autowired
private GoodsRightsSelectorApiService goodsRightsSelectorApiService; private GoodsRightsSelectorApiService goodsRightsSelectorApiService;
private Logger log = LogManager.getLogger(GoodsSelectorController.class);
/** /**
* @Title: BaseGoodsController * @Title: BaseGoodsController
* @Description: 保存商品选择器权限版 * @Description: 保存商品选择器权限版
...@@ -80,8 +83,9 @@ public class GoodsRightsSelectorController extends BaseGoodsController { ...@@ -80,8 +83,9 @@ public class GoodsRightsSelectorController extends BaseGoodsController {
@RequestMapping("/get-goods-rights-selector") @RequestMapping("/get-goods-rights-selector")
public RestResponse getGoodsRightsSelector(Long goodsRightsSelectorId) { public RestResponse getGoodsRightsSelector(Long goodsRightsSelectorId) {
ServiceResponse<GoodsRightsSelectorDTO> serviceResponse = goodsRightsSelectorApiService.getGoodsRightsSelector(goodsRightsSelectorId, ServiceResponse<GoodsRightsSelectorDTO> serviceResponse = goodsRightsSelectorApiService.getGoodsRightsSelector(goodsRightsSelectorId,
getEnterpriseId(), UserDetailUtils.getUserDetail().getUserInfo().getSuperAdmin()); getEnterpriseId(), 0);
if (serviceResponse.isSuccess()) { if (serviceResponse.isSuccess()) {
GoodsRightsSelectorDTO goodsRightsSelectorDTO = serviceResponse.getResult(); GoodsRightsSelectorDTO goodsRightsSelectorDTO = serviceResponse.getResult();
return RestResponse.success(EntityUtil.changeEntityByOrika(GoodsRightsSelectorVO.class, goodsRightsSelectorDTO)); return RestResponse.success(EntityUtil.changeEntityByOrika(GoodsRightsSelectorVO.class, goodsRightsSelectorDTO));
......
...@@ -73,6 +73,8 @@ public class GoodsSelectorController extends BaseGoodsController { ...@@ -73,6 +73,8 @@ public class GoodsSelectorController extends BaseGoodsController {
goodsSelectorDTO.setHasRights(goodsRightsSelectorDTO.getHasRights()); goodsSelectorDTO.setHasRights(goodsRightsSelectorDTO.getHasRights());
goodsSelectorDTO.setGoodsSearchRightValue(goodsRightsSelectorDTO.getGoodsRightsSearchValue()); goodsSelectorDTO.setGoodsSearchRightValue(goodsRightsSelectorDTO.getGoodsRightsSearchValue());
goodsSelectorDTO.setGoodsSearchRightText(goodsRightsSelectorDTO.getGoodsRightsSearchText()); goodsSelectorDTO.setGoodsSearchRightText(goodsRightsSelectorDTO.getGoodsRightsSearchText());
goodsSelectorDTO.setGoodsRightsBrands(goodsRightsSelectorDTO.getGoodsRightsBrands());
goodsSelectorDTO.setGoodsRightsDomains(goodsRightsSelectorDTO.getGoodsRightsDomains());
ServiceResponse<GoodsSelectorDTO> serviceResponse = goodsSelectorApiService.saveGoodsSelector(goodsSelectorDTO); ServiceResponse<GoodsSelectorDTO> serviceResponse = goodsSelectorApiService.saveGoodsSelector(goodsSelectorDTO);
if (serviceResponse.isSuccess()) { if (serviceResponse.isSuccess()) {
goodsSelectorDTO = serviceResponse.getResult(); goodsSelectorDTO = serviceResponse.getResult();
...@@ -138,11 +140,15 @@ public class GoodsSelectorController extends BaseGoodsController { ...@@ -138,11 +140,15 @@ public class GoodsSelectorController extends BaseGoodsController {
} }
GoodsRightsSelectorDTO goodsRightsSelectorDTO = goodsRightsSelectorDTOServiceResponse.getResult(); GoodsRightsSelectorDTO goodsRightsSelectorDTO = goodsRightsSelectorDTOServiceResponse.getResult();
ServiceResponse<GoodsSelectorDTO> serviceResponse = goodsSelectorApiService.updateGoodsSelectorRights(goodsSelectorId, ServiceResponse<GoodsSelectorDTO> serviceResponse = goodsSelectorApiService.updateGoodsSelectorRights(goodsSelectorId,
goodsRightsSelectorDTO.getGoodsRightsSearchText(), goodsRightsSelectorDTO.getGoodsRightsSearchValue(), goodsRightsSelectorDTO.getHasRights(), getEnterpriseId()); goodsRightsSelectorDTO.getGoodsRightsSearchText(), goodsRightsSelectorDTO.getGoodsRightsSearchValue(), goodsRightsSelectorDTO.getHasRights(), goodsRightsSelectorDTO.getGoodsRightsBrands(), goodsRightsSelectorDTO.getGoodsRightsDomains(), getEnterpriseId());
if (!serviceResponse.isSuccess()) { if (!serviceResponse.isSuccess()) {
return RestResponse.failure(serviceResponse.getCode(), serviceResponse.getMessage()); return RestResponse.failure(serviceResponse.getCode(), serviceResponse.getMessage());
} }
return RestResponse.success(serviceResponse.getResult()); goodsRightsSelectorDTO = new GoodsRightsSelectorDTO();
goodsRightsSelectorDTO.setGoodsRightsSearchText(serviceResponse.getResult().getGoodsSearchRightText());
goodsRightsSelectorDTO.setGoodsRightsSearchValue(serviceResponse.getResult().getGoodsSearchRightValue());
goodsRightsSelectorDTO.setHasRights(serviceResponse.getResult().getHasRights());
return RestResponse.success(goodsRightsSelectorDTO);
} }
......
package com.gic.plug.web.utils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.enterprise.utils.UserDetail;
import com.gic.enterprise.utils.UserDetailUtils;
import com.gic.store.constant.StoreESFieldsEnum;
import com.gic.store.dto.StoreWidgetDTO;
import com.gic.store.service.StoreWidgetApiService;
import org.apache.commons.collections.CollectionUtils;
import java.util.HashSet;
import java.util.Set;
public class StoreRegionAuthUtil {
public static Set<String> getUserRegion(StoreWidgetApiService storeWidgetApiService){
Set<String> authRegionSet = new HashSet<>();
UserDetail userDetail = UserDetailUtils.getUserDetail();
if(userDetail.getUserInfo().getSuperAdmin() != 1 && userDetail.getUserResourceInfo() != null){
Long storeResource = userDetail.getUserResourceInfo().getStoreResource();
if(storeResource != null){
ServiceResponse<StoreWidgetDTO> storeWidget = storeWidgetApiService.getStoreWidget(storeResource.intValue());
if(storeWidget.getResult() != null){
String searchParam = storeWidget.getResult().getSearchParam();
JSONObject json = JSON.parseArray(searchParam).getJSONObject(0);
JSONArray list = json.getJSONArray("list");
for(int i=0; i< list.size(); i++){
JSONObject o = list.getJSONObject(i).getJSONObject("data");
if(o.getString("key").equals(StoreESFieldsEnum.REGIONID.getField())){
String[] arr = o.getString("value").split(" ");
Set<String> set = new HashSet<>();
for(String s : arr){
set.add(s);
}
authRegionSet.addAll(set);
}
}
}
}
if(CollectionUtils.isEmpty(authRegionSet)){
authRegionSet.add("-1");
}
}
return authRegionSet;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment