Commit 5d3bb551 by 墨竹

Merge remote-tracking branch 'origin/developer' into developer

parents 2bc97eef a5dd5e0a
......@@ -45,6 +45,10 @@ public class AdminController extends WebBaseController {
@RequestMapping("admin-list")
public HaobanResponse adminList() {
WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
String staffId = login.getStaffId() ;
if(StringUtils.isBlank(staffId)) {
return this.resultResponse(HaoBanErrCode.ERR_10030) ;
}
String wxEnterpriseId = login.getWxEnterpriseId();
WxApplicationDTO application = wxApplicationApiService.selectByWxEnterpriseIdAndApplicationType(wxEnterpriseId, 2);
WxEnterpriseDTO enterprise = wxEnterpriseApiService.getOne(wxEnterpriseId);
......@@ -63,10 +67,6 @@ public class AdminController extends WebBaseController {
List<StaffDTO> list = new ArrayList<>();
List<AdminVO> resultList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(openUserIds)) {
String staffId = login.getStaffId() ;
if(StringUtils.isBlank(staffId)) {
return this.resultResponse(HaoBanErrCode.ERR_10030) ;
}
if (corpid.length() > 20) {
logger.info("OpenUserIds");
list = staffApiService.listByOpenUserIdsAndWxEnterpriseId(openUserIds, wxEnterpriseId);
......
package com.gic.haoban.manage.web.controller;
import cn.hutool.core.collection.CollectionUtil;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
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 com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.Page;
import com.gic.clerk.api.dto.ClerkDTO;
import com.gic.clerk.api.dto.ClerkListDTO;
......@@ -24,21 +39,20 @@ import com.gic.haoban.manage.api.dto.DepartmentDTO;
import com.gic.haoban.manage.api.dto.DepartmentShortDTO;
import com.gic.haoban.manage.api.dto.StaffDTO;
import com.gic.haoban.manage.api.dto.StaffDepartmentRelatedDTO;
import com.gic.haoban.manage.api.dto.WxApplicationDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseDTO;
import com.gic.haoban.manage.api.service.DepartmentApiService;
import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.api.service.StaffDepartmentRelatedApiService;
import com.gic.haoban.manage.api.service.WxApplicationApiService;
import com.gic.haoban.manage.api.service.WxEnterpriseApiService;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.haoban.manage.web.vo.DepartmentChainVO;
import com.gic.haoban.manage.web.vo.DepartmentVO;
import com.gic.redis.data.util.RedisUtil;
import org.apache.commons.lang.StringUtils;
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 com.gic.wechat.api.service.qywx.QywxSuiteApiService;
import java.util.*;
import cn.hutool.core.collection.CollectionUtil;
@RestController
public class DepartmentContoller extends WebBaseController {
......@@ -46,20 +60,24 @@ public class DepartmentContoller extends WebBaseController {
private static final Logger logger = LoggerFactory.getLogger(DepartmentContoller.class);
@Autowired
private DepartmentApiService departmentApiService;
@Autowired
private StoreGroupService storeGroupService;
@Autowired
private StoreService storeService;
@Autowired
private StaffApiService staffApiService;
@Autowired
private EnterpriseService enterpriseService;
@Autowired
private ClerkService clerkService;
@Autowired
private StaffDepartmentRelatedApiService staffDepartmentRelatedApiService;
@Autowired
private WxApplicationApiService wxApplicationApiService ;
@Autowired
private WxEnterpriseApiService wxEnterpriseApiService ;
@Autowired
private QywxSuiteApiService qywxSuiteApiService ;
@RequestMapping("department-list")
......@@ -420,6 +438,9 @@ public class DepartmentContoller extends WebBaseController {
*/
@RequestMapping("department-list-cache")
public HaobanResponse departmentCachelist() {
if(!isAdmin()) {
return this.resultResponse(HaoBanErrCode.ERR_10030) ;
}
WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
if (StringUtils.isBlank(wxEnterpriseId)) {
......@@ -434,5 +455,33 @@ public class DepartmentContoller extends WebBaseController {
return resultResponse(HaoBanErrCode.ERR_1, cache);
}
}
private boolean isAdmin(){
WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
String staffId = login.getStaffId() ;
if(StringUtils.isBlank(staffId)) {
return false ;
}
String wxEnterpriseId = login.getWxEnterpriseId();
WxApplicationDTO application = wxApplicationApiService.selectByWxEnterpriseIdAndApplicationType(wxEnterpriseId, 2);
WxEnterpriseDTO enterprise = wxEnterpriseApiService.getOne(wxEnterpriseId);
String corpid = enterprise.getCorpid();
logger.info("【管理员查询】corpid={},siteId={},agentId={}", corpid, application.getSiteId(), application.getAgentId());
String adminList = qywxSuiteApiService.getAdminList(corpid, application.getSiteId(), Integer.parseInt(application.getAgentId()));
logger.info("【管理员查询】userIds={}", JSON.toJSONString(adminList));
List<String> openUserIds = new ArrayList<>();
if (StringUtils.isNotBlank(adminList)) {
JSONArray jsonArr = JSON.parseArray(adminList);
for (Object object : jsonArr) {
JSONObject json = JSON.parseObject(JSON.toJSONString(object));
openUserIds.add(json.getString("userid"));
}
}
StaffDTO staff = this.staffApiService.selectById(staffId) ;
if(openUserIds.contains(staff.getWxUserId()) || openUserIds.contains(staff.getWxOpenUseId())) {
return true ;
}
return false ;
}
}
......@@ -238,8 +238,7 @@ public class LoginController extends WebBaseController {
String url = "https://open.work.weixin.qq.com/wwopen/sso/3rd_qrConnect?appid=" + corpid + "&redirect_uri="
+ URLEncoder.encode(redirectUri, "UTF-8") + "&state=web_login@gyoss9&usertype=admin";*/
// return resultResponse(HaoBanErrCode.ERR_1, URL.decode(url));
String gicHost = GlobalVar.ctxPropertiesMap.get("gicweb_service_host");
gicHost = gicHost.replace("gicweb", "").replace("https://", "http://").replace("http://", "https://")+"gic-web/#/login?ishb=1";
String gicHost =this.getGicHost()+"gic-web/#/login?ishb=1";
try {
response.sendRedirect(gicHost);
} catch (IOException e) {
......@@ -247,6 +246,10 @@ public class LoginController extends WebBaseController {
}
return null ;
}
private String getGicHost(){
return GlobalVar.ctxPropertiesMap.get("gicweb_service_host").replace("gicweb", "");
}
// 登录逻辑
private String doLogin(String wxEnterpriseId, String gicEnterpriseId, String loginPhoneNumber, String loginChannel,
......@@ -344,8 +347,7 @@ public class LoginController extends WebBaseController {
logger.info("当前登录信息={}", JSON.toJSON(loginUser));
vo = EntityUtil.changeEntityByOrika(WebLoginVO.class, loginUser);
}
String gicHost = GlobalVar.ctxPropertiesMap.get("gicweb_service_host");
gicHost = gicHost.replace("gicweb", "").replace("https://", "http://").replace("http://", "https://");
String gicHost = this.getGicHost();
vo.setGicHost(gicHost);
return this.success(vo);
}
......
......@@ -562,6 +562,10 @@ public class StaffController extends WebBaseController {
private boolean isAdmin(){
WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
String staffId = login.getStaffId() ;
if(StringUtils.isBlank(staffId)) {
return false ;
}
String wxEnterpriseId = login.getWxEnterpriseId();
WxApplicationDTO application = wxApplicationApiService.selectByWxEnterpriseIdAndApplicationType(wxEnterpriseId, 2);
WxEnterpriseDTO enterprise = wxEnterpriseApiService.getOne(wxEnterpriseId);
......@@ -577,10 +581,6 @@ public class StaffController extends WebBaseController {
openUserIds.add(json.getString("userid"));
}
}
String staffId = login.getStaffId() ;
if(StringUtils.isBlank(staffId)) {
return false ;
}
StaffDTO staff = this.staffApiService.selectById(staffId) ;
if(openUserIds.contains(staff.getWxUserId()) || openUserIds.contains(staff.getWxOpenUseId())) {
return true ;
......
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