diff --git a/basic-app/pom.xml b/basic-app/pom.xml new file mode 100644 index 00000000..678ae39d --- /dev/null +++ b/basic-app/pom.xml @@ -0,0 +1,19 @@ + + + + wg-basic + ink.wgink + 1.0-SNAPSHOT + + 4.0.0 + + basic-app + + + 8 + 8 + + + \ No newline at end of file diff --git a/basic-app/src/main/java/ink/wgink/app/AppTokenManager.java b/basic-app/src/main/java/ink/wgink/app/AppTokenManager.java new file mode 100644 index 00000000..baab82a0 --- /dev/null +++ b/basic-app/src/main/java/ink/wgink/app/AppTokenManager.java @@ -0,0 +1,154 @@ +package ink.wgink.app; + +import com.alibaba.fastjson.JSONObject; +import com.cm.common.constants.ISystemConstant; +import com.cm.common.enums.AppTokenTypeEnum; +import com.cm.common.exception.TokenException; +import com.cm.common.token.app.entity.AppToken; +import com.cm.common.token.app.entity.AppTokenUser; +import com.cm.common.utils.AesUtil; +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: AppTokenManager + * @Description: AppToken管理 + * @Author: WangGeng + * @Date: 2019-08-02 11:08 + * @Version: 1.0 + **/ +public class AppTokenManager { + + private static final Logger LOG = LoggerFactory.getLogger(AppTokenManager.class); + private static AppTokenManager appTokenManager = AppTokenManagerBuilder.appTokenManager; + private static final Map tokens = new ConcurrentHashMap(); + + private AppTokenManager() { + } + + public static AppTokenManager getInstance() { + return appTokenManager; + } + + /** + * 获取token + * + * @param token + * @return + */ + public AppToken getToken(String token) { + AppToken appToken = tokens.get(token); + if (appToken != null) { + appToken.setLastTime(System.currentTimeMillis()); + } + return appToken; + } + + /** + * 添加token + * + * @param token + * @param type + * @param appTokenUser + */ + public synchronized void addToken(String token, AppTokenTypeEnum appTokenTypeEnum, AppTokenUser appTokenUser) { + AppToken appToken = new AppToken(); + appToken.setToken(token); + appToken.setAppTokenTypeEnum(appTokenTypeEnum); + appToken.setLastTime(System.currentTimeMillis()); + appToken.setAppTokenUser(appTokenUser); + appToken.setUserId(appTokenUser.getId()); + for (Map.Entry kvs : tokens.entrySet()) { + if (StringUtils.equals(appTokenUser.getId(), kvs.getValue().getUserId())) { + tokens.remove(kvs.getValue().getToken()); + break; + } + } + tokens.put(token, appToken); + } + + public AppTokenUser parseToAppTokenUser(String token) throws TokenException { + String userInfo = null; + try { + userInfo = AesUtil.aesCommonDecoder(ISystemConstant.APP_TOKEN_AES_KEY, new String(Base64.decodeBase64(token), "UTF-8")); + } catch (Exception e) { + LOG.error(e.getMessage(), e); + throw new TokenException("Token解码异常"); + } + JSONObject userInfoObj = JSONObject.parseObject(userInfo); + if (userInfoObj == null) { + throw new TokenException("Token非法"); + } + String appTokenSign = userInfoObj.getString(ISystemConstant.APP_TOKEN_SIGN); + if (StringUtils.isBlank(appTokenSign)) { + LOG.debug("Token标识为空"); + throw new TokenException("Token非法"); + } + if (!StringUtils.startsWith(appTokenSign, ISystemConstant.APP_TOKEN_VERIFY)) { + LOG.debug("Token标识开头错误"); + throw new TokenException("Token非法"); + } + String[] appTokenSignArray = appTokenSign.split("_"); + if (appTokenSignArray.length != 3) { + LOG.debug("Token标识格式长度异常,应为3,这里为:{}", appTokenSignArray.length); + throw new TokenException("Token非法"); + } + try { + new Date(Long.parseLong(appTokenSignArray[2])); + } catch (NumberFormatException e) { + e.printStackTrace(); + LOG.debug("Token时间戳异常"); + throw new TokenException("Token非法"); + } + return JSONObject.toJavaObject(userInfoObj, AppTokenUser.class); + } + + /** + * 当前用户列表 + * + * @return + */ + public List listCurrentUsers() { + List users = new ArrayList<>(); + for (Map.Entry kvs : tokens.entrySet()) { + AppToken appToken = kvs.getValue(); + users.add(appToken.getAppTokenUser()); + } + return users; + } + + /** + * 清空超时Token + */ + public synchronized void clearTimeoutToken() { + long currentTime = System.currentTimeMillis(); + List clearTokenKeys = new ArrayList<>(0); + for (Map.Entry kvs : tokens.entrySet()) { + AppToken appToken = kvs.getValue(); + // 超过10分钟 + if (currentTime - appToken.getLastTime() > 600000L) { + clearTokenKeys.add(kvs.getKey()); + } + } + for (String tokenKey : clearTokenKeys) { + tokens.remove(tokenKey); + } + LOG.debug("本次共清理超时Token:{}个", clearTokenKeys.size()); + } + + private static class AppTokenManagerBuilder { + public static final AppTokenManager appTokenManager = new AppTokenManager(); + } + +} diff --git a/basic-app/src/main/java/ink/wgink/app/AppTokenTask.java b/basic-app/src/main/java/ink/wgink/app/AppTokenTask.java new file mode 100644 index 00000000..08780a4f --- /dev/null +++ b/basic-app/src/main/java/ink/wgink/app/AppTokenTask.java @@ -0,0 +1,28 @@ +package ink.wgink.app; + +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: AppTokenTask + * @Description: app token 定时任务 + * @Author: WangGeng + * @Date: 2019-08-10 14:50 + * @Version: 1.0 + **/ +@Component +@Configuration +@EnableScheduling +public class AppTokenTask { + + @Scheduled(cron = "0 0/1 * * * ?") + public void clearAppTokenUser() { + AppTokenManager.getInstance().clearTimeoutToken(); + } + +} diff --git a/basic-app/src/main/java/ink/wgink/app/entity/AppToken.java b/basic-app/src/main/java/ink/wgink/app/entity/AppToken.java new file mode 100644 index 00000000..cb9e50b8 --- /dev/null +++ b/basic-app/src/main/java/ink/wgink/app/entity/AppToken.java @@ -0,0 +1,80 @@ +package ink.wgink.app.entity; + + +import ink.wgink.app.enums.AppTokenTypeEnum; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: TokenInfo + * @Description: token信息 + * @Author: WangGeng + * @Date: 2019-08-02 11:19 + * @Version: 1.0 + **/ +public class AppToken { + + private String token; + private AppTokenTypeEnum appTokenTypeEnum; + private long lastTime; + private String userId; + private AppTokenUser appTokenUser; + + public String getToken() { + return token == null ? "" : token.trim(); + } + + public void setToken(String token) { + this.token = token; + } + + public AppTokenTypeEnum getAppTokenTypeEnum() { + return appTokenTypeEnum; + } + + public void setAppTokenTypeEnum(AppTokenTypeEnum appTokenTypeEnum) { + this.appTokenTypeEnum = appTokenTypeEnum; + } + + public long getLastTime() { + return lastTime; + } + + public void setLastTime(long lastTime) { + this.lastTime = lastTime; + } + + public String getUserId() { + return userId == null ? "" : userId.trim(); + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public AppTokenUser getAppTokenUser() { + return appTokenUser; + } + + public void setAppTokenUser(AppTokenUser appTokenUser) { + this.appTokenUser = appTokenUser; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("{"); + sb.append("\"token\":") + .append("\"").append(token).append("\""); + sb.append(",\"appTokenTypeEnum\":") + .append(appTokenTypeEnum); + sb.append(",\"lastTime\":") + .append(lastTime); + sb.append(",\"userId\":") + .append("\"").append(userId).append("\""); + sb.append(",\"appTokenUser\":") + .append(appTokenUser); + sb.append('}'); + return sb.toString(); + } +} diff --git a/basic-app/src/main/java/ink/wgink/app/entity/AppTokenUser.java b/basic-app/src/main/java/ink/wgink/app/entity/AppTokenUser.java new file mode 100644 index 00000000..89c77661 --- /dev/null +++ b/basic-app/src/main/java/ink/wgink/app/entity/AppTokenUser.java @@ -0,0 +1,134 @@ +package ink.wgink.app.entity; + +import java.util.List; + +/** + * 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; + private List roles; + private List positions; + private List departments; + private List groups; + + 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; + } + + public List getRoles() { + return roles; + } + + public void setRoles(List roles) { + this.roles = roles; + } + + public List getPositions() { + return positions; + } + + public void setPositions(List positions) { + this.positions = positions; + } + + public List getDepartments() { + return departments; + } + + public void setDepartments(List departments) { + this.departments = departments; + } + + public List getGroups() { + return groups; + } + + public void setGroups(List groups) { + this.groups = groups; + } + + @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(",\"roles\":") + .append(roles); + sb.append(",\"positions\":") + .append(positions); + sb.append(",\"departments\":") + .append(departments); + sb.append(",\"groups\":") + .append(groups); + sb.append('}'); + return sb.toString(); + } +} diff --git a/basic-app/src/main/java/ink/wgink/app/entity/AppTokenUserDepartment.java b/basic-app/src/main/java/ink/wgink/app/entity/AppTokenUserDepartment.java new file mode 100644 index 00000000..b3f94237 --- /dev/null +++ b/basic-app/src/main/java/ink/wgink/app/entity/AppTokenUserDepartment.java @@ -0,0 +1,43 @@ +package ink.wgink.app.entity; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: AppTokenUserDepartment + * @Description: 用户部门 + * @Author: WangGeng + * @Date: 2019-08-10 14:21 + * @Version: 1.0 + **/ +public class AppTokenUserDepartment { + private String departmentId; + private String departmentName; + + public String getDepartmentId() { + return departmentId == null ? "" : departmentId.trim(); + } + + public void setDepartmentId(String departmentId) { + this.departmentId = departmentId; + } + + public String getDepartmentName() { + return departmentName == null ? "" : departmentName.trim(); + } + + public void setDepartmentName(String departmentName) { + this.departmentName = departmentName; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("{"); + sb.append("\"departmentId\":") + .append("\"").append(departmentId).append("\""); + sb.append(",\"departmentName\":") + .append("\"").append(departmentName).append("\""); + sb.append('}'); + return sb.toString(); + } +} diff --git a/basic-app/src/main/java/ink/wgink/app/entity/AppTokenUserGroup.java b/basic-app/src/main/java/ink/wgink/app/entity/AppTokenUserGroup.java new file mode 100644 index 00000000..fa24e78d --- /dev/null +++ b/basic-app/src/main/java/ink/wgink/app/entity/AppTokenUserGroup.java @@ -0,0 +1,44 @@ +package ink.wgink.app.entity; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: AppTokenUserGroup + * @Description: 用户组 + * @Author: WangGeng + * @Date: 2020/2/10 9:33 下午 + * @Version: 1.0 + **/ +public class AppTokenUserGroup { + + private String groupId; + private String groupName; + + public String getGroupId() { + return groupId == null ? "" : groupId.trim(); + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + public String getGroupName() { + return groupName == null ? "" : groupName.trim(); + } + + public void setGroupName(String groupName) { + this.groupName = groupName; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("{"); + sb.append("\"groupId\":") + .append("\"").append(groupId).append("\""); + sb.append(",\"groupName\":") + .append("\"").append(groupName).append("\""); + sb.append('}'); + return sb.toString(); + } +} diff --git a/basic-app/src/main/java/ink/wgink/app/entity/AppTokenUserPosition.java b/basic-app/src/main/java/ink/wgink/app/entity/AppTokenUserPosition.java new file mode 100644 index 00000000..78ea249a --- /dev/null +++ b/basic-app/src/main/java/ink/wgink/app/entity/AppTokenUserPosition.java @@ -0,0 +1,44 @@ +package ink.wgink.app.entity; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: AppTokenUserPosition + * @Description: 用户职位 + * @Author: WangGeng + * @Date: 2019-08-10 14:22 + * @Version: 1.0 + **/ +public class AppTokenUserPosition { + + private String positionId; + private String positionName; + + public String getPositionId() { + return positionId == null ? "" : positionId.trim(); + } + + public void setPositionId(String positionId) { + this.positionId = positionId; + } + + public String getPositionName() { + return positionName == null ? "" : positionName.trim(); + } + + public void setPositionName(String positionName) { + this.positionName = positionName; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("{"); + sb.append("\"positionId\":") + .append("\"").append(positionId).append("\""); + sb.append(",\"positionName\":") + .append("\"").append(positionName).append("\""); + sb.append('}'); + return sb.toString(); + } +} diff --git a/basic-app/src/main/java/ink/wgink/app/entity/AppTokenUserRole.java b/basic-app/src/main/java/ink/wgink/app/entity/AppTokenUserRole.java new file mode 100644 index 00000000..55c2c942 --- /dev/null +++ b/basic-app/src/main/java/ink/wgink/app/entity/AppTokenUserRole.java @@ -0,0 +1,44 @@ +package ink.wgink.app.entity; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: AppTokenUserRole + * @Description: 用户角色 + * @Author: WangGeng + * @Date: 2019-08-10 12:25 + * @Version: 1.0 + **/ +public class AppTokenUserRole { + + private String roleId; + private String roleName; + + public String getRoleId() { + return roleId == null ? "" : roleId.trim(); + } + + public void setRoleId(String roleId) { + this.roleId = roleId; + } + + public String getRoleName() { + return roleName == null ? "" : roleName.trim(); + } + + public void setRoleName(String roleName) { + this.roleName = roleName; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("{"); + sb.append("\"roleId\":") + .append("\"").append(roleId).append("\""); + sb.append(",\"roleName\":") + .append("\"").append(roleName).append("\""); + sb.append('}'); + return sb.toString(); + } +} diff --git a/basic-app/src/main/java/ink/wgink/app/enums/AppTokenTypeEnum.java b/basic-app/src/main/java/ink/wgink/app/enums/AppTokenTypeEnum.java new file mode 100644 index 00000000..2e63d88a --- /dev/null +++ b/basic-app/src/main/java/ink/wgink/app/enums/AppTokenTypeEnum.java @@ -0,0 +1,27 @@ +package ink.wgink.app.enums; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: AppTokenTypeEnum + * @Description: appToken类别 + * @Author: WangGeng + * @Date: 2020/3/8 10:09 上午 + * @Version: 1.0 + **/ +public enum AppTokenTypeEnum { + + WECHAT("wechat"), + WECHAT_MINI_APP("wxminiapp"), + APP("app"); + private String type; + + AppTokenTypeEnum(String type) { + this.type = type; + } + + public String getType() { + return type == null ? "" : type.trim(); + } +} diff --git a/basic-exception/pom.xml b/basic-exception/pom.xml new file mode 100644 index 00000000..8baa1f9d --- /dev/null +++ b/basic-exception/pom.xml @@ -0,0 +1,19 @@ + + + + wg-basic + ink.wgink + 1.0-SNAPSHOT + + 4.0.0 + + basic-exception + + + 8 + 8 + + + \ No newline at end of file diff --git a/basic-exception/src/main/java/ink/wgink/exceptions/AccessTokenException.java b/basic-exception/src/main/java/ink/wgink/exceptions/AccessTokenException.java new file mode 100644 index 00000000..905c9581 --- /dev/null +++ b/basic-exception/src/main/java/ink/wgink/exceptions/AccessTokenException.java @@ -0,0 +1,35 @@ +package ink.wgink.exceptions; + + +import ink.wgink.exceptions.base.SystemException; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: AccessTokenException + * @Description: accessToken异常 + * @Author: WangGeng + * @Date: 2019-08-15 18:00 + * @Version: 1.0 + **/ +public class AccessTokenException extends SystemException { + public AccessTokenException() { + } + + public AccessTokenException(String message) { + super(message); + } + + public AccessTokenException(String message, boolean withMsg) { + super(message, withMsg); + } + + public AccessTokenException(String message, Throwable cause) { + super(message, cause); + } + + public AccessTokenException(Throwable cause) { + super(cause); + } +} diff --git a/basic-exception/src/main/java/ink/wgink/exceptions/AppDeviceException.java b/basic-exception/src/main/java/ink/wgink/exceptions/AppDeviceException.java new file mode 100644 index 00000000..758dc327 --- /dev/null +++ b/basic-exception/src/main/java/ink/wgink/exceptions/AppDeviceException.java @@ -0,0 +1,36 @@ +package ink.wgink.exceptions; + + +import ink.wgink.exceptions.base.SystemException; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: AppDeviceException + * @Description: APP设备异常 + * @Author: WangGeng + * @Date: 2019/8/27 11:14 上午 + * @Version: 1.0 + **/ +public class AppDeviceException extends SystemException { + + public AppDeviceException() { + } + + public AppDeviceException(String message) { + super(message); + } + + public AppDeviceException(String message, boolean withMsg) { + super(message, withMsg); + } + + public AppDeviceException(String message, Throwable cause) { + super(message, cause); + } + + public AppDeviceException(Throwable cause) { + super(cause); + } +} diff --git a/basic-exception/src/main/java/ink/wgink/exceptions/AppVersionException.java b/basic-exception/src/main/java/ink/wgink/exceptions/AppVersionException.java new file mode 100644 index 00000000..f8982a7b --- /dev/null +++ b/basic-exception/src/main/java/ink/wgink/exceptions/AppVersionException.java @@ -0,0 +1,37 @@ +package ink.wgink.exceptions; + + +import ink.wgink.exceptions.base.SystemException; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: AppVersionException + * @Description: app版本异常 + * @Author: WangGeng + * @Date: 2019/9/19 5:47 下午 + * @Version: 1.0 + **/ +public class AppVersionException extends SystemException { + + public AppVersionException() { + super(); + } + + public AppVersionException(String message) { + super(message); + } + + public AppVersionException(String message, boolean withMsg) { + super(message, withMsg); + } + + public AppVersionException(String message, Throwable cause) { + super(message, cause); + } + + public AppVersionException(Throwable cause) { + super(cause); + } +} diff --git a/basic-exception/src/main/java/ink/wgink/exceptions/DingDingAccessTokenException.java b/basic-exception/src/main/java/ink/wgink/exceptions/DingDingAccessTokenException.java new file mode 100644 index 00000000..fe2c46e3 --- /dev/null +++ b/basic-exception/src/main/java/ink/wgink/exceptions/DingDingAccessTokenException.java @@ -0,0 +1,36 @@ +package ink.wgink.exceptions; + + +import ink.wgink.exceptions.base.SystemException; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: DingDingAccessTokenException + * @Description: 钉钉accessToken异常 + * @Author: WangGeng + * @Date: 2020/8/31 18:16 + * @Version: 1.0 + **/ +public class DingDingAccessTokenException extends SystemException { + + public DingDingAccessTokenException() { + } + + public DingDingAccessTokenException(String message) { + super(message); + } + + public DingDingAccessTokenException(String message, boolean withMsg) { + super(message, withMsg); + } + + public DingDingAccessTokenException(String message, Throwable cause) { + super(message, cause); + } + + public DingDingAccessTokenException(Throwable cause) { + super(cause); + } +} diff --git a/basic-exception/src/main/java/ink/wgink/exceptions/FileException.java b/basic-exception/src/main/java/ink/wgink/exceptions/FileException.java new file mode 100644 index 00000000..112fa270 --- /dev/null +++ b/basic-exception/src/main/java/ink/wgink/exceptions/FileException.java @@ -0,0 +1,33 @@ +package ink.wgink.exceptions; + + +import ink.wgink.exceptions.base.SystemException; + +/** + * @ClassName: FileException + * @Description: 文件异常 + * @Author: WangGeng + * @Date: 2019/3/11 10:29 AM + * @Version: 1.0 + **/ +public class FileException extends SystemException { + + public FileException() { + } + + public FileException(String message) { + super(message); + } + + public FileException(String message, boolean withMsg) { + super(message, withMsg); + } + + public FileException(String message, Throwable cause) { + super(message, cause); + } + + public FileException(Throwable cause) { + super(cause); + } +} diff --git a/basic-exception/src/main/java/ink/wgink/exceptions/ParamsException.java b/basic-exception/src/main/java/ink/wgink/exceptions/ParamsException.java new file mode 100644 index 00000000..594f9eb6 --- /dev/null +++ b/basic-exception/src/main/java/ink/wgink/exceptions/ParamsException.java @@ -0,0 +1,33 @@ +package ink.wgink.exceptions; + + +import ink.wgink.exceptions.base.SystemException; + +/** + * @ClassName: ParamsException + * @Description: 参数异常 + * @Author: WangGeng + * @Date: 2019/2/26 3:53 PM + * @Version: 1.0 + **/ +public class ParamsException extends SystemException { + + public ParamsException() { + } + + public ParamsException(String message) { + super(message); + } + + public ParamsException(String message, boolean withMsg) { + super(message, withMsg); + } + + public ParamsException(String message, Throwable cause) { + super(message, cause); + } + + public ParamsException(Throwable cause) { + super(cause); + } +} diff --git a/basic-exception/src/main/java/ink/wgink/exceptions/RemoveException.java b/basic-exception/src/main/java/ink/wgink/exceptions/RemoveException.java new file mode 100644 index 00000000..7a4486e7 --- /dev/null +++ b/basic-exception/src/main/java/ink/wgink/exceptions/RemoveException.java @@ -0,0 +1,33 @@ +package ink.wgink.exceptions; + + +import ink.wgink.exceptions.base.SystemException; + +/** + * @ClassName: RemoveException + * @Description: 删除异常 + * @Author: WangGeng + * @Date: 2019/2/26 5:26 PM + * @Version: 1.0 + **/ +public class RemoveException extends SystemException { + + public RemoveException() { + } + + public RemoveException(String message) { + super(message); + } + + public RemoveException(String message, boolean withMsg) { + super(message, withMsg); + } + + public RemoveException(String message, Throwable cause) { + super(message, cause); + } + + public RemoveException(Throwable cause) { + super(cause); + } +} diff --git a/basic-exception/src/main/java/ink/wgink/exceptions/SaveException.java b/basic-exception/src/main/java/ink/wgink/exceptions/SaveException.java new file mode 100644 index 00000000..e7cd4bb2 --- /dev/null +++ b/basic-exception/src/main/java/ink/wgink/exceptions/SaveException.java @@ -0,0 +1,33 @@ +package ink.wgink.exceptions; + + +import ink.wgink.exceptions.base.SystemException; + +/** + * @ClassName: SaveException + * @Description: 新增异常 + * @Author: WangGeng + * @Date: 2019/2/26 5:24 PM + * @Version: 1.0 + **/ +public class SaveException extends SystemException { + + public SaveException() { + } + + public SaveException(String message) { + super(message); + } + + public SaveException(String message, boolean withMsg) { + super(message, withMsg); + } + + public SaveException(String message, Throwable cause) { + super(message, cause); + } + + public SaveException(Throwable cause) { + super(cause); + } +} diff --git a/basic-exception/src/main/java/ink/wgink/exceptions/SearchException.java b/basic-exception/src/main/java/ink/wgink/exceptions/SearchException.java new file mode 100644 index 00000000..19bbd473 --- /dev/null +++ b/basic-exception/src/main/java/ink/wgink/exceptions/SearchException.java @@ -0,0 +1,33 @@ +package ink.wgink.exceptions; + + +import ink.wgink.exceptions.base.SystemException; + +/** + * @ClassName: SearchException + * @Description: 查询异常 + * @Author: WangGeng + * @Date: 2019/2/26 5:26 PM + * @Version: 1.0 + **/ +public class SearchException extends SystemException { + + public SearchException() { + } + + public SearchException(String message) { + super(message); + } + + public SearchException(String message, boolean withMsg) { + super(message, withMsg); + } + + public SearchException(String message, Throwable cause) { + super(message, cause); + } + + public SearchException(Throwable cause) { + super(cause); + } +} diff --git a/basic-exception/src/main/java/ink/wgink/exceptions/TokenException.java b/basic-exception/src/main/java/ink/wgink/exceptions/TokenException.java new file mode 100644 index 00000000..31fe4696 --- /dev/null +++ b/basic-exception/src/main/java/ink/wgink/exceptions/TokenException.java @@ -0,0 +1,37 @@ +package ink.wgink.exceptions; + + +import ink.wgink.exceptions.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/basic-exception/src/main/java/ink/wgink/exceptions/UpdateException.java b/basic-exception/src/main/java/ink/wgink/exceptions/UpdateException.java new file mode 100644 index 00000000..19b48334 --- /dev/null +++ b/basic-exception/src/main/java/ink/wgink/exceptions/UpdateException.java @@ -0,0 +1,33 @@ +package ink.wgink.exceptions; + + +import ink.wgink.exceptions.base.SystemException; + +/** + * @ClassName: UpdateException + * @Description: 编辑异常 + * @Author: WangGeng + * @Date: 2019/2/26 5:25 PM + * @Version: 1.0 + **/ +public class UpdateException extends SystemException { + + public UpdateException() { + } + + public UpdateException(String message) { + super(message); + } + + public UpdateException(String message, boolean withMsg) { + super(message, withMsg); + } + + public UpdateException(String message, Throwable cause) { + super(message, cause); + } + + public UpdateException(Throwable cause) { + super(cause); + } +} diff --git a/basic-exception/src/main/java/ink/wgink/exceptions/WechatAccessTokenException.java b/basic-exception/src/main/java/ink/wgink/exceptions/WechatAccessTokenException.java new file mode 100644 index 00000000..131ddf0e --- /dev/null +++ b/basic-exception/src/main/java/ink/wgink/exceptions/WechatAccessTokenException.java @@ -0,0 +1,36 @@ +package ink.wgink.exceptions; + + +import ink.wgink.exceptions.base.SystemException; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: WechatAccessTokenException + * @Description: 微信accessToken异常 + * @Author: WangGeng + * @Date: 2020/3/2 3:42 下午 + * @Version: 1.0 + **/ +public class WechatAccessTokenException extends SystemException { + + public WechatAccessTokenException() { + } + + public WechatAccessTokenException(String message) { + super(message); + } + + public WechatAccessTokenException(String message, boolean withMsg) { + super(message, withMsg); + } + + public WechatAccessTokenException(String message, Throwable cause) { + super(message, cause); + } + + public WechatAccessTokenException(Throwable cause) { + super(cause); + } +} diff --git a/basic-exception/src/main/java/ink/wgink/exceptions/WechatAccessTokenForUserException.java b/basic-exception/src/main/java/ink/wgink/exceptions/WechatAccessTokenForUserException.java new file mode 100644 index 00000000..369f9c26 --- /dev/null +++ b/basic-exception/src/main/java/ink/wgink/exceptions/WechatAccessTokenForUserException.java @@ -0,0 +1,36 @@ +package ink.wgink.exceptions; + + +import ink.wgink.exceptions.base.SystemException; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: WechatAccessTokenForUserException + * @Description: 微信公众号用户AccessToken异常 + * @Author: WangGeng + * @Date: 2020/3/2 3:43 下午 + * @Version: 1.0 + **/ +public class WechatAccessTokenForUserException extends SystemException { + + public WechatAccessTokenForUserException() { + } + + public WechatAccessTokenForUserException(String message) { + super(message); + } + + public WechatAccessTokenForUserException(String message, boolean withMsg) { + super(message, withMsg); + } + + public WechatAccessTokenForUserException(String message, Throwable cause) { + super(message, cause); + } + + public WechatAccessTokenForUserException(Throwable cause) { + super(cause); + } +} diff --git a/basic-exception/src/main/java/ink/wgink/exceptions/WechatUserInfoException.java b/basic-exception/src/main/java/ink/wgink/exceptions/WechatUserInfoException.java new file mode 100644 index 00000000..a2a65dc1 --- /dev/null +++ b/basic-exception/src/main/java/ink/wgink/exceptions/WechatUserInfoException.java @@ -0,0 +1,35 @@ +package ink.wgink.exceptions; + + +import ink.wgink.exceptions.base.SystemException; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: WechatUserInfoException + * @Description: 微信用户异常 + * @Author: WangGeng + * @Date: 2020/3/2 3:44 下午 + * @Version: 1.0 + **/ +public class WechatUserInfoException extends SystemException { + public WechatUserInfoException() { + } + + public WechatUserInfoException(String message) { + super(message); + } + + public WechatUserInfoException(String message, boolean withMsg) { + super(message, withMsg); + } + + public WechatUserInfoException(String message, Throwable cause) { + super(message, cause); + } + + public WechatUserInfoException(Throwable cause) { + super(cause); + } +} diff --git a/basic-exception/src/main/java/ink/wgink/exceptions/base/SystemException.java b/basic-exception/src/main/java/ink/wgink/exceptions/base/SystemException.java new file mode 100644 index 00000000..691408d8 --- /dev/null +++ b/basic-exception/src/main/java/ink/wgink/exceptions/base/SystemException.java @@ -0,0 +1,41 @@ +package ink.wgink.exceptions.base; + +/** + * @ClassName: SystemException + * @Description: 系统异常 + * @Author: WangGeng + * @Date: 2019/3/4 6:04 PM + * @Version: 1.0 + **/ +public class SystemException extends RuntimeException { + + private boolean withMsg = false; + + public SystemException() { + } + + public SystemException(String message) { + super(message); + } + + public SystemException(String message, boolean withMsg) { + super(message); + this.withMsg = withMsg; + } + + public SystemException(String message, Throwable cause) { + super(message, cause); + } + + public SystemException(Throwable cause) { + super(cause); + } + + public boolean isWithMsg() { + return withMsg; + } + + public void setWithMsg(boolean withMsg) { + this.withMsg = withMsg; + } +} diff --git a/basic-pojo/pom.xml b/basic-pojo/pom.xml index 2e95d48f..f9264f55 100644 --- a/basic-pojo/pom.xml +++ b/basic-pojo/pom.xml @@ -12,6 +12,19 @@ basic-pojo + + + org.springframework.security + spring-security-config + compile + + + org.springframework.security + spring-security-web + compile + + + io.springfox diff --git a/basic-pojo/src/main/java/ink/wgink/pojo/bos/DepartmentBO.java b/basic-pojo/src/main/java/ink/wgink/pojo/bos/DepartmentBO.java new file mode 100644 index 00000000..dc96ae7b --- /dev/null +++ b/basic-pojo/src/main/java/ink/wgink/pojo/bos/DepartmentBO.java @@ -0,0 +1,232 @@ +package ink.wgink.pojo.bos; + +import java.io.Serializable; + +/** + * @ClassName: DepartmentBO + * @Description: 部门 + * @Author: WangGeng + * @Date: 2019/3/14 9:29 PM + * @Version: 1.0 + **/ +public class DepartmentBO implements Serializable { + + private static final long serialVersionUID = -8160484188600622923L; + private String departmentId; + private String departmentName; + private String departmentCode; + private String departmentSummary; + private String departmentArea1Id; + private String departmentArea1Code; + private String departmentArea1Name; + private String departmentArea2Id; + private String departmentArea2Code; + private String departmentArea2Name; + private String departmentArea3Id; + private String departmentArea3Code; + private String departmentArea3Name; + private String departmentArea4Id; + private String departmentArea4Code; + private String departmentArea4Name; + private String departmentArea5Id; + private String departmentArea5Code; + private String departmentArea5Name; + + + public String getDepartmentId() { + return departmentId == null ? "" : departmentId.trim(); + } + + public void setDepartmentId(String departmentId) { + this.departmentId = departmentId; + } + + public String getDepartmentName() { + return departmentName == null ? "" : departmentName.trim(); + } + + public void setDepartmentName(String departmentName) { + this.departmentName = departmentName; + } + + public String getDepartmentCode() { + return departmentCode == null ? "" : departmentCode.trim(); + } + + public void setDepartmentCode(String departmentCode) { + this.departmentCode = departmentCode; + } + + public String getDepartmentSummary() { + return departmentSummary == null ? "" : departmentSummary.trim(); + } + + public void setDepartmentSummary(String departmentSummary) { + this.departmentSummary = departmentSummary; + } + + public String getDepartmentArea1Id() { + return departmentArea1Id == null ? "" : departmentArea1Id.trim(); + } + + public void setDepartmentArea1Id(String departmentArea1Id) { + this.departmentArea1Id = departmentArea1Id; + } + + public String getDepartmentArea1Code() { + return departmentArea1Code == null ? "" : departmentArea1Code.trim(); + } + + public void setDepartmentArea1Code(String departmentArea1Code) { + this.departmentArea1Code = departmentArea1Code; + } + + public String getDepartmentArea1Name() { + return departmentArea1Name == null ? "" : departmentArea1Name.trim(); + } + + public void setDepartmentArea1Name(String departmentArea1Name) { + this.departmentArea1Name = departmentArea1Name; + } + + public String getDepartmentArea2Id() { + return departmentArea2Id == null ? "" : departmentArea2Id.trim(); + } + + public void setDepartmentArea2Id(String departmentArea2Id) { + this.departmentArea2Id = departmentArea2Id; + } + + public String getDepartmentArea2Code() { + return departmentArea2Code == null ? "" : departmentArea2Code.trim(); + } + + public void setDepartmentArea2Code(String departmentArea2Code) { + this.departmentArea2Code = departmentArea2Code; + } + + public String getDepartmentArea2Name() { + return departmentArea2Name == null ? "" : departmentArea2Name.trim(); + } + + public void setDepartmentArea2Name(String departmentArea2Name) { + this.departmentArea2Name = departmentArea2Name; + } + + public String getDepartmentArea3Id() { + return departmentArea3Id == null ? "" : departmentArea3Id.trim(); + } + + public void setDepartmentArea3Id(String departmentArea3Id) { + this.departmentArea3Id = departmentArea3Id; + } + + public String getDepartmentArea3Code() { + return departmentArea3Code == null ? "" : departmentArea3Code.trim(); + } + + public void setDepartmentArea3Code(String departmentArea3Code) { + this.departmentArea3Code = departmentArea3Code; + } + + public String getDepartmentArea3Name() { + return departmentArea3Name == null ? "" : departmentArea3Name.trim(); + } + + public void setDepartmentArea3Name(String departmentArea3Name) { + this.departmentArea3Name = departmentArea3Name; + } + + public String getDepartmentArea4Id() { + return departmentArea4Id == null ? "" : departmentArea4Id.trim(); + } + + public void setDepartmentArea4Id(String departmentArea4Id) { + this.departmentArea4Id = departmentArea4Id; + } + + public String getDepartmentArea4Code() { + return departmentArea4Code == null ? "" : departmentArea4Code.trim(); + } + + public void setDepartmentArea4Code(String departmentArea4Code) { + this.departmentArea4Code = departmentArea4Code; + } + + public String getDepartmentArea4Name() { + return departmentArea4Name == null ? "" : departmentArea4Name.trim(); + } + + public void setDepartmentArea4Name(String departmentArea4Name) { + this.departmentArea4Name = departmentArea4Name; + } + + public String getDepartmentArea5Id() { + return departmentArea5Id == null ? "" : departmentArea5Id.trim(); + } + + public void setDepartmentArea5Id(String departmentArea5Id) { + this.departmentArea5Id = departmentArea5Id; + } + + public String getDepartmentArea5Code() { + return departmentArea5Code == null ? "" : departmentArea5Code.trim(); + } + + public void setDepartmentArea5Code(String departmentArea5Code) { + this.departmentArea5Code = departmentArea5Code; + } + + public String getDepartmentArea5Name() { + return departmentArea5Name == null ? "" : departmentArea5Name.trim(); + } + + public void setDepartmentArea5Name(String departmentArea5Name) { + this.departmentArea5Name = departmentArea5Name; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("{"); + sb.append("\"departmentId\":\"") + .append(departmentId).append('\"'); + sb.append(",\"departmentName\":\"") + .append(departmentName).append('\"'); + sb.append(",\"departmentCode\":\"") + .append(departmentCode).append('\"'); + sb.append(",\"departmentSummary\":\"") + .append(departmentSummary).append('\"'); + sb.append(",\"departmentArea1Id\":\"") + .append(departmentArea1Id).append('\"'); + sb.append(",\"departmentArea1Code\":\"") + .append(departmentArea1Code).append('\"'); + sb.append(",\"departmentArea1Name\":\"") + .append(departmentArea1Name).append('\"'); + sb.append(",\"departmentArea2Id\":\"") + .append(departmentArea2Id).append('\"'); + sb.append(",\"departmentArea2Code\":\"") + .append(departmentArea2Code).append('\"'); + sb.append(",\"departmentArea2Name\":\"") + .append(departmentArea2Name).append('\"'); + sb.append(",\"departmentArea3Id\":\"") + .append(departmentArea3Id).append('\"'); + sb.append(",\"departmentArea3Code\":\"") + .append(departmentArea3Code).append('\"'); + sb.append(",\"departmentArea3Name\":\"") + .append(departmentArea3Name).append('\"'); + sb.append(",\"departmentArea4Id\":\"") + .append(departmentArea4Id).append('\"'); + sb.append(",\"departmentArea4Code\":\"") + .append(departmentArea4Code).append('\"'); + sb.append(",\"departmentArea4Name\":\"") + .append(departmentArea4Name).append('\"'); + sb.append(",\"departmentArea5Id\":\"") + .append(departmentArea5Id).append('\"'); + sb.append(",\"departmentArea5Code\":\"") + .append(departmentArea5Code).append('\"'); + sb.append(",\"departmentArea5Name\":\"") + .append(departmentArea5Name).append('\"'); + sb.append('}'); + return sb.toString(); + } +} diff --git a/basic-pojo/src/main/java/ink/wgink/pojo/bos/GroupBO.java b/basic-pojo/src/main/java/ink/wgink/pojo/bos/GroupBO.java new file mode 100644 index 00000000..d83bf293 --- /dev/null +++ b/basic-pojo/src/main/java/ink/wgink/pojo/bos/GroupBO.java @@ -0,0 +1,52 @@ +package ink.wgink.pojo.bos; + +/** + * @ClassName: GroupBO + * @Description: 用户组 + * @Author: WangGeng + * @Date: 2019/3/14 9:29 PM + * @Version: 1.0 + **/ +public class GroupBO { + + private String groupId; + private String groupName; + private String groupSummary; + + public String getGroupId() { + return groupId == null ? "" : groupId.trim(); + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + public String getGroupName() { + return groupName == null ? "" : groupName.trim(); + } + + public void setGroupName(String groupName) { + this.groupName = groupName; + } + + public String getGroupSummary() { + return groupSummary == null ? "" : groupSummary.trim(); + } + + public void setGroupSummary(String groupSummary) { + this.groupSummary = groupSummary; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("{"); + sb.append("\"groupId\":") + .append("\"").append(groupId).append("\""); + sb.append(",\"groupName\":") + .append("\"").append(groupName).append("\""); + sb.append(",\"groupSummary\":") + .append("\"").append(groupSummary).append("\""); + sb.append('}'); + return sb.toString(); + } +} diff --git a/basic-pojo/src/main/java/ink/wgink/pojo/bos/PermissionBO.java b/basic-pojo/src/main/java/ink/wgink/pojo/bos/PermissionBO.java new file mode 100644 index 00000000..aed908d0 --- /dev/null +++ b/basic-pojo/src/main/java/ink/wgink/pojo/bos/PermissionBO.java @@ -0,0 +1,44 @@ +package ink.wgink.pojo.bos; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: PermissionBO + * @Description: 权限业务 + * @Author: WangGeng + * @Date: 2020/5/28 10:32 下午 + * @Version: 1.0 + **/ +public class PermissionBO { + + private String permissionType; + private String permissionUrl; + + public String getPermissionType() { + return permissionType == null ? "" : permissionType.trim(); + } + + public void setPermissionType(String permissionType) { + this.permissionType = permissionType; + } + + public String getPermissionUrl() { + return permissionUrl == null ? "" : permissionUrl.trim(); + } + + public void setPermissionUrl(String permissionUrl) { + this.permissionUrl = permissionUrl; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("{"); + sb.append("\"permissionType\":") + .append("\"").append(permissionType).append("\""); + sb.append(",\"permissionUrl\":") + .append("\"").append(permissionUrl).append("\""); + sb.append('}'); + return sb.toString(); + } +} diff --git a/basic-pojo/src/main/java/ink/wgink/pojo/bos/PositionBO.java b/basic-pojo/src/main/java/ink/wgink/pojo/bos/PositionBO.java new file mode 100644 index 00000000..6ce92245 --- /dev/null +++ b/basic-pojo/src/main/java/ink/wgink/pojo/bos/PositionBO.java @@ -0,0 +1,58 @@ +package ink.wgink.pojo.bos; + +import java.io.Serializable; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: PositionBO + * @Description: 职位 + * @Author: WangGeng + * @Date: 2019-08-10 13:27 + * @Version: 1.0 + **/ +public class PositionBO implements Serializable { + + private static final long serialVersionUID = -7228959403262849245L; + private String positionId; + private String positionName; + private String positionSummary; + + public String getPositionId() { + return positionId == null ? "" : positionId.trim(); + } + + public void setPositionId(String positionId) { + this.positionId = positionId; + } + + public String getPositionName() { + return positionName == null ? "" : positionName.trim(); + } + + public void setPositionName(String positionName) { + this.positionName = positionName; + } + + public String getPositionSummary() { + return positionSummary == null ? "" : positionSummary.trim(); + } + + public void setPositionSummary(String positionSummary) { + this.positionSummary = positionSummary; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("{"); + sb.append("\"positionId\":") + .append("\"").append(positionId).append("\""); + sb.append(",\"positionName\":") + .append("\"").append(positionName).append("\""); + sb.append(",\"positionSummary\":") + .append("\"").append(positionSummary).append("\""); + sb.append('}'); + return sb.toString(); + } +} diff --git a/basic-pojo/src/main/java/ink/wgink/pojo/bos/RoleBO.java b/basic-pojo/src/main/java/ink/wgink/pojo/bos/RoleBO.java new file mode 100644 index 00000000..d1980ab6 --- /dev/null +++ b/basic-pojo/src/main/java/ink/wgink/pojo/bos/RoleBO.java @@ -0,0 +1,233 @@ +package ink.wgink.pojo.bos; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +/** + * @ClassName: RoleBO + * @Description: 角色 + * @Author: WangGeng + * @Date: 2019/3/14 9:29 PM + * @Version: 1.0 + **/ +public class RoleBO implements Serializable { + + private static final long serialVersionUID = 3106644672498095887L; + private String roleId; + private String roleName; + private String roleSummary; + private String roleDataAuthority; + private List apiSaveMenu = new ArrayList<>(); + private List apiDeleteMenu = new ArrayList<>(); + private List apiUpdateMenu = new ArrayList<>(); + private List apiQueryMenu = new ArrayList<>(); + private List resourceSaveMenu = new ArrayList<>(); + private List resourceDeleteMenu = new ArrayList<>(); + private List resourceUpdateMenu = new ArrayList<>(); + private List resourceQueryMenu = new ArrayList<>(); + private List routeSaveMenu = new ArrayList<>(); + private List routeUpdateMenu = new ArrayList<>(); + private List routeQueryMenu = new ArrayList<>(); + private List permissionInsert = new ArrayList<>(); + private List permissionDelete = new ArrayList<>(); + private List permissionUpdate = new ArrayList<>(); + private List permissionQuery = new ArrayList<>(); + + public String getRoleId() { + return roleId == null ? "" : roleId.trim(); + } + + public void setRoleId(String roleId) { + this.roleId = roleId; + } + + public String getRoleName() { + return roleName == null ? "" : roleName.trim(); + } + + public void setRoleName(String roleName) { + this.roleName = roleName; + } + + public String getRoleSummary() { + return roleSummary == null ? "" : roleSummary.trim(); + } + + public void setRoleSummary(String roleSummary) { + this.roleSummary = roleSummary; + } + + public String getRoleDataAuthority() { + return roleDataAuthority == null ? "" : roleDataAuthority.trim(); + } + + public void setRoleDataAuthority(String roleDataAuthority) { + this.roleDataAuthority = roleDataAuthority; + } + + public List getApiSaveMenu() { + return apiSaveMenu; + } + + public void setApiSaveMenu(List apiSaveMenu) { + this.apiSaveMenu = apiSaveMenu; + } + + public List getApiDeleteMenu() { + return apiDeleteMenu; + } + + public void setApiDeleteMenu(List apiDeleteMenu) { + this.apiDeleteMenu = apiDeleteMenu; + } + + public List getApiUpdateMenu() { + return apiUpdateMenu; + } + + public void setApiUpdateMenu(List apiUpdateMenu) { + this.apiUpdateMenu = apiUpdateMenu; + } + + public List getApiQueryMenu() { + return apiQueryMenu; + } + + public void setApiQueryMenu(List apiQueryMenu) { + this.apiQueryMenu = apiQueryMenu; + } + + public List getResourceSaveMenu() { + return resourceSaveMenu; + } + + public void setResourceSaveMenu(List resourceSaveMenu) { + this.resourceSaveMenu = resourceSaveMenu; + } + + public List getResourceDeleteMenu() { + return resourceDeleteMenu; + } + + public void setResourceDeleteMenu(List resourceDeleteMenu) { + this.resourceDeleteMenu = resourceDeleteMenu; + } + + public List getResourceUpdateMenu() { + return resourceUpdateMenu; + } + + public void setResourceUpdateMenu(List resourceUpdateMenu) { + this.resourceUpdateMenu = resourceUpdateMenu; + } + + public List getResourceQueryMenu() { + return resourceQueryMenu; + } + + public void setResourceQueryMenu(List resourceQueryMenu) { + this.resourceQueryMenu = resourceQueryMenu; + } + + public List getRouteSaveMenu() { + return routeSaveMenu; + } + + public void setRouteSaveMenu(List routeSaveMenu) { + this.routeSaveMenu = routeSaveMenu; + } + + public List getRouteUpdateMenu() { + return routeUpdateMenu; + } + + public void setRouteUpdateMenu(List routeUpdateMenu) { + this.routeUpdateMenu = routeUpdateMenu; + } + + public List getRouteQueryMenu() { + return routeQueryMenu; + } + + public void setRouteQueryMenu(List routeQueryMenu) { + this.routeQueryMenu = routeQueryMenu; + } + + public List getPermissionInsert() { + return permissionInsert; + } + + public void setPermissionInsert(List permissionInsert) { + this.permissionInsert = permissionInsert; + } + + public List getPermissionDelete() { + return permissionDelete; + } + + public void setPermissionDelete(List permissionDelete) { + this.permissionDelete = permissionDelete; + } + + public List getPermissionUpdate() { + return permissionUpdate; + } + + public void setPermissionUpdate(List permissionUpdate) { + this.permissionUpdate = permissionUpdate; + } + + public List getPermissionQuery() { + return permissionQuery; + } + + public void setPermissionQuery(List permissionQuery) { + this.permissionQuery = permissionQuery; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("{"); + sb.append("\"roleId\":") + .append("\"").append(roleId).append("\""); + sb.append(",\"roleName\":") + .append("\"").append(roleName).append("\""); + sb.append(",\"roleSummary\":") + .append("\"").append(roleSummary).append("\""); + sb.append(",\"roleDataAuthority\":") + .append("\"").append(roleDataAuthority).append("\""); + sb.append(",\"apiSaveMenu\":") + .append(apiSaveMenu); + sb.append(",\"apiDeleteMenu\":") + .append(apiDeleteMenu); + sb.append(",\"apiUpdateMenu\":") + .append(apiUpdateMenu); + sb.append(",\"apiQueryMenu\":") + .append(apiQueryMenu); + sb.append(",\"resourceSaveMenu\":") + .append(resourceSaveMenu); + sb.append(",\"resourceDeleteMenu\":") + .append(resourceDeleteMenu); + sb.append(",\"resourceUpdateMenu\":") + .append(resourceUpdateMenu); + sb.append(",\"resourceQueryMenu\":") + .append(resourceQueryMenu); + sb.append(",\"routeSaveMenu\":") + .append(routeSaveMenu); + sb.append(",\"routeUpdateMenu\":") + .append(routeUpdateMenu); + sb.append(",\"routeQueryMenu\":") + .append(routeQueryMenu); + sb.append(",\"permissionInsert\":") + .append(permissionInsert); + sb.append(",\"permissionDelete\":") + .append(permissionDelete); + sb.append(",\"permissionUpdate\":") + .append(permissionUpdate); + sb.append(",\"permissionQuery\":") + .append(permissionQuery); + sb.append('}'); + return sb.toString(); + } +} diff --git a/basic-pojo/src/main/java/ink/wgink/pojo/bos/RoleGrantedAuthority.java b/basic-pojo/src/main/java/ink/wgink/pojo/bos/RoleGrantedAuthority.java new file mode 100644 index 00000000..522a0abb --- /dev/null +++ b/basic-pojo/src/main/java/ink/wgink/pojo/bos/RoleGrantedAuthority.java @@ -0,0 +1,258 @@ +package ink.wgink.pojo.bos; + +import org.springframework.security.core.GrantedAuthority; + +import java.util.List; + +/** + * @ClassName: RoleGrantedAuthority + * @Description: 角色权限 + * @Author: WangGeng + * @Date: 2019-06-08 10:34 + * @Version: 1.0 + **/ +public class RoleGrantedAuthority implements GrantedAuthority { + + private static final long serialVersionUID = 520L; + private String role; + private String roleId; + private String roleName; + private List apiSaveMenu; + private List apiDeleteMenu; + private List apiUpdateMenu; + private List apiQueryMenu; + private List resourceSaveMenu; + private List resourceDeleteMenu; + private List resourceUpdateMenu; + private List resourceQueryMenu; + private List routeSaveMenu; + private List routeUpdateMenu; + private List routeQueryMenu; + private List permissionInsert; + private List permissionDelete; + private List permissionUpdate; + private List permissionQuery; + + public RoleGrantedAuthority(String role) { + this.role = role; + } + + public RoleGrantedAuthority(String role, com.cm.common.pojo.bos.RoleBO roleBO) { + this.role = role; + this.roleId = roleBO.getRoleId(); + this.roleName = roleBO.getRoleName(); + this.apiSaveMenu = roleBO.getApiSaveMenu(); + this.apiDeleteMenu = roleBO.getApiDeleteMenu(); + this.apiUpdateMenu = roleBO.getApiUpdateMenu(); + this.apiQueryMenu = roleBO.getApiQueryMenu(); + this.resourceSaveMenu = roleBO.getResourceSaveMenu(); + this.resourceDeleteMenu = roleBO.getResourceDeleteMenu(); + this.resourceUpdateMenu = roleBO.getResourceUpdateMenu(); + this.resourceQueryMenu = roleBO.getResourceQueryMenu(); + this.routeSaveMenu = roleBO.getRouteSaveMenu(); + this.routeUpdateMenu = roleBO.getRouteUpdateMenu(); + this.routeQueryMenu = roleBO.getRouteQueryMenu(); + this.permissionInsert = roleBO.getPermissionInsert(); + this.permissionDelete = roleBO.getPermissionDelete(); + this.permissionUpdate = roleBO.getPermissionUpdate(); + this.permissionQuery = roleBO.getPermissionQuery(); + } + + @Override + public String getAuthority() { + return this.role; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } else { + return obj instanceof RoleGrantedAuthority ? this.role.equals(((RoleGrantedAuthority) obj).role) : false; + } + } + + @Override + public int hashCode() { + return this.role.hashCode(); + } + + public String getRoleId() { + return roleId == null ? "" : roleId.trim(); + } + + public void setRoleId(String roleId) { + this.roleId = roleId; + } + + public String getRoleName() { + return roleName == null ? "" : roleName.trim(); + } + + public void setRoleName(String roleName) { + this.roleName = roleName; + } + + public List getApiSaveMenu() { + return apiSaveMenu; + } + + public void setApiSaveMenu(List apiSaveMenu) { + this.apiSaveMenu = apiSaveMenu; + } + + public List getApiDeleteMenu() { + return apiDeleteMenu; + } + + public void setApiDeleteMenu(List apiDeleteMenu) { + this.apiDeleteMenu = apiDeleteMenu; + } + + public List getApiUpdateMenu() { + return apiUpdateMenu; + } + + public void setApiUpdateMenu(List apiUpdateMenu) { + this.apiUpdateMenu = apiUpdateMenu; + } + + public List getApiQueryMenu() { + return apiQueryMenu; + } + + public void setApiQueryMenu(List apiQueryMenu) { + this.apiQueryMenu = apiQueryMenu; + } + + public List getResourceSaveMenu() { + return resourceSaveMenu; + } + + public void setResourceSaveMenu(List resourceSaveMenu) { + this.resourceSaveMenu = resourceSaveMenu; + } + + public List getResourceDeleteMenu() { + return resourceDeleteMenu; + } + + public void setResourceDeleteMenu(List resourceDeleteMenu) { + this.resourceDeleteMenu = resourceDeleteMenu; + } + + public List getResourceUpdateMenu() { + return resourceUpdateMenu; + } + + public void setResourceUpdateMenu(List resourceUpdateMenu) { + this.resourceUpdateMenu = resourceUpdateMenu; + } + + public List getResourceQueryMenu() { + return resourceQueryMenu; + } + + public void setResourceQueryMenu(List resourceQueryMenu) { + this.resourceQueryMenu = resourceQueryMenu; + } + + public List getRouteSaveMenu() { + return routeSaveMenu; + } + + public void setRouteSaveMenu(List routeSaveMenu) { + this.routeSaveMenu = routeSaveMenu; + } + + public List getRouteUpdateMenu() { + return routeUpdateMenu; + } + + public void setRouteUpdateMenu(List routeUpdateMenu) { + this.routeUpdateMenu = routeUpdateMenu; + } + + public List getRouteQueryMenu() { + return routeQueryMenu; + } + + public void setRouteQueryMenu(List routeQueryMenu) { + this.routeQueryMenu = routeQueryMenu; + } + + public List getPermissionInsert() { + return permissionInsert; + } + + public void setPermissionInsert(List permissionInsert) { + this.permissionInsert = permissionInsert; + } + + public List getPermissionDelete() { + return permissionDelete; + } + + public void setPermissionDelete(List permissionDelete) { + this.permissionDelete = permissionDelete; + } + + public List getPermissionUpdate() { + return permissionUpdate; + } + + public void setPermissionUpdate(List permissionUpdate) { + this.permissionUpdate = permissionUpdate; + } + + public List getPermissionQuery() { + return permissionQuery; + } + + public void setPermissionQuery(List permissionQuery) { + this.permissionQuery = permissionQuery; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("{"); + sb.append("\"role\":") + .append("\"").append(role).append("\""); + sb.append(",\"roleId\":") + .append("\"").append(roleId).append("\""); + sb.append(",\"roleName\":") + .append("\"").append(roleName).append("\""); + sb.append(",\"apiSaveMenu\":") + .append(apiSaveMenu); + sb.append(",\"apiDeleteMenu\":") + .append(apiDeleteMenu); + sb.append(",\"apiUpdateMenu\":") + .append(apiUpdateMenu); + sb.append(",\"apiQueryMenu\":") + .append(apiQueryMenu); + sb.append(",\"resourceSaveMenu\":") + .append(resourceSaveMenu); + sb.append(",\"resourceDeleteMenu\":") + .append(resourceDeleteMenu); + sb.append(",\"resourceUpdateMenu\":") + .append(resourceUpdateMenu); + sb.append(",\"resourceQueryMenu\":") + .append(resourceQueryMenu); + sb.append(",\"routeSaveMenu\":") + .append(routeSaveMenu); + sb.append(",\"routeUpdateMenu\":") + .append(routeUpdateMenu); + sb.append(",\"routeQueryMenu\":") + .append(routeQueryMenu); + sb.append(",\"permissionInsert\":") + .append(permissionInsert); + sb.append(",\"permissionDelete\":") + .append(permissionDelete); + sb.append(",\"permissionUpdate\":") + .append(permissionUpdate); + sb.append(",\"permissionQuery\":") + .append(permissionQuery); + sb.append('}'); + return sb.toString(); + } +} diff --git a/basic-pojo/src/main/java/ink/wgink/pojo/bos/RoleMenuBO.java b/basic-pojo/src/main/java/ink/wgink/pojo/bos/RoleMenuBO.java new file mode 100644 index 00000000..34717095 --- /dev/null +++ b/basic-pojo/src/main/java/ink/wgink/pojo/bos/RoleMenuBO.java @@ -0,0 +1,88 @@ +package ink.wgink.pojo.bos; + +import java.io.Serializable; + +/** + * @ClassName: RoleMenuBO + * @Description: 角色菜单 + * @Author: WangGeng + * @Date: 2019-06-08 19:43 + * @Version: 1.0 + **/ +public class RoleMenuBO implements Serializable { + + private static final long serialVersionUID = 2341873646895943250L; + private String roleId; + private String roleType; + private String menuId; + private String apiPrefix; + private String resourcePrefix; + private String routePrefix; + + public String getRoleId() { + return roleId == null ? "" : roleId.trim(); + } + + public void setRoleId(String roleId) { + this.roleId = roleId; + } + + public String getRoleType() { + return roleType == null ? "" : roleType.trim(); + } + + public void setRoleType(String roleType) { + this.roleType = roleType; + } + + public String getMenuId() { + return menuId == null ? "" : menuId.trim(); + } + + public void setMenuId(String menuId) { + this.menuId = menuId; + } + + public String getApiPrefix() { + return apiPrefix == null ? "" : apiPrefix.trim(); + } + + public void setApiPrefix(String apiPrefix) { + this.apiPrefix = apiPrefix; + } + + public String getResourcePrefix() { + return resourcePrefix == null ? "" : resourcePrefix.trim(); + } + + public void setResourcePrefix(String resourcePrefix) { + this.resourcePrefix = resourcePrefix; + } + + public String getRoutePrefix() { + return routePrefix == null ? "" : routePrefix.trim(); + } + + public void setRoutePrefix(String routePrefix) { + this.routePrefix = routePrefix; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("{"); + sb.append("\"roleId\":") + .append("\"").append(roleId).append("\""); + sb.append(",\"roleType\":") + .append("\"").append(roleType).append("\""); + sb.append(",\"menuId\":") + .append("\"").append(menuId).append("\""); + sb.append(",\"apiPrefix\":") + .append("\"").append(apiPrefix).append("\""); + sb.append(",\"resourcePrefix\":") + .append("\"").append(resourcePrefix).append("\""); + sb.append(",\"routePrefix\":") + .append("\"").append(routePrefix).append("\""); + sb.append('}'); + return sb.toString(); + } +} diff --git a/basic-pojo/src/main/java/ink/wgink/pojo/bos/UserBO.java b/basic-pojo/src/main/java/ink/wgink/pojo/bos/UserBO.java new file mode 100644 index 00000000..fdb746a1 --- /dev/null +++ b/basic-pojo/src/main/java/ink/wgink/pojo/bos/UserBO.java @@ -0,0 +1,257 @@ +package ink.wgink.pojo.bos; + +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.userdetails.User; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +/** + * @ClassName: UserBO + * @Description: 用户 + * @Author: WangGeng + * @Date: 2019/2/20 2:22 PM + * @Version: 1.0 + **/ +public class UserBO extends User { + + private String userId; + private String userName; + private String userPhone; + private String userAvatar; + private String userEmail; + private String userUKey; + private Integer loginType; + private String dataAuthority; + private List baseDepartmentIds; + private List dataAuthorityUserIds; + private List roles; + private List groups; + private List departments; + private List positions; + private String roleIdAndNamesValue; + private String groupIdAndNamesValue; + private String departmentIdAndNamesValue; + private String positionIdAndNamesValue; + + public UserBO() { + super("", "", null); + } + + public UserBO(String username, String password, Collection authorities) { + super(username, password, authorities); + } + + public UserBO(String username, String password, boolean enabled, boolean accountNonExpired, boolean credentialsNonExpired, boolean accountNonLocked, Collection authorities) { + super(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities); + } + + public String getUserId() { + return userId == null ? "" : userId.trim(); + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getUserName() { + return userName == null ? "" : userName.trim(); + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getUserPhone() { + return userPhone == null ? "" : userPhone.trim(); + } + + public void setUserPhone(String userPhone) { + this.userPhone = userPhone; + } + + public String getUserAvatar() { + return userAvatar == null ? "" : userAvatar; + } + + public void setUserAvatar(String userAvatar) { + this.userAvatar = userAvatar; + } + + public String getUserEmail() { + return userEmail == null ? "" : userEmail; + } + + public void setUserEmail(String userEmail) { + this.userEmail = userEmail; + } + + public String getUserUKey() { + return userUKey == null ? "" : userUKey.trim(); + } + + public void setUserUKey(String userUKey) { + this.userUKey = userUKey; + } + + public Integer getLoginType() { + return loginType; + } + + public void setLoginType(Integer loginType) { + this.loginType = loginType; + } + + public List getBaseDepartmentIds() { + return baseDepartmentIds == null ? new ArrayList<>(0) : baseDepartmentIds; + } + + public void setBaseDepartmentIds(List baseDepartmentIds) { + this.baseDepartmentIds = baseDepartmentIds; + } + + public String getDataAuthority() { + return dataAuthority == null ? "" : dataAuthority.trim(); + } + + public void setDataAuthority(String dataAuthority) { + this.dataAuthority = dataAuthority; + } + + public List getDataAuthorityUserIds() { + return dataAuthorityUserIds == null ? new ArrayList<>(0) : dataAuthorityUserIds; + } + + public void setDataAuthorityUserIds(List dataAuthorityUserIds) { + this.dataAuthorityUserIds = dataAuthorityUserIds; + } + + public List getRoles() { + return roles == null ? new ArrayList<>(0) : roles; + } + + public void setRoles(List roles) { + this.roles = roles; + if (roles == null || roles.isEmpty()) { + return; + } + StringBuilder idSB = new StringBuilder(); + StringBuilder nameSB = new StringBuilder(); + roles.forEach(roleBO -> { + if (idSB.length() > 0) { + idSB.append(","); + nameSB.append(","); + } + idSB.append(roleBO.getRoleId()); + nameSB.append(roleBO.getRoleName()); + }); + this.roleIdAndNamesValue = idSB.append("|").append(nameSB).toString(); + } + + public List getGroups() { + return groups == null ? new ArrayList<>(0) : groups; + } + + public void setGroups(List groups) { + this.groups = groups; + if (groups == null || groups.isEmpty()) { + return; + } + StringBuilder idSB = new StringBuilder(); + StringBuilder nameSB = new StringBuilder(); + groups.forEach(groupBO -> { + if (idSB.length() > 0) { + idSB.append(","); + nameSB.append(","); + } + idSB.append(groupBO.getGroupId()); + nameSB.append(groupBO.getGroupName()); + }); + this.groupIdAndNamesValue = idSB.append("|").append(nameSB).toString(); + } + + public List getDepartments() { + return departments == null ? new ArrayList<>(0) : departments; + } + + public void setDepartments(List departments) { + this.departments = departments; + if (departments == null || departments.isEmpty()) { + return; + } + StringBuilder idSB = new StringBuilder(); + StringBuilder nameSB = new StringBuilder(); + departments.forEach(departmentBO -> { + if (idSB.length() > 0) { + idSB.append(","); + nameSB.append(","); + } + idSB.append(departmentBO.getDepartmentId()); + nameSB.append(departmentBO.getDepartmentName()); + }); + this.departmentIdAndNamesValue = idSB.append("|").append(nameSB).toString(); + } + + public List getPositions() { + return positions == null ? new ArrayList<>(0) : positions; + } + + public void setPositions(List positions) { + this.positions = positions; + if (positions == null || positions.isEmpty()) { + return; + } + StringBuilder idSB = new StringBuilder(); + StringBuilder nameSB = new StringBuilder(); + positions.forEach(positionBO -> { + if (idSB.length() > 0) { + idSB.append(","); + nameSB.append(","); + } + idSB.append(positionBO.getPositionId()); + nameSB.append(positionBO.getPositionName()); + }); + this.positionIdAndNamesValue = idSB.append("|").append(nameSB).toString(); + } + + public String getRoleIdAndNamesValue() { + return roleIdAndNamesValue == null ? "" : roleIdAndNamesValue.trim(); + } + + public String getGroupIdAndNamesValue() { + return groupIdAndNamesValue == null ? "" : groupIdAndNamesValue.trim(); + } + + public String getDepartmentIdAndNamesValue() { + return departmentIdAndNamesValue == null ? "" : departmentIdAndNamesValue.trim(); + } + + public String getPositionIdAndNamesValue() { + return positionIdAndNamesValue == null ? "" : positionIdAndNamesValue.trim(); + } + + @Override + public String toString() { + return "UserBO{" + + "userId='" + userId + '\'' + + ", userName='" + userName + '\'' + + ", userPhone='" + userPhone + '\'' + + ", userAvatar='" + userAvatar + '\'' + + ", userEmail='" + userEmail + '\'' + + ", userUKey='" + userUKey + '\'' + + ", loginType=" + loginType + + ", dataAuthority='" + dataAuthority + '\'' + + ", baseDepartmentIds=" + baseDepartmentIds + + ", dataAuthorityUserIds=" + dataAuthorityUserIds + + ", roles=" + roles + + ", groups=" + groups + + ", departments=" + departments + + ", positions=" + positions + + ", roleIdAndNamesValue='" + roleIdAndNamesValue + '\'' + + ", groupIdAndNamesValue='" + groupIdAndNamesValue + '\'' + + ", departmentIdAndNamesValue='" + departmentIdAndNamesValue + '\'' + + ", positionIdAndNamesValue='" + positionIdAndNamesValue + '\'' + + '}'; + } +} diff --git a/basic-pojo/src/main/java/ink/wgink/pojo/bos/UserInfoBO.java b/basic-pojo/src/main/java/ink/wgink/pojo/bos/UserInfoBO.java new file mode 100644 index 00000000..72ba236b --- /dev/null +++ b/basic-pojo/src/main/java/ink/wgink/pojo/bos/UserInfoBO.java @@ -0,0 +1,231 @@ +package ink.wgink.pojo.bos; + +import java.util.ArrayList; +import java.util.List; + +/** + * @ClassName: UserInfoBO + * @Description: 用户 + * @Author: WangGeng + * @Date: 2019/3/24 11:03 PM + * @Version: 1.0 + **/ +public class UserInfoBO { + + private String userId; + private String userUsername; + private String userName; + private String userPhone; + private String userAvatar; + private String userEmail; + private String dataAuthority; + private List dataAuthorityUserIds; + private List baseDepartmentIds; + private List departments; + private List roles; + private List groups; + private List positions; + private String roleIdAndNamesValue; + private String groupIdAndNamesValue; + private String departmentIdAndNamesValue; + private String positionIdAndNamesValue; + + public String getUserId() { + return userId == null ? "" : userId.trim(); + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getUserUsername() { + return userUsername == null ? "" : userUsername.trim(); + } + + public void setUserUsername(String userUsername) { + this.userUsername = userUsername; + } + + public String getUserName() { + return userName == null ? "" : userName.trim(); + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getUserPhone() { + return userPhone == null ? "" : userPhone.trim(); + } + + public void setUserPhone(String userPhone) { + this.userPhone = userPhone; + } + + public String getUserAvatar() { + return userAvatar == null ? "" : userAvatar; + } + + public void setUserAvatar(String userAvatar) { + this.userAvatar = userAvatar; + } + + public String getUserEmail() { + return userEmail == null ? "" : userEmail; + } + + public void setUserEmail(String userEmail) { + this.userEmail = userEmail; + } + + public String getDataAuthority() { + return dataAuthority == null ? "" : dataAuthority.trim(); + } + + public void setDataAuthority(String dataAuthority) { + this.dataAuthority = dataAuthority; + } + + public List getDataAuthorityUserIds() { + return dataAuthorityUserIds == null ? new ArrayList<>(0) : dataAuthorityUserIds; + } + + public void setDataAuthorityUserIds(List dataAuthorityUserIds) { + this.dataAuthorityUserIds = dataAuthorityUserIds; + } + + public List getBaseDepartmentIds() { + return baseDepartmentIds == null ? new ArrayList<>(0) : baseDepartmentIds; + } + + public void setBaseDepartmentIds(List baseDepartmentIds) { + this.baseDepartmentIds = baseDepartmentIds; + } + + public List getDepartments() { + return departments == null ? new ArrayList<>(0) : departments; + } + + public void setDepartments(List departments) { + this.departments = departments; + if (departments == null || departments.isEmpty()) { + return; + } + StringBuilder idSB = new StringBuilder(); + StringBuilder nameSB = new StringBuilder(); + departments.forEach(departmentBO -> { + if (idSB.length() > 0) { + idSB.append(","); + nameSB.append(","); + } + idSB.append(departmentBO.getDepartmentId()); + nameSB.append(departmentBO.getDepartmentName()); + }); + this.departmentIdAndNamesValue = idSB.append("|").append(nameSB).toString(); + } + + public List getRoles() { + return roles == null ? new ArrayList<>(0) : roles; + } + + public void setRoles(List roles) { + this.roles = roles; + if (roles == null || roles.isEmpty()) { + return; + } + StringBuilder idSB = new StringBuilder(); + StringBuilder nameSB = new StringBuilder(); + roles.forEach(roleBO -> { + if (idSB.length() > 0) { + idSB.append(","); + nameSB.append(","); + } + idSB.append(roleBO.getRoleId()); + nameSB.append(roleBO.getRoleName()); + }); + this.roleIdAndNamesValue = idSB.append("|").append(nameSB).toString(); + } + + public List getGroups() { + return groups == null ? new ArrayList<>(0) : groups; + } + + public void setGroups(List groups) { + this.groups = groups; + if (groups == null || groups.isEmpty()) { + return; + } + StringBuilder idSB = new StringBuilder(); + StringBuilder nameSB = new StringBuilder(); + groups.forEach(groupBO -> { + if (idSB.length() > 0) { + idSB.append(","); + nameSB.append(","); + } + idSB.append(groupBO.getGroupId()); + nameSB.append(groupBO.getGroupName()); + }); + this.groupIdAndNamesValue = idSB.append("|").append(nameSB).toString(); + } + + public List getPositions() { + return positions == null ? new ArrayList<>(0) : positions; + } + + public void setPositions(List positions) { + this.positions = positions; + if (positions == null || positions.isEmpty()) { + return; + } + StringBuilder idSB = new StringBuilder(); + StringBuilder nameSB = new StringBuilder(); + positions.forEach(positionBO -> { + if (idSB.length() > 0) { + idSB.append(","); + nameSB.append(","); + } + idSB.append(positionBO.getPositionId()); + nameSB.append(positionBO.getPositionName()); + }); + this.positionIdAndNamesValue = idSB.append("|").append(nameSB).toString(); + } + + public String getRoleIdAndNamesValue() { + return roleIdAndNamesValue == null ? "" : roleIdAndNamesValue.trim(); + } + + public String getGroupIdAndNamesValue() { + return groupIdAndNamesValue == null ? "" : groupIdAndNamesValue.trim(); + } + + public String getDepartmentIdAndNamesValue() { + return departmentIdAndNamesValue == null ? "" : departmentIdAndNamesValue.trim(); + } + + public String getPositionIdAndNamesValue() { + return positionIdAndNamesValue == null ? "" : positionIdAndNamesValue.trim(); + } + + @Override + public String toString() { + return "UserInfoBO{" + + "userId='" + userId + '\'' + + ", userUsername='" + userUsername + '\'' + + ", userName='" + userName + '\'' + + ", userPhone='" + userPhone + '\'' + + ", userAvatar='" + userAvatar + '\'' + + ", userEmail='" + userEmail + '\'' + + ", dataAuthority='" + dataAuthority + '\'' + + ", dataAuthorityUserIds=" + dataAuthorityUserIds + + ", baseDepartmentIds=" + baseDepartmentIds + + ", departments=" + departments + + ", roles=" + roles + + ", groups=" + groups + + ", positions=" + positions + + ", roleIdAndNamesValue='" + roleIdAndNamesValue + '\'' + + ", groupIdAndNamesValue='" + groupIdAndNamesValue + '\'' + + ", departmentIdAndNamesValue='" + departmentIdAndNamesValue + '\'' + + ", positionIdAndNamesValue='" + positionIdAndNamesValue + '\'' + + '}'; + } +} diff --git a/basic-pojo/src/main/java/ink/wgink/pojo/dtos/CurrentUserIdInfoDTO.java b/basic-pojo/src/main/java/ink/wgink/pojo/dtos/CurrentUserIdInfoDTO.java new file mode 100644 index 00000000..3712512e --- /dev/null +++ b/basic-pojo/src/main/java/ink/wgink/pojo/dtos/CurrentUserIdInfoDTO.java @@ -0,0 +1,146 @@ +package ink.wgink.pojo.dtos; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: CurrentUserInfoDTO + * @Description: 当前用户信息 + * @Author: WangGeng + * @Date: 2020/2/24 2:20 下午 + * @Version: 1.0 + **/ +@ApiModel +public class CurrentUserIdInfoDTO { + + @ApiModelProperty(name = "userIdAndValue", value = "用户ID") + private String userIdAndValue; + @ApiModelProperty(name = "userNameValue", value = "用户名称") + private String userNameValue; + @ApiModelProperty(name = "departmentIdAndNamesValue", value = "部门ID和名称") + private String departmentIdAndNamesValue; + @ApiModelProperty(name = "departmentNamesValue", value = "部门名称") + private String departmentNamesValue; + @ApiModelProperty(name = "roleIdAndNamesValue", value = "角色ID和名称") + private String roleIdAndNamesValue; + @ApiModelProperty(name = "roleNamesValue", value = "角色名称") + private String roleNamesValue; + @ApiModelProperty(name = "groupIdAndNamesValue", value = "组名ID和名称") + private String groupIdAndNamesValue; + @ApiModelProperty(name = "groupNamesValue", value = "组名称") + private String groupNamesValue; + @ApiModelProperty(name = "positionIdAndNamesValue", value = "职位ID和名称") + private String positionIdAndNamesValue; + @ApiModelProperty(name = "positionNamesValue", value = "职位名称") + private String positionNamesValue; + + public String getUserIdAndValue() { + return userIdAndValue == null ? "" : userIdAndValue.trim(); + } + + public void setUserIdAndValue(String userIdAndValue) { + this.userIdAndValue = userIdAndValue; + } + + public String getUserNameValue() { + return userNameValue == null ? "" : userNameValue.trim(); + } + + public void setUserNameValue(String userNameValue) { + this.userNameValue = userNameValue; + } + + public String getDepartmentIdAndNamesValue() { + return departmentIdAndNamesValue == null ? "" : departmentIdAndNamesValue.trim(); + } + + public void setDepartmentIdAndNamesValue(String departmentIdAndNamesValue) { + this.departmentIdAndNamesValue = departmentIdAndNamesValue; + } + + public String getDepartmentNamesValue() { + return departmentNamesValue == null ? "" : departmentNamesValue.trim(); + } + + public void setDepartmentNamesValue(String departmentNamesValue) { + this.departmentNamesValue = departmentNamesValue; + } + + public String getRoleIdAndNamesValue() { + return roleIdAndNamesValue == null ? "" : roleIdAndNamesValue.trim(); + } + + public void setRoleIdAndNamesValue(String roleIdAndNamesValue) { + this.roleIdAndNamesValue = roleIdAndNamesValue; + } + + public String getRoleNamesValue() { + return roleNamesValue == null ? "" : roleNamesValue.trim(); + } + + public void setRoleNamesValue(String roleNamesValue) { + this.roleNamesValue = roleNamesValue; + } + + public String getGroupIdAndNamesValue() { + return groupIdAndNamesValue == null ? "" : groupIdAndNamesValue.trim(); + } + + public void setGroupIdAndNamesValue(String groupIdAndNamesValue) { + this.groupIdAndNamesValue = groupIdAndNamesValue; + } + + public String getGroupNamesValue() { + return groupNamesValue == null ? "" : groupNamesValue.trim(); + } + + public void setGroupNamesValue(String groupNamesValue) { + this.groupNamesValue = groupNamesValue; + } + + public String getPositionIdAndNamesValue() { + return positionIdAndNamesValue == null ? "" : positionIdAndNamesValue.trim(); + } + + public void setPositionIdAndNamesValue(String positionIdAndNamesValue) { + this.positionIdAndNamesValue = positionIdAndNamesValue; + } + + public String getPositionNamesValue() { + return positionNamesValue == null ? "" : positionNamesValue.trim(); + } + + public void setPositionNamesValue(String positionNamesValue) { + this.positionNamesValue = positionNamesValue; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("{"); + sb.append("\"userIdAndValue\":") + .append("\"").append(userIdAndValue).append("\""); + sb.append(",\"userNameValue\":") + .append("\"").append(userNameValue).append("\""); + sb.append(",\"departmentIdAndNamesValue\":") + .append("\"").append(departmentIdAndNamesValue).append("\""); + sb.append(",\"departmentNamesValue\":") + .append("\"").append(departmentNamesValue).append("\""); + sb.append(",\"roleIdAndNamesValue\":") + .append("\"").append(roleIdAndNamesValue).append("\""); + sb.append(",\"roleNamesValue\":") + .append("\"").append(roleNamesValue).append("\""); + sb.append(",\"groupIdAndNamesValue\":") + .append("\"").append(groupIdAndNamesValue).append("\""); + sb.append(",\"groupNamesValue\":") + .append("\"").append(groupNamesValue).append("\""); + sb.append(",\"positionIdAndNamesValue\":") + .append("\"").append(positionIdAndNamesValue).append("\""); + sb.append(",\"positionNamesValue\":") + .append("\"").append(positionNamesValue).append("\""); + sb.append('}'); + return sb.toString(); + } +} diff --git a/basic-pojo/src/main/java/ink/wgink/pojo/dtos/FileDTO.java b/basic-pojo/src/main/java/ink/wgink/pojo/dtos/FileDTO.java new file mode 100644 index 00000000..8bb95582 --- /dev/null +++ b/basic-pojo/src/main/java/ink/wgink/pojo/dtos/FileDTO.java @@ -0,0 +1,86 @@ +package ink.wgink.pojo.dtos; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.io.Serializable; + +/** + * @ClassName: FileDTO + * @Description: 文件 + * @Author: WangGeng + * @Date: 2019/3/10 10:47 PM + * @Version: 1.0 + **/ +@ApiModel +public class FileDTO implements Serializable { + + private static final long serialVersionUID = 3765953896919360869L; + @ApiModelProperty(name = "fileId", value = "文件ID") + private String fileId; + @ApiModelProperty(name = "fileName", value = "文件名称") + private String fileName; + @ApiModelProperty(name = "fileUrl", value = "文件链接") + private String fileUrl; + @ApiModelProperty(name = "fileType", value = "文件类型") + private String fileType; + @ApiModelProperty(name = "fileSize", value = "文件大小") + private Long fileSize; + + public String getFileId() { + return fileId == null ? "" : fileId.trim(); + } + + public void setFileId(String fileId) { + this.fileId = fileId; + } + + public String getFileName() { + return fileName == null ? "" : fileName.trim(); + } + + public void setFileName(String fileName) { + this.fileName = fileName; + } + + public String getFileUrl() { + return fileUrl == null ? "" : fileUrl.trim(); + } + + public void setFileUrl(String fileUrl) { + this.fileUrl = fileUrl; + } + + public String getFileType() { + return fileType == null ? "" : fileType.trim(); + } + + public void setFileType(String fileType) { + this.fileType = fileType; + } + + public Long getFileSize() { + return fileSize; + } + + public void setFileSize(Long fileSize) { + this.fileSize = fileSize; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("{"); + sb.append("\"fileId\":") + .append("\"").append(fileId).append("\""); + sb.append(",\"fileName\":") + .append("\"").append(fileName).append("\""); + sb.append(",\"fileUrl\":") + .append("\"").append(fileUrl).append("\""); + sb.append(",\"fileType\":") + .append("\"").append(fileType).append("\""); + sb.append(",\"fileSize\":") + .append("\"").append(fileSize).append("\""); + sb.append('}'); + return sb.toString(); + } +} diff --git a/basic-pojo/src/main/java/ink/wgink/pojo/dtos/UserAttrInfoDTO.java b/basic-pojo/src/main/java/ink/wgink/pojo/dtos/UserAttrInfoDTO.java new file mode 100644 index 00000000..bee82704 --- /dev/null +++ b/basic-pojo/src/main/java/ink/wgink/pojo/dtos/UserAttrInfoDTO.java @@ -0,0 +1,106 @@ +package ink.wgink.pojo.dtos; + +import com.cm.common.pojo.bos.DepartmentBO; +import com.cm.common.pojo.bos.GroupBO; +import com.cm.common.pojo.bos.PositionBO; +import com.cm.common.pojo.bos.RoleBO; + +import java.util.List; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: UserAttrInfoBO + * @Description: 用户属性 + * @Author: WangGeng + * @Date: 2020/2/7 1:42 下午 + * @Version: 1.0 + **/ +public class UserAttrInfoDTO { + + private List roles; + private List departments; + private List groups; + private List positions; + private String dataAuthority; + private List baseDepartmentIds; + private List dataAuthorityUserIds; + + public List getRoles() { + return roles; + } + + public void setRoles(List roles) { + this.roles = roles; + } + + public List getDepartments() { + return departments; + } + + public void setDepartments(List departments) { + this.departments = departments; + } + + public List getGroups() { + return groups; + } + + public void setGroups(List groups) { + this.groups = groups; + } + + public List getPositions() { + return positions; + } + + public void setPositions(List positions) { + this.positions = positions; + } + + public String getDataAuthority() { + return dataAuthority == null ? "" : dataAuthority.trim(); + } + + public void setDataAuthority(String dataAuthority) { + this.dataAuthority = dataAuthority; + } + + public List getBaseDepartmentIds() { + return baseDepartmentIds; + } + + public void setBaseDepartmentIds(List baseDepartmentIds) { + this.baseDepartmentIds = baseDepartmentIds; + } + + public List getDataAuthorityUserIds() { + return dataAuthorityUserIds; + } + + public void setDataAuthorityUserIds(List dataAuthorityUserIds) { + this.dataAuthorityUserIds = dataAuthorityUserIds; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("{"); + sb.append("\"roles\":") + .append(roles); + sb.append(",\"departments\":") + .append(departments); + sb.append(",\"groups\":") + .append(groups); + sb.append(",\"positions\":") + .append(positions); + sb.append(",\"dataAuthority\":") + .append("\"").append(dataAuthority).append("\""); + sb.append(",\"baseDepartmentIds\":") + .append(baseDepartmentIds); + sb.append(",\"dataAuthorityUserIds\":") + .append(dataAuthorityUserIds); + sb.append('}'); + return sb.toString(); + } +} diff --git a/basic-pojo/src/main/java/ink/wgink/pojo/dtos/ZTreeDTO.java b/basic-pojo/src/main/java/ink/wgink/pojo/dtos/ZTreeDTO.java new file mode 100644 index 00000000..5644aa81 --- /dev/null +++ b/basic-pojo/src/main/java/ink/wgink/pojo/dtos/ZTreeDTO.java @@ -0,0 +1,145 @@ +package ink.wgink.pojo.dtos; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.io.Serializable; + +/** + * @ClassName: ZTreeDTO + * @Description: zTree菜单 + * @Author: wenc + * @Date: 2018/12/29 12:13 AM + * @Version: 1.0 + **/ +@ApiModel +public class ZTreeDTO implements Cloneable, Serializable { + + private static final long serialVersionUID = 1972916766961693525L; + @ApiModelProperty(name = "id", value = "ID") + private String id; + @ApiModelProperty(name = "pId", value = "父ID") + private String pId; + @ApiModelProperty(name = "name", value = "节点名称") + private String name; + @ApiModelProperty(name = "url", value = "节点链接") + private String url; + @ApiModelProperty(name = "icon", value = "节点图标") + private String icon; + @ApiModelProperty(name = "target", value = "节点点击目标") + private String target; + @ApiModelProperty(name = "isParent", value = "是否父节点") + private Boolean isParent; + @ApiModelProperty(name = "checked", value = "是否勾选") + private Boolean checked; + @ApiModelProperty(name = "title", value = "标题") + private String title; + + public String getId() { + return id == null ? "" : id.trim(); + } + + public void setId(String id) { + this.id = id; + } + + public String getpId() { + return pId == null ? "" : pId.trim(); + } + + public void setpId(String pId) { + this.pId = pId; + } + + public String getName() { + return name == null ? "" : name.trim(); + } + + public void setName(String name) { + this.name = name; + } + + public String getUrl() { + return url == null ? "" : url.trim(); + } + + public void setUrl(String url) { + this.url = url; + } + + public String getIcon() { + return icon == null ? "" : icon.trim(); + } + + public void setIcon(String icon) { + this.icon = icon; + } + + public String getTarget() { + return target == null ? "" : target.trim(); + } + + public void setTarget(String target) { + this.target = target; + } + + public Boolean getIsParent() { + return isParent; + } + + public void setIsParent(Boolean parent) { + isParent = parent; + } + + public Boolean getChecked() { + return checked; + } + + public void setChecked(Boolean checked) { + this.checked = checked; + } + + public String getTitle() { + return title == null ? "" : title; + } + + public void setTitle(String title) { + this.title = title; + } + + @Override + public Object clone() { + ZTreeDTO zTreeDTO = null; + try{ + zTreeDTO = (ZTreeDTO) super.clone(); + }catch (CloneNotSupportedException e) { + e.printStackTrace(); + } + return zTreeDTO; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("{"); + sb.append("\"id\":\"") + .append(id).append('\"'); + sb.append(",\"pId\":\"") + .append(pId).append('\"'); + sb.append(",\"name\":\"") + .append(name).append('\"'); + sb.append(",\"url\":\"") + .append(url).append('\"'); + sb.append(",\"icon\":\"") + .append(icon).append('\"'); + sb.append(",\"target\":\"") + .append(target).append('\"'); + sb.append(",\"isParent\":") + .append(isParent); + sb.append(",\"checked\":") + .append(checked); + sb.append(",\"title\":\"") + .append(title).append('\"'); + sb.append('}'); + return sb.toString(); + } +} diff --git a/basic-pojo/src/main/java/ink/wgink/pojo/pos/FilePO.java b/basic-pojo/src/main/java/ink/wgink/pojo/pos/FilePO.java new file mode 100644 index 00000000..25243228 --- /dev/null +++ b/basic-pojo/src/main/java/ink/wgink/pojo/pos/FilePO.java @@ -0,0 +1,165 @@ +package ink.wgink.pojo.pos; + +import java.io.Serializable; + +/** + * @ClassName: FilePO + * @Description: 文件 + * @Author: wenc + * @Date: 2019/1/4 11:57 AM + * @Version: 1.0 + **/ +public class FilePO implements Serializable { + + private static final long serialVersionUID = -118382389804178231L; + private String fileId; + private String fileName; + private String filePath; + private String fileUrl; + private String fileType; + private String fileSize; + private String fileSummary; + private Integer isBack; + private String creator; + private String gmtCreate; + private String modifier; + private String gmtModified; + private Integer isDelete; + + public String getFileId() { + return fileId == null ? "" : fileId.trim(); + } + + public void setFileId(String fileId) { + this.fileId = fileId; + } + + public String getFileName() { + return fileName == null ? "" : fileName.trim(); + } + + public void setFileName(String fileName) { + this.fileName = fileName; + } + + public String getFilePath() { + return filePath == null ? "" : filePath.trim(); + } + + public void setFilePath(String filePath) { + this.filePath = filePath; + } + + public String getFileUrl() { + return fileUrl == null ? "" : fileUrl.trim(); + } + + public void setFileUrl(String fileUrl) { + this.fileUrl = fileUrl; + } + + public String getFileType() { + return fileType == null ? "" : fileType.trim(); + } + + public void setFileType(String fileType) { + this.fileType = fileType; + } + + public String getFileSize() { + return fileSize == null ? "" : fileSize.trim(); + } + + public void setFileSize(String fileSize) { + this.fileSize = fileSize; + } + + public String getFileSummary() { + return fileSummary == null ? "" : fileSummary.trim(); + } + + public void setFileSummary(String fileSummary) { + this.fileSummary = fileSummary; + } + + public Integer getIsBack() { + return isBack; + } + + public void setIsBack(Integer isBack) { + this.isBack = isBack; + } + + public String getCreator() { + return creator == null ? "" : creator.trim(); + } + + public void setCreator(String creator) { + this.creator = creator; + } + + public String getGmtCreate() { + return gmtCreate == null ? "" : gmtCreate.trim(); + } + + public void setGmtCreate(String gmtCreate) { + this.gmtCreate = gmtCreate; + } + + public String getModifier() { + return modifier == null ? "" : modifier.trim(); + } + + public void setModifier(String modifier) { + this.modifier = modifier; + } + + public String getGmtModified() { + return gmtModified == null ? "" : gmtModified.trim(); + } + + public void setGmtModified(String gmtModified) { + this.gmtModified = gmtModified; + } + + public Integer getIsDelete() { + return isDelete; + } + + public void setIsDelete(Integer isDelete) { + this.isDelete = isDelete; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("{"); + sb.append("\"fileId\":") + .append("\"").append(fileId).append("\""); + sb.append(",\"fileName\":") + .append("\"").append(fileName).append("\""); + sb.append(",\"filePath\":") + .append("\"").append(filePath).append("\""); + sb.append(",\"fileUrl\":") + .append("\"").append(fileUrl).append("\""); + sb.append(",\"fileType\":") + .append("\"").append(fileType).append("\""); + sb.append(",\"fileSize\":") + .append("\"").append(fileSize).append("\""); + sb.append(",\"fileSummary\":") + .append("\"").append(fileSummary).append("\""); + sb.append(",\"isBack\":") + .append(isBack); + sb.append(",\"creator\":") + .append("\"").append(creator).append("\""); + sb.append(",\"gmtCreate\":") + .append("\"").append(gmtCreate).append("\""); + sb.append(",\"modifier\":") + .append("\"").append(modifier).append("\""); + sb.append(",\"gmtModified\":") + .append("\"").append(gmtModified).append("\""); + sb.append(",\"isDelete\":") + .append(isDelete); + sb.append('}'); + return sb.toString(); + } +} diff --git a/basic-util/pom.xml b/basic-util/pom.xml index 01de1e8a..8a7de1c1 100644 --- a/basic-util/pom.xml +++ b/basic-util/pom.xml @@ -47,6 +47,10 @@ org.springframework spring-context-support + + org.springframework + spring-aop + @@ -95,10 +99,17 @@ joda-time joda-time - ${jodatime.version} + + + com.alibaba + fastjson + ${fastjson.version} + + + \ No newline at end of file diff --git a/common/pom.xml b/common/pom.xml index b1450d4a..2680f7b3 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -22,6 +22,11 @@ basic-util 1.0-SNAPSHOT + + ink.wgink + basic-exception + 1.0-SNAPSHOT + diff --git a/common/src/main/java/ink/wgink/common/base/DefaultBaseService.java b/common/src/main/java/ink/wgink/common/base/DefaultBaseService.java index 7e84b321..64f137a0 100644 --- a/common/src/main/java/ink/wgink/common/base/DefaultBaseService.java +++ b/common/src/main/java/ink/wgink/common/base/DefaultBaseService.java @@ -1,6 +1,22 @@ package ink.wgink.common.base; +import com.alibaba.fastjson.JSONObject; +import ink.wgink.common.component.SecurityComponent; +import ink.wgink.common.enums.RoleDataAuthorityEnum; +import ink.wgink.exceptions.AccessTokenException; +import ink.wgink.exceptions.SearchException; +import ink.wgink.interfaces.consts.ISystemConstant; +import ink.wgink.pojo.bos.UserInfoBO; +import ink.wgink.pojo.dtos.ZTreeDTO; +import ink.wgink.util.date.DateUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; + +import javax.servlet.http.HttpSession; +import java.util.*; /** * @ClassName: AbstractService @@ -12,6 +28,240 @@ import org.springframework.stereotype.Component; @Component public class DefaultBaseService { + protected static Logger LOG = LoggerFactory.getLogger(DefaultBaseService.class); + @Autowired + protected SecurityComponent securityComponent; + @Autowired + private HttpSession httpSession; + /** + * 设置新增基础数据 + * + * @param params + */ + protected void setSaveInfo(Map params) { + UserInfoBO userInfoBO = securityComponent.getCurrentUser(); + if (userInfoBO != null) { + setSave(userInfoBO.getUserId(), params); + } else { + setSave("1", params); + } + } + + /** + * 设置新增基础信息 + * + * @param params + * @param userId + */ + protected void setSaveInfoByUserId(Map params, String userId) { + setSave(userId, params); + } + + /** + * 设置新增 + * + * @param userId + * @param params + */ + private void setSave(String userId, Map params) { + String currentDate = DateUtil.getTime(); + params.put("creator", userId); + params.put("gmtCreate", currentDate); + params.put("modifier", userId); + params.put("gmtModified", currentDate); + params.put("isDelete", 0); + } + + /** + * 设置修改基础数据 + * + * @param params + */ + protected void setUpdateInfo(Map params) { + UserInfoBO userInfoBO = securityComponent.getCurrentUser(); + setUpdate(userInfoBO.getUserId(), params); + } + + /** + * 设置更新基础信息 + * + * @param params + * @param userId + */ + protected void setUpdateInfoByUserId(Map params, String userId) { + setUpdate(userId, params); + } + + /** + * 设置修改 + * + * @param userId + * @param params + */ + private void setUpdate(String userId, Map params) { + String currentDate = DateUtil.getTime(); + params.put("modifier", userId); + params.put("gmtModified", currentDate); + } + + /** + * 设置zTree内容 + * + * @param zTreeDTO + * @param subCount + */ + protected void setZTreeInfo(ZTreeDTO zTreeDTO, Integer subCount) { + zTreeDTO.setUrl("javascript:void(0);"); + if (null != subCount && 0 < subCount) { + zTreeDTO.setIsParent(true); + } else { + zTreeDTO.setIsParent(false); + } + } + + /** + * 获取新的code + * + * @param code + * @param parentCode + * @return + */ + protected String getNewCode(String code, String parentCode) { + // 最后的code长度 + int lastCodeLength = code.length(); + int lastNumber = Integer.parseInt(code.substring(lastCodeLength - 4, lastCodeLength)) + 1; + code = String.format("%04d", lastNumber); + if (!StringUtils.isEmpty(parentCode)) { + code = parentCode + code; + } + return code; + } + + /** + * 获取session + * + * @return + */ + protected HttpSession getHttpSession() { + return httpSession; + } + + /** + * 获取HashMap + * + * @return + */ + protected Map getHashMap(int initSize) { + return new HashMap<>(initSize); + } + + /** + * 是否管理员 + * + * @return + */ + protected boolean isAdmin() { + if (ISystemConstant.ADMIN.equalsIgnoreCase(securityComponent.getCurrentUsername())) { + return true; + } + return false; + } + + /** + * 获取基础部门ID列表 + * + * @return + */ + protected List listBaseDepartmentIds() { + if (isAdmin()) { + return null; + } + return securityComponent.getCurrentUser().getBaseDepartmentIds(); + } + + /** + * 查询资源结果 + * + * @param result 结果 + * @param errorMessage 异常提示 + * @throws AccessTokenException + * @throws SearchException + */ + protected void searchResourceResult(String result, String errorMessage) throws AccessTokenException, SearchException { + if (result == null) { + throw new AccessTokenException("认证失败"); + } + if (result.isEmpty()) { + throw new SearchException(errorMessage); + } + } + + /** + * 更新结果 + * + * @param result + * @param errorMessage + * @throws AccessTokenException + * @throws SearchException + */ + protected void updateResourceResult(String result, String errorMessage) throws AccessTokenException, SearchException { + if (result == null) { + throw new AccessTokenException("认证失败"); + } + if (result.isEmpty()) { + throw new SearchException(errorMessage); + } + JSONObject resultObj = JSONObject.parseObject(result); + if (resultObj.getString("msg") != null) { + throw new SearchException(resultObj.getString("msg")); + } + } + + /** + * 简单Excel的Header + * + * @param names + * @return + */ + protected List> simpleExcelHeader(String... names) { + List> listHeaders = new ArrayList<>(); + for (String name : names) { + List listHeader = new ArrayList<>(); + listHeader.add(name); + listHeaders.add(listHeader); + } + return listHeaders; + } + + /** + * 设置数据权限信息 + * + * @param params + */ + protected void setDataAuthorityInfo(Map params) { + UserInfoBO currentUser = securityComponent.getCurrentUser(); + if (ISystemConstant.ADMIN.equals(securityComponent.getCurrentUser().getUserName())) { + return; + } + String dataAuthority = currentUser.getDataAuthority(); + List dataAuthorityUserIds = currentUser.getDataAuthorityUserIds(); + if (org.apache.commons.lang3.StringUtils.equals(RoleDataAuthorityEnum.ALL.getDataAuthorityType(), dataAuthority)) { + return; + } else if (org.apache.commons.lang3.StringUtils.equals(RoleDataAuthorityEnum.SELF.getDataAuthorityType(), dataAuthority)) { + params.put(ISystemConstant.DATA_AUTHORITY, dataAuthority); + params.put(ISystemConstant.DATA_CREATOR, currentUser.getUserId()); + } else if (org.apache.commons.lang3.StringUtils.equals(RoleDataAuthorityEnum.DEPARTMENT.getDataAuthorityType(), dataAuthority) + || org.apache.commons.lang3.StringUtils.equals(RoleDataAuthorityEnum.CUSTOM.getDataAuthorityType(), dataAuthority)) { + if (Objects.isNull(dataAuthorityUserIds) || dataAuthorityUserIds.isEmpty()) { + LOG.debug("权限列表为空,设置查看个人"); + params.put(ISystemConstant.DATA_AUTHORITY, RoleDataAuthorityEnum.SELF.getDataAuthorityType()); + params.put(ISystemConstant.DATA_CREATOR, currentUser.getUserId()); + } else { + params.put(ISystemConstant.DATA_AUTHORITY, dataAuthority); + params.put(ISystemConstant.DATA_CREATORS, dataAuthorityUserIds); + } + } + } } diff --git a/common/src/main/java/ink/wgink/common/component/SecurityComponent.java b/common/src/main/java/ink/wgink/common/component/SecurityComponent.java new file mode 100644 index 00000000..e4d77282 --- /dev/null +++ b/common/src/main/java/ink/wgink/common/component/SecurityComponent.java @@ -0,0 +1,156 @@ +package ink.wgink.common.component; + +import ink.wgink.pojo.bos.*; +import ink.wgink.pojo.dtos.CurrentUserIdInfoDTO; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +/** + * @ClassName: SecurityCompontent + * @Description: 权限工具 + * @Author: WangGeng + * @Date: 2019/2/26 3:31 PM + * @Version: 1.0 + **/ +@Component +public class SecurityComponent { + + /** + * 超级管理员 + */ + public static final String USERNAME_ADMIN = "admin"; + + /** + * 获取当前用户 + * + * @return + */ + public UserInfoBO getCurrentUser() { + Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + Object user = authentication.getPrincipal(); + UserInfoBO userInfoBO = null; + if (user instanceof UserBO) { + userInfoBO = new UserInfoBO(); + UserBO userBO = (UserBO) user; + userInfoBO.setUserId(userBO.getUserId()); + userInfoBO.setUserUsername(userBO.getUsername()); + userInfoBO.setUserName(userBO.getUserName()); + userInfoBO.setUserPhone(userBO.getUserPhone()); + userInfoBO.setUserAvatar(userBO.getUserAvatar()); + userInfoBO.setUserEmail(userBO.getUserEmail()); + userInfoBO.setDataAuthority(userBO.getDataAuthority()); + userInfoBO.setDataAuthorityUserIds(userBO.getDataAuthorityUserIds()); + userInfoBO.setBaseDepartmentIds(userBO.getBaseDepartmentIds()); + userInfoBO.setRoles(userBO.getRoles()); + userInfoBO.setDepartments(userBO.getDepartments()); + userInfoBO.setGroups(userBO.getGroups()); + userInfoBO.setPositions(userBO.getPositions()); + } + if (user instanceof UserInfoBO) { + userInfoBO = (UserInfoBO) user; + } + return userInfoBO; + } + + /** + * 角色ID列表 + * + * @return + */ + public List listRoleIds() { + Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + Collection grantedAuthorities = authentication.getAuthorities(); + List roleIds = new ArrayList<>(); + for (GrantedAuthority grantedAuthority : grantedAuthorities) { + RoleGrantedAuthority roleGrantedAuthority = (RoleGrantedAuthority) grantedAuthority; + roleIds.add(roleGrantedAuthority.getRoleId()); + } + return roleIds; + } + + /** + * 当前角色列表 + * + * @return + */ + public List listRole() { + UserInfoBO userInfoBO = getCurrentUser(); + return userInfoBO.getRoles(); + } + + /** + * 部门列表 + * + * @return + */ + public List listDepartment() { + UserInfoBO userInfoBO = getCurrentUser(); + return userInfoBO.getDepartments(); + } + + /** + * 组列表 + * + * @return + */ + public List listGroup() { + UserInfoBO userInfoBO = getCurrentUser(); + return userInfoBO.getGroups(); + } + + /** + * 职位列白 + * + * @return + */ + public List listPosition() { + UserInfoBO userInfoBO = getCurrentUser(); + return userInfoBO.getPositions(); + } + + /** + * 获取当前用户名 + * + * @return + */ + public String getCurrentUsername() { + UserInfoBO userInfoBO = getCurrentUser(); + return userInfoBO.getUserUsername(); + } + + /** + * 获取当前用户ID信息 + * + * @return + */ + public CurrentUserIdInfoDTO getCurrentUserIdInfo() { + UserInfoBO userInfoBO = getCurrentUser(); + CurrentUserIdInfoDTO currentUserIdInfoDTO = new CurrentUserIdInfoDTO(); + currentUserIdInfoDTO.setUserIdAndValue(new StringBuilder(userInfoBO.getUserId()).append("|").append(userInfoBO.getUserName()).toString()); + currentUserIdInfoDTO.setUserNameValue(userInfoBO.getUserName()); + + String departmentIdAndNamesValue = userInfoBO.getDepartmentIdAndNamesValue(); + currentUserIdInfoDTO.setDepartmentIdAndNamesValue(departmentIdAndNamesValue); + currentUserIdInfoDTO.setDepartmentNamesValue(departmentIdAndNamesValue.isEmpty() ? departmentIdAndNamesValue : departmentIdAndNamesValue.split("\\|")[1]); + + String roleIdAndNamesValue = userInfoBO.getRoleIdAndNamesValue(); + currentUserIdInfoDTO.setRoleIdAndNamesValue(roleIdAndNamesValue); + currentUserIdInfoDTO.setRoleNamesValue(roleIdAndNamesValue.isEmpty() ? roleIdAndNamesValue : roleIdAndNamesValue.split("\\|")[1]); + + String groupIdAndNamesValue = userInfoBO.getGroupIdAndNamesValue(); + currentUserIdInfoDTO.setGroupIdAndNamesValue(groupIdAndNamesValue); + currentUserIdInfoDTO.setGroupNamesValue(groupIdAndNamesValue.isEmpty() ? groupIdAndNamesValue : groupIdAndNamesValue.split("\\|")[1]); + + String positionIdAndNamesValue = userInfoBO.getPositionIdAndNamesValue(); + currentUserIdInfoDTO.setPositionIdAndNamesValue(positionIdAndNamesValue); + currentUserIdInfoDTO.setPositionNamesValue(positionIdAndNamesValue.isEmpty() ? positionIdAndNamesValue : positionIdAndNamesValue.split("\\|")[1]); + return currentUserIdInfoDTO; + } + +} diff --git a/common/src/main/java/ink/wgink/common/enums/ErrorResultCodeEnum.java b/common/src/main/java/ink/wgink/common/enums/ErrorResultCodeEnum.java new file mode 100644 index 00000000..4c682d6d --- /dev/null +++ b/common/src/main/java/ink/wgink/common/enums/ErrorResultCodeEnum.java @@ -0,0 +1,41 @@ +package ink.wgink.common.enums; + +/** + * @ClassName: ErrorResultCodeEnum + * @Description: 错误代码 + * @Author: WangGeng + * @Date: 2019/3/2 3:51 PM + * @Version: 1.0 + **/ +public enum ErrorResultCodeEnum { + + /** + * 错误类型 + */ + SYSTEM_ERROR(40001), + TEXT_ILLEGAL(40101), + PARAMS_ERROR(40102), + QUERY_ERROR(40101), + SAVE_ERROR(40102), + UPDATE_ERROR(40103), + REMOVE_ERROR(40104), + FILE_ERROR(40401), + TEST_ERROR(40201), + LOGIN_OUT(40301), + TOKEN_ERROR(40302), + USERNAME_PASSWORD_ERROR(40303), + USER_EXIST(40304), + PERMISSION_ERROR(40401), + DEVICE_ERROR(40501), + DEVICE_VERSION_ERROR(40502); + + private int value; + + ErrorResultCodeEnum(int value) { + this.value = value; + } + + public int getValue() { + return value; + } +} diff --git a/common/src/main/java/ink/wgink/common/enums/RoleDataAuthorityEnum.java b/common/src/main/java/ink/wgink/common/enums/RoleDataAuthorityEnum.java new file mode 100644 index 00000000..514d639c --- /dev/null +++ b/common/src/main/java/ink/wgink/common/enums/RoleDataAuthorityEnum.java @@ -0,0 +1,29 @@ +package ink.wgink.common.enums; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: RoleDataAuthorityEnum + * @Description: 数据权限 + * @Author: WangGeng + * @Date: 2019/11/23 9:43 下午 + * @Version: 1.0 + **/ +public enum RoleDataAuthorityEnum { + + ALL("all"), + DEPARTMENT("department"), + CUSTOM("custom"), + SELF("self"); + + private String dataAuthorityType; + + RoleDataAuthorityEnum(String dataAuthorityType) { + this.dataAuthorityType = dataAuthorityType; + } + + public String getDataAuthorityType() { + return dataAuthorityType == null ? "" : dataAuthorityType.trim(); + } +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 01c0b45d..f3ba39e9 100644 --- a/pom.xml +++ b/pom.xml @@ -13,6 +13,8 @@ basic-util common service-user + basic-app + basic-exception pom @@ -93,6 +95,21 @@ spring-context-support ${spring.version} + + org.springframework + spring-aop + ${spring.version} + + + org.springframework.security + spring-security-config + ${spring.version} + + + org.springframework.security + spring-security-web + ${spring.version} + diff --git a/service-user/src/main/java/ink/wgink/service/user/controller/api/UserController.java b/service-user/src/main/java/ink/wgink/service/user/controller/api/UserController.java index 41736202..98531b9b 100644 --- a/service-user/src/main/java/ink/wgink/service/user/controller/api/UserController.java +++ b/service-user/src/main/java/ink/wgink/service/user/controller/api/UserController.java @@ -1,5 +1,6 @@ package ink.wgink.service.user.controller.api; +import ink.wgink.common.base.DefaultBaseController; import ink.wgink.interfaces.consts.ISystemConstant; import io.swagger.annotations.Api; import org.springframework.web.bind.annotation.RequestMapping; @@ -18,7 +19,7 @@ import org.springframework.web.bind.annotation.RestController; @Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "用户信息管理") @RestController @RequestMapping(ISystemConstant.API_PREFIX + "/user") -public class UserController { +public class UserController extends DefaultBaseController { diff --git a/service-user/src/main/java/ink/wgink/service/user/service/UserServiceImpl.java b/service-user/src/main/java/ink/wgink/service/user/service/UserServiceImpl.java index b991a709..e823cb77 100644 --- a/service-user/src/main/java/ink/wgink/service/user/service/UserServiceImpl.java +++ b/service-user/src/main/java/ink/wgink/service/user/service/UserServiceImpl.java @@ -1,5 +1,6 @@ package ink.wgink.service.user.service; +import ink.wgink.common.base.DefaultBaseService; import ink.wgink.interfaces.user.IUserService; import org.springframework.stereotype.Service; @@ -14,7 +15,7 @@ import org.springframework.stereotype.Service; * @Version: 1.0 **/ @Service -public class UserServiceImpl implements IUserService { +public class UserServiceImpl extends DefaultBaseService implements IUserService {