feat: oss
This commit is contained in:
92
sms-auth/sms-auth-common/pom.xml
Normal file
92
sms-auth/sms-auth-common/pom.xml
Normal file
@@ -0,0 +1,92 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.landaiqing</groupId>
|
||||
<artifactId>sms-auth</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>sms-auth-common</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>sms-auth-common</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<version>2.4.2</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>spring-boot-starter-logging</artifactId>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.28</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct</artifactId>
|
||||
<version>1.4.2.Final</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct-processor</artifactId>
|
||||
<version>1.4.2.Final</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-log4j2</artifactId>
|
||||
<version>2.4.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.79</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>19.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.11</version>
|
||||
</dependency>
|
||||
|
||||
<!-- <!– Sa-Token 权限认证,在线文档:https://sa-token.cc –>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>cn.dev33</groupId>-->
|
||||
<!-- <artifactId>sa-token-spring-boot-starter</artifactId>-->
|
||||
<!-- <version>1.37.0</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <!– Sa-Token 整合 Redis (使用 jackson 序列化方式) –>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>cn.dev33</groupId>-->
|
||||
<!-- <artifactId>sa-token-redis-jackson</artifactId>-->
|
||||
<!-- <version>1.37.0</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <!– 提供Redis连接池 –>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.apache.commons</groupId>-->
|
||||
<!-- <artifactId>commons-pool2</artifactId>-->
|
||||
<!-- <version>2.9.0</version>-->
|
||||
<!-- </dependency>-->
|
||||
</dependencies>
|
||||
</project>
|
@@ -0,0 +1,25 @@
|
||||
package com.landaiqing.auth.common.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.support.ResourceBundleMessageSource;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
@Configuration
|
||||
public class LocaleConfig {
|
||||
|
||||
@Bean
|
||||
public ResourceBundleMessageSource messageSource() {
|
||||
Locale.setDefault(Locale.CHINA);
|
||||
ResourceBundleMessageSource source = new ResourceBundleMessageSource();
|
||||
//设置国际化文件存储路径和名称 i18n目录,messages文件名
|
||||
source.setBasenames("i18n/messages");
|
||||
//设置根据key如果没有获取到对应的文本信息,则返回key作为信息
|
||||
source.setUseCodeAsDefaultMessage(true);
|
||||
//设置字符编码
|
||||
source.setDefaultEncoding("UTF-8");
|
||||
return source;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
package com.landaiqing.auth.common.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 分页请求实体
|
||||
*
|
||||
* @author: landaiqing
|
||||
*/
|
||||
@Data
|
||||
public class PageInfo {
|
||||
|
||||
private Integer pageNo = 1;
|
||||
|
||||
private Integer pageSize = 20;
|
||||
|
||||
public Integer getPageNo() {
|
||||
if (pageNo == null || pageNo < 1) {
|
||||
return 1;
|
||||
}
|
||||
return pageNo;
|
||||
}
|
||||
|
||||
public Integer getPageSize() {
|
||||
if (pageSize == null || pageSize < 1 || pageSize > Integer.MAX_VALUE) {
|
||||
return 20;
|
||||
}
|
||||
return pageSize;
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,57 @@
|
||||
package com.landaiqing.auth.common.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 分页返回实体
|
||||
*
|
||||
* @author: landaiqing
|
||||
*/
|
||||
@Data
|
||||
public class PageResult<T> implements Serializable {
|
||||
|
||||
private Integer pageNo = 1;
|
||||
|
||||
private Integer pageSize = 20;
|
||||
|
||||
private Integer total = 0;
|
||||
|
||||
private Integer totalPages = 0;
|
||||
|
||||
private List<T> result = Collections.emptyList();
|
||||
|
||||
private Integer start = 1;
|
||||
|
||||
private Integer end = 0;
|
||||
|
||||
public void setRecords(List<T> result) {
|
||||
this.result = result;
|
||||
if (result != null && result.size() > 0) {
|
||||
setTotal(result.size());
|
||||
}
|
||||
}
|
||||
|
||||
public void setTotal(Integer total) {
|
||||
this.total = total;
|
||||
if (this.pageSize > 0) {
|
||||
this.totalPages = (total / this.pageSize) + (total % this.pageSize == 0 ? 0 : 1);
|
||||
} else {
|
||||
this.totalPages = 0;
|
||||
}
|
||||
this.start = (this.pageSize > 0 ? (this.pageNo - 1) * this.pageSize : 0) + 1;
|
||||
this.end = (this.start - 1 + this.pageSize * (this.pageNo > 0 ? 1 : 0));
|
||||
}
|
||||
|
||||
public void setPageSize(Integer pageSize) {
|
||||
this.pageSize = pageSize;
|
||||
}
|
||||
|
||||
public void setPageNo(Integer pageNo) {
|
||||
this.pageNo = pageNo;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,51 @@
|
||||
package com.landaiqing.auth.common.entity;
|
||||
|
||||
import com.landaiqing.auth.common.enums.ResultCodeEnum;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Result<T> {
|
||||
|
||||
private Boolean success;
|
||||
|
||||
private Integer code;
|
||||
|
||||
private String message;
|
||||
|
||||
private T data;
|
||||
|
||||
public static Result ok(){
|
||||
Result result = new Result();
|
||||
result.setSuccess(true);
|
||||
result.setCode(ResultCodeEnum.SUCCESS.getCode());
|
||||
result.setMessage(ResultCodeEnum.SUCCESS.getDesc());
|
||||
return result;
|
||||
}
|
||||
|
||||
public static <T> Result ok(T data){
|
||||
Result result = new Result();
|
||||
result.setSuccess(true);
|
||||
result.setCode(ResultCodeEnum.SUCCESS.getCode());
|
||||
result.setMessage(ResultCodeEnum.SUCCESS.getDesc());
|
||||
result.setData(data);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Result fail(){
|
||||
Result result = new Result();
|
||||
result.setSuccess(false);
|
||||
result.setCode(ResultCodeEnum.FAIL.getCode());
|
||||
result.setMessage(ResultCodeEnum.FAIL.getDesc());
|
||||
return result;
|
||||
}
|
||||
|
||||
public static <T> Result fail(T data){
|
||||
Result result = new Result();
|
||||
result.setSuccess(false);
|
||||
result.setCode(ResultCodeEnum.FAIL.getCode());
|
||||
result.setMessage(ResultCodeEnum.FAIL.getDesc());
|
||||
result.setData(data);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
package com.landaiqing.auth.common.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 用户状态枚举
|
||||
*
|
||||
* @author: landaiqing
|
||||
*/
|
||||
@Getter
|
||||
public enum AuthUserStatusEnum {
|
||||
|
||||
OPEN(0,"启用"),
|
||||
CLOSE(1,"禁用");
|
||||
|
||||
public int code;
|
||||
|
||||
public String desc;
|
||||
|
||||
AuthUserStatusEnum(int code, String desc){
|
||||
this.code = code;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public static AuthUserStatusEnum getByCode(int codeVal){
|
||||
for(AuthUserStatusEnum resultCodeEnum : AuthUserStatusEnum.values()){
|
||||
if(resultCodeEnum.code == codeVal){
|
||||
return resultCodeEnum;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
package com.landaiqing.auth.common.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 删除状态枚举
|
||||
*
|
||||
* @author: landaiqing
|
||||
*/
|
||||
@Getter
|
||||
public enum IsDeletedFlagEnum {
|
||||
|
||||
DELETED(1,"已删除"),
|
||||
UN_DELETED(0,"未删除");
|
||||
|
||||
public int code;
|
||||
|
||||
public String desc;
|
||||
|
||||
IsDeletedFlagEnum(int code, String desc){
|
||||
this.code = code;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public static IsDeletedFlagEnum getByCode(int codeVal){
|
||||
for(IsDeletedFlagEnum resultCodeEnum : IsDeletedFlagEnum.values()){
|
||||
if(resultCodeEnum.code == codeVal){
|
||||
return resultCodeEnum;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
package com.landaiqing.auth.common.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum LanguageEnum {
|
||||
|
||||
ZH_CN("zh_CN", "中文/中国"),
|
||||
EN_US( "en_US", "英语/美国"),
|
||||
;
|
||||
|
||||
/**
|
||||
* 语言_国家缩写
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String desc;
|
||||
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
package com.landaiqing.auth.common.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum ResultCodeEnum {
|
||||
SUCCESS(200,"成功"),
|
||||
FAIL(500,"失败");
|
||||
private int code;
|
||||
private String desc;
|
||||
|
||||
ResultCodeEnum(int code, String desc){
|
||||
this.code=code;
|
||||
this.desc=desc;
|
||||
}
|
||||
public static ResultCodeEnum getByCode(int codeVal){
|
||||
for(ResultCodeEnum resultCodeEnum:ResultCodeEnum.values()){
|
||||
if(resultCodeEnum.code==codeVal){
|
||||
return resultCodeEnum;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@@ -0,0 +1,69 @@
|
||||
package com.landaiqing.auth.common.util;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.context.MessageSource;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class MessageUtil {
|
||||
|
||||
|
||||
/**
|
||||
* 根据key信息获取对应语言的内容
|
||||
*
|
||||
* @param key 消息key值
|
||||
* @param language 语言_国家
|
||||
* @return
|
||||
*/
|
||||
public static String get(String key, String language) {
|
||||
if (!StringUtils.isEmpty(language)) {
|
||||
String[] arrs = language.split("_");
|
||||
if (arrs.length == 2) {
|
||||
return get(key, new Locale(arrs[0], arrs[1]));
|
||||
}
|
||||
}
|
||||
//使用默认的国际化语言
|
||||
return get(key, Locale.getDefault());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据key信息获取对应语言的内容
|
||||
*
|
||||
* @param key 消息key值
|
||||
* @param params 需要替换到占位符中的参数 占位符下标重0开始 格式如: {0} {1}
|
||||
* @param language 语言_国家
|
||||
* @return
|
||||
*/
|
||||
public static String get(String key, Object[] params, String language) {
|
||||
if (!StringUtils.isEmpty(language)) {
|
||||
String arrs[] = language.split("_");
|
||||
if (arrs.length == 2) {
|
||||
return get(key, params, new Locale(arrs[0], arrs[1]));
|
||||
}
|
||||
}
|
||||
return get(key, params, Locale.getDefault());
|
||||
}
|
||||
|
||||
private static String get(String key, Locale language) {
|
||||
return get(key, new String[0], language);
|
||||
}
|
||||
|
||||
private static String get(String key, Object[] params, Locale language) {
|
||||
return getInstance().getMessage(key, params, language);
|
||||
}
|
||||
|
||||
private static MessageSource getInstance() {
|
||||
return Lazy.messageSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用懒加载方式实例化messageSource国际化工具
|
||||
*/
|
||||
private static class Lazy {
|
||||
private static final MessageSource messageSource = SpringUtil.getBean(MessageSource.class);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
package com.landaiqing.auth.common.util;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author Dominick Li
|
||||
* @description 普通类调用Spring bean对象使用的工具栏
|
||||
**/
|
||||
@Component
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class SpringUtil implements ApplicationContextAware {
|
||||
|
||||
private static ApplicationContext applicationContext = null;
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
if (SpringUtil.applicationContext == null) {
|
||||
SpringUtil.applicationContext = applicationContext;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过class获取Bean.
|
||||
*/
|
||||
public static <T> T getBean(Class<T> clazz) {
|
||||
return applicationContext.getBean(clazz);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,2 @@
|
||||
student_management=????
|
||||
sutdent_center=????
|
@@ -0,0 +1,2 @@
|
||||
student_management=student_management
|
||||
sutdent_center=sutdent_center
|
@@ -0,0 +1,2 @@
|
||||
student_management=????
|
||||
sutdent_center=????
|
Reference in New Issue
Block a user