commit
05077da71b
145 changed files with 10424 additions and 0 deletions
@ -0,0 +1,15 @@ |
|||
/target/ |
|||
/logs/ |
|||
/.idea/ |
|||
*.iml |
|||
*.bak |
|||
*.log |
|||
/.settings/ |
|||
*.project |
|||
*.classpath |
|||
*.factorypath |
|||
*.springBeans |
|||
/.apt_generated/ |
|||
/.externalToolBuilders/ |
|||
/bin/ |
|||
application-*.properties |
|||
@ -0,0 +1,35 @@ |
|||
<?xml version="1.0"?> |
|||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" |
|||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
|||
<modelVersion>4.0.0</modelVersion> |
|||
<parent> |
|||
<groupId>com.techsor</groupId> |
|||
<artifactId>buildics-oviphone-back</artifactId> |
|||
<version>0.0.1-SNAPSHOT</version> |
|||
</parent> |
|||
<artifactId>buildics-oviphone-back-common</artifactId> |
|||
<name>buildics-oviphone-back-common</name> |
|||
<url>http://maven.apache.org</url> |
|||
<properties> |
|||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
|||
</properties> |
|||
<dependencies> |
|||
<dependency> |
|||
<groupId>junit</groupId> |
|||
<artifactId>junit</artifactId> |
|||
<scope>test</scope> |
|||
</dependency> |
|||
|
|||
<dependency> |
|||
<groupId>com.techsor</groupId> |
|||
<artifactId>buildics-oviphone-back-dao</artifactId> |
|||
<version>0.0.1-SNAPSHOT</version> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.techsor</groupId> |
|||
<artifactId>buildics-oviphone-back-util</artifactId> |
|||
<version>0.0.1-SNAPSHOT</version> |
|||
</dependency> |
|||
|
|||
</dependencies> |
|||
</project> |
|||
@ -0,0 +1,22 @@ |
|||
package com.buildics.oviphone.back.common; |
|||
/** |
|||
* @author Mr.Jiang |
|||
* @time 2022年5月20日 下午2:01:41 |
|||
*/ |
|||
public class Constants { |
|||
|
|||
//这个很重要,不要随便动
|
|||
public static final String DES_SALT = "ci3b512jwy199511"; |
|||
|
|||
public static final String APP_NAME = "buildics_oviphone_back:"; |
|||
|
|||
//用户ID,登录名,企业ID,token
|
|||
public static final String ACCESS_TOKEN_FORMAT = APP_NAME + "RequestHeader:AccessToken:{0}:{1}:{2}:{3}"; |
|||
|
|||
public static final String CAPTCHA_VERIFICATION = APP_NAME + "CAPTCHA:VERIFICATION:"; |
|||
|
|||
public static final String DATASOURCE_PREFIX = "dataSourceForCompany_"; |
|||
|
|||
public static final String THIRD_DB_PREFIX = "data_center_buildics_"; |
|||
|
|||
} |
|||
@ -0,0 +1,167 @@ |
|||
package com.buildics.oviphone.back.common.config; |
|||
|
|||
import com.alibaba.druid.pool.DruidDataSource; |
|||
import com.baomidou.mybatisplus.core.MybatisConfiguration; |
|||
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean; |
|||
import com.buildics.oviphone.back.common.Constants; |
|||
import org.apache.ibatis.session.SqlSessionFactory; |
|||
import org.mybatis.spring.SqlSessionFactoryBean; |
|||
import org.mybatis.spring.SqlSessionTemplate; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.boot.context.properties.ConfigurationProperties; |
|||
import org.springframework.boot.jdbc.DataSourceBuilder; |
|||
import org.springframework.context.annotation.Bean; |
|||
import org.springframework.context.annotation.Configuration; |
|||
import org.springframework.context.annotation.Primary; |
|||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
|
|||
import javax.sql.DataSource; |
|||
import java.util.HashMap; |
|||
import java.util.Map; |
|||
|
|||
@Configuration |
|||
public class DataSourceAdminConfig { |
|||
|
|||
private static Logger logger = LoggerFactory.getLogger(DataSourceAdminConfig.class); |
|||
|
|||
@Value("${spring.datasource.admin.name}") |
|||
private String name; |
|||
|
|||
@Value("${spring.datasource.admin.url}") |
|||
private String url; |
|||
|
|||
@Value("${spring.datasource.admin.username}") |
|||
private String username; |
|||
|
|||
@Value("${spring.datasource.admin.password}") |
|||
private String password; |
|||
|
|||
@Value("${spring.datasource.admin.driverClassName}") |
|||
private String driverClassName; |
|||
|
|||
@Value("${spring.datasource.admin.type}") |
|||
private String type; |
|||
|
|||
@Value("${dynamic.jdbc.url}") |
|||
private String dynamicJdbcUrl; |
|||
|
|||
|
|||
private final static String THIRD_DB_PREFIX = Constants.THIRD_DB_PREFIX; |
|||
|
|||
private final static String DATASOURCE_PREFIX = Constants.DATASOURCE_PREFIX; |
|||
|
|||
|
|||
@Primary |
|||
@Bean |
|||
public DataSource adminDatasource() { |
|||
DruidDataSource datasource = DataSourceBuilder.create() |
|||
.url(url) |
|||
.username(username) |
|||
.password(password).driverClassName(driverClassName) |
|||
.type(DruidDataSource.class) |
|||
.build(); |
|||
|
|||
return datasource; |
|||
} |
|||
|
|||
@Bean |
|||
public JdbcTemplate jdbcTemplate(DataSource adminDatasource) { |
|||
return new JdbcTemplate(adminDatasource); |
|||
} |
|||
|
|||
// @Bean
|
|||
// @ConfigurationProperties(prefix = "mybatis.configuration")
|
|||
// public org.apache.ibatis.session.Configuration globalConfiguration() {
|
|||
// return new org.apache.ibatis.session.Configuration();
|
|||
// }
|
|||
|
|||
@Bean |
|||
public SqlSessionFactory sqlSessionFactory(@Qualifier("dynamicDataSource") DataSource dynamicDataSource) throws Exception { |
|||
// SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
|
|||
// sessionFactory.setDataSource(dynamicDataSource); // 设置为动态数据源
|
|||
// sessionFactory.setConfiguration(globalConfiguration());//驼峰设置mybatis.configuration.map-underscore-to-camel-case不生效处理
|
|||
// sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath*:mappers/**/*.xml")); // 设置Mapper XML文件的位置
|
|||
// return sessionFactory.getObject();
|
|||
|
|||
// 使用 MybatisSqlSessionFactoryBean 而不是 SqlSessionFactoryBean
|
|||
MybatisSqlSessionFactoryBean sessionFactory = new MybatisSqlSessionFactoryBean(); |
|||
sessionFactory.setDataSource(dynamicDataSource); |
|||
// 注意:MyBatis-Plus 的配置需要使用其专有的 Configuration
|
|||
// 确保com.baomidou.mybatisplus.core.MybatisConfiguration
|
|||
sessionFactory.setConfiguration(mybatisConfiguration()); |
|||
sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver() |
|||
.getResources("classpath*:mappers/**/*.xml")); |
|||
return sessionFactory.getObject(); |
|||
} |
|||
|
|||
// 修改 Configuration 的 Bean
|
|||
@Bean |
|||
public MybatisConfiguration mybatisConfiguration() { |
|||
MybatisConfiguration configuration = new com.baomidou.mybatisplus.core.MybatisConfiguration(); |
|||
// 开启驼峰命名
|
|||
configuration.setMapUnderscoreToCamelCase(true); |
|||
return configuration; |
|||
} |
|||
|
|||
@Bean |
|||
public SqlSessionTemplate sqlSessionTemplate(SqlSessionFactory sqlSessionFactory) { |
|||
return new SqlSessionTemplate(sqlSessionFactory); |
|||
} |
|||
|
|||
|
|||
@Bean |
|||
public DataSource dynamicDataSource(JdbcTemplate jdbcTemplate, DataSource adminDatasource) { |
|||
DynamicRouteDataSource dynamicDataSource = new DynamicRouteDataSource(); |
|||
Map<Object, Object> targetDataSources = new HashMap<>(); |
|||
|
|||
//Requirement for 2024-07-16: Small enterprises and large enterprises share the same database. For large enterprises, parent_id = 1
|
|||
String sql="\t\tSELECT\n" + |
|||
"\t\t\tbcom.id,\n" + |
|||
"\t\t\tbcom.company_name companyName\n" + |
|||
"\t\tFROM\n" + |
|||
"\t\t\tdata_center_buildics_admin.basic_company bcom\n" + |
|||
"\t\tWHERE bcom.flag != 1 and (parent_id = 1 or parent_id = -1)"; |
|||
|
|||
jdbcTemplate.query(sql,rs->{ |
|||
DruidDataSource dataSource1 = new DruidDataSource(); |
|||
String dbName=THIRD_DB_PREFIX+rs.getInt("id"); |
|||
String dbUrl=String.format(dynamicJdbcUrl,dbName); |
|||
dataSource1.setUrl(dbUrl); |
|||
dataSource1.setUsername(username); |
|||
dataSource1.setPassword(password); |
|||
dataSource1.setDriverClassName(driverClassName); |
|||
dataSource1.setDbType(type); |
|||
targetDataSources.put(DATASOURCE_PREFIX+rs.getInt("id"), dataSource1); |
|||
|
|||
}); |
|||
|
|||
dynamicDataSource.setTargetDataSources(targetDataSources); |
|||
dynamicDataSource.setDefaultTargetDataSource(adminDatasource); // 设置默认数据源
|
|||
return dynamicDataSource; |
|||
} |
|||
|
|||
public void updateTargetDataSources(DynamicRouteDataSource dynamicRouteDataSource, long companyId) { |
|||
DruidDataSource dataSource = new DruidDataSource(); |
|||
String dbUrl = String.format(dynamicJdbcUrl, THIRD_DB_PREFIX+companyId); |
|||
dataSource.setUrl(dbUrl); |
|||
dataSource.setUsername(username); |
|||
dataSource.setPassword(password); |
|||
dataSource.setDriverClassName(driverClassName); |
|||
dataSource.setDbType(type); |
|||
|
|||
Map<Object, Object> targetDataSources = new HashMap<>(dynamicRouteDataSource.getResolvedDataSources()); |
|||
|
|||
targetDataSources.put(DATASOURCE_PREFIX +companyId, dataSource); |
|||
dynamicRouteDataSource.setTargetDataSources(targetDataSources); |
|||
dynamicRouteDataSource.afterPropertiesSet(); // 重新加载数据源配置
|
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
package com.buildics.oviphone.back.common.config; |
|||
|
|||
public class DataSourceContextHolder { |
|||
|
|||
private static final ThreadLocal<String> contextHolder = new ThreadLocal<>(); |
|||
|
|||
public static void setCurrentDataSourceKey(String dataSourceKey) { |
|||
contextHolder.set(dataSourceKey); |
|||
} |
|||
|
|||
public static String getCurrentDataSourceKey() { |
|||
return contextHolder.get(); |
|||
} |
|||
|
|||
public static void clearCurrentDataSourceKey() { |
|||
contextHolder.remove(); |
|||
} |
|||
} |
|||
@ -0,0 +1,117 @@ |
|||
package com.buildics.oviphone.back.common.config; |
|||
|
|||
import com.buildics.oviphone.back.common.Constants; |
|||
import jakarta.servlet.http.HttpServletRequest; |
|||
import jakarta.servlet.http.HttpServletResponse; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Component; |
|||
import org.springframework.web.servlet.HandlerInterceptor; |
|||
|
|||
import java.util.*; |
|||
|
|||
|
|||
@Slf4j |
|||
@Component |
|||
public class DataSourceInterceptor implements HandlerInterceptor { |
|||
|
|||
@Autowired |
|||
JdbcTemplate jdbcTemplate; |
|||
|
|||
@Override |
|||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { |
|||
String companyId = request.getHeader("companyId"); |
|||
if (companyId != null && !companyId.isEmpty()) { |
|||
//Find the ID of the large enterprise.
|
|||
long topCompanyId = getTopCompanyId(companyId); |
|||
|
|||
String dataSourceKey = Constants.DATASOURCE_PREFIX + topCompanyId; // 创建数据源键
|
|||
log.info("当前数据源为:" + dataSourceKey); |
|||
DataSourceContextHolder.setCurrentDataSourceKey(dataSourceKey); |
|||
} |
|||
return true; |
|||
} |
|||
|
|||
public long getTopCompanyId(String companyId) { |
|||
|
|||
if (StringUtils.isBlank(companyId)) { |
|||
throw new IllegalArgumentException("companyId不能为空"); |
|||
} |
|||
|
|||
return getTopCompanyIdInternal(Long.parseLong(companyId), new HashSet<>()); |
|||
} |
|||
|
|||
private long getTopCompanyIdInternal(Long companyId, Set<Long> visited) { |
|||
|
|||
// 防止循环引用
|
|||
if (!visited.add(companyId)) { |
|||
throw new IllegalStateException("检测到公司父子结构循环,companyId=" + companyId); |
|||
} |
|||
|
|||
String sql = """ |
|||
SELECT id, parent_id |
|||
FROM data_center_buildics_admin.basic_company |
|||
WHERE flag != 1 AND id = ? |
|||
"""; |
|||
|
|||
List<Map<String, Object>> result = jdbcTemplate.queryForList(sql, companyId); |
|||
|
|||
if (result.isEmpty()) { |
|||
throw new IllegalStateException("公司不存在,companyId=" + companyId); |
|||
} |
|||
|
|||
Map<String, Object> row = result.get(0); |
|||
|
|||
Long parentId = row.get("parent_id") == null |
|||
? null |
|||
: ((Number) row.get("parent_id")).longValue(); |
|||
|
|||
// 顶级企业
|
|||
if (parentId == null || parentId == 1 || parentId == -1) { |
|||
return companyId; |
|||
} |
|||
|
|||
return getTopCompanyIdInternal(parentId, visited); |
|||
} |
|||
|
|||
/** |
|||
* 获取所有的一级企业 |
|||
* @return |
|||
*/ |
|||
public List<Long> getTopCompanyIdList(){ |
|||
List<Long> companyIdList=new ArrayList<>(); |
|||
String sql="\t\tSELECT\n" + |
|||
"\t\t\tbcom.id,\n" + |
|||
"\t\t\tbcom.company_name companyName\n" + |
|||
"\t\tFROM\n" + |
|||
"\t\t\tdata_center_buildics_admin.basic_company bcom\n" + |
|||
"\t\tWHERE (bcom.parent_id=1 or bcom.parent_id=-1) and bcom.flag != 1"; |
|||
|
|||
jdbcTemplate.query(sql,rs->{ |
|||
companyIdList.add(rs.getLong("id")); |
|||
}); |
|||
|
|||
// // 用于存放去重后的 topCompanyIdList
|
|||
// List<Long> topCompanyIdList = new ArrayList<>();
|
|||
// Set<Long> seenIds = new HashSet<>(); // 用于快速判断重复
|
|||
// // 遍历 companyIdList
|
|||
// for (Integer companyId : companyIdList) {
|
|||
// Long topCompanyId = getTopCompanyId(companyId.toString());
|
|||
// // 如果 topCompanyId 未出现在 seenIds 中,则添加
|
|||
// if (seenIds.add(topCompanyId)) {
|
|||
// topCompanyIdList.add(topCompanyId);
|
|||
// }
|
|||
// }
|
|||
|
|||
return companyIdList; |
|||
} |
|||
|
|||
@Override |
|||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) { |
|||
DataSourceContextHolder.clearCurrentDataSourceKey(); // 清理数据源键
|
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,13 @@ |
|||
package com.buildics.oviphone.back.common.config; |
|||
|
|||
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource; |
|||
|
|||
|
|||
public class DynamicRouteDataSource extends AbstractRoutingDataSource { |
|||
|
|||
@Override |
|||
protected Object determineCurrentLookupKey() { |
|||
// 返回当前线程要使用的数据源的键
|
|||
return DataSourceContextHolder.getCurrentDataSourceKey(); |
|||
} |
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
package com.buildics.oviphone.back.common.exception; |
|||
|
|||
/** |
|||
* 业务异常处理 |
|||
* |
|||
*/ |
|||
public class BusinessException extends RuntimeException{ |
|||
|
|||
/** |
|||
* 实例化一个新的业务异常 |
|||
* |
|||
* @param msg 异常信息 |
|||
*/ |
|||
public BusinessException(String msg) { |
|||
super(msg); |
|||
} |
|||
|
|||
/** |
|||
* 实例化一个新的业务异常 |
|||
* |
|||
* @param cause 异常原因 |
|||
*/ |
|||
public BusinessException(Throwable cause) { |
|||
super(cause); |
|||
} |
|||
|
|||
/** |
|||
* 实例化一个新的业务异常 |
|||
* |
|||
* @param msg 异常信息 |
|||
* @param cause 异常原因 |
|||
*/ |
|||
public BusinessException(String msg, Throwable cause) { |
|||
super(msg, cause); |
|||
} |
|||
} |
|||
@ -0,0 +1,26 @@ |
|||
package com.buildics.oviphone.back.common.exception; |
|||
|
|||
/** |
|||
* |
|||
* @author jwy-style |
|||
* |
|||
*/ |
|||
public class MsgCodeException extends RuntimeException{ |
|||
|
|||
private String message; |
|||
|
|||
public MsgCodeException(String message) { |
|||
super(message); |
|||
this.message = message; |
|||
} |
|||
|
|||
|
|||
public String getMessage() { |
|||
return message; |
|||
} |
|||
|
|||
public void setMessage(String message) { |
|||
this.message = message; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,26 @@ |
|||
package com.buildics.oviphone.back.common.language; |
|||
|
|||
import java.io.IOException; |
|||
import java.util.List; |
|||
|
|||
import org.springframework.boot.env.YamlPropertySourceLoader; |
|||
import org.springframework.core.env.PropertySource; |
|||
import org.springframework.core.io.support.DefaultPropertySourceFactory; |
|||
import org.springframework.core.io.support.EncodedResource; |
|||
|
|||
/** |
|||
* @PropertySource 解析.yum文件需要指定该工厂 |
|||
*/ |
|||
public class PropertySourceYumFactory extends DefaultPropertySourceFactory { |
|||
|
|||
@Override |
|||
public PropertySource<?> createPropertySource(String name, EncodedResource resource) throws IOException { |
|||
if (resource == null) { |
|||
return super.createPropertySource(name, resource); |
|||
} |
|||
List<PropertySource<?>> sources = new YamlPropertySourceLoader().load(resource.getResource().getFilename(), resource.getResource()); |
|||
return sources.get(0); |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,54 @@ |
|||
package com.buildics.oviphone.back.common.language.msg; |
|||
|
|||
import org.apache.commons.collections4.MapUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
@Component |
|||
public class MsgLanguageChange { |
|||
@Autowired |
|||
private Msg_EN msgEn; |
|||
@Autowired |
|||
private Msg_CN msgCn; |
|||
@Autowired |
|||
private Msg_JP msgJp; |
|||
|
|||
/** |
|||
* 参数映射 |
|||
* @param languaType |
|||
* @param code |
|||
* @return |
|||
*/ |
|||
public String getParameterMapByCode(Integer languaType,String code){ |
|||
String msg = null; |
|||
if(null != languaType){ |
|||
if(languaType == 0){//中文
|
|||
msg = MapUtils.getString(msgCn.getParameterMap(), code, code); |
|||
}else if(languaType == 1){//英文
|
|||
msg = MapUtils.getString(msgEn.getParameterMap(), code, code); |
|||
}else if(languaType == 2){//日语
|
|||
msg = MapUtils.getString(msgJp.getParameterMap(), code, code); |
|||
} |
|||
}else{ |
|||
msg = MapUtils.getString(msgJp.getParameterMap(), code, code); |
|||
} |
|||
return msg; |
|||
} |
|||
|
|||
public String getBadRequestMessage(Integer languaType,String code){ |
|||
String msg = null; |
|||
if(null != languaType){ |
|||
if(languaType == 0){//中文
|
|||
msg = MapUtils.getString(msgCn.getArgumentNotValid(), code, code); |
|||
}else if(languaType == 1){//英文
|
|||
msg = MapUtils.getString(msgEn.getArgumentNotValid(), code, code); |
|||
}else if(languaType == 2){//日语
|
|||
msg = MapUtils.getString(msgJp.getArgumentNotValid(), code, code); |
|||
} |
|||
}else{ |
|||
msg = MapUtils.getString(msgJp.getArgumentNotValid(), code, code); |
|||
} |
|||
return msg; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,25 @@ |
|||
package com.buildics.oviphone.back.common.language.msg; |
|||
|
|||
import java.util.Map; |
|||
|
|||
import org.springframework.boot.context.properties.ConfigurationProperties; |
|||
import org.springframework.context.annotation.PropertySource; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import com.buildics.oviphone.back.common.language.PropertySourceYumFactory; |
|||
|
|||
import lombok.Getter; |
|||
import lombok.Setter; |
|||
|
|||
@Setter |
|||
@Getter |
|||
@Component |
|||
@PropertySource(value = "classpath:/config/language/msg/msg_cn.yml", encoding = "UTF-8", factory = PropertySourceYumFactory.class) |
|||
@ConfigurationProperties(prefix = "msgcn") |
|||
public class Msg_CN { |
|||
|
|||
private Map<String,String> parameterMap; |
|||
|
|||
private Map<String,String> argumentNotValid; |
|||
|
|||
} |
|||
@ -0,0 +1,25 @@ |
|||
package com.buildics.oviphone.back.common.language.msg; |
|||
|
|||
import java.util.Map; |
|||
|
|||
import org.springframework.boot.context.properties.ConfigurationProperties; |
|||
import org.springframework.context.annotation.PropertySource; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import com.buildics.oviphone.back.common.language.PropertySourceYumFactory; |
|||
|
|||
import lombok.Getter; |
|||
import lombok.Setter; |
|||
|
|||
@Setter |
|||
@Getter |
|||
@Component |
|||
@PropertySource(value = "classpath:/config/language/msg/msg_en.yml", encoding = "UTF-8", factory = PropertySourceYumFactory.class) |
|||
@ConfigurationProperties(prefix = "msgen") |
|||
public class Msg_EN { |
|||
|
|||
private Map<String,String> parameterMap; |
|||
|
|||
private Map<String,String> argumentNotValid; |
|||
|
|||
} |
|||
@ -0,0 +1,25 @@ |
|||
package com.buildics.oviphone.back.common.language.msg; |
|||
|
|||
import java.util.Map; |
|||
|
|||
import org.springframework.boot.context.properties.ConfigurationProperties; |
|||
import org.springframework.context.annotation.PropertySource; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import com.buildics.oviphone.back.common.language.PropertySourceYumFactory; |
|||
|
|||
import lombok.Getter; |
|||
import lombok.Setter; |
|||
|
|||
@Setter |
|||
@Getter |
|||
@Component |
|||
@PropertySource(value = "classpath:/config/language/msg/msg_jp.yml", encoding = "UTF-8", factory = PropertySourceYumFactory.class) |
|||
@ConfigurationProperties(prefix = "msgjp") |
|||
public class Msg_JP { |
|||
|
|||
private Map<String,String> parameterMap; |
|||
|
|||
private Map<String,String> argumentNotValid; |
|||
|
|||
} |
|||
@ -0,0 +1,51 @@ |
|||
package com.buildics.oviphone.back.common.response; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
|
|||
/** |
|||
* |
|||
* @author jwy-style |
|||
* |
|||
*/ |
|||
public class BaseResponse<T> { |
|||
/** |
|||
* 返回码 |
|||
*/ |
|||
@Schema(description ="状态码, 0或者200表示成功",example = "0") |
|||
private int code; |
|||
/** |
|||
* 提示信息 |
|||
*/ |
|||
@Schema(description ="简单的提示信息",example = "服务器错误") |
|||
private String msg = "success"; |
|||
|
|||
public BaseResponse() { |
|||
|
|||
} |
|||
|
|||
public BaseResponse(int code) { |
|||
this.code = code; |
|||
} |
|||
|
|||
public BaseResponse(int code, String msg) { |
|||
this.code = code; |
|||
this.msg = msg; |
|||
} |
|||
|
|||
public int getCode() { |
|||
return code; |
|||
} |
|||
|
|||
public void setCode(int code) { |
|||
this.code = code; |
|||
} |
|||
|
|||
public String getMsg() { |
|||
return msg; |
|||
} |
|||
|
|||
public void setMsg(String msg) { |
|||
this.msg = msg; |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,66 @@ |
|||
package com.buildics.oviphone.back.common.response; |
|||
|
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
|
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* |
|||
* @author jwy-style |
|||
* |
|||
* @param <T> |
|||
*/ |
|||
public class PageResponse<T> extends BaseResponse<T>{ |
|||
/** |
|||
* 对象信息 |
|||
*/ |
|||
private T data; |
|||
|
|||
private Map<String,String> errorMap; |
|||
|
|||
public PageResponse() { |
|||
} |
|||
|
|||
public PageResponse(int code) { |
|||
super(code); |
|||
} |
|||
|
|||
public PageResponse(int code, String msg) { |
|||
super(code, msg); |
|||
} |
|||
|
|||
public PageResponse(int code,String msg,Map<String,String> errorMap){ |
|||
super(code, msg); |
|||
this.errorMap = errorMap; |
|||
} |
|||
|
|||
public static PageResponse success(Object data){ |
|||
PageResponse pageResponse = new PageResponse(); |
|||
pageResponse.setData((IPage) data); |
|||
pageResponse.setCode(ResponseCode.SUCCESS); |
|||
pageResponse.setMsg("success"); |
|||
return pageResponse; |
|||
} |
|||
|
|||
|
|||
public Map<String, String> getErrorMap() { |
|||
return errorMap; |
|||
} |
|||
|
|||
public void setErrorMap(Map<String, String> errorMap) { |
|||
this.errorMap = errorMap; |
|||
} |
|||
|
|||
public T getData() { |
|||
return data; |
|||
} |
|||
|
|||
public void setData(T data) { |
|||
this.data = data; |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,28 @@ |
|||
package com.buildics.oviphone.back.common.response; |
|||
|
|||
/** |
|||
* |
|||
* @author jwy-style |
|||
* |
|||
*/ |
|||
public class ResponseCode { |
|||
|
|||
/** 成功 */ |
|||
public static final int OK = 0; |
|||
/** |
|||
* 请求已成功,请求所希望的响应头或数据体将随此响应返回。 |
|||
*/ |
|||
public static final int SUCCESS = 200; |
|||
|
|||
//错误请求
|
|||
public static final int BAD_REQUEST = 400; |
|||
//未授权
|
|||
public static final int AUTHORIZE_FAILED = 401; |
|||
|
|||
//服务器内部错误
|
|||
public static final int SERVER_ERROR = 500; |
|||
public static final String SERVER_ERROR_MSG = "service error"; |
|||
|
|||
//查看msg提示信息
|
|||
public static final int MSG_ERROR = 20001; |
|||
} |
|||
@ -0,0 +1,104 @@ |
|||
package com.buildics.oviphone.back.common.response; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonInclude; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
|
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* |
|||
* @author jwy-style |
|||
* |
|||
* @param <T> |
|||
*/ |
|||
@JsonInclude(JsonInclude.Include.NON_NULL) |
|||
public class SimpleDataResponse<T> extends BaseResponse<T> { |
|||
/** |
|||
* 单个对象 |
|||
*/ |
|||
@Schema(description ="返回的数据",example = "object") |
|||
private T data; |
|||
|
|||
/** |
|||
* The parameters Error map. |
|||
*/ |
|||
@Schema(description ="复杂的提示信息",example = "{\"name\":\"长度过长\",\"age\":\"年龄太大\",\"weight\":\"体重超标\"}") |
|||
private Map<String, String> errorMap; |
|||
|
|||
public SimpleDataResponse() { |
|||
super(); |
|||
} |
|||
|
|||
public SimpleDataResponse(int code) { |
|||
super(code); |
|||
} |
|||
|
|||
public SimpleDataResponse(int code, String msg) { |
|||
super(code, msg); |
|||
} |
|||
|
|||
/** |
|||
* 响应结果,携带错误Map |
|||
* @param code |
|||
* @param msg |
|||
* @param errorMap |
|||
*/ |
|||
public SimpleDataResponse(int code, String msg, Map<String, String> errorMap) { |
|||
this(code, msg); |
|||
this.errorMap = errorMap; |
|||
} |
|||
|
|||
/** |
|||
* 成功响应 |
|||
* @return |
|||
*/ |
|||
public static SimpleDataResponse success(){ |
|||
return new SimpleDataResponse(ResponseCode.SUCCESS,"Success"); |
|||
} |
|||
|
|||
/** |
|||
* 多条数据,成功响应 |
|||
* @param rows |
|||
* @return |
|||
*/ |
|||
public static SimpleDataResponse success(int rows){ |
|||
return new SimpleDataResponse(ResponseCode.SUCCESS,"Success: "+rows); |
|||
} |
|||
|
|||
/** |
|||
* 成功响应,携带数据对象返回 |
|||
* @param data |
|||
* @return |
|||
*/ |
|||
public static SimpleDataResponse success(Object data){ |
|||
SimpleDataResponse comm = success(); |
|||
comm.setData(data); |
|||
return comm; |
|||
} |
|||
|
|||
|
|||
public static SimpleDataResponse fail(int code,String message){ |
|||
return new SimpleDataResponse(code,message); |
|||
} |
|||
public static SimpleDataResponse fail(int code,String message,Object data){ |
|||
SimpleDataResponse simpleDataResponse= new SimpleDataResponse(code,message); |
|||
simpleDataResponse.setData(data); |
|||
return simpleDataResponse; |
|||
} |
|||
public T getData() { |
|||
return data; |
|||
} |
|||
|
|||
public void setData(T data) { |
|||
this.data = data; |
|||
} |
|||
|
|||
public Map<String, String> getErrorMap() { |
|||
return errorMap; |
|||
} |
|||
|
|||
public void setErrorMap(Map<String, String> errorMap) { |
|||
this.errorMap = errorMap; |
|||
} |
|||
} |
|||
@ -0,0 +1,38 @@ |
|||
msgcn: |
|||
argumentNotValid: |
|||
1000: 未通过参数校验 |
|||
1001: 参数不能为空 |
|||
1002: 长度不能超过{0} |
|||
1003: 长度无效 |
|||
1004: 无效的邮箱 |
|||
1005: 数值范围在{0}到{1}之间 |
|||
1006: 必须大于或等于{0} |
|||
1007: 必须小于或等于{0} |
|||
1008: 无效的参数 |
|||
parameterMap: |
|||
serviceError: 内部服务错误 |
|||
tokenError: 接口鉴权失败 |
|||
excelEmpty: 表格为空 |
|||
lineNum: 第{0}行: |
|||
paramsFormatError: 参数格式错误 |
|||
verifCodeExpired: 验证码过期 |
|||
verifCodeError: 验证码错误 |
|||
accountExpired: 该账号已过期 |
|||
pwdError: 密码错误 |
|||
userNotExist: 用户不存在 |
|||
noOperationAuth: 无操作权限 |
|||
excelBuildingLineDuplicate: 表格内存在相同的数据 |
|||
userOrEmailNotExist: 用户名或邮箱不存在 |
|||
companyNameHasExisted: 平台已存在此企业 |
|||
taowaComapny: 不可使用下级企业作为父企业 |
|||
hasSubsidiary: 删除的企业拥有下级企业,需先处理下级企业 |
|||
roleNameExist: 角色名已存在 |
|||
roleHasBinded: 角色已绑定用户,请先解绑再删除 |
|||
loginNameOrEmailHasExisted: 用户名或邮箱已被使用 |
|||
mailAddUserPwdSubject: 新建账号密码 |
|||
mailAddUserPwdContent: 账号 <u>{0}</u> 的密码为:<u>{1}</u>, 请妥善保管<br/><br/>登陆网址:<u>{2}</u> |
|||
mailResetUserPwdSubject: 重置账号密码 |
|||
pwdFormatError: 密码组成必须包含数字、英文字母、特殊符号(~!@#$%^&*)且大于等于12位 |
|||
oldPwdError: 旧密码错误 |
|||
newPwdSameOld: 新密码不得与旧密码相同 |
|||
companyLimit: 最多可创建15个企业 |
|||
@ -0,0 +1,38 @@ |
|||
msgen: |
|||
argumentNotValid: |
|||
1000: 未通过参数校验 |
|||
1001: 参数不能为空 |
|||
1002: 长度不能超过{0} |
|||
1003: 长度无效 |
|||
1004: 无效的邮箱 |
|||
1005: 数值范围在{0}到{1}之间 |
|||
1006: 必须大于或等于{0} |
|||
1007: 必须小于或等于{0} |
|||
1008: 无效的参数 |
|||
parameterMap: |
|||
serviceError: Internal service error. |
|||
tokenError: API authentication failed. |
|||
excelEmpty: The spreadsheet is empty. |
|||
lineNum: "Lines {0}:" |
|||
paramsFormatError: Parameter format error. |
|||
verifCodeExpired: Verification code expired. |
|||
verifCodeError: Verification code error. |
|||
accountExpired: The account has expired. |
|||
pwdError: Password error. |
|||
userNotExist: User does not exist. |
|||
noOperationAuth: No operation permission. |
|||
excelBuildingLineDuplicate: Duplicate data exists in the spreadsheet. |
|||
userOrEmailNotExist: 用户名或邮箱不存在 |
|||
companyNameHasExisted: 平台已存在此企业 |
|||
taowaComapny: 不可使用下级企业作为父企业 |
|||
hasSubsidiary: 删除的企业拥有下级企业,需先处理下级企业 |
|||
roleNameExist: 角色名已存在 |
|||
roleHasBinded: 角色已绑定用户,请先解绑再删除 |
|||
loginNameOrEmailHasExisted: 用户名或邮箱已被使用 |
|||
mailAddUserPwdSubject: 新建账号密码 |
|||
mailAddUserPwdContent: 账号 <u>{0}</u> 的密码为:<u>{1}</u>, 请妥善保管<br/><br/>登陆网址:<u>{2}</u> |
|||
mailResetUserPwdSubject: 重置账号密码 |
|||
pwdFormatError: 密码组成必须包含数字、英文字母、特殊符号(~!@#$%^&*)且大于等于12位 |
|||
oldPwdError: 旧密码错误 |
|||
newPwdSameOld: 新密码不得与旧密码相同 |
|||
companyLimit: 最多可创建15个企业 |
|||
@ -0,0 +1,38 @@ |
|||
msgjp: |
|||
argumentNotValid: |
|||
1000: 未通过参数校验 |
|||
1001: 参数不能为空 |
|||
1002: 长度不能超过{0} |
|||
1003: 长度无效 |
|||
1004: 无效的邮箱 |
|||
1005: 数值范围在{0}到{1}之间 |
|||
1006: 必须大于或等于{0} |
|||
1007: 必须小于或等于{0} |
|||
1008: 无效的参数 |
|||
parameterMap: |
|||
serviceError: 内部サービスのエラー |
|||
tokenError: インターフェイスの認証に失敗 |
|||
excelEmpty: フォームが空になっている |
|||
lineNum: 行{0}: |
|||
paramsFormatError: パラメータのフォーマットエラー |
|||
verifCodeExpired: 確認コード期限切れ |
|||
verifCodeError: 確認コードエラー |
|||
accountExpired: アカウントの有効期限が切れている |
|||
pwdError: パスワードエラー |
|||
userNotExist: ユーザーが存在しない |
|||
noOperationAuth: 操作権限なし |
|||
excelBuildingLineDuplicate: テーブルに同じデータがある |
|||
userOrEmailNotExist: ユーザーが存在しません |
|||
companyNameHasExisted: 会社はすでにプラットフォーム上に存在する |
|||
taowaComapny: 下位の会社を親会社として利用することは不可 |
|||
hasSubsidiary: 削除対象の会社には下位の会社があるので、先に下位の会社を対応してください |
|||
roleNameExist: 役割名が既に登録済み |
|||
roleHasBinded: 役割はユーザーにバインドされている ので、削除する前にバインドを解除してください |
|||
loginNameOrEmailHasExisted: ユーザー名またはメールボックスはすでに使用されています |
|||
mailAddUserPwdSubject: 新規アカウント・パスワードの作成 |
|||
mailAddUserPwdContent: アカウント <u>{0}</u> のパスワードは:<u>{1}</u>, お忘れにならないようにお願いします。<br/><br/>ログインWebアドレス:<u>{2}</u> |
|||
mailResetUserPwdSubject: アカウント・パスワードのリセット |
|||
pwdFormatError: パスワードの構成には、数字、アルファベット、特殊文字(~!@#$%^&*) で、12桁以上 |
|||
oldPwdError: 旧パスワードエラー |
|||
newPwdSameOld: 注:旧パスワードと同じものを使用しないでください |
|||
companyLimit: 最大15のエンタープライズを作成可能 |
|||
@ -0,0 +1,15 @@ |
|||
/target/ |
|||
/logs/ |
|||
/.idea/ |
|||
*.iml |
|||
*.bak |
|||
*.log |
|||
/.settings/ |
|||
*.project |
|||
*.classpath |
|||
*.factorypath |
|||
*.springBeans |
|||
/.apt_generated/ |
|||
/.externalToolBuilders/ |
|||
/bin/ |
|||
application-*.properties |
|||
@ -0,0 +1,69 @@ |
|||
#FROM openjdk:8-jre-alpine |
|||
#FROM amazon-corretto-8 |
|||
#FROM amazoncorretto:11 |
|||
|
|||
# 使用Ubuntu 20.04 LTS作为基础镜像 |
|||
FROM ubuntu:20.04 |
|||
|
|||
# 设置系统的默认编码方式为 UTF-8 |
|||
ENV LANG=en_US.UTF-8 |
|||
ENV LC_CTYPE=zh_CN.UTF-8 |
|||
|
|||
# 设置环境变量,避免交互式安装 |
|||
ENV DEBIAN_FRONTEND=noninteractive |
|||
|
|||
# 更新APT软件包索引并安装必要的软件包 |
|||
RUN apt-get update && \ |
|||
apt-get install -y \ |
|||
curl \ |
|||
unzip \ |
|||
vim \ |
|||
fontconfig \ |
|||
&& apt-get clean \ |
|||
&& rm -rf /var/lib/apt/lists/* |
|||
|
|||
# 安装Terraform |
|||
RUN curl -fsSLk https://releases.hashicorp.com/terraform/1.7.5/terraform_1.7.5_linux_amd64.zip -o /tmp/terraform.zip && \ |
|||
unzip /tmp/terraform.zip -d /usr/local/bin/ && \ |
|||
rm /tmp/terraform.zip |
|||
|
|||
# 安装Amazon Corretto 11 JDK |
|||
RUN curl -fsSLk https://corretto.aws/downloads/resources/11.0.22.7.1/amazon-corretto-11.0.22.7.1-linux-x64.tar.gz -o /tmp/amazon-corretto-11.tar.gz && \ |
|||
mkdir /usr/lib/jvm/ && \ |
|||
tar -xzvf /tmp/amazon-corretto-11.tar.gz -C /usr/lib/jvm/ && \ |
|||
rm /tmp/amazon-corretto-11.tar.gz |
|||
|
|||
# 设置JAVA_HOME环境变量 |
|||
ENV JAVA_HOME=/usr/lib/jvm/amazon-corretto-11.0.22.7.1-linux-x64 |
|||
ENV PATH=$JAVA_HOME/bin:$PATH |
|||
|
|||
ENV JAVA_TOOL_OPTIONS="-Dfile.encoding=UTF8" |
|||
|
|||
# 打印Terraform版本 |
|||
RUN terraform --version |
|||
|
|||
# 打印Java版本 |
|||
RUN java -version |
|||
|
|||
WORKDIR /home/data-center-admin |
|||
|
|||
#EXPOSE 20008 |
|||
|
|||
# 设置时区 |
|||
#RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone |
|||
|
|||
ARG JAR_FILE |
|||
ARG LIB_DIR |
|||
ARG CONFIG_DIR |
|||
ARG AURORA_TERRAFORM |
|||
ARG JVM_OPTS |
|||
|
|||
COPY ${JAR_FILE} app.jar |
|||
COPY ${LIB_DIR} lib |
|||
COPY ${CONFIG_DIR} config |
|||
COPY ${AURORA_TERRAFORM} aurora_terraform |
|||
|
|||
#ENTRYPOINT ["java", "${JVM_OPTS}", "-jar","app.jar"] |
|||
ENTRYPOINT java ${JVM_OPTS} -jar app.jar |
|||
|
|||
|
|||
@ -0,0 +1,350 @@ |
|||
<?xml version="1.0"?> |
|||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" |
|||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
|||
<modelVersion>4.0.0</modelVersion> |
|||
<parent> |
|||
<groupId>com.techsor</groupId> |
|||
<artifactId>buildics-oviphone-back</artifactId> |
|||
<version>0.0.1-SNAPSHOT</version> |
|||
</parent> |
|||
<artifactId>buildics-oviphone-back-controller</artifactId> |
|||
<name>buildics-oviphone-back-controller</name> |
|||
<url>http://maven.apache.org</url> |
|||
<properties> |
|||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
|||
|
|||
<aws.ecr.repository>tokyo-build-admin</aws.ecr.repository> |
|||
<aws.ecr.tag>latest</aws.ecr.tag> |
|||
<aws.ecr.region>ap-northeast-1</aws.ecr.region> |
|||
|
|||
<aws.ecr.registry.test>923770123186.dkr.ecr.ap-northeast-1.amazonaws.com</aws.ecr.registry.test> |
|||
<aws.access.key.test>AKIA5OFH5OOZHM3U3KX4</aws.access.key.test> |
|||
<aws.secret.access.key.test>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</aws.secret.access.key.test> |
|||
|
|||
<aws.ecr.registry.production>381659385655.dkr.ecr.ap-northeast-1.amazonaws.com</aws.ecr.registry.production> |
|||
<aws.access.key.production>AKIAVRXFMB43XVQ3GXAL</aws.access.key.production> |
|||
<aws.secret.access.key.production>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</aws.secret.access.key.production> |
|||
|
|||
</properties> |
|||
|
|||
<dependencies> |
|||
|
|||
<dependency> |
|||
<groupId>com.techsor</groupId> |
|||
<artifactId>buildics-oviphone-back-service</artifactId> |
|||
<version>0.0.1-SNAPSHOT</version> |
|||
</dependency> |
|||
|
|||
<dependency> |
|||
<groupId>com.techsor</groupId> |
|||
<artifactId>buildics-oviphone-back-common</artifactId> |
|||
<version>0.0.1-SNAPSHOT</version> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>junit</groupId> |
|||
<artifactId>junit</artifactId> |
|||
<scope>test</scope> |
|||
</dependency> |
|||
|
|||
<dependency> |
|||
<groupId>com.spotify</groupId> |
|||
<artifactId>dockerfile-maven-plugin</artifactId> |
|||
<version>1.4.13</version> |
|||
<!--排除掉下面这个,不然重复导入javax.annotation,amazon-corretto-11下报错java.lang.String javax.annotation.Resource.lookup()--> |
|||
<exclusions> |
|||
<exclusion> |
|||
<groupId>javax.annotation</groupId> |
|||
<artifactId>jsr250-api</artifactId> |
|||
</exclusion> |
|||
</exclusions> |
|||
</dependency> |
|||
</dependencies> |
|||
|
|||
<profiles> |
|||
<profile> |
|||
<id>only-package</id> |
|||
<activation> |
|||
<activeByDefault>true</activeByDefault> |
|||
</activation> |
|||
<build> |
|||
<!-- 项目的打包配置 --> |
|||
<plugins> |
|||
<!-- 自定义打zip包 --> |
|||
<plugin> |
|||
<groupId>org.apache.maven.plugins</groupId> |
|||
<artifactId>maven-assembly-plugin</artifactId> |
|||
<configuration> |
|||
<finalName>buildics-oviphone-back</finalName> |
|||
<descriptors> |
|||
<descriptor>src/main/resources/assembly.xml</descriptor> |
|||
</descriptors> |
|||
<appendAssemblyId>false</appendAssemblyId> |
|||
</configuration> |
|||
<executions> |
|||
<execution> |
|||
<id>make-assembly</id> |
|||
<phase>package</phase> |
|||
<goals> |
|||
<goal>single</goal> |
|||
</goals> |
|||
</execution> |
|||
</executions> |
|||
</plugin> |
|||
</plugins> |
|||
</build> |
|||
</profile> |
|||
<profile> |
|||
<id>docker-package</id> |
|||
<build> |
|||
<!-- 先用dockerfile-maven-plugin构建镜像,然后maven-antrun-plugin执行推送aws ecr的命令 --> |
|||
<plugins> |
|||
<!-- dockerfile-maven-plugin构建镜像--> |
|||
<plugin> |
|||
<groupId>com.spotify</groupId> |
|||
<artifactId>dockerfile-maven-plugin</artifactId> |
|||
<version>1.4.13</version> |
|||
<executions> |
|||
<execution> |
|||
<id>default</id> |
|||
<goals> |
|||
<goal>build</goal> |
|||
<!-- <goal>push</goal>--> |
|||
</goals> |
|||
</execution> |
|||
</executions> |
|||
<configuration> |
|||
<repository>registry.cn-shanghai.aliyuncs.com/clouddog/datacenter-admin</repository> |
|||
<tag>${aws.ecr.tag}</tag> |
|||
<buildArgs> |
|||
<JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE> |
|||
<LIB_DIR>target/lib</LIB_DIR> |
|||
<CONFIG_DIR>target/config</CONFIG_DIR> |
|||
<AURORA_TERRAFORM>target/aurora_terraform</AURORA_TERRAFORM> |
|||
<JVM_OPTS>${java.jvm.opts}</JVM_OPTS> |
|||
</buildArgs> |
|||
</configuration> |
|||
</plugin> |
|||
</plugins> |
|||
</build> |
|||
</profile> |
|||
<profile> |
|||
<id>docker-aliyun</id> |
|||
<build> |
|||
<!-- 先用dockerfile-maven-plugin构建镜像,然后maven-antrun-plugin执行推送aws ecr的命令 --> |
|||
<plugins> |
|||
<!-- dockerfile-maven-plugin构建镜像--> |
|||
<plugin> |
|||
<groupId>com.spotify</groupId> |
|||
<artifactId>dockerfile-maven-plugin</artifactId> |
|||
<version>1.4.13</version> |
|||
<executions> |
|||
<execution> |
|||
<id>default</id> |
|||
<goals> |
|||
<goal>build</goal> |
|||
<!-- <goal>push</goal>--> |
|||
</goals> |
|||
</execution> |
|||
</executions> |
|||
<configuration> |
|||
<repository>registry.cn-shanghai.aliyuncs.com/clouddog/datacenter-admin</repository> |
|||
<tag>${aws.ecr.tag}</tag> |
|||
<buildArgs> |
|||
<JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE> |
|||
<LIB_DIR>target/lib</LIB_DIR> |
|||
<CONFIG_DIR>target/config</CONFIG_DIR> |
|||
<AURORA_TERRAFORM>target/aurora_terraform</AURORA_TERRAFORM> |
|||
<JVM_OPTS>${java.jvm.opts}</JVM_OPTS> |
|||
</buildArgs> |
|||
</configuration> |
|||
</plugin> |
|||
<!-- maven-antrun-plugin执行推送aws ecr的命令 --> |
|||
<plugin> |
|||
<groupId>org.apache.maven.plugins</groupId> |
|||
<artifactId>maven-antrun-plugin</artifactId> |
|||
<version>3.0.0</version> |
|||
<executions> |
|||
<execution> |
|||
<!--放在package阶段后面执行--> |
|||
<phase>package</phase> |
|||
<goals> |
|||
<goal>run</goal> |
|||
</goals> |
|||
<configuration> |
|||
<target> |
|||
<!-- Run AWS ECR login command using Ant tasks --> |
|||
<exec executable="cmd" osfamily="windows"> |
|||
<arg value="/c" /> |
|||
<arg value="docker login --username=409950420@qq.com registry.cn-shanghai.aliyuncs.com --password=Youqu48bnb1." /> |
|||
</exec> |
|||
<exec executable="cmd" osfamily="windows"> |
|||
<arg value="/c" /> |
|||
<arg value="docker push registry.cn-shanghai.aliyuncs.com/clouddog/datacenter-admin:${aws.ecr.tag}" /> |
|||
</exec> |
|||
</target> |
|||
</configuration> |
|||
</execution> |
|||
</executions> |
|||
</plugin> |
|||
</plugins> |
|||
</build> |
|||
</profile> |
|||
<profile> |
|||
<id>docker-test</id> |
|||
<build> |
|||
<!-- 先用dockerfile-maven-plugin构建镜像,然后maven-antrun-plugin执行推送aws ecr的命令 --> |
|||
<plugins> |
|||
<!-- dockerfile-maven-plugin构建镜像--> |
|||
<plugin> |
|||
<groupId>com.spotify</groupId> |
|||
<artifactId>dockerfile-maven-plugin</artifactId> |
|||
<version>1.4.13</version> |
|||
<executions> |
|||
<execution> |
|||
<id>default</id> |
|||
<goals> |
|||
<goal>build</goal> |
|||
<!-- <goal>push</goal>--> |
|||
</goals> |
|||
</execution> |
|||
</executions> |
|||
<configuration> |
|||
<repository>${aws.ecr.registry.test}/${aws.ecr.repository}</repository> |
|||
<tag>${aws.ecr.tag}</tag> |
|||
<buildArgs> |
|||
<JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE> |
|||
<LIB_DIR>target/lib</LIB_DIR> |
|||
<CONFIG_DIR>target/config</CONFIG_DIR> |
|||
<AURORA_TERRAFORM>target/aurora_terraform</AURORA_TERRAFORM> |
|||
<JVM_OPTS>${java.jvm.opts}</JVM_OPTS> |
|||
</buildArgs> |
|||
</configuration> |
|||
</plugin> |
|||
<!-- maven-antrun-plugin执行推送aws ecr的命令 --> |
|||
<plugin> |
|||
<groupId>org.apache.maven.plugins</groupId> |
|||
<artifactId>maven-antrun-plugin</artifactId> |
|||
<version>3.0.0</version> |
|||
<executions> |
|||
<execution> |
|||
<!--放在package阶段后面执行--> |
|||
<phase>package</phase> |
|||
<goals> |
|||
<goal>run</goal> |
|||
</goals> |
|||
<configuration> |
|||
<target> |
|||
<!-- Run AWS ECR login command using Ant tasks --> |
|||
<exec executable="cmd" osfamily="windows"> |
|||
<arg value="/c" /> |
|||
<arg value="aws configure set aws_access_key_id ${aws.access.key.test}" /> |
|||
</exec> |
|||
<exec executable="cmd" osfamily="windows"> |
|||
<arg value="/c" /> |
|||
<arg value="aws configure set aws_secret_access_key ${aws.secret.access.key.test}" /> |
|||
</exec> |
|||
<exec executable="cmd" osfamily="windows"> |
|||
<arg value="/c" /> |
|||
<arg value="aws configure set default.region ${aws.ecr.region}" /> |
|||
</exec> |
|||
<exec executable="cmd" osfamily="windows"> |
|||
<arg value="/c" /> |
|||
<arg value="aws configure set default.output text" /> |
|||
</exec> |
|||
<exec executable="cmd" osfamily="windows"> |
|||
<arg value="/c" /> |
|||
<arg value="aws ecr get-login-password --region ${aws.ecr.region} | docker login --username AWS --password-stdin ${aws.ecr.registry.test}" /> |
|||
</exec> |
|||
<exec executable="cmd" osfamily="windows"> |
|||
<arg value="/c" /> |
|||
<arg value="docker push ${aws.ecr.registry.test}/${aws.ecr.repository}:${aws.ecr.tag}" /> |
|||
</exec> |
|||
</target> |
|||
</configuration> |
|||
</execution> |
|||
</executions> |
|||
</plugin> |
|||
</plugins> |
|||
</build> |
|||
</profile> |
|||
<profile> |
|||
<id>docker-production</id> |
|||
<build> |
|||
<!-- 先用dockerfile-maven-plugin构建镜像,然后maven-antrun-plugin执行推送aws ecr的命令 --> |
|||
<plugins> |
|||
<!-- dockerfile-maven-plugin构建镜像--> |
|||
<plugin> |
|||
<groupId>com.spotify</groupId> |
|||
<artifactId>dockerfile-maven-plugin</artifactId> |
|||
<version>1.4.13</version> |
|||
<executions> |
|||
<execution> |
|||
<id>default</id> |
|||
<goals> |
|||
<goal>build</goal> |
|||
<!-- <goal>push</goal>--> |
|||
</goals> |
|||
</execution> |
|||
</executions> |
|||
<configuration> |
|||
<repository>${aws.ecr.registry.production}/${aws.ecr.repository}</repository> |
|||
<tag>${aws.ecr.tag}</tag> |
|||
<buildArgs> |
|||
<JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE> |
|||
<LIB_DIR>target/lib</LIB_DIR> |
|||
<CONFIG_DIR>target/config</CONFIG_DIR> |
|||
<AURORA_TERRAFORM>target/aurora_terraform</AURORA_TERRAFORM> |
|||
<JVM_OPTS>${java.jvm.opts}</JVM_OPTS> |
|||
</buildArgs> |
|||
</configuration> |
|||
</plugin> |
|||
<!-- maven-antrun-plugin执行推送aws ecr的命令 --> |
|||
<plugin> |
|||
<groupId>org.apache.maven.plugins</groupId> |
|||
<artifactId>maven-antrun-plugin</artifactId> |
|||
<version>3.0.0</version> |
|||
<executions> |
|||
<execution> |
|||
<!--放在package阶段后面执行--> |
|||
<phase>package</phase> |
|||
<goals> |
|||
<goal>run</goal> |
|||
</goals> |
|||
<configuration> |
|||
<target> |
|||
<!-- Run AWS ECR login command using Ant tasks --> |
|||
<exec executable="cmd" osfamily="windows"> |
|||
<arg value="/c" /> |
|||
<arg value="aws configure set aws_access_key_id ${aws.access.key.production}" /> |
|||
</exec> |
|||
<exec executable="cmd" osfamily="windows"> |
|||
<arg value="/c" /> |
|||
<arg value="aws configure set aws_secret_access_key ${aws.secret.access.key.production}" /> |
|||
</exec> |
|||
<exec executable="cmd" osfamily="windows"> |
|||
<arg value="/c" /> |
|||
<arg value="aws configure set default.region ${aws.ecr.region}" /> |
|||
</exec> |
|||
<exec executable="cmd" osfamily="windows"> |
|||
<arg value="/c" /> |
|||
<arg value="aws configure set default.output text" /> |
|||
</exec> |
|||
<exec executable="cmd" osfamily="windows"> |
|||
<arg value="/c" /> |
|||
<arg value="aws ecr get-login-password --region ${aws.ecr.region} | docker login --username AWS --password-stdin ${aws.ecr.registry.production}" /> |
|||
</exec> |
|||
<exec executable="cmd" osfamily="windows"> |
|||
<arg value="/c" /> |
|||
<arg value="docker push ${aws.ecr.registry.production}/${aws.ecr.repository}:${aws.ecr.tag}" /> |
|||
</exec> |
|||
</target> |
|||
</configuration> |
|||
</execution> |
|||
</executions> |
|||
</plugin> |
|||
</plugins> |
|||
</build> |
|||
</profile> |
|||
</profiles> |
|||
|
|||
</project> |
|||
@ -0,0 +1,19 @@ |
|||
package com.buildics.oviphone.back; |
|||
|
|||
import org.springframework.boot.SpringApplication; |
|||
import org.springframework.boot.autoconfigure.SpringBootApplication; |
|||
import org.springframework.boot.web.servlet.ServletComponentScan; |
|||
import org.springframework.scheduling.annotation.EnableAsync; |
|||
import org.springframework.scheduling.annotation.EnableScheduling; |
|||
|
|||
@SpringBootApplication |
|||
@ServletComponentScan |
|||
@EnableAsync |
|||
//@EnableScheduling
|
|||
public class BuildicsOviphoneApplication { |
|||
|
|||
public static void main(String[] args) { |
|||
SpringApplication.run(BuildicsOviphoneApplication.class, args); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,65 @@ |
|||
package com.buildics.oviphone.back.configurator; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.DbType; |
|||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; |
|||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; |
|||
import jakarta.servlet.MultipartConfigElement; |
|||
import org.springframework.boot.web.servlet.MultipartConfigFactory; |
|||
import org.springframework.context.annotation.Bean; |
|||
import org.springframework.context.annotation.Configuration; |
|||
import org.springframework.mobile.device.DeviceHandlerMethodArgumentResolver; |
|||
import org.springframework.util.unit.DataSize; |
|||
import org.springframework.web.method.support.HandlerMethodArgumentResolver; |
|||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry; |
|||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
|||
|
|||
import com.buildics.oviphone.back.configurator.interceptor.AccessApiInterceptor; |
|||
|
|||
import java.io.File; |
|||
import java.util.List; |
|||
|
|||
@Configuration |
|||
public class ApiConfig implements WebMvcConfigurer { |
|||
|
|||
@Bean |
|||
public AccessApiInterceptor accessApiInterceptor(){ |
|||
return new AccessApiInterceptor(); |
|||
} |
|||
|
|||
@Override |
|||
public void addInterceptors(InterceptorRegistry registry){ |
|||
registry.addInterceptor(accessApiInterceptor()); |
|||
} |
|||
|
|||
@Bean |
|||
public DeviceHandlerMethodArgumentResolver deviceHandlerMethodArgumentResolver() { |
|||
return new DeviceHandlerMethodArgumentResolver(); |
|||
} |
|||
|
|||
@Override |
|||
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) { |
|||
argumentResolvers.add(deviceHandlerMethodArgumentResolver()); |
|||
} |
|||
|
|||
@Bean |
|||
public MybatisPlusInterceptor mybatisPlusInterceptor() { |
|||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); |
|||
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); // 如果配置多个插件, 切记分页最后添加
|
|||
// 如果有多数据源可以不配具体类型, 否则都建议配上具体的 DbType
|
|||
return interceptor; |
|||
} |
|||
|
|||
|
|||
@Bean |
|||
public MultipartConfigElement multipartConfigElement() { |
|||
String path = System.getProperty("user.dir")+"/tmp"; |
|||
MultipartConfigFactory factory = new MultipartConfigFactory(); |
|||
factory.setMaxFileSize(DataSize.ofMegabytes(20L)); |
|||
File tmpFile = new File(path); |
|||
if (!tmpFile.exists()) { |
|||
tmpFile.mkdirs(); |
|||
} |
|||
factory.setLocation(path); |
|||
return factory.createMultipartConfig(); |
|||
} |
|||
} |
|||
@ -0,0 +1,38 @@ |
|||
package com.buildics.oviphone.back.configurator; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.boot.web.servlet.FilterRegistrationBean; |
|||
import org.springframework.context.annotation.Bean; |
|||
import org.springframework.context.annotation.Configuration; |
|||
import org.springframework.web.cors.CorsConfiguration; |
|||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource; |
|||
import org.springframework.web.filter.CorsFilter; |
|||
|
|||
/** |
|||
* 跨域配置 |
|||
* @author jwy |
|||
* @time 2022-5-12 17:54:43 |
|||
*/ |
|||
@Configuration |
|||
public class CorsConfigurer { |
|||
@Value("${crosxss.origin:*}") |
|||
private String corsOrigin; |
|||
@Bean |
|||
public FilterRegistrationBean corsFilter() { |
|||
List<String> allowedOriginPatterns = new ArrayList<String>(); |
|||
allowedOriginPatterns.add(corsOrigin); |
|||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); |
|||
CorsConfiguration config = new CorsConfiguration(); |
|||
config.setAllowCredentials(true); |
|||
config.setAllowedOriginPatterns(allowedOriginPatterns); |
|||
config.addAllowedHeader("*"); |
|||
config.addAllowedMethod("*"); |
|||
source.registerCorsConfiguration("/**", config); |
|||
FilterRegistrationBean bean = new FilterRegistrationBean(new CorsFilter(source)); |
|||
bean.setOrder(0); |
|||
return bean; |
|||
} |
|||
} |
|||
@ -0,0 +1,78 @@ |
|||
package com.buildics.oviphone.back.configurator; |
|||
|
|||
import java.io.IOException; |
|||
|
|||
import javax.servlet.Filter; |
|||
import javax.servlet.FilterChain; |
|||
import javax.servlet.FilterConfig; |
|||
import javax.servlet.ServletException; |
|||
import javax.servlet.ServletRequest; |
|||
import javax.servlet.ServletResponse; |
|||
import javax.servlet.annotation.WebFilter; |
|||
import javax.servlet.http.HttpServletRequest; |
|||
import javax.servlet.http.HttpServletResponse; |
|||
|
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import java.util.UUID; |
|||
|
|||
import org.jboss.logging.MDC; |
|||
|
|||
@WebFilter |
|||
public class CrosXssFilter implements Filter { |
|||
|
|||
private static final Logger logger = LoggerFactory.getLogger(CrosXssFilter.class); |
|||
|
|||
@Value("${crosxss.filter.disable:false}") |
|||
private boolean disable; |
|||
|
|||
@Override |
|||
public void init(FilterConfig filterConfig) throws ServletException { |
|||
} |
|||
|
|||
@Override |
|||
public void doFilter(ServletRequest request, ServletResponse response, |
|||
FilterChain chain) throws IOException, ServletException { |
|||
try { |
|||
MDC.put("processNo", UUID.randomUUID().toString().replace("-", "")); |
|||
request.setCharacterEncoding("utf-8"); |
|||
// response.setContentType("text/html;charset=utf-8");
|
|||
if (disable) { |
|||
chain.doFilter(request, response); |
|||
} else { |
|||
//跨域设置
|
|||
if (response instanceof HttpServletResponse) { |
|||
HttpServletResponse httpServletResponse = (HttpServletResponse) response; |
|||
//禁用浏览器缓存
|
|||
httpServletResponse.setHeader("Cache-Control", "no-store"); |
|||
//禁止被IFrame嵌套
|
|||
httpServletResponse.setHeader("X-Frame-Options", "deny"); |
|||
//安全性配置
|
|||
httpServletResponse.setHeader("X-XSS-Protection", "1; mode=block"); |
|||
httpServletResponse.setHeader("X-Content-Type-Options", "nosniff"); |
|||
httpServletResponse.setHeader("Referrer-Policy", "origin"); |
|||
} |
|||
ServletRequest requestWrapper = null; |
|||
if(request instanceof HttpServletRequest) { |
|||
requestWrapper = new RequestWrapper((HttpServletRequest) request); |
|||
} |
|||
if(requestWrapper == null) { |
|||
chain.doFilter(request, response); |
|||
} else { |
|||
chain.doFilter(requestWrapper, response); |
|||
} |
|||
} |
|||
} finally { |
|||
// 避免线程泄漏
|
|||
MDC.clear(); |
|||
} |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public void destroy() { |
|||
|
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,92 @@ |
|||
package com.buildics.oviphone.back.configurator; |
|||
|
|||
import javax.servlet.ReadListener; |
|||
import javax.servlet.ServletInputStream; |
|||
import javax.servlet.http.HttpServletRequest; |
|||
import javax.servlet.http.HttpServletRequestWrapper; |
|||
|
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
|
|||
import java.io.*; |
|||
|
|||
public class RequestWrapper extends HttpServletRequestWrapper { |
|||
|
|||
private static final Logger logger = LoggerFactory.getLogger(HttpServletRequestWrapper.class); |
|||
|
|||
private final String body; |
|||
|
|||
public RequestWrapper(HttpServletRequest request) { |
|||
super(request); |
|||
StringBuilder stringBuilder = new StringBuilder(); |
|||
BufferedReader bufferedReader = null; |
|||
InputStream inputStream = null; |
|||
try { |
|||
inputStream = request.getInputStream(); |
|||
if (inputStream != null) { |
|||
bufferedReader = new BufferedReader(new InputStreamReader(inputStream)); |
|||
char[] charBuffer = new char[128]; |
|||
int bytesRead = -1; |
|||
while ((bytesRead = bufferedReader.read(charBuffer)) > 0) { |
|||
stringBuilder.append(charBuffer, 0, bytesRead); |
|||
} |
|||
} else { |
|||
stringBuilder.append(""); |
|||
} |
|||
} catch (IOException ex) { |
|||
logger.error("RequestWrapper读取流错误", ex); |
|||
} finally { |
|||
if (inputStream != null) { |
|||
try { |
|||
inputStream.close(); |
|||
} |
|||
catch (IOException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
} |
|||
if (bufferedReader != null) { |
|||
try { |
|||
bufferedReader.close(); |
|||
} |
|||
catch (IOException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
} |
|||
} |
|||
body = stringBuilder.toString(); |
|||
} |
|||
|
|||
@Override |
|||
public ServletInputStream getInputStream() throws IOException { |
|||
final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(body.getBytes()); |
|||
ServletInputStream servletInputStream = new ServletInputStream() { |
|||
@Override |
|||
public boolean isFinished() { |
|||
return false; |
|||
} |
|||
@Override |
|||
public boolean isReady() { |
|||
return false; |
|||
} |
|||
@Override |
|||
public void setReadListener(ReadListener readListener) { |
|||
} |
|||
@Override |
|||
public int read() throws IOException { |
|||
return byteArrayInputStream.read(); |
|||
} |
|||
}; |
|||
return servletInputStream; |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public BufferedReader getReader() throws IOException { |
|||
return new BufferedReader(new InputStreamReader(this.getInputStream())); |
|||
} |
|||
|
|||
public String getBody() { |
|||
return this.body; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,19 @@ |
|||
package com.buildics.oviphone.back.configurator; |
|||
|
|||
import com.buildics.oviphone.back.common.config.DataSourceInterceptor; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
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 WebMvcConfig implements WebMvcConfigurer { |
|||
|
|||
@Autowired |
|||
private DataSourceInterceptor dataSourceInterceptor; |
|||
|
|||
@Override |
|||
public void addInterceptors(InterceptorRegistry registry) { |
|||
registry.addInterceptor(dataSourceInterceptor); |
|||
} |
|||
} |
|||
@ -0,0 +1,118 @@ |
|||
package com.buildics.oviphone.back.configurator.handler; |
|||
|
|||
import com.buildics.oviphone.back.common.language.msg.MsgLanguageChange; |
|||
import com.buildics.oviphone.back.common.response.ResponseCode; |
|||
import com.buildics.oviphone.back.common.response.SimpleDataResponse; |
|||
import jakarta.servlet.http.HttpServletRequest; |
|||
import jakarta.validation.constraints.Max; |
|||
import jakarta.validation.constraints.Min; |
|||
import org.hibernate.validator.constraints.Length; |
|||
import org.hibernate.validator.constraints.Range; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.validation.FieldError; |
|||
import org.springframework.web.bind.MethodArgumentNotValidException; |
|||
import org.springframework.web.bind.annotation.ExceptionHandler; |
|||
import org.springframework.web.bind.annotation.ResponseStatus; |
|||
import org.springframework.web.bind.annotation.RestControllerAdvice; |
|||
|
|||
import java.lang.reflect.Field; |
|||
import java.text.MessageFormat; |
|||
import java.util.HashMap; |
|||
import java.util.Map; |
|||
|
|||
@RestControllerAdvice |
|||
public class GlobalExceptionHandler { |
|||
|
|||
@Autowired |
|||
private MsgLanguageChange msgLanguageChange; |
|||
|
|||
// 处理@NotNull等校验异常
|
|||
@ResponseStatus(HttpStatus.BAD_REQUEST)// 这里jakarta.validation.constraints MethodArgumentNotValidException错误码是400(Bad Request)
|
|||
@ExceptionHandler(MethodArgumentNotValidException.class) |
|||
public SimpleDataResponse handleValidationExceptions( |
|||
MethodArgumentNotValidException ex, |
|||
HttpServletRequest request) { |
|||
|
|||
// 获取语言类型,默认为中文
|
|||
String languageType = request.getHeader("LanguageType"); |
|||
if (languageType == null || languageType.isEmpty()) { |
|||
languageType = "0"; // 默认中文
|
|||
} |
|||
|
|||
Map<String, String> errors = new HashMap<>(); |
|||
|
|||
Integer finalLanguageType = Integer.valueOf(languageType); |
|||
ex.getBindingResult().getAllErrors().forEach((error) -> { |
|||
String fieldName = ((FieldError) error).getField(); |
|||
String errorMessage = error.getDefaultMessage(); |
|||
|
|||
// 尝试获取字段的注解信息
|
|||
try { |
|||
Field field = ex.getBindingResult().getTarget().getClass().getDeclaredField(fieldName); |
|||
|
|||
Length lengthAnnotation = field.getAnnotation(Length.class); |
|||
Range rangeAnnotation = field.getAnnotation(Range.class); |
|||
Min minAnnotation = field.getAnnotation(Min.class); |
|||
Max maxAnnotation = field.getAnnotation(Max.class); |
|||
// 处理Length校验
|
|||
if (lengthAnnotation != null && ("1002".equals(errorMessage) || errorMessage.contains("length"))) {// 处理长度校验错误
|
|||
errorMessage = handleLengthValidationError(lengthAnnotation, finalLanguageType); |
|||
} |
|||
// 处理Range校验
|
|||
else if (rangeAnnotation != null && ("1005".equals(errorMessage) || errorMessage.contains("Range"))) { |
|||
errorMessage = handleRangeValidationError(rangeAnnotation, finalLanguageType); |
|||
} |
|||
// 处理min校验
|
|||
else if (minAnnotation != null && ("1006".equals(errorMessage) || errorMessage.contains("Min"))) { |
|||
errorMessage = handleMinValidationError(minAnnotation, finalLanguageType); |
|||
} |
|||
// 处理max校验
|
|||
else if (maxAnnotation != null && ("1007".equals(errorMessage) || errorMessage.contains("Max"))) { |
|||
errorMessage = handleMaxValidationError(maxAnnotation, finalLanguageType); |
|||
} |
|||
// 处理其他校验错误
|
|||
else { |
|||
errorMessage = translateErrorMessage(errorMessage, finalLanguageType); |
|||
} |
|||
} catch (Exception e) { |
|||
// 如果无法获取字段信息,使用默认翻译
|
|||
errorMessage = translateErrorMessage(errorMessage, finalLanguageType); |
|||
} |
|||
|
|||
errors.put(fieldName, errorMessage); |
|||
}); |
|||
|
|||
return new SimpleDataResponse( |
|||
ResponseCode.BAD_REQUEST, |
|||
msgLanguageChange.getBadRequestMessage(finalLanguageType, "1000"), |
|||
errors); |
|||
} |
|||
|
|||
private String handleMaxValidationError(Max max, Integer languageType) { |
|||
long value = max.value(); |
|||
return MessageFormat.format(msgLanguageChange.getBadRequestMessage(languageType, "1007"), value) ; |
|||
} |
|||
|
|||
private String handleMinValidationError(Min min, Integer languageType) { |
|||
long value = min.value(); |
|||
return MessageFormat.format(msgLanguageChange.getBadRequestMessage(languageType, "1006"), value) ; |
|||
} |
|||
|
|||
private String handleRangeValidationError(Range rangeAnnotation, Integer finalLanguageType) { |
|||
long max = rangeAnnotation.max(); |
|||
long min = rangeAnnotation.min(); |
|||
return MessageFormat.format(msgLanguageChange.getBadRequestMessage(finalLanguageType, "1005"), min, max) ; |
|||
} |
|||
|
|||
private String handleLengthValidationError(Length lengthAnnotation, Integer languageType) { |
|||
int max = lengthAnnotation.max(); |
|||
// int min = lengthAnnotation.min();
|
|||
return MessageFormat.format(msgLanguageChange.getBadRequestMessage(languageType, "1002"), max) ; |
|||
} |
|||
|
|||
private String translateErrorMessage(String errorCode, Integer languageType) { |
|||
return msgLanguageChange.getBadRequestMessage(languageType, errorCode); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,72 @@ |
|||
package com.buildics.oviphone.back.configurator.interceptor; |
|||
|
|||
import com.alibaba.fastjson2.JSONObject; |
|||
import com.buildics.oviphone.back.common.response.ResponseCode; |
|||
import com.buildics.oviphone.back.service.AccountService; |
|||
|
|||
import jakarta.servlet.http.HttpServletRequest; |
|||
import jakarta.servlet.http.HttpServletResponse; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.web.method.HandlerMethod; |
|||
import org.springframework.web.servlet.HandlerInterceptor; |
|||
import org.springframework.web.servlet.resource.ResourceHttpRequestHandler; |
|||
|
|||
import java.lang.reflect.Method; |
|||
|
|||
public class AccessApiInterceptor implements HandlerInterceptor { |
|||
|
|||
private static final Logger logger = LoggerFactory.getLogger(AccessApiInterceptor.class); |
|||
|
|||
@Value("${user.login.keytimeout}") |
|||
private long keytimeout; |
|||
|
|||
@Autowired |
|||
private AccountService accountService; |
|||
|
|||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { |
|||
if(handler instanceof HandlerMethod) { |
|||
HandlerMethod handlerMethod = (HandlerMethod) handler; |
|||
Class<?> tClass = handlerMethod.getBeanType(); |
|||
AccessRequired annotation = tClass.getAnnotation(AccessRequired.class); |
|||
if (annotation == null) { |
|||
Method method = handlerMethod.getMethod(); |
|||
annotation = method.getAnnotation(AccessRequired.class); |
|||
} |
|||
try { |
|||
if (annotation != null) { |
|||
String loginName = request.getHeader("LoginName"); |
|||
String accessToken = request.getHeader("AccessToken"); |
|||
String userId = request.getHeader("UserId"); |
|||
String companyId = request.getHeader("CompanyId"); |
|||
|
|||
String languageType = request.getHeader("LanguageType"); |
|||
response.setContentType("application/json;charset=utf-8"); |
|||
String URI = request.getRequestURI(); |
|||
logger.info("===============请求的URI :" + URI + " ==============="); |
|||
JSONObject jsonObject = new JSONObject(); |
|||
|
|||
boolean result = accountService.accessAuth(loginName, companyId, userId, accessToken, languageType, jsonObject, keytimeout); |
|||
if(!result) { |
|||
response.getWriter().print(jsonObject.toString()); |
|||
} |
|||
return result; |
|||
} |
|||
} catch (Exception e) { |
|||
logger.error("Error from AccessApiInterceptor!", e); |
|||
JSONObject jsonObject = new JSONObject(); |
|||
jsonObject.put("code", ResponseCode.SERVER_ERROR); |
|||
jsonObject.put("msg", ResponseCode.SERVER_ERROR_MSG); |
|||
response.getWriter().print(jsonObject.toString()); |
|||
return false; |
|||
} |
|||
// 没有注解通过拦截
|
|||
return true; |
|||
}else if(handler instanceof ResourceHttpRequestHandler) {//资源文件不拦截
|
|||
return true; |
|||
} |
|||
return false; |
|||
} |
|||
} |
|||
@ -0,0 +1,10 @@ |
|||
package com.buildics.oviphone.back.configurator.interceptor; |
|||
|
|||
import java.lang.annotation.*; |
|||
|
|||
@Target({ElementType.TYPE,ElementType.METHOD}) |
|||
@Retention(RetentionPolicy.RUNTIME) |
|||
@Documented |
|||
public @interface AccessRequired { |
|||
|
|||
} |
|||
@ -0,0 +1,98 @@ |
|||
package com.buildics.oviphone.back.controller; |
|||
|
|||
import io.swagger.v3.oas.annotations.Hidden; |
|||
import io.swagger.v3.oas.annotations.Operation; |
|||
import io.swagger.v3.oas.annotations.Parameter; |
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import io.swagger.v3.oas.annotations.tags.Tag; |
|||
import jakarta.servlet.http.HttpServletRequest; |
|||
import jakarta.servlet.http.HttpServletResponse; |
|||
import org.apache.commons.codec.binary.Base64; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.mobile.device.Device; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import com.google.code.kaptcha.impl.DefaultKaptcha; |
|||
import com.buildics.oviphone.back.common.response.SimpleDataResponse; |
|||
import com.buildics.oviphone.back.configurator.interceptor.AccessRequired; |
|||
import com.buildics.oviphone.back.dto.account.CacheUserData; |
|||
import com.buildics.oviphone.back.dto.account.LoginParam; |
|||
import com.buildics.oviphone.back.service.AccountService; |
|||
import com.buildics.oviphone.back.service.captcha.CaptchaService; |
|||
import com.buildics.oviphone.back.service.captcha.CaptchaVO; |
|||
|
|||
import java.awt.image.BufferedImage; |
|||
import java.io.ByteArrayOutputStream; |
|||
import java.io.IOException; |
|||
|
|||
import javax.imageio.ImageIO; |
|||
|
|||
/** |
|||
* 账户管理 |
|||
* @author jwy-style |
|||
* |
|||
*/ |
|||
@Hidden |
|||
@RestController |
|||
@RequestMapping("/account") |
|||
@Tag(name = "AccountController",description = "账号登录/登出、获取验证码接口") |
|||
public class AccountController { |
|||
|
|||
@Autowired |
|||
private AccountService accountService; |
|||
@Autowired |
|||
private DefaultKaptcha producer; |
|||
@Autowired |
|||
private CaptchaService captchaService; |
|||
|
|||
|
|||
@Operation(summary = "用户登录") |
|||
@RequestMapping(value = "/login", method = RequestMethod.POST) |
|||
public SimpleDataResponse<CacheUserData> login(@RequestBody LoginParam loginParam, |
|||
@Parameter(name="LanguageType",description="语言类型 0:中文 1:英文 2:日文",required=true, schema = @Schema(defaultValue = "2")) @RequestHeader(required=true) Integer LanguageType, |
|||
HttpServletRequest request, |
|||
HttpServletResponse response, |
|||
Device device) { |
|||
return accountService.login(loginParam,device,LanguageType,request,response); |
|||
} |
|||
|
|||
|
|||
|
|||
/** |
|||
* 用户退出登录 |
|||
*/ |
|||
@AccessRequired |
|||
@Operation(summary = "用户退出") |
|||
@RequestMapping(value = "/logout", method = RequestMethod.GET) |
|||
public SimpleDataResponse logout( @Parameter(name="LoginName",description="登录名",required=true) @RequestHeader(required=true) String LoginName, |
|||
@Parameter(name="AccessToken",description="鉴权token",required=true) @RequestHeader(required=true) String AccessToken, |
|||
@Parameter(name="UserId",description="用户ID",required=true) @RequestHeader(required=true) String UserId, |
|||
@Parameter(name="CompanyId",description="所属企业ID",required=false) @RequestHeader(required=false) String CompanyId, |
|||
@Parameter(name="LanguageType",description="语言类型 0:中文 1:英文 2:日文",required=true, schema = @Schema(defaultValue = "2")) @RequestHeader(required=true) Integer LanguageType) { |
|||
return accountService.logout(AccessToken,CompanyId,LoginName,UserId); |
|||
} |
|||
|
|||
/** |
|||
* 获取验证码 |
|||
* @return |
|||
*/ |
|||
@Operation(summary = "获取登录验证码") |
|||
@RequestMapping(value = "/getCaptcha", method = RequestMethod.GET ) |
|||
public SimpleDataResponse<CaptchaVO> getCaptcha() throws IOException { |
|||
// 生成文字验证码
|
|||
String content = producer.createText(); |
|||
// 生成图片验证码
|
|||
ByteArrayOutputStream outputStream = null; |
|||
BufferedImage image = producer.createImage(content); |
|||
outputStream = new ByteArrayOutputStream(); |
|||
ImageIO.write(image, "jpg", outputStream); |
|||
// 对字节数组Base64编码
|
|||
// BASE64Encoder encoder = new BASE64Encoder();
|
|||
String str = "data:image/jpeg;base64,"; |
|||
String base64Img = str + Base64.encodeBase64String(outputStream.toByteArray()).replace("\n", "").replace("\r", ""); |
|||
CaptchaVO captchaVO = captchaService.cacheCaptcha(content); |
|||
captchaVO.setBase64Img(base64Img); |
|||
return SimpleDataResponse.success(captchaVO); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,43 @@ |
|||
package com.buildics.oviphone.back.controller; |
|||
|
|||
import io.swagger.v3.oas.annotations.Hidden; |
|||
import io.swagger.v3.oas.annotations.Operation; |
|||
import io.swagger.v3.oas.annotations.Parameter; |
|||
import io.swagger.v3.oas.annotations.tags.Tag; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestMethod; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import com.buildics.oviphone.back.common.response.SimpleDataResponse; |
|||
import com.buildics.oviphone.back.service.CommonService; |
|||
|
|||
/** |
|||
* |
|||
* @author jwy-style |
|||
* |
|||
*/ |
|||
//@Hidden
|
|||
@RestController//代表返回的是json格式的数据,这个注解是Spring4之后新加的注解
|
|||
@RequestMapping("/common") //http请求路径映射
|
|||
@Tag(name = "CommonController",description = "公共接口") |
|||
@SuppressWarnings("unchecked") |
|||
public class CommonController{ |
|||
|
|||
private static Logger logger = LoggerFactory.getLogger(CommonController.class); |
|||
|
|||
@Autowired |
|||
private CommonService commonService; |
|||
|
|||
|
|||
@Hidden |
|||
@Operation(summary = "检测apikey是否有效") |
|||
@RequestMapping(value = "/checkApikey",method = RequestMethod.GET) |
|||
public SimpleDataResponse checkApikey( |
|||
@Parameter(name="apikey",description="apikey值",required=true) @RequestParam String apikey){ |
|||
return commonService.checkApikey(apikey); |
|||
} |
|||
} |
|||
@ -0,0 +1,78 @@ |
|||
package com.buildics.oviphone.back.controller; |
|||
|
|||
import java.util.List; |
|||
|
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.buildics.oviphone.back.common.response.PageResponse; |
|||
import io.swagger.v3.oas.annotations.Hidden; |
|||
import io.swagger.v3.oas.annotations.Operation; |
|||
import io.swagger.v3.oas.annotations.Parameter; |
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import io.swagger.v3.oas.annotations.tags.Tag; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.validation.annotation.Validated; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import com.buildics.oviphone.back.common.exception.BusinessException; |
|||
import com.buildics.oviphone.back.common.response.ResponseCode; |
|||
import com.buildics.oviphone.back.common.response.SimpleDataResponse; |
|||
import com.buildics.oviphone.back.configurator.interceptor.AccessRequired; |
|||
import com.buildics.oviphone.back.dto.company.CompanySearchParams; |
|||
import com.buildics.oviphone.back.dto.company.DeleteCompanyParams; |
|||
import com.buildics.oviphone.back.dto.company.OptCompanyParams; |
|||
import com.buildics.oviphone.back.vo.company.CompanyPageDTO; |
|||
import com.buildics.oviphone.back.vo.TreeMenusDTO; |
|||
import com.buildics.oviphone.back.service.CompanyService; |
|||
|
|||
/** |
|||
* |
|||
* @author jwy-style |
|||
* |
|||
*/ |
|||
@Hidden |
|||
@RestController//代表返回的是json格式的数据,这个注解是Spring4之后新加的注解
|
|||
//@AccessRequired //注解标识是否需要验证token
|
|||
@RequestMapping("/company") //http请求路径映射
|
|||
@Tag(name = "CompanyController",description = "企业管理的相关接口") |
|||
@SuppressWarnings("unchecked") |
|||
public class CompanyController { |
|||
|
|||
private static Logger logger = LoggerFactory.getLogger(CompanyController.class); |
|||
|
|||
@Autowired |
|||
private CompanyService companyService; |
|||
|
|||
|
|||
|
|||
@AccessRequired |
|||
@Operation(summary = "获取企业列表") |
|||
@RequestMapping(value = "/getListPage",method = RequestMethod.GET) |
|||
public PageResponse<IPage<CompanyPageDTO>> getListPage( |
|||
@Parameter(name="LoginName",description="登录名",required=true,schema = @Schema(defaultValue = "admin")) @RequestHeader(required=true) String LoginName, |
|||
@Parameter(name="AccessToken",description="鉴权token",required=true) @RequestHeader(required=true) String AccessToken, |
|||
@Parameter(name="UserId",description="用户ID",required=true,schema = @Schema(defaultValue = "1")) @RequestHeader(required=true) Long UserId, |
|||
@Parameter(name="CompanyId",description="所属企业ID",required=false,schema = @Schema(defaultValue = "1")) @RequestHeader(required=false) Long CompanyId, |
|||
// @Parameter(name="LoginCompanyId",description="登录用户的企业ID",required=false,schema = @Schema(defaultValue = "1") @RequestHeader(required=false) Long LoginCompanyId,
|
|||
@Parameter(name="LanguageType",description="语言类型 0:中文 1:英文 2:日文",required=true,schema = @Schema(defaultValue = "0")) @RequestHeader(required=true) Integer LanguageType, |
|||
@Parameter(name="UTCOffset",description="格林威治时间与本地时间的差值,单位是分钟,比如东八区是 -480",required=true,schema = @Schema(defaultValue = "-480")) @RequestHeader(required=true) Integer UTCOffset, |
|||
CompanySearchParams pageSearchParam |
|||
) throws BusinessException { |
|||
|
|||
pageSearchParam.setUserId(UserId); |
|||
|
|||
PageResponse<IPage<CompanyPageDTO>> pageResponse = new PageResponse<IPage<CompanyPageDTO>>(); |
|||
try{ |
|||
pageResponse.setData(companyService.getListPage(pageSearchParam, CompanyId, UserId, LanguageType, UTCOffset)); |
|||
pageResponse.setCode(ResponseCode.SUCCESS); |
|||
pageResponse.setMsg("success"); |
|||
}catch (Exception e){ |
|||
logger.error("查询列表报错",e); |
|||
pageResponse.setCode(ResponseCode.SERVER_ERROR); |
|||
pageResponse.setMsg(ResponseCode.SERVER_ERROR_MSG); |
|||
} |
|||
return pageResponse; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
package com.buildics.oviphone.back.controller; |
|||
|
|||
import com.alibaba.fastjson2.JSONObject; |
|||
import io.swagger.v3.oas.annotations.tags.Tag; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import java.io.BufferedReader; |
|||
import java.io.IOException; |
|||
import java.io.InputStreamReader; |
|||
import java.io.Reader; |
|||
import java.util.Properties; |
|||
|
|||
@RestController |
|||
@Tag(name = "HealthController",description = "健康检测接口") |
|||
public class HealthController { |
|||
|
|||
@GetMapping("/healthcheck") |
|||
public String health(){ |
|||
return "ok"; |
|||
} |
|||
|
|||
@GetMapping("/version") |
|||
public String getVersion() throws IOException { |
|||
Properties properties = new Properties(); |
|||
Reader in = new InputStreamReader(this.getClass().getResourceAsStream("/config/version.properties"),"utf-8"); |
|||
BufferedReader bufferedReader = new BufferedReader(in); |
|||
properties.load(bufferedReader); |
|||
String version=properties.getProperty("project.latest.version"); |
|||
String content = properties.getProperty(version); |
|||
JSONObject jsonObject = new JSONObject(); |
|||
jsonObject.put("version", version); |
|||
jsonObject.put("content", content); |
|||
return jsonObject.toString(); |
|||
} |
|||
} |
|||
@ -0,0 +1,59 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<assembly> |
|||
<!-- 最终打包文件的后缀,格式为 ${fileName}-bin --> |
|||
<id>buildics-oviphone-back</id> |
|||
<!-- 最终打包成一个用于发布的zip文件 --> |
|||
<formats> |
|||
<format>zip</format> |
|||
</formats> |
|||
|
|||
<!-- 文件配置 --> |
|||
<fileSets> |
|||
|
|||
<!-- 把项目自己编译出来根目录下的jar文件,打包进zip文件的根目录 --> |
|||
<fileSet> |
|||
<directory>${project.build.directory}</directory> |
|||
<outputDirectory>/</outputDirectory> |
|||
<includes> |
|||
<include>*.jar</include> |
|||
</includes> |
|||
</fileSet> |
|||
|
|||
<!-- 把项目自己编译出来的jar文件夹下的jar文件,去除第三方jar,打包进zip文件的根目录 --> |
|||
<fileSet> |
|||
<directory>${project.build.directory}/jar</directory> |
|||
<outputDirectory>/</outputDirectory> |
|||
<excludes> |
|||
<exclude>lib/*.jar</exclude> |
|||
</excludes> |
|||
<includes> |
|||
<include>*.jar</include> |
|||
</includes> |
|||
</fileSet> |
|||
|
|||
<!-- 把项目自己编译出来的lib文件夹下的jar文件,打包进zip文件的lib目录 --> |
|||
<fileSet> |
|||
<directory>${project.build.directory}/lib</directory> |
|||
<outputDirectory>/lib</outputDirectory> |
|||
<includes> |
|||
<include>*.jar</include> |
|||
</includes> |
|||
</fileSet> |
|||
|
|||
<!-- 把编译出来的config文件夹,去除application.properties,打包进zip文件的config目录 --> |
|||
<fileSet> |
|||
<directory>${project.build.directory}/config</directory> |
|||
<outputDirectory>/config</outputDirectory> |
|||
<excludes> |
|||
<exclude>application.properties</exclude> |
|||
</excludes> |
|||
</fileSet> |
|||
|
|||
<!-- 把编译出来的sql文件夹,打包进zip文件的sql目录 --> |
|||
<fileSet> |
|||
<directory>${project.build.directory}/sql</directory> |
|||
<outputDirectory>/sql</outputDirectory> |
|||
</fileSet> |
|||
|
|||
</fileSets> |
|||
</assembly> |
|||
@ -0,0 +1,115 @@ |
|||
server.port=${serverPort} |
|||
|
|||
spring.mvc.pathmatch.matching-strategy= ANT_PATH_MATCHER |
|||
|
|||
#mybatis.mapperLocations=classpath:mappers/**/*.xml |
|||
# MyBatis-Plus 配置 |
|||
mybatis-plus.mapper-locations=classpath:mappers/**/*.xml |
|||
# MyBatis 原生配置 |
|||
mybatis-plus.configuration.map-underscore-to-camel-case=true |
|||
mybatis-plus.configuration.cache-enabled=false |
|||
mybatis-plus.configuration.lazy-loading-enabled=false |
|||
mybatis-plus.configuration.multiple-result-sets-enabled=false |
|||
# MyBatis-Plus 全局配置 |
|||
mybatis-plus.global-config.banner=false |
|||
mybatis-plus.global-config.enable-sql-runner=false |
|||
# 数据库相关配置 |
|||
mybatis-plus.global-config.db-config.table-underline=true |
|||
|
|||
spring.datasource.admin.name=data_center_buildics_admin |
|||
spring.datasource.admin.url=jdbc:mysql://${datasourceDNS}/data_center_buildics_admin?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=${datasourceTimeZone} |
|||
spring.datasource.admin.username=${datasourceUsername} |
|||
spring.datasource.admin.password=${datasourcePassword} |
|||
#使用druid数据源 |
|||
spring.datasource.admin.type=com.alibaba.druid.pool.DruidDataSource |
|||
spring.datasource.admin.driverClassName=com.mysql.jdbc.Driver |
|||
spring.datasource.admin.hikari.driverClassName=com.mysql.jdbc.Driver |
|||
spring.datasource.admin.hikari.schema=data_center_buildics_admin |
|||
spring.datasource.admin.hikari.minimum-idle: 5 |
|||
spring.datasource.admin.hikari.maximum-pool-size: ${rdsMaxPool:40} |
|||
spring.datasource.admin.hikari.connection-timeout:10000 |
|||
|
|||
dynamic.jdbc.url=jdbc:mysql://${datasourceDNS:rm-bp11k2zm2fr7864428o.mysql.rds.aliyuncs.com:3306}/%s?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=${datasourceTimeZone} |
|||
|
|||
spring.datasource.url=jdbc:mysql://${datasourceDNS:rm-bp11k2zm2fr7864428o.mysql.rds.aliyuncs.com:3306}/data_center_buildics_admin?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=${datasourceTimeZone} |
|||
|
|||
|
|||
#配置log日志 |
|||
logging.config=classpath:config/logback-boot.xml |
|||
logging_level=${loggingLevel} |
|||
logging_path=${loggingPath} |
|||
#部署时使用SYSLOG |
|||
logging_appender=${loggingAppender} |
|||
logging_maxHistory=${loggingMaxHistory:7} |
|||
logging_maxFileSize=100MB |
|||
mybatis_log_level=${mybatisLogLevel} |
|||
|
|||
user.login.keytimeout=360000 |
|||
|
|||
#集群模式cluster |
|||
spring.redis.cluster.nodes=192.168.0.30:7000,192.168.0.30:7001 |
|||
#跨集群执行命令时要遵循的最大重定向数量 |
|||
spring.redis.cluster.max-redirects=3 |
|||
#哨兵模式sentinel |
|||
spring.redis.sentinel.master=mymaster |
|||
spring.redis.sentinel.nodes=192.168.0.30:16379,192.168.0.30:16379 |
|||
|
|||
#单机模式standalone |
|||
spring.redis.host=${redisHost} |
|||
spring.redis.port=6379 |
|||
|
|||
spring.redis.password=${redisPassword} |
|||
spring.redis.timeout=5000 |
|||
#Redis数据库索引(默认为0) |
|||
spring.redis.database=0 |
|||
#配置启动模式cluster、sentinel、standalone |
|||
spring.redis.mode=standalone |
|||
# Lettuce |
|||
# 连接池最大连接数(使用负值表示没有限制) |
|||
spring.redis.lettuce.pool.max-active=8 |
|||
# 连接池最大阻塞等待时间(使用负值表示没有限制) |
|||
spring.redis.lettuce.pool.max-wait=100 |
|||
# 连接池中的最大空闲连接 |
|||
spring.redis.lettuce.pool.max-idle=8 |
|||
# 连接池中的最小空闲连接 |
|||
spring.redis.lettuce.pool.min-idle=0 |
|||
# 关闭超时时间 |
|||
spring.redis.lettuce.shutdown-timeout=100 |
|||
|
|||
|
|||
#邮件发送信息 |
|||
mail.smtp.host=smtp.163.com |
|||
mail.smtp.port=465 |
|||
mail.smtp.auth=true |
|||
mail.smtp.ssl=true |
|||
mail.sender.username=style202206@163.com |
|||
mail.sender.password_encrypted=true |
|||
#这个密码三个月有效期,过期需要更换 |
|||
mail.sender.password=hVndud7spllTv1zuqPHPBSOk5mmvtET+ |
|||
mail.sender.sendername=admin |
|||
mail.sender.from=style202206@163.com |
|||
#邮件通知服务开关 |
|||
mail.send.switch=true |
|||
|
|||
Spring.mvc.hiddenmethod.filter.enabled=true |
|||
#单个文件上传发大小 |
|||
spring.servlet.multipart.max-file-size=20MB |
|||
#多个文件上传的共大小不得超过100M |
|||
spring.servlet.multipart.max-request-size=100MB |
|||
|
|||
server.servlet.context-path=/api |
|||
|
|||
web.login.url=${webLoginUrl} |
|||
|
|||
|
|||
#启用 NoHandlerFoundException |
|||
spring.mvc.throw-exception-if-no-handler-found=true |
|||
#禁用 Spring Boot 默认的静态资源映射,避免 404 错误被静态资源处理覆盖。 |
|||
spring.web.resources.add-mappings=false |
|||
|
|||
server.servlet.session.cookie.http-only=true |
|||
server.servlet.session.cookie.secure=true |
|||
|
|||
springdoc.swagger-ui.doc-expansion=none |
|||
springdoc.swagger-ui.operations-sorter=alpha |
|||
springdoc.swagger-ui.tags-sorter=alpha |
|||
@ -0,0 +1,53 @@ |
|||
<configuration> |
|||
<springProperty scop="context" name="logging_level" source="logging_level" defaultValue="debug"/> |
|||
<springProperty scop="context" name="logging_path" source="logging_path"/> |
|||
<springProperty scop="context" name="logging_appender" source="logging_appender"/> |
|||
<springProperty scop="context" name="logging_maxHistory" source="logging_maxHistory"/> |
|||
<springProperty scop="context" name="logging_maxFileSize" source="logging_maxFileSize"/> |
|||
<springProperty scop="context" name="mybatis_log_level" source="mybatis_log_level"/> |
|||
|
|||
<!-- %m输出的信息,%p日志级别,%t线程名,%d日期,%c类的全名,%i索引【从数字0开始递增】,,, --> |
|||
<!-- appender是configuration的子节点,是负责写日志的组件。 --> |
|||
<!-- ConsoleAppender:把日志输出到控制台 --> |
|||
<appender name="CONSOLELOG" class="ch.qos.logback.core.ConsoleAppender"> |
|||
<encoder> |
|||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %p [%t] %m%n</pattern> |
|||
<!-- <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %p [%t] %c (%file:%line\)- %m%n</pattern> --> |
|||
<charset>UTF-8</charset> |
|||
</encoder> |
|||
</appender> |
|||
<!-- RollingFileAppender:滚动记录文件,先将日志记录到指定文件,当符合某个条件时,将日志记录到其他文件 --> |
|||
<appender name="SYSLOG" |
|||
class="ch.qos.logback.core.rolling.RollingFileAppender"> |
|||
<File>${logging_path}/spring.log</File> |
|||
<!-- rollingPolicy:当发生滚动时,决定 RollingFileAppender 的行为,涉及文件移动和重命名。 --> |
|||
<!-- TimeBasedRollingPolicy: 最常用的滚动策略,它根据时间来制定滚动策略,既负责滚动也负责出发滚动 --> |
|||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
|||
<!-- 活动文件的名字会根据fileNamePattern的值,每隔一段时间改变一次 --> |
|||
<!-- 文件名:log/spring.2019-05-27.0.log --> |
|||
<fileNamePattern>${logging_path}/spring.%d.%i.gz</fileNamePattern> |
|||
<!-- 每产生一个日志文件,该日志文件的保存期限为15天 --> |
|||
<maxHistory>${logging_maxHistory}</maxHistory> |
|||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
|||
<!-- maxFileSize:这是活动文件的大小,默认值是10MB--> |
|||
<maxFileSize>${logging_maxFileSize}</maxFileSize> |
|||
</timeBasedFileNamingAndTriggeringPolicy> |
|||
</rollingPolicy> |
|||
<encoder> |
|||
<!-- pattern节点,用来设置日志的输入格式 --> |
|||
<pattern> |
|||
%d{yyyy-MM-dd HH:mm:ss.SSS} %-5p [%t] %c %m%n |
|||
</pattern> |
|||
<!-- 记录日志的编码 --> |
|||
<charset>UTF-8</charset> <!-- 此处设置字符集 --> |
|||
</encoder> |
|||
</appender> |
|||
|
|||
<!-- project default level --> |
|||
<logger name="com.buildics.oviphone.back" level="${logging_level}"/> |
|||
<logger name="com.buildics.oviphone.back.dao" level="${mybatis_log_level}"/> |
|||
<!-- 控制台输出日志级别 --> |
|||
<root level="INFO"> |
|||
<appender-ref ref="${logging_appender}" /> |
|||
</root> |
|||
</configuration> |
|||
@ -0,0 +1,3 @@ |
|||
project.latest.version=v0.0.1.20240228 |
|||
|
|||
v0.0.1.20240228=1.初始版本 |
|||
@ -0,0 +1,15 @@ |
|||
/target/ |
|||
/logs/ |
|||
/.idea/ |
|||
*.iml |
|||
*.bak |
|||
*.log |
|||
/.settings/ |
|||
*.project |
|||
*.classpath |
|||
*.factorypath |
|||
*.springBeans |
|||
/.apt_generated/ |
|||
/.externalToolBuilders/ |
|||
/bin/ |
|||
application-*.properties |
|||
@ -0,0 +1,91 @@ |
|||
<?xml version="1.0"?> |
|||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" |
|||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
|||
<modelVersion>4.0.0</modelVersion> |
|||
<parent> |
|||
<groupId>com.techsor</groupId> |
|||
<artifactId>buildics-oviphone-back</artifactId> |
|||
<version>0.0.1-SNAPSHOT</version> |
|||
</parent> |
|||
<artifactId>buildics-oviphone-back-dao</artifactId> |
|||
<name>buildics-oviphone-back-dao</name> |
|||
<url>http://maven.apache.org</url> |
|||
<properties> |
|||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
|||
</properties> |
|||
<dependencies> |
|||
|
|||
<!-- https://mvnrepository.com/artifact/org.freemarker/freemarker --> |
|||
<dependency> |
|||
<groupId>org.freemarker</groupId> |
|||
<artifactId>freemarker</artifactId> |
|||
<version>2.3.34</version> |
|||
</dependency> |
|||
|
|||
<!-- MyBatis-Plus --> |
|||
<dependency> |
|||
<groupId>com.baomidou</groupId> |
|||
<artifactId>mybatis-plus-boot-starter</artifactId> |
|||
<version>3.5.16</version> |
|||
<exclusions> |
|||
<!-- 版本匹配问题,防止出现Invalid value type for attribute ‘factoryBeanObjectType‘: java.lang.String --> |
|||
<exclusion> |
|||
<groupId>org.mybatis</groupId> |
|||
<artifactId>mybatis-spring</artifactId> |
|||
</exclusion> |
|||
</exclusions> |
|||
</dependency> |
|||
|
|||
<!-- https://mvnrepository.com/artifact/com.baomidou/mybatis-plus-jsqlparser --> |
|||
<dependency> |
|||
<groupId>com.baomidou</groupId> |
|||
<artifactId>mybatis-plus-jsqlparser</artifactId> |
|||
<version>3.5.16</version> |
|||
</dependency> |
|||
|
|||
|
|||
<!-- https://mvnrepository.com/artifact/com.baomidou/mybatis-plus-generator --> |
|||
<dependency> |
|||
<groupId>com.baomidou</groupId> |
|||
<artifactId>mybatis-plus-generator</artifactId> |
|||
<version>3.5.16</version> |
|||
</dependency> |
|||
|
|||
<!-- https://mvnrepository.com/artifact/org.mybatis/mybatis-spring --> |
|||
<dependency> |
|||
<groupId>org.mybatis</groupId> |
|||
<artifactId>mybatis-spring</artifactId> |
|||
<version>3.0.4</version> |
|||
</dependency> |
|||
|
|||
<dependency> |
|||
<groupId>com.techsor</groupId> |
|||
<artifactId>buildics-oviphone-back-model</artifactId> |
|||
<version>0.0.1-SNAPSHOT</version> |
|||
</dependency> |
|||
|
|||
<!-- <dependency>--> |
|||
<!-- <groupId>com.github.pagehelper</groupId>--> |
|||
<!-- <artifactId>pagehelper-spring-boot-starter</artifactId>--> |
|||
<!-- <version>1.4.7</version>--> |
|||
<!-- </dependency>--> |
|||
|
|||
<dependency> |
|||
<groupId>com.mysql</groupId> |
|||
<artifactId>mysql-connector-j</artifactId> |
|||
<version>9.2.0</version> |
|||
</dependency> |
|||
|
|||
<dependency> |
|||
<groupId>com.alibaba</groupId> |
|||
<artifactId>druid</artifactId> |
|||
<version>1.1.3</version> |
|||
</dependency> |
|||
|
|||
<dependency> |
|||
<groupId>junit</groupId> |
|||
<artifactId>junit</artifactId> |
|||
<scope>test</scope> |
|||
</dependency> |
|||
</dependencies> |
|||
</project> |
|||
@ -0,0 +1,203 @@ |
|||
package com.buildics.oviphone.back.dao; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.IdType; |
|||
import com.baomidou.mybatisplus.generator.AutoGenerator; |
|||
import com.baomidou.mybatisplus.generator.config.*; |
|||
import com.baomidou.mybatisplus.generator.config.builder.GeneratorBuilder; |
|||
import com.baomidou.mybatisplus.generator.config.po.TableField; |
|||
import com.baomidou.mybatisplus.generator.config.querys.MySqlQuery; |
|||
import com.baomidou.mybatisplus.generator.config.rules.DateType; |
|||
import com.baomidou.mybatisplus.generator.config.rules.IColumnType; |
|||
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy; |
|||
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine; |
|||
import com.baomidou.mybatisplus.generator.type.ITypeConvertHandler; |
|||
import com.baomidou.mybatisplus.generator.type.TypeRegistry; |
|||
import org.springframework.util.CollectionUtils; |
|||
|
|||
|
|||
import java.util.Arrays; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
public class MyBatisPlusGenerator { |
|||
|
|||
|
|||
public static class MyCustomTypeConvertHandler implements ITypeConvertHandler { |
|||
@Override |
|||
public IColumnType convert(GlobalConfig globalConfig, TypeRegistry typeRegistry, TableField.MetaInfo metaInfo) { |
|||
String jdbcType = metaInfo.getJdbcType().name(); |
|||
String columnType = metaInfo.getTypeName(); |
|||
String columnName = metaInfo.getColumnName(); |
|||
|
|||
System.out.println(">>> [字段处理] column: " + columnName + |
|||
", jdbcType: " + jdbcType + ", columnType: " + columnType); |
|||
|
|||
// 自定义处理地理类型字段
|
|||
if (columnType != null && (columnType.toLowerCase().contains("geometry") || columnType.toLowerCase().contains("point"))) { |
|||
System.out.println(">>> 命中地理类型字段,使用自定义类型 Point"); |
|||
return new IColumnType() { |
|||
@Override |
|||
public String getType() { |
|||
return "Point"; |
|||
} |
|||
|
|||
@Override |
|||
public String getPkg() { |
|||
return "org.locationtech.jts.geom"; |
|||
} |
|||
}; |
|||
} |
|||
// 默认使用注册中心处理(推荐)
|
|||
return typeRegistry.getColumnType(metaInfo); |
|||
} |
|||
} |
|||
|
|||
public static void main(String[] args) { |
|||
// 1. 数据源配置
|
|||
DataSourceConfig dataSourceConfig = new DataSourceConfig.Builder( |
|||
"jdbc:mysql://rm-bp11k2zm2fr7864428o.mysql.rds.aliyuncs.com:3306/data_center_buildics_admin?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai", |
|||
"zhc", |
|||
"Youqu48bnb1") |
|||
.dbQuery(new MySqlQuery()) |
|||
.schema("data_center_buildics_admin") |
|||
.typeConvertHandler(new MyCustomTypeConvertHandler()) // 自定义字段类型转换类
|
|||
.build(); |
|||
|
|||
// 2. 全局配置(这里设置公共配置,实际路径在pathInfo中单独指定)
|
|||
GlobalConfig globalConfig = GeneratorBuilder.globalConfigBuilder() |
|||
.author("jwy") |
|||
.disableOpenDir() |
|||
.enableSwagger() |
|||
.dateType(DateType.TIME_PACK) |
|||
.commentDate("") |
|||
.build(); |
|||
|
|||
// 3. 包配置(包名设置)
|
|||
PackageConfig packageConfig = GeneratorBuilder.packageConfigBuilder() |
|||
.parent("com.buildics.oviphone.back") |
|||
.entity("model") // 实体类包名
|
|||
.mapper("dao.auto") // Mapper接口包名
|
|||
.service("service") // Service接口包名
|
|||
.serviceImpl("service.impl") // Service实现类包名
|
|||
.controller("controller") // Controller包名
|
|||
.xml("mappers.auto") // XML文件包名
|
|||
.pathInfo(getPathInfo()) // 各层级的实际输出路径
|
|||
.build(); |
|||
|
|||
// 4
|
|||
// 自增主键的表
|
|||
List<String> autoIncrementTables = Arrays.asList( |
|||
"login_history", |
|||
"basic_menu", |
|||
"basic_role", |
|||
"basic_company", |
|||
"basic_user" |
|||
); |
|||
// uuid算法主键的表
|
|||
List<String> assignIdTables = Arrays.asList( |
|||
|
|||
|
|||
); |
|||
// 输入主键的表
|
|||
List<String> inputIdTables = Arrays.asList( |
|||
// "app_stray_animal_location"
|
|||
); |
|||
// 没有主键的表
|
|||
List<String> noIdTables = Arrays.asList( |
|||
"basic_role_menu_relation", |
|||
"basic_role_user_relation" |
|||
); |
|||
|
|||
// 5. 为不同类型表创建不同的策略配置
|
|||
generateForTables(dataSourceConfig, globalConfig, packageConfig, |
|||
autoIncrementTables, IdType.AUTO); |
|||
|
|||
generateForTables(dataSourceConfig, globalConfig, packageConfig, |
|||
assignIdTables, IdType.ASSIGN_UUID); |
|||
|
|||
generateForTables(dataSourceConfig, globalConfig, packageConfig, |
|||
inputIdTables, IdType.INPUT); |
|||
|
|||
generateForTables(dataSourceConfig, globalConfig, packageConfig, |
|||
noIdTables, null); |
|||
} |
|||
|
|||
private static void generateForTables(DataSourceConfig dataSourceConfig, |
|||
GlobalConfig globalConfig, |
|||
PackageConfig packageConfig, |
|||
List<String> tables, |
|||
IdType idType) { |
|||
if (CollectionUtils.isEmpty(tables)){ |
|||
System.out.println(">>> [警告] tables为空,跳过生成"); |
|||
return; |
|||
} |
|||
StrategyConfig strategyConfig = GeneratorBuilder.strategyConfigBuilder() |
|||
.addInclude(tables) |
|||
|
|||
.entityBuilder() |
|||
.enableFileOverride() // 实体类覆盖
|
|||
.enableLombok() |
|||
.enableTableFieldAnnotation() |
|||
.naming(NamingStrategy.underline_to_camel) |
|||
.columnNaming(NamingStrategy.underline_to_camel) |
|||
.enableChainModel() |
|||
.enableRemoveIsPrefix() |
|||
.logicDeleteColumnName("deleted") |
|||
.idType(idType) |
|||
|
|||
.mapperBuilder() |
|||
.enableFileOverride() // Mapper接口覆盖
|
|||
.enableBaseResultMap() |
|||
.enableBaseColumnList() |
|||
.formatMapperFileName("%sMapper") |
|||
.formatXmlFileName("%sMapper") |
|||
|
|||
.controllerBuilder() |
|||
.enableRestStyle() |
|||
.disable() |
|||
|
|||
.serviceBuilder() |
|||
.formatServiceFileName("I%sService") |
|||
.formatServiceImplFileName("%sServiceImpl") |
|||
.disable() |
|||
|
|||
.build(); |
|||
|
|||
// 5. 模板配置
|
|||
TemplateConfig templateConfig = GeneratorBuilder.templateConfigBuilder() |
|||
.entity("/templates/entity.java") //使用自定义模板
|
|||
.build(); |
|||
|
|||
// 6. 创建生成器并执行
|
|||
new AutoGenerator(dataSourceConfig) |
|||
.global(globalConfig) |
|||
.packageInfo(packageConfig) |
|||
.strategy(strategyConfig) |
|||
.template(templateConfig) |
|||
.execute(new FreemarkerTemplateEngine()); |
|||
} |
|||
|
|||
// 自定义各层级的实际输出路径
|
|||
private static Map<OutputFile, String> getPathInfo() { |
|||
String projectRoot = System.getProperty("user.dir"); |
|||
Map<OutputFile, String> pathInfo = new HashMap<>(); |
|||
|
|||
// 实体类输出到 model 模块
|
|||
pathInfo.put(OutputFile.entity, projectRoot + "/buildics-oviphone-back-model/src/main/java/com/buildics/oviphone/back/model"); |
|||
// Mapper接口输出到 dao 模块
|
|||
pathInfo.put(OutputFile.mapper, projectRoot + "/buildics-oviphone-back-dao/src/main/java/com/buildics/oviphone/back/dao/auto"); |
|||
// XML文件输出到 resources 目录
|
|||
pathInfo.put(OutputFile.xml, projectRoot + "/buildics-oviphone-back-dao/src/main/resources/mappers/auto"); |
|||
|
|||
// Service和ServiceImpl输出到 service 模块
|
|||
pathInfo.put(OutputFile.service, projectRoot + "/buildics-oviphone-back-service/src/main/java/com/buildics/oviphone/back/service"); |
|||
pathInfo.put(OutputFile.serviceImpl, projectRoot + "/buildics-oviphone-back-service/src/main/java/com/buildics/oviphone/back/service/impl"); |
|||
// Controller输出到 controller 模块
|
|||
pathInfo.put(OutputFile.controller, projectRoot + "/buildics-oviphone-back-controller/src/main/java/com/buildics/oviphone/back/controller"); |
|||
|
|||
|
|||
|
|||
return pathInfo; |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
package com.buildics.oviphone.back.dao.auto; |
|||
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.buildics.oviphone.back.model.BasicCompany; |
|||
|
|||
/** |
|||
* <p> |
|||
* Mapper 接口 |
|||
* </p> |
|||
* |
|||
* @author jwy |
|||
* @since |
|||
*/ |
|||
public interface BasicCompanyMapper extends BaseMapper<BasicCompany> { |
|||
|
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
package com.buildics.oviphone.back.dao.auto; |
|||
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.buildics.oviphone.back.model.BasicMenu; |
|||
|
|||
/** |
|||
* <p> |
|||
* Mapper 接口 |
|||
* </p> |
|||
* |
|||
* @author jwy |
|||
* @since |
|||
*/ |
|||
public interface BasicMenuMapper extends BaseMapper<BasicMenu> { |
|||
|
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
package com.buildics.oviphone.back.dao.auto; |
|||
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.buildics.oviphone.back.model.BasicRole; |
|||
|
|||
/** |
|||
* <p> |
|||
* Mapper 接口 |
|||
* </p> |
|||
* |
|||
* @author jwy |
|||
* @since |
|||
*/ |
|||
public interface BasicRoleMapper extends BaseMapper<BasicRole> { |
|||
|
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
package com.buildics.oviphone.back.dao.auto; |
|||
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.buildics.oviphone.back.model.BasicRoleMenuRelation; |
|||
|
|||
/** |
|||
* <p> |
|||
* Mapper 接口 |
|||
* </p> |
|||
* |
|||
* @author jwy |
|||
* @since |
|||
*/ |
|||
public interface BasicRoleMenuRelationMapper extends BaseMapper<BasicRoleMenuRelation> { |
|||
|
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
package com.buildics.oviphone.back.dao.auto; |
|||
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.buildics.oviphone.back.model.BasicRoleUserRelation; |
|||
|
|||
/** |
|||
* <p> |
|||
* Mapper 接口 |
|||
* </p> |
|||
* |
|||
* @author jwy |
|||
* @since |
|||
*/ |
|||
public interface BasicRoleUserRelationMapper extends BaseMapper<BasicRoleUserRelation> { |
|||
|
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
package com.buildics.oviphone.back.dao.auto; |
|||
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.buildics.oviphone.back.model.BasicUser; |
|||
|
|||
/** |
|||
* <p> |
|||
* Mapper 接口 |
|||
* </p> |
|||
* |
|||
* @author jwy |
|||
* @since |
|||
*/ |
|||
public interface BasicUserMapper extends BaseMapper<BasicUser> { |
|||
|
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
package com.buildics.oviphone.back.dao.auto; |
|||
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.buildics.oviphone.back.model.LoginHistory; |
|||
|
|||
/** |
|||
* <p> |
|||
* Mapper 接口 |
|||
* </p> |
|||
* |
|||
* @author jwy |
|||
* @since |
|||
*/ |
|||
public interface LoginHistoryMapper extends BaseMapper<LoginHistory> { |
|||
|
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
package com.buildics.oviphone.back.dao.ex; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import com.buildics.oviphone.back.model.BasicCompany; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
import com.buildics.oviphone.back.dao.auto.BasicCompanyMapper; |
|||
import com.buildics.oviphone.back.dto.company.CompanySearchParams; |
|||
import com.buildics.oviphone.back.dto.company.OptCompanyParams; |
|||
import com.buildics.oviphone.back.vo.TreeMenusDTO; |
|||
import com.buildics.oviphone.back.vo.company.CompanyPageDTO; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
@Mapper |
|||
public interface BasicCompanyMapperExt extends BasicCompanyMapper{ |
|||
|
|||
List<BasicCompany> getSubCompanyByParentId(Map<String, Object> searchChildMap); |
|||
|
|||
List<BasicCompany> getSelectList(Map<String, Object> paramMap); |
|||
|
|||
int checkExist(OptCompanyParams optCompanyParams); |
|||
|
|||
IPage<CompanyPageDTO> getListPage(Page<?> page, @Param("params") CompanySearchParams pageSearchParam); |
|||
|
|||
List<TreeMenusDTO> getListForTree(); |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,26 @@ |
|||
package com.buildics.oviphone.back.dao.ex; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import com.buildics.oviphone.back.dto.role.RolePageSearchParam; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
import com.buildics.oviphone.back.dao.auto.BasicRoleMapper; |
|||
import com.buildics.oviphone.back.dto.role.OptRoleParam; |
|||
import com.buildics.oviphone.back.vo.TreeMenusDTO; |
|||
import com.buildics.oviphone.back.vo.role.RolePageDTO; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
@Mapper |
|||
public interface BasicRoleMapperExt extends BasicRoleMapper { |
|||
|
|||
Long checkExist(OptRoleParam param); |
|||
|
|||
List<TreeMenusDTO> getOwnMenuIds(Map<String, Object> paramMap); |
|||
|
|||
IPage<RolePageDTO> getListPage(Page page, @Param("params") RolePageSearchParam pageSearchParam); |
|||
|
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
package com.buildics.oviphone.back.dao.ex; |
|||
|
|||
import java.util.Map; |
|||
|
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
import com.buildics.oviphone.back.dao.auto.BasicRoleMenuRelationMapper; |
|||
|
|||
@Mapper |
|||
public interface BasicRoleMenuRelationMapperExt extends BasicRoleMenuRelationMapper { |
|||
|
|||
void batchInsert(Map<String, Object> paramMap); |
|||
|
|||
String getMenuIdsByRoleId(Long roleId); |
|||
|
|||
} |
|||
@ -0,0 +1,10 @@ |
|||
package com.buildics.oviphone.back.dao.ex; |
|||
|
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
import com.buildics.oviphone.back.dao.auto.BasicRoleUserRelationMapper; |
|||
|
|||
@Mapper |
|||
public interface BasicRoleUserRelationMapperExt extends BasicRoleUserRelationMapper { |
|||
|
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
package com.buildics.oviphone.back.dao.ex; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
import com.buildics.oviphone.back.dao.auto.BasicUserMapper; |
|||
import com.buildics.oviphone.back.dto.user.OptUserParam; |
|||
import com.buildics.oviphone.back.dto.user.PageSearchParam; |
|||
import com.buildics.oviphone.back.vo.user.UserInfoVO; |
|||
import com.buildics.oviphone.back.vo.user.UserPageDTO; |
|||
|
|||
@Mapper |
|||
public interface BasicUserMapperExt extends BasicUserMapper{ |
|||
|
|||
Long checkExist(OptUserParam param); |
|||
|
|||
IPage<UserPageDTO> getListPage(Page<?> page, @Param("params") PageSearchParam pageSearchParam); |
|||
|
|||
String getMenuIdsByUserId(@Param("userId") Long userId); |
|||
|
|||
UserInfoVO getAccountInfo(Map<String, Object> paramMap); |
|||
|
|||
} |
|||
@ -0,0 +1,10 @@ |
|||
package com.buildics.oviphone.back.dao.ex; |
|||
|
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
import com.buildics.oviphone.back.dao.auto.LoginHistoryMapper; |
|||
|
|||
@Mapper |
|||
public interface LoginHistoryMapperExt extends LoginHistoryMapper{ |
|||
|
|||
} |
|||
@ -0,0 +1,33 @@ |
|||
<?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.buildics.oviphone.back.dao.auto.BasicCompanyMapper"> |
|||
|
|||
<!-- 通用查询映射结果 --> |
|||
<resultMap id="BaseResultMap" type="com.buildics.oviphone.back.model.BasicCompany"> |
|||
<id column="id" property="id" /> |
|||
<result column="parent_id" property="parentId" /> |
|||
<result column="company_name" property="companyName" /> |
|||
<result column="mfa_switch" property="mfaSwitch" /> |
|||
<result column="flag" property="flag" /> |
|||
<result column="create_time" property="createTime" /> |
|||
<result column="creator_id" property="creatorId" /> |
|||
<result column="modify_time" property="modifyTime" /> |
|||
<result column="modifier_id" property="modifierId" /> |
|||
<result column="apikey" property="apikey" /> |
|||
<result column="aurora_flag" property="auroraFlag" /> |
|||
<result column="aurora_url" property="auroraUrl" /> |
|||
<result column="aurora_read_url" property="auroraReadUrl" /> |
|||
<result column="aurora_username" property="auroraUsername" /> |
|||
<result column="aurora_password" property="auroraPassword" /> |
|||
<result column="redis_db_id" property="redisDbId" /> |
|||
<result column="bearer_token" property="bearerToken" /> |
|||
<result column="third_api_host" property="thirdApiHost" /> |
|||
<result column="lock_switch" property="lockSwitch" /> |
|||
</resultMap> |
|||
|
|||
<!-- 通用查询结果列 --> |
|||
<sql id="Base_Column_List"> |
|||
id, parent_id, company_name, mfa_switch, flag, create_time, creator_id, modify_time, modifier_id, apikey, aurora_flag, aurora_url, aurora_read_url, aurora_username, aurora_password, redis_db_id, bearer_token, third_api_host, lock_switch |
|||
</sql> |
|||
|
|||
</mapper> |
|||
@ -0,0 +1,23 @@ |
|||
<?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.buildics.oviphone.back.dao.auto.BasicMenuMapper"> |
|||
|
|||
<!-- 通用查询映射结果 --> |
|||
<resultMap id="BaseResultMap" type="com.buildics.oviphone.back.model.BasicMenu"> |
|||
<id column="id" property="id" /> |
|||
<result column="parent_menu_id" property="parentMenuId" /> |
|||
<result column="menu_name" property="menuName" /> |
|||
<result column="menu_name_en" property="menuNameEn" /> |
|||
<result column="menu_name_jp" property="menuNameJp" /> |
|||
<result column="remark" property="remark" /> |
|||
<result column="menu_level" property="menuLevel" /> |
|||
<result column="flag" property="flag" /> |
|||
<result column="create_time" property="createTime" /> |
|||
</resultMap> |
|||
|
|||
<!-- 通用查询结果列 --> |
|||
<sql id="Base_Column_List"> |
|||
id, parent_menu_id, menu_name, menu_name_en, menu_name_jp, remark, menu_level, flag, create_time |
|||
</sql> |
|||
|
|||
</mapper> |
|||
@ -0,0 +1,23 @@ |
|||
<?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.buildics.oviphone.back.dao.auto.BasicRoleMapper"> |
|||
|
|||
<!-- 通用查询映射结果 --> |
|||
<resultMap id="BaseResultMap" type="com.buildics.oviphone.back.model.BasicRole"> |
|||
<id column="id" property="id" /> |
|||
<result column="company_id" property="companyId" /> |
|||
<result column="role_name" property="roleName" /> |
|||
<result column="description" property="description" /> |
|||
<result column="flag" property="flag" /> |
|||
<result column="creator_id" property="creatorId" /> |
|||
<result column="create_time" property="createTime" /> |
|||
<result column="modifier_id" property="modifierId" /> |
|||
<result column="modify_time" property="modifyTime" /> |
|||
</resultMap> |
|||
|
|||
<!-- 通用查询结果列 --> |
|||
<sql id="Base_Column_List"> |
|||
id, company_id, role_name, description, flag, creator_id, create_time, modifier_id, modify_time |
|||
</sql> |
|||
|
|||
</mapper> |
|||
@ -0,0 +1,18 @@ |
|||
<?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.buildics.oviphone.back.dao.auto.BasicRoleMenuRelationMapper"> |
|||
|
|||
<!-- 通用查询映射结果 --> |
|||
<resultMap id="BaseResultMap" type="com.buildics.oviphone.back.model.BasicRoleMenuRelation"> |
|||
<result column="role_id" property="roleId" /> |
|||
<result column="menu_id" property="menuId" /> |
|||
<result column="creator_id" property="creatorId" /> |
|||
<result column="create_time" property="createTime" /> |
|||
</resultMap> |
|||
|
|||
<!-- 通用查询结果列 --> |
|||
<sql id="Base_Column_List"> |
|||
role_id, menu_id, creator_id, create_time |
|||
</sql> |
|||
|
|||
</mapper> |
|||
@ -0,0 +1,18 @@ |
|||
<?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.buildics.oviphone.back.dao.auto.BasicRoleUserRelationMapper"> |
|||
|
|||
<!-- 通用查询映射结果 --> |
|||
<resultMap id="BaseResultMap" type="com.buildics.oviphone.back.model.BasicRoleUserRelation"> |
|||
<result column="user_id" property="userId" /> |
|||
<result column="role_id" property="roleId" /> |
|||
<result column="creator_id" property="creatorId" /> |
|||
<result column="create_time" property="createTime" /> |
|||
</resultMap> |
|||
|
|||
<!-- 通用查询结果列 --> |
|||
<sql id="Base_Column_List"> |
|||
user_id, role_id, creator_id, create_time |
|||
</sql> |
|||
|
|||
</mapper> |
|||
@ -0,0 +1,33 @@ |
|||
<?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.buildics.oviphone.back.dao.auto.BasicUserMapper"> |
|||
|
|||
<!-- 通用查询映射结果 --> |
|||
<resultMap id="BaseResultMap" type="com.buildics.oviphone.back.model.BasicUser"> |
|||
<id column="id" property="id" /> |
|||
<result column="user_type" property="userType" /> |
|||
<result column="company_id" property="companyId" /> |
|||
<result column="username" property="username" /> |
|||
<result column="login_name" property="loginName" /> |
|||
<result column="password" property="password" /> |
|||
<result column="salt" property="salt" /> |
|||
<result column="email" property="email" /> |
|||
<result column="mobile_number" property="mobileNumber" /> |
|||
<result column="last_login_time" property="lastLoginTime" /> |
|||
<result column="flag" property="flag" /> |
|||
<result column="expire_time" property="expireTime" /> |
|||
<result column="create_time" property="createTime" /> |
|||
<result column="creator_id" property="creatorId" /> |
|||
<result column="modify_time" property="modifyTime" /> |
|||
<result column="modifier_id" property="modifierId" /> |
|||
<result column="mfa_secret" property="mfaSecret" /> |
|||
<result column="mfa_bind" property="mfaBind" /> |
|||
<result column="super_role" property="superRole" /> |
|||
</resultMap> |
|||
|
|||
<!-- 通用查询结果列 --> |
|||
<sql id="Base_Column_List"> |
|||
id, user_type, company_id, username, login_name, password, salt, email, mobile_number, last_login_time, flag, expire_time, create_time, creator_id, modify_time, modifier_id, mfa_secret, mfa_bind, super_role |
|||
</sql> |
|||
|
|||
</mapper> |
|||
@ -0,0 +1,18 @@ |
|||
<?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.buildics.oviphone.back.dao.auto.LoginHistoryMapper"> |
|||
|
|||
<!-- 通用查询映射结果 --> |
|||
<resultMap id="BaseResultMap" type="com.buildics.oviphone.back.model.LoginHistory"> |
|||
<id column="id" property="id" /> |
|||
<result column="user_id" property="userId" /> |
|||
<result column="request_ip" property="requestIp" /> |
|||
<result column="login_time" property="loginTime" /> |
|||
</resultMap> |
|||
|
|||
<!-- 通用查询结果列 --> |
|||
<sql id="Base_Column_List"> |
|||
id, user_id, request_ip, login_time |
|||
</sql> |
|||
|
|||
</mapper> |
|||
@ -0,0 +1,72 @@ |
|||
<?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.buildics.oviphone.back.dao.ex.BasicCompanyMapperExt"> |
|||
|
|||
<select id="getSubCompanyByParentId" resultType="com.buildics.oviphone.back.model.BasicCompany" > |
|||
SELECT |
|||
bcom.id |
|||
FROM |
|||
data_center_buildics_admin.basic_company bcom |
|||
WHERE |
|||
bcom.flag != 1 and bcom.parent_id IN |
|||
<foreach collection="companyIds" item="id" open="(" separator="," close=")"> |
|||
#{id} |
|||
</foreach> |
|||
</select> |
|||
|
|||
<select id="getSelectList" resultType="com.buildics.oviphone.back.model.BasicCompany" > |
|||
SELECT |
|||
bcom.id, |
|||
bcom.company_name companyName |
|||
FROM |
|||
data_center_buildics_admin.basic_company bcom |
|||
WHERE bcom.flag != 1 AND bcom.id IN |
|||
<foreach collection="companyIds" item="id" open="(" separator="," close=")"> |
|||
#{id} |
|||
</foreach> |
|||
</select> |
|||
|
|||
|
|||
<select id="checkExist" resultType="java.lang.Integer"> |
|||
SELECT |
|||
COUNT(1) |
|||
FROM |
|||
data_center_buildics_admin.basic_company |
|||
WHERE |
|||
flag != 1 AND company_name = #{companyName} |
|||
<if test="companyId != null"> |
|||
AND id != #{companyId} |
|||
</if> |
|||
</select> |
|||
|
|||
|
|||
<select id="getListPage" resultType="com.buildics.oviphone.back.vo.company.CompanyPageDTO"> |
|||
SELECT |
|||
bcom.id companyId, |
|||
bcom.company_name companyName, |
|||
parentcom.id parentId, |
|||
parentcom.company_name parentCompanyName |
|||
FROM |
|||
data_center_buildics_admin.basic_company bcom |
|||
LEFT JOIN data_center_buildics_admin.basic_company parentcom ON parentcom.id = bcom.parent_id |
|||
WHERE |
|||
bcom.flag != 1 AND bcom.id IN <foreach collection="params.companyIdList" item="item" open="(" separator="," close=")">#{item}</foreach> |
|||
<if test="params.companyName != null"> |
|||
AND bcom.company_name LIKE CONCAT('%',#{params.companyName},'%') |
|||
</if> |
|||
ORDER BY bcom.create_time DESC, bcom.id DESC |
|||
</select> |
|||
|
|||
|
|||
<select id="getListForTree" resultType="com.buildics.oviphone.back.vo.TreeMenusDTO"> |
|||
SELECT |
|||
bcom.id `key`, |
|||
bcom.parent_id parentKey, |
|||
bcom.company_name label |
|||
FROM |
|||
data_center_buildics_admin.basic_company bcom |
|||
WHERE |
|||
bcom.flag != 1 |
|||
</select> |
|||
|
|||
</mapper> |
|||
@ -0,0 +1,68 @@ |
|||
<?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.buildics.oviphone.back.dao.ex.BasicRoleMapperExt"> |
|||
|
|||
<select id="checkExist" resultType="java.lang.Long"> |
|||
SELECT |
|||
COUNT(1) |
|||
FROM |
|||
basic_role brole |
|||
WHERE |
|||
brole.flag != 1 AND brole.role_name = #{roleName} AND brole.company_id = #{companyId} |
|||
<if test="roleId != null"> |
|||
AND brole.id != #{roleId} |
|||
</if> |
|||
</select> |
|||
|
|||
<select id="getOwnMenuIds" resultType="com.buildics.oviphone.back.vo.TreeMenusDTO"> |
|||
SELECT |
|||
bmenu.id `key`, |
|||
bmenu.parent_menu_id parentKey, |
|||
<choose> |
|||
<when test="languageType == 0"> |
|||
bmenu.menu_name label |
|||
</when> |
|||
<when test="languageType == 1"> |
|||
bmenu.menu_name_en label |
|||
</when> |
|||
<otherwise> |
|||
bmenu.menu_name_jp label |
|||
</otherwise> |
|||
</choose> |
|||
FROM |
|||
<choose> |
|||
<when test="superRole != null and superRole == 1"> |
|||
basic_menu bmenu WHERE bmenu.flag != 1 |
|||
</when> |
|||
<otherwise> |
|||
basic_role_user_relation brur |
|||
INNER JOIN basic_role_menu_relation brmr ON brur.role_id = brmr.role_id |
|||
INNER JOIN basic_menu bmenu ON bmenu.id = brmr.menu_id |
|||
WHERE |
|||
bmenu.flag != 1 AND brur.user_id = #{userId} |
|||
</otherwise> |
|||
</choose> |
|||
|
|||
</select> |
|||
|
|||
|
|||
<select id="getListPage" resultType="com.buildics.oviphone.back.vo.role.RolePageDTO"> |
|||
SELECT |
|||
brole.id roleId, |
|||
brole.role_name roleName, |
|||
brole.description, |
|||
brole.modify_time modifyTime |
|||
FROM |
|||
basic_role brole |
|||
WHERE |
|||
brole.flag != 1 AND brole.company_id IN <foreach collection="params.companyIdList" item="item" open="(" separator="," close=")">#{item}</foreach> |
|||
AND brole.id != IFNULL((SELECT role_id FROM basic_role_user_relation WHERE user_id = #{params.userId}), -9) |
|||
<if test="params.roleName != null and params.roleName != ''"> |
|||
AND brole.role_name LIKE CONCAT('%',#{params.roleName},'%') |
|||
</if> |
|||
ORDER BY brole.create_time DESC, brole.id DESC |
|||
|
|||
</select> |
|||
|
|||
|
|||
</mapper> |
|||
@ -0,0 +1,24 @@ |
|||
<?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.buildics.oviphone.back.dao.ex.BasicRoleMenuRelationMapperExt"> |
|||
|
|||
<insert id="batchInsert"> |
|||
INSERT INTO |
|||
basic_role_menu_relation (role_id, menu_id, creator_id, create_time) |
|||
VALUES |
|||
<foreach collection="menuIds" item="item" index="index" separator=","> |
|||
(#{roleId}, #{item}, #{creatorId}, #{createTime}) |
|||
</foreach> |
|||
</insert> |
|||
|
|||
<select id="getMenuIdsByRoleId" resultType="java.lang.String"> |
|||
SELECT |
|||
GROUP_CONCAT(bmenu.id) |
|||
FROM |
|||
basic_role_menu_relation brmr |
|||
INNER JOIN basic_menu bmenu ON bmenu.id = brmr.menu_id |
|||
WHERE |
|||
bmenu.flag != 1 AND brmr.role_id = #{roleId} |
|||
</select> |
|||
|
|||
</mapper> |
|||
@ -0,0 +1,96 @@ |
|||
<?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.buildics.oviphone.back.dao.ex.BasicUserMapperExt"> |
|||
|
|||
<select id="checkExist" resultType="java.lang.Long"> |
|||
SELECT |
|||
COUNT(1) |
|||
FROM |
|||
basic_user buser |
|||
WHERE |
|||
buser.flag != 1 AND (buser.login_name = #{email} OR buser.email = #{loginName} OR buser.email = #{email}) |
|||
<if test="userId != null"> |
|||
AND buser.id != #{userId} |
|||
</if> |
|||
</select> |
|||
|
|||
|
|||
<select id="getListPage" resultType="com.buildics.oviphone.back.vo.user.UserPageDTO"> |
|||
SELECT |
|||
bcom.id companyId, |
|||
bcom.company_name companyName, |
|||
buser.id userId, |
|||
buser.username username, |
|||
buser.login_name loginName, |
|||
buser.email, |
|||
buser.mobile_number mobileNumber, |
|||
buser.create_time createTime, |
|||
any_value(brole.id) roleId, |
|||
any_value(brole.role_name) roleName |
|||
FROM |
|||
basic_user buser |
|||
INNER JOIN basic_company bcom ON buser.company_id = bcom.id |
|||
INNER JOIN basic_role_user_relation brur ON brur.user_id = buser.id |
|||
INNER JOIN basic_role brole ON brur.role_id = brole.id |
|||
WHERE |
|||
buser.flag != 1 AND brole.flag != 1 AND buser.company_id IN <foreach collection="params.companyIdList" item="item" open="(" separator="," close=")">#{item}</foreach> |
|||
<if test="params.userId != null"> |
|||
AND buser.id != #{params.userId} |
|||
</if> |
|||
<if test="params.keyword != null and params.keyword !=''"> |
|||
AND ( |
|||
buser.username LIKE CONCAT('%',#{params.keyword},'%') |
|||
OR |
|||
buser.email LIKE CONCAT('%',#{params.keyword},'%') |
|||
) |
|||
</if> |
|||
ORDER BY buser.create_time DESC, buser.id DESC |
|||
</select> |
|||
|
|||
|
|||
<select id="getMenuIdsByUserId" resultType="java.lang.String"> |
|||
SELECT |
|||
GROUP_CONCAT(bmenu.id) |
|||
FROM |
|||
<choose> |
|||
<when test='userId != null and "1".equals(userId)'> |
|||
basic_menu bmenu WHERE bmenu.flag != 1 |
|||
</when> |
|||
<otherwise> |
|||
basic_role_user_relation brur |
|||
INNER JOIN basic_role brole ON brole.id = brur.role_id |
|||
INNER JOIN basic_role_menu_relation brmr ON brur.role_id = brmr.role_id |
|||
INNER JOIN basic_menu bmenu ON bmenu.id = brmr.menu_id |
|||
WHERE |
|||
brole.flag != 1 AND bmenu.flag != 1 AND brur.user_id = #{userId} |
|||
</otherwise> |
|||
</choose> |
|||
|
|||
</select> |
|||
|
|||
|
|||
<select id="getAccountInfo" resultType="com.buildics.oviphone.back.vo.user.UserInfoVO"> |
|||
SELECT |
|||
buser.id, |
|||
buser.company_id, |
|||
buser.username, |
|||
buser.login_name, |
|||
buser.`password`, |
|||
buser.salt, |
|||
buser.email, |
|||
buser.mobile_number, |
|||
buser.last_login_time, |
|||
buser.flag, |
|||
buser.expire_time, |
|||
buser.create_time, |
|||
buser.creator_id, |
|||
buser.modify_time, |
|||
buser.modifier_id, |
|||
bcom.parent_id parentCompanyId |
|||
FROM |
|||
basic_user buser |
|||
inner join basic_company bcom on bcom.id = buser.company_id |
|||
WHERE buser.flag != 1 and bcom.flag != 1 and (buser.login_name = #{loginname} OR buser.email = #{loginname}) |
|||
</select> |
|||
|
|||
</mapper> |
|||
@ -0,0 +1,90 @@ |
|||
package ${package.Entity}; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.*; |
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Getter; |
|||
import lombok.Setter; |
|||
import lombok.ToString; |
|||
import lombok.experimental.Accessors; |
|||
|
|||
import java.io.Serializable; |
|||
<#-- 日期导入 --> |
|||
<#list table.fields as field> |
|||
<#if field.propertyType == "LocalDate" || field.propertyType == "LocalDateTime"> |
|||
import java.util.Date; |
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
<#break> |
|||
</#if> |
|||
</#list> |
|||
<#-- 导入 org.locationtech.jts.geom.Point 类型 --> |
|||
<#list table.fields as field> |
|||
<#if field.propertyType == "Point"> |
|||
import org.locationtech.jts.geom.Point; |
|||
import com.pet.map.back.handler.PointTypeHandler; |
|||
<#break> |
|||
</#if> |
|||
</#list> |
|||
<#-- BigDecimal 导入 --> |
|||
<#list table.fields as field> |
|||
<#if field.propertyType == "BigDecimal"> |
|||
import java.math.BigDecimal; |
|||
<#break> |
|||
</#if> |
|||
</#list> |
|||
|
|||
@Getter |
|||
@Setter |
|||
@ToString |
|||
@Accessors(chain = true) |
|||
@TableName("${table.name}") |
|||
@Schema(description = "${table.comment!}") |
|||
public class ${entity} implements Serializable { |
|||
|
|||
<#-- 主键字段 --> |
|||
<#assign hasPk = false> |
|||
<#list table.fields as field> |
|||
<#if field.keyFlag> |
|||
<#assign hasPk = true> |
|||
@TableId(value = "${field.name}", type = IdType.${idType!"ASSIGN_ID"}) |
|||
@Schema(description = "${field.comment!}") |
|||
<#if field.propertyType == "LocalDate"> |
|||
JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") |
|||
private Date ${field.propertyName}; |
|||
<#elseif field.propertyType == "LocalDateTime"> |
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
|||
private Date ${field.propertyName}; |
|||
<#else> |
|||
private ${field.propertyType} ${field.propertyName}; |
|||
</#if> |
|||
|
|||
</#if> |
|||
</#list> |
|||
|
|||
<#-- 普通字段 --> |
|||
<#list table.fields as field> |
|||
<#if !field.keyFlag> |
|||
<#if field.propertyType == "Point"> |
|||
@TableField(value = "${field.name}", typeHandler = PointTypeHandler.class) |
|||
<#else> |
|||
@TableField("${field.name}") |
|||
</#if> |
|||
@Schema(description = "${field.comment!}") |
|||
<#if field.propertyType == "LocalDate"> |
|||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") |
|||
private Date ${field.propertyName}; |
|||
<#elseif field.propertyType == "LocalDateTime"> |
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
|||
private Date ${field.propertyName}; |
|||
<#else> |
|||
private ${field.propertyType} ${field.propertyName}; |
|||
</#if> |
|||
|
|||
</#if> |
|||
</#list> |
|||
|
|||
<#-- 无主键表的额外处理 --> |
|||
<#if !hasPk> |
|||
<#-- 在这里可以添加无主键表特有的方法或注释 --> |
|||
<#-- 例如,可能需要提供手动主键生成策略或者修改操作方法 --> |
|||
</#if> |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
/target/ |
|||
/logs/ |
|||
/.idea/ |
|||
*.iml |
|||
*.bak |
|||
*.log |
|||
/.settings/ |
|||
*.project |
|||
*.classpath |
|||
*.factorypath |
|||
*.springBeans |
|||
/.apt_generated/ |
|||
/.externalToolBuilders/ |
|||
/bin/ |
|||
application-*.properties |
|||
@ -0,0 +1,56 @@ |
|||
<?xml version="1.0"?> |
|||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" |
|||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
|||
<modelVersion>4.0.0</modelVersion> |
|||
<parent> |
|||
<groupId>com.techsor</groupId> |
|||
<artifactId>buildics-oviphone-back</artifactId> |
|||
<version>0.0.1-SNAPSHOT</version> |
|||
</parent> |
|||
<artifactId>buildics-oviphone-back-model</artifactId> |
|||
<name>buildics-oviphone-back-model</name> |
|||
<url>http://maven.apache.org</url> |
|||
<properties> |
|||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
|||
</properties> |
|||
<dependencies> |
|||
|
|||
<!-- https://mvnrepository.com/artifact/org.hibernate.validator/hibernate-validator --> |
|||
<dependency> |
|||
<groupId>org.hibernate.validator</groupId> |
|||
<artifactId>hibernate-validator</artifactId> |
|||
<version>9.0.0.CR1</version> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.glassfish</groupId> |
|||
<artifactId>javax.el</artifactId> |
|||
<version>3.0.1-b11</version> |
|||
</dependency> |
|||
<!-- https://mvnrepository.com/artifact/org.hibernate.validator/hibernate-validator-cdi --> |
|||
<dependency> |
|||
<groupId>org.hibernate.validator</groupId> |
|||
<artifactId>hibernate-validator-cdi</artifactId> |
|||
<version>9.0.0.CR1</version> |
|||
</dependency> |
|||
|
|||
<!-- MyBatis-Plus --> |
|||
<dependency> |
|||
<groupId>com.baomidou</groupId> |
|||
<artifactId>mybatis-plus-boot-starter</artifactId> |
|||
<version>3.5.16</version> |
|||
<exclusions> |
|||
<!-- 版本匹配问题,防止出现Invalid value type for attribute ‘factoryBeanObjectType‘: java.lang.String --> |
|||
<exclusion> |
|||
<groupId>org.mybatis</groupId> |
|||
<artifactId>mybatis-spring</artifactId> |
|||
</exclusion> |
|||
</exclusions> |
|||
</dependency> |
|||
|
|||
<dependency> |
|||
<groupId>junit</groupId> |
|||
<artifactId>junit</artifactId> |
|||
<scope>test</scope> |
|||
</dependency> |
|||
</dependencies> |
|||
</project> |
|||
@ -0,0 +1,25 @@ |
|||
package com.buildics.oviphone.back.dto; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Getter; |
|||
import lombok.Setter; |
|||
|
|||
/** |
|||
* @author Mr.Jiang |
|||
* @time 2022年4月23日 下午1:55:22 |
|||
*/ |
|||
@Setter |
|||
@Getter |
|||
public class BaseSearchNoCompanysParams { |
|||
|
|||
/** 页码 */ |
|||
@Schema(description = "当前页码(默认第一页)",example = "1") |
|||
private Integer pageNum; |
|||
/** 每页显示的条数 */ |
|||
@Schema(description = "每页显示的条数(默认20条)", example = "20") |
|||
private Integer pageSize; |
|||
|
|||
@Schema(description = "用户ID", hidden = true) |
|||
private Long userId; |
|||
|
|||
} |
|||
@ -0,0 +1,23 @@ |
|||
package com.buildics.oviphone.back.dto; |
|||
|
|||
import java.util.List; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Getter; |
|||
import lombok.Setter; |
|||
|
|||
/** |
|||
* @author Mr.Jiang |
|||
* @time 2022年4月23日 下午1:55:22 |
|||
*/ |
|||
@Setter |
|||
@Getter |
|||
public class BaseSearchParams extends BaseSearchNoCompanysParams{ |
|||
|
|||
@Schema(description = "查询对象所属企业ID,多个使用逗号连接") |
|||
private String companyIds; |
|||
|
|||
@Schema(description = "查询对象所属企业ID", hidden = true) |
|||
private List<Long> companyIdList; |
|||
|
|||
} |
|||
@ -0,0 +1,23 @@ |
|||
package com.buildics.oviphone.back.dto.account; |
|||
|
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @author Mr.Jiang |
|||
* @time 2022年5月20日 下午2:08:50 |
|||
*/ |
|||
@Data |
|||
public class CacheUserData { |
|||
|
|||
private String accessToken; |
|||
private Long userId; |
|||
private Long companyId; |
|||
private String username; |
|||
private String loginName; |
|||
private String password; |
|||
private Long createTime; |
|||
private Long expireTime; |
|||
private String menuIds; |
|||
// private String userGroupIds;
|
|||
|
|||
} |
|||
@ -0,0 +1,25 @@ |
|||
package com.buildics.oviphone.back.dto.account; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @author Mr.Jiang |
|||
* @time 2022年5月20日 下午7:13:50 |
|||
*/ |
|||
@Data |
|||
public class LoginParam { |
|||
|
|||
@Schema(description ="登录名",example = "admin") |
|||
private String loginname; |
|||
|
|||
@Schema(description = "密码",example = "123456") |
|||
private String password; |
|||
|
|||
@Schema(description = "验证码的请求标识ID",example = "111weyu2-123rt2u1-121ueiu2") |
|||
private String captchaRequestId; |
|||
|
|||
@Schema(description = "验证码值",example = "Z3xA") |
|||
private String captcha; |
|||
|
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
package com.buildics.oviphone.back.dto.company; |
|||
|
|||
import com.buildics.oviphone.back.dto.BaseSearchParams; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @author Mr.Jiang |
|||
* @time 2022年7月21日 下午8:50:31 |
|||
*/ |
|||
@Data |
|||
public class CompanySearchParams extends BaseSearchParams{ |
|||
|
|||
@Schema(description ="企业名",example = "张三李四") |
|||
private String companyName; |
|||
|
|||
@Schema(description ="登录账号的企业ID",example = "1", hidden = true) |
|||
private String selfCompanyId; |
|||
|
|||
// @Schema(description ="1-未进入系统homepage页面获取,2-点击企业后进入系统后获取",example = "2")
|
|||
// private Integer searchType;
|
|||
|
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
package com.buildics.oviphone.back.dto.company; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import jakarta.validation.constraints.NotBlank; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @author Mr.Jiang |
|||
* @time 2022年7月21日 下午8:50:31 |
|||
*/ |
|||
@Data |
|||
public class DeleteCompanyParams{ |
|||
|
|||
@NotBlank(message = "1001") |
|||
@Schema(description ="企业ID,多个使用半角字符逗号连接",example = "2738967,587") |
|||
private String companyIds; |
|||
|
|||
} |
|||
@ -0,0 +1,28 @@ |
|||
package com.buildics.oviphone.back.dto.company; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import jakarta.validation.constraints.NotBlank; |
|||
import jakarta.validation.constraints.NotNull; |
|||
import lombok.Data; |
|||
import org.hibernate.validator.constraints.Length; |
|||
|
|||
/** |
|||
* @author Mr.Jiang |
|||
* @time 2022年7月21日 下午8:50:31 |
|||
*/ |
|||
@Data |
|||
public class OptCompanyParams{ |
|||
|
|||
@Schema(description ="企业唯一标识ID,新增时无此参数",example = "2738967") |
|||
private String companyId; |
|||
|
|||
@Schema(description ="父企业ID",example = "2738967", hidden = true) |
|||
private Long parentId; |
|||
|
|||
@NotBlank(message = "1001") |
|||
@Length(max = 500,message = "1002") |
|||
@Schema(description ="企业名称",example = "testAccount1", required = true) |
|||
private String companyName; |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,20 @@ |
|||
package com.buildics.oviphone.back.dto.role; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import jakarta.validation.constraints.NotBlank; |
|||
import lombok.Getter; |
|||
import lombok.Setter; |
|||
|
|||
/** |
|||
* @author Mr.Jiang |
|||
* @time 2022年4月23日 下午1:59:33 |
|||
*/ |
|||
@Setter |
|||
@Getter |
|||
public class DeleteRoleParam { |
|||
|
|||
@NotBlank(message = "1001") |
|||
@Schema(description ="Id,多个使用逗号连接",example = "3,5", required = true) |
|||
private String roleIds; |
|||
|
|||
} |
|||
@ -0,0 +1,38 @@ |
|||
package com.buildics.oviphone.back.dto.role; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import jakarta.validation.constraints.Max; |
|||
import jakarta.validation.constraints.Min; |
|||
import jakarta.validation.constraints.NotBlank; |
|||
import lombok.Getter; |
|||
import lombok.Setter; |
|||
import org.hibernate.validator.constraints.Length; |
|||
import org.hibernate.validator.constraints.Range; |
|||
|
|||
/** |
|||
* @author zhc |
|||
* @time 2022年6月14日10:56:38 |
|||
*/ |
|||
@Setter |
|||
@Getter |
|||
public class OptRoleParam { |
|||
|
|||
@Schema(description ="角色ID, 新增时无此参数",example = "111", required = false) |
|||
private String roleId; |
|||
|
|||
@NotBlank(message = "1001") |
|||
@Length(max = 100,message = "1002") |
|||
@Schema(description ="角色名称",example = "管理员", required = true) |
|||
private String roleName; |
|||
|
|||
@Length(max = 500,message = "1002") |
|||
@Schema(description ="描述",example = "这是管理员描述") |
|||
private String description; |
|||
|
|||
@Schema(description ="菜单权限ID,使用逗号连接",example = "1,4,5,6") |
|||
private String menuIds; |
|||
|
|||
@Schema(description ="所属企业ID",example = "2", hidden = true) |
|||
private String companyId; |
|||
|
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
package com.buildics.oviphone.back.dto.role; |
|||
|
|||
import com.buildics.oviphone.back.dto.BaseSearchParams; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Getter; |
|||
import lombok.Setter; |
|||
|
|||
/** |
|||
* @author Mr.zhc |
|||
* @time 2022年7月27日12:06:35 |
|||
*/ |
|||
@Setter |
|||
@Getter |
|||
public class RolePageSearchParam extends BaseSearchParams{ |
|||
|
|||
@Schema(description ="角色名",example = "test", required = false) |
|||
private String roleName; |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,20 @@ |
|||
package com.buildics.oviphone.back.dto.user; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import jakarta.validation.constraints.NotBlank; |
|||
import lombok.Getter; |
|||
import lombok.Setter; |
|||
|
|||
/** |
|||
* @author Mr.Jiang |
|||
* @time 2022年4月23日 下午1:59:33 |
|||
*/ |
|||
@Setter |
|||
@Getter |
|||
public class DeleteUserParam { |
|||
|
|||
@NotBlank(message = "1001") |
|||
@Schema(description ="Id,多个使用逗号连接",example = "3,5", required = true) |
|||
private String userIds; |
|||
|
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
package com.buildics.oviphone.back.dto.user; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import jakarta.validation.constraints.NotBlank; |
|||
import lombok.Getter; |
|||
import lombok.Setter; |
|||
|
|||
/** |
|||
* @author Mr.Jiang |
|||
* @time 2022年4月23日 下午1:59:33 |
|||
*/ |
|||
@Setter |
|||
@Getter |
|||
public class ModifyPassword{ |
|||
|
|||
@NotBlank(message = "1001") |
|||
@Schema(description ="旧密码",example = "haoihg09278", required = true) |
|||
private String oldPassword; |
|||
|
|||
@NotBlank(message = "1001") |
|||
@Schema(description ="新密码",example = "og.ayhgih", required = true) |
|||
private String newPassword; |
|||
|
|||
} |
|||
@ -0,0 +1,44 @@ |
|||
package com.buildics.oviphone.back.dto.user; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import jakarta.validation.constraints.Email; |
|||
import jakarta.validation.constraints.NotBlank; |
|||
import lombok.Getter; |
|||
import lombok.Setter; |
|||
import org.hibernate.validator.constraints.Length; |
|||
|
|||
/** |
|||
* @author zhc |
|||
* @time 2022年6月14日10:56:38 |
|||
*/ |
|||
@Setter |
|||
@Getter |
|||
public class OptUserParam { |
|||
|
|||
|
|||
@Schema(description ="用户ID, 新增时无此参数",example = "111", required = false) |
|||
private String userId; |
|||
|
|||
@Schema(description ="角色ID",example = "24", required = false) |
|||
private String roleId; |
|||
|
|||
@NotBlank(message = "1001") |
|||
@Length(max = 255,message = "1002") |
|||
@Schema(description ="用户名",example = "管理员", required = true) |
|||
private String username; |
|||
|
|||
@Schema(description ="登录名",example = "adminmin", hidden = true) |
|||
private String loginName; |
|||
|
|||
@Email(message = "1004") |
|||
@Schema(description ="用户邮箱",example = "1057897@qq.com", required = true) |
|||
private String email; |
|||
|
|||
@Schema(description ="手机号码,这里要加上国际区号,比如日本是+81,传给后台的就是+81-08041165856,中国是+86,传给后台的就是+86-18841165856",example = "+81-08041165856", required = false) |
|||
private String mobileNumber; |
|||
|
|||
@Schema(description ="所属企业ID",example = "2", hidden = true) |
|||
private String companyId; |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,20 @@ |
|||
package com.buildics.oviphone.back.dto.user; |
|||
|
|||
import com.buildics.oviphone.back.dto.BaseSearchParams; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Getter; |
|||
import lombok.Setter; |
|||
|
|||
/** |
|||
* @author Mr.zhc |
|||
* @time 2022年7月27日12:06:35 |
|||
*/ |
|||
@Setter |
|||
@Getter |
|||
public class PageSearchParam extends BaseSearchParams{ |
|||
|
|||
@Schema(description ="用户名/用户邮箱",example = "test", required = false) |
|||
private String keyword; |
|||
|
|||
} |
|||
@ -0,0 +1,23 @@ |
|||
package com.buildics.oviphone.back.dto.user; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import jakarta.validation.constraints.NotBlank; |
|||
import lombok.Getter; |
|||
import lombok.Setter; |
|||
|
|||
/** |
|||
* @author Mr.Jiang |
|||
* @time 2022年4月23日 下午1:59:33 |
|||
*/ |
|||
@Setter |
|||
@Getter |
|||
public class ResetPassword{ |
|||
|
|||
@NotBlank(message = "1001") |
|||
@Schema(description ="Id,多个使用逗号连接",example = "3,5", required = true) |
|||
private String userIds; |
|||
|
|||
// @Schema(description ="重置密码方式 1-管理员直接重置密码,账号邮箱接收该密码,2-发送重置密码链接到绑定的账户邮箱中,用户自己重置密码",example = "2", required = true)
|
|||
// private Integer resetType = 1;
|
|||
|
|||
} |
|||
@ -0,0 +1,98 @@ |
|||
package com.buildics.oviphone.back.model; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.*; |
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Getter; |
|||
import lombok.Setter; |
|||
import lombok.ToString; |
|||
import lombok.experimental.Accessors; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
@Getter |
|||
@Setter |
|||
@ToString |
|||
@Accessors(chain = true) |
|||
@TableName("basic_company") |
|||
@Schema(description = "") |
|||
public class BasicCompany implements Serializable { |
|||
|
|||
@TableId(value = "id", type = IdType.AUTO) |
|||
@Schema(description = "") |
|||
private Long id; |
|||
|
|||
|
|||
@TableField("parent_id") |
|||
@Schema(description = "父企业ID") |
|||
private Long parentId; |
|||
|
|||
@TableField("company_name") |
|||
@Schema(description = "") |
|||
private String companyName; |
|||
|
|||
@TableField("mfa_switch") |
|||
@Schema(description = "谷歌mfa服务开关。0-关闭,1-开启") |
|||
private Integer mfaSwitch; |
|||
|
|||
@TableField("flag") |
|||
@Schema(description = "0-正常,1-删除") |
|||
private Integer flag; |
|||
|
|||
@TableField("create_time") |
|||
@Schema(description = "") |
|||
private Long createTime; |
|||
|
|||
@TableField("creator_id") |
|||
@Schema(description = "") |
|||
private Long creatorId; |
|||
|
|||
@TableField("modify_time") |
|||
@Schema(description = "") |
|||
private Long modifyTime; |
|||
|
|||
@TableField("modifier_id") |
|||
@Schema(description = "") |
|||
private Long modifierId; |
|||
|
|||
@TableField("apikey") |
|||
@Schema(description = "") |
|||
private String apikey; |
|||
|
|||
@TableField("aurora_flag") |
|||
@Schema(description = "0-未创建,1-创建中,2-创建成功,3-创建失败") |
|||
private Integer auroraFlag; |
|||
|
|||
@TableField("aurora_url") |
|||
@Schema(description = "") |
|||
private String auroraUrl; |
|||
|
|||
@TableField("aurora_read_url") |
|||
@Schema(description = "") |
|||
private String auroraReadUrl; |
|||
|
|||
@TableField("aurora_username") |
|||
@Schema(description = "") |
|||
private String auroraUsername; |
|||
|
|||
@TableField("aurora_password") |
|||
@Schema(description = "") |
|||
private String auroraPassword; |
|||
|
|||
@TableField("redis_db_id") |
|||
@Schema(description = "使用的redis库id") |
|||
private Integer redisDbId; |
|||
|
|||
@TableField("bearer_token") |
|||
@Schema(description = "") |
|||
private String bearerToken; |
|||
|
|||
@TableField("third_api_host") |
|||
@Schema(description = "Third api地址域名,例如:https://api-sec.test-public-api.kanri-roid.app/api/public/v1/problem-reports/return-to-normal,则这里是https://api-sec.test-public-api.kanri-roid.app") |
|||
private String thirdApiHost; |
|||
|
|||
@TableField("lock_switch") |
|||
@Schema(description = "5次登录失败锁定开关,0-关闭,1-开启") |
|||
private Integer lockSwitch; |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,58 @@ |
|||
package com.buildics.oviphone.back.model; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.*; |
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Getter; |
|||
import lombok.Setter; |
|||
import lombok.ToString; |
|||
import lombok.experimental.Accessors; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
@Getter |
|||
@Setter |
|||
@ToString |
|||
@Accessors(chain = true) |
|||
@TableName("basic_menu") |
|||
@Schema(description = "") |
|||
public class BasicMenu implements Serializable { |
|||
|
|||
@TableId(value = "id", type = IdType.AUTO) |
|||
@Schema(description = "") |
|||
private Long id; |
|||
|
|||
|
|||
@TableField("parent_menu_id") |
|||
@Schema(description = "") |
|||
private Long parentMenuId; |
|||
|
|||
@TableField("menu_name") |
|||
@Schema(description = "") |
|||
private String menuName; |
|||
|
|||
@TableField("menu_name_en") |
|||
@Schema(description = "") |
|||
private String menuNameEn; |
|||
|
|||
@TableField("menu_name_jp") |
|||
@Schema(description = "") |
|||
private String menuNameJp; |
|||
|
|||
@TableField("remark") |
|||
@Schema(description = "") |
|||
private String remark; |
|||
|
|||
@TableField("menu_level") |
|||
@Schema(description = "菜单级别") |
|||
private Integer menuLevel; |
|||
|
|||
@TableField("flag") |
|||
@Schema(description = "0-正常,1-删除") |
|||
private Integer flag; |
|||
|
|||
@TableField("create_time") |
|||
@Schema(description = "") |
|||
private Long createTime; |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,58 @@ |
|||
package com.buildics.oviphone.back.model; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.*; |
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Getter; |
|||
import lombok.Setter; |
|||
import lombok.ToString; |
|||
import lombok.experimental.Accessors; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
@Getter |
|||
@Setter |
|||
@ToString |
|||
@Accessors(chain = true) |
|||
@TableName("basic_role") |
|||
@Schema(description = "") |
|||
public class BasicRole implements Serializable { |
|||
|
|||
@TableId(value = "id", type = IdType.AUTO) |
|||
@Schema(description = "") |
|||
private Long id; |
|||
|
|||
|
|||
@TableField("company_id") |
|||
@Schema(description = "") |
|||
private Long companyId; |
|||
|
|||
@TableField("role_name") |
|||
@Schema(description = "") |
|||
private String roleName; |
|||
|
|||
@TableField("description") |
|||
@Schema(description = "") |
|||
private String description; |
|||
|
|||
@TableField("flag") |
|||
@Schema(description = "0-正常,1-删除") |
|||
private Integer flag; |
|||
|
|||
@TableField("creator_id") |
|||
@Schema(description = "") |
|||
private Long creatorId; |
|||
|
|||
@TableField("create_time") |
|||
@Schema(description = "") |
|||
private Long createTime; |
|||
|
|||
@TableField("modifier_id") |
|||
@Schema(description = "") |
|||
private Long modifierId; |
|||
|
|||
@TableField("modify_time") |
|||
@Schema(description = "") |
|||
private Long modifyTime; |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,38 @@ |
|||
package com.buildics.oviphone.back.model; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.*; |
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Getter; |
|||
import lombok.Setter; |
|||
import lombok.ToString; |
|||
import lombok.experimental.Accessors; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
@Getter |
|||
@Setter |
|||
@ToString |
|||
@Accessors(chain = true) |
|||
@TableName("basic_role_menu_relation") |
|||
@Schema(description = "") |
|||
public class BasicRoleMenuRelation implements Serializable { |
|||
|
|||
|
|||
@TableField("role_id") |
|||
@Schema(description = "") |
|||
private Long roleId; |
|||
|
|||
@TableField("menu_id") |
|||
@Schema(description = "") |
|||
private Long menuId; |
|||
|
|||
@TableField("creator_id") |
|||
@Schema(description = "") |
|||
private Long creatorId; |
|||
|
|||
@TableField("create_time") |
|||
@Schema(description = "") |
|||
private Long createTime; |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,38 @@ |
|||
package com.buildics.oviphone.back.model; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.*; |
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Getter; |
|||
import lombok.Setter; |
|||
import lombok.ToString; |
|||
import lombok.experimental.Accessors; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
@Getter |
|||
@Setter |
|||
@ToString |
|||
@Accessors(chain = true) |
|||
@TableName("basic_role_user_relation") |
|||
@Schema(description = "") |
|||
public class BasicRoleUserRelation implements Serializable { |
|||
|
|||
|
|||
@TableField("user_id") |
|||
@Schema(description = "") |
|||
private Long userId; |
|||
|
|||
@TableField("role_id") |
|||
@Schema(description = "") |
|||
private Long roleId; |
|||
|
|||
@TableField("creator_id") |
|||
@Schema(description = "") |
|||
private Long creatorId; |
|||
|
|||
@TableField("create_time") |
|||
@Schema(description = "") |
|||
private Long createTime; |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,98 @@ |
|||
package com.buildics.oviphone.back.model; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.*; |
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Getter; |
|||
import lombok.Setter; |
|||
import lombok.ToString; |
|||
import lombok.experimental.Accessors; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
@Getter |
|||
@Setter |
|||
@ToString |
|||
@Accessors(chain = true) |
|||
@TableName("basic_user") |
|||
@Schema(description = "") |
|||
public class BasicUser implements Serializable { |
|||
|
|||
@TableId(value = "id", type = IdType.AUTO) |
|||
@Schema(description = "") |
|||
private Long id; |
|||
|
|||
|
|||
@TableField("user_type") |
|||
@Schema(description = "0-未知,1-管理平台用户,2-普通平台用户") |
|||
private Integer userType; |
|||
|
|||
@TableField("company_id") |
|||
@Schema(description = "") |
|||
private Long companyId; |
|||
|
|||
@TableField("username") |
|||
@Schema(description = "") |
|||
private String username; |
|||
|
|||
@TableField("login_name") |
|||
@Schema(description = "") |
|||
private String loginName; |
|||
|
|||
@TableField("password") |
|||
@Schema(description = "") |
|||
private String password; |
|||
|
|||
@TableField("salt") |
|||
@Schema(description = "密码加密的盐") |
|||
private String salt; |
|||
|
|||
@TableField("email") |
|||
@Schema(description = "") |
|||
private String email; |
|||
|
|||
@TableField("mobile_number") |
|||
@Schema(description = "") |
|||
private String mobileNumber; |
|||
|
|||
@TableField("last_login_time") |
|||
@Schema(description = "最新登录时间") |
|||
private Long lastLoginTime; |
|||
|
|||
@TableField("flag") |
|||
@Schema(description = "0-正常,1-删除") |
|||
private Integer flag; |
|||
|
|||
@TableField("expire_time") |
|||
@Schema(description = "有效期") |
|||
private Long expireTime; |
|||
|
|||
@TableField("create_time") |
|||
@Schema(description = "创建时间") |
|||
private Long createTime; |
|||
|
|||
@TableField("creator_id") |
|||
@Schema(description = "创建人") |
|||
private Long creatorId; |
|||
|
|||
@TableField("modify_time") |
|||
@Schema(description = "修改时间") |
|||
private Long modifyTime; |
|||
|
|||
@TableField("modifier_id") |
|||
@Schema(description = "修改人") |
|||
private Long modifierId; |
|||
|
|||
@TableField("mfa_secret") |
|||
@Schema(description = "") |
|||
private String mfaSecret; |
|||
|
|||
@TableField("mfa_bind") |
|||
@Schema(description = "用户是否绑定了mfa设备。0-未绑定,1-已绑定") |
|||
private Integer mfaBind; |
|||
|
|||
@TableField("super_role") |
|||
@Schema(description = "超管权限,1超管,0普通") |
|||
private Integer superRole; |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,38 @@ |
|||
package com.buildics.oviphone.back.model; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.*; |
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Getter; |
|||
import lombok.Setter; |
|||
import lombok.ToString; |
|||
import lombok.experimental.Accessors; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
@Getter |
|||
@Setter |
|||
@ToString |
|||
@Accessors(chain = true) |
|||
@TableName("login_history") |
|||
@Schema(description = "") |
|||
public class LoginHistory implements Serializable { |
|||
|
|||
@TableId(value = "id", type = IdType.AUTO) |
|||
@Schema(description = "") |
|||
private Long id; |
|||
|
|||
|
|||
@TableField("user_id") |
|||
@Schema(description = "") |
|||
private Long userId; |
|||
|
|||
@TableField("request_ip") |
|||
@Schema(description = "") |
|||
private String requestIp; |
|||
|
|||
@TableField("login_time") |
|||
@Schema(description = "") |
|||
private Long loginTime; |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
package com.buildics.oviphone.back.vo; |
|||
|
|||
import java.util.List; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @author Mr.Jiang |
|||
* @time 2022年7月29日 下午4:37:50 |
|||
*/ |
|||
@Data |
|||
public class TreeMenusDTO { |
|||
|
|||
@Schema(description ="节点ID",example = "11", required = true) |
|||
private String key; |
|||
|
|||
@Schema(description ="父节点ID",example = "2", hidden = true) |
|||
private String parentKey; |
|||
|
|||
@Schema(description ="节点名称",example = "添加", required = true) |
|||
private String label; |
|||
|
|||
@Schema(description ="子节点",example = "[]", required = false) |
|||
private List<TreeMenusDTO> children; |
|||
|
|||
} |
|||
@ -0,0 +1,25 @@ |
|||
package com.buildics.oviphone.back.vo.company; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @author Mr.Jiang |
|||
* @time 2022年7月21日 下午8:50:31 |
|||
*/ |
|||
@Data |
|||
public class CompanyPageDTO{ |
|||
|
|||
@Schema(description ="企业唯一标识ID,新增时无此参数",example = "2738967") |
|||
private String companyId; |
|||
|
|||
@Schema(description ="企业名称",example = "testAccount1", required = true) |
|||
private String companyName; |
|||
|
|||
@Schema(description ="所属企业ID",example = "2738967") |
|||
private String parentId; |
|||
|
|||
@Schema(description ="所属企业名称",example = "testAccount1", required = true) |
|||
private String parentCompanyName; |
|||
|
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
package com.buildics.oviphone.back.vo.role; |
|||
|
|||
import java.util.List; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @author Mr.Jiang |
|||
* @time 2022年7月29日 下午4:37:50 |
|||
*/ |
|||
@Data |
|||
public class RoleMenuDTO { |
|||
|
|||
@Schema(description ="菜单ID",example = "11", required = true) |
|||
private String key; |
|||
|
|||
@Schema(description ="父菜单ID",example = "2", hidden = true) |
|||
private String parentKey; |
|||
|
|||
@Schema(description ="菜单名称",example = "添加", required = true) |
|||
private String label; |
|||
|
|||
@Schema(description ="子菜单",example = "[]", required = false) |
|||
private List<RoleMenuDTO> children; |
|||
|
|||
} |
|||
@ -0,0 +1,25 @@ |
|||
package com.buildics.oviphone.back.vo.role; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @author Mr.Jiang |
|||
* @time 2022年5月22日 下午10:37:02 |
|||
*/ |
|||
@Data |
|||
public class RolePageDTO { |
|||
|
|||
@Schema(description ="角色ID",example = "111", required = true) |
|||
private String roleId; |
|||
|
|||
@Schema(description ="角色名称",example = "管理员", required = true) |
|||
private String roleName; |
|||
|
|||
@Schema(description ="描述",example = "这是管理员描述", required = true) |
|||
private String description; |
|||
|
|||
@Schema(description ="最后更新时间",example = "1689878789647", required = true) |
|||
private Long modifyTime; |
|||
|
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
package com.buildics.oviphone.back.vo.user; |
|||
|
|||
import com.buildics.oviphone.back.model.BasicUser; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @author Mr.Jiang |
|||
* @time 2022年5月22日 下午10:37:02 |
|||
*/ |
|||
@Data |
|||
public class UserInfoVO extends BasicUser { |
|||
|
|||
private String parentCompanyId; |
|||
|
|||
} |
|||
@ -0,0 +1,43 @@ |
|||
package com.buildics.oviphone.back.vo.user; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @author Mr.Jiang |
|||
* @time 2022年5月22日 下午10:37:02 |
|||
*/ |
|||
@Data |
|||
public class UserPageDTO { |
|||
|
|||
@Schema(description ="企业唯一标识ID,新增时无此参数",example = "2738967") |
|||
private String companyId; |
|||
|
|||
@Schema(description ="企业名称",example = "testAccount1", required = true) |
|||
private String companyName; |
|||
|
|||
@Schema(description ="用户ID, 新增时无此参数",example = "111", required = false) |
|||
private String userId; |
|||
|
|||
@Schema(description ="角色ID",example = "24", required = false) |
|||
private String roleId; |
|||
|
|||
@Schema(description ="角色名",example = "24", required = false) |
|||
private String roleName; |
|||
|
|||
@Schema(description ="用户名",example = "管理员", required = true) |
|||
private String username; |
|||
|
|||
// @Schema(description ="登录名",example = "adminmin", required = true)
|
|||
// private String loginName;
|
|||
|
|||
@Schema(description ="用户邮箱",example = "1057897@qq.com", required = true) |
|||
private String email; |
|||
|
|||
@Schema(description ="手机号码,这里要加上国际区号,比如日本是+81,传给后台的就是+81-08041165856,中国是+86,传给后台的就是+86-18841165856",example = "+81-08041165856", required = false) |
|||
private String mobileNumber; |
|||
|
|||
@Schema(description ="创建时间",example = "1678990326897", required = false) |
|||
private Long createTime; |
|||
|
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
/target/ |
|||
/logs/ |
|||
/.idea/ |
|||
*.iml |
|||
*.bak |
|||
*.log |
|||
/.settings/ |
|||
*.project |
|||
*.classpath |
|||
*.factorypath |
|||
*.springBeans |
|||
/.apt_generated/ |
|||
/.externalToolBuilders/ |
|||
/bin/ |
|||
application-*.properties |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue