init:初始化项目
commit
c79d96e14b
@ -0,0 +1,33 @@
|
|||||||
|
HELP.md
|
||||||
|
target/
|
||||||
|
!.mvn/wrapper/maven-wrapper.jar
|
||||||
|
!**/src/main/**/target/
|
||||||
|
!**/src/test/**/target/
|
||||||
|
|
||||||
|
### STS ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
.sts4-cache
|
||||||
|
|
||||||
|
### IntelliJ IDEA ###
|
||||||
|
.idea
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
/nbproject/private/
|
||||||
|
/nbbuild/
|
||||||
|
/dist/
|
||||||
|
/nbdist/
|
||||||
|
/.nb-gradle/
|
||||||
|
build/
|
||||||
|
!**/src/main/**/build/
|
||||||
|
!**/src/test/**/build/
|
||||||
|
|
||||||
|
### VS Code ###
|
||||||
|
.vscode/
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
package com.ngskcloud.advise;
|
||||||
|
|
||||||
|
import cn.dev33.satoken.util.SaResult;
|
||||||
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
|
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||||
|
|
||||||
|
@RestControllerAdvice
|
||||||
|
public class GlobalExceptionHandler {
|
||||||
|
// 全局异常拦截
|
||||||
|
@ExceptionHandler
|
||||||
|
public SaResult handlerException(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return SaResult.error(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
package com.ngskcloud.config;
|
||||||
|
|
||||||
|
|
||||||
|
import feign.codec.Decoder;
|
||||||
|
import feign.codec.Encoder;
|
||||||
|
|
||||||
|
import feign.jackson.JacksonDecoder;
|
||||||
|
import feign.jackson.JacksonEncoder;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class FeignConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Encoder feignEncoder() {
|
||||||
|
return new JacksonEncoder();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Decoder feignDecoder() {
|
||||||
|
return new JacksonDecoder();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
package com.ngskcloud.config;
|
||||||
|
|
||||||
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
//@Configuration
|
||||||
|
//@MapperScan("com.ngskcloud.mapper")
|
||||||
|
//public class MybatisConfig {
|
||||||
|
//}
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
package com.ngskcloud.config;
|
||||||
|
|
||||||
|
import cn.dev33.satoken.jwt.StpLogicJwtForSimple;
|
||||||
|
import cn.dev33.satoken.stp.StpLogic;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class SaTokenConfig {
|
||||||
|
|
||||||
|
// Sa-Token 整合 jwt (Simple 简单模式)
|
||||||
|
@Bean
|
||||||
|
public StpLogic getStpLogicJwt() {
|
||||||
|
return new StpLogicJwtForSimple();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
package com.ngskcloud.constant;
|
||||||
|
|
||||||
|
public class SystemConstant {
|
||||||
|
|
||||||
|
public static final String VERSION = "v1.0-beta1";
|
||||||
|
|
||||||
|
public static final String ENV_PROD = "prod";
|
||||||
|
|
||||||
|
public static final String REDIS_PREFIX = "playedu:";
|
||||||
|
|
||||||
|
public static final String JWT_PRV_ADMIN_USER =
|
||||||
|
"dc14511e97e7eb725fb2976bc939b375"; // AdminUser的md5加密
|
||||||
|
public static final String JWT_PRV_USER = "8f9bfe9d1345237cb3b2b205864da075"; // User的md5加密
|
||||||
|
|
||||||
|
public static final String INTERNAL_IP = "127.0.0.1";
|
||||||
|
|
||||||
|
public static final String INTERNAL_IP_AREA = "内网";
|
||||||
|
|
||||||
|
public static final String CONFIG_MASK = "********";
|
||||||
|
}
|
||||||
@ -0,0 +1,174 @@
|
|||||||
|
package com.ngskcloud.entity;/*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @TableName admin_users
|
||||||
|
*/
|
||||||
|
@TableName(value = "admin_users")
|
||||||
|
@Data
|
||||||
|
@Slf4j
|
||||||
|
public class AdminUser implements Serializable {
|
||||||
|
/** */
|
||||||
|
@TableId(type = IdType.ASSIGN_ID)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/** 姓名 */
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/** 邮箱 */
|
||||||
|
private String email;
|
||||||
|
|
||||||
|
/** 密码 */
|
||||||
|
@JsonIgnore private String password;
|
||||||
|
|
||||||
|
/** Salt */
|
||||||
|
@JsonIgnore private String salt;
|
||||||
|
|
||||||
|
/** 登录IP */
|
||||||
|
@JsonProperty("login_ip")
|
||||||
|
private String loginIp;
|
||||||
|
|
||||||
|
/** 登录时间 */
|
||||||
|
@JsonProperty("login_at")
|
||||||
|
private Date loginAt;
|
||||||
|
|
||||||
|
/** 1禁止登录,0否 */
|
||||||
|
@JsonProperty("is_ban_login")
|
||||||
|
private Integer isBanLogin;
|
||||||
|
|
||||||
|
/** 登录次数 */
|
||||||
|
@JsonProperty("login_times")
|
||||||
|
private Integer loginTimes;
|
||||||
|
/** 登陆账号 */
|
||||||
|
@JsonProperty("account")
|
||||||
|
private String account;
|
||||||
|
|
||||||
|
@JsonProperty("created_at")
|
||||||
|
private Date createdAt;
|
||||||
|
|
||||||
|
@JsonProperty("updated_at")
|
||||||
|
private Date updatedAt;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
// @JsonGetter("email")
|
||||||
|
// public String transformEmail() {
|
||||||
|
// return BackendBus.valueHidden(
|
||||||
|
// BPermissionConstant.DATA_ADMIN_EMAIL,
|
||||||
|
// BackendConstant.PRIVACY_FIELD_TYPE_EMAIL,
|
||||||
|
// email);
|
||||||
|
// }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object that) {
|
||||||
|
if (this == that) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (that == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (getClass() != that.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
AdminUser other = (AdminUser) that;
|
||||||
|
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
|
||||||
|
&& (this.getName() == null
|
||||||
|
? other.getName() == null
|
||||||
|
: this.getName().equals(other.getName()))
|
||||||
|
&& (this.getEmail() == null
|
||||||
|
? other.getEmail() == null
|
||||||
|
: this.getEmail().equals(other.getEmail()))
|
||||||
|
&& (this.getPassword() == null
|
||||||
|
? other.getPassword() == null
|
||||||
|
: this.getPassword().equals(other.getPassword()))
|
||||||
|
&& (this.getSalt() == null
|
||||||
|
? other.getSalt() == null
|
||||||
|
: this.getSalt().equals(other.getSalt()))
|
||||||
|
&& (this.getLoginIp() == null
|
||||||
|
? other.getLoginIp() == null
|
||||||
|
: this.getLoginIp().equals(other.getLoginIp()))
|
||||||
|
&& (this.getLoginAt() == null
|
||||||
|
? other.getLoginAt() == null
|
||||||
|
: this.getLoginAt().equals(other.getLoginAt()))
|
||||||
|
&& (this.getIsBanLogin() == null
|
||||||
|
? other.getIsBanLogin() == null
|
||||||
|
: this.getIsBanLogin().equals(other.getIsBanLogin()))
|
||||||
|
&& (this.getLoginTimes() == null
|
||||||
|
? other.getLoginTimes() == null
|
||||||
|
: this.getLoginTimes().equals(other.getLoginTimes()))
|
||||||
|
&& (this.getCreatedAt() == null
|
||||||
|
? other.getCreatedAt() == null
|
||||||
|
: this.getCreatedAt().equals(other.getCreatedAt()))
|
||||||
|
&& (this.getUpdatedAt() == null
|
||||||
|
? other.getUpdatedAt() == null
|
||||||
|
: this.getUpdatedAt().equals(other.getUpdatedAt()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
|
||||||
|
result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
|
||||||
|
result = prime * result + ((getEmail() == null) ? 0 : getEmail().hashCode());
|
||||||
|
result = prime * result + ((getPassword() == null) ? 0 : getPassword().hashCode());
|
||||||
|
result = prime * result + ((getSalt() == null) ? 0 : getSalt().hashCode());
|
||||||
|
result = prime * result + ((getLoginIp() == null) ? 0 : getLoginIp().hashCode());
|
||||||
|
result = prime * result + ((getLoginAt() == null) ? 0 : getLoginAt().hashCode());
|
||||||
|
result = prime * result + ((getIsBanLogin() == null) ? 0 : getIsBanLogin().hashCode());
|
||||||
|
result = prime * result + ((getLoginTimes() == null) ? 0 : getLoginTimes().hashCode());
|
||||||
|
result = prime * result + ((getCreatedAt() == null) ? 0 : getCreatedAt().hashCode());
|
||||||
|
result = prime * result + ((getUpdatedAt() == null) ? 0 : getUpdatedAt().hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append(getClass().getSimpleName());
|
||||||
|
sb.append(" [");
|
||||||
|
sb.append("Hash = ").append(hashCode());
|
||||||
|
sb.append(", id=").append(id);
|
||||||
|
sb.append(", name=").append(name);
|
||||||
|
sb.append(", email=").append(email);
|
||||||
|
sb.append(", password=").append(password);
|
||||||
|
sb.append(", salt=").append(salt);
|
||||||
|
sb.append(", loginIp=").append(loginIp);
|
||||||
|
sb.append(", loginAt=").append(loginAt);
|
||||||
|
sb.append(", isBanLogin=").append(isBanLogin);
|
||||||
|
sb.append(", loginTimes=").append(loginTimes);
|
||||||
|
sb.append(", createdAt=").append(createdAt);
|
||||||
|
sb.append(", updatedAt=").append(updatedAt);
|
||||||
|
sb.append(", serialVersionUID=").append(serialVersionUID);
|
||||||
|
sb.append("]");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,266 @@
|
|||||||
|
package com.ngskcloud.entity;/*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonGetter;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @TableName users
|
||||||
|
*/
|
||||||
|
@TableName(value = "users")
|
||||||
|
@Data
|
||||||
|
public class User implements Serializable {
|
||||||
|
|
||||||
|
/** */
|
||||||
|
@TableId(type = IdType.ASSIGN_ID)
|
||||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/** 邮件 */
|
||||||
|
private String email;
|
||||||
|
|
||||||
|
/** 真实姓名 */
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/** 头像 */
|
||||||
|
private String avatar;
|
||||||
|
|
||||||
|
/** 密码 */
|
||||||
|
@JsonIgnore private String password;
|
||||||
|
|
||||||
|
/** salt */
|
||||||
|
@JsonIgnore private String salt;
|
||||||
|
|
||||||
|
/** 身份证号 */
|
||||||
|
@JsonProperty("id_card")
|
||||||
|
private String idCard;
|
||||||
|
|
||||||
|
/** 学分 */
|
||||||
|
private Integer credit1;
|
||||||
|
|
||||||
|
/** 注册Ip */
|
||||||
|
@JsonProperty("create_ip")
|
||||||
|
private String createIp;
|
||||||
|
|
||||||
|
/** 注册城市 */
|
||||||
|
@JsonProperty("create_city")
|
||||||
|
private String createCity;
|
||||||
|
|
||||||
|
/** 激活[1:是,0:否] */
|
||||||
|
@JsonProperty("is_active")
|
||||||
|
private Integer isActive;
|
||||||
|
|
||||||
|
/** 锁定[1:是,0:否] */
|
||||||
|
@JsonProperty("is_lock")
|
||||||
|
private Integer isLock;
|
||||||
|
|
||||||
|
/** 实名认证[1:是,0:否] */
|
||||||
|
@JsonProperty("is_verify")
|
||||||
|
private Integer isVerify;
|
||||||
|
|
||||||
|
/** 实名认证时间 */
|
||||||
|
@JsonProperty("verify_at")
|
||||||
|
private Date verifyAt;
|
||||||
|
|
||||||
|
/** 设置密码[1:是,0:否] */
|
||||||
|
@JsonProperty("is_set_password")
|
||||||
|
private Integer isSetPassword;
|
||||||
|
|
||||||
|
/** 登录时间 */
|
||||||
|
@JsonProperty("login_at")
|
||||||
|
private Date loginAt;
|
||||||
|
|
||||||
|
@JsonProperty("created_at")
|
||||||
|
private Date createdAt;
|
||||||
|
|
||||||
|
@JsonProperty("updated_at")
|
||||||
|
private Date updatedAt;
|
||||||
|
@TableLogic
|
||||||
|
private Integer isDeleted;
|
||||||
|
/** 同步状态 0-未同步 1-同步成功 2-同步失败 */
|
||||||
|
@JsonProperty("sync_status")
|
||||||
|
private int syncStatus;
|
||||||
|
/** 同步失败原因 */
|
||||||
|
@JsonProperty("sync_remark")
|
||||||
|
private String syncRemark;
|
||||||
|
|
||||||
|
/** 同步时间 */
|
||||||
|
@JsonProperty("sync_time")
|
||||||
|
private Date syncTime;
|
||||||
|
|
||||||
|
/** gitea账号 */
|
||||||
|
@JsonProperty("gitea_user")
|
||||||
|
private String giteaUser;
|
||||||
|
/** 账号 */
|
||||||
|
@JsonProperty("account")
|
||||||
|
private String account;
|
||||||
|
/** 管理员关联账号 */
|
||||||
|
@JsonProperty("admin_user")
|
||||||
|
private Integer adminUser;
|
||||||
|
|
||||||
|
// @TableField(exist = false)
|
||||||
|
// private List<UserSyncInfo> userSyncInfoList;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
// @JsonGetter("name")
|
||||||
|
// public String transformName() {
|
||||||
|
// return BackendBus.valueHidden(
|
||||||
|
// BPermissionConstant.DATA_USER_NAME,
|
||||||
|
// BackendConstant.PRIVACY_FIELD_TYPE_NAME,
|
||||||
|
// getName());
|
||||||
|
// }
|
||||||
|
|
||||||
|
// @JsonGetter("email")
|
||||||
|
// public String transformEmail() {
|
||||||
|
// return BackendBus.valueHidden(
|
||||||
|
// BPermissionConstant.DATA_USER_EMAIL,
|
||||||
|
// BackendConstant.PRIVACY_FIELD_TYPE_EMAIL,
|
||||||
|
// getEmail());
|
||||||
|
// }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object that) {
|
||||||
|
if (this == that) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (that == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (getClass() != that.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
User other = (User) that;
|
||||||
|
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
|
||||||
|
&& (this.getEmail() == null
|
||||||
|
? other.getEmail() == null
|
||||||
|
: this.getEmail().equals(other.getEmail()))
|
||||||
|
&& (this.getName() == null
|
||||||
|
? other.getName() == null
|
||||||
|
: this.getName().equals(other.getName()))
|
||||||
|
&& (this.getAvatar() == null
|
||||||
|
? other.getAvatar() == null
|
||||||
|
: this.getAvatar().equals(other.getAvatar()))
|
||||||
|
&& (this.getPassword() == null
|
||||||
|
? other.getPassword() == null
|
||||||
|
: this.getPassword().equals(other.getPassword()))
|
||||||
|
&& (this.getSalt() == null
|
||||||
|
? other.getSalt() == null
|
||||||
|
: this.getSalt().equals(other.getSalt()))
|
||||||
|
&& (this.getIdCard() == null
|
||||||
|
? other.getIdCard() == null
|
||||||
|
: this.getIdCard().equals(other.getIdCard()))
|
||||||
|
&& (this.getCredit1() == null
|
||||||
|
? other.getCredit1() == null
|
||||||
|
: this.getCredit1().equals(other.getCredit1()))
|
||||||
|
&& (this.getCreateIp() == null
|
||||||
|
? other.getCreateIp() == null
|
||||||
|
: this.getCreateIp().equals(other.getCreateIp()))
|
||||||
|
&& (this.getCreateCity() == null
|
||||||
|
? other.getCreateCity() == null
|
||||||
|
: this.getCreateCity().equals(other.getCreateCity()))
|
||||||
|
&& (this.getIsActive() == null
|
||||||
|
? other.getIsActive() == null
|
||||||
|
: this.getIsActive().equals(other.getIsActive()))
|
||||||
|
&& (this.getIsLock() == null
|
||||||
|
? other.getIsLock() == null
|
||||||
|
: this.getIsLock().equals(other.getIsLock()))
|
||||||
|
&& (this.getIsVerify() == null
|
||||||
|
? other.getIsVerify() == null
|
||||||
|
: this.getIsVerify().equals(other.getIsVerify()))
|
||||||
|
&& (this.getVerifyAt() == null
|
||||||
|
? other.getVerifyAt() == null
|
||||||
|
: this.getVerifyAt().equals(other.getVerifyAt()))
|
||||||
|
&& (this.getIsSetPassword() == null
|
||||||
|
? other.getIsSetPassword() == null
|
||||||
|
: this.getIsSetPassword().equals(other.getIsSetPassword()))
|
||||||
|
&& (this.getLoginAt() == null
|
||||||
|
? other.getLoginAt() == null
|
||||||
|
: this.getLoginAt().equals(other.getLoginAt()))
|
||||||
|
&& (this.getCreatedAt() == null
|
||||||
|
? other.getCreatedAt() == null
|
||||||
|
: this.getCreatedAt().equals(other.getCreatedAt()))
|
||||||
|
&& (this.getUpdatedAt() == null
|
||||||
|
? other.getUpdatedAt() == null
|
||||||
|
: this.getUpdatedAt().equals(other.getUpdatedAt()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
|
||||||
|
result = prime * result + ((getEmail() == null) ? 0 : getEmail().hashCode());
|
||||||
|
result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
|
||||||
|
result = prime * result + ((getAvatar() == null) ? 0 : getAvatar().hashCode());
|
||||||
|
result = prime * result + ((getPassword() == null) ? 0 : getPassword().hashCode());
|
||||||
|
result = prime * result + ((getSalt() == null) ? 0 : getSalt().hashCode());
|
||||||
|
result = prime * result + ((getIdCard() == null) ? 0 : getIdCard().hashCode());
|
||||||
|
result = prime * result + ((getCredit1() == null) ? 0 : getCredit1().hashCode());
|
||||||
|
result = prime * result + ((getCreateIp() == null) ? 0 : getCreateIp().hashCode());
|
||||||
|
result = prime * result + ((getCreateCity() == null) ? 0 : getCreateCity().hashCode());
|
||||||
|
result = prime * result + ((getIsActive() == null) ? 0 : getIsActive().hashCode());
|
||||||
|
result = prime * result + ((getIsLock() == null) ? 0 : getIsLock().hashCode());
|
||||||
|
result = prime * result + ((getIsVerify() == null) ? 0 : getIsVerify().hashCode());
|
||||||
|
result = prime * result + ((getVerifyAt() == null) ? 0 : getVerifyAt().hashCode());
|
||||||
|
result =
|
||||||
|
prime * result + ((getIsSetPassword() == null) ? 0 : getIsSetPassword().hashCode());
|
||||||
|
result = prime * result + ((getLoginAt() == null) ? 0 : getLoginAt().hashCode());
|
||||||
|
result = prime * result + ((getCreatedAt() == null) ? 0 : getCreatedAt().hashCode());
|
||||||
|
result = prime * result + ((getUpdatedAt() == null) ? 0 : getUpdatedAt().hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append(getClass().getSimpleName());
|
||||||
|
sb.append(" [");
|
||||||
|
sb.append("Hash = ").append(hashCode());
|
||||||
|
sb.append(", id=").append(id);
|
||||||
|
sb.append(", email=").append(email);
|
||||||
|
sb.append(", name=").append(name);
|
||||||
|
sb.append(", avatar=").append(avatar);
|
||||||
|
sb.append(", password=").append(password);
|
||||||
|
sb.append(", salt=").append(salt);
|
||||||
|
sb.append(", idCard=").append(idCard);
|
||||||
|
sb.append(", credit1=").append(credit1);
|
||||||
|
sb.append(", createIp=").append(createIp);
|
||||||
|
sb.append(", createCity=").append(createCity);
|
||||||
|
sb.append(", isActive=").append(isActive);
|
||||||
|
sb.append(", isLock=").append(isLock);
|
||||||
|
sb.append(", isVerify=").append(isVerify);
|
||||||
|
sb.append(", verifyAt=").append(verifyAt);
|
||||||
|
sb.append(", isSetPassword=").append(isSetPassword);
|
||||||
|
sb.append(", loginAt=").append(loginAt);
|
||||||
|
sb.append(", createdAt=").append(createdAt);
|
||||||
|
sb.append(", updatedAt=").append(updatedAt);
|
||||||
|
sb.append(", serialVersionUID=").append(serialVersionUID);
|
||||||
|
sb.append("]");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,46 @@
|
|||||||
|
package com.ngskcloud.feign;
|
||||||
|
|
||||||
|
import cn.dev33.satoken.util.SaResult;
|
||||||
|
import com.ngskcloud.config.FeignConfig;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SSO 服务端 OpenFeign 客户端接口
|
||||||
|
* 用于其他微服务通过 Nacos 调用 SSO 功能
|
||||||
|
*/
|
||||||
|
@FeignClient(name = "sso-server", path = "/sso", configuration = FeignConfig.class)
|
||||||
|
public interface SsoServerClient {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录接口
|
||||||
|
*/
|
||||||
|
@GetMapping("/doLogin")
|
||||||
|
SaResult doLogin(@RequestParam("username") String account,
|
||||||
|
@RequestParam("pwd") String pwd,
|
||||||
|
@RequestParam("identity") Integer identity);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证ticket接口
|
||||||
|
*/
|
||||||
|
@GetMapping("/checkTicket")
|
||||||
|
SaResult checkTicket(@RequestParam("ticket") String ticket,
|
||||||
|
@RequestParam("identity") Integer identity);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查登录状态
|
||||||
|
*/
|
||||||
|
@GetMapping("/isLogin")
|
||||||
|
SaResult isLogin();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注销接口
|
||||||
|
*/
|
||||||
|
@PostMapping("/logout")
|
||||||
|
SaResult logout();
|
||||||
|
}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
package com.ngskcloud.interceptor;
|
||||||
|
|
||||||
|
import cn.dev33.satoken.interceptor.SaInterceptor;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class SaTokenInterceptorConfig implements WebMvcConfigurer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addInterceptors(InterceptorRegistry registry) {
|
||||||
|
// 注册 Sa-Token 拦截器,打开注解式鉴权功能
|
||||||
|
registry.addInterceptor(new SaInterceptor())
|
||||||
|
.addPathPatterns("/**")
|
||||||
|
.excludePathPatterns("/sso/**", "/error");
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
package com.ngskcloud.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.ngskcloud.entity.AdminUser;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
//@Mapper
|
||||||
|
public interface AdminUserMapper extends BaseMapper<AdminUser> {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.ngskcloud.mapper.AdminUserMapper">
|
||||||
|
|
||||||
|
<resultMap id="BaseResultMap" type="com.ngskcloud.entity.AdminUser">
|
||||||
|
<id property="id" column="id" jdbcType="INTEGER"/>
|
||||||
|
<result property="name" column="name" jdbcType="VARCHAR"/>
|
||||||
|
<result property="email" column="email" jdbcType="VARCHAR"/>
|
||||||
|
<result property="password" column="password" jdbcType="VARCHAR"/>
|
||||||
|
<result property="salt" column="salt" jdbcType="VARCHAR"/>
|
||||||
|
<result property="loginIp" column="login_ip" jdbcType="VARCHAR"/>
|
||||||
|
<result property="loginAt" column="login_at" jdbcType="TIMESTAMP"/>
|
||||||
|
<result property="isBanLogin" column="is_ban_login" jdbcType="TINYINT"/>
|
||||||
|
<result property="loginTimes" column="login_times" jdbcType="INTEGER"/>
|
||||||
|
<result property="createdAt" column="created_at" jdbcType="TIMESTAMP"/>
|
||||||
|
<result property="updatedAt" column="updated_at" jdbcType="TIMESTAMP"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
id
|
||||||
|
,name,email,
|
||||||
|
password,salt,login_ip,
|
||||||
|
login_at,is_ban_login,login_times,
|
||||||
|
created_at,updated_at
|
||||||
|
</sql>
|
||||||
|
</mapper>
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
package com.ngskcloud.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.ngskcloud.entity.User;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface UserMapper extends BaseMapper<User> {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.ngskcloud.mapper.UserMapper">
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
package com.ngskcloud.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.ngskcloud.entity.AdminUser;
|
||||||
|
|
||||||
|
|
||||||
|
public interface AdminUserService extends IService<AdminUser> {
|
||||||
|
AdminUser findByAccount(String account);
|
||||||
|
|
||||||
|
AdminUser findById(Long id);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
package com.ngskcloud.service.Impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.ngskcloud.entity.AdminUser;
|
||||||
|
import com.ngskcloud.mapper.AdminUserMapper;
|
||||||
|
import com.ngskcloud.service.AdminUserService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser> implements AdminUserService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AdminUser findByAccount(String account) {
|
||||||
|
return getOne(query().getWrapper().eq("account", account));
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public AdminUser findById(Long id) {
|
||||||
|
return getOne((query().getWrapper().eq("id", id)));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
package com.ngskcloud.service.Impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.ngskcloud.entity.User;
|
||||||
|
import com.ngskcloud.mapper.UserMapper;
|
||||||
|
import com.ngskcloud.service.UserService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public User find(String account) {
|
||||||
|
return getOne(query().getWrapper().eq("account", account));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public User find(Long id) {
|
||||||
|
return getOne(query().getWrapper().eq("id", id));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
package com.ngskcloud.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.ngskcloud.entity.User;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
|
||||||
|
public interface UserService extends IService<User> {
|
||||||
|
User find(String account);
|
||||||
|
User find(Long id);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,62 @@
|
|||||||
|
package com.ngskcloud.utils;
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by FernFlower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
import com.alibaba.cloud.commons.lang.StringUtils;
|
||||||
|
import org.apache.commons.codec.Charsets;
|
||||||
|
import org.springframework.util.DigestUtils;
|
||||||
|
|
||||||
|
import java.security.MessageDigest;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
|
||||||
|
public class DigestUtil {
|
||||||
|
|
||||||
|
private static final char[] HEX_CODE = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
|
||||||
|
|
||||||
|
public static String encrypt(String data) {
|
||||||
|
return StringUtils.isBlank(data) ? "" : sha1Hex(md5Hex(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static String md5Hex(final String data) {
|
||||||
|
return DigestUtils.md5DigestAsHex(data.getBytes(Charsets.UTF_8));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String sha1Hex(String data) {
|
||||||
|
return sha1Hex((data.getBytes(Charsets.UTF_8)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String sha1Hex(final byte[] bytes) {
|
||||||
|
return digestHex("SHA-1", bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String digestHex(String algorithm, byte[] bytes) {
|
||||||
|
try {
|
||||||
|
MessageDigest md = MessageDigest.getInstance(algorithm);
|
||||||
|
return encodeHex(md.digest(bytes));
|
||||||
|
} catch (NoSuchAlgorithmException var3) {
|
||||||
|
throw new RuntimeException(var3.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String encodeHex(byte[] bytes) {
|
||||||
|
StringBuilder r = new StringBuilder(bytes.length * 2);
|
||||||
|
byte[] var2 = bytes;
|
||||||
|
int var3 = bytes.length;
|
||||||
|
|
||||||
|
for(int var4 = 0; var4 < var3; ++var4) {
|
||||||
|
byte b = var2[var4];
|
||||||
|
r.append(HEX_CODE[b >> 4 & 15]);
|
||||||
|
r.append(HEX_CODE[b & 15]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return r.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String hex(String data) {
|
||||||
|
return StringUtils.isBlank(data) ? "" : sha1Hex(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,106 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.ngskcloud.utils;
|
||||||
|
|
||||||
|
import cn.hutool.http.useragent.UserAgent;
|
||||||
|
import cn.hutool.http.useragent.UserAgentUtil;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class RequestUtil {
|
||||||
|
|
||||||
|
public static HttpServletRequest handler() {
|
||||||
|
ServletRequestAttributes servletRequestAttributes =
|
||||||
|
(ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||||
|
return servletRequestAttributes == null ? null : servletRequestAttributes.getRequest();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static UserAgent ua() {
|
||||||
|
HttpServletRequest request = RequestUtil.handler();
|
||||||
|
if (request == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return UserAgentUtil.parse(request.getHeader("User-Agent"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String token() {
|
||||||
|
HttpServletRequest request = RequestUtil.handler();
|
||||||
|
if (request == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
String token = request.getHeader("Authorization");
|
||||||
|
if (token == null || token.length() == 0 || token.split(" ").length != 2) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return token.split(" ")[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String url() {
|
||||||
|
HttpServletRequest request = RequestUtil.handler();
|
||||||
|
return request == null ? "" : request.getRequestURL().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String uri() {
|
||||||
|
Integer portNumber = port();
|
||||||
|
return RequestUtil.domain()
|
||||||
|
+ (Arrays.asList(443, 80, 0).contains(portNumber) ? "" : ":" + portNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String uriWithProtocol() {
|
||||||
|
Integer portNumber = port();
|
||||||
|
return RequestUtil.protocol()
|
||||||
|
+ RequestUtil.domain()
|
||||||
|
+ (Arrays.asList(443, 80, 0).contains(portNumber) ? "" : ":" + portNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String pathname() {
|
||||||
|
HttpServletRequest request = RequestUtil.handler();
|
||||||
|
return request == null ? "" : request.getRequestURI();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Integer port() {
|
||||||
|
HttpServletRequest request = RequestUtil.handler();
|
||||||
|
return request == null ? 0 : request.getServerPort();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String domain() {
|
||||||
|
HttpServletRequest request = RequestUtil.handler();
|
||||||
|
if (request != null) {
|
||||||
|
String requestUrl = request.getRequestURL().toString();
|
||||||
|
List<String> urls = Arrays.asList(requestUrl.split("/"));
|
||||||
|
|
||||||
|
return urls.get(2).split(":")[0];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String protocol() {
|
||||||
|
HttpServletRequest request = RequestUtil.handler();
|
||||||
|
if (request != null) {
|
||||||
|
String requestUrl = request.getRequestURL().toString();
|
||||||
|
List<String> urls = Arrays.asList(requestUrl.split("//"));
|
||||||
|
|
||||||
|
return urls.get(0) + "//";
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<h1>hello word!!!</h1>
|
||||||
|
<p>this is a html page</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
package com.ngskcloud;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
|
@SpringBootTest
|
||||||
|
class BpmsSsoApplicationTests {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void contextLoads() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue