Commit 83a7a273 by fudahua

绑定接口

parent d28ae4e1
package com.gic.haoban.manage.api.dto;
import java.io.Serializable;
import java.util.Date;
/**
* Created By MBG-GUI-EXTENSION https://github.com/spawpaw/mybatis-generator-gui-extension
* Description:
* 门店选择器
*
* @author fdh
*/
public class StoreRangeInfoDTO implements Serializable {
/**
*
*/
private String wxEnterpriseId;
/**
* 关联id 默认0
*/
private String relationId;
/**
* 0所有门店 1分组 2门店
*/
private Integer relationType;
/**
*/
private static final long serialVersionUID = 1L;
public String getWxEnterpriseId() {
return wxEnterpriseId;
}
public void setWxEnterpriseId(String wxEnterpriseId) {
this.wxEnterpriseId = wxEnterpriseId;
}
public String getRelationId() {
return relationId;
}
public void setRelationId(String relationId) {
this.relationId = relationId;
}
public Integer getRelationType() {
return relationType;
}
public void setRelationType(Integer relationType) {
this.relationType = relationType;
}
}
\ No newline at end of file
......@@ -65,6 +65,14 @@ public interface WxEnterpriseRelatedApiService {
public List<WxEnterpriseDTO> listWxEnterpriseByEid(String enterpriseId);
/**
* 根据商户id 获取所有被绑定分组
*
* @param enterpriseId
* @return
*/
public List<StoreRangeInfoDTO> listAllBindStoreOrGroup(String enterpriseId);
/**
* @param enterpriseId
* @param search
* @param pageInfo
......
......@@ -313,6 +313,12 @@ public class WxEnterpriseRelatedApiServiceImpl implements WxEnterpriseRelatedApi
}
@Override
public List<StoreRangeInfoDTO> listAllBindStoreOrGroup(String enterpriseId) {
List<TabStoreRange> tabStoreRanges = storeRangeService.queryAllBindRangeByEnterpriseId(enterpriseId);
return EntityUtil.changeEntityListNew(StoreRangeInfoDTO.class, tabStoreRanges);
}
@Override
public Page<BindStoreInfoDTO> pageBindStoreByEnterpriseId(String wxEnterpriseId, String enterpriseId, String search, BasePageInfo pageInfo) {
Page<TabStoreRelation> relationPage = storeRangeService.pageStoreRelation(enterpriseId, wxEnterpriseId, search, pageInfo);
if (CollectionUtils.isEmpty(relationPage.getResult())) {
......
package com.gic.haoban.manage.web.controller;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import com.gic.haoban.auth.api.dto.UserRightDetailDTO;
import com.gic.haoban.manage.api.dto.StoreRangeInfoDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseRelationDetailDTO;
import com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService;
import com.gic.haoban.manage.web.vo.LoginVO;
import com.gic.haoban.manage.web.vo.StoreGroupVo;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -22,12 +32,40 @@ public class GicDepartmentController extends WebBaseController{
@Autowired
private StoreGroupService storeGroupService;
@Autowired
private WxEnterpriseRelatedApiService wxEnterpriseRelatedApiService;
@RequestMapping("gic-department-list")
public HaobanResponse departmentList(String enterpriseId,BasePageInfo pageInfo,String keyWord) {
List<PowerStoreGroupDTO> departmentList = storeGroupService.getStoreGroupList(enterpriseId, keyWord);
public HaobanResponse departmentList(String enterpriseId, String keyWord) {
List<PowerStoreGroupDTO> departmentList = storeGroupService.getStoreGroupList(enterpriseId, keyWord);
return resultResponse(HaoBanErrCode.ERR_1,departmentList);
}
@RequestMapping("gic-store-group-list")
public HaobanResponse storeGroupList(String enterpriseId, String keyWord) {
LoginVO loginUser = this.getLoginUser();
String wxEnterpriseId = loginUser.getWxEnterpriseId();
List<PowerStoreGroupDTO> departmentList = storeGroupService.getStoreGroupList(enterpriseId, keyWord);
List<StoreRangeInfoDTO> rangeInfoDTOList = wxEnterpriseRelatedApiService.listAllBindStoreOrGroup(enterpriseId);
Set<String> groupIds = new HashSet<>();
if (CollectionUtils.isNotEmpty(rangeInfoDTOList)) {
groupIds = rangeInfoDTOList.stream().filter(dto -> (!dto.getWxEnterpriseId().equals(wxEnterpriseId)) && dto.getRelationType() == 1)
.map(dto -> dto.getRelationId()).collect(Collectors.toSet());
}
Set<String> finalGroupIds = groupIds;
List<StoreGroupVo> ret = departmentList.stream().map(dto -> {
StoreGroupVo storeGroupVo = new StoreGroupVo();
storeGroupVo.setRelationId(dto.getStoreGroupId());
storeGroupVo.setParentRelationId(dto.getParentGroupId());
storeGroupVo.setIsBind(finalGroupIds.contains(dto.getStoreGroupId()) ? 1 : 0);
storeGroupVo.setRelationType(1);
storeGroupVo.setRelationName(dto.getStoreGroupName());
return storeGroupVo;
}).collect(Collectors.toList());
return resultResponse(HaoBanErrCode.ERR_1, ret);
}
}
package com.gic.haoban.manage.web.controller;
import com.gic.haoban.auth.api.dto.DisplayRelationShortInfoDTO;
import com.gic.haoban.auth.api.dto.UserRightDetailDTO;
import com.gic.haoban.common.utils.AuthRequestUtil;
import com.gic.haoban.common.utils.HaobanResponse;
import com.gic.haoban.manage.web.auth.AuthRequestUtil;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.haoban.manage.web.vo.LoginVO;
import org.apache.commons.collections.CollectionUtils;
import java.util.ArrayList;
......@@ -49,8 +49,9 @@ public class WebBaseController {
*
* @return
*/
protected UserRightDetailDTO getLoginUser() {
return (UserRightDetailDTO) AuthRequestUtil.getSessionUser();
protected LoginVO getLoginUser() {
LoginVO login = (LoginVO) AuthRequestUtil.getLoginUser();
return login;
}
public boolean haveRight(List<DisplayRelationShortInfoDTO> list){
......
package com.gic.haoban.manage.web.vo;
import java.io.Serializable;
/**
* Created 2021/4/17.
*
* @author hua
*/
public class StoreGroupVo implements Serializable {
private String relationId;
private Integer relationType;
private String relationName;
private int isBind = 0;
private String parentRelationId;
public String getRelationId() {
return relationId;
}
public void setRelationId(String relationId) {
this.relationId = relationId;
}
public Integer getRelationType() {
return relationType;
}
public void setRelationType(Integer relationType) {
this.relationType = relationType;
}
public String getRelationName() {
return relationName;
}
public void setRelationName(String relationName) {
this.relationName = relationName;
}
public int getIsBind() {
return isBind;
}
public void setIsBind(int isBind) {
this.isBind = isBind;
}
public String getParentRelationId() {
return parentRelationId;
}
public void setParentRelationId(String parentRelationId) {
this.parentRelationId = parentRelationId;
}
}
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