mirror of
https://github.com/hpd840321/starRiverProperty.git
synced 2026-06-09 08:20:31 +08:00
Initial commit: reorganized source tree
- backend/: 13 Maven modules (cw-elevator-application, cloudwalk-cloud, intelligent-cwoscomponent, ninca-crk, etc.) - frontend/: 4 Vue projects (elevator-front, cwos-portal, alarm-front, front_acs) + decompiled + scripts - scripts/: build, test-env, tools (Docker Compose, service templates, API parity) - docs/: AGENTS.md, superpowers specs, architecture docs - .gitignore: standard Java/Maven exclusions Moved from legacy maven-*/ root layout to backend/ organized structure.
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>cn.cloudwalk.cloud</groupId>
|
||||
<artifactId>cloudwalk-cloud-reactor</artifactId>
|
||||
<version>4.0.0-Brussels-SRX</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>cloudwalk-common-service</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<description>云从科技-公共组件 service 通用层(源码已迁入本模块 src/main/java)</description>
|
||||
|
||||
<properties>
|
||||
<alibaba.eclipse.codestyle.path>${project.basedir}/../../docs/style/alibaba-eclipse-codestyle.xml</alibaba.eclipse.codestyle.path>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>cn.cloudwalk.cloud</groupId>
|
||||
<artifactId>cloudwalk-common-result</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-aop</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-aspects</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-beans</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-webmvc</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>net.revelc.code.formatter</groupId>
|
||||
<artifactId>formatter-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
package cn.cloudwalk.service.aop;
|
||||
|
||||
import cn.cloudwalk.cloud.annotation.CloudwalkParamsValidate;
|
||||
import cn.cloudwalk.cloud.result.CloudwalkResult;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import javax.validation.ConstraintViolation;
|
||||
import javax.validation.Validator;
|
||||
import javax.validation.groups.Default;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 对标注了 {@link cn.cloudwalk.cloud.annotation.CloudwalkParamsValidate} 的入口进行 Bean Validation 校验。
|
||||
*/
|
||||
@Aspect
|
||||
@Order(-100)
|
||||
@Component
|
||||
public class CloudwalkParamsValidateAspect {
|
||||
private final Logger logger = LoggerFactory.getLogger(getClass());
|
||||
@Autowired
|
||||
private Validator validator;
|
||||
@Autowired
|
||||
private MessageSource messageSource;
|
||||
|
||||
public String getMessage(String code) {
|
||||
return this.messageSource.getMessage(code, null, LocaleContextHolder.getLocale());
|
||||
}
|
||||
|
||||
@Pointcut("@annotation(cn.cloudwalk.cloud.annotation.CloudwalkParamsValidate)")
|
||||
public void validatePointcut() {}
|
||||
|
||||
@Around("validatePointcut()")
|
||||
public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
|
||||
MethodSignature methodSignature = (MethodSignature)joinPoint.getSignature();
|
||||
Method targetMethod =
|
||||
joinPoint.getTarget().getClass().getMethod(methodSignature.getName(), methodSignature.getParameterTypes());
|
||||
this.logger.debug("正在进行对类{}中方法{}进行参数检查开始", joinPoint.getTarget().getClass().getName(), targetMethod.getName());
|
||||
CloudwalkParamsValidate paramsValidate =
|
||||
targetMethod.<CloudwalkParamsValidate>getAnnotation(CloudwalkParamsValidate.class);
|
||||
if (paramsValidate == null) {
|
||||
return joinPoint.proceed();
|
||||
}
|
||||
int[] needCheckParamIndexs = paramsValidate.argsIndexs();
|
||||
if (needCheckParamIndexs == null) {
|
||||
return joinPoint.proceed();
|
||||
}
|
||||
Class<?>[] groupsClazz = paramsValidate.groups();
|
||||
if (groupsClazz == null) {
|
||||
groupsClazz = new Class[] {Default.class};
|
||||
}
|
||||
Object[] args = joinPoint.getArgs();
|
||||
for (int index : needCheckParamIndexs) {
|
||||
Object arg = args[index];
|
||||
Set<ConstraintViolation<Object>> constraintViolationSet = this.validator.validate(arg, groupsClazz);
|
||||
if (constraintViolationSet != null && constraintViolationSet.size() > 0) {
|
||||
Iterator<ConstraintViolation<Object>> iterator = constraintViolationSet.iterator();
|
||||
if (iterator.hasNext()) {
|
||||
ConstraintViolation<Object> constraintViolation = iterator.next();
|
||||
String code = constraintViolation.getMessage();
|
||||
return CloudwalkResult.fail(code, getMessage(code));
|
||||
}
|
||||
}
|
||||
}
|
||||
this.logger.debug("正在进行对类{}中方法{}进行参数检查通过", joinPoint.getTarget().getClass().getName(), targetMethod.getName());
|
||||
return joinPoint.proceed();
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package cn.cloudwalk.service.config;
|
||||
|
||||
import javax.validation.Validation;
|
||||
import javax.validation.Validator;
|
||||
import javax.validation.ValidatorFactory;
|
||||
import org.hibernate.validator.HibernateValidator;
|
||||
import org.hibernate.validator.HibernateValidatorConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.validation.beanvalidation.MethodValidationPostProcessor;
|
||||
|
||||
/**
|
||||
* Hibernate Validator 与 Spring {@link org.springframework.validation.beanvalidation.MethodValidationPostProcessor} 注册。
|
||||
*/
|
||||
@Configuration
|
||||
public class ValidatorConfig {
|
||||
@Bean
|
||||
public Validator validator() {
|
||||
ValidatorFactory validatorFactory =
|
||||
((HibernateValidatorConfiguration)Validation.byProvider(HibernateValidator.class).configure())
|
||||
.failFast(true).buildValidatorFactory();
|
||||
return validatorFactory.getValidator();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MethodValidationPostProcessor methodValidationPostProcessor() {
|
||||
MethodValidationPostProcessor postProcessor = new MethodValidationPostProcessor();
|
||||
postProcessor.setValidator(validator());
|
||||
return postProcessor;
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* 云从公共 Web/Service 横切能力:参数校验 AOP、校验器与 Spring 集成等。
|
||||
* <p>
|
||||
* 典型用法:在依赖了 {@code cloudwalk-common-result} 的应用中注册切面与 {@link org.springframework.validation.Validator}。
|
||||
*/
|
||||
package cn.cloudwalk.service;
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
Manifest-Version: 1.0
|
||||
Archiver-Version: Plexus Archiver
|
||||
Built-By: hechunjie
|
||||
Created-By: Apache Maven 3.6.0
|
||||
Build-Jdk: 1.8.0_191
|
||||
|
||||
Reference in New Issue
Block a user