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;
import com.gic.auth.service.UserResourceApiService;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.enterprise.utils.UserDetail;
import com.gic.enterprise.utils.UserDetailUtils;
import com.gic.plug.web.qo.StoreWidgetCountQO;
import com.gic.plug.web.qo.StoreWidgetQO;
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.StoreResourceVO;
import com.gic.plug.web.vo.StoreVO;
......@@ -34,7 +36,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* @author zhiwj
......@@ -59,11 +64,23 @@ public class StoreController {
@RequestMapping("/list-store-region")
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);
if (serviceResponse.isSuccess()) {
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 {
return RestResponse.failure(serviceResponse.getCode(), serviceResponse.getMessage());
}
......
package com.gic.plug.web.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import com.gic.plug.web.utils.StoreRegionAuthUtil;
import com.gic.store.service.StoreWidgetApiService;
import com.gic.store.utils.StoreRedisKeyUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -43,6 +42,8 @@ public class StoreFieldController {
private StoreFieldApiService storeFieldApiService;
@Autowired
private StoreFieldSelectApiService storeFieldSelectApiService;
@Autowired
private StoreWidgetApiService widgetApiService;
@RequestMapping("/list-store-field-type")
public RestResponse listStoreFieldType() {
......@@ -115,8 +116,14 @@ public class StoreFieldController {
String key = "enterprise:store:storeField:" + enterpriseId + ":";
List<StoreFieldRegionVO> voList = new ArrayList<>(dtoList.size());
Set<String> userRegion = StoreRegionAuthUtil.getUserRegion(widgetApiService);
for (StoreFieldDTO dto : dtoList) {
//不需要文本类型字段
if(!userRegion.isEmpty()){
if(!userRegion.contains(dto.getStoreRegionId())){
continue;
}
}
if (dto.getStoreFieldType().intValue() != StoreFieldTypeEnum.TEXT.getCode()) {
Object obj = RedisUtil.getCache(StoreRedisKeyUtils.getStoreFieldKey(enterpriseId, dto.getStoreFieldId()));
if (obj != null) {
......
......@@ -10,11 +10,14 @@ import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.enterprise.utils.UserDetailUtils;
import com.gic.goods.api.dto.BrandDTO;
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.GoodsRightsSelectorApiService;
import com.gic.goods.api.service.GoodsSelectorApiService;
import com.gic.goods.api.util.Constant;
import com.gic.plug.web.vo.goods.GoodsBrandVO;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -32,36 +35,45 @@ public class GoodsBrandController extends BaseGoodsController {
@Autowired
private GoodsRightsSelectorApiService goodsRightsSelectorApiService;
@Autowired
private GoodsSelectorApiService goodsSelectorApiService;
@RequestMapping("/goods-brand-list")
public RestResponse goodsBrandList(int pageSize, int currentPage, String search, Long goodsDomainId, String channelCode) {
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);
public RestResponse goodsBrandList(int pageSize, int currentPage, String search, Long goodsDomainId, String channelCode, Long goodsSelectorId) {
String goodsRightsBrands = null;
if (goodsSelectorId != null) {
ServiceResponse<GoodsSelectorDTO> selectorServiceResponse = goodsSelectorApiService
.getGoodsSelector(goodsSelectorId, getEnterpriseId());
if (selectorServiceResponse.getResult() != null) {
goodsRightsBrands = selectorServiceResponse.getResult().getGoodsRightsBrands();
} 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);
}
goodsRightsBrands = selectorDTOServiceResponse.getResult().getGoodsRightsBrands();
}
// 是否最高权限
List<Long> branIdList = new ArrayList<>();
if (UserDetailUtils.getUserDetail().getUserResourceInfo() != null
&& UserDetailUtils.getUserDetail().getUserResourceInfo().getGoodsResourceId() != null) {
if (selectorDTOServiceResponse.isSuccess()) {
GoodsRightsSelectorDTO goodsRightsSelectorDTO = selectorDTOServiceResponse.getResult();
if (goodsRightsSelectorDTO != null) {
JSONObject brandRightsObject = JSONObject.parseObject(goodsRightsSelectorDTO.getGoodsRightsBrands());
JSONArray array = brandRightsObject.getJSONArray(channelCode + "_" + goodsDomainId);
if (CollectionUtils.isNotEmpty(array)) {
for (int i = 0; i < array.size(); i++) {
Long brandId = array.getLong(i);
branIdList.add(brandId);
}
}
if (StringUtils.isNotBlank(goodsRightsBrands)) {
JSONObject brandRightsObject = JSONObject.parseObject(goodsRightsBrands);
JSONArray array = brandRightsObject.getJSONArray(channelCode + "_" + goodsDomainId);
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;
import com.gic.enterprise.utils.UserDetailUtils;
import com.gic.goods.api.dto.GoodsDomainDTO;
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.GoodsRightsSelectorApiService;
import com.gic.goods.api.service.GoodsSelectorApiService;
import com.gic.goods.api.util.Constant;
import com.gic.plug.web.vo.goods.GoodsChannelVO;
import com.gic.plug.web.vo.goods.GoodsDomainVO;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -28,12 +31,15 @@ public class GoodsDomainController extends BaseGoodsController {
@Autowired
private GoodsRightsSelectorApiService goodsRightsSelectorApiService;
@Autowired
private GoodsSelectorApiService goodsSelectorApiService;
/**
* @return com.gic.commons.webapi.reponse.RestResponse
* @throws
* @Title: getAllGoodsDomianListWith
* @Description: 权限筛选器选择权限
* @author majia
* @return com.gic.commons.webapi.reponse.RestResponse
* @throws
*/
@RequestMapping("/get-all-goods-domain-list-for-rights")
public RestResponse getAllGoodsDomainListForRights() {
......@@ -45,21 +51,36 @@ public class GoodsDomainController extends BaseGoodsController {
}
/**
* @Title: getAllGoodsDomianListWith
* @Description: 查询企业下所有的域,拼接成channelVO返回
* @author majia
* @return com.gic.commons.webapi.reponse.RestResponse
* @throws
*/
* @return com.gic.commons.webapi.reponse.RestResponse
* @throws
* @Title: getAllGoodsDomianListWith
* @Description: 查询企业下所有的域,拼接成channelVO返回
* @author majia
*/
@RequestMapping("/get-all-goods-domain-list")
public RestResponse getAllGoodsDomianList() {
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);
public RestResponse getAllGoodsDomianList(Long goodsSelectorId) {
String goodsDomian = null;
Integer hasRights = 0;
if (goodsSelectorId != null) {
ServiceResponse<GoodsSelectorDTO> selectorServiceResponse = goodsSelectorApiService
.getGoodsSelector(goodsSelectorId, getEnterpriseId());
if (selectorServiceResponse.getResult() != null) {
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);
// 是否最高权限
......@@ -67,16 +88,13 @@ public class GoodsDomainController extends BaseGoodsController {
JSONObject json = null;
if (UserDetailUtils.getUserDetail().getUserInfo().getSuperAdmin() != 1) {
isHighestRights = false;
if (selectorDTOServiceResponse.isSuccess()) {
GoodsRightsSelectorDTO goodsRightsSelectorDTO = selectorDTOServiceResponse.getResult();
if (goodsRightsSelectorDTO != null) {
if (goodsRightsSelectorDTO.getHasRights() == 0) {
json = JSONObject.parseObject(JSONObject.toJSONString(Collections.EMPTY_LIST));
} else {
json = JSONObject.parseObject(goodsRightsSelectorDTO.getGoodsRightsDomains());
if (json.isEmpty()) {
isHighestRights = true;
}
if (StringUtils.isNotBlank(goodsDomian)) {
if (hasRights == 0) {
json = JSONObject.parseObject(JSONObject.toJSONString(Collections.EMPTY_LIST));
} else {
json = JSONObject.parseObject(goodsDomian);
if (json.isEmpty()) {
isHighestRights = true;
}
}
}
......@@ -93,7 +111,7 @@ public class GoodsDomainController extends BaseGoodsController {
return RestResponse.success(Collections.EMPTY_LIST);
}
for (GoodsDomainDTO goodsDomainDTO : goodsDomainDTOList) {
if (CollectionUtils.isNotEmpty(goodsDomainDTO.getChannels())){
if (CollectionUtils.isNotEmpty(goodsDomainDTO.getChannels())) {
for (String channelCode : goodsDomainDTO.getChannels()) {
if (isHighestRights) { // 最高权限所有都显示
map.putIfAbsent(channelCode, new ArrayList<>());
......
......@@ -3,13 +3,14 @@ package com.gic.plug.web.controller.goods;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.EntityUtil;
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.service.GoodsRightsSelectorApiService;
import com.gic.goods.api.util.Constant;
import com.gic.plug.web.qo.goods.GoodsRightsSelectorSaveQO;
import com.gic.plug.web.qo.goods.GoodsRightsSelectorUpdateQO;
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.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -20,6 +21,8 @@ public class GoodsRightsSelectorController extends BaseGoodsController {
@Autowired
private GoodsRightsSelectorApiService goodsRightsSelectorApiService;
private Logger log = LogManager.getLogger(GoodsSelectorController.class);
/**
* @Title: BaseGoodsController
* @Description: 保存商品选择器权限版
......@@ -80,8 +83,9 @@ public class GoodsRightsSelectorController extends BaseGoodsController {
@RequestMapping("/get-goods-rights-selector")
public RestResponse getGoodsRightsSelector(Long goodsRightsSelectorId) {
ServiceResponse<GoodsRightsSelectorDTO> serviceResponse = goodsRightsSelectorApiService.getGoodsRightsSelector(goodsRightsSelectorId,
getEnterpriseId(), UserDetailUtils.getUserDetail().getUserInfo().getSuperAdmin());
getEnterpriseId(), 0);
if (serviceResponse.isSuccess()) {
GoodsRightsSelectorDTO goodsRightsSelectorDTO = serviceResponse.getResult();
return RestResponse.success(EntityUtil.changeEntityByOrika(GoodsRightsSelectorVO.class, goodsRightsSelectorDTO));
......
......@@ -73,6 +73,8 @@ public class GoodsSelectorController extends BaseGoodsController {
goodsSelectorDTO.setHasRights(goodsRightsSelectorDTO.getHasRights());
goodsSelectorDTO.setGoodsSearchRightValue(goodsRightsSelectorDTO.getGoodsRightsSearchValue());
goodsSelectorDTO.setGoodsSearchRightText(goodsRightsSelectorDTO.getGoodsRightsSearchText());
goodsSelectorDTO.setGoodsRightsBrands(goodsRightsSelectorDTO.getGoodsRightsBrands());
goodsSelectorDTO.setGoodsRightsDomains(goodsRightsSelectorDTO.getGoodsRightsDomains());
ServiceResponse<GoodsSelectorDTO> serviceResponse = goodsSelectorApiService.saveGoodsSelector(goodsSelectorDTO);
if (serviceResponse.isSuccess()) {
goodsSelectorDTO = serviceResponse.getResult();
......@@ -138,11 +140,15 @@ public class GoodsSelectorController extends BaseGoodsController {
}
GoodsRightsSelectorDTO goodsRightsSelectorDTO = goodsRightsSelectorDTOServiceResponse.getResult();
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()) {
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