1.报文管理

2.模块管理
更新时间09231131
master
微醺 2024-09-23 11:31:58 +08:00
parent 68f94b0f26
commit dd30d17c40
27 changed files with 578 additions and 74 deletions

View File

@ -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 {};
/**
* 012
*/
Type type () default Type.ALL;
Type type() default Type.ALL;
public enum Type {
ALL(0), EXPORT(1), IMPORT(2);

View File

@ -13,5 +13,5 @@ import java.lang.annotation.Target;
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Excels {
Excel[] value ();
Excel[] value();
}

View File

@ -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);

View File

@ -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 {};
}

View File

@ -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>

View File

@ -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 "";
}

View File

@ -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);
}
}
}
/**
* sqlparams.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, "");
}
}
}

View File

@ -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>

View File

@ -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("车辆修改成功");
}

View File

@ -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("删除成功");
}
}

View File

@ -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("删除成功");
}
}

View File

@ -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
*/

View File

@ -18,7 +18,7 @@ public class CarMessageType {
*
*/
@TableId(value = "message_type_id",type = IdType.AUTO)
private Integer messageTypeId;
private Long messageTypeId;
/**
*
*/

View File

@ -19,7 +19,7 @@ public class CarTemplate {
*
*/
@TableId(value = "template_id",type = IdType.AUTO)
private Integer templateId;
private Long templateId;
/**
*
*/

View File

@ -39,10 +39,6 @@ public class SysCar {
* VIN
*/
private String carVin;
/**
*
*/
private Long carUserId;
/**
*
*/

View File

@ -50,4 +50,11 @@ public class CarDTO {
* 线 1. 2. 3.
*/
private Integer carStatus;
/**
*
*/
@TableField(exist = false)
private String companyName;
}

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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();
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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>

View File

@ -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>