新增Token管理内容,修改HashMap工具类,新增TokenException异常类

This commit is contained in:
wenc000 2019-08-02 14:15:07 +08:00
parent dbaf2cda60
commit 1e02ef2f31
3 changed files with 127 additions and 3 deletions

View File

@ -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);
}
}

View File

@ -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();
}
}

View File

@ -101,7 +101,7 @@ public class HashMapUtil {
* @param object
* @return
*/
private static Map<String, Object> mapObjToMap(Object object) {
public static Map<String, Object> mapObjToMap(Object object) {
Map<String, Object> 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<String, Object> beanToMap(Object object) throws Exception {
public static Map<String, Object> beanToMap(Object object) throws Exception {
Map<String, Object> 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<String, String> beanToMapString(Object object) throws Exception {
public static Map<String, String> beanToMapString(Object object) throws Exception {
Map<String, String> result = null;
BeanInfo beanInfo = Introspector.getBeanInfo(object.getClass());
PropertyDescriptor[] properties = beanInfo.getPropertyDescriptors();