From 1e02ef2f319fd4dee7866841cba6a525b7a5843a Mon Sep 17 00:00:00 2001 From: wenc000 <450292408@qq.com> Date: Fri, 2 Aug 2019 14:15:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9EToken=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=86=85=E5=AE=B9=EF=BC=8C=E4=BF=AE=E6=94=B9HashMap=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E7=B1=BB=EF=BC=8C=E6=96=B0=E5=A2=9ETokenException?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cm/common/exception/TokenException.java | 36 ++++++++ .../common/token/app/entity/AppTokenUser.java | 88 +++++++++++++++++++ .../java/com/cm/common/utils/HashMapUtil.java | 6 +- 3 files changed, 127 insertions(+), 3 deletions(-) create mode 100644 cloud-common/src/main/java/com/cm/common/exception/TokenException.java create mode 100644 cloud-common/src/main/java/com/cm/common/token/app/entity/AppTokenUser.java diff --git a/cloud-common/src/main/java/com/cm/common/exception/TokenException.java b/cloud-common/src/main/java/com/cm/common/exception/TokenException.java new file mode 100644 index 0000000..807be42 --- /dev/null +++ b/cloud-common/src/main/java/com/cm/common/exception/TokenException.java @@ -0,0 +1,36 @@ +package com.cm.common.exception; + +import com.cm.common.exception.base.SystemException; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: TokenException + * @Description: token异常 + * @Author: WangGeng + * @Date: 2019-08-02 12:57 + * @Version: 1.0 + **/ +public class TokenException extends SystemException { + + public TokenException() { + super(); + } + + public TokenException(String message) { + super(message); + } + + public TokenException(String message, boolean withMsg) { + super(message, withMsg); + } + + public TokenException(String message, Throwable cause) { + super(message, cause); + } + + public TokenException(Throwable cause) { + super(cause); + } +} diff --git a/cloud-common/src/main/java/com/cm/common/token/app/entity/AppTokenUser.java b/cloud-common/src/main/java/com/cm/common/token/app/entity/AppTokenUser.java new file mode 100644 index 0000000..66d015f --- /dev/null +++ b/cloud-common/src/main/java/com/cm/common/token/app/entity/AppTokenUser.java @@ -0,0 +1,88 @@ +package com.cm.common.token.app.entity; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: UserInfo + * @Description: + * @Author: WangGeng + * @Date: 2019-08-02 11:20 + * @Version: 1.0 + **/ +public class AppTokenUser { + + private String id; + private String name; + private String avatar; + private String username; + private String phone; + private String email; + + public String getId() { + return id == null ? "" : id.trim(); + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name == null ? "" : name.trim(); + } + + public void setName(String name) { + this.name = name; + } + + public String getAvatar() { + return avatar == null ? "" : avatar.trim(); + } + + public void setAvatar(String avatar) { + this.avatar = avatar; + } + + public String getUsername() { + return username == null ? "" : username.trim(); + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPhone() { + return phone == null ? "" : phone.trim(); + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getEmail() { + return email == null ? "" : email.trim(); + } + + public void setEmail(String email) { + this.email = email; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("{"); + sb.append("\"id\":") + .append("\"").append(id).append("\""); + sb.append(",\"name\":") + .append("\"").append(name).append("\""); + sb.append(",\"avatar\":") + .append("\"").append(avatar).append("\""); + sb.append(",\"username\":") + .append("\"").append(username).append("\""); + sb.append(",\"phone\":") + .append("\"").append(phone).append("\""); + sb.append(",\"email\":") + .append("\"").append(email).append("\""); + sb.append('}'); + return sb.toString(); + } +} diff --git a/cloud-common/src/main/java/com/cm/common/utils/HashMapUtil.java b/cloud-common/src/main/java/com/cm/common/utils/HashMapUtil.java index 94bc76e..9ffd290 100644 --- a/cloud-common/src/main/java/com/cm/common/utils/HashMapUtil.java +++ b/cloud-common/src/main/java/com/cm/common/utils/HashMapUtil.java @@ -101,7 +101,7 @@ public class HashMapUtil { * @param object * @return */ - private static Map mapObjToMap(Object object) { + public static Map mapObjToMap(Object object) { Map result = new HashMap<>(); Map map = (Map) object; for (Entry entry : map.entrySet()) { @@ -119,7 +119,7 @@ public class HashMapUtil { * @return * @throws Exception */ - private static Map beanToMap(Object object) throws Exception { + public static Map beanToMap(Object object) throws Exception { Map result = null; BeanInfo beanInfo = Introspector.getBeanInfo(object.getClass()); PropertyDescriptor[] properties = beanInfo.getPropertyDescriptors(); @@ -144,7 +144,7 @@ public class HashMapUtil { * @return * @throws Exception */ - private static Map beanToMapString(Object object) throws Exception { + public static Map beanToMapString(Object object) throws Exception { Map result = null; BeanInfo beanInfo = Introspector.getBeanInfo(object.getClass()); PropertyDescriptor[] properties = beanInfo.getPropertyDescriptors();