parent
68f94b0f26
commit
dd30d17c40
|
@ -21,132 +21,132 @@ public @interface Excel {
|
||||||
/**
|
/**
|
||||||
* 导出时在excel中排序
|
* 导出时在excel中排序
|
||||||
*/
|
*/
|
||||||
public int sort () default Integer.MAX_VALUE;
|
public int sort() default Integer.MAX_VALUE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出到Excel中的名字.
|
* 导出到Excel中的名字.
|
||||||
*/
|
*/
|
||||||
public String name () default "";
|
public String name() default "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 日期格式, 如: yyyy-MM-dd
|
* 日期格式, 如: yyyy-MM-dd
|
||||||
*/
|
*/
|
||||||
public String dateFormat () default "";
|
public String dateFormat() default "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 读取内容转表达式 (如: 0=男,1=女,2=未知)
|
* 读取内容转表达式 (如: 0=男,1=女,2=未知)
|
||||||
*/
|
*/
|
||||||
public String readConverterExp () default "";
|
public String readConverterExp() default "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分隔符,读取字符串组内容
|
* 分隔符,读取字符串组内容
|
||||||
*/
|
*/
|
||||||
public String separator () default ",";
|
public String separator() default ",";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BigDecimal 精度 默认:-1(默认不开启BigDecimal格式化)
|
* BigDecimal 精度 默认:-1(默认不开启BigDecimal格式化)
|
||||||
*/
|
*/
|
||||||
public int scale () default -1;
|
public int scale() default -1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BigDecimal 舍入规则 默认:BigDecimal.ROUND_HALF_EVEN
|
* BigDecimal 舍入规则 默认:BigDecimal.ROUND_HALF_EVEN
|
||||||
*/
|
*/
|
||||||
public int roundingMode () default BigDecimal.ROUND_HALF_EVEN;
|
public int roundingMode() default BigDecimal.ROUND_HALF_EVEN;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出时在excel中每个列的高度
|
* 导出时在excel中每个列的高度
|
||||||
*/
|
*/
|
||||||
public double height () default 14;
|
public double height() default 14;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出时在excel中每个列的宽度
|
* 导出时在excel中每个列的宽度
|
||||||
*/
|
*/
|
||||||
public double width () default 16;
|
public double width() default 16;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文字后缀,如% 90 变成90%
|
* 文字后缀,如% 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集合单元格)
|
* 是否需要纵向合并单元格,应对需求:含有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字符串)
|
* 导出类型(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:仅导入)
|
* 字段类型(0:导出导入;1:仅导出;2:仅导入)
|
||||||
*/
|
*/
|
||||||
Type type () default Type.ALL;
|
Type type() default Type.ALL;
|
||||||
|
|
||||||
public enum Type {
|
public enum Type {
|
||||||
ALL(0), EXPORT(1), IMPORT(2);
|
ALL(0), EXPORT(1), IMPORT(2);
|
||||||
|
|
|
@ -13,5 +13,5 @@ import java.lang.annotation.Target;
|
||||||
@Target(ElementType.FIELD)
|
@Target(ElementType.FIELD)
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
public @interface Excels {
|
public @interface Excels {
|
||||||
Excel[] value ();
|
Excel[] value();
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ public final class SpringUtils implements BeanFactoryPostProcessor {
|
||||||
*
|
*
|
||||||
* @return Object 一个以所给名字注册的bean的实例
|
* @return Object 一个以所给名字注册的bean的实例
|
||||||
*
|
*
|
||||||
* @throws org.springframework.beans.BeansException
|
* @throws BeansException
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <T> T getBean (String name) throws BeansException {
|
public static <T> T getBean (String name) throws BeansException {
|
||||||
|
@ -40,7 +40,7 @@ public final class SpringUtils implements BeanFactoryPostProcessor {
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*
|
*
|
||||||
* @throws org.springframework.beans.BeansException
|
* @throws BeansException
|
||||||
*/
|
*/
|
||||||
public static <T> T getBean (Class<T> clz) throws BeansException {
|
public static <T> T getBean (Class<T> clz) throws BeansException {
|
||||||
T result = (T) beanFactory.getBean(clz);
|
T result = (T) beanFactory.getBean(clz);
|
||||||
|
@ -65,7 +65,7 @@ public final class SpringUtils implements BeanFactoryPostProcessor {
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*
|
*
|
||||||
* @throws org.springframework.beans.factory.NoSuchBeanDefinitionException
|
* @throws NoSuchBeanDefinitionException
|
||||||
*/
|
*/
|
||||||
public static boolean isSingleton (String name) throws NoSuchBeanDefinitionException {
|
public static boolean isSingleton (String name) throws NoSuchBeanDefinitionException {
|
||||||
return beanFactory.isSingleton(name);
|
return beanFactory.isSingleton(name);
|
||||||
|
@ -76,7 +76,7 @@ public final class SpringUtils implements BeanFactoryPostProcessor {
|
||||||
*
|
*
|
||||||
* @return Class 注册对象的类型
|
* @return Class 注册对象的类型
|
||||||
*
|
*
|
||||||
* @throws org.springframework.beans.factory.NoSuchBeanDefinitionException
|
* @throws NoSuchBeanDefinitionException
|
||||||
*/
|
*/
|
||||||
public static Class<?> getType (String name) throws NoSuchBeanDefinitionException {
|
public static Class<?> getType (String name) throws NoSuchBeanDefinitionException {
|
||||||
return beanFactory.getType(name);
|
return beanFactory.getType(name);
|
||||||
|
@ -89,7 +89,7 @@ public final class SpringUtils implements BeanFactoryPostProcessor {
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*
|
*
|
||||||
* @throws org.springframework.beans.factory.NoSuchBeanDefinitionException
|
* @throws NoSuchBeanDefinitionException
|
||||||
*/
|
*/
|
||||||
public static String[] getAliases (String name) throws NoSuchBeanDefinitionException {
|
public static String[] getAliases (String name) throws NoSuchBeanDefinitionException {
|
||||||
return beanFactory.getAliases(name);
|
return beanFactory.getAliases(name);
|
||||||
|
|
|
@ -17,11 +17,11 @@ import java.lang.annotation.Target;
|
||||||
@Target(value = {ElementType.METHOD, ElementType.FIELD, ElementType.CONSTRUCTOR, ElementType.PARAMETER})
|
@Target(value = {ElementType.METHOD, ElementType.FIELD, ElementType.CONSTRUCTOR, ElementType.PARAMETER})
|
||||||
@Constraint(validatedBy = {XssValidator.class})
|
@Constraint(validatedBy = {XssValidator.class})
|
||||||
public @interface Xss {
|
public @interface Xss {
|
||||||
String message ()
|
String message()
|
||||||
|
|
||||||
default "不允许任何脚本运行";
|
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
|
|
@ -12,6 +12,7 @@
|
||||||
<module>cloud-common-log</module>
|
<module>cloud-common-log</module>
|
||||||
<module>cloud-common-core</module>
|
<module>cloud-common-core</module>
|
||||||
<module>cloud-common-redis</module>
|
<module>cloud-common-redis</module>
|
||||||
|
<module>cloud-common-saas</module>
|
||||||
<module>cloud-common-seata</module>
|
<module>cloud-common-seata</module>
|
||||||
<module>cloud-common-api-doc</module>
|
<module>cloud-common-api-doc</module>
|
||||||
<module>cloud-common-security</module>
|
<module>cloud-common-security</module>
|
||||||
|
@ -20,7 +21,6 @@
|
||||||
<module>cloud-common-system</module>
|
<module>cloud-common-system</module>
|
||||||
<module>cloud-common-xxl</module>
|
<module>cloud-common-xxl</module>
|
||||||
<module>cloud-common-rabbit</module>
|
<module>cloud-common-rabbit</module>
|
||||||
<module>cloud-common-saas</module>
|
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<artifactId>cloud-common</artifactId>
|
<artifactId>cloud-common</artifactId>
|
||||||
|
|
|
@ -78,8 +78,6 @@ public class SysCarController extends BaseController {
|
||||||
// 随机生成VIN码
|
// 随机生成VIN码
|
||||||
String key2 = RandomUtil.randomNumbers(17);
|
String key2 = RandomUtil.randomNumbers(17);
|
||||||
carVO.setCarVin(key2);
|
carVO.setCarVin(key2);
|
||||||
//
|
|
||||||
carVO.setUserId(SecurityUtils.getUserId());
|
|
||||||
sysCarService.insertCar(carVO);
|
sysCarService.insertCar(carVO);
|
||||||
return Result.success("车辆添加成功");
|
return Result.success("车辆添加成功");
|
||||||
}
|
}
|
||||||
|
@ -92,6 +90,8 @@ public class SysCarController extends BaseController {
|
||||||
*/
|
*/
|
||||||
@PostMapping("updataCar")
|
@PostMapping("updataCar")
|
||||||
public Result updataCar(@RequestBody CarVO carVO){
|
public Result updataCar(@RequestBody CarVO carVO){
|
||||||
|
//
|
||||||
|
carVO.setUserId(SecurityUtils.getUserId());
|
||||||
sysCarService.updateById(carVO);
|
sysCarService.updateById(carVO);
|
||||||
return Result.success("车辆修改成功");
|
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)
|
@TableId(value = "message_id",type = IdType.AUTO)
|
||||||
private Long messageId;
|
private Long messageId;
|
||||||
/**
|
|
||||||
* 车辆编码
|
|
||||||
*/
|
|
||||||
private String messageCode;
|
|
||||||
/**
|
/**
|
||||||
* 车辆报文类别
|
* 车辆报文类别
|
||||||
*/
|
*/
|
||||||
|
@ -35,22 +31,7 @@ public class CarMessage {
|
||||||
* 结束位下标
|
* 结束位下标
|
||||||
*/
|
*/
|
||||||
private Integer messageEndIndex;
|
private Integer messageEndIndex;
|
||||||
/**
|
|
||||||
* 数据类型
|
|
||||||
*/
|
|
||||||
private String messageDataType;
|
|
||||||
/**
|
|
||||||
* 固定值
|
|
||||||
*/
|
|
||||||
private double fixedValue;
|
|
||||||
/**
|
|
||||||
* 最小值
|
|
||||||
*/
|
|
||||||
private double minimumValue;
|
|
||||||
/**
|
|
||||||
* 最大值
|
|
||||||
*/
|
|
||||||
private double maximumValue;
|
|
||||||
/**
|
/**
|
||||||
* 模版id
|
* 模版id
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -18,7 +18,7 @@ public class CarMessageType {
|
||||||
* 报文
|
* 报文
|
||||||
*/
|
*/
|
||||||
@TableId(value = "message_type_id",type = IdType.AUTO)
|
@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)
|
@TableId(value = "template_id",type = IdType.AUTO)
|
||||||
private Integer templateId;
|
private Long templateId;
|
||||||
/**
|
/**
|
||||||
* 报文模版名称
|
* 报文模版名称
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -39,10 +39,6 @@ public class SysCar {
|
||||||
* VIN码
|
* VIN码
|
||||||
*/
|
*/
|
||||||
private String carVin;
|
private String carVin;
|
||||||
/**
|
|
||||||
* 驾车人
|
|
||||||
*/
|
|
||||||
private Long carUserId;
|
|
||||||
/**
|
/**
|
||||||
* 车主
|
* 车主
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -50,4 +50,11 @@ public class CarDTO {
|
||||||
* 在线状态 1.无信号 2.行驶中 3.已停止
|
* 在线状态 1.无信号 2.行驶中 3.已停止
|
||||||
*/
|
*/
|
||||||
private Integer carStatus;
|
private Integer carStatus;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 企业名称
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String companyName;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,10 +40,6 @@ public class CarVO {
|
||||||
* VIN码
|
* VIN码
|
||||||
*/
|
*/
|
||||||
private String carVin;
|
private String carVin;
|
||||||
/**
|
|
||||||
* 驾车人
|
|
||||||
*/
|
|
||||||
private Long carUserId;
|
|
||||||
/**
|
/**
|
||||||
* 车主
|
* 车主
|
||||||
*/
|
*/
|
||||||
|
@ -120,4 +116,10 @@ public class CarVO {
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private Integer gearType;
|
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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.muyu.car.domain.CarCompany;
|
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.SysCarCompanyMapper;
|
||||||
import com.muyu.car.mapper.SysCarMapper;
|
|
||||||
import com.muyu.car.service.SysCarCompanyService;
|
import com.muyu.car.service.SysCarCompanyService;
|
||||||
import com.muyu.car.service.SysCarService;
|
|
||||||
import com.muyu.common.redis.service.RedisService;
|
import com.muyu.common.redis.service.RedisService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author zmw
|
* @author zmw
|
||||||
* @description: 配置plus业务实现层
|
* @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>
|
Loading…
Reference in New Issue