|
@@ -977,79 +977,79 @@ public class WeiXinCorpController {
|
|
}
|
|
}
|
|
|
|
|
|
//老版本
|
|
//老版本
|
|
-// @RequestMapping("/getCorpMembs")
|
|
|
|
-// public HttpRespMsg getCorpMembs(String corpId) {
|
|
|
|
-//
|
|
|
|
-// WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectById(corpId);
|
|
|
|
-//
|
|
|
|
-// Company company = companyMapper.selectById(wxCorpInfo.getCompanyId());
|
|
|
|
-// String curCorpAccessToken = null;
|
|
|
|
-// try {
|
|
|
|
-// curCorpAccessToken = getCorpAccessToken(wxCorpInfo);
|
|
|
|
-// } catch (Exception exception) {
|
|
|
|
-// exception.printStackTrace();
|
|
|
|
-// }
|
|
|
|
-// int companyId = company.getId();
|
|
|
|
-// //获取公司根部门人员,也就是没有分配部门的人员
|
|
|
|
-// int companyRootDeptId = 1;
|
|
|
|
-// JSONArray unAssignedUserList = getDeptUserSimple(curCorpAccessToken, companyRootDeptId);
|
|
|
|
-// SysRole defaultRole = sysRoleMapper.selectOne(
|
|
|
|
-// new QueryWrapper<SysRole>().eq("company_id", companyId).eq("is_default", 1));
|
|
|
|
-//
|
|
|
|
-// for (int m=0;m<unAssignedUserList.size(); m++) {
|
|
|
|
-// JSONObject userJson = unAssignedUserList.getJSONObject(m);
|
|
|
|
-// String curUserid = userJson.getString("userid");
|
|
|
|
-// System.out.println("userid="+curUserid+", name=" + userJson.getString("name")+", mobile="+userJson.getString("mobile"));
|
|
|
|
-// //不存在的人员, 进行插入
|
|
|
|
-// User user = new User();
|
|
|
|
-//
|
|
|
|
-// user.setId(SnowFlake.nextId()+"")
|
|
|
|
-// .setRoleId(defaultRole.getId())//默认普通员工
|
|
|
|
-// .setRoleName(defaultRole.getRolename())
|
|
|
|
-// .setCompanyId(companyId)
|
|
|
|
-// .setName(userJson.getString("name"))
|
|
|
|
-// .setCorpwxUserid(curUserid)
|
|
|
|
-// .setColor(ColorUtil.randomColor());
|
|
|
|
-//
|
|
|
|
-// //检查用户是否已经存在
|
|
|
|
-// if (userMapper.selectCount(new QueryWrapper<User>().eq("corpwx_userid", curUserid)) == 0) {
|
|
|
|
-// userMapper.insert(user);
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// //获取部门
|
|
|
|
-// JSONObject deptObj = getAllDepartments(curCorpAccessToken);
|
|
|
|
-// JSONArray deptObjJSONArray = deptObj.getJSONArray("department");
|
|
|
|
-//
|
|
|
|
-// for (int i=0;i<deptObjJSONArray.size(); i++) {
|
|
|
|
-// int deptId = deptObjJSONArray.getJSONObject(i).getIntValue("id");
|
|
|
|
-//
|
|
|
|
-// JSONArray userList = getDeptUserSimple(curCorpAccessToken, deptId);
|
|
|
|
-// for (int m=0;m<userList.size(); m++) {
|
|
|
|
-// JSONObject userJson = userList.getJSONObject(m);
|
|
|
|
-// String curUserid = userJson.getString("userid");
|
|
|
|
-// System.out.println("userid="+curUserid+", name=" + userJson.getString("name")+", mobile="+userJson.getString("mobile"));
|
|
|
|
-// //不存在的人员, 进行插入
|
|
|
|
-// User user = new User();
|
|
|
|
-//
|
|
|
|
-// user.setId(SnowFlake.nextId()+"")
|
|
|
|
-// .setRoleId(defaultRole.getId())//默认普通员工
|
|
|
|
-// .setRoleName(defaultRole.getRolename())
|
|
|
|
-// .setCompanyId(companyId)
|
|
|
|
-// .setDepartmentId(0)
|
|
|
|
-// .setName(userJson.getString("name"))
|
|
|
|
-// .setCorpwxUserid(curUserid)
|
|
|
|
-// .setColor(ColorUtil.randomColor());
|
|
|
|
-//
|
|
|
|
-// //检查用户是否已经存在
|
|
|
|
-// if (userMapper.selectCount(new QueryWrapper<User>().eq("corpwx_userid", curUserid)) == 0) {
|
|
|
|
-// userMapper.insert(user);
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// return new HttpRespMsg();
|
|
|
|
-// }
|
|
|
|
|
|
+ @RequestMapping("/getCorpMembsOld")
|
|
|
|
+ public HttpRespMsg getCorpMembsOld(String corpId) {
|
|
|
|
+
|
|
|
|
+ WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectById(corpId);
|
|
|
|
+
|
|
|
|
+ Company company = companyMapper.selectById(wxCorpInfo.getCompanyId());
|
|
|
|
+ String curCorpAccessToken = null;
|
|
|
|
+ try {
|
|
|
|
+ curCorpAccessToken = getCorpAccessToken(wxCorpInfo);
|
|
|
|
+ } catch (Exception exception) {
|
|
|
|
+ exception.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ int companyId = company.getId();
|
|
|
|
+ //获取公司根部门人员,也就是没有分配部门的人员
|
|
|
|
+ int companyRootDeptId = 1;
|
|
|
|
+ JSONArray unAssignedUserList = getDeptUserSimple(curCorpAccessToken, companyRootDeptId);
|
|
|
|
+ SysRole defaultRole = sysRoleMapper.selectOne(
|
|
|
|
+ new QueryWrapper<SysRole>().eq("company_id", companyId).eq("is_default", 1));
|
|
|
|
+
|
|
|
|
+ for (int m=0;m<unAssignedUserList.size(); m++) {
|
|
|
|
+ JSONObject userJson = unAssignedUserList.getJSONObject(m);
|
|
|
|
+ String curUserid = userJson.getString("userid");
|
|
|
|
+ System.out.println("userid="+curUserid+", name=" + userJson.getString("name")+", mobile="+userJson.getString("mobile"));
|
|
|
|
+ //不存在的人员, 进行插入
|
|
|
|
+ User user = new User();
|
|
|
|
+
|
|
|
|
+ user.setId(SnowFlake.nextId()+"")
|
|
|
|
+ .setRoleId(defaultRole.getId())//默认普通员工
|
|
|
|
+ .setRoleName(defaultRole.getRolename())
|
|
|
|
+ .setCompanyId(companyId)
|
|
|
|
+ .setName(userJson.getString("name"))
|
|
|
|
+ .setCorpwxUserid(curUserid)
|
|
|
|
+ .setColor(ColorUtil.randomColor());
|
|
|
|
+
|
|
|
|
+ //检查用户是否已经存在
|
|
|
|
+ if (userMapper.selectCount(new QueryWrapper<User>().eq("corpwx_userid", curUserid)) == 0) {
|
|
|
|
+ userMapper.insert(user);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //获取部门
|
|
|
|
+ JSONObject deptObj = getAllDepartments(curCorpAccessToken);
|
|
|
|
+ JSONArray deptObjJSONArray = deptObj.getJSONArray("department");
|
|
|
|
+
|
|
|
|
+ for (int i=0;i<deptObjJSONArray.size(); i++) {
|
|
|
|
+ int deptId = deptObjJSONArray.getJSONObject(i).getIntValue("id");
|
|
|
|
+
|
|
|
|
+ JSONArray userList = getDeptUserSimple(curCorpAccessToken, deptId);
|
|
|
|
+ for (int m=0;m<userList.size(); m++) {
|
|
|
|
+ JSONObject userJson = userList.getJSONObject(m);
|
|
|
|
+ String curUserid = userJson.getString("userid");
|
|
|
|
+ System.out.println("userid="+curUserid+", name=" + userJson.getString("name")+", mobile="+userJson.getString("mobile"));
|
|
|
|
+ //不存在的人员, 进行插入
|
|
|
|
+ User user = new User();
|
|
|
|
+
|
|
|
|
+ user.setId(SnowFlake.nextId()+"")
|
|
|
|
+ .setRoleId(defaultRole.getId())//默认普通员工
|
|
|
|
+ .setRoleName(defaultRole.getRolename())
|
|
|
|
+ .setCompanyId(companyId)
|
|
|
|
+ .setDepartmentId(0)
|
|
|
|
+ .setName(userJson.getString("name"))
|
|
|
|
+ .setCorpwxUserid(curUserid)
|
|
|
|
+ .setColor(ColorUtil.randomColor());
|
|
|
|
+
|
|
|
|
+ //检查用户是否已经存在
|
|
|
|
+ if (userMapper.selectCount(new QueryWrapper<User>().eq("corpwx_userid", curUserid)) == 0) {
|
|
|
|
+ userMapper.insert(user);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return new HttpRespMsg();
|
|
|
|
+ }
|
|
|
|
|
|
//新版本
|
|
//新版本
|
|
@RequestMapping("/getCorpMembs")
|
|
@RequestMapping("/getCorpMembs")
|