Commit 81d154f9 by 徐高华

门店

parent dcb9fa4a
package com.gic.haoban.manage.web.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -12,8 +13,16 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.gic.api.base.commons.Page;
import com.gic.clerk.api.dto.ClerkDTO;
import com.gic.clerk.api.service.ClerkService;
import com.gic.enterprise.api.dto.EnterpriseSettingDTO;
import com.gic.enterprise.api.dto.PowerStoreGroupDTO;
import com.gic.enterprise.api.dto.StoreWidgetDTO;
import com.gic.enterprise.api.dto.StoreWidgetRightDataDTO;
import com.gic.enterprise.api.service.EnterpriseService;
import com.gic.enterprise.api.service.StoreGroupService;
import com.gic.enterprise.api.service.StoreWidgetService;
import com.gic.haoban.base.api.common.pojo.dto.WebLoginDTO;
import com.gic.haoban.common.utils.AuthWebRequestUtil;
import com.gic.haoban.common.utils.HaobanResponse;
......@@ -23,6 +32,7 @@ import com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.haoban.manage.web.vo.StoreGroupVo;
@RestController
public class GicDepartmentController extends WebBaseController{
......@@ -30,14 +40,57 @@ public class GicDepartmentController extends WebBaseController{
@Autowired
private StoreGroupService storeGroupService;
@Autowired
private WxEnterpriseRelatedApiService wxEnterpriseRelatedApiService;
@Autowired
private EnterpriseService enterpriseService ;
@Autowired
private ClerkService clerkService ;
@Autowired
private StoreWidgetService storeWidgetService ;
@RequestMapping("gic-department-list")
public HaobanResponse departmentList(String enterpriseId, String keyWord) {
List<PowerStoreGroupDTO> departmentList = storeGroupService.getStoreGroupList(enterpriseId, keyWord);
public HaobanResponse departmentList(String keyWord) {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser() ;
String enterpriseId = loginUser.getEnterpriseId() ;
EnterpriseSettingDTO enterpriseSetting = enterpriseService.getEnterpriseSettingByEnterpriseId(enterpriseId) ;
List<StoreWidgetRightDataDTO> list = null ;
if (enterpriseSetting.getEnableAccessControl() != null && enterpriseSetting.getEnableAccessControl() == 1) {
String clerkId = loginUser.getClerkId() ;
ClerkDTO clerk = this.clerkService.getclerkById(clerkId) ;
String storeWidgetId = clerk.getStoreWidgetId() ;
StoreWidgetDTO storeWidgetDTO = this.storeWidgetService.getStoreWidgetBykey(storeWidgetId);
if(0 != storeWidgetDTO.getSelectType() || 4!=storeWidgetDTO.getSelectType()) {
return this.resultResponse(HaoBanErrCode.ERR_10031) ;
}
if(4==storeWidgetDTO.getSelectType()) {
Page page = new Page();
page.setPageSize(3000);
page.setCurrentPage(1);
page = this.storeWidgetService.listRightData(storeWidgetId, page, null) ;
list = page.getResult() ;
if(CollectionUtils.isEmpty(list)) {
list = new ArrayList<StoreWidgetRightDataDTO>();
}
}
}
List<PowerStoreGroupDTO> departmentList = storeGroupService.getStoreGroupList(enterpriseId, keyWord);
if(null != list) {
List<PowerStoreGroupDTO> retList = new ArrayList<>();
List<String> idList = list.stream().map(dto->dto.getId()).collect(Collectors.toList()) ;
for(PowerStoreGroupDTO item : departmentList) {
if(idList.contains(item.getStoreGroupId())) {
retList.add(item) ;
}else {
for(String id : idList) {
if(item.getStoreGroupChain().contains(id)) {
retList.add(item) ;
break ;
}
}
}
}
}
return resultResponse(HaoBanErrCode.ERR_1,departmentList);
}
......
......@@ -104,7 +104,7 @@ public enum HaoBanErrCode {
ERR_10020(10020,"模板名称已存在"),
ERR_10030(10030,"您还不是企微的管理员,无法查看通讯录,若需查看,请联系超级管理员开通"),
ERR_10031(10031,"您的门店范围不支持分组查询"),
ERR_10021(10021,"模板关联企业不能删除"),
ERR_100015(100015,"暂存部门不能删除"),
......
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