Commit d227321e by xiehongfei

feat:新增区经角色好办访问数据

parent 454cf6a9
......@@ -12,6 +12,9 @@ import java.util.stream.Collectors;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;
import com.gic.enterprise.api.dto.EnterpriseSettingDTO;
import com.gic.enterprise.api.dto.StoreWidgetDTO;
import com.gic.enterprise.api.service.StoreWidgetService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
......@@ -88,6 +91,8 @@ public class LoginController extends WebBaseController {
private HaobanUserApiService haobanUserApiService;
@Autowired
private RightService rightService ;
@Autowired
private StoreWidgetService storeWidgetService;
/**
* 企微后台登录
......@@ -445,9 +450,38 @@ public class LoginController extends WebBaseController {
}
String gicHost = this.getGicHost();
vo.setGicHost(gicHost);
String clerkId = loginUser.getClerkId();
ClerkDTO clerkDTO = clerkService.getClerkByClerkId(clerkId);
vo.setHasAllStorePermission(0);
if (null != clerkDTO) {
vo.setHasAllStorePermission(isAdminAuthStore(loginUser.getEnterpriseId(), clerkDTO) ? 1:0);
}
return this.success(vo);
}
private boolean isAdminAuthStore(String enterpriseId, ClerkDTO clerkDTO) {
if (!isAuthEnterprise(enterpriseId)) {
return true;
}
boolean isAdmin = clerkDTO.getSuperAdmin() != null && clerkDTO.getSuperAdmin() == 1;
return isAdmin || StringUtils.isBlank(clerkDTO.getStoreWidgetId()) || isAllAuth(clerkDTO.getStoreWidgetId());
}
private boolean isAuthEnterprise(String enterpriseId) {
EnterpriseSettingDTO enterpriseSettingDTO = enterpriseService.getEnterpriseSettingByEnterpriseId(enterpriseId);
Integer enableAccessControl = enterpriseSettingDTO.getEnableAccessControl();
//是否开启权限控制
boolean isEnableAccessControl = enableAccessControl != null && enableAccessControl.intValue() == 1;
return isEnableAccessControl;
}
private boolean isAllAuth(String key) {
StoreWidgetDTO storeWidgetDTO = storeWidgetService.getStoreWidgetBykey(key);
return storeWidgetDTO != null && storeWidgetDTO.getSelectType().intValue() == 0;
}
@RequestMapping("get-login-session")
@IgnoreLogin
public HaobanResponse getLoginSession() {
......
......@@ -36,6 +36,11 @@ public class WebLoginVO implements Serializable {
private String cliqueId ;
//登录用户关联的企业是否是集团:1是0否
private Integer isClique ;
/**
* 是否有所有门店权限,1:是,0:否
*/
private Integer hasAllStorePermission;
public String getCliqueId() {
return cliqueId;
......@@ -183,4 +188,12 @@ public class WebLoginVO implements Serializable {
this.clerkPhone = clerkPhone;
return this;
}
public Integer getHasAllStorePermission() {
return hasAllStorePermission;
}
public void setHasAllStorePermission(Integer hasAllStorePermission) {
this.hasAllStorePermission = hasAllStorePermission;
}
}
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