Commit 8b8765bd by 何文超

商品选择器

parent 28b05247
......@@ -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<>());
......
......@@ -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,7 +140,7 @@ 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());
}
......
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