diff --git a/laws-modules/src/main/java/com/jero/modules/iam/BamboocloudUtils.java b/laws-modules/src/main/java/com/jero/modules/iam/BamboocloudUtils.java new file mode 100644 index 00000000..7c8ea820 --- /dev/null +++ b/laws-modules/src/main/java/com/jero/modules/iam/BamboocloudUtils.java @@ -0,0 +1,78 @@ +//package com.jero.modules.iam; +//import com.banboocloud.Codec.BamboocloudFacade; +//import com.ruoyi.common.utils.reflect.ReflectUtils; +//import org.slf4j.Logger; +//import org.slf4j.LoggerFactory; +// +//import javax.servlet.http.HttpServletRequest; +//import java.io.BufferedReader; +//import java.io.IOException; +//import java.util.Iterator; +//import java.util.Map; +//import java.util.TreeMap; +//public class BamboocloudUtils { +// private static Logger logger = LoggerFactory.getLogger(ReflectUtils.class); +// public static boolean checkUsernamePassword(String username, String password) { +// logger.info("username --->" + username + " password --- >" + password + " ----ok"); +// if("bbcadmin".equals(username)&&"P@ssw0rd".equals(password)) { +// return true; +// } +// else { +// return false; +// } +// } +// +// public static String getPlaintext(String ciphertext, String key, String type) { +// return BamboocloudFacade.decrypt(ciphertext, key, type); +// } +// +// public static Boolean verify(Map reqmap, String type) { +// Map verifymap = new TreeMap(); +// StringBuffer sb = new StringBuffer(); +// Iterator it = reqmap.keySet().iterator(); +// while (it.hasNext()) { +// String key = (String) it.next(); +// verifymap.put(key, reqmap.get(key)); +// } +// Iterator ittree = verifymap.keySet().iterator(); +// while (ittree.hasNext()) { +// String key = (String) ittree.next(); +// if (!"signature".equals(key)) { +// sb.append(key).append("=").append(verifymap.get(key)).append("&"); +// } +// } +// sb.deleteCharAt(sb.length() - 1); +// System.out.println(reqmap.get("signature") + " now " + sb.toString()); +// return BamboocloudFacade.verify(reqmap.get("signature").toString(), sb.toString(), type); +// } +// +// public static String getRequestBody(HttpServletRequest request) { +// BufferedReader br = null; +// StringBuilder sb = new StringBuilder(); +// String str = ""; +// try { +// br = request.getReader(); +// while ((str = br.readLine()) != null) { +// sb.append(str); +// } +// br.close(); +// } catch (IOException e) { +// e.printStackTrace(); +// if (br != null) +// try { +// br.close(); +// } catch (IOException eo) { +// eo.printStackTrace(); +// } +// } finally { +// if (br != null) { +// try { +// br.close(); +// } catch (IOException e) { +// e.printStackTrace(); +// } +// } +// } +// return sb.toString(); +// } +//} diff --git a/laws-modules/src/main/java/com/jero/modules/iam/BbcController.java b/laws-modules/src/main/java/com/jero/modules/iam/BbcController.java new file mode 100644 index 00000000..5e5bc577 --- /dev/null +++ b/laws-modules/src/main/java/com/jero/modules/iam/BbcController.java @@ -0,0 +1,1138 @@ +//package com.jero.modules.iam; +//import com.alibaba.fastjson.JSON; +//import com.alibaba.fastjson.JSONObject; +//import com.banboocloud.Codec.BamboocloudFacade; +//import com.ruoyi.common.utils.reflect.ReflectUtils; +//import com.ruoyi.framework.web.controller.BaseController; +//import com.ruoyi.project.system.dept.domain.Dept; +//import com.ruoyi.project.system.dept.service.IDeptService; +//import com.ruoyi.project.system.dict.domain.DictData; +//import com.ruoyi.project.system.dict.service.IDictDataService; +//import com.ruoyi.project.system.post.domain.Post; +//import com.ruoyi.project.system.post.service.IPostService; +//import com.ruoyi.project.system.role.domain.Role; +//import com.ruoyi.project.system.role.service.IRoleService; +//import com.ruoyi.project.system.user.domain.User; +//import com.ruoyi.project.system.user.domain.UserRole; +//import com.ruoyi.project.system.user.service.IUserService; +//import com.ruoyi.project.tool.swagger.accessory.*; +//import io.swagger.annotations.Api; +//import io.swagger.annotations.ApiImplicitParam; +//import io.swagger.annotations.ApiOperation; +//import org.slf4j.Logger; +//import org.slf4j.LoggerFactory; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.web.bind.annotation.PostMapping; +//import org.springframework.web.bind.annotation.RequestMapping; +//import org.springframework.web.bind.annotation.ResponseBody; +//import org.springframework.web.bind.annotation.RestController; +// +//import javax.servlet.ServletException; +//import javax.servlet.http.HttpServletRequest; +//import javax.servlet.http.HttpServletResponse; +//import java.io.BufferedReader; +//import java.io.IOException; +//import java.io.PrintWriter; +//import java.util.*; +//public class BbcController { +// +// @Autowired +// private IUserService userService; +// +// @Autowired +// private IRoleService roleService; +// +// @Autowired +// private IPostService postService; +// +// @Autowired +// private IDeptService deptService; +// +// @Autowired +// private IDictDataService dictDataService; +// +// @Autowired +// private SysPasswordService passwordService; +// +// private String bimRequestId; +// +// private static Logger logger = LoggerFactory.getLogger(ReflectUtils.class); +// +// @ApiOperation("测试") +// @RequestMapping() +// public JSONObject bbcUser() { +// +// JSONObject jsonObject = new JSONObject(); +// jsonObject.put("resultCode", "0"); +// jsonObject.put("message", "success"); +// return jsonObject; +// +// } +// +// @ApiOperation("对象属性字段查询") +// @PostMapping("/schemaService") +// public String SchemaService(HttpServletRequest req, HttpServletResponse resp) { +// +// JSONObject jsonObject = new JSONObject(); +// +// // StringBuilder sb = stringBuilder(req); +// String bodyparam= BamboocloudUtils.getRequestBody(req); +// logger.info("json--param-->" + bodyparam); +// // String bodyparam = sb.toString(); +// //解密json字符传 +// bodyparam = BamboocloudUtils.getPlaintext(bodyparam, "123456", "AES"); +// logger.info("json--param-->" + bodyparam); +// Map reqmap = (Map) JSON.parse(bodyparam); +// //验证签名 +// if (BamboocloudUtils.verify(reqmap, "MD5").booleanValue()) { +// String username = (String) reqmap.get("bimRemoteUser"); +// String password = (String) reqmap.get("bimRemotePwd"); +// //判断接口中的调用名及调用密码是否正确 +// if (BamboocloudUtils.checkUsernamePassword(username, password)) { +// //添加返回的对象及属性字段名 +// MapJson mapJson = new MapJson(); +// Map>> map = new HashMap<>(); +// jsonObject.put("account", mapJson.accountList()); +// jsonObject.put("organization", mapJson.organizationList()); +// jsonObject.put("role", mapJson.roleList()); +// jsonObject.put("post", mapJson.postList()); +// jsonObject.put("dict", mapJson.dictDataList()); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJs = JSON.toJSONString(jsonObject); +// logger.info(jsonObject.toJSONString()); +// //返回加密的json字符串 +// mapJs = BamboocloudFacade.encrypt(mapJs, "123456", "AES"); +// //jsonObject.put(map); +// // values = jsonObject.values(); +// return mapJs; +// } +// } +// jsonObject.put("bimRequestId", bimRequestId); +// jsonObject.put("resultCode", "505"); +// jsonObject.put("message", "连接失败,请检查连接器配置的参数"); +// logger.info(jsonObject.toJSONString()); +// String mapJs = JSON.toJSONString(jsonObject); +// //返回加密的json字符串 +// mapJs = BamboocloudFacade.encrypt(mapJs, "123456", "AES"); +// return mapJs; +// } +// +// @ApiOperation("新增用户") +// @ApiImplicitParam(name = "user", value = "新增用户信息", dataType = "User") +// @PostMapping("/UserCreateService") +// @ResponseBody +// public String userCreateService(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { +// +// Map schema = new HashMap(); +// +// JSONObject jsonObject = new JSONObject(); +// +// StringBuilder sb = stringBuilder(req); +// //修改多值的属性格式方便转换 +// String bodyparam = sb.toString(); +// bodyparam = BamboocloudUtils.getPlaintext(bodyparam, "123456", "AES"); +// String p = bodyparam; +// String z = "[\""; +// String y = "\"]"; +// bodyparam.indexOf(z); +// bodyparam.indexOf(y); +// while (bodyparam.contains(z)) { +// p = bodyparam.substring(bodyparam.indexOf(z), bodyparam.indexOf(y) + 2).replace(z, "\"").replace(y, "\"").replace("\",\"", ","); +// bodyparam = bodyparam.substring(0, bodyparam.indexOf(z)) + p + bodyparam.substring(bodyparam.indexOf(y) + 2, bodyparam.length()); +// } +// logger.info("json--param-->" + bodyparam); +// Map reqmap = (Map) JSON.parse(bodyparam); +// String username = (String) reqmap.get("bimRemoteUser"); +// String password = (String) reqmap.get("bimRemotePwd"); +// +// if (BamboocloudUtils.checkUsernamePassword(username, password)) { +// //获取用户创建所需的参数 +// User user = createUpdateUser(reqmap); +// //用户创建 +// userService.insertBbcUser(user); +// //获取返回给IAM连接器的唯一标识,用于后续该条数据的更新修改删除 +// String uid = user.getUserId() + ""; +// if (uid != null) { +// schema.put("uid", uid); +// schema.put("bimRequestId", reqmap.get("bimRequestId")); +// schema.put("resultCode", "0"); +// schema.put("message", "success"); +// } else { +// schema.put("bimRequestId", reqmap.get("bimRequestId")); +// schema.put("resultCode", "500"); +// schema.put("message", "账号创建失败"); +// } +// String mapJson = JSON.toJSONString(schema); +// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); +// return mapJson; +// } +// schema.put("bimRequestId", reqmap.get("bimRequestId")); +// schema.put("resultCode", "500"); +// schema.put("message", "账号创建失败,请检查连接器配置的参数"); +// String mapJson = JSON.toJSONString(schema); +// //返回加密的json字符串 +// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); +// return mapJson; +// } +// +// /** +// *填充用户的属性值 +// * @param reqmap json +// * @return 用户 +// */ +// private User createUpdateUser(Map reqmap) { +// User user = new User(); +// if (reqmap.get("__NAME__") != null) { +// user.setLoginName((String) reqmap.get("__NAME__")); +// } +// if (reqmap.get("login_name") != null) { +// user.setLoginName((String) reqmap.get("login_name")); +// } +// if (reqmap.get("password") != null) { +// user.setPassword((String) reqmap.get("password")); +// } +// if (reqmap.get("dept_id") != null) { +// user.setDeptId(Long.valueOf(String.valueOf(reqmap.get("dept_id")))); +// } +// if (reqmap.get("user_name") != null) { +// user.setUserName((String) reqmap.get("user_name")); +// } +// if (reqmap.get("phonenumber") != null) { +// user.setPhonenumber((String) reqmap.get("phonenumber")); +// } +// if (reqmap.get("sex") != null) { +// String sex = (String) reqmap.get("sex"); +// if (sex.equals("1")) { +// sex = "0"; +// } +// if (sex.equals("2")) { +// sex = "1"; +// } +// if (sex.equals("3")) { +// sex = "2"; +// } +// user.setSex(sex); +// } +// if (reqmap.get("email") != null) { +// user.setEmail((String) reqmap.get("email")); +// } +// if (reqmap.get("status") != null) { +// if (Boolean.valueOf(String.valueOf(reqmap.get("status")))) +// user.setStatus("1"); +// else user.setStatus("0"); +// } +// if (reqmap.get("__ENABLE__") != null) { +// if (Boolean.valueOf(String.valueOf(reqmap.get("__ENABLE__")))) +// user.setStatus("0"); +// else user.setStatus("1"); +// } +// if (reqmap.get("user_role") != null) { +// String user_role = ((String) reqmap.get("user_role")).replaceAll(" ", ""); +// if (user_role.contains(",")) { +// String[] userRole = user_role.split(","); +// List roleIds = new ArrayList<>(); +// for (String up : userRole) { +// roleIds.add(Long.valueOf(String.valueOf(up))); +// } +// user.setRoleIds(roleIds.toArray(new Long[roleIds.size()])); +// } else { +// List roleIds = new ArrayList<>(); +// roleIds.add(Long.valueOf(String.valueOf(user_role))); +// user.setRoleIds(roleIds.toArray(new Long[roleIds.size()])); +// } +// } +// if (reqmap.get("user_post") != null) { +// String user_post = ((String) reqmap.get("user_post")).replaceAll(" ", ""); +// if (user_post.contains(",")) { +// String[] userPost = user_post.split(","); +// List postIds = new ArrayList<>(); +// for (String up : userPost) { +// postIds.add(Long.valueOf(String.valueOf(up))); +// } +// user.setPostIds(postIds.toArray(new Long[postIds.size()])); +// } else { +// List postIds = new ArrayList<>(); +// postIds.add(Long.valueOf(String.valueOf(user_post))); +// user.setPostIds(postIds.toArray(new Long[postIds.size()])); +// } +// } +// /* userService.selectUserByLoginName((String) reqmap.get("__NAME__")).getUserId();*/ +// return user; +// } +// +// @ApiOperation("修改用户") +// @ApiImplicitParam(name = "user", value = "修改用户信息", dataType = "User") +// @PostMapping("/UserUpdateService") +// @ResponseBody +// public String userUpdateService(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { +// +// Map schema = new HashMap(); +// +// JSONObject jsonObject = new JSONObject(); +// +// StringBuilder sb = stringBuilder(req); +// +// String bodyparam = sb.toString(); +// +// bodyparam = BamboocloudUtils.getPlaintext(bodyparam, "123456", "AES"); +// //修改多值的属性格式方便转换 +// String p = bodyparam; +// String bdp = bodyparam; +// String z = "[\""; +// String y = "\"]"; +// bodyparam.indexOf(z); +// bodyparam.indexOf(y); +// while (bodyparam.contains(z)) { +// p = bodyparam.substring(bodyparam.indexOf(z), bodyparam.indexOf(y) + 2).replace(z, "\"").replace(y, "\"").replace("\",\"", ","); +// bodyparam = bodyparam.substring(0, bodyparam.indexOf(z)) + p + bodyparam.substring(bodyparam.indexOf(y) + 2, bodyparam.length()); +// } +// logger.info("json--param-->" + bodyparam); +// Map reqmap = (Map) JSON.parse(bodyparam); +// String username = (String) reqmap.get("bimRemoteUser"); +// String password = (String) reqmap.get("bimRemotePwd"); +// if (BamboocloudUtils.checkUsernamePassword(username, password)) { +// User user = new User(); +// //获取用于更新的参数 +// user = createUpdateUser(reqmap); +// //获取用于更新的唯一标识 +// user.setUserId(Long.valueOf(String.valueOf(reqmap.get("bimUid")))); +// //更新用户 +// userService.updateBbcUser(user); +// schema.put("bimRequestId", reqmap.get("bimRequestId")); +// schema.put("resultCode", "0"); +// schema.put("message", "success"); +// String mapJson = JSON.toJSONString(schema); +// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); +// logger.info("response----->" + schema); +// return mapJson; +// } +// schema.put("bimRequestId", reqmap.get("bimRequestId")); +// schema.put("resultCode", "500"); +// schema.put("message", "账号更新失败,请检查连接器配置的参数"); +// String mapJson = JSON.toJSONString(schema); +// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); +// logger.info("response----->" + schema); +// return mapJson; +// } +// +// @ApiOperation("删除用户") +// @ApiImplicitParam(name = "user", value = "删除用户信息", dataType = "User") +// @PostMapping("/UserDeleteService") +// @ResponseBody +// public String userDeleteService(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { +// +// Map schema = new HashMap(); +// +// JSONObject jsonObject = new JSONObject(); +// +// StringBuilder sb = stringBuilder(req); +// +// String bodyparam = sb.toString(); +// +// bodyparam = BamboocloudUtils.getPlaintext(bodyparam, "123456", "AES"); +// +// logger.info("json--param-->" + bodyparam); +// Map reqmap = (Map) JSON.parse(bodyparam); +// //验证签名 +// if (BamboocloudUtils.verify(reqmap, "MD5").booleanValue()) { +// String username = (String) reqmap.get("bimRemoteUser"); +// String password = (String) reqmap.get("bimRemotePwd"); +// if (BamboocloudUtils.checkUsernamePassword(username, password)) { +// //调用删除方法 +// int n = userService.deleteUserById(Long.valueOf(String.valueOf(reqmap.get("bimUid")))); +// schema.put("bimRequestId", reqmap.get("bimRequestId")); +// schema.put("resultCode", "0"); +// schema.put("message", "success"); +// +// String mapJson = JSON.toJSONString(schema); +// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); +// logger.info("response----->" + schema); +// return mapJson; +// } +// } +// schema.put("bimRequestId", reqmap.get("bimRequestId")); +// schema.put("resultCode", "500"); +// schema.put("message", "账号删除失败"); +// String mapJson = JSON.toJSONString(schema); +// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); +// logger.info("response----->" + schema); +// return mapJson; +// } +// +// @ApiOperation("获取用户id") +// @ApiImplicitParam(name = "user", value = "获取用户id", dataType = "User") +// @PostMapping("/QueryAllUserIdsService") +// @ResponseBody +// public String Idlist(HttpServletRequest request, HttpServletResponse response) { +// JSONObject jsonObject = new JSONObject(); +// +// StringBuilder sb = stringBuilder(request); +// +// String bodyparam = sb.toString(); +// +// bodyparam = BamboocloudUtils.getPlaintext(bodyparam, "123456", "AES"); +// +// logger.info("json--param-->" + bodyparam); +// Map reqmap = (Map) JSON.parse(bodyparam); +// //验证签名 +// if (BamboocloudUtils.verify(reqmap, "MD5").booleanValue()) { +// String username = (String) reqmap.get("bimRemoteUser"); +// String password = (String) reqmap.get("bimRemotePwd"); +// if (BamboocloudUtils.checkUsernamePassword(username, password)) { +// try { +// //获取所有用户id +// List list = userService.selectUserIdList(); +// jsonObject.put("resultCode", "0"); +// jsonObject.put("message", "success"); +// jsonObject.put("userIdList", list); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } catch (Exception e) { +// jsonObject.put("resultCode", "505"); +// jsonObject.put("message", "获取id失败"); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } +// } +// } +// jsonObject.put("resultCode", "505"); +// jsonObject.put("message", "获取id失败"); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } +// +// @ApiOperation("通过用户id获取信息") +// @ApiImplicitParam(name = "user", value = "获取用户id", dataType = "User") +// @PostMapping("/QueryUserByIdService") +// @ResponseBody +// public String IdUserlist(HttpServletRequest request, HttpServletResponse response) { +// JSONObject jsonObject = new JSONObject(); +// +// StringBuilder sb = stringBuilder(request); +// +// String bodyparam = sb.toString(); +// +// bodyparam = BamboocloudUtils.getPlaintext(bodyparam, "123456", "AES"); +// +// logger.info("json--param-->" + bodyparam); +// Map reqmap = (Map) JSON.parse(bodyparam); +// //验证签名 +// if (BamboocloudUtils.verify(reqmap, "MD5").booleanValue()) { +// String username = (String) reqmap.get("bimRemoteUser"); +// String password = (String) reqmap.get("bimRemotePwd"); +// if (BamboocloudUtils.checkUsernamePassword(username, password)) { +// try { +// //获取用户信息 +// User userAll = userService.selectUserByIdq(Long.valueOf((String) reqmap.get("bimUid"))); +// //获取用户所担任的角色 +// List roles = roleService.selectRoleId(Long.valueOf((String) reqmap.get("bimUid"))); +// //获取用户所在的岗位 +// List posts = postService.selectPostId(Long.valueOf((String) reqmap.get("bimUid"))); +// //用于将对象的属性改为仅需要的对象 +// DeptGai deptGai = new DeptGai(); +// UserZhuan userZhuan = deptGai.zhuanHuan(userAll, roles, posts); +// jsonObject.put("resultCode", "0"); +// jsonObject.put("message", "success"); +// jsonObject.put("account", userZhuan); +// jsonObject.put("bimRequestId", request.getParameter("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } catch (Exception e) { +// jsonObject.put("resultCode", "505"); +// jsonObject.put("message", "获取id失败"); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } +// } +// } +// jsonObject.put("resultCode", "505"); +// jsonObject.put("message", "获取id失败"); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } +// +// @ApiOperation("创建机构信息") +// @ApiImplicitParam(name = "dept", value = "创建机构信息", dataType = "Dept") +// @PostMapping("/OrgCreateService") +// @ResponseBody +// public String OrgCreate(HttpServletRequest req, HttpServletResponse resp) { +// Map schema = new HashMap(); +// JSONObject jsonObject = new JSONObject(); +// StringBuilder sb = stringBuilder(req); +// String bodyparam = sb.toString(); +// //json字符串解密 +// bodyparam = BamboocloudUtils.getPlaintext(bodyparam, "123456", "AES"); +// +// logger.info("json--param-->" + bodyparam); +// Map reqmap = (Map) JSON.parse(bodyparam); +// //验证签名 +// if (BamboocloudUtils.verify(reqmap, "MD5").booleanValue()) { +// String username = (String) reqmap.get("bimRemoteUser"); +// String password = (String) reqmap.get("bimRemotePwd"); +// if (BamboocloudUtils.checkUsernamePassword(username, password)) { +// //机构的属性填值 +// Dept dept = createUpdateOrg(reqmap); +// deptService.insertBbcDept(dept); +// String uid = dept.getDeptId() + ""; +// if (uid != null) { +// schema.put("uid", uid); +// schema.put("bimRequestId", reqmap.get("bimRequestId")); +// schema.put("resultCode", "0"); +// schema.put("message", "success"); +// String mapJson = JSON.toJSONString(schema); +// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); +// logger.info("response----->" + schema); +// return mapJson; +// } +// } +// } +// schema.put("bimRequestId", reqmap.get("bimRequestId")); +// schema.put("resultCode", "500"); +// schema.put("message", "机构创建失败,报错信息自定义"); +// String mapJson = JSON.toJSONString(schema); +// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); +// logger.info("response----->" + schema); +// return mapJson; +// } +// +// private Dept createUpdateOrg(Map reqmap) { +// Dept dept = new Dept(); +// if (reqmap.get("dept_id") != null) { +// dept.setDeptId(Long.valueOf(String.valueOf(reqmap.get("dept_id")))); +// } +// if (reqmap.get("__UID__") != null) { +// dept.setDeptId(Long.valueOf(String.valueOf(reqmap.get("__UID__")))); +// } +// if (reqmap.get("parent_id") != null) { +// dept.setParentId(Long.valueOf(String.valueOf(reqmap.get("parent_id")))); +// } +// if (reqmap.get("status") != null) { +// if (Boolean.valueOf(String.valueOf(reqmap.get("status")))) +// dept.setStatus("1"); +// else dept.setStatus("0"); +// } +// if (reqmap.get("__ENABLE__") != null) { +// if (Boolean.valueOf(String.valueOf(reqmap.get("__ENABLE__")))) +// dept.setStatus("0"); +// else dept.setStatus("1"); +// } +// +// if (reqmap.get("dept_name") != null) { +// dept.setDeptName((String) reqmap.get("dept_name")); +// } +// if (reqmap.get("__NAME__") != null) { +// dept.setDeptName((String) reqmap.get("__NAME__")); +// } +// return dept; +// } +// +// @ApiOperation("修改机构信息") +// @ApiImplicitParam(name = "dept", value = "修改机构信息", dataType = "Dept") +// @PostMapping("/OrgUpdateService") +// @ResponseBody +// public String orgUpdateService(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { +// Map schema = new HashMap(); +// JSONObject jsonObject = new JSONObject(); +// StringBuilder sb = stringBuilder(req); +// String bodyparam = sb.toString(); +// +// bodyparam = BamboocloudUtils.getPlaintext(bodyparam, "123456", "AES"); +// +// logger.info("json--param-->" + bodyparam); +// Map reqmap = (Map) JSON.parse(bodyparam); +// //验证签名 +// if (BamboocloudUtils.verify(reqmap, "MD5").booleanValue()) { +// String username = (String) reqmap.get("bimRemoteUser"); +// String password = (String) reqmap.get("bimRemotePwd"); +// if (BamboocloudUtils.checkUsernamePassword(username, password)) { +// Dept dept = new Dept(); +// dept = createUpdateOrg(reqmap); +// dept.setDeptId(Long.valueOf(String.valueOf(reqmap.get("bimOrgId")))); +// deptService.updateBbcDept(dept); +// schema.put("bimRequestId", reqmap.get("bimRequestId")); +// schema.put("resultCode", "0"); +// schema.put("message", "success"); +// String mapJson = JSON.toJSONString(schema); +// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); +// logger.info("response----->" + schema); +// return mapJson; +// } +// } +// schema.put("bimRequestId", reqmap.get("bimRequestId")); +// schema.put("resultCode", "500"); +// schema.put("message", "机构更新失败,报错信息自定义"); +// String mapJson = JSON.toJSONString(schema); +// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); +// logger.info("response----->" + schema); +// return mapJson; +// } +// +// @ApiOperation("删除机构信息") +// @ApiImplicitParam(name = "dept", value = "删除机构信息", dataType = "Dept") +// @PostMapping("/OrgDeleteService") +// @ResponseBody +// public String orgDeleteService(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { +// Map schema = new HashMap(); +// JSONObject jsonObject = new JSONObject(); +// StringBuilder sb = stringBuilder(req); +// String bodyparam = sb.toString(); +// +// bodyparam = BamboocloudUtils.getPlaintext(bodyparam, "123456", "AES"); +// +// logger.info("json--param-->" + bodyparam); +// Map reqmap = (Map) JSON.parse(bodyparam); +// //验证签名 +// if (BamboocloudUtils.verify(reqmap, "MD5").booleanValue()) { +// String username = (String) reqmap.get("bimRemoteUser"); +// String password = (String) reqmap.get("bimRemotePwd"); +// if (BamboocloudUtils.checkUsernamePassword(username, password)) { +// int n = deptService.deleteDeptById(Long.valueOf(String.valueOf(reqmap.get("bimOrgId")))); +// schema.put("bimRequestId", reqmap.get("bimRequestId")); +// schema.put("resultCode", "0"); +// schema.put("message", "success"); +// String mapJson = JSON.toJSONString(schema); +// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); +// logger.info("response----->" + schema); +// return mapJson; +// } +// } +// schema.put("bimRequestId", reqmap.get("bimRequestId")); +// schema.put("resultCode", "500"); +// schema.put("message", "机构删除失败,报错信息自定义"); +// String mapJson = JSON.toJSONString(schema); +// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); +// logger.info("response----->" + schema); +// return mapJson; +// +// } +// +// @ApiOperation("获取机构id") +// @ApiImplicitParam(name = "BodyParam", value = "获取机构id", dataType = "BodyParam") +// @PostMapping("/QueryAllOrgIdsService") +// @ResponseBody +// public String QueryAllOrgIds(HttpServletRequest request, HttpServletResponse response) { +// JSONObject jsonObject = new JSONObject(); +// StringBuilder sb = stringBuilder(request); +// String bodyparam = sb.toString(); +// bodyparam = BamboocloudUtils.getPlaintext(bodyparam, "123456", "AES"); +// +// logger.info("json--param-->" + bodyparam); +// Map reqmap = (Map) JSON.parse(bodyparam); +// //验证签名 +// if (BamboocloudUtils.verify(reqmap, "MD5").booleanValue()) { +// String username = (String) reqmap.get("bimRemoteUser"); +// String password = (String) reqmap.get("bimRemotePwd"); +// if (BamboocloudUtils.checkUsernamePassword(username, password)) { +// try { +// +// List list = deptService.selectDeptIdList(new Dept()); +// jsonObject.put("resultCode", "0"); +// jsonObject.put("message", "success"); +// jsonObject.put("orgIdList", list); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } catch (Exception e) { +// jsonObject.put("resultCode", "505"); +// jsonObject.put("message", "获取id失败"); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } +// } +// } +// jsonObject.put("resultCode", "505"); +// jsonObject.put("message", "获取id失败"); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } +// +// @ApiOperation("通过机构id获取信息") +// @ApiImplicitParam(name = "dept", value = "获取用户id", dataType = "Dept") +// @PostMapping("/QueryOrgByIdService") +// @ResponseBody +// public String IdDeptlist(HttpServletRequest request, HttpServletResponse response) { +// JSONObject jsonObject = new JSONObject(); +// StringBuilder sb = stringBuilder(request); +// String bodyparam = sb.toString(); +// bodyparam = BamboocloudUtils.getPlaintext(bodyparam, "123456", "AES"); +// +// logger.info("json--param-->" + bodyparam); +// Map reqmap = (Map) JSON.parse(bodyparam); +// //验证签名 +// if (BamboocloudUtils.verify(reqmap, "MD5").booleanValue()) { +// String username = (String) reqmap.get("bimRemoteUser"); +// String password = (String) reqmap.get("bimRemotePwd"); +// if (BamboocloudUtils.checkUsernamePassword(username, password)) { +// try { +// Dept deptAll = deptService.selectDeptById(Long.valueOf((String) reqmap.get("bimOrgId"))); +// DeptGai deptGai = new DeptGai(); +// DeptZhuan deptZhuan = deptGai.zhuanHuan(deptAll); +// jsonObject.put("resultCode", "0"); +// jsonObject.put("message", "success"); +// jsonObject.put("organization", deptZhuan); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } catch (Exception e) { +// jsonObject.put("resultCode", "505"); +// jsonObject.put("message", "获取机构信息失败"); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } +// } +// } +// jsonObject.put("resultCode", "505"); +// jsonObject.put("message", "回收机构失败"); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } +// +// @ApiOperation("创建角色信息") +// @ApiImplicitParam(name = "role", value = "创建角色信息", dataType = "Role") +// @PostMapping("/RoleCreateService") +// @ResponseBody +// public String RoleCreateService(HttpServletRequest req, HttpServletResponse resp) { +// Map schema = new HashMap(); +// JSONObject jsonObject = new JSONObject(); +// StringBuilder sb = stringBuilder(req); +// String bodyparam = sb.toString(); +// +// bodyparam = BamboocloudUtils.getPlaintext(bodyparam, "123456", "AES"); +// +// logger.info("json--param-->" + bodyparam); +// Map reqmap = (Map) JSON.parse(bodyparam); +// //验证签名 +// if (BamboocloudUtils.verify(reqmap, "MD5").booleanValue()) { +// String username = (String) reqmap.get("bimRemoteUser"); +// String password = (String) reqmap.get("bimRemotePwd"); +// if (BamboocloudUtils.checkUsernamePassword(username, password)) { +// Role role = createUpdateRole(reqmap); +// if (reqmap.get("roleSort") != null) { +// role.setRoleSort((String) reqmap.get("roleSort")); +// } +// if (reqmap.get("roleSort") == null || "".equals((String) reqmap.get("roleSort"))) { +// role.setRoleSort("1"); +// } +// if (reqmap.get("status") == null && reqmap.get("__ENABLE__") == null) { +// role.setStatus("0"); +// } +// roleService.insertBbcRole(role); +// String uid = role.getRoleId().toString(); +// if (uid != null) { +// schema.put("uid", uid); +// schema.put("bimRequestId", reqmap.get("bimRequestId")); +// schema.put("resultCode", "0"); +// schema.put("message", "success"); +// String mapJson = JSON.toJSONString(schema); +// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); +// logger.info("response----->" + schema); +// return mapJson; +// } +// } +// } +// schema.put("bimRequestId", reqmap.get("bimRequestId")); +// schema.put("resultCode", "500"); +// schema.put("message", "角色创建失败,报错信息自定义"); +// String mapJson = JSON.toJSONString(schema); +// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); +// logger.info("response----->" + schema); +// return mapJson; +// } +// +// private Role createUpdateRole(Map reqmap) { +// Role role = new Role(); +// if (reqmap.get("bimRid") != null) { +// role.setRoleId(Long.valueOf(String.valueOf(reqmap.get("bimRid")))); +// } +// if (reqmap.get("roleId") != null) { +// role.setRoleId(Long.valueOf(String.valueOf(reqmap.get("roleId")))); +// } +// if (reqmap.get("__UID__") != null) { +// role.setRoleId(Long.valueOf(String.valueOf(reqmap.get("roleId")))); +// } +// if (reqmap.get("__NAME__") != null) { +// role.setRoleName((String) reqmap.get("__NAME__")); +// } +// if (reqmap.get("roleName") != null) { +// role.setRoleName((String) reqmap.get("roleName")); +// } +// if (reqmap.get("dataScope") != null) { +// role.setDataScope((String) reqmap.get("dataScope")); +// } +// if (reqmap.get("roleKey") != null) { +// role.setRoleKey((String) reqmap.get("roleKey")); +// } +// if (reqmap.get("status") != null) { +// if (Boolean.valueOf(String.valueOf(reqmap.get("status")))) +// role.setStatus("1"); +// else role.setStatus("0"); +// } +// if (reqmap.get("__ENABLE__") != null) { +// if (Boolean.valueOf(String.valueOf(reqmap.get("__ENABLE__")))) +// role.setStatus("0"); +// else role.setStatus("1"); +// } +// return role; +// } +// +// @ApiOperation("修改角色信息") +// @ApiImplicitParam(name = "role", value = "修改角色信息", dataType = "Role") +// @PostMapping("/RoleUpdateService") +// @ResponseBody +// public String RoleUpdateService(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { +// Map schema = new HashMap(); +// JSONObject jsonObject = new JSONObject(); +// StringBuilder sb = stringBuilder(req); +// String bodyparam = sb.toString(); +// +// bodyparam = BamboocloudUtils.getPlaintext(bodyparam, "123456", "AES"); +// +// logger.info("json--param-->" + bodyparam); +// Map reqmap = (Map) JSON.parse(bodyparam); +// //验证签名 +// if (BamboocloudUtils.verify(reqmap, "MD5").booleanValue()) { +// String username = (String) reqmap.get("bimRemoteUser"); +// String password = (String) reqmap.get("bimRemotePwd"); +// if (BamboocloudUtils.checkUsernamePassword(username, password)) { +// Role role = createUpdateRole(reqmap); +// roleService.updateBbcRole(role); +// schema.put("bimRequestId", reqmap.get("bimRequestId")); +// schema.put("resultCode", "0"); +// schema.put("message", "success"); +// String mapJson = JSON.toJSONString(schema); +// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); +// logger.info("response----->" + schema); +// return mapJson; +// } +// } +// schema.put("bimRequestId", reqmap.get("bimRequestId")); +// schema.put("resultCode", "500"); +// schema.put("message", "角色更新失败,报错信息自定义"); +// String mapJson = JSON.toJSONString(schema); +// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); +// logger.info("response----->" + schema); +// return mapJson; +// } +// +// +// @ApiOperation("删除角色信息") +// @ApiImplicitParam(name = "role", value = "删除角色信息", dataType = "Role") +// @PostMapping("/RoleDeleteService") +// @ResponseBody +// public String RoleDeleteService(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { +// Map schema = new HashMap(); +// JSONObject jsonObject = new JSONObject(); +// StringBuilder sb = stringBuilder(req); +// String bodyparam = sb.toString(); +// +// bodyparam = BamboocloudUtils.getPlaintext(bodyparam, "123456", "AES"); +// +// logger.info("json--param-->" + bodyparam); +// Map reqmap = (Map) JSON.parse(bodyparam); +// //验证签名 +// if (BamboocloudUtils.verify(reqmap, "MD5").booleanValue()) { +// String username = (String) reqmap.get("bimRemoteUser"); +// String password = (String) reqmap.get("bimRemotePwd"); +// if (BamboocloudUtils.checkUsernamePassword(username, password)) { +// boolean n = roleService.deleteRoleById(Long.valueOf(String.valueOf(reqmap.get("bimRid")))); +// schema.put("bimRequestId", reqmap.get("bimRequestId")); +// schema.put("resultCode", "0"); +// schema.put("message", "success"); +// String mapJson = JSON.toJSONString(schema); +// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); +// logger.info("response----->" + schema); +// return mapJson; +// } +// } +// schema.put("bimRequestId", reqmap.get("bimRequestId")); +// schema.put("resultCode", "500"); +// schema.put("message", "机构删除失败,报错信息自定义"); +// String mapJson = JSON.toJSONString(schema); +// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); +// logger.info("response----->" + schema); +// return mapJson; +// } +// +// @ApiOperation("获取角色id") +// @ApiImplicitParam(name = "BodyParam", value = "获取角色id", dataType = "BodyParam") +// @PostMapping("/QueryAllRoleIdsService") +// @ResponseBody +// public String QueryAllRoleIdsService(HttpServletRequest request, HttpServletResponse response) { +// JSONObject jsonObject = new JSONObject(); +// StringBuilder sb = stringBuilder(request); +// String bodyparam = sb.toString(); +// bodyparam = BamboocloudUtils.getPlaintext(bodyparam, "123456", "AES"); +// +// logger.info("json--param-->" + bodyparam); +// Map reqmap = (Map) JSON.parse(bodyparam); +// //验证签名 +// if (BamboocloudUtils.verify(reqmap, "MD5").booleanValue()) { +// String username = (String) reqmap.get("bimRemoteUser"); +// String password = (String) reqmap.get("bimRemotePwd"); +// if (BamboocloudUtils.checkUsernamePassword(username, password)) { +// try { +// +// List list = roleService.selectRoleIdList(new Role()); +// jsonObject.put("resultCode", "0"); +// jsonObject.put("message", "success"); +// jsonObject.put("roleIdList", list); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } catch (Exception e) { +// jsonObject.put("resultCode", "505"); +// jsonObject.put("message", "获取id失败"); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } +// } +// } +// jsonObject.put("resultCode", "505"); +// jsonObject.put("message", "获取id失败"); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } +// +// @ApiOperation("通过角色id获取信息") +// @ApiImplicitParam(name = "role", value = "获取角色id", dataType = "Role") +// @PostMapping("/QueryRoleByIdService") +// @ResponseBody +// public String QueryRoleByIdService(HttpServletRequest request, HttpServletResponse response) { +// JSONObject jsonObject = new JSONObject(); +// StringBuilder sb = stringBuilder(request); +// String bodyparam = sb.toString(); +// bodyparam = BamboocloudUtils.getPlaintext(bodyparam, "123456", "AES"); +// +// logger.info("json--param-->" + bodyparam); +// Map reqmap = (Map) JSON.parse(bodyparam); +// //验证签名 +// if (BamboocloudUtils.verify(reqmap, "MD5").booleanValue()) { +// String username = (String) reqmap.get("bimRemoteUser"); +// String password = (String) reqmap.get("bimRemotePwd"); +// if (BamboocloudUtils.checkUsernamePassword(username, password)) { +// try { +// Role roleAll = roleService.selectRoleById(Long.valueOf((String) reqmap.get("bimRid"))); +// jsonObject.put("resultCode", "0"); +// jsonObject.put("message", "success"); +// jsonObject.put("role", roleAll); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } catch (Exception e) { +// jsonObject.put("resultCode", "505"); +// jsonObject.put("message", "获取角色信息失败"); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } +// } +// } +// jsonObject.put("resultCode", "505"); +// jsonObject.put("message", "回收角色失败"); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } +// +// @ApiOperation("获取资源id") +// @ApiImplicitParam(name = "BodyParam", value = "获取资源id", dataType = "获取资源id") +// @PostMapping("/QueryAllResourceIdsService") +// @ResponseBody +// public String QueryAllResourceIdsService(HttpServletRequest request, HttpServletResponse response) { +// JSONObject jsonObject = new JSONObject(); +// StringBuilder sb = stringBuilder(request); +// String bodyparam = sb.toString(); +// bodyparam = BamboocloudUtils.getPlaintext(bodyparam, "123456", "AES"); +// +// logger.info("json--param-->" + bodyparam); +// Map reqmap = (Map) JSON.parse(bodyparam); +// //验证签名 +// if (BamboocloudUtils.verify(reqmap, "MD5").booleanValue()) { +// String username = (String) reqmap.get("bimRemoteUser"); +// String password = (String) reqmap.get("bimRemotePwd"); +// String resourceType = (String) reqmap.get("resourceType"); +// if (BamboocloudUtils.checkUsernamePassword(username, password)) { +// try { +// if ("post".equals(resourceType)) { +// List list = postService.selectPostIdList(new Post()); +// jsonObject.put("resultCode", "0"); +// jsonObject.put("message", "success"); +// jsonObject.put("resourceIdList", list); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } +// if ("dict".equals(resourceType)) { +// DictData dictData = new DictData(); +// dictData.setDictType("sys_user_sex"); +// List list = dictDataService.selectDictDataIdList(dictData); +// jsonObject.put("resultCode", "0"); +// jsonObject.put("message", "success"); +// jsonObject.put("resourceIdList", list); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } +// } catch (Exception e) { +// jsonObject.put("resultCode", "505"); +// jsonObject.put("message", "获取id失败"); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } +// } +// } +// jsonObject.put("resultCode", "505"); +// jsonObject.put("message", "获取id失败"); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } +// +// @ApiOperation("通过资源id获取信息") +// @ApiImplicitParam(name = "resource", value = "获取资源id", dataType = "Resource") +// @PostMapping("/QueryResourceByIdService") +// @ResponseBody +// public String QueryResourceByIdService(HttpServletRequest request, HttpServletResponse response) { +// JSONObject jsonObject = new JSONObject(); +// StringBuilder sb = stringBuilder(request); +// String bodyparam = sb.toString(); +// bodyparam = BamboocloudUtils.getPlaintext(bodyparam, "123456", "AES"); +// +// logger.info("json--param-->" + bodyparam); +// Map reqmap = (Map) JSON.parse(bodyparam); +// //验证签名 +// if (BamboocloudUtils.verify(reqmap, "MD5").booleanValue()) { +// String username = (String) reqmap.get("bimRemoteUser"); +// String password = (String) reqmap.get("bimRemotePwd"); +// String resourceType = (String) reqmap.get("resourceType"); +// if (BamboocloudUtils.checkUsernamePassword(username, password)) { +// try { +// if ("post".equals(resourceType)) { +// Post postAll = postService.selectPostById(Long.valueOf((String) reqmap.get("resourceId"))); +// jsonObject.put("resultCode", "0"); +// jsonObject.put("message", "success"); +// jsonObject.put("resource", postAll); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } +// if ("dict".equals(resourceType)) { +// DictData dictDataAll = dictDataService.selectDictDataById(Long.valueOf((String) reqmap.get("resourceId"))); +// jsonObject.put("resultCode", "0"); +// jsonObject.put("message", "success"); +// jsonObject.put("resource", dictDataAll); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } +// } catch (Exception e) { +// jsonObject.put("resultCode", "505"); +// jsonObject.put("message", "获取资源信息失败"); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } +// } +// } +// jsonObject.put("resultCode", "505"); +// jsonObject.put("message", "回收资源失败"); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } +// +// +// public StringBuilder stringBuilder(HttpServletRequest req) { +// BufferedReader br = null; +// StringBuilder sb = new StringBuilder(); +// String str = ""; +// try { +// br = req.getReader(); +// while ((str = br.readLine()) != null) { +// sb.append(str); +// } +// br.close(); +// } catch (IOException e) { +// e.printStackTrace(); +// if (br != null) +// try { +// br.close(); +// } catch (IOException eo) { +// eo.printStackTrace(); +// } +// } finally { +// if (br != null) { +// try { +// br.close(); +// } catch (IOException e) { +// e.printStackTrace(); +// } +// } +// } +// return sb; +// } +//} diff --git a/laws-modules/src/main/java/com/jero/modules/iam/BbcControllerUnencrypted.java b/laws-modules/src/main/java/com/jero/modules/iam/BbcControllerUnencrypted.java new file mode 100644 index 00000000..11d3a50a --- /dev/null +++ b/laws-modules/src/main/java/com/jero/modules/iam/BbcControllerUnencrypted.java @@ -0,0 +1,1013 @@ +//package com.jero.modules.iam; +// +//import com.alibaba.fastjson.JSON; +//import com.alibaba.fastjson.JSONObject; +//import com.banboocloud.Codec.BamboocloudFacade; +//import com.ruoyi.common.utils.reflect.ReflectUtils; +//import com.ruoyi.framework.web.controller.BaseController; +//import com.ruoyi.project.system.dept.domain.Dept; +//import com.ruoyi.project.system.dept.service.IDeptService; +//import com.ruoyi.project.system.dict.domain.DictData; +//import com.ruoyi.project.system.dict.service.IDictDataService; +//import com.ruoyi.project.system.post.domain.Post; +//import com.ruoyi.project.system.post.service.IPostService; +//import com.ruoyi.project.system.role.domain.Role; +//import com.ruoyi.project.system.role.service.IRoleService; +//import com.ruoyi.project.system.user.domain.User; +//import com.ruoyi.project.system.user.service.IUserService; +//import com.ruoyi.project.tool.swagger.accessory.*; +//import io.swagger.annotations.Api; +//import io.swagger.annotations.ApiImplicitParam; +//import io.swagger.annotations.ApiImplicitParams; +//import io.swagger.annotations.ApiOperation; +//import org.slf4j.Logger; +//import org.slf4j.LoggerFactory; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.web.bind.annotation.*; +// +//import javax.servlet.ServletException; +//import javax.servlet.http.HttpServletRequest; +//import javax.servlet.http.HttpServletResponse; +//import java.io.BufferedReader; +//import java.io.IOException; +//import java.util.ArrayList; +//import java.util.HashMap; +//import java.util.List; +//import java.util.Map; +// +///** +// * swagger 用户测试方法 +// * 未加密 +// * @author ruoyi +// */ +//@Api("bbc用户信息") +//@RestController +//@RequestMapping("/bbc/userUnencrypted") +//public class BbcControllerUnencrypted extends BaseController { +// @Autowired +// private IUserService userService; +// +// @Autowired +// private IRoleService roleService; +// +// @Autowired +// private IPostService postService; +// +// @Autowired +// private IDeptService deptService; +// +// @Autowired +// private IDictDataService dictDataService; +// +// @Autowired +// private SysPasswordService passwordService; +// +// private String bimRequestId; +// +// private static Logger logger = LoggerFactory.getLogger(ReflectUtils.class); +// +// @ApiOperation("测试") +// @RequestMapping() +// public JSONObject bbcUser() { +// +// JSONObject jsonObject = new JSONObject(); +// jsonObject.put("resultCode", "0"); +// jsonObject.put("message", "success"); +// return jsonObject; +// +// } +// +// @ApiOperation("对象属性字段查询") +// @ApiImplicitParam(name = "json", value = "调用账号密码id", dataType = "String") +// @PostMapping("/SchemaService") +// public String SchemaService(@RequestBody String json) { +// +// JSONObject jsonObject = new JSONObject(); +// String bodyparam= json; +// logger.info("json--param-->" + bodyparam); +// +// logger.info("json--param-->" + bodyparam); +// Map reqmap = (Map) JSON.parse(bodyparam); +// +// String username = (String) reqmap.get("bimRemoteUser"); +// String password = (String) reqmap.get("bimRemotePwd"); +// //判断接口中的调用名及调用密码是否正确 +// if (BamboocloudUtils.checkUsernamePassword(username, password)) { +// //添加返回的对象及属性字段名 +// MapJson mapJson = new MapJson(); +// Map>> map = new HashMap<>(); +// jsonObject.put("account", mapJson.accountList()); +// jsonObject.put("organization", mapJson.organizationList()); +// jsonObject.put("role", mapJson.roleList()); +// jsonObject.put("post", mapJson.postList()); +// jsonObject.put("dict", mapJson.dictDataList()); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJs = JSON.toJSONString(jsonObject); +// logger.info(jsonObject.toJSONString()); +// return mapJs; +// } +// jsonObject.put("bimRequestId", bimRequestId); +// jsonObject.put("resultCode", "505"); +// jsonObject.put("message", "连接失败,请检查连接器配置的参数"); +// logger.info(jsonObject.toJSONString()); +// String mapJs = JSON.toJSONString(jsonObject); +// return mapJs; +// } +// +// @ApiOperation("新增用户") +// @ApiImplicitParam(name = "json", value = "新增用户信息", dataType = "String") +// @PostMapping("/UserCreateService") +// @ResponseBody +// public String userCreateService(@RequestBody String json) throws ServletException, IOException { +// +// Map schema = new HashMap(); +// +// JSONObject jsonObject = new JSONObject(); +// +// //修改多值的属性格式方便转换 +// String bodyparam = json; +// +// String p = bodyparam; +// String z = "[\""; +// String y = "\"]"; +// bodyparam.indexOf(z); +// bodyparam.indexOf(y); +// while (bodyparam.contains(z)) { +// p = bodyparam.substring(bodyparam.indexOf(z), bodyparam.indexOf(y) + 2).replace(z, "\"").replace(y, "\"").replace("\",\"", ","); +// bodyparam = bodyparam.substring(0, bodyparam.indexOf(z)) + p + bodyparam.substring(bodyparam.indexOf(y) + 2, bodyparam.length()); +// } +// logger.info("json--param-->" + bodyparam); +// Map reqmap = (Map) JSON.parse(bodyparam); +// String username = (String) reqmap.get("bimRemoteUser"); +// String password = (String) reqmap.get("bimRemotePwd"); +// +// if (BamboocloudUtils.checkUsernamePassword(username, password)) { +// //获取用户创建所需的参数 +// User user = createUpdateUser(reqmap); +// //用户创建 +// userService.insertBbcUser(user); +// //获取返回给IAM连接器的唯一标识,用于后续该条数据的更新修改删除 +// String uid = user.getUserId() + ""; +// if (uid != null) { +// schema.put("uid", uid); +// schema.put("bimRequestId", reqmap.get("bimRequestId")); +// schema.put("resultCode", "0"); +// schema.put("message", "success"); +// } else { +// schema.put("bimRequestId", reqmap.get("bimRequestId")); +// schema.put("resultCode", "500"); +// schema.put("message", "账号创建失败"); +// } +// String mapJson = JSON.toJSONString(schema); +// return mapJson; +// } +// schema.put("bimRequestId", reqmap.get("bimRequestId")); +// schema.put("resultCode", "500"); +// schema.put("message", "账号创建失败,请检查连接器配置的参数"); +// String mapJson = JSON.toJSONString(schema); +// return mapJson; +// } +// +// /** +// *填充用户的属性值 +// * @param reqmap json +// * @return 用户 +// */ +// private User createUpdateUser(Map reqmap) { +// User user = new User(); +// if (reqmap.get("__NAME__") != null) { +// user.setLoginName((String) reqmap.get("__NAME__")); +// } +// if (reqmap.get("login_name") != null) { +// user.setLoginName((String) reqmap.get("login_name")); +// } +// if (reqmap.get("password") != null) { +// user.setPassword((String) reqmap.get("password")); +// } +// if (reqmap.get("dept_id") != null) { +// user.setDeptId(Long.valueOf(String.valueOf(reqmap.get("dept_id")))); +// } +// if (reqmap.get("user_name") != null) { +// user.setUserName((String) reqmap.get("user_name")); +// } +// if (reqmap.get("phonenumber") != null) { +// user.setPhonenumber((String) reqmap.get("phonenumber")); +// } +// if (reqmap.get("sex") != null) { +// String sex = (String) reqmap.get("sex"); +// if (sex.equals("1")) { +// sex = "0"; +// } +// if (sex.equals("2")) { +// sex = "1"; +// } +// if (sex.equals("3")) { +// sex = "2"; +// } +// user.setSex(sex); +// } +// if (reqmap.get("email") != null) { +// user.setEmail((String) reqmap.get("email")); +// } +// if (reqmap.get("status") != null) { +// if (Boolean.valueOf(String.valueOf(reqmap.get("status")))) +// user.setStatus("1"); +// else user.setStatus("0"); +// } +// if (reqmap.get("__ENABLE__") != null) { +// if (Boolean.valueOf(String.valueOf(reqmap.get("__ENABLE__")))) +// user.setStatus("0"); +// else user.setStatus("1"); +// } +// //角色为多值情况下的处理 +// if (reqmap.get("user_role") != null) { +// String user_role = ((String) reqmap.get("user_role")).replaceAll(" ", ""); +// if (user_role.contains(",")) { +// String[] userRole = user_role.split(","); +// List roleIds = new ArrayList<>(); +// for (String up : userRole) { +// roleIds.add(Long.valueOf(String.valueOf(up))); +// } +// user.setRoleIds(roleIds.toArray(new Long[roleIds.size()])); +// } else { +// List roleIds = new ArrayList<>(); +// roleIds.add(Long.valueOf(String.valueOf(user_role))); +// user.setRoleIds(roleIds.toArray(new Long[roleIds.size()])); +// } +// } +// if (reqmap.get("user_post") != null) { +// String user_post = ((String) reqmap.get("user_post")).replaceAll(" ", ""); +// if (user_post.contains(",")) { +// String[] userPost = user_post.split(","); +// List postIds = new ArrayList<>(); +// for (String up : userPost) { +// postIds.add(Long.valueOf(String.valueOf(up))); +// } +// user.setPostIds(postIds.toArray(new Long[postIds.size()])); +// } else { +// List postIds = new ArrayList<>(); +// postIds.add(Long.valueOf(String.valueOf(user_post))); +// user.setPostIds(postIds.toArray(new Long[postIds.size()])); +// } +// } +// /* userService.selectUserByLoginName((String) reqmap.get("__NAME__")).getUserId();*/ +// return user; +// } +// +// @ApiOperation("修改用户") +// @ApiImplicitParam(name = "json", value = "修改用户信息", dataType = "String") +// @PostMapping("/UserUpdateService") +// @ResponseBody +// public String userUpdateService(@RequestBody String json) throws ServletException, IOException { +// +// Map schema = new HashMap(); +// +// JSONObject jsonObject = new JSONObject(); +// +// String bodyparam =json; +// +// //修改多值的属性格式方便转换 +// String p = bodyparam; +// String bdp = bodyparam; +// String z = "[\""; +// String y = "\"]"; +// bodyparam.indexOf(z); +// bodyparam.indexOf(y); +// while (bodyparam.contains(z)) { +// p = bodyparam.substring(bodyparam.indexOf(z), bodyparam.indexOf(y) + 2).replace(z, "\"").replace(y, "\"").replace("\",\"", ","); +// bodyparam = bodyparam.substring(0, bodyparam.indexOf(z)) + p + bodyparam.substring(bodyparam.indexOf(y) + 2, bodyparam.length()); +// } +// logger.info("json--param-->" + bodyparam); +// Map reqmap = (Map) JSON.parse(bodyparam); +// String username = (String) reqmap.get("bimRemoteUser"); +// String password = (String) reqmap.get("bimRemotePwd"); +// if (BamboocloudUtils.checkUsernamePassword(username, password)) { +// User user = new User(); +// //获取用于更新的参数 +// user = createUpdateUser(reqmap); +// //获取用于更新的唯一标识 +// user.setUserId(Long.valueOf(String.valueOf(reqmap.get("bimUid")))); +// //更新用户 +// userService.updateBbcUser(user); +// schema.put("bimRequestId", reqmap.get("bimRequestId")); +// schema.put("resultCode", "0"); +// schema.put("message", "success"); +// String mapJson = JSON.toJSONString(schema); +// logger.info("response----->" + schema); +// return mapJson; +// } +// schema.put("bimRequestId", reqmap.get("bimRequestId")); +// schema.put("resultCode", "500"); +// schema.put("message", "账号更新失败,请检查连接器配置的参数"); +// String mapJson = JSON.toJSONString(schema); +// logger.info("response----->" + schema); +// return mapJson; +// } +// +// @ApiOperation("删除用户") +// @ApiImplicitParam(name = "json", value = "删除用户信息", dataType = "String") +// @PostMapping("/UserDeleteService") +// @ResponseBody +// public String userDeleteService(@RequestBody String json) throws ServletException, IOException { +// +// Map schema = new HashMap(); +// +// JSONObject jsonObject = new JSONObject(); +// +// String bodyparam = json; +// +// logger.info("json--param-->" + bodyparam); +// Map reqmap = (Map) JSON.parse(bodyparam); +// //验证签名 +// String username = (String) reqmap.get("bimRemoteUser"); +// String password = (String) reqmap.get("bimRemotePwd"); +// if (BamboocloudUtils.checkUsernamePassword(username, password)) { +// //调用删除方法 +// int n = userService.deleteUserById(Long.valueOf(String.valueOf(reqmap.get("bimUid")))); +// schema.put("bimRequestId", reqmap.get("bimRequestId")); +// schema.put("resultCode", "0"); +// schema.put("message", "success"); +// +// String mapJson = JSON.toJSONString(schema); +// logger.info("response----->" + schema); +// return mapJson; +// } +// schema.put("bimRequestId", reqmap.get("bimRequestId")); +// schema.put("resultCode", "500"); +// schema.put("message", "账号删除失败"); +// String mapJson = JSON.toJSONString(schema); +// logger.info("response----->" + schema); +// return mapJson; +// } +// +// @ApiOperation("获取用户id") +// @ApiImplicitParam(name = "json", value = "获取用户id", dataType = "String") +// @PostMapping("/QueryAllUserIdsService") +// @ResponseBody +// public String Idlist(@RequestBody String json) { +// JSONObject jsonObject = new JSONObject(); +// +// String bodyparam = json; +// +// logger.info("json--param-->" + bodyparam); +// Map reqmap = (Map) JSON.parse(bodyparam); +// //验证签名 +// String username = (String) reqmap.get("bimRemoteUser"); +// String password = (String) reqmap.get("bimRemotePwd"); +// if (BamboocloudUtils.checkUsernamePassword(username, password)) { +// try { +// //获取所有用户id +// List list = userService.selectUserIdList(); +// jsonObject.put("resultCode", "0"); +// jsonObject.put("message", "success"); +// jsonObject.put("userIdList", list); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } catch (Exception e) { +// jsonObject.put("resultCode", "505"); +// jsonObject.put("message", "获取id失败"); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } +// } +// jsonObject.put("resultCode", "505"); +// jsonObject.put("message", "获取id失败"); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } +// +// @ApiOperation("通过用户id获取信息") +// @ApiImplicitParam(name = "json", value = "用户ID相关信息", dataType = "String") +// @PostMapping("/QueryUserByIdService") +// @ResponseBody +// public String IdUserlist(@RequestBody String json) { +// JSONObject jsonObject = new JSONObject(); +// +// String bodyparam = json; +// +// logger.info("json--param-->" + bodyparam); +// Map reqmap = (Map) JSON.parse(bodyparam); +// +// String username = (String) reqmap.get("bimRemoteUser"); +// String password = (String) reqmap.get("bimRemotePwd"); +// if (BamboocloudUtils.checkUsernamePassword(username, password)) { +// try { +// //获取用户信息 +// User userAll = userService.selectUserByIdq(Long.valueOf((String) reqmap.get("bimUid"))); +// //获取用户所担任的角色 +// List roles = roleService.selectRoleId(Long.valueOf((String) reqmap.get("bimUid"))); +// //获取用户所在的岗位 +// List posts = postService.selectPostId(Long.valueOf((String) reqmap.get("bimUid"))); +// //用于将对象的属性改为仅需要的对象 +// DeptGai deptGai = new DeptGai(); +// UserZhuan userZhuan = deptGai.zhuanHuan(userAll, roles, posts); +// jsonObject.put("resultCode", "0"); +// jsonObject.put("message", "success"); +// jsonObject.put("account", userZhuan); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } catch (Exception e) { +// jsonObject.put("resultCode", "505"); +// jsonObject.put("message", "获取id失败"); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } +// } +// jsonObject.put("resultCode", "505"); +// jsonObject.put("message", "获取id失败"); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } +// +// @ApiOperation("创建机构信息") +// @ApiImplicitParam(name = "json", value = "创建机构信息", dataType = "String") +// @PostMapping("/OrgCreateService") +// @ResponseBody +// public String OrgCreate(@RequestBody String json) { +// Map schema = new HashMap(); +// JSONObject jsonObject = new JSONObject(); +// String bodyparam = json; +// logger.info("json--param-->" + bodyparam); +// Map reqmap = (Map) JSON.parse(bodyparam); +// String username = (String) reqmap.get("bimRemoteUser"); +// String password = (String) reqmap.get("bimRemotePwd"); +// if (BamboocloudUtils.checkUsernamePassword(username, password)) { +// //机构的属性填值 +// Dept dept = createUpdateOrg(reqmap); +// deptService.insertBbcDept(dept); +// String uid = dept.getDeptId() + ""; +// if (uid != null) { +// schema.put("uid", uid); +// schema.put("bimRequestId", reqmap.get("bimRequestId")); +// schema.put("resultCode", "0"); +// schema.put("message", "success"); +// String mapJson = JSON.toJSONString(schema); +// logger.info("response----->" + schema); +// return mapJson; +// } +// } +// schema.put("bimRequestId", reqmap.get("bimRequestId")); +// schema.put("resultCode", "500"); +// schema.put("message", "机构创建失败,报错信息自定义"); +// String mapJson = JSON.toJSONString(schema); +// logger.info("response----->" + schema); +// return mapJson; +// } +// +// private Dept createUpdateOrg(Map reqmap) { +// Dept dept = new Dept(); +// if (reqmap.get("dept_id") != null) { +// dept.setDeptId(Long.valueOf(String.valueOf(reqmap.get("dept_id")))); +// } +// if (reqmap.get("__UID__") != null) { +// dept.setDeptId(Long.valueOf(String.valueOf(reqmap.get("__UID__")))); +// } +// if (reqmap.get("parent_id") != null) { +// dept.setParentId(Long.valueOf(String.valueOf(reqmap.get("parent_id")))); +// } +// if (reqmap.get("status") != null) { +// if (Boolean.valueOf(String.valueOf(reqmap.get("status")))) +// dept.setStatus("1"); +// else dept.setStatus("0"); +// } +// if (reqmap.get("__ENABLE__") != null) { +// if (Boolean.valueOf(String.valueOf(reqmap.get("__ENABLE__")))) +// dept.setStatus("0"); +// else dept.setStatus("1"); +// } +// +// if (reqmap.get("dept_name") != null) { +// dept.setDeptName((String) reqmap.get("dept_name")); +// } +// if (reqmap.get("__NAME__") != null) { +// dept.setDeptName((String) reqmap.get("__NAME__")); +// } +// return dept; +// } +// +// @ApiOperation("修改机构信息") +// @ApiImplicitParam(name = "json", value = "修改机构信息", dataType = "String") +// @PostMapping("/OrgUpdateService") +// @ResponseBody +// public String orgUpdateService(@RequestBody String json) throws ServletException, IOException { +// Map schema = new HashMap(); +// JSONObject jsonObject = new JSONObject(); +// String bodyparam = json; +// +// logger.info("json--param-->" + bodyparam); +// Map reqmap = (Map) JSON.parse(bodyparam); +// String username = (String) reqmap.get("bimRemoteUser"); +// String password = (String) reqmap.get("bimRemotePwd"); +// if (BamboocloudUtils.checkUsernamePassword(username, password)) { +// Dept dept = new Dept(); +// dept = createUpdateOrg(reqmap); +// dept.setDeptId(Long.valueOf(String.valueOf(reqmap.get("bimOrgId")))); +// deptService.updateBbcDept(dept); +// schema.put("bimRequestId", reqmap.get("bimRequestId")); +// schema.put("resultCode", "0"); +// schema.put("message", "success"); +// String mapJson = JSON.toJSONString(schema); +// logger.info("response----->" + schema); +// return mapJson; +// } +// schema.put("bimRequestId", reqmap.get("bimRequestId")); +// schema.put("resultCode", "500"); +// schema.put("message", "机构更新失败,报错信息自定义"); +// String mapJson = JSON.toJSONString(schema); +// logger.info("response----->" + schema); +// return mapJson; +// } +// +// @ApiOperation("删除机构信息") +// @ApiImplicitParam(name = "json", value = "删除机构信息", dataType = "String") +// @PostMapping("/OrgDeleteService") +// @ResponseBody +// public String orgDeleteService(@RequestBody String json) throws ServletException, IOException { +// Map schema = new HashMap(); +// JSONObject jsonObject = new JSONObject(); +// String bodyparam = json; +// +// +// logger.info("json--param-->" + bodyparam); +// Map reqmap = (Map) JSON.parse(bodyparam); +// String username = (String) reqmap.get("bimRemoteUser"); +// String password = (String) reqmap.get("bimRemotePwd"); +// if (BamboocloudUtils.checkUsernamePassword(username, password)) { +// int n = deptService.deleteDeptById(Long.valueOf(String.valueOf(reqmap.get("bimOrgId")))); +// schema.put("bimRequestId", reqmap.get("bimRequestId")); +// schema.put("resultCode", "0"); +// schema.put("message", "success"); +// String mapJson = JSON.toJSONString(schema); +// logger.info("response----->" + schema); +// return mapJson; +// } +// schema.put("bimRequestId", reqmap.get("bimRequestId")); +// schema.put("resultCode", "500"); +// schema.put("message", "机构删除失败,报错信息自定义"); +// String mapJson = JSON.toJSONString(schema); +// logger.info("response----->" + schema); +// return mapJson; +// +// } +// +// @ApiOperation("获取机构id") +// @ApiImplicitParam(name = "json", value = "获取机构id", dataType = "String") +// @PostMapping("/QueryAllOrgIdsService") +// @ResponseBody +// public String QueryAllOrgIds(@RequestBody String json) { +// JSONObject jsonObject = new JSONObject(); +// String bodyparam = json; +// +// logger.info("json--param-->" + bodyparam); +// Map reqmap = (Map) JSON.parse(bodyparam); +// String username = (String) reqmap.get("bimRemoteUser"); +// String password = (String) reqmap.get("bimRemotePwd"); +// if (BamboocloudUtils.checkUsernamePassword(username, password)) { +// try { +// +// List list = deptService.selectDeptIdList(new Dept()); +// jsonObject.put("resultCode", "0"); +// jsonObject.put("message", "success"); +// jsonObject.put("orgIdList", list); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } catch (Exception e) { +// jsonObject.put("resultCode", "505"); +// jsonObject.put("message", "获取id失败"); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } +// } +// jsonObject.put("resultCode", "505"); +// jsonObject.put("message", "获取id失败"); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } +// +// @ApiOperation("通过机构id获取信息") +// @ApiImplicitParam(name = "json", value = "机构ID等相关信息", dataType = "String") +// @PostMapping("/QueryOrgByIdService") +// @ResponseBody +// public String IdDeptlist(@RequestBody String json) { +// JSONObject jsonObject = new JSONObject(); +// String bodyparam = json; +// +// logger.info("json--param-->" + bodyparam); +// Map reqmap = (Map) JSON.parse(bodyparam); +// //验证签名 +// String username = (String) reqmap.get("bimRemoteUser"); +// String password = (String) reqmap.get("bimRemotePwd"); +// if (BamboocloudUtils.checkUsernamePassword(username, password)) { +// try { +// Dept deptAll = deptService.selectDeptById(Long.valueOf((String) reqmap.get("bimOrgId"))); +// DeptGai deptGai = new DeptGai(); +// DeptZhuan deptZhuan = deptGai.zhuanHuan(deptAll); +// jsonObject.put("resultCode", "0"); +// jsonObject.put("message", "success"); +// jsonObject.put("organization", deptZhuan); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } catch (Exception e) { +// jsonObject.put("resultCode", "505"); +// jsonObject.put("message", "获取机构信息失败"); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } +// } +// jsonObject.put("resultCode", "505"); +// jsonObject.put("message", "回收机构失败"); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } +// +// @ApiOperation("创建角色信息") +// @ApiImplicitParam(name = "json", value = "创建角色信息", dataType = "String") +// @PostMapping("/RoleCreateService") +// @ResponseBody +// public String RoleCreateService(@RequestBody String json) { +// Map schema = new HashMap(); +// JSONObject jsonObject = new JSONObject(); +// +// String bodyparam = json; +// +// logger.info("json--param-->" + bodyparam); +// Map reqmap = (Map) JSON.parse(bodyparam); +// String username = (String) reqmap.get("bimRemoteUser"); +// String password = (String) reqmap.get("bimRemotePwd"); +// if (BamboocloudUtils.checkUsernamePassword(username, password)) { +// Role role = createUpdateRole(reqmap); +// if (reqmap.get("roleSort") != null) { +// role.setRoleSort((String) reqmap.get("roleSort")); +// } +// if (reqmap.get("roleSort") == null || "".equals((String) reqmap.get("roleSort"))) { +// role.setRoleSort("1"); +// } +// if (reqmap.get("status") == null && reqmap.get("__ENABLE__") == null) { +// role.setStatus("0"); +// } +// roleService.insertBbcRole(role); +// String uid = role.getRoleId().toString(); +// if (uid != null) { +// schema.put("uid", uid); +// schema.put("bimRequestId", reqmap.get("bimRequestId")); +// schema.put("resultCode", "0"); +// schema.put("message", "success"); +// String mapJson = JSON.toJSONString(schema); +// logger.info("response----->" + schema); +// return mapJson; +// } +// } +// schema.put("bimRequestId", reqmap.get("bimRequestId")); +// schema.put("resultCode", "500"); +// schema.put("message", "角色创建失败,报错信息自定义"); +// String mapJson = JSON.toJSONString(schema); +// logger.info("response----->" + schema); +// return mapJson; +// } +// +// private Role createUpdateRole(Map reqmap) { +// Role role = new Role(); +// if (reqmap.get("bimRid") != null) { +// role.setRoleId(Long.valueOf(String.valueOf(reqmap.get("bimRid")))); +// } +// if (reqmap.get("roleId") != null) { +// role.setRoleId(Long.valueOf(String.valueOf(reqmap.get("roleId")))); +// } +// if (reqmap.get("__UID__") != null) { +// role.setRoleId(Long.valueOf(String.valueOf(reqmap.get("roleId")))); +// } +// if (reqmap.get("__NAME__") != null) { +// role.setRoleName((String) reqmap.get("__NAME__")); +// } +// if (reqmap.get("roleName") != null) { +// role.setRoleName((String) reqmap.get("roleName")); +// } +// if (reqmap.get("dataScope") != null) { +// role.setDataScope((String) reqmap.get("dataScope")); +// } +// if (reqmap.get("roleKey") != null) { +// role.setRoleKey((String) reqmap.get("roleKey")); +// } +// if (reqmap.get("status") != null) { +// if (Boolean.valueOf(String.valueOf(reqmap.get("status")))) +// role.setStatus("1"); +// else role.setStatus("0"); +// } +// if (reqmap.get("__ENABLE__") != null) { +// if (Boolean.valueOf(String.valueOf(reqmap.get("__ENABLE__")))) +// role.setStatus("0"); +// else role.setStatus("1"); +// } +// return role; +// } +// +// @ApiOperation("修改角色信息") +// @ApiImplicitParam(name = "json", value = "修改角色信息", dataType = "String") +// @PostMapping("/RoleUpdateService") +// @ResponseBody +// public String RoleUpdateService(@RequestBody String json) throws ServletException, IOException { +// Map schema = new HashMap(); +// JSONObject jsonObject = new JSONObject(); +// String bodyparam = json; +// +// logger.info("json--param-->" + bodyparam); +// Map reqmap = (Map) JSON.parse(bodyparam); +// +// String username = (String) reqmap.get("bimRemoteUser"); +// String password = (String) reqmap.get("bimRemotePwd"); +// if (BamboocloudUtils.checkUsernamePassword(username, password)) { +// Role role = createUpdateRole(reqmap); +// roleService.updateBbcRole(role); +// schema.put("bimRequestId", reqmap.get("bimRequestId")); +// schema.put("resultCode", "0"); +// schema.put("message", "success"); +// String mapJson = JSON.toJSONString(schema); +// logger.info("response----->" + schema); +// return mapJson; +// } +// schema.put("bimRequestId", reqmap.get("bimRequestId")); +// schema.put("resultCode", "500"); +// schema.put("message", "角色更新失败,报错信息自定义"); +// String mapJson = JSON.toJSONString(schema); +// logger.info("response----->" + schema); +// return mapJson; +// } +// +// +// @ApiOperation("删除角色信息") +// @ApiImplicitParam(name = "json", value = "删除角色信息", dataType = "String") +// @PostMapping("/RoleDeleteService") +// @ResponseBody +// public String RoleDeleteService(@RequestBody String json) throws ServletException, IOException { +// Map schema = new HashMap(); +// JSONObject jsonObject = new JSONObject(); +// +// String bodyparam = json; +// +// logger.info("json--param-->" + bodyparam); +// Map reqmap = (Map) JSON.parse(bodyparam); +// String username = (String) reqmap.get("bimRemoteUser"); +// String password = (String) reqmap.get("bimRemotePwd"); +// if (BamboocloudUtils.checkUsernamePassword(username, password)) { +// boolean n = roleService.deleteRoleById(Long.valueOf(String.valueOf(reqmap.get("bimRid")))); +// schema.put("bimRequestId", reqmap.get("bimRequestId")); +// schema.put("resultCode", "0"); +// schema.put("message", "success"); +// String mapJson = JSON.toJSONString(schema); +// logger.info("response----->" + schema); +// return mapJson; +// } +// schema.put("bimRequestId", reqmap.get("bimRequestId")); +// schema.put("resultCode", "500"); +// schema.put("message", "机构删除失败,报错信息自定义"); +// String mapJson = JSON.toJSONString(schema); +// logger.info("response----->" + schema); +// return mapJson; +// } +// +// @ApiOperation("获取角色id") +// @ApiImplicitParam(name = "json", value = "获取角色id", dataType = "String") +// @PostMapping("/QueryAllRoleIdsService") +// @ResponseBody +// public String QueryAllRoleIdsService(@RequestBody String json) { +// JSONObject jsonObject = new JSONObject(); +// String bodyparam = json; +// +// logger.info("json--param-->" + bodyparam); +// Map reqmap = (Map) JSON.parse(bodyparam); +// String username = (String) reqmap.get("bimRemoteUser"); +// String password = (String) reqmap.get("bimRemotePwd"); +// if (BamboocloudUtils.checkUsernamePassword(username, password)) { +// try { +// +// List list = roleService.selectRoleIdList(new Role()); +// jsonObject.put("resultCode", "0"); +// jsonObject.put("message", "success"); +// jsonObject.put("roleIdList", list); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } catch (Exception e) { +// jsonObject.put("resultCode", "505"); +// jsonObject.put("message", "获取id失败"); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } +// } +// jsonObject.put("resultCode", "505"); +// jsonObject.put("message", "获取id失败"); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } +// +// @ApiOperation("通过角色id获取信息") +// @ApiImplicitParam(name = "json", value = "获取角色id", dataType = "String") +// @PostMapping("/QueryRoleByIdService") +// @ResponseBody +// public String QueryRoleByIdService(@RequestBody String json) { +// JSONObject jsonObject = new JSONObject(); +// String bodyparam = json; +// +// logger.info("json--param-->" + bodyparam); +// Map reqmap = (Map) JSON.parse(bodyparam); +// String username = (String) reqmap.get("bimRemoteUser"); +// String password = (String) reqmap.get("bimRemotePwd"); +// if (BamboocloudUtils.checkUsernamePassword(username, password)) { +// try { +// Role roleAll = roleService.selectRoleById(Long.valueOf((String) reqmap.get("bimRid"))); +// jsonObject.put("resultCode", "0"); +// jsonObject.put("message", "success"); +// jsonObject.put("role", roleAll); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } catch (Exception e) { +// jsonObject.put("resultCode", "505"); +// jsonObject.put("message", "获取角色信息失败"); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } +// } +// jsonObject.put("resultCode", "505"); +// jsonObject.put("message", "回收角色失败"); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } +// +// @ApiOperation("获取资源id") +// @ApiImplicitParam(name = "json", value = "获取资源id", dataType = "String") +// @PostMapping("/QueryAllResourceIdsService") +// @ResponseBody +// public String QueryAllResourceIdsService(@RequestBody String json) { +// JSONObject jsonObject = new JSONObject(); +// String bodyparam = json; +// +// logger.info("json--param-->" + bodyparam); +// Map reqmap = (Map) JSON.parse(bodyparam); +// +// String username = (String) reqmap.get("bimRemoteUser"); +// String password = (String) reqmap.get("bimRemotePwd"); +// String resourceType = (String) reqmap.get("resourceType"); +// if (BamboocloudUtils.checkUsernamePassword(username, password)) { +// try { +// if ("post".equals(resourceType)) { +// List list = postService.selectPostIdList(new Post()); +// jsonObject.put("resultCode", "0"); +// jsonObject.put("message", "success"); +// jsonObject.put("resourceIdList", list); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } +// if ("dict".equals(resourceType)) { +// DictData dictData = new DictData(); +// dictData.setDictType("sys_user_sex"); +// List list = dictDataService.selectDictDataIdList(dictData); +// jsonObject.put("resultCode", "0"); +// jsonObject.put("message", "success"); +// jsonObject.put("resourceIdList", list); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } +// } catch (Exception e) { +// jsonObject.put("resultCode", "505"); +// jsonObject.put("message", "获取id失败"); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } +// } +// jsonObject.put("resultCode", "505"); +// jsonObject.put("message", "获取id失败"); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } +// +// @ApiOperation("通过资源id获取信息") +// @ApiImplicitParam(name = "json", value = "资源id等相关信息", dataType = "String") +// @PostMapping("/QueryResourceByIdService") +// @ResponseBody +// public String QueryResourceByIdService(@RequestBody String json) { +// JSONObject jsonObject = new JSONObject(); +// String bodyparam =json; +// +// logger.info("json--param-->" + bodyparam); +// Map reqmap = (Map) JSON.parse(bodyparam); +// String username = (String) reqmap.get("bimRemoteUser"); +// String password = (String) reqmap.get("bimRemotePwd"); +// //根据resourceType的值进行资源类的判断如下面dict和post两个对象类 +// String resourceType = (String) reqmap.get("resourceType"); +// if (BamboocloudUtils.checkUsernamePassword(username, password)) { +// try { +// if ("post".equals(resourceType)) { +// Post postAll = postService.selectPostById(Long.valueOf((String) reqmap.get("resourceId"))); +// jsonObject.put("resultCode", "0"); +// jsonObject.put("message", "success"); +// jsonObject.put("resource", postAll); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } +// if ("dict".equals(resourceType)) { +// DictData dictDataAll = dictDataService.selectDictDataById(Long.valueOf((String) reqmap.get("resourceId"))); +// jsonObject.put("resultCode", "0"); +// jsonObject.put("message", "success"); +// jsonObject.put("resource", dictDataAll); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } +// } catch (Exception e) { +// jsonObject.put("resultCode", "505"); +// jsonObject.put("message", "获取资源信息失败"); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } +// } +// jsonObject.put("resultCode", "505"); +// jsonObject.put("message", "回收资源失败"); +// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); +// String mapJson = JSON.toJSONString(jsonObject); +// logger.info("response----->" + jsonObject); +// return mapJson; +// } +// +// +// public StringBuilder stringBuilder(HttpServletRequest req) { +// BufferedReader br = null; +// StringBuilder sb = new StringBuilder(); +// String str = ""; +// try { +// br = req.getReader(); +// while ((str = br.readLine()) != null) { +// sb.append(str); +// } +// br.close(); +// } catch (IOException e) { +// e.printStackTrace(); +// if (br != null) { +// try { +// br.close(); +// } catch (IOException eo) { +// eo.printStackTrace(); +// } +// } +// } finally { +// if (br != null) { +// try { +// br.close(); +// } catch (IOException e) { +// e.printStackTrace(); +// } +// } +// } +// return sb; +// } +// +//} +// +// diff --git a/laws-modules/src/main/java/com/jero/modules/iam/SHA256Util.java b/laws-modules/src/main/java/com/jero/modules/iam/SHA256Util.java new file mode 100644 index 00000000..e3cdf99c --- /dev/null +++ b/laws-modules/src/main/java/com/jero/modules/iam/SHA256Util.java @@ -0,0 +1,41 @@ +package com.jero.modules.iam; + +import java.nio.charset.StandardCharsets; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +public class SHA256Util { + + /** + * 利用java原生的摘要实现SHA256加密密后的报文 + */ + public static String getSHA256StrJava(String str) { + MessageDigest messageDigest; + String encodeStr = ""; + try { + messageDigest = MessageDigest.getInstance("SHA-256"); + messageDigest.update(str.getBytes(StandardCharsets.UTF_8)); + encodeStr = byte2Hex(messageDigest.digest()); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + } + return encodeStr; + } + + /** + * 将byte转为16进制 + */ + private static String byte2Hex(byte[] bytes) { + StringBuilder stringBuffer = new StringBuilder(); + String temp; + for (byte aByte : bytes) { + temp = Integer.toHexString(aByte & 0xFF); + if (temp.length() == 1) { + //1得到一位的进行补0操作 + stringBuffer.append("0"); + } + stringBuffer.append(temp); + } + return stringBuffer.toString(); + } +} diff --git a/laws-modules/src/main/java/com/jero/modules/iam/bim-codec-1.0.0.jar b/laws-modules/src/main/java/com/jero/modules/iam/bim-codec-1.0.0.jar new file mode 100644 index 00000000..1625554e Binary files /dev/null and b/laws-modules/src/main/java/com/jero/modules/iam/bim-codec-1.0.0.jar differ