Compare commits
10 Commits
17c891ff02
...
027e3df9d0
Author | SHA1 | Date |
---|---|---|
|
027e3df9d0 | |
|
dd30d17c40 | |
|
68f94b0f26 | |
|
c470ef9787 | |
|
50a58d2470 | |
|
934367b1ea | |
|
b5757fdead | |
|
7c49fee992 | |
|
0b97b1e2ed | |
|
d81b53910e |
|
@ -7,7 +7,7 @@ nacos:
|
|||
addr: 106.15.136.7:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: lyb
|
||||
namespace: xzr
|
||||
# Spring
|
||||
spring:
|
||||
application:
|
||||
|
|
|
@ -21,132 +21,132 @@ public @interface Excel {
|
|||
/**
|
||||
* 导出时在excel中排序
|
||||
*/
|
||||
public int sort () default Integer.MAX_VALUE;
|
||||
public int sort() default Integer.MAX_VALUE;
|
||||
|
||||
/**
|
||||
* 导出到Excel中的名字.
|
||||
*/
|
||||
public String name () default "";
|
||||
public String name() default "";
|
||||
|
||||
/**
|
||||
* 日期格式, 如: yyyy-MM-dd
|
||||
*/
|
||||
public String dateFormat () default "";
|
||||
public String dateFormat() default "";
|
||||
|
||||
/**
|
||||
* 读取内容转表达式 (如: 0=男,1=女,2=未知)
|
||||
*/
|
||||
public String readConverterExp () default "";
|
||||
public String readConverterExp() default "";
|
||||
|
||||
/**
|
||||
* 分隔符,读取字符串组内容
|
||||
*/
|
||||
public String separator () default ",";
|
||||
public String separator() default ",";
|
||||
|
||||
/**
|
||||
* BigDecimal 精度 默认:-1(默认不开启BigDecimal格式化)
|
||||
*/
|
||||
public int scale () default -1;
|
||||
public int scale() default -1;
|
||||
|
||||
/**
|
||||
* BigDecimal 舍入规则 默认:BigDecimal.ROUND_HALF_EVEN
|
||||
*/
|
||||
public int roundingMode () default BigDecimal.ROUND_HALF_EVEN;
|
||||
public int roundingMode() default BigDecimal.ROUND_HALF_EVEN;
|
||||
|
||||
/**
|
||||
* 导出时在excel中每个列的高度
|
||||
*/
|
||||
public double height () default 14;
|
||||
public double height() default 14;
|
||||
|
||||
/**
|
||||
* 导出时在excel中每个列的宽度
|
||||
*/
|
||||
public double width () default 16;
|
||||
public double width() default 16;
|
||||
|
||||
/**
|
||||
* 文字后缀,如% 90 变成90%
|
||||
*/
|
||||
public String suffix () default "";
|
||||
public String suffix() default "";
|
||||
|
||||
/**
|
||||
* 当值为空时,字段的默认值
|
||||
*/
|
||||
public String defaultValue () default "";
|
||||
public String defaultValue() default "";
|
||||
|
||||
/**
|
||||
* 提示信息
|
||||
*/
|
||||
public String prompt () default "";
|
||||
public String prompt() default "";
|
||||
|
||||
/**
|
||||
* 设置只能选择不能输入的列内容.
|
||||
*/
|
||||
public String[] combo () default {};
|
||||
public String[] combo() default {};
|
||||
|
||||
/**
|
||||
* 是否需要纵向合并单元格,应对需求:含有list集合单元格)
|
||||
*/
|
||||
public boolean needMerge () default false;
|
||||
public boolean needMerge() default false;
|
||||
|
||||
/**
|
||||
* 是否导出数据,应对需求:有时我们需要导出一份模板,这是标题需要但内容需要用户手工填写.
|
||||
*/
|
||||
public boolean isExport () default true;
|
||||
public boolean isExport() default true;
|
||||
|
||||
/**
|
||||
* 另一个类中的属性名称,支持多级获取,以小数点隔开
|
||||
*/
|
||||
public String targetAttr () default "";
|
||||
public String targetAttr() default "";
|
||||
|
||||
/**
|
||||
* 是否自动统计数据,在最后追加一行统计数据总和
|
||||
*/
|
||||
public boolean isStatistics () default false;
|
||||
public boolean isStatistics() default false;
|
||||
|
||||
/**
|
||||
* 导出类型(0数字 1字符串)
|
||||
*/
|
||||
public ColumnType cellType () default ColumnType.STRING;
|
||||
public ColumnType cellType() default ColumnType.STRING;
|
||||
|
||||
/**
|
||||
* 导出列头背景颜色
|
||||
*/
|
||||
public IndexedColors headerBackgroundColor () default IndexedColors.GREY_50_PERCENT;
|
||||
public IndexedColors headerBackgroundColor() default IndexedColors.GREY_50_PERCENT;
|
||||
|
||||
/**
|
||||
* 导出列头字体颜色
|
||||
*/
|
||||
public IndexedColors headerColor () default IndexedColors.WHITE;
|
||||
public IndexedColors headerColor() default IndexedColors.WHITE;
|
||||
|
||||
/**
|
||||
* 导出单元格背景颜色
|
||||
*/
|
||||
public IndexedColors backgroundColor () default IndexedColors.WHITE;
|
||||
public IndexedColors backgroundColor() default IndexedColors.WHITE;
|
||||
|
||||
/**
|
||||
* 导出单元格字体颜色
|
||||
*/
|
||||
public IndexedColors color () default IndexedColors.BLACK;
|
||||
public IndexedColors color() default IndexedColors.BLACK;
|
||||
|
||||
/**
|
||||
* 导出字段对齐方式
|
||||
*/
|
||||
public HorizontalAlignment align () default HorizontalAlignment.CENTER;
|
||||
public HorizontalAlignment align() default HorizontalAlignment.CENTER;
|
||||
|
||||
/**
|
||||
* 自定义数据处理器
|
||||
*/
|
||||
public Class<?> handler () default ExcelHandlerAdapter.class;
|
||||
public Class<?> handler() default ExcelHandlerAdapter.class;
|
||||
|
||||
/**
|
||||
* 自定义数据处理器参数
|
||||
*/
|
||||
public String[] args () default {};
|
||||
public String[] args() default {};
|
||||
|
||||
/**
|
||||
* 字段类型(0:导出导入;1:仅导出;2:仅导入)
|
||||
*/
|
||||
Type type () default Type.ALL;
|
||||
Type type() default Type.ALL;
|
||||
|
||||
public enum Type {
|
||||
ALL(0), EXPORT(1), IMPORT(2);
|
||||
|
|
|
@ -13,5 +13,5 @@ import java.lang.annotation.Target;
|
|||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Excels {
|
||||
Excel[] value ();
|
||||
Excel[] value();
|
||||
}
|
||||
|
|
|
@ -45,4 +45,9 @@ public class SecurityConstants {
|
|||
* 角色权限
|
||||
*/
|
||||
public static final String ROLE_PERMISSION = "role_permission";
|
||||
|
||||
/**
|
||||
* SaaS标识
|
||||
*/
|
||||
public static final String SAAS_KEY = "ent-code";
|
||||
}
|
||||
|
|
|
@ -162,4 +162,13 @@ public class JwtUtils {
|
|||
public static String getValue (Claims claims, String key) {
|
||||
return Convert.toStr(claims.get(key), "");
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据身份信息获取SaaS标识
|
||||
* @param claims 身份信息
|
||||
* @return Saas标识
|
||||
*/
|
||||
public static String getSaaSKey (Claims claims) {
|
||||
return getValue(claims, SecurityConstants.SAAS_KEY);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ public final class SpringUtils implements BeanFactoryPostProcessor {
|
|||
*
|
||||
* @return Object 一个以所给名字注册的bean的实例
|
||||
*
|
||||
* @throws org.springframework.beans.BeansException
|
||||
* @throws BeansException
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T getBean (String name) throws BeansException {
|
||||
|
@ -40,7 +40,7 @@ public final class SpringUtils implements BeanFactoryPostProcessor {
|
|||
*
|
||||
* @return
|
||||
*
|
||||
* @throws org.springframework.beans.BeansException
|
||||
* @throws BeansException
|
||||
*/
|
||||
public static <T> T getBean (Class<T> clz) throws BeansException {
|
||||
T result = (T) beanFactory.getBean(clz);
|
||||
|
@ -65,7 +65,7 @@ public final class SpringUtils implements BeanFactoryPostProcessor {
|
|||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @throws org.springframework.beans.factory.NoSuchBeanDefinitionException
|
||||
* @throws NoSuchBeanDefinitionException
|
||||
*/
|
||||
public static boolean isSingleton (String name) throws NoSuchBeanDefinitionException {
|
||||
return beanFactory.isSingleton(name);
|
||||
|
@ -76,7 +76,7 @@ public final class SpringUtils implements BeanFactoryPostProcessor {
|
|||
*
|
||||
* @return Class 注册对象的类型
|
||||
*
|
||||
* @throws org.springframework.beans.factory.NoSuchBeanDefinitionException
|
||||
* @throws NoSuchBeanDefinitionException
|
||||
*/
|
||||
public static Class<?> getType (String name) throws NoSuchBeanDefinitionException {
|
||||
return beanFactory.getType(name);
|
||||
|
@ -89,7 +89,7 @@ public final class SpringUtils implements BeanFactoryPostProcessor {
|
|||
*
|
||||
* @return
|
||||
*
|
||||
* @throws org.springframework.beans.factory.NoSuchBeanDefinitionException
|
||||
* @throws NoSuchBeanDefinitionException
|
||||
*/
|
||||
public static String[] getAliases (String name) throws NoSuchBeanDefinitionException {
|
||||
return beanFactory.getAliases(name);
|
||||
|
|
|
@ -17,11 +17,11 @@ import java.lang.annotation.Target;
|
|||
@Target(value = {ElementType.METHOD, ElementType.FIELD, ElementType.CONSTRUCTOR, ElementType.PARAMETER})
|
||||
@Constraint(validatedBy = {XssValidator.class})
|
||||
public @interface Xss {
|
||||
String message ()
|
||||
String message()
|
||||
|
||||
default "不允许任何脚本运行";
|
||||
|
||||
Class<?>[] groups () default {};
|
||||
Class<?>[] groups() default {};
|
||||
|
||||
Class<? extends Payload>[] payload () default {};
|
||||
Class<? extends Payload>[] payload() default {};
|
||||
}
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>cloud-common-datascope</artifactId>
|
||||
|
||||
<description>
|
||||
cloud-common-datascope权限范围
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- MuYu Common Security -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-security</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,28 @@
|
|||
package com.muyu.common.datascope.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 数据权限过滤注解
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface DataScope {
|
||||
/**
|
||||
* 部门表的别名
|
||||
*/
|
||||
public String deptAlias () default "";
|
||||
|
||||
/**
|
||||
* 用户表的别名
|
||||
*/
|
||||
public String userAlias () default "";
|
||||
|
||||
/**
|
||||
* 权限字符(用于多个角色匹配符合要求的权限)默认根据权限注解@RequiresPermissions获取,多个权限用逗号分隔开来
|
||||
*/
|
||||
public String permission () default "";
|
||||
}
|
|
@ -0,0 +1,149 @@
|
|||
package com.muyu.common.datascope.aspect;
|
||||
|
||||
import com.muyu.common.core.context.SecurityContextHolder;
|
||||
import com.muyu.common.core.text.Convert;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.common.datascope.annotation.DataScope;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.common.system.domain.SysRole;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import com.muyu.common.system.domain.LoginUser;
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Before;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据过滤处理
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
@Aspect
|
||||
@Component
|
||||
public class DataScopeAspect {
|
||||
/**
|
||||
* 全部数据权限
|
||||
*/
|
||||
public static final String DATA_SCOPE_ALL = "1";
|
||||
|
||||
/**
|
||||
* 自定数据权限
|
||||
*/
|
||||
public static final String DATA_SCOPE_CUSTOM = "2";
|
||||
|
||||
/**
|
||||
* 部门数据权限
|
||||
*/
|
||||
public static final String DATA_SCOPE_DEPT = "3";
|
||||
|
||||
/**
|
||||
* 部门及以下数据权限
|
||||
*/
|
||||
public static final String DATA_SCOPE_DEPT_AND_CHILD = "4";
|
||||
|
||||
/**
|
||||
* 仅本人数据权限
|
||||
*/
|
||||
public static final String DATA_SCOPE_SELF = "5";
|
||||
|
||||
/**
|
||||
* 数据权限过滤关键字
|
||||
*/
|
||||
public static final String DATA_SCOPE = "dataScope";
|
||||
|
||||
/**
|
||||
* 数据范围过滤
|
||||
*
|
||||
* @param joinPoint 切点
|
||||
* @param user 用户
|
||||
* @param deptAlias 部门别名
|
||||
* @param userAlias 用户别名
|
||||
* @param permission 权限字符
|
||||
*/
|
||||
public static void dataScopeFilter (JoinPoint joinPoint, SysUser user, String deptAlias, String userAlias, String permission) {
|
||||
StringBuilder sqlString = new StringBuilder();
|
||||
List<String> conditions = new ArrayList<String>();
|
||||
|
||||
for (SysRole role : user.getRoles()) {
|
||||
String dataScope = role.getDataScope();
|
||||
if (!DATA_SCOPE_CUSTOM.equals(dataScope) && conditions.contains(dataScope)) {
|
||||
continue;
|
||||
}
|
||||
if (StringUtils.isNotEmpty(permission) && StringUtils.isNotEmpty(role.getPermissions())
|
||||
&& !StringUtils.containsAny(role.getPermissions(), Convert.toStrArray(permission))) {
|
||||
continue;
|
||||
}
|
||||
if (DATA_SCOPE_ALL.equals(dataScope)) {
|
||||
sqlString = new StringBuilder();
|
||||
conditions.add(dataScope);
|
||||
break;
|
||||
} else if (DATA_SCOPE_CUSTOM.equals(dataScope)) {
|
||||
sqlString.append(StringUtils.format(
|
||||
" OR {}.dept_id IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = {} ) ", deptAlias,
|
||||
role.getRoleId()));
|
||||
} else if (DATA_SCOPE_DEPT.equals(dataScope)) {
|
||||
sqlString.append(StringUtils.format(" OR {}.dept_id = {} ", deptAlias, user.getDeptId()));
|
||||
} else if (DATA_SCOPE_DEPT_AND_CHILD.equals(dataScope)) {
|
||||
sqlString.append(StringUtils.format(
|
||||
" OR {}.dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = {} or find_in_set( {} , ancestors ) )",
|
||||
deptAlias, user.getDeptId(), user.getDeptId()));
|
||||
} else if (DATA_SCOPE_SELF.equals(dataScope)) {
|
||||
if (StringUtils.isNotBlank(userAlias)) {
|
||||
sqlString.append(StringUtils.format(" OR {}.user_id = {} ", userAlias, user.getUserId()));
|
||||
} else {
|
||||
// 数据权限为仅本人且没有userAlias别名不查询任何数据
|
||||
sqlString.append(StringUtils.format(" OR {}.dept_id = 0 ", deptAlias));
|
||||
}
|
||||
}
|
||||
conditions.add(dataScope);
|
||||
}
|
||||
|
||||
// 多角色情况下,所有角色都不包含传递过来的权限字符,这个时候sqlString也会为空,所以要限制一下,不查询任何数据
|
||||
if (StringUtils.isEmpty(conditions)) {
|
||||
sqlString.append(StringUtils.format(" OR {}.dept_id = 0 ", deptAlias));
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(sqlString.toString())) {
|
||||
Object params = joinPoint.getArgs()[0];
|
||||
if (StringUtils.isNotNull(params) && params instanceof BaseEntity) {
|
||||
BaseEntity baseEntity = (BaseEntity) params;
|
||||
baseEntity.getParams().put(DATA_SCOPE, " AND (" + sqlString.substring(4) + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Before("@annotation(controllerDataScope)")
|
||||
public void doBefore (JoinPoint point, DataScope controllerDataScope) throws Throwable {
|
||||
clearDataScope(point);
|
||||
handleDataScope(point, controllerDataScope);
|
||||
}
|
||||
|
||||
protected void handleDataScope (final JoinPoint joinPoint, DataScope controllerDataScope) {
|
||||
// 获取当前的用户
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (StringUtils.isNotNull(loginUser)) {
|
||||
SysUser currentUser = loginUser.getSysUser();
|
||||
// 如果是超级管理员,则不过滤数据
|
||||
if (StringUtils.isNotNull(currentUser) && !currentUser.isAdmin()) {
|
||||
String permission = StringUtils.defaultIfEmpty(controllerDataScope.permission(), SecurityContextHolder.getPermission());
|
||||
dataScopeFilter(joinPoint, currentUser, controllerDataScope.deptAlias(),
|
||||
controllerDataScope.userAlias(), permission);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼接权限sql前先清空params.dataScope参数防止注入
|
||||
*/
|
||||
private void clearDataScope (final JoinPoint joinPoint) {
|
||||
Object params = joinPoint.getArgs()[0];
|
||||
if (StringUtils.isNotNull(params) && params instanceof BaseEntity) {
|
||||
BaseEntity baseEntity = (BaseEntity) params;
|
||||
baseEntity.getParams().put(DATA_SCOPE, "");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
com.muyu.common.datascope.aspect.DataScopeAspect
|
|
@ -11,11 +11,10 @@ import com.muyu.cloud.common.saas.domain.model.EntInfo;
|
|||
import com.muyu.cloud.common.saas.exception.SaaSException;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.SpringUtils;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import com.muyu.common.system.remote.RemoteUserService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.mybatis.spring.SqlSessionFactoryBean;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
|
@ -78,7 +77,7 @@ public class ManyDataSource implements ApplicationRunner {
|
|||
)
|
||||
.toList();
|
||||
}else {
|
||||
log.error("远调数据源错误,远调数据为:{}", JSON.toJSONString(data));
|
||||
log.error("远调数据源异常,异常信息:{}", JSON.toJSONString(entListResult.getMsg()));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -91,29 +90,21 @@ public class ManyDataSource implements ApplicationRunner {
|
|||
*/
|
||||
@Bean
|
||||
public DynamicDataSource dynamicDataSource(DruidDataSourceFactory druidDataSourceFactory) {
|
||||
List<DataSourceInfo> sourceInfoList = dataSourceInfoList().stream()
|
||||
List<EntInfo> entInfoList = dataSourceInfoList();
|
||||
if(StringUtils.isEmpty(entInfoList)){
|
||||
throw new SaaSException("数据源信息列表为空或为null");
|
||||
}
|
||||
Map<Object, Object> dataSourceMap = dataSourceInfoList().stream()
|
||||
.map(entInfo -> DataSourceInfo.hostAndPortBuild(
|
||||
entInfo.getEntCode(),
|
||||
entInfo.getIp(),
|
||||
entInfo.getPort()
|
||||
)
|
||||
).toList();
|
||||
|
||||
Map<Object, Object> dataSourceMap = sourceInfoList.stream().collect(Collectors.toMap(
|
||||
)
|
||||
.collect(Collectors.toMap(
|
||||
dataSourceInfo -> dataSourceInfo.getKey(),
|
||||
dataSourceInfo -> druidDataSourceFactory.create(dataSourceInfo)
|
||||
));
|
||||
// Map<Object, Object> dataSourceMap = dataSourceInfoList().stream()
|
||||
// .map(entInfo -> DataSourceInfo.hostAndPortBuild(
|
||||
// entInfo.getEntCode(),
|
||||
// entInfo.getIp(),
|
||||
// entInfo.getPort()
|
||||
// )
|
||||
// )
|
||||
// .collect(Collectors.toMap(
|
||||
// dataSourceInfo -> dataSourceInfo.getKey(),
|
||||
// dataSourceInfo -> druidDataSourceFactory.create(dataSourceInfo)
|
||||
// ));
|
||||
|
||||
//设置动态数据源
|
||||
DynamicDataSource dynamicDataSource = new DynamicDataSource();
|
||||
|
@ -121,19 +112,4 @@ public class ManyDataSource implements ApplicationRunner {
|
|||
dynamicDataSource.setDefineTargetDataSources(dataSourceMap);
|
||||
return dynamicDataSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建 SqlSessionFactory Bean,用于 MyBatis 数据库操作。
|
||||
* 该方法接收动态数据源并配置 SqlSessionFactory,返回
|
||||
* 用于与数据库交互的 SqlSessionFactory 实例。
|
||||
* @param dataSource 动态数据源
|
||||
* @return 配置好的 SqlSessionFactory 实例
|
||||
* @throws Exception 可能抛出的异常
|
||||
*/
|
||||
@Bean
|
||||
public SqlSessionFactory sqlSessionFactory(DynamicDataSource dataSource) throws Exception {
|
||||
SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
|
||||
sessionFactory.setDataSource(dataSource);
|
||||
return sessionFactory.getObject();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,6 +55,7 @@ public class TokenService {
|
|||
claimsMap.put(SecurityConstants.USER_KEY, token);
|
||||
claimsMap.put(SecurityConstants.DETAILS_USER_ID, userId);
|
||||
claimsMap.put(SecurityConstants.DETAILS_USERNAME, userName);
|
||||
claimsMap.put(SecurityConstants.SAAS_KEY, loginUser.getSysUser().getDatabaseName());
|
||||
|
||||
// 接口返回信息
|
||||
Map<String, Object> rspMap = new HashMap<String, Object>();
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
<module>cloud-common-log</module>
|
||||
<module>cloud-common-core</module>
|
||||
<module>cloud-common-redis</module>
|
||||
<module>cloud-common-saas</module>
|
||||
<module>cloud-common-seata</module>
|
||||
<module>cloud-common-api-doc</module>
|
||||
<module>cloud-common-security</module>
|
||||
|
@ -20,7 +21,6 @@
|
|||
<module>cloud-common-system</module>
|
||||
<module>cloud-common-xxl</module>
|
||||
<module>cloud-common-rabbit</module>
|
||||
<module>cloud-common-saas</module>
|
||||
</modules>
|
||||
|
||||
<artifactId>cloud-common</artifactId>
|
||||
|
|
|
@ -56,9 +56,9 @@ public class AuthFilter implements GlobalFilter, Ordered {
|
|||
if (claims == null) {
|
||||
return unauthorizedResponse(exchange, "令牌已过期或验证不正确!");
|
||||
}
|
||||
String userkey = JwtUtils.getUserKey(claims);
|
||||
boolean islogin = redisService.hasKey(getTokenKey(userkey));
|
||||
if (!islogin) {
|
||||
String userKey = JwtUtils.getUserKey(claims);
|
||||
boolean isLogin = redisService.hasKey(getTokenKey(userKey));
|
||||
if (!isLogin) {
|
||||
return unauthorizedResponse(exchange, "登录状态已过期");
|
||||
}
|
||||
String userid = JwtUtils.getUserId(claims);
|
||||
|
@ -66,11 +66,14 @@ public class AuthFilter implements GlobalFilter, Ordered {
|
|||
if (StringUtils.isEmpty(userid) || StringUtils.isEmpty(username)) {
|
||||
return unauthorizedResponse(exchange, "令牌验证失败");
|
||||
}
|
||||
String saaSKey = JwtUtils.getSaaSKey(claims);
|
||||
|
||||
// 设置用户信息到请求
|
||||
addHeader(mutate, SecurityConstants.USER_KEY, userkey);
|
||||
addHeader(mutate, SecurityConstants.USER_KEY, userKey);
|
||||
addHeader(mutate, SecurityConstants.DETAILS_USER_ID, userid);
|
||||
addHeader(mutate, SecurityConstants.DETAILS_USERNAME, username);
|
||||
addHeader(mutate, SecurityConstants.SAAS_KEY, saaSKey);
|
||||
|
||||
// 内部请求来源参数清除
|
||||
removeHeader(mutate, SecurityConstants.FROM_SOURCE);
|
||||
return chain.filter(exchange.mutate().request(mutate.build()).build());
|
||||
|
|
|
@ -7,7 +7,7 @@ nacos:
|
|||
addr: 106.15.136.7:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: lyb
|
||||
namespace: xzr
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
package com.muyu;
|
||||
|
||||
import com.alibaba.druid.spring.boot3.autoconfigure.DruidDataSourceAutoConfigure;
|
||||
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceAutoConfiguration;
|
||||
import com.muyu.common.security.annotation.EnableCustomConfig;
|
||||
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
|
||||
/**
|
||||
* 系统模块
|
||||
|
@ -11,7 +14,6 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||
* @author muyu
|
||||
*/
|
||||
@EnableCustomConfig
|
||||
//@EnableCustomSwagger2
|
||||
@EnableMyFeignClients
|
||||
@SpringBootApplication
|
||||
public class CloudCarApplication {
|
||||
|
|
|
@ -78,8 +78,6 @@ public class SysCarController extends BaseController {
|
|||
// 随机生成VIN码
|
||||
String key2 = RandomUtil.randomNumbers(17);
|
||||
carVO.setCarVin(key2);
|
||||
//
|
||||
carVO.setUserId(SecurityUtils.getUserId());
|
||||
sysCarService.insertCar(carVO);
|
||||
return Result.success("车辆添加成功");
|
||||
}
|
||||
|
@ -92,6 +90,8 @@ public class SysCarController extends BaseController {
|
|||
*/
|
||||
@PostMapping("updataCar")
|
||||
public Result updataCar(@RequestBody CarVO carVO){
|
||||
//
|
||||
carVO.setUserId(SecurityUtils.getUserId());
|
||||
sysCarService.updateById(carVO);
|
||||
return Result.success("车辆修改成功");
|
||||
}
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
package com.muyu.car.controller;
|
||||
|
||||
import com.muyu.car.domain.CarMessage;
|
||||
import com.muyu.car.service.SysCarMessageService;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/message") // 报文
|
||||
@Tag(name = "报文",description = "报文模块")
|
||||
public class SysCarMessageController extends BaseController {
|
||||
@Autowired
|
||||
private SysCarMessageService sysCarMessageService;
|
||||
|
||||
/**
|
||||
* 查询所有报文信息
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("selectMessageShow")
|
||||
public List<CarMessage> selectMessageShow(@RequestParam("templateId") Long templateId){
|
||||
return sysCarMessageService.selectMessageShow(templateId);
|
||||
}
|
||||
/**
|
||||
* 通过id查询报文信息
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("selectMessageByMessageId")
|
||||
public CarMessage selectMessageByMessageId(@RequestParam("messageId") Long messageId){
|
||||
return sysCarMessageService.selectMessageByMessageId(messageId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加报文信息
|
||||
* @return carMessage
|
||||
*/
|
||||
@PostMapping("insertMessage")
|
||||
public Result insertMessage(@RequestBody CarMessage carMessage){
|
||||
sysCarMessageService.save(carMessage);
|
||||
return Result.success("添加成功");
|
||||
}
|
||||
/**
|
||||
* 修改报文信息
|
||||
* @return carMessage
|
||||
*/
|
||||
@PostMapping("updataMessage")
|
||||
public Result updataMessage(@RequestBody CarMessage carMessage){
|
||||
sysCarMessageService.updateById(carMessage);
|
||||
return Result.success("修改成功");
|
||||
}
|
||||
/**
|
||||
* 删除报文信息
|
||||
* @return carMessage
|
||||
*/
|
||||
@PostMapping("deleteMessage")
|
||||
public Result deleteMessage(@RequestParam("ids") List<Long> ids){
|
||||
sysCarMessageService.removeBatchByIds(ids);
|
||||
return Result.success("删除成功");
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package com.muyu.car.controller;
|
||||
|
||||
import com.muyu.car.domain.CarMessage;
|
||||
import com.muyu.car.domain.CarTemplate;
|
||||
import com.muyu.car.service.SysCarMessageService;
|
||||
import com.muyu.car.service.SysCarTemplateService;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/template") // 报文
|
||||
@Tag(name = "模版模块",description = "报文模版模块")
|
||||
public class SysCarTemplateController extends BaseController {
|
||||
@Autowired
|
||||
private SysCarTemplateService sysCarTemplateService;
|
||||
|
||||
/**
|
||||
* 查询所有模版信息
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("selectTemplateShow")
|
||||
public List<CarTemplate> selectTemplateShow(){
|
||||
return sysCarTemplateService.selectTemplateShow();
|
||||
}
|
||||
/**
|
||||
* 通过id查询模版信息
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("selectTemplateByTemplateId")
|
||||
public CarTemplate selectTemplateByTemplateId(@RequestParam("templateId") Long templateId){
|
||||
return sysCarTemplateService.selectTemplateByTemplateId(templateId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加模版信息
|
||||
* @return carMessage
|
||||
*/
|
||||
@PostMapping("insertTemplate")
|
||||
public Result insertTemplate(@RequestBody CarTemplate carTemplate){
|
||||
sysCarTemplateService.save(carTemplate);
|
||||
return Result.success("添加成功");
|
||||
}
|
||||
/**
|
||||
* 修改模版信息
|
||||
* @return carMessage
|
||||
*/
|
||||
@PostMapping("updataTemplate")
|
||||
public Result updataTemplate(@RequestBody CarTemplate carTemplate){
|
||||
sysCarTemplateService.updateById(carTemplate);
|
||||
return Result.success("修改成功");
|
||||
}
|
||||
/**
|
||||
* 删除模版信息
|
||||
* @return carMessage
|
||||
*/
|
||||
@PostMapping("deleteTemplate")
|
||||
public Result deleteTemplate(@RequestParam("ids") List<Long> ids){
|
||||
sysCarTemplateService.removeBatchByIds(ids);
|
||||
return Result.success("删除成功");
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -19,10 +19,6 @@ public class CarMessage {
|
|||
*/
|
||||
@TableId(value = "message_id",type = IdType.AUTO)
|
||||
private Long messageId;
|
||||
/**
|
||||
* 车辆编码
|
||||
*/
|
||||
private String messageCode;
|
||||
/**
|
||||
* 车辆报文类别
|
||||
*/
|
||||
|
@ -35,22 +31,7 @@ public class CarMessage {
|
|||
* 结束位下标
|
||||
*/
|
||||
private Integer messageEndIndex;
|
||||
/**
|
||||
* 数据类型
|
||||
*/
|
||||
private String messageDataType;
|
||||
/**
|
||||
* 固定值
|
||||
*/
|
||||
private double fixedValue;
|
||||
/**
|
||||
* 最小值
|
||||
*/
|
||||
private double minimumValue;
|
||||
/**
|
||||
* 最大值
|
||||
*/
|
||||
private double maximumValue;
|
||||
|
||||
/**
|
||||
* 模版id
|
||||
*/
|
||||
|
|
|
@ -18,7 +18,7 @@ public class CarMessageType {
|
|||
* 报文
|
||||
*/
|
||||
@TableId(value = "message_type_id",type = IdType.AUTO)
|
||||
private Integer messageTypeId;
|
||||
private Long messageTypeId;
|
||||
/**
|
||||
* 报文编码
|
||||
*/
|
||||
|
|
|
@ -19,7 +19,7 @@ public class CarTemplate {
|
|||
* 报文模版表
|
||||
*/
|
||||
@TableId(value = "template_id",type = IdType.AUTO)
|
||||
private Integer templateId;
|
||||
private Long templateId;
|
||||
/**
|
||||
* 报文模版名称
|
||||
*/
|
||||
|
|
|
@ -39,10 +39,6 @@ public class SysCar {
|
|||
* VIN码
|
||||
*/
|
||||
private String carVin;
|
||||
/**
|
||||
* 驾车人
|
||||
*/
|
||||
private Long carUserId;
|
||||
/**
|
||||
* 车主
|
||||
*/
|
||||
|
|
|
@ -50,4 +50,11 @@ public class CarDTO {
|
|||
* 在线状态 1.无信号 2.行驶中 3.已停止
|
||||
*/
|
||||
private Integer carStatus;
|
||||
|
||||
|
||||
/**
|
||||
* 企业名称
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String companyName;
|
||||
}
|
||||
|
|
|
@ -40,10 +40,6 @@ public class CarVO {
|
|||
* VIN码
|
||||
*/
|
||||
private String carVin;
|
||||
/**
|
||||
* 驾车人
|
||||
*/
|
||||
private Long carUserId;
|
||||
/**
|
||||
* 车主
|
||||
*/
|
||||
|
@ -120,4 +116,10 @@ public class CarVO {
|
|||
@TableField(exist = false)
|
||||
private Integer gearType;
|
||||
|
||||
/**
|
||||
* 企业名称
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String companyName;
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package com.muyu.car.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.car.domain.CarMessage;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface SysCarMessageMapper extends BaseMapper<CarMessage> {
|
||||
/**
|
||||
* 查询所有报文信息
|
||||
* @param templateId
|
||||
* @return
|
||||
*/
|
||||
List<CarMessage> selectMessageShow(Long templateId);
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.muyu.car.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.car.domain.CarMessage;
|
||||
import com.muyu.car.domain.CarTemplate;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface SysCarTemplateMapper extends BaseMapper<CarTemplate> {
|
||||
/**
|
||||
* 查询所有报文信息
|
||||
* @return
|
||||
*/
|
||||
List<CarTemplate> selectTemplateShow();
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.muyu.car.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.car.domain.CarMessage;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SysCarMessageService extends IService<CarMessage> {
|
||||
/**
|
||||
* 查询所有报文信息
|
||||
* @param templateId
|
||||
* @return
|
||||
*/
|
||||
List<CarMessage> selectMessageShow(Long templateId);
|
||||
|
||||
/**
|
||||
* 通过id查询报文信息
|
||||
* @param messageId
|
||||
* @return
|
||||
*/
|
||||
CarMessage selectMessageByMessageId(Long messageId);
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.muyu.car.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.car.domain.CarMessage;
|
||||
import com.muyu.car.domain.CarTemplate;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SysCarTemplateService extends IService<CarTemplate> {
|
||||
/**
|
||||
* 查询所有报文信息
|
||||
* @return
|
||||
*/
|
||||
List<CarTemplate> selectTemplateShow();
|
||||
|
||||
/**
|
||||
* 通过id查询报文信息
|
||||
* @param messageId
|
||||
* @return
|
||||
*/
|
||||
CarTemplate selectTemplateByTemplateId(Long messageId);
|
||||
}
|
|
@ -2,18 +2,12 @@ package com.muyu.car.service.impl;
|
|||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.car.domain.CarCompany;
|
||||
import com.muyu.car.domain.dto.CarDTO;
|
||||
import com.muyu.car.domain.vo.CarVO;
|
||||
import com.muyu.car.mapper.SysCarCompanyMapper;
|
||||
import com.muyu.car.mapper.SysCarMapper;
|
||||
import com.muyu.car.service.SysCarCompanyService;
|
||||
import com.muyu.car.service.SysCarService;
|
||||
import com.muyu.common.redis.service.RedisService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zmw
|
||||
* @description: 配置plus业务实现层
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
package com.muyu.car.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.car.domain.CarMessage;
|
||||
import com.muyu.car.mapper.SysCarMessageMapper;
|
||||
import com.muyu.car.service.SysCarMessageService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class SysCarMessageServiceImpl extends ServiceImpl<SysCarMessageMapper, CarMessage> implements SysCarMessageService {
|
||||
|
||||
@Autowired
|
||||
private SysCarMessageMapper sysCarMessageMapper;
|
||||
/**
|
||||
* 查询所有报文信息
|
||||
* @param templateId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<CarMessage> selectMessageShow(Long templateId) {
|
||||
return sysCarMessageMapper.selectMessageShow(templateId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询报文信息
|
||||
* @param messageId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public CarMessage selectMessageByMessageId(Long messageId) {
|
||||
return sysCarMessageMapper.selectById(messageId);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package com.muyu.car.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.car.domain.CarMessage;
|
||||
import com.muyu.car.domain.CarTemplate;
|
||||
import com.muyu.car.mapper.SysCarMessageMapper;
|
||||
import com.muyu.car.mapper.SysCarTemplateMapper;
|
||||
import com.muyu.car.service.SysCarMessageService;
|
||||
import com.muyu.car.service.SysCarTemplateService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class SysCarTemplateServiceImpl extends ServiceImpl<SysCarTemplateMapper, CarTemplate> implements SysCarTemplateService {
|
||||
|
||||
@Autowired
|
||||
private SysCarTemplateMapper sysCarTemplateMapper;
|
||||
/**
|
||||
* 查询所有报文信息
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<CarTemplate> selectTemplateShow() {
|
||||
return sysCarTemplateMapper.selectTemplateShow();
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询报文信息
|
||||
* @param templateId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public CarTemplate selectTemplateByTemplateId(Long templateId) {
|
||||
return sysCarTemplateMapper.selectById(templateId);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
<?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.muyu.car.mapper.SysCarMessageMapper">
|
||||
|
||||
<!-- 查询所有报文信息 -->
|
||||
|
||||
|
||||
<!-- 查询所有报文信息 -->
|
||||
<select id="selectMessageShow" resultType="com.muyu.car.domain.CarMessage">
|
||||
SELECT
|
||||
tcm.*
|
||||
FROM
|
||||
`t_car_message` tcm
|
||||
WHERE
|
||||
tcm.template_id = #{templateId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,13 @@
|
|||
<?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.muyu.car.mapper.SysCarTemplateMapper">
|
||||
|
||||
<!-- 查询所有报文信息 -->
|
||||
|
||||
|
||||
<select id="selectTemplateShow" resultType="com.muyu.car.domain.CarTemplate">
|
||||
select * from `t_template`
|
||||
</select>
|
||||
</mapper>
|
|
@ -72,6 +72,12 @@
|
|||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-api-doc</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SaaS-->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-saas</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -1,14 +1,21 @@
|
|||
package com.muyu;
|
||||
|
||||
|
||||
import com.alibaba.druid.spring.boot3.autoconfigure.DruidDataSourceAutoConfigure;
|
||||
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceAutoConfiguration;
|
||||
import com.muyu.common.security.annotation.EnableCustomConfig;
|
||||
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
|
||||
@EnableCustomConfig
|
||||
@EnableMyFeignClients
|
||||
@SpringBootApplication
|
||||
@SpringBootApplication(exclude = {
|
||||
DataSourceAutoConfiguration.class,
|
||||
DruidDataSourceAutoConfigure.class,
|
||||
DynamicDataSourceAutoConfiguration.class
|
||||
})
|
||||
public class CloudFaultApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(CloudFaultApplication.class,args);
|
||||
|
|
|
@ -7,7 +7,7 @@ nacos:
|
|||
addr: 106.15.136.7:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: crj
|
||||
namespace: xzr
|
||||
|
||||
spring:
|
||||
application:
|
||||
|
|
|
@ -7,7 +7,7 @@ nacos:
|
|||
addr: 106.15.136.7:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: lyb
|
||||
namespace: xzr
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
|
|
|
@ -7,7 +7,7 @@ nacos:
|
|||
addr: 106.15.136.7:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: lyb
|
||||
namespace: xzr
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
|
|
|
@ -7,9 +7,15 @@ nacos:
|
|||
addr: 106.15.136.7:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: lyb
|
||||
namespace: xzr
|
||||
|
||||
spring:
|
||||
amqp:
|
||||
deserialization:
|
||||
trust:
|
||||
all: true
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
application:
|
||||
# 应用名称
|
||||
name: cloud-system
|
||||
|
@ -44,6 +50,10 @@ spring:
|
|||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
# 系统环境Config共享配置
|
||||
- application-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
# xxl-job 配置文件
|
||||
- application-xxl-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
# rabbit 配置文件
|
||||
- application-rabbit-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
logging:
|
||||
level:
|
||||
com.muyu.system.mapper: DEBUG
|
||||
|
|
|
@ -7,7 +7,7 @@ nacos:
|
|||
addr: 106.15.136.7:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: lyb
|
||||
namespace: xzr
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
|
|
|
@ -73,6 +73,12 @@
|
|||
<artifactId>cloud-common-api-doc</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<version>3.3.2</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
package com.muyu.warn.controller;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.warn.domain.Car;
|
||||
import com.muyu.warn.service.CarService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @ClassName CarController
|
||||
* @Description 描述
|
||||
* @Author YiBo.Liu
|
||||
* @Date 2024/9/23 22:42
|
||||
*/
|
||||
@RequestMapping("/car")
|
||||
@RestController
|
||||
public class CarController {
|
||||
|
||||
@Autowired
|
||||
private CarService carService;
|
||||
|
||||
/**
|
||||
* 根据车辆vin码
|
||||
* @param vin
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/ByVin")
|
||||
public Result<Car> findByVin(@RequestParam("vin") String vin) {
|
||||
Car car = carService.findByVin(vin);
|
||||
return Result.success(car);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -3,6 +3,7 @@ package com.muyu.warn.controller;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.muyu.warn.domain.Resp.StrategyRespList;
|
||||
import com.muyu.warn.domain.Resp.WarnStrategyList;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import javax.annotation.Resource;
|
||||
|
@ -120,4 +121,15 @@ public class WarnStrategyController extends BaseController
|
|||
List<WarnStrategyList> list = warnStrategyService.strategyList(warnStrategy);
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 三表联查
|
||||
* @param warnStrategy
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/strategyList")
|
||||
public Result<List<StrategyRespList>> StrategyList(@RequestBody WarnStrategy warnStrategy){
|
||||
List<StrategyRespList> list = warnStrategyService.strategyRespList(warnStrategy);
|
||||
return Result.success(list);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,103 @@
|
|||
package com.muyu.warn.domain;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.annotation.security.DenyAll;
|
||||
|
||||
/**
|
||||
* @ClassName Car
|
||||
* @Description 描述
|
||||
* @Author YiBo.Liu
|
||||
* @Date 2024/9/23 22:42
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@Tag(name = "车辆表")
|
||||
public class Car {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String carId;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String carFrame;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String carCoed;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String carColor;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String carVin;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String userId;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String typeId;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String audditTime;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String licenseTime;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String insuranceTime;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String carStatus;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String createdTime;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String carGears;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String carModel;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String carBrand;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String carLastJoinTime;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String carLastOfflineTime;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String companyId;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String carType;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package com.muyu.warn.domain.Resp;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @ClassName StrategyRespList
|
||||
* @Description 描述
|
||||
* @Author YiBo.Liu
|
||||
* @Date 2024/9/23 14:39
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@Tag(name = "三表联查")
|
||||
public class StrategyRespList {
|
||||
|
||||
/** 策略id */
|
||||
@TableId( type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/** 车辆类型id */
|
||||
@Excel(name = "车辆类型id")
|
||||
private Long carTypeId;
|
||||
|
||||
/** 策略名称 */
|
||||
@Excel(name = "策略名称")
|
||||
private String strategyName;
|
||||
|
||||
/** 报文模版id */
|
||||
@Excel(name = "报文模版id")
|
||||
private Long templateId;
|
||||
|
||||
/** 车辆类型 */
|
||||
private String carTypeName;
|
||||
|
||||
/** 模板名称*/
|
||||
private String templateName;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.muyu.warn.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.warn.domain.Car;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@Mapper
|
||||
public interface CarMapper extends BaseMapper<Car> {
|
||||
Car findByVin(@Param("vin") String vin);
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package com.muyu.warn.mapper;
|
||||
|
||||
import com.muyu.warn.domain.Resp.StrategyRespList;
|
||||
import com.muyu.warn.domain.Resp.WarnStrategyList;
|
||||
import com.muyu.warn.domain.WarnStrategy;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
@ -17,4 +18,6 @@ import java.util.List;
|
|||
public interface WarnStrategyMapper extends BaseMapper<WarnStrategy>{
|
||||
|
||||
List<WarnStrategyList> strategyList(WarnStrategy warnStrategy);
|
||||
|
||||
List<StrategyRespList> strategyRespList(WarnStrategy warnStrategy);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package com.muyu.warn.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.warn.domain.Car;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public interface CarService extends IService<Car> {
|
||||
Car findByVin(String vin);
|
||||
|
||||
}
|
|
@ -2,6 +2,7 @@ package com.muyu.warn.service;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import com.muyu.warn.domain.Resp.StrategyRespList;
|
||||
import com.muyu.warn.domain.Resp.WarnStrategyList;
|
||||
import com.muyu.warn.domain.WarnStrategy;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
@ -37,6 +38,17 @@ public interface IWarnStrategyService extends IService<WarnStrategy> {
|
|||
Boolean checkIdUnique(WarnStrategy warnStrategy);
|
||||
|
||||
|
||||
/**
|
||||
* 双表联查
|
||||
* @param warnStrategy
|
||||
* @return
|
||||
*/
|
||||
List<WarnStrategyList> strategyList(WarnStrategy warnStrategy);
|
||||
|
||||
/**
|
||||
* 三表联查列表
|
||||
* @param warnStrategy
|
||||
* @return
|
||||
*/
|
||||
List<StrategyRespList> strategyRespList(WarnStrategy warnStrategy);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
package com.muyu.warn.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.warn.domain.Car;
|
||||
import com.muyu.warn.mapper.CarMapper;
|
||||
import com.muyu.warn.service.CarService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @ClassName CarServiceImpl
|
||||
* @Description 描述
|
||||
* @Author YiBo.Liu
|
||||
* @Date 2024/9/24 0:27
|
||||
*/
|
||||
@Service
|
||||
public class CarServiceImpl
|
||||
extends ServiceImpl<CarMapper, Car>
|
||||
implements CarService {
|
||||
|
||||
@Autowired
|
||||
private CarMapper carMapper;
|
||||
|
||||
/**
|
||||
* 通过车辆vin码查询车辆类型
|
||||
* @param vin
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Car findByVin(String vin) {
|
||||
return carMapper.findByVin(vin);
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@ package com.muyu.warn.service.impl;
|
|||
import java.util.List;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.warn.domain.Resp.StrategyRespList;
|
||||
import com.muyu.warn.domain.Resp.WarnStrategyList;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||
|
@ -85,4 +86,9 @@ public class WarnStrategyServiceImpl
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StrategyRespList> strategyRespList(WarnStrategy warnStrategy) {
|
||||
return warnStrategyMapper.strategyRespList(warnStrategy);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<?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.muyu.warn.mapper.CarMapper">
|
||||
|
||||
<select id="findByVin" resultType="com.muyu.warn.domain.Car">
|
||||
select * from t_car where car_vin = #{vin}
|
||||
</select>
|
||||
</mapper>
|
|
@ -23,4 +23,12 @@
|
|||
LEFT JOIN warn_rule r ON s.id = r.strategy_id
|
||||
LEFT JOIN t_message_type on r.msg_type_id = t_message_type.message_type_id
|
||||
</select>
|
||||
<select id="strategyRespList" resultType="com.muyu.warn.domain.Resp.StrategyRespList">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
warn_strategy s
|
||||
LEFT JOIN t_car_type c ON c.car_type_id = s.car_type_id
|
||||
LEFT JOIN t_template t ON t.template_id = s.template_id
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
Loading…
Reference in New Issue