|
@@ -35,19 +35,19 @@ public class ApiController extends BaseController {
|
|
|
@Autowired
|
|
|
private SapUserService sapUserService;
|
|
|
@Autowired
|
|
|
- private static final String TOKEN="UserId";
|
|
|
-
|
|
|
+ private static final String TOKEN = "UserId";
|
|
|
|
|
|
/**
|
|
|
* 获取授权url
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/getAuthUrl", produces = "application/json;charset=utf-8")
|
|
|
@ResponseBody
|
|
|
public Object getAuthUrl(String url) {
|
|
|
try {
|
|
|
- String redirectUri = ConfConfig.getConfigString("wxCp.redirectUri")+"/API/wxCpLogin";
|
|
|
- String authUri = WXCpMailList.oauth2Service.buildAuthorizationUrl(redirectUri,url);
|
|
|
+ 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) {
|
|
@@ -58,41 +58,41 @@ public class ApiController extends BaseController {
|
|
|
|
|
|
@RequestMapping(value = "/wxCpLogin", produces = "application/json;charset=utf-8")
|
|
|
@ResponseBody
|
|
|
- public void wxCpLogin(String code,String state,HttpServletRequest request, HttpServletResponse response) throws Exception {
|
|
|
+ public void wxCpLogin(String code, String state, HttpServletRequest request, HttpServletResponse response)
|
|
|
+ throws Exception {
|
|
|
WxCpOauth2UserInfo userInfo = WXCpMailList.oauth2Service.getUserInfo(code);
|
|
|
- if(StringUtils.isEmpty(userInfo.getUserId())){
|
|
|
+ if (StringUtils.isEmpty(userInfo.getUserId())) {
|
|
|
response.getWriter().println("无权限访问!");
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
HttpSession httpSession = request.getSession();
|
|
|
- httpSession.setAttribute(TOKEN,userInfo.getUserId());
|
|
|
+ httpSession.setAttribute(TOKEN, userInfo.getUserId());
|
|
|
response.sendRedirect(state);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据部门id查询下级部门和用户
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/getChildDepartAndUserListByDepartId", produces = "application/json;charset=utf-8")
|
|
|
@ResponseBody
|
|
|
public Object getChildDepartAndUserListByDepartId(HttpServletRequest request) {
|
|
|
- if(!isLogin(request)){
|
|
|
- return AppUtil.error(ResultConstant.NO_TOKEN,ResultConstant.TOKEN_ERR_MSG);
|
|
|
+ if (!isLogin(request)) {
|
|
|
+ return AppUtil.error(ResultConstant.NO_TOKEN, ResultConstant.TOKEN_ERR_MSG);
|
|
|
}
|
|
|
try {
|
|
|
String departId = getPageData().getString("departId");
|
|
|
SapOrg sapOrg = null;
|
|
|
- if (StringUtils.isBlank(departId)
|
|
|
- ||WebConstants.TOP_DEPART.toString().equals(departId)) {
|
|
|
+ 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);
|
|
|
+ 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("departInfo", sapOrg);
|
|
|
result.put("departList", sapOrgService.selectListByParentId(departId));
|
|
|
result.put("userList", sapUserService.selectListByDepartIdAndLevel(departId));
|
|
|
return AppUtil.success(result, null);
|
|
@@ -104,13 +104,14 @@ public class ApiController extends BaseController {
|
|
|
|
|
|
/**
|
|
|
* 根据输入查询内容查询对应部门和用户
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
- @RequestMapping(value = "/getDepartAndUserListByName", produces = "application/json;charset=utf-8")
|
|
|
+ @RequestMapping(value = "/getDepartAndUserListByName", produces = "application/json;charset=utf-8")
|
|
|
@ResponseBody
|
|
|
public Object getDepartAndUserListByName(HttpServletRequest request) {
|
|
|
- if(!isLogin(request)){
|
|
|
- return AppUtil.error(ResultConstant.NO_TOKEN,ResultConstant.TOKEN_ERR_MSG);
|
|
|
+ if (!isLogin(request)) {
|
|
|
+ return AppUtil.error(ResultConstant.NO_TOKEN, ResultConstant.TOKEN_ERR_MSG);
|
|
|
}
|
|
|
try {
|
|
|
String name = getPageData().getString("name");
|
|
@@ -126,13 +127,14 @@ public class ApiController extends BaseController {
|
|
|
|
|
|
/**
|
|
|
* 根据id查询用户信息
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/getUserInfoByUserId", produces = "application/json;charset=utf-8")
|
|
|
@ResponseBody
|
|
|
public Object getUserInfoById(HttpServletRequest request) {
|
|
|
- if(!isLogin(request)){
|
|
|
- return AppUtil.error(ResultConstant.NO_TOKEN,ResultConstant.TOKEN_ERR_MSG);
|
|
|
+ if (!isLogin(request)) {
|
|
|
+ return AppUtil.error(ResultConstant.NO_TOKEN, ResultConstant.TOKEN_ERR_MSG);
|
|
|
}
|
|
|
try {
|
|
|
String userId = getPageData().getString("userId");
|
|
@@ -145,12 +147,13 @@ public class ApiController extends BaseController {
|
|
|
|
|
|
/**
|
|
|
* 判断是否经过授权
|
|
|
+ *
|
|
|
* @param request
|
|
|
* @return
|
|
|
*/
|
|
|
- public boolean isLogin(HttpServletRequest request){
|
|
|
+ public boolean isLogin(HttpServletRequest request) {
|
|
|
HttpSession httpSession = request.getSession();
|
|
|
- if(null==httpSession.getAttribute(TOKEN)){
|
|
|
+ if (null == httpSession.getAttribute(TOKEN)) {
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|