|
@@ -14,6 +14,7 @@ import org.fouram.core.util.AppUtil;
|
|
|
import org.fouram.core.util.AppUtil.ResultConstant;
|
|
|
import org.fouram.core.util.ConfConfig;
|
|
|
import org.fouram.core.util.LoggerUtil;
|
|
|
+import org.fouram.entity.SapOrg;
|
|
|
import org.fouram.service.SapOrgService;
|
|
|
import org.fouram.service.SapUserService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -35,8 +36,8 @@ public class ApiController extends BaseController {
|
|
|
private SapUserService sapUserService;
|
|
|
@Autowired
|
|
|
private static final String TOKEN="UserId";
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 获取授权url
|
|
|
* @return
|
|
@@ -45,8 +46,9 @@ public class ApiController extends BaseController {
|
|
|
@ResponseBody
|
|
|
public Object getAuthUrl(String url) {
|
|
|
try {
|
|
|
- String redirectUri = ConfConfig.getConfigString("wxCp.redirectUri");
|
|
|
+ String redirectUri = ConfConfig.getConfigString("wxCp.redirectUri")+"/API/wxCpLogin";
|
|
|
String authUri = WXCpMailList.oauth2Service.buildAuthorizationUrl(redirectUri,url);
|
|
|
+ System.out.println(authUri);
|
|
|
return AppUtil.success(authUri, null);
|
|
|
} catch (Exception e) {
|
|
|
LoggerUtil.error(e);
|
|
@@ -75,14 +77,22 @@ public class ApiController extends BaseController {
|
|
|
@ResponseBody
|
|
|
public Object getChildDepartAndUserListByDepartId(HttpServletRequest request) {
|
|
|
if(!isLogin(request)){
|
|
|
- return AppUtil.error(ResultConstant.TOKEN_ERR_MSG);
|
|
|
+ return AppUtil.error(ResultConstant.NO_TOKEN,ResultConstant.TOKEN_ERR_MSG);
|
|
|
}
|
|
|
try {
|
|
|
String departId = getPageData().getString("departId");
|
|
|
- if (StringUtils.isBlank(departId)) {
|
|
|
+ SapOrg sapOrg = null;
|
|
|
+ if (StringUtils.isBlank(departId)
|
|
|
+ ||WebConstants.TOP_DEPART.toString().equals(departId)) {
|
|
|
departId = WebConstants.TOP_DEPART.toString();
|
|
|
+ sapOrg=SapOrg.builder()
|
|
|
+ .id(WebConstants.TOP_DEPART.toString())
|
|
|
+ .sapName(WebConstants.TOP_DEPART_NAME).build();
|
|
|
+ }else{
|
|
|
+ sapOrg=sapOrgService.selectById(departId);
|
|
|
}
|
|
|
Map<String, Object> result = Maps.newHashMap();
|
|
|
+ result.put("departInfo",sapOrg);
|
|
|
result.put("departList", sapOrgService.selectListByParentId(departId));
|
|
|
result.put("userList", sapUserService.selectListByDepartIdAndLevel(departId));
|
|
|
return AppUtil.success(result, null);
|
|
@@ -100,7 +110,7 @@ public class ApiController extends BaseController {
|
|
|
@ResponseBody
|
|
|
public Object getDepartAndUserListByName(HttpServletRequest request) {
|
|
|
if(!isLogin(request)){
|
|
|
- return AppUtil.error(ResultConstant.TOKEN_ERR_MSG);
|
|
|
+ return AppUtil.error(ResultConstant.NO_TOKEN,ResultConstant.TOKEN_ERR_MSG);
|
|
|
}
|
|
|
try {
|
|
|
String name = getPageData().getString("name");
|
|
@@ -122,7 +132,7 @@ public class ApiController extends BaseController {
|
|
|
@ResponseBody
|
|
|
public Object getUserInfoById(HttpServletRequest request) {
|
|
|
if(!isLogin(request)){
|
|
|
- return AppUtil.error(ResultConstant.TOKEN_ERR_MSG);
|
|
|
+ return AppUtil.error(ResultConstant.NO_TOKEN,ResultConstant.TOKEN_ERR_MSG);
|
|
|
}
|
|
|
try {
|
|
|
String userId = getPageData().getString("userId");
|
|
@@ -139,10 +149,10 @@ public class ApiController extends BaseController {
|
|
|
* @return
|
|
|
*/
|
|
|
public boolean isLogin(HttpServletRequest request){
|
|
|
-// HttpSession httpSession = request.getSession();
|
|
|
-// if(null==httpSession.getAttribute(TOKEN)){
|
|
|
-// return false;
|
|
|
-// }
|
|
|
+ HttpSession httpSession = request.getSession();
|
|
|
+ if(null==httpSession.getAttribute(TOKEN)){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
return true;
|
|
|
}
|
|
|
|