Skip to content

Commit 86260ea

Browse files
committed
新增 ads
1 parent 4472482 commit 86260ea

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+3879
-0
lines changed

java/ads/.gitignore

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
target/
2+
!.mvn/wrapper/maven-wrapper.jar
3+
!**/src/main/**/target/
4+
!**/src/test/**/target/
5+
6+
### IntelliJ IDEA ###
7+
.idea/modules.xml
8+
.idea/jarRepositories.xml
9+
.idea/compiler.xml
10+
.idea/libraries/
11+
*.iws
12+
*.iml
13+
*.ipr
14+
15+
### Eclipse ###
16+
.apt_generated
17+
.classpath
18+
.factorypath
19+
.project
20+
.settings
21+
.springBeans
22+
.sts4-cache
23+
24+
### NetBeans ###
25+
/nbproject/private/
26+
/nbbuild/
27+
/dist/
28+
/nbdist/
29+
/.nb-gradle/
30+
build/
31+
!**/src/main/**/build/
32+
!**/src/test/**/build/
33+
34+
### VS Code ###
35+
.vscode/
36+
37+
### Mac OS ###
38+
.DS_Store

java/ads/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# 农业调光系统
2+
3+
## 网页
4+
5+
- [仿真平台](http://hsims.incloudlab.com/)
6+
- [组态平台](http://hcada.incloudlab.com/)
7+
8+
##

java/ads/pom.xml

+127
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xmlns="http://maven.apache.org/POM/4.0.0"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>org.example</groupId>
8+
<artifactId>ads</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
11+
<properties>
12+
<maven.compiler.source>8</maven.compiler.source>
13+
<maven.compiler.target>8</maven.compiler.target>
14+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15+
</properties>
16+
17+
<dependencies>
18+
<dependency>
19+
<groupId>org.springframework.boot</groupId>
20+
<artifactId>spring-boot-starter-web</artifactId>
21+
</dependency>
22+
23+
<dependency>
24+
<groupId>org.springframework.boot</groupId>
25+
<artifactId>spring-boot-starter-websocket</artifactId>
26+
</dependency>
27+
28+
<dependency>
29+
<groupId>org.springframework.cloud</groupId>
30+
<artifactId>spring-cloud-starter-openfeign</artifactId>
31+
</dependency>
32+
33+
<dependency>
34+
<groupId>cn.hutool</groupId>
35+
<artifactId>hutool-all</artifactId>
36+
<version>5.8.24</version>
37+
</dependency>
38+
39+
<!-- 持久层 -->
40+
<dependency>
41+
<groupId>com.baomidou</groupId>
42+
<artifactId>mybatis-plus-boot-starter</artifactId>
43+
<version>3.5.5</version>
44+
</dependency>
45+
46+
<dependency>
47+
<groupId>com.mysql</groupId>
48+
<artifactId>mysql-connector-j</artifactId>
49+
</dependency>
50+
51+
<!-- 代码生成 -->
52+
<dependency>
53+
<groupId>com.baomidou</groupId>
54+
<artifactId>mybatis-plus-generator</artifactId>
55+
<version>3.5.5</version>
56+
</dependency>
57+
58+
<dependency>
59+
<groupId>org.apache.velocity</groupId>
60+
<artifactId>velocity-engine-core</artifactId>
61+
<version>2.1</version>
62+
</dependency>
63+
64+
<!-- 开发工具 -->
65+
<dependency>
66+
<groupId>org.springframework.boot</groupId>
67+
<artifactId>spring-boot-starter-test</artifactId>
68+
<scope>test</scope>
69+
</dependency>
70+
71+
<dependency>
72+
<groupId>org.springframework.boot</groupId>
73+
<artifactId>spring-boot-devtools</artifactId>
74+
<scope>runtime</scope>
75+
</dependency>
76+
77+
<dependency>
78+
<groupId>org.projectlombok</groupId>
79+
<artifactId>lombok</artifactId>
80+
<optional>true</optional>
81+
</dependency>
82+
83+
<dependency>
84+
<groupId>org.springframework.boot</groupId>
85+
<artifactId>spring-boot-configuration-processor</artifactId>
86+
<optional>true</optional>
87+
</dependency>
88+
</dependencies>
89+
90+
<dependencyManagement>
91+
<dependencies>
92+
<dependency>
93+
<groupId>org.springframework.boot</groupId>
94+
<artifactId>spring-boot-dependencies</artifactId>
95+
<version>2.7.18</version>
96+
<type>pom</type>
97+
<scope>import</scope>
98+
</dependency>
99+
100+
<dependency>
101+
<groupId>org.springframework.cloud</groupId>
102+
<artifactId>spring-cloud-dependencies</artifactId>
103+
<version>2021.0.9</version>
104+
<type>pom</type>
105+
<scope>import</scope>
106+
</dependency>
107+
</dependencies>
108+
</dependencyManagement>
109+
110+
<build>
111+
<plugins>
112+
<plugin>
113+
<groupId>org.springframework.boot</groupId>
114+
<artifactId>spring-boot-maven-plugin</artifactId>
115+
<version>2.7.18</version>
116+
<executions>
117+
<execution>
118+
<goals>
119+
<goal>repackage</goal>
120+
</goals>
121+
</execution>
122+
</executions>
123+
</plugin>
124+
</plugins>
125+
</build>
126+
127+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package org.example;
2+
3+
import lombok.extern.slf4j.Slf4j;
4+
import org.mybatis.spring.annotation.MapperScan;
5+
import org.springframework.boot.SpringApplication;
6+
import org.springframework.boot.autoconfigure.SpringBootApplication;
7+
import org.springframework.cloud.openfeign.EnableFeignClients;
8+
import org.springframework.scheduling.annotation.EnableScheduling;
9+
10+
@Slf4j
11+
@EnableScheduling
12+
@EnableFeignClients
13+
@SpringBootApplication
14+
@MapperScan("org.example.mapper")
15+
public class Application {
16+
public static void main(String[] args) {
17+
SpringApplication.run(Application.class, args);
18+
}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package org.example.config;
2+
3+
import lombok.Data;
4+
import org.example.controller.advice.BusinessException;
5+
import org.example.entity.Role;
6+
import org.springframework.boot.context.properties.ConfigurationProperties;
7+
import org.springframework.context.annotation.Configuration;
8+
9+
import java.util.List;
10+
11+
@Data
12+
@Configuration
13+
@ConfigurationProperties("ads.privilege")
14+
public class PrivilegeConfig {
15+
private List<String> farmer;
16+
private List<String> technician;
17+
private List<String> administrator;
18+
19+
public List<String> getPrivilege(Role role) {
20+
switch (role) {
21+
case FARMER: {
22+
return farmer;
23+
}
24+
case TECHNICIAN: {
25+
return technician;
26+
}
27+
case ADMINISTRATOR: {
28+
return administrator;
29+
}
30+
default: {
31+
throw new BusinessException("Invalid role");
32+
}
33+
}
34+
}
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package org.example.config;
2+
3+
import org.example.service.NodeService;
4+
import org.example.service.PolicyService;
5+
import org.springframework.beans.factory.annotation.Autowired;
6+
import org.springframework.context.annotation.Configuration;
7+
import org.springframework.scheduling.annotation.SchedulingConfigurer;
8+
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
9+
10+
@Configuration
11+
public class SchedulingConfig implements SchedulingConfigurer {
12+
@Autowired
13+
private ZCloudConfiguration.ZCloudConfig zCloudConfig;
14+
15+
@Autowired
16+
private NodeService nodeService;
17+
18+
@Autowired
19+
private PolicyService policyService;
20+
21+
@Override
22+
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
23+
taskRegistrar.addFixedDelayTask(nodeService::sync, zCloudConfig.getUpdateInterval());
24+
taskRegistrar.addFixedDelayTask(policyService::control, zCloudConfig.getUpdateInterval());
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package org.example.config;
2+
3+
import org.example.controller.advice.AuthInterceptor;
4+
import org.example.controller.advice.LoggerInterceptor;
5+
import org.springframework.beans.factory.annotation.Autowired;
6+
import org.springframework.context.annotation.Configuration;
7+
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
8+
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
9+
10+
@Configuration
11+
public class WebMvcConfig implements WebMvcConfigurer {
12+
@Autowired
13+
private PrivilegeConfig privilegeConfig;
14+
15+
@Override
16+
public void addInterceptors(InterceptorRegistry registry) {
17+
registry.addInterceptor(new LoggerInterceptor())
18+
.addPathPatterns("/**");
19+
registry.addInterceptor(new AuthInterceptor(privilegeConfig))
20+
.addPathPatterns("/**")
21+
.excludePathPatterns("/", "/error", "/favicon.ico", "/index.html")
22+
.excludePathPatterns("/user/login", "/user/me");
23+
}
24+
}

0 commit comments

Comments
 (0)