|
@@ -0,0 +1,124 @@
|
|
|
+package com.jpsoft.railroad.modules.mobile.controller;
|
|
|
+
|
|
|
+import com.github.pagehelper.Page;
|
|
|
+import com.jpsoft.railroad.modules.base.dto.FocusNewsDTO;
|
|
|
+import com.jpsoft.railroad.modules.base.dto.NewsDTO;
|
|
|
+import com.jpsoft.railroad.modules.base.entity.*;
|
|
|
+import com.jpsoft.railroad.modules.base.service.*;
|
|
|
+import com.jpsoft.railroad.modules.common.dto.MessageResult;
|
|
|
+import com.jpsoft.railroad.modules.common.dto.Sort;
|
|
|
+import com.jpsoft.railroad.modules.common.utils.JwtUtil;
|
|
|
+import com.jpsoft.railroad.modules.common.utils.PojoUtils;
|
|
|
+import com.jpsoft.railroad.modules.sys.service.DataDictionaryService;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@RequestMapping("/mobile/addressBook")
|
|
|
+@Api(description = "通讯录接口")
|
|
|
+public class AddressBookApi {
|
|
|
+ private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
+
|
|
|
+ @Value("${jwt.secret}")
|
|
|
+ private String jwtSecret;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private OrganizationService organizationService;
|
|
|
+ @Autowired
|
|
|
+ private RegUserService regUserService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private DataDictionaryService dataDictionaryService;
|
|
|
+
|
|
|
+ @ApiOperation(value="通讯录")
|
|
|
+ @RequestMapping(value = "bookList",method = RequestMethod.POST)
|
|
|
+ public MessageResult<Map> bookList(
|
|
|
+ String orgId,
|
|
|
+ @RequestAttribute String subject){
|
|
|
+ MessageResult<Map> msgResult = new MessageResult<>();
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+ List<RegUser> regUserList = regUserService.findByOrgId(orgId);
|
|
|
+ map.put("userList",regUserList);
|
|
|
+ msgResult.setData(map);
|
|
|
+ }
|
|
|
+ catch(Exception ex){
|
|
|
+ logger.error(ex.getMessage(),ex);
|
|
|
+
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return msgResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value="选择列表")
|
|
|
+ @RequestMapping(value = "companyList",method = RequestMethod.POST)
|
|
|
+ public MessageResult companyList(String parentId){
|
|
|
+ MessageResult msgResult = new MessageResult<>();
|
|
|
+
|
|
|
+ Map<String,Object> searchParms = new HashMap<>();
|
|
|
+ if(StringUtils.isNotEmpty(parentId)) {
|
|
|
+ searchParms.put("parentId", parentId);
|
|
|
+ }else{
|
|
|
+ searchParms.put("noParentId", "1");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
+ sortList.add(new Sort("a.name_","asc"));
|
|
|
+
|
|
|
+ List<Map> list1 = new ArrayList<>();
|
|
|
+
|
|
|
+ searchParms.put("noName", "测试");
|
|
|
+ Page<Organization> page = organizationService.pageSearch(searchParms,1,10000,false,sortList);
|
|
|
+ for(Organization organization : page.getResult()){
|
|
|
+ List<Map> children = children(organization.getId());
|
|
|
+
|
|
|
+ Map<String,Object> org = new HashMap<>();
|
|
|
+ org.put("label",organization.getName());
|
|
|
+ org.put("value",organization.getId());
|
|
|
+ if(children.size() > 0){
|
|
|
+ org.put("children",children);
|
|
|
+ }
|
|
|
+ list1.add(org);
|
|
|
+ }
|
|
|
+
|
|
|
+ msgResult.setResult(true);
|
|
|
+ msgResult.setData(list1);
|
|
|
+
|
|
|
+ return msgResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<Map> children(String orgId){
|
|
|
+ List<Map> list = new ArrayList<>();
|
|
|
+
|
|
|
+ List<Organization> orgList = organizationService.findByParent(orgId);
|
|
|
+ for(Organization org : orgList){
|
|
|
+ List<Map> children = children(org.getId());
|
|
|
+
|
|
|
+ Map<String,Object> oMap = new HashMap<>();
|
|
|
+ oMap.put("label",org.getName());
|
|
|
+ oMap.put("value",org.getId());
|
|
|
+ if(children.size() > 0){
|
|
|
+ oMap.put("children",children);
|
|
|
+ }
|
|
|
+ list.add(oMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|