Browse Source

Merge remote-tracking branch 'origin/dev' into dev

huxz 8 years ago
parent
commit
9a0b271a2a

+ 2 - 0
sso-common/build.gradle

@@ -6,6 +6,8 @@ dependencies {
     compile("org.springframework:spring-beans:4.3.3.RELEASE")
     compile("org.springframework:spring-context:4.3.3.RELEASE")
     compile("org.apache.tomcat.embed:tomcat-embed-core:8.5.5")
+    compile("com.alibaba:fastjson:1.2.15")
+    compile("org.codehaus.jackson:jackson-core-asl:1.9.13")
     compile("net.sf.flexjson:flexjson:2.1")
 
     testCompile("junit:junit:4.12")

+ 9 - 16
sso-common/src/main/java/com/uas/sso/entity/UserAccount.java

@@ -1,5 +1,8 @@
 package com.uas.sso.entity;
 
+import com.alibaba.fastjson.annotation.JSONField;
+import org.codehaus.jackson.annotate.JsonIgnore;
+
 import javax.persistence.*;
 import java.io.Serializable;
 import java.util.Date;
@@ -23,61 +26,51 @@ public class UserAccount implements Serializable {
      * uu号
      */
     @Id
-    @Column(name = "useruu")
     private Long userUU;
 
     /**
      * 会员名
      */
-    @Column(name = "vip_name", nullable = false)
     private String vipName;
 
     /**
      * 手机号
      */
-    @Column(name = "mobile", unique = true, nullable = false)
     private String mobile;
 
     /**
      * 手机号所属区域(continent or Hongkong)
      */
-    @Column(name = "mobile_area")
     private String mobileArea;
 
     /**
      * 手机号认证状态
      */
-    @Column(name = "mobile_valid_code")
     private Short mobileValidCode;
 
     /**
      * 用户密码
      */
-    @Column(name = "_password", nullable = false)
     private String password;
 
     /**
      * 用户erp密码
      */
-    @Column(name = "erp_password")
     private String erpPassword;
 
     /**
      * 盐值
      */
-    @Column(name = "salt")
     private String salt;
 
     /**
      * 用户邮箱
      */
-    @Column(name = "user_email")
     private String email;
 
     /**
      * 用户邮箱认证状态
      */
-    @Column(name = "email_valid_code")
     private Short emailValidCode;
 
     /**
@@ -88,37 +81,31 @@ public class UserAccount implements Serializable {
     /**
      * 账户是否冻结(1、冻结)
      */
-    @Column(name = "_lock")
     private Integer lock;
 
     /**
      * 企业uu号
      */
-    @Column(name = "spaceuu")
     private Long spaceUU;
 
     /**
      * 企业名称
      */
-    @Column(name = "space_name", unique = true)
     private String spaceName;
 
     /**
      * 营业执照号
      */
-    @Column(name = "business_code")
     private String businessCode;
 
     /**
      * 企业域名
      */
-    @Column(name = "domain")
     private String spaceDomain;
 
     /**
      * 应用唯一标志
      */
-    @Column(name = "app_uid")
     private String appId;
 
     /**
@@ -206,6 +193,8 @@ public class UserAccount implements Serializable {
         this.mobileValidCode = mobileValidCode;
     }
 
+    @JsonIgnore
+    @JSONField(serialize = false)
     public String getPassword() {
         return password;
     }
@@ -214,6 +203,8 @@ public class UserAccount implements Serializable {
         this.password = password;
     }
 
+    @JsonIgnore
+    @JSONField(serialize = false)
     public String getErpPassword() {
         return erpPassword;
     }
@@ -222,6 +213,8 @@ public class UserAccount implements Serializable {
         this.erpPassword = erpPassword;
     }
 
+    @JsonIgnore
+    @JSONField(serialize = false)
     public String getSalt() {
         return salt;
     }

+ 25 - 49
sso-common/src/main/java/com/uas/sso/entity/UserView.java

@@ -1,5 +1,7 @@
 package com.uas.sso.entity;
 
+import com.alibaba.fastjson.annotation.JSONField;
+
 import java.util.Date;
 
 /**
@@ -17,7 +19,7 @@ public class UserView {
     /**
      * 会员名
      */
-    private String vipName;
+    private String name;
 
     /**
      * 手机号
@@ -34,21 +36,6 @@ public class UserView {
      */
     private Short mobileValidCode;
 
-    /**
-     * 用户密码
-     */
-    private String password;
-
-    /**
-     * 盐值
-     */
-    private String salt;
-
-    /**
-     * 用户注册时间
-     */
-    private Date registerDate;
-
     /**
      * 用户邮箱
      */
@@ -74,6 +61,11 @@ public class UserView {
      */
     private Short identityValidCode;
 
+    /**
+     * 用户身份认证状态
+     */
+    private String imId;
+
     /**
      * 账户是否冻结(1、冻结)
      */
@@ -82,21 +74,19 @@ public class UserView {
     public UserView() {
     }
 
-    public UserView(Long userUU, String vipName, String mobile, String mobileArea, Short mobileValidCode, String password, String salt, Date registerDate, String email, Short emailValidCode, String realName, String idCard, Short identityValidCode, Integer lock) {
+    public UserView(Long userUU, String name, String mobile, String mobileArea, Short mobileValidCode, String email, Short emailValidCode, String realName, String idCard, Short identityValidCode, Integer lock, String imId) {
         this.userUU = userUU;
-        this.vipName = vipName;
+        this.name = name;
         this.mobile = mobile;
         this.mobileArea = mobileArea;
         this.mobileValidCode = mobileValidCode;
-        this.password = password;
-        this.salt = salt;
-        this.registerDate = registerDate;
         this.email = email;
         this.emailValidCode = emailValidCode;
         this.realName = realName;
         this.idCard = idCard;
         this.identityValidCode = identityValidCode;
         this.lock = lock;
+        this.imId = imId;
     }
 
     public Long getUserUU() {
@@ -107,12 +97,14 @@ public class UserView {
         this.userUU = userUU;
     }
 
-    public String getVipName() {
-        return vipName;
+    @JSONField(name="vipName")
+    public String getName() {
+        return name;
     }
 
-    public void setVipName(String vipName) {
-        this.vipName = vipName;
+    @JSONField(name="vipName")
+    public void setName(String name) {
+        this.name = name;
     }
 
     public String getMobile() {
@@ -139,30 +131,6 @@ public class UserView {
         this.mobileValidCode = mobileValidCode;
     }
 
-    public String getPassword() {
-        return password;
-    }
-
-    public void setPassword(String password) {
-        this.password = password;
-    }
-
-    public String getSalt() {
-        return salt;
-    }
-
-    public void setSalt(String salt) {
-        this.salt = salt;
-    }
-
-    public Date getRegisterDate() {
-        return registerDate;
-    }
-
-    public void setRegisterDate(Date registerDate) {
-        this.registerDate = registerDate;
-    }
-
     public String getEmail() {
         return email;
     }
@@ -210,4 +178,12 @@ public class UserView {
     public void setLock(Integer lock) {
         this.lock = lock;
     }
+
+    public String getImId() {
+        return imId;
+    }
+
+    public void setImId(String imId) {
+        this.imId = imId;
+    }
 }

+ 0 - 118
sso-common/src/main/java/com/uas/sso/support/Page.java

@@ -1,118 +0,0 @@
-package com.uas.sso.support;
-
-import java.io.Serializable;
-import java.util.List;
-
-public class Page<T> implements Serializable {
-
-	/**
-	 * 
-	 */
-	private static final long serialVersionUID = 1L;
-
-    /**
-     * 页数
-     */
-	private int number;
-
-    /**
-     * 每页大小
-     */
-    private int size;
-
-    /**
-     * 获取数据数量
-     */
-    private int numberOfElements;
-
-    /**
-     * 数据
-     */
-    private List<T> content;
-
-    /**
-     * 是否为第一页
-     */
-    private boolean first;
-
-    /**
-     * 是否为最后一页
-     */
-    private boolean last;
-
-    /**
-     * 总页数
-     */
-    private long totalElements;
-
-	public Page() {
-
-	}
-
-	public Page(int pageNumber, int pageSize, List<T> content, int totalElements) {
-		this.number = pageNumber;
-		this.size = pageSize;
-		this.content = content;
-		this.numberOfElements = content == null || content.isEmpty() ? 0 : content.size();
-		this.totalElements = totalElements;
-		this.first = pageNumber == 1;
-		this.last = pageNumber >= (int) Math.floor((double) totalElements / pageSize);
-	}
-
-	public int getNumber() {
-		return number;
-	}
-
-	public void setNumber(int number) {
-		this.number = number;
-	}
-
-	public int getSize() {
-		return size;
-	}
-
-	public void setSize(int size) {
-		this.size = size;
-	}
-
-	public int getNumberOfElements() {
-		return numberOfElements;
-	}
-
-	public void setNumberOfElements(int numberOfElements) {
-		this.numberOfElements = numberOfElements;
-	}
-
-	public List<T> getContent() {
-		return content;
-	}
-
-	public void setContent(List<T> content) {
-		this.content = content;
-	}
-
-	public boolean isFirst() {
-		return first;
-	}
-
-	public void setFirst(boolean first) {
-		this.first = first;
-	}
-
-	public boolean isLast() {
-		return last;
-	}
-
-	public void setLast(boolean last) {
-		this.last = last;
-	}
-
-	public long getTotalElements() {
-		return totalElements;
-	}
-
-	public void setTotalElements(long totalElements) {
-		this.totalElements = totalElements;
-	}
-
-}

+ 38 - 0
sso-common/src/main/java/com/uas/sso/support/PageInfo.java

@@ -0,0 +1,38 @@
+package com.uas.sso.support;
+
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageImpl;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Pageable;
+
+import java.util.List;
+
+/**
+ * @author wangmh
+ * @create 2018-02-09 16:51
+ * @desc 分页
+ **/
+public class PageInfo<T> extends PageImpl<T> implements Page<T> {
+
+    public PageInfo(List<T> content, Pageable pageable, long total) {
+        super(content, pageable, total);
+    }
+
+    public PageInfo(List<T> content) {
+        super(content);
+    }
+
+    /**
+     * 获取pageable,将当前页减1
+     * @param pageable
+     * @return
+     */
+    public static Pageable pageRequest(Pageable pageable) {
+        return new PageRequest(pageable.getPageNumber() - 1, pageable.getPageSize(), pageable.getSort());
+    }
+
+    @Override
+    public int getNumber() {
+        return super.getNumber() + 1;
+    }
+}

+ 78 - 95
sso-common/src/main/java/com/uas/sso/util/AccountUtils.java

@@ -82,7 +82,7 @@ public class AccountUtils {
      * @param spaceUU 企业uu号
      * @throws Exception
      */
-    public static void unbindUserSpace(Long userUU, Long spaceUU) throws Exception {
+    public static void removeUser(Long userUU, Long spaceUU) throws Exception {
         String saveUrl = AccountConfig.getUserSaveUrl();
         if (!StringUtils.isEmpty(saveUrl)) {
             ModelMap formData = new ModelMap();
@@ -107,7 +107,7 @@ public class AccountUtils {
      * @param spaceUU 企业uu号
      * @throws Exception
      */
-    public static void bindUserSpace(Long userUU, Long spaceUU) throws Exception {
+    public static void addUser(Long userUU, Long spaceUU) throws Exception {
         String saveUrl = AccountConfig.getUserSaveUrl();
         if (!StringUtils.isEmpty(saveUrl)) {
             ModelMap formData = new ModelMap();
@@ -131,7 +131,7 @@ public class AccountUtils {
      * @param businessCode 营业执照号
      * @return
      */
-    public List<UserSpaceView> findByBusinessCode(String businessCode) throws Exception {
+    public UserSpaceView findByBusinessCode(String businessCode) throws Exception {
         String saveUrl = AccountConfig.getSpaceSaveUrl();
         if (!StringUtils.isEmpty(saveUrl)) {
             ModelMap formData = new ModelMap();
@@ -145,7 +145,7 @@ public class AccountUtils {
                 if (!result.isSuccess()) {
                     throw new Exception(result.getErrMsg());
                 } else if (result.getContent() != null){
-                    return JSON.parseArray(result.getContent().toString(), UserSpaceView.class);
+                    return JSON.parseObject(result.getContent().toString(), UserSpaceView.class);
                 }
             }
         }
@@ -153,11 +153,11 @@ public class AccountUtils {
     }
 
     /**
-     * 根据营业执照号获得企业信息
-     * @param spaceName 营业执照号
+     * 根据企业名获得企业信息
+     * @param spaceName 企业名
      * @return
      */
-    public List<UserSpaceView> findBySpaceName(String spaceName) throws Exception {
+    public UserSpaceView findBySpaceName(String spaceName) throws Exception {
         String saveUrl = AccountConfig.getSpaceSaveUrl();
         if (!StringUtils.isEmpty(saveUrl)) {
             ModelMap formData = new ModelMap();
@@ -171,7 +171,7 @@ public class AccountUtils {
                 if (!result.isSuccess()) {
                     throw new Exception(result.getErrMsg());
                 } else if (result.getContent() != null){
-                    return JSON.parseArray(result.getContent().toString(), UserSpaceView.class);
+                    return JSON.parseObject(result.getContent().toString(), UserSpaceView.class);
                 }
             }
         }
@@ -240,7 +240,7 @@ public class AccountUtils {
     }
 
     /**
-     * 统计该企业审批记录数量
+     * 统计该企业申请记录数量
      * @param spaceUU 企业uu号
      * @return
      * @throws Exception
@@ -338,7 +338,7 @@ public class AccountUtils {
     }
 
     /**
-     * 根据用户uu号获取用户信息
+     * 根据企业uu号获取企业信息
      * @param spaceUU 企业uu号
      * @return
      * @throws Exception
@@ -827,91 +827,74 @@ public class AccountUtils {
 		}
 	}
 
-//	/**
-//	 * ERP、SAAS新开账套名称校验
-//	 *
-//	 * @param name
-//	 * @return
-//	 * @throws Exception
-//	 */
-//	public static String validName(String name) throws Exception {
-//		String result = null;
-//		String url = AccountConfig.getSpaceSaveUrl();
-//		if (!StringUtils.isEmpty(url)) {
-//			ResponseWrap res = HttpUtil.doGet(url, new ModelMap("_operate", "validName").addAttribute("name", name),
-//					50);
-//			if (!res.isSuccess())
-//				throw new Exception(res.getContent());
-//			else
-//				result = res.getContent();
-//		}
-//		return result;
-//	}
-//
-//	/**
-//	 * ERP、SAAS新开账套名称校验
-//	 *
-//	 * @param businessCode
-//	 * @return
-//	 * @throws Exception
-//	 */
-//	public static String validBusinessCode(String businessCode) throws Exception {
-//		String result = null;
-//		String url = AccountConfig.getSpaceSaveUrl();
-//		if (!StringUtils.isEmpty(url)) {
-//			ResponseWrap res = HttpUtil.doGet(url,
-//					new ModelMap("_operate", "validBusinessCode").addAttribute("businessCode", businessCode), 50);
-//			if (!res.isSuccess())
-//				throw new Exception(res.getContent());
-//			else
-//				result = res.getContent();
-//		}
-//		return result;
-//	}
-//
-//	/**
-//	 * 通过营业执照号查找 企业详细信息
-//	 *
-//	 * @param
-//	 * @return
-//	 * @throws Exception
-//	 */
-//	public static UserSpaceDetail findByBusinessCode(String businessCode) throws Exception {
-//		String result = null;
-//		String url = AccountConfig.getSpaceSaveUrl();
-//		if (!StringUtils.isEmpty(url)) {
-//			ResponseWrap res = HttpUtil.doGet(url,
-//					new ModelMap("_operate", "findByBusinessCode").addAttribute("businessCode", businessCode), 50);
-//			if (!res.isSuccess())
-//				throw new Exception(res.getContent());
-//			else
-//				result = res.getContent();
-//		}
-//		return JSON.parseObject(result,UserSpaceDetail.class);
-//	}
-//
-//	/**
-//	 * ERP、SAAS新开账套
-//	 *
-//	 * @param userSpaceDetail
-//	 * @param users
-//	 * @throws Exception
-//	 */
-//	public static String applyApp(UserSpaceDetail userSpaceDetail, List<UserDetail> users) throws Exception {
-//		String url = AccountConfig.getSpaceSaveUrl();
-//		String result = null;
-//		if (!StringUtils.isEmpty(url)) {
-//			ResponseWrap res = HttpUtil.doPost(url, new ModelMap("_operate", "registerBranchAccount")
-//							.addAttribute("detail", JSON.toJSON(userSpaceDetail))
-//							.addAttribute("userInfos", JSON.toJSON(users)));
-//			if (!res.isSuccess())
-//				throw new Exception(res.getContent());
-//			else
-//				result = res.getContent();
-//		}
-//		return result;
-//	}
-//
+	/**
+	 * ERP、SAAS新开账套名称校验
+	 *
+	 * @param name
+	 * @return
+	 * @throws Exception
+	 */
+	public static String validName(String name) throws Exception {
+		String result = null;
+		String url = AccountConfig.getSpaceSaveUrl();
+		if (!StringUtils.isEmpty(url)) {
+			HttpUtil.ResponseWrap res = HttpUtil.doGet(url, new ModelMap("_operate", "validName").addAttribute("name", name),
+					50);
+			if (!res.isSuccess()) {
+                throw new Exception(res.getContent());
+            } else {
+                result = res.getContent();
+            }
+		}
+		return result;
+	}
+
+	/**
+	 * ERP、SAAS新开账套名称校验
+	 *
+	 * @param businessCode
+	 * @return
+	 * @throws Exception
+	 */
+	public static String validBusinessCode(String businessCode) throws Exception {
+		String result = null;
+		String url = AccountConfig.getSpaceSaveUrl();
+		if (!StringUtils.isEmpty(url)) {
+			HttpUtil.ResponseWrap res = HttpUtil.doGet(url,
+					new ModelMap("_operate", "validBusinessCode").addAttribute("businessCode", businessCode), 50);
+			if (!res.isSuccess()) {
+                throw new Exception(res.getContent());
+            } else {
+                result = res.getContent();
+            }
+		}
+		return result;
+	}
+
+
+	/**
+	 * ERP、SAAS新开账套
+	 *
+	 * @param userSpaceDetail
+	 * @param users
+	 * @throws Exception
+	 */
+	public static String applyApp(UserSpaceView userSpaceDetail, List<UserView> users) throws Exception {
+		String url = AccountConfig.getSpaceSaveUrl();
+		String result = null;
+		if (!StringUtils.isEmpty(url)) {
+			HttpUtil.ResponseWrap res = HttpUtil.doPost(url, new ModelMap("_operate", "registerBranchAccount")
+							.addAttribute("detail", JSON.toJSON(userSpaceDetail))
+							.addAttribute("userInfos", JSON.toJSON(users)));
+			if (!res.isSuccess()) {
+                throw new Exception(res.getContent());
+            } else {
+                result = res.getContent();
+            }
+		}
+		return result;
+	}
+
 //	/**
 //	 * 商城个人账号增加企业注册
 //	 *

+ 36 - 0
sso-common/src/test/java/test/Test.java

@@ -0,0 +1,36 @@
+package test;
+
+import com.alibaba.fastjson.JSON;
+import com.uas.sso.ResultWrap;
+import com.uas.sso.common.util.HttpUtil;
+import com.uas.sso.entity.UserView;
+import org.springframework.ui.ModelMap;
+
+import static com.alibaba.fastjson.JSON.parseObject;
+
+/**
+ * @author wangmh
+ * @create 2018-02-09 14:03
+ * @desc 测试
+ **/
+public class Test {
+
+    public static void main(String[] args) throws Exception {
+        String url = "http://192.168.253.66:8081/api/user";
+        url = url + "/info";
+        ModelMap data = new ModelMap();
+        data.put("userUU", 10000L);
+        HttpUtil.ResponseWrap res = HttpUtil.doGet(url, data);
+        if (!res.isSuccess()) {
+            throw new Exception(res.getContent());
+        } else {
+            ResultWrap result = parseObject(res.getContent(), ResultWrap.class);
+            if (!result.isSuccess()) {
+                throw new Exception(result.getErrMsg());
+            } else if (result.getContent() != null) {
+                UserView userView =  JSON.parseObject(result.getContent().toString(), UserView.class);
+                System.out.println(userView);
+            }
+        }
+    }
+}

+ 4 - 1
sso-server/src/main/java/com/uas/sso/controller/AppealController.java

@@ -84,6 +84,9 @@ public class AppealController extends BaseController {
     public ModelMap resetPwd(Appeal appeal, @RequestParam String token, String code, String password) {
         // 获取申述人,将修改的账号作为申述人
         User user = userService.findByMobile(appeal.getMobile());
+        if (user == null) {
+            return error("该手机号未注册");
+        }
         Long submitterUU = user.getUserUU();
 
         // 校验token
@@ -124,7 +127,7 @@ public class AppealController extends BaseController {
 
         // 保存申述信息,把新管理员当作申请人
         User submitter = userService.findByMobile(appeal.getMobile());
-        appeal.setSubmitterUU(submitter.getUserUU());
+        appeal.setSubmitterUU(submitter == null ? null : submitter.getUserUU());
         appealService.submitChangeAdmin(appeal, userspace, checkSpace.getSpaceUU());
         return success();
     }

+ 1 - 1
sso-server/src/main/java/com/uas/sso/controller/LoginController.java

@@ -359,7 +359,7 @@ public class LoginController extends BaseController {
         if (StringUtils.isEmpty(username)) {
             return error("用户名不能为空");
         }
-        return success(userService.getPwdErrorCount(username));
+        return success(userService.getPwdErrorCount(username.trim()));
     }
 
     /**

+ 30 - 0
sso-server/src/main/java/com/uas/sso/controller/UserspaceManagerController.java

@@ -13,11 +13,13 @@ import com.uas.sso.util.FileUrl;
 import com.uas.sso.util.HttpUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.ui.ModelMap;
+import org.springframework.util.CollectionUtils;
 import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.io.UnsupportedEncodingException;
+import java.util.Arrays;
 import java.util.List;
 
 /**
@@ -298,4 +300,32 @@ public class UserspaceManagerController extends BaseController {
         info.setEnuu(userspace.getSpaceUU() + "");
         return info;
     }
+
+    /**
+     * 根据用户的手机号查询企业信息和个人信息
+     *
+     * @param tel 手机号集合,逗号分隔
+     * @return keys:{listdata:数据}
+     */
+    @RequestMapping(value = "/userInfos", method = RequestMethod.GET)
+    public ModelMap getUserInfos(String tel) {
+        List<String> tels = Arrays.asList(tel.split(","));
+        return CollectionUtils.isEmpty(tels) ? new ModelMap("listdata", "请先输入电话号码")
+                : new ModelMap("listdata", userspaceService.findSpaceByTels(tels));
+    }
+
+    /**
+     * 通过企业名称查询企业相关信息
+     *
+     * @param keyword 企业名关键字
+     * @param pageNumber 企业名关键字
+     * @param pageSize 企业名关键字
+     * @return keys:{listdata:数据}
+     */
+    @RequestMapping(value = "/userSpaceDetail/keyword", method = RequestMethod.GET)
+    @ResponseBody
+    public ModelMap getUserSpaceDetailByKeyword(String keyword, @RequestParam(defaultValue = "1") Integer pageNumber, @RequestParam(defaultValue = "30") Integer pageSize) {
+        return StringUtils.isEmpty(keyword) ? new ModelMap("listdata", "请先输入企业名称")
+                : new ModelMap("listdata", userspaceService.findByKeyword(keyword, pageNumber, pageSize).getContent());
+    }
 }

+ 2 - 2
sso-server/src/main/java/com/uas/sso/controller/YunCenterController.java

@@ -81,7 +81,7 @@ public class YunCenterController extends BaseController {
      */
     @RequestMapping(value = "/apply/info", method = RequestMethod.GET)
     @ResponseBody
-    public ModelMap findApplyAll(@RequestParam(defaultValue = "0") int page, @RequestParam(defaultValue = "20") int size) {
+    public ModelMap findApplyAll(@RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "20") int size) {
         UserAccount userAccount = SystemSession.getUserAccount();
         if (userAccount.getSpaceUU() == null) {
             return error(Const.SPACEUU_PERSONAL+"", "个人账号");
@@ -99,7 +99,7 @@ public class YunCenterController extends BaseController {
      */
     @RequestMapping(value = "/member/info", method = RequestMethod.GET)
     @ResponseBody
-    public ModelMap findMemberAll(@RequestParam(defaultValue = "0") int page, @RequestParam(defaultValue = "20") int size) {
+    public ModelMap findMemberAll(@RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "20") int size) {
         UserAccount userAccount = getLoginUser();
         if (userAccount.getSpaceUU() == null) {
             return error(Const.SPACEUU_PERSONAL+"", "个人账号");

+ 11 - 0
sso-server/src/main/java/com/uas/sso/dao/UserspaceDao.java

@@ -1,5 +1,6 @@
 package com.uas.sso.dao;
 
+import com.uas.sso.entity.UserSpaceDetailInfo;
 import com.uas.sso.entity.Userspace;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
@@ -78,4 +79,14 @@ public interface UserspaceDao extends JpaRepository<Userspace, Long>, JpaSpecifi
     @Query(value = "select t.spaceName from Userspace t where UPPER(t.spaceName) like CONCAT('%',UPPER(:keyword),'%')",
             countQuery = "select count(t) from Userspace t where UPPER(t.spaceName) like CONCAT('%',UPPER(:keyword),'%')")
     Page<String> findByPageInfo(@Param("keyword") String keyword, Pageable pageable);
+
+    /**
+     * uu互联接口,根据关键字查询
+     * @param keyword 企业名关键字
+     * @param pageable 分页信息
+     * @return
+     */
+    @QueryHints({ @QueryHint(name = "org.hibernate.cacheable", value = "true") })
+    @Query(value = "select new com.uas.sso.entity.UserSpaceDetailInfo(t.spaceName, t.regAddress, t.admin.vipName, t.admin.mobile, t.admin.imId, t.admin.email) from Userspace t where UPPER(t.spaceName) like CONCAT('%',UPPER(:keyword),'%')")
+    Page<UserSpaceDetailInfo> findInfoByPageInfo(@Param("keyword") String keyword, Pageable pageable);
 }

+ 1 - 1
sso-server/src/main/java/com/uas/sso/entity/Appeal.java

@@ -54,7 +54,7 @@ public class Appeal implements Serializable {
     /**
      * 申请人uu号
      */
-    @Column(name = "submitter_uu", nullable = false)
+    @Column(name = "submitter_uu")
     private Long submitterUU;
 
     /**

+ 11 - 4
sso-server/src/main/java/com/uas/sso/entity/PageInfo.java

@@ -1,9 +1,6 @@
 package com.uas.sso.entity;
 
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.PageImpl;
-import org.springframework.data.domain.PageRequest;
-import org.springframework.data.domain.Pageable;
+import org.springframework.data.domain.*;
 
 import java.util.List;
 
@@ -35,4 +32,14 @@ public class PageInfo<T> extends PageImpl<T> implements Page<T> {
     public static Pageable pageRequest(Pageable pageable) {
         return new PageRequest(pageable.getPageNumber() - 1, pageable.getPageSize(), pageable.getSort());
     }
+
+    /**
+     * 前台传参1为起始页修改为spring data jpa的0为起始页
+     * @param pageNumber 页号
+     * @param pageSize 每页大小
+     * @return
+     */
+    public static Pageable pageRequest(int pageNumber, int pageSize) {
+        return new PageRequest(pageNumber - 1, pageSize);
+    }
 }

+ 2 - 4
sso-server/src/main/java/com/uas/sso/entity/User.java

@@ -462,19 +462,17 @@ public class User implements Serializable {
     public UserView toView() {
         UserView userView = new UserView();
         userView.setUserUU(this.getUserUU());
-        userView.setVipName(this.getVipName());
+        userView.setName(this.getVipName());
         userView.setMobile(this.getMobile());
         userView.setMobileArea(this.getMobileArea());
         userView.setMobileValidCode(this.getMobileValidCode());
-        userView.setPassword(this.getPassword());
-        userView.setSalt(this.getSalt());
-        userView.setRegisterDate(this.getRegisterDate());
         userView.setEmail(this.getEmail());
         userView.setEmailValidCode(this.getEmailValidCode());
         userView.setRealName(this.getRealName());
         userView.setIdCard(this.getIdCard());
         userView.setIdentityValidCode(this.getIdentityValidCode());
         userView.setLock(this.getLock());
+        userView.setImId(this.getImId());
         return userView;
     }
 }

+ 100 - 0
sso-server/src/main/java/com/uas/sso/entity/UserSpaceDetailInfo.java

@@ -0,0 +1,100 @@
+package com.uas.sso.entity;
+
+
+/**
+ * uu互联企业信息实体
+ * @author wangmh copy by hejq
+ */
+public class UserSpaceDetailInfo {
+
+	/**
+	 * 企业名称
+	 */
+	private String company;
+
+	/**
+	 * 地址
+	 */
+	private String address;
+
+	/**
+	 * 管理员姓名
+	 */
+	private String username;
+
+	/**
+	 * 管理员电话
+	 */
+	private String usertel;
+
+	/**
+	 * 管理员imid
+	 */
+	private String imid;
+
+	/**
+	 * 管理员邮箱
+	 */
+	private String email;
+
+	public UserSpaceDetailInfo() {
+	}
+
+	public UserSpaceDetailInfo(String company, String address, String username, String usertel, String imid, String email) {
+		this.company = company;
+		this.address = address;
+		this.username = username;
+		this.usertel = usertel;
+		this.imid = imid;
+		this.email = email;
+	}
+
+	public String getCompany() {
+		return company;
+	}
+
+	public void setCompany(String company) {
+		this.company = company;
+	}
+
+	public String getAddress() {
+		return address;
+	}
+
+	public void setAddress(String address) {
+		this.address = address;
+	}
+
+	public String getUsername() {
+		return username;
+	}
+
+	public void setUsername(String username) {
+		this.username = username;
+	}
+
+	public String getUsertel() {
+		return usertel;
+	}
+
+	public void setUsertel(String usertel) {
+		this.usertel = usertel;
+	}
+
+	public String getImid() {
+		return imid;
+	}
+
+	public void setImid(String imid) {
+		this.imid = imid;
+	}
+
+	public String getEmail() {
+		return email;
+	}
+
+	public void setEmail(String email) {
+		this.email = email;
+	}
+
+}

+ 18 - 0
sso-server/src/main/java/com/uas/sso/service/UserspaceService.java

@@ -1,11 +1,13 @@
 package com.uas.sso.service;
 
 import com.uas.sso.entity.User;
+import com.uas.sso.entity.UserSpaceDetailInfo;
 import com.uas.sso.entity.UserSpaceView;
 import com.uas.sso.entity.Userspace;
 import org.springframework.data.domain.Page;
 
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 /**
@@ -126,4 +128,20 @@ public interface UserspaceService {
      * @param users 用户信息
      */
     void addUser(Userspace userspace, List<User> users);
+
+    /**
+     * uu互联接口,通过手机号查询随机一个企业信息和个人的相关信息
+     * @param tels 手机号集合
+     * @return UserSpaceDetailInfo
+     */
+    List<UserSpaceDetailInfo> findSpaceByTels(List<String> tels);
+
+    /**
+     * uu互联接口,通过企业名称查询企业相关信息
+     * @param keyword 关键词
+     * @param page 页号
+     * @param size 每页大小
+     * @return
+     */
+    Page<UserSpaceDetailInfo> findByKeyword(String keyword, int page, int size);
 }

+ 7 - 7
sso-server/src/main/java/com/uas/sso/service/impl/ApplyUserSpaceServiceImpl.java

@@ -68,7 +68,7 @@ public class ApplyUserSpaceServiceImpl implements ApplyUserSpaceService {
         }
 
         // 判断是否已申请
-        List<ApplyUserSpace> applyUserSpaces = applyUserSpaceDao.findByUserUUAndSpaceUUAndStatus(user.getUserUU(), userspace.getSpaceUU(), Status.UNAUDIT.getCode());
+        List<ApplyUserSpace> applyUserSpaces = applyUserSpaceDao.findByUserUUAndSpaceUUAndStatus(user.getUserUU(), userspace.getSpaceUU(), Status.TO_BE_CERTIFIED.getCode());
         if (!CollectionUtils.isEmpty(applyUserSpaces)) {
             throw new VisibleError("你已申请该企业,请耐心等待管理员审核");
         }
@@ -80,7 +80,7 @@ public class ApplyUserSpaceServiceImpl implements ApplyUserSpaceService {
 
     @Override
     public Page<ApplyUserSpace> findApplyAll(Integer pageNumber, Integer pageSize, Long spaceUU) {
-        Pageable pageable = new PageRequest(pageNumber, pageSize);
+        Pageable pageable = PageInfo.pageRequest(new PageRequest(pageNumber, pageSize));
         Page<ApplyUserSpace> page = applyUserSpaceDao.findAll(new Specification<ApplyUserSpace>() {
             @Override
             public Predicate toPredicate(Root<ApplyUserSpace> root,
@@ -92,8 +92,7 @@ public class ApplyUserSpaceServiceImpl implements ApplyUserSpaceService {
                 return cb.and(predicates);
             }
         }, pageable);
-
-        return page;
+        return new PageInfo<>(page.getContent(), pageable, page.getTotalElements());
     }
 
     @Override
@@ -108,8 +107,8 @@ public class ApplyUserSpaceServiceImpl implements ApplyUserSpaceService {
 
     @Override
     public Page<ApplyUserSpace> findUserApply(Integer pageNumber, Integer pageSize, Long userUU) {
-        Pageable pageable = new PageRequest(pageNumber, pageSize);
-        return applyUserSpaceDao.findAll(new Specification<ApplyUserSpace>() {
+        Pageable pageable = PageInfo.pageRequest(new PageRequest(pageNumber, pageSize));
+        Page<ApplyUserSpace> page =  applyUserSpaceDao.findAll(new Specification<ApplyUserSpace>() {
             @Override
             public Predicate toPredicate(Root<ApplyUserSpace> root,
                                          CriteriaQuery<?> query, CriteriaBuilder cb) {
@@ -120,6 +119,7 @@ public class ApplyUserSpaceServiceImpl implements ApplyUserSpaceService {
                 return cb.and(predicates);
             }
         }, pageable);
+        return new PageInfo<>(page.getContent(), pageable, page.getTotalElements());
     }
 
     @Override
@@ -182,6 +182,6 @@ public class ApplyUserSpaceServiceImpl implements ApplyUserSpaceService {
                 return cb.and(predicates);
             }
         }, pageable);
-        return pApply;
+        return new PageInfo<>(pApply.getContent(), pageable, pApply.getTotalElements());
     }
 }

+ 2 - 2
sso-server/src/main/java/com/uas/sso/service/impl/UserServiceImpl.java

@@ -332,7 +332,7 @@ public class UserServiceImpl implements UserService {
 
     @Override
     public Page<User> findMemberBySpaceUU(int page, int size, Long spaceUU) {
-        Pageable pageable = new PageRequest(page, size);
+        Pageable pageable = PageInfo.pageRequest(new PageRequest(page, size));
         Page<User> pUsers = userDao.findAll(new Specification<User>() {
             @Override
             public Predicate toPredicate(Root<User> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
@@ -343,7 +343,7 @@ public class UserServiceImpl implements UserService {
                 return cb.and(predicates);
             }
         }, pageable);
-        return pUsers;
+        return new PageInfo<User>(pUsers.getContent(), pageable, pUsers.getTotalElements());
     }
 
     @Override

+ 33 - 7
sso-server/src/main/java/com/uas/sso/service/impl/UserspaceServiceImpl.java

@@ -6,10 +6,7 @@ import com.uas.sso.common.util.HttpUtil;
 import com.uas.sso.core.ICallable;
 import com.uas.sso.core.Status;
 import com.uas.sso.dao.UserspaceDao;
-import com.uas.sso.entity.App;
-import com.uas.sso.entity.User;
-import com.uas.sso.entity.UserSpaceView;
-import com.uas.sso.entity.Userspace;
+import com.uas.sso.entity.*;
 import com.uas.sso.exception.VisibleError;
 import com.uas.sso.logging.LoggerManager;
 import com.uas.sso.logging.SyncBufferedLogger;
@@ -24,14 +21,13 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.data.domain.Pageable;
+import org.springframework.security.access.method.P;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.StringUtils;
 
 import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
 
 /**
  * 企业信息service层
@@ -289,4 +285,34 @@ public class UserspaceServiceImpl implements UserspaceService {
         userspace.getUsers().addAll(users);
         userspaceDao.save(userspace);
     }
+
+    @Override
+    public List<UserSpaceDetailInfo> findSpaceByTels(List<String> tels) {
+        List<UserSpaceDetailInfo> data = new ArrayList<>(tels.size());
+        UserSpaceDetailInfo info = new UserSpaceDetailInfo();
+        for (String tel : tels) {
+            User user = userService.findByMobile(tel);
+            info.setUsertel(user.getMobile());
+            if (user != null) {
+                info.setUsername(user.getVipName());
+                info.setImid(user.getImId());
+                info.setEmail(user.getEmail());
+                if (!CollectionUtils.isEmpty(user.getUserSpaces())) {
+                    Iterator<Userspace> iterator = user.getUserSpaces().iterator();
+                    Userspace userspace = iterator.next();
+                    info.setCompany(userspace.getSpaceName());
+                    info.setAddress(userspace.getRegAddress());
+                }
+            }
+            data.add(info);
+        }
+        return data;
+    }
+
+    @Override
+    public Page<UserSpaceDetailInfo> findByKeyword(String keyword, int pageNumber, int pageSize) {
+        Pageable pageable = PageInfo.pageRequest(pageNumber, pageSize);
+        Page<UserSpaceDetailInfo> page = userspaceDao.findInfoByPageInfo(keyword, pageable);
+        return new PageInfo<>(page.getContent(), pageable, page.getTotalElements());
+    }
 }