Commit afe6efda by guojuxing

门店选择器接口返回统一字段

parent 14bc5ff1
package com.gic.plug.web.controller;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import com.gic.plug.web.vo.widget.StoreWidgetInterfaceVO;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -33,9 +37,17 @@ public class StoreBrandController {
Integer enterpriseId = UserDetailUtils.getUserDetail().getEnterpriseId();
ServiceResponse<List<StoreBrandDTO>> serviceResponse = storeBrandApiService.listAllStoreBrand(enterpriseId, search);
if (serviceResponse.isSuccess()) {
return RestResponse.success(StoreResourceUtils.auth(
List<StoreBrandDTO> list = StoreResourceUtils.auth(
serviceResponse.getResult(),
StoreESFieldsEnum.STOREBRANDIDLIST.getField()));
StoreESFieldsEnum.STOREBRANDIDLIST.getField());
List<StoreWidgetInterfaceVO> voList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(list)) {
voList = list.stream()
.map(e -> new StoreWidgetInterfaceVO().setLabel(e.getStoreBrandName()).setValue(e.getStoreBrandId().toString()))
.collect(Collectors.toList());
}
return RestResponse.success(voList);
} else {
return RestResponse.failure(serviceResponse.getCode(), serviceResponse.getMessage());
}
......
......@@ -238,9 +238,8 @@ public class StoreController {
if(storeWidget.isSuccess()){
StoreWidgetDTO storeWidgetDTO = storeWidget.getResult();
StoreResourceVO vo = new StoreResourceVO();
vo.setAuthMode(storeWidget.getResult().getAuthMode());
vo.setSearchJson(storeWidget.getResult().getSearchParam());
StoreResourceVO vo = EntityUtil.changeEntityNew(StoreResourceVO.class, storeWidgetDTO);
vo.setSearchJson(storeWidgetDTO.getSearchParam());
vo.setSceenBack(getScreenBack(storeWidgetDTO.getSearchParam()));
return vo;
}
......
......@@ -5,14 +5,16 @@ import com.gic.enterprise.utils.UserDetailUtils;
import com.gic.store.constant.StoreGroupConstant;
import com.gic.store.dto.StoreGroupDTO;
import com.gic.store.service.StoreGroupApiService;
import com.gic.store.utils.storegroup.ChangeListToTree;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author guojx
......@@ -31,6 +33,58 @@ public class StoreGroupController {
StoreGroupDTO dto = new StoreGroupDTO();
dto.setEnterpriseId(UserDetailUtils.getUserDetail().getEnterpriseId());
List<StoreGroupDTO> list = storeGroupApiService.listStoreGroup(dto).getResult();
return RestResponse.success(ChangeListToTree.changeListToTreeNotIncludeAllStore(StoreGroupConstant.ALL_STORE_LEVEL, list));
return RestResponse.success(changeListToTreeNotIncludeAllStore(StoreGroupConstant.ALL_STORE_LEVEL, list));
}
/**
* 把集合数据成树结构
* @Title: changeListToTree

* @Description:

 * @author guojuxing
* @param storeGroupId
* @param list

* @return java.util.List<java.util.Map<java.lang.String,java.lang.Object>>


 */
private static List<Map<String, Object>> changeListToTree(int storeGroupId, List<StoreGroupDTO> list) {
List<Map<String, Object>> result = new ArrayList<>();
if (list != null) {
for (StoreGroupDTO t : list) {
if (storeGroupId == t.getParentStoreGroupId()) {
Map<String, Object> data = new HashMap<>(16);
data.put("value", t.getStoreGroupId());
data.put("label", t.getStoreGroupName());
List<Map<String, Object>> children = changeListToTree(t.getStoreGroupId(), list);
if (children == null || children.size() < 1) {
data.put("children", null);
} else {
data.put("children", children);
}
result.add(data);
}
}
}
return result;
}
/**
* 不包括全部门店的数据的树结构数据
* @Title: changeListToTreeNotIncludeAllStore

* @Description:

 * @author guojuxing
* @param storeGroupId
* @param list

* @return java.util.List<java.util.Map<java.lang.String,java.lang.Object>>


 */
private static List<Map<String, Object>> changeListToTreeNotIncludeAllStore(int storeGroupId,
List<StoreGroupDTO> list) {
List<Map<String, Object>> result = changeListToTree(storeGroupId, list);
if (result.size() > 0) {
for (Map<String, Object> obj : result) {
if ((int) obj.get("groupLevel") == StoreGroupConstant.ALL_STORE_LEVEL) {
return (List<Map<String, Object>>) obj.get("children");
}
}
}
return result;
}
}
package com.gic.plug.web.controller;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import com.gic.plug.web.vo.widget.StoreWidgetInterfaceVO;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -36,7 +40,13 @@ public class StoreTagController {
List<StoreTagDTO> result = StoreResourceUtils.auth(
response.getResult(),
StoreESFieldsEnum.STORETAG.getField());
return RestResponse.success(EntityUtil.changeEntityListNew(StoreTagVO.class, result));
List<StoreWidgetInterfaceVO> voList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(result)) {
voList = result.stream()
.map(e -> new StoreWidgetInterfaceVO().setLabel(e.getStoreTagName()).setValue(e.getStoreTagId().toString()))
.collect(Collectors.toList());
}
return RestResponse.success(voList);
}
return RestResponse.failure(response.getCode(), response.getMessage());
}
......
package com.gic.plug.web.controller;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.enterprise.utils.UserDetailUtils;
import com.gic.plug.web.vo.widget.StoreWidgetInterfaceVO;
import com.gic.store.dto.StoreDictDTO;
import com.gic.store.service.StoreDictApiService;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
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.List;
import java.util.stream.Collectors;
@RestController
@RequestMapping("/store-type")
public class StoreTypeController {
@Autowired
private StoreDictApiService storeDictApiService;
@RequestMapping("list-storetype")
@ResponseBody
public RestResponse listStoreType(){
Integer enterpriseId = UserDetailUtils.getUserDetail().getEnterpriseId();
ServiceResponse<List<StoreDictDTO>> serviceResponse = this.storeDictApiService.listStoreType(enterpriseId);
if (serviceResponse.isSuccess()) {
return RestResponse.success(transferToVo(serviceResponse.getResult()));
} else {
return RestResponse.failure(serviceResponse.getCode(), serviceResponse.getMessage());
}
}
@RequestMapping("list-storestatus")
@ResponseBody
public RestResponse listStoreStatus(){
Integer enterpriseId = UserDetailUtils.getUserDetail().getEnterpriseId();
ServiceResponse<List<StoreDictDTO>> serviceResponse = this.storeDictApiService.listStoreStatus(enterpriseId);
if(serviceResponse.isSuccess()){
return RestResponse.success(transferToVo(serviceResponse.getResult()));
}else {
return RestResponse.failure(serviceResponse.getCode(), serviceResponse.getMessage());
}
}
private List<StoreWidgetInterfaceVO> transferToVo(List<StoreDictDTO> list) {
List<StoreWidgetInterfaceVO> voList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(list)) {
voList = list.stream()
.map(e -> new StoreWidgetInterfaceVO().setLabel(e.getKey()).setValue(e.getValue().toString()))
.collect(Collectors.toList());
}
return voList;
}
}
......@@ -8,36 +8,149 @@ import java.util.List;
* @date 2020/9/14 10:44 AM

*/
public class StoreResourceVO {
private Integer authMode;
private String searchJson;
/**
* 后端需要的条件筛选数据
*/
private String searchParam;
/**
* 现在弃用
*/
private String writeBackParam;
/**
* 后端需要的权限筛选数据
*/
private String authSearchParam;
private Integer authMode;
/**
* 前端需要字段(条件筛选)
*/
private String screenDetailData;
/**
* 前端需要字段(条件筛选)
*/
private String screenSimpleData;
/**
* 前端需要字段(权限筛选)
*/
private String authScreenDetailData;
/**
* 前端需要字段(权限筛选)
*/
private String authScreenSimpleData;
private List<ScreenBackVO> sceenBack;
public String getSearchJson() {
return searchJson;
}
public StoreResourceVO setSearchJson(String searchJson) {
this.searchJson = searchJson;
return this;
}
public String getSearchParam() {
return searchParam;
}
public StoreResourceVO setSearchParam(String searchParam) {
this.searchParam = searchParam;
return this;
}
public String getWriteBackParam() {
return writeBackParam;
}
public StoreResourceVO setWriteBackParam(String writeBackParam) {
this.writeBackParam = writeBackParam;
return this;
}
public String getAuthSearchParam() {
return authSearchParam;
}
public StoreResourceVO setAuthSearchParam(String authSearchParam) {
this.authSearchParam = authSearchParam;
return this;
}
public Integer getAuthMode() {
return authMode;
}
public void setAuthMode(Integer authMode) {
public StoreResourceVO setAuthMode(Integer authMode) {
this.authMode = authMode;
return this;
}
public String getSearchJson() {
return searchJson;
public String getScreenDetailData() {
return screenDetailData;
}
public void setSearchJson(String searchJson) {
this.searchJson = searchJson;
public StoreResourceVO setScreenDetailData(String screenDetailData) {
this.screenDetailData = screenDetailData;
return this;
}
public String getScreenSimpleData() {
return screenSimpleData;
}
public StoreResourceVO setScreenSimpleData(String screenSimpleData) {
this.screenSimpleData = screenSimpleData;
return this;
}
public String getAuthScreenDetailData() {
return authScreenDetailData;
}
public StoreResourceVO setAuthScreenDetailData(String authScreenDetailData) {
this.authScreenDetailData = authScreenDetailData;
return this;
}
public String getAuthScreenSimpleData() {
return authScreenSimpleData;
}
public StoreResourceVO setAuthScreenSimpleData(String authScreenSimpleData) {
this.authScreenSimpleData = authScreenSimpleData;
return this;
}
public List<ScreenBackVO> getSceenBack() {
return sceenBack;
}
public void setSceenBack(List<ScreenBackVO> sceenBack) {
public StoreResourceVO setSceenBack(List<ScreenBackVO> sceenBack) {
this.sceenBack = sceenBack;
return this;
}
@Override
public String toString() {
return super.toString();
return "StoreResourceVO{" +
"searchJson='" + searchJson + '\'' +
", searchParam='" + searchParam + '\'' +
", writeBackParam='" + writeBackParam + '\'' +
", authSearchParam='" + authSearchParam + '\'' +
", authMode=" + authMode +
", screenDetailData='" + screenDetailData + '\'' +
", screenSimpleData='" + screenSimpleData + '\'' +
", authScreenDetailData='" + authScreenDetailData + '\'' +
", authScreenSimpleData='" + authScreenSimpleData + '\'' +
", sceenBack=" + sceenBack +
'}';
}
}
......@@ -27,6 +27,26 @@ public class StoreWidgetVO implements Serializable {
private String authSearchParam;
/**
* 前端需要字段(条件筛选)
*/
private String screenDetailData;
/**
* 前端需要字段(条件筛选)
*/
private String screenSimpleData;
/**
* 前端需要字段(权限筛选)
*/
private String authScreenDetailData;
/**
* 前端需要字段(权限筛选)
*/
private String authScreenSimpleData;
private Integer authMode = 1;
private List<ScreenBackVO> screenBack;
......@@ -78,8 +98,55 @@ public class StoreWidgetVO implements Serializable {
this.screenBack = screenBack;
}
public String getScreenDetailData() {
return screenDetailData;
}
public StoreWidgetVO setScreenDetailData(String screenDetailData) {
this.screenDetailData = screenDetailData;
return this;
}
public String getScreenSimpleData() {
return screenSimpleData;
}
public StoreWidgetVO setScreenSimpleData(String screenSimpleData) {
this.screenSimpleData = screenSimpleData;
return this;
}
public String getAuthScreenDetailData() {
return authScreenDetailData;
}
public StoreWidgetVO setAuthScreenDetailData(String authScreenDetailData) {
this.authScreenDetailData = authScreenDetailData;
return this;
}
public String getAuthScreenSimpleData() {
return authScreenSimpleData;
}
public StoreWidgetVO setAuthScreenSimpleData(String authScreenSimpleData) {
this.authScreenSimpleData = authScreenSimpleData;
return this;
}
@Override
public String toString() {
return super.toString();
return "StoreWidgetVO{" +
"storeWidgetId=" + storeWidgetId +
", searchParam='" + searchParam + '\'' +
", writeBackParam='" + writeBackParam + '\'' +
", authSearchParam='" + authSearchParam + '\'' +
", screenDetailData='" + screenDetailData + '\'' +
", screenSimpleData='" + screenSimpleData + '\'' +
", authScreenDetailData='" + authScreenDetailData + '\'' +
", authScreenSimpleData='" + authScreenSimpleData + '\'' +
", authMode=" + authMode +
", screenBack=" + screenBack +
'}';
}
}
\ No newline at end of file
package com.gic.plug.web.vo.widget;
import java.io.Serializable;
/**
* 门店选择器的接口的返回字段统一
* @ClassName:
* @Description: 

* @author guojuxing

* @date 2021/2/1 3:01 PM

*/
public class StoreWidgetInterfaceVO implements Serializable{
private static final long serialVersionUID = 6577203951535930844L;
/**
* 后端的值
*/
private String value;
/**
* 展示字段
*/
private String label;
public String getValue() {
return value;
}
public StoreWidgetInterfaceVO setValue(String value) {
this.value = value;
return this;
}
public String getLabel() {
return label;
}
public StoreWidgetInterfaceVO setLabel(String label) {
this.label = label;
return this;
}
}
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