|
@@ -1,14 +1,13 @@
|
|
|
package org.fouram.controller;
|
|
|
|
|
|
-import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.fouram.constants.WebConstants;
|
|
|
import org.fouram.core.base.controller.BaseController;
|
|
|
import org.fouram.core.util.AppUtil;
|
|
|
import org.fouram.core.util.AppUtil.ResultConstant;
|
|
|
import org.fouram.core.util.LoggerUtil;
|
|
|
-import org.fouram.core.util.TreeUtil;
|
|
|
-import org.fouram.entity.SapOrg;
|
|
|
-import org.fouram.entity.SapUser;
|
|
|
import org.fouram.service.SapOrgService;
|
|
|
import org.fouram.service.SapUserService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -16,47 +15,44 @@ import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
+import com.google.common.collect.Maps;
|
|
|
+
|
|
|
@Controller
|
|
|
@RequestMapping(value = "/API")
|
|
|
public class ApiController extends BaseController {
|
|
|
-
|
|
|
+
|
|
|
@Autowired
|
|
|
private SapOrgService sapOrgService;
|
|
|
@Autowired
|
|
|
private SapUserService sapUserService;
|
|
|
|
|
|
- @RequestMapping(value = "/getDepartTree", produces = "application/json;charset=utf-8")
|
|
|
+ @RequestMapping(value = "/getChildDepartAndUserListByDepartId", produces = "application/json;charset=utf-8")
|
|
|
@ResponseBody
|
|
|
- public Object getDepartTree() {
|
|
|
+ public Object getChildDepartAndUserListByDepartId() {
|
|
|
try {
|
|
|
- List<SapOrg> allOrgs = sapOrgService.findAll();
|
|
|
- return AppUtil.success(TreeUtil.buildTreeSimple(allOrgs), null);
|
|
|
+ String departId = getPageData().getString("departId");
|
|
|
+ if (StringUtils.isBlank(departId)) {
|
|
|
+ departId = WebConstants.TOP_DEPART.toString();
|
|
|
+ }
|
|
|
+ Map<String, Object> result = Maps.newHashMap();
|
|
|
+ result.put("departList", sapOrgService.selectListByParentId(departId));
|
|
|
+ result.put("userList", sapUserService.selectListByDepartId(departId));
|
|
|
+ return AppUtil.success(result, null);
|
|
|
} catch (Exception e) {
|
|
|
LoggerUtil.error(e);
|
|
|
return AppUtil.error(ResultConstant.WEB_ERR_MSG);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- @RequestMapping(value = "/getDepartListByName", produces = "application/json;charset=utf-8")
|
|
|
- @ResponseBody
|
|
|
- public Object getDepartListByName() {
|
|
|
- try {
|
|
|
- String name = getPageData().getString("name");
|
|
|
- List<SapOrg> orgs = sapOrgService.getDepartListByName(name);
|
|
|
- return AppUtil.success(orgs, null);
|
|
|
- } catch (Exception e) {
|
|
|
- LoggerUtil.error(e);
|
|
|
- return AppUtil.error(ResultConstant.WEB_ERR_MSG);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @RequestMapping(value = "/getUserListByName", produces = "application/json;charset=utf-8")
|
|
|
+
|
|
|
+ @RequestMapping(value = "/getDepartAndUserListByName", produces = "application/json;charset=utf-8")
|
|
|
@ResponseBody
|
|
|
- public Object getUserListByName() {
|
|
|
+ public Object getDepartAndUserListByName() {
|
|
|
try {
|
|
|
String name = getPageData().getString("name");
|
|
|
- List<SapUser> users = sapUserService.getUserListByName(name);
|
|
|
- return AppUtil.success(users, null);
|
|
|
+ Map<String, Object> result = Maps.newHashMap();
|
|
|
+ result.put("departList", sapOrgService.selectListByName(name));
|
|
|
+ result.put("userList", sapUserService.selectListByName(name));
|
|
|
+ return AppUtil.success(result, null);
|
|
|
} catch (Exception e) {
|
|
|
LoggerUtil.error(e);
|
|
|
return AppUtil.error(ResultConstant.WEB_ERR_MSG);
|