|
|
|
@ -1,307 +1,268 @@
|
|
|
|
|
package com.ruoyi.project.system.controller;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
|
|
import com.alibaba.fastjson2.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.domain.SysUser;
|
|
|
|
|
import com.ruoyi.project.system.service.ISysDeptService;
|
|
|
|
|
import com.ruoyi.project.system.service.ISysPostService;
|
|
|
|
|
import com.ruoyi.project.system.service.ISysRoleService;
|
|
|
|
|
import com.ruoyi.project.system.service.ISysUserService;
|
|
|
|
|
import com.ruoyi.project.system.utils.BamboocloudUtils;
|
|
|
|
|
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.security.core.userdetails.User;
|
|
|
|
|
import org.springframework.security.core.userdetails.UserDetails;
|
|
|
|
|
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.*;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* swagger 用户测试方法
|
|
|
|
|
* 加密认证
|
|
|
|
|
* @author ruoyi
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
|
@RequestMapping("/bbc/user")
|
|
|
|
|
public class BbcController extends BaseController {
|
|
|
|
|
|
|
|
|
|
private String bimRequestId;
|
|
|
|
|
|
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(ReflectUtils.class);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private ISysUserService userService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private ISysRoleService roleService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private ISysDeptService deptService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private ISysPostService postService;
|
|
|
|
|
|
|
|
|
|
// @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<String, Object> reqmap = (Map<String, Object>) 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<String, List<Map<String, Object>>> map = new HashMap<>();
|
|
|
|
|
ArrayList<HashMap<String,Object>> accountList = new ArrayList<>();
|
|
|
|
|
HashMap<String, Object> nameMap = new HashMap<>();
|
|
|
|
|
nameMap.put("multivalued",false);
|
|
|
|
|
nameMap.put("name","userName");
|
|
|
|
|
nameMap.put("required",true);
|
|
|
|
|
nameMap.put("type","String");
|
|
|
|
|
HashMap<String, Object> passMap = new HashMap<>();
|
|
|
|
|
passMap.put("multivalued",false);
|
|
|
|
|
passMap.put("name","password");
|
|
|
|
|
passMap.put("required",true);
|
|
|
|
|
passMap.put("type","String");
|
|
|
|
|
HashMap<String, Object> mobileMap = new HashMap<>();
|
|
|
|
|
mobileMap.put("multivalued",false);
|
|
|
|
|
mobileMap.put("name","mobile");
|
|
|
|
|
mobileMap.put("required",true);
|
|
|
|
|
mobileMap.put("type","String");
|
|
|
|
|
HashMap<String, Object> statusMap = new HashMap<>();
|
|
|
|
|
statusMap.put("multivalued",false);
|
|
|
|
|
statusMap.put("name","status");
|
|
|
|
|
statusMap.put("required",true);
|
|
|
|
|
statusMap.put("type","String");
|
|
|
|
|
accountList.add(nameMap);
|
|
|
|
|
accountList.add(passMap);
|
|
|
|
|
accountList.add(mobileMap);
|
|
|
|
|
accountList.add(statusMap);
|
|
|
|
|
jsonObject.put("account", 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);
|
|
|
|
|
//<Object> 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<String, Object> schema = new HashMap<String, Object>();
|
|
|
|
|
|
|
|
|
|
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<String, Object> reqmap = (Map<String, Object>) JSON.parse(bodyparam);
|
|
|
|
|
String username = (String) reqmap.get("bimRemoteUser");
|
|
|
|
|
String password = (String) reqmap.get("bimRemotePwd");
|
|
|
|
|
|
|
|
|
|
if (BamboocloudUtils.checkUsernamePassword(username, password)) {
|
|
|
|
|
/**
|
|
|
|
|
* 新增用户
|
|
|
|
|
*/
|
|
|
|
|
//获取用户创建所需的参数
|
|
|
|
|
// User user = createUpdateUser(reqmap);
|
|
|
|
|
String userName = (String) reqmap.get("userName");
|
|
|
|
|
String pass = (String) reqmap.get("password");
|
|
|
|
|
|
|
|
|
|
logger.info("reqmap---------->"+reqmap);
|
|
|
|
|
SysUser user = new SysUser();
|
|
|
|
|
user.setUserName(userName);
|
|
|
|
|
user.setPassword(pass);
|
|
|
|
|
//用户创建
|
|
|
|
|
userService.registerUser(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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// @ApiOperation("修改用户")
|
|
|
|
|
// @ApiImplicitParam(name = "user", value = "修改用户信息", dataType = "User")
|
|
|
|
|
@PostMapping("/UserUpdateService")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public String userUpdateService(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
|
|
|
|
|
|
|
|
|
Map<String, Object> schema = new HashMap<String, Object>();
|
|
|
|
|
|
|
|
|
|
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<String, Object> reqmap = (Map<String, Object>) JSON.parse(bodyparam);
|
|
|
|
|
String username = (String) reqmap.get("bimRemoteUser");
|
|
|
|
|
String password = (String) reqmap.get("bimRemotePwd");
|
|
|
|
|
if (BamboocloudUtils.checkUsernamePassword(username, password)) {
|
|
|
|
|
SysUser user = new SysUser();
|
|
|
|
|
//获取用于更新的参数
|
|
|
|
|
// user = createUpdateUser(reqmap);
|
|
|
|
|
String userName = (String) reqmap.get("userName");
|
|
|
|
|
String pass = (String) reqmap.get("password");
|
|
|
|
|
|
|
|
|
|
logger.info("reqmap---------->"+reqmap);
|
|
|
|
|
user.setUserName(userName);
|
|
|
|
|
user.setPassword(pass);
|
|
|
|
|
//获取用于更新的唯一标识
|
|
|
|
|
user.setUserId(Long.valueOf(String.valueOf(reqmap.get("bimUid"))));
|
|
|
|
|
//更新用户
|
|
|
|
|
userService.updateUserStatus(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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//package com.ruoyi.project.system.controller;
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//import com.alibaba.fastjson2.JSON;
|
|
|
|
|
//import com.alibaba.fastjson2.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.domain.SysUser;
|
|
|
|
|
//import com.ruoyi.project.system.service.ISysDeptService;
|
|
|
|
|
//import com.ruoyi.project.system.service.ISysPostService;
|
|
|
|
|
//import com.ruoyi.project.system.service.ISysRoleService;
|
|
|
|
|
//import com.ruoyi.project.system.service.ISysUserService;
|
|
|
|
|
//import com.ruoyi.project.system.utils.BamboocloudUtils;
|
|
|
|
|
//
|
|
|
|
|
//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.*;
|
|
|
|
|
//
|
|
|
|
|
///**
|
|
|
|
|
// * swagger 用户测试方法
|
|
|
|
|
// * 加密认证
|
|
|
|
|
// * @author ruoyi
|
|
|
|
|
// */
|
|
|
|
|
//
|
|
|
|
|
//@RestController
|
|
|
|
|
//@RequestMapping("/bbc/user")
|
|
|
|
|
//public class BbcController extends BaseController {
|
|
|
|
|
//
|
|
|
|
|
// private String bimRequestId;
|
|
|
|
|
//
|
|
|
|
|
// private static Logger logger = LoggerFactory.getLogger(ReflectUtils.class);
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// @Autowired
|
|
|
|
|
// private ISysUserService userService;
|
|
|
|
|
//
|
|
|
|
|
// @Autowired
|
|
|
|
|
// private ISysRoleService roleService;
|
|
|
|
|
//
|
|
|
|
|
// @Autowired
|
|
|
|
|
// private ISysDeptService deptService;
|
|
|
|
|
//
|
|
|
|
|
// @Autowired
|
|
|
|
|
// private ISysPostService postService;
|
|
|
|
|
//
|
|
|
|
|
//// @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<String, Object> reqmap = (Map<String, Object>) 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<String, List<Map<String, Object>>> 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);
|
|
|
|
|
// //<Object> 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<String, Object> schema = new HashMap<String, Object>();
|
|
|
|
|
//
|
|
|
|
|
// 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<String, Object> reqmap = (Map<String, Object>) JSON.parse(bodyparam);
|
|
|
|
|
// String username = (String) reqmap.get("bimRemoteUser");
|
|
|
|
|
// String password = (String) reqmap.get("bimRemotePwd");
|
|
|
|
|
//
|
|
|
|
|
// if (BamboocloudUtils.checkUsernamePassword(username, password)) {
|
|
|
|
|
// /**
|
|
|
|
|
// * 新增用户
|
|
|
|
|
// */
|
|
|
|
|
// //获取用户创建所需的参数
|
|
|
|
|
//// User user = createUpdateUser(reqmap);
|
|
|
|
|
// SysUser user = new SysUser();
|
|
|
|
|
// //用户创建
|
|
|
|
|
// userService.insertUser(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;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//// @ApiOperation("修改用户")
|
|
|
|
|
//// @ApiImplicitParam(name = "user", value = "修改用户信息", dataType = "User")
|
|
|
|
|
// @PostMapping("/UserUpdateService")
|
|
|
|
|
// @ResponseBody
|
|
|
|
|
// public String userUpdateService(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
|
|
|
|
//
|
|
|
|
|
// Map<String, Object> schema = new HashMap<String, Object>();
|
|
|
|
|
//
|
|
|
|
|
// 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<String, Object> reqmap = (Map<String, Object>) JSON.parse(bodyparam);
|
|
|
|
|
// String username = (String) reqmap.get("bimRemoteUser");
|
|
|
|
|
// String password = (String) reqmap.get("bimRemotePwd");
|
|
|
|
|
// if (BamboocloudUtils.checkUsernamePassword(username, password)) {
|
|
|
|
|
// SysUser user = new SysUser();
|
|
|
|
|
// //获取用于更新的参数
|
|
|
|
|
//// user = createUpdateUser(reqmap);
|
|
|
|
|
// //获取用于更新的唯一标识
|
|
|
|
|
// user.setUserId(Long.valueOf(String.valueOf(reqmap.get("bimUid"))));
|
|
|
|
|
// //更新用户
|
|
|
|
|
// userService.updateUser(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;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// 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;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
//}
|
|
|
|
|
//
|
|
|
|
|