|
|
@@ -2,18 +2,25 @@ package com.uas.sso.util;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.alibaba.fastjson.TypeReference;
|
|
|
import com.uas.sso.AccountConfig;
|
|
|
import com.uas.sso.ResultWrap;
|
|
|
import com.uas.sso.common.util.HttpUtil;
|
|
|
+import com.uas.sso.entity.ApplyUserSpaceView;
|
|
|
import com.uas.sso.entity.UserSpaceView;
|
|
|
import com.uas.sso.entity.UserView;
|
|
|
+import org.springframework.data.domain.Page;
|
|
|
import org.springframework.ui.ModelMap;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Set;
|
|
|
+
|
|
|
/**
|
|
|
* 客户端使用,操作企业资料、用户资料
|
|
|
*
|
|
|
- * @author yingp
|
|
|
+ * @author wangmh
|
|
|
*
|
|
|
*/
|
|
|
public class AccountUtils {
|
|
|
@@ -78,6 +85,31 @@ public class AccountUtils {
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public static void unbindUserSpace(Long userUU, Long spaceUU) throws Exception {
|
|
|
+ String saveUrl = AccountConfig.getUserSaveUrl();
|
|
|
+ if (!StringUtils.isEmpty(saveUrl)) {
|
|
|
+ ModelMap formData = new ModelMap();
|
|
|
+ formData.put("_operate", "bind");
|
|
|
+ formData.put("userUU", userUU);
|
|
|
+ formData.put("spaceUU", spaceUU);
|
|
|
+ HttpUtil.ResponseWrap res = HttpUtil.doPost(saveUrl, formData);
|
|
|
+ if (!res.isSuccess()) {
|
|
|
+ throw new Exception(res.getContent());
|
|
|
+ } else {
|
|
|
+ ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
|
|
|
+ if (!result.isSuccess()) {
|
|
|
+ throw new Exception(result.getErrMsg());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 用户绑定企业
|
|
|
+ * @param userUU 用户uu号
|
|
|
+ * @param spaceUU 企业uu号
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public static void bindUserSpace(Long userUU, Long spaceUU) throws Exception {
|
|
|
String saveUrl = AccountConfig.getUserSaveUrl();
|
|
|
if (!StringUtils.isEmpty(saveUrl)) {
|
|
|
ModelMap formData = new ModelMap();
|
|
|
@@ -95,6 +127,245 @@ public class AccountUtils {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据营业执照号获得企业信息
|
|
|
+ * @param businessCode 营业执照号
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<UserSpaceView> findByBusinessCode(String businessCode) throws Exception {
|
|
|
+ String saveUrl = AccountConfig.getSpaceSaveUrl();
|
|
|
+ if (!StringUtils.isEmpty(saveUrl)) {
|
|
|
+ ModelMap formData = new ModelMap();
|
|
|
+ saveUrl = saveUrl + "/info/businessCode";
|
|
|
+ formData.put("businessCode", businessCode);
|
|
|
+ HttpUtil.ResponseWrap res = HttpUtil.doPost(saveUrl, formData);
|
|
|
+ if (!res.isSuccess()) {
|
|
|
+ throw new Exception(res.getContent());
|
|
|
+ } else {
|
|
|
+ ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
|
|
|
+ if (!result.isSuccess()) {
|
|
|
+ throw new Exception(result.getErrMsg());
|
|
|
+ } else if (result.getContent() != null){
|
|
|
+ return JSON.parseArray(result.getContent().toString(), UserSpaceView.class);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据营业执照号获得企业信息
|
|
|
+ * @param spaceName 营业执照号
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<UserSpaceView> findBySpaceName(String spaceName) throws Exception {
|
|
|
+ String saveUrl = AccountConfig.getSpaceSaveUrl();
|
|
|
+ if (!StringUtils.isEmpty(saveUrl)) {
|
|
|
+ ModelMap formData = new ModelMap();
|
|
|
+ saveUrl = saveUrl + "/info/businessCode";
|
|
|
+ formData.put("spaceName", spaceName);
|
|
|
+ HttpUtil.ResponseWrap res = HttpUtil.doPost(saveUrl, formData);
|
|
|
+ if (!res.isSuccess()) {
|
|
|
+ throw new Exception(res.getContent());
|
|
|
+ } else {
|
|
|
+ ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
|
|
|
+ if (!result.isSuccess()) {
|
|
|
+ throw new Exception(result.getErrMsg());
|
|
|
+ } else if (result.getContent() != null){
|
|
|
+ return JSON.parseArray(result.getContent().toString(), UserSpaceView.class);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 用户申请绑定企业
|
|
|
+ * @param userUU 用户uu号
|
|
|
+ * @param spaceUU 企业uu号
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public static void applyUserSpace(Long userUU, Long spaceUU) throws Exception {
|
|
|
+ String saveUrl = AccountConfig.getUserSaveUrl();
|
|
|
+ if (!StringUtils.isEmpty(saveUrl)) {
|
|
|
+ ModelMap formData = new ModelMap();
|
|
|
+ saveUrl = saveUrl + "/apply/bind";
|
|
|
+ formData.put("userUU", userUU);
|
|
|
+ formData.put("spaceUU", spaceUU);
|
|
|
+ HttpUtil.ResponseWrap res = HttpUtil.doPost(saveUrl, formData);
|
|
|
+ if (!res.isSuccess()) {
|
|
|
+ throw new Exception(res.getContent());
|
|
|
+ } else {
|
|
|
+ ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
|
|
|
+ if (!result.isSuccess()) {
|
|
|
+ throw new Exception(result.getErrMsg());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页查找个人申请记录
|
|
|
+ *
|
|
|
+ * @author wangmh
|
|
|
+ * @date 2018/2/1 15:47
|
|
|
+ * @param userUU 用户uu号
|
|
|
+ * @param page 页数(从0开始)
|
|
|
+ * @param size 每页大小
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public static Page<ApplyUserSpaceView> findApplyInfo(Long userUU, int page, int size) throws Exception {
|
|
|
+ String url = AccountConfig.getUserSaveUrl();
|
|
|
+ if (!StringUtils.isEmpty(url)) {
|
|
|
+ url = url + "/apply/info";
|
|
|
+ ModelMap data = new ModelMap();
|
|
|
+ data.put("userUU", userUU);
|
|
|
+ data.put("page", page);
|
|
|
+ data.put("size", size);
|
|
|
+ HttpUtil.ResponseWrap res = HttpUtil.doGet(url, data);
|
|
|
+ if (!res.isSuccess()) {
|
|
|
+ throw new Exception(res.getContent());
|
|
|
+ } else {
|
|
|
+ ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
|
|
|
+ if (!result.isSuccess()) {
|
|
|
+ throw new Exception(result.getErrMsg());
|
|
|
+ } else if (result.getContent() != null) {
|
|
|
+ return JSON.parseObject(result.getContent().toString(), new TypeReference<Page<ApplyUserSpaceView>>() {
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 统计该企业审批记录数量
|
|
|
+ * @param spaceUU 企业uu号
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public static Map<String, Integer> applyCount(Long spaceUU) throws Exception {
|
|
|
+ String url = AccountConfig.getSpaceSaveUrl();
|
|
|
+ if (!StringUtils.isEmpty(url)) {
|
|
|
+ url = url + "/apply/count";
|
|
|
+ ModelMap data = new ModelMap();
|
|
|
+ data.put("spaceUU", spaceUU);
|
|
|
+ HttpUtil.ResponseWrap res = HttpUtil.doGet(url, data);
|
|
|
+ if (!res.isSuccess()) {
|
|
|
+ throw new Exception(res.getContent());
|
|
|
+ } else {
|
|
|
+ ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
|
|
|
+ if (!result.isSuccess()) {
|
|
|
+ throw new Exception(result.getErrMsg());
|
|
|
+ } else if (result.getContent() != null) {
|
|
|
+ return JSON.parseObject(result.getContent().toString(), Map.class);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 校验企业名称
|
|
|
+ * @param spaceName 企业名称
|
|
|
+ */
|
|
|
+ public static void checkSpaceName(String spaceName) throws Exception {
|
|
|
+ String url = AccountConfig.getSpaceSaveUrl();
|
|
|
+ if (!StringUtils.isEmpty(url)) {
|
|
|
+ url = url + "/checkSpaceName";
|
|
|
+ ModelMap data = new ModelMap();
|
|
|
+ data.put("spaceName", spaceName);
|
|
|
+ HttpUtil.ResponseWrap res = HttpUtil.doGet(url, data);
|
|
|
+ if (!res.isSuccess()) {
|
|
|
+ throw new Exception(res.getContent());
|
|
|
+ } else {
|
|
|
+ ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
|
|
|
+ if (!result.isSuccess()) {
|
|
|
+ throw new Exception(result.getErrMsg());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 校验企业营业执照号
|
|
|
+ * @param businessCode 企业营业执照号
|
|
|
+ */
|
|
|
+ public static void checkBusinessCode(String businessCode) throws Exception {
|
|
|
+ String url = AccountConfig.getSpaceSaveUrl();
|
|
|
+ if (!StringUtils.isEmpty(url)) {
|
|
|
+ url = url + "/checkBusinessCode";
|
|
|
+ ModelMap data = new ModelMap();
|
|
|
+ data.put("businessCode", businessCode);
|
|
|
+ HttpUtil.ResponseWrap res = HttpUtil.doGet(url, data);
|
|
|
+ if (!res.isSuccess()) {
|
|
|
+ throw new Exception(res.getContent());
|
|
|
+ } else {
|
|
|
+ ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
|
|
|
+ if (!result.isSuccess()) {
|
|
|
+ throw new Exception(result.getErrMsg());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据用户uu号获取用户信息
|
|
|
+ * @param userUU 用户uu号
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public static UserView findByUserUU(Long userUU) throws Exception {
|
|
|
+ String url = AccountConfig.getUserSaveUrl();
|
|
|
+ if (!StringUtils.isEmpty(url)) {
|
|
|
+ url = url + "/info";
|
|
|
+ ModelMap data = new ModelMap();
|
|
|
+ data.put("userUU", userUU);
|
|
|
+ HttpUtil.ResponseWrap res = HttpUtil.doGet(url, data);
|
|
|
+ if (!res.isSuccess()) {
|
|
|
+ throw new Exception(res.getContent());
|
|
|
+ } else {
|
|
|
+ ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
|
|
|
+ if (!result.isSuccess()) {
|
|
|
+ throw new Exception(result.getErrMsg());
|
|
|
+ } else if (result.getContent() != null) {
|
|
|
+ return JSON.parseObject(result.getContent().toString(), UserView.class);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据用户uu号获取用户信息
|
|
|
+ * @param spaceUU 企业uu号
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public static UserSpaceView findBySpaceUU(Long spaceUU) throws Exception {
|
|
|
+ String url = AccountConfig.getUserSaveUrl();
|
|
|
+ if (!StringUtils.isEmpty(url)) {
|
|
|
+ url = url + "/checkBusinessCode";
|
|
|
+ ModelMap data = new ModelMap();
|
|
|
+ data.put("spaceUU", spaceUU);
|
|
|
+ HttpUtil.ResponseWrap res = HttpUtil.doGet(url, data);
|
|
|
+ if (!res.isSuccess()) {
|
|
|
+ throw new Exception(res.getContent());
|
|
|
+ } else {
|
|
|
+ ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
|
|
|
+ if (!result.isSuccess()) {
|
|
|
+ throw new Exception(result.getErrMsg());
|
|
|
+ } else if (result.getContent() != null) {
|
|
|
+ return JSON.parseObject(result.getContent().toString(), UserSpaceView.class);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
/// 之后方法会恢复并修改
|
|
|
//
|
|
|
// /**
|