|
|
@@ -1,9 +1,16 @@
|
|
|
package easydo.technology.controller;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import easydo.technology.annotation.WebLog;
|
|
|
import easydo.technology.components.JdbcClient;
|
|
|
import easydo.technology.model.ApproveInfo;
|
|
|
+import easydo.technology.model.GldDept;
|
|
|
+import easydo.technology.model.GldMember;
|
|
|
+import easydo.technology.model.SysUser;
|
|
|
+import easydo.technology.service.GLDApproveService;
|
|
|
import easydo.technology.service.GLDMasterService;
|
|
|
+import easydo.technology.utils.StringUtil;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
@@ -15,14 +22,19 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.sql.DataSource;
|
|
|
import java.sql.Connection;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@RestController
|
|
|
@RequestMapping("/gldMaster")
|
|
|
public class GLDMasterController {
|
|
|
@Resource
|
|
|
GLDMasterService gldMasterService;
|
|
|
+ @Resource
|
|
|
+ GLDApproveService gldApproveService;
|
|
|
@Value("${GLD.APPROVE.mgtGroupId}")
|
|
|
String mgtGroupId;
|
|
|
@Value("${tenantId_gld_master}")
|
|
|
@@ -69,4 +81,44 @@ public class GLDMasterController {
|
|
|
gldMasterService.removeToken();
|
|
|
return new ResponseEntity<>(HttpStatus.OK);
|
|
|
}
|
|
|
+
|
|
|
+ @WebLog
|
|
|
+ @RequestMapping("/getUserDeptList")
|
|
|
+ public Object getUserDeptList(@RequestBody SysUser user) throws Exception {
|
|
|
+ if (StringUtil.isEmpty(user.getPhone())) {
|
|
|
+ throw new Exception("参数错误");
|
|
|
+ }
|
|
|
+
|
|
|
+ Connection connection = null;
|
|
|
+ try {
|
|
|
+ connection = dataSource.getConnection();
|
|
|
+
|
|
|
+ GldMember gldMember = new GldMember();
|
|
|
+ gldMember.setPhone(user.getPhone());
|
|
|
+ gldMember.setActive(true);
|
|
|
+ gldMember.setEnabled(true);
|
|
|
+ gldMember = jdbcClient.getJdbcModel(gldMember, connection);
|
|
|
+
|
|
|
+ if (StringUtil.isEmpty(gldMember.getId())) {
|
|
|
+ throw new Exception("手机号参数错误或缺失");
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONArray list = gldApproveService.getUserDeptList(gldMember.getUserId());
|
|
|
+ List<GldDept> deptList = new ArrayList<>();
|
|
|
+ for (Object object : list) {
|
|
|
+ JSONObject obj = (JSONObject) object;
|
|
|
+ Long deptId = obj.getLong("deptId");
|
|
|
+ GldDept gldDept = new GldDept();
|
|
|
+ gldDept.setId(deptId.toString());
|
|
|
+ gldDept = jdbcClient.getJdbcModel(gldDept, connection);
|
|
|
+ deptList.add(gldDept);
|
|
|
+ }
|
|
|
+ deptList = deptList.stream().filter(model->!"内部单位".equals(model.getName())).collect(Collectors.toList());
|
|
|
+ return new ResponseEntity<>(deptList, HttpStatus.OK);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw e;
|
|
|
+ } finally {
|
|
|
+ jdbcClient.finallyExecute(connection);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|