Selaa lähdekoodia

添加电表服务

nahida 1 vuosi sitten
vanhempi
commit
1a556c2bcc

+ 85 - 0
electricity-service/pom.xml

@@ -0,0 +1,85 @@
+<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>com.zksy</groupId>
+        <artifactId>dh-server-micro</artifactId>
+        <version>1.0.0</version>
+    </parent>
+    <artifactId>electricity-service</artifactId>
+    <groupId>com.zksy.electricity</groupId>
+    <properties>
+        <maven.compiler.source>11</maven.compiler.source>
+        <maven.compiler.target>11</maven.compiler.target>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+
+    <dependencies>
+        <!--common-->
+        <dependency>
+            <groupId>com.zksy</groupId>
+            <artifactId>zksy-common</artifactId>
+            <version>1.0.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+        <!--数据库-->
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+        </dependency>
+        <!--mybatis-->
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-boot-starter</artifactId>
+        </dependency>
+        <!--nacos 服务注册发现-->
+        <dependency>
+            <groupId>com.alibaba.cloud</groupId>
+            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
+        </dependency>
+        <!--负载均衡-->
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-loadbalancer</artifactId>
+        </dependency>
+        <!--统一配置管理-->
+        <dependency>
+            <groupId>com.alibaba.cloud</groupId>
+            <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
+        </dependency>
+        <!--加载bootstrap-->
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-bootstrap</artifactId>
+        </dependency>
+        <!--redis-->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-redis</artifactId>
+        </dependency>
+        <!--sentinel-->
+        <dependency>
+            <groupId>com.alibaba.cloud</groupId>
+            <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
+        </dependency>
+        <!--netty依赖-->
+        <dependency>
+            <groupId>io.netty</groupId>
+            <artifactId>netty-all</artifactId>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <finalName>${project.artifactId}</finalName>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+</project>

+ 15 - 0
electricity-service/src/main/java/com/zksy/electricity/ElectricityApplication.java

@@ -0,0 +1,15 @@
+package com.zksy.electricity;
+
+
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+@MapperScan(basePackages = "com.zksy.electricity.mapper")
+public class ElectricityApplication {
+    public static void main(String[] args) {
+        SpringApplication.run(ElectricityApplication.class, args);
+        System.out.println("电表服务启动成功");
+    }
+}

+ 15 - 0
electricity-service/src/main/java/com/zksy/electricity/controller/TestController.java

@@ -0,0 +1,15 @@
+package com.zksy.electricity.controller;
+
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/test")
+public class TestController {
+
+    @GetMapping
+    public String test() {
+        return "性与暴力";
+    }
+}

+ 17 - 0
electricity-service/src/main/resources/application-dev.yaml

@@ -0,0 +1,17 @@
+zksy:
+  db:
+    host: 192.168.110.30
+    un: root
+    pw: 123
+    port: 3307
+    database: zhongkeshengyang
+spring:
+  redis:
+    host: 192.168.110.30
+    port: 6379
+  cloud:
+    nacos:
+      discovery:
+        server-addr: 192.168.110.30:8848
+      config:
+        server-addr: 192.168.110.30:8848

+ 11 - 0
electricity-service/src/main/resources/application-prod.yaml

@@ -0,0 +1,11 @@
+zksy:
+  db:
+    host: 172.16.102.51
+    un: root
+    pw: d$3%#*(jnhUDGHB]z0x876c~
+    port: 3306
+    database: zhongkeshengyang
+spring:
+  redis:
+    host: 172.16.102.52
+    port: 6379

+ 31 - 0
electricity-service/src/main/resources/bootstrap.yaml

@@ -0,0 +1,31 @@
+spring:
+  application:
+    name: electricity-service
+  profiles:
+    active: dev
+  servlet:
+    multipart:
+      max-file-size: 100MB
+      max-request-size: 100MB
+  main:
+    allow-bean-definition-overriding: true
+  cloud:
+    sentinel:
+      transport:
+#        dashboard: 172.16.102.52:8090
+        dashboard: 192.168.110.30:8090
+      http-method-specify: true
+    nacos:
+      discovery:
+#        server-addr: 172.16.102.52:8848
+#        namespace: 99a7b129-faed-4b32-bcbf-54acd7ffd372
+         server-addr: 192.168.110.30:8848
+      config:
+#        server-addr: 172.16.102.52:8848
+#        namespace: 99a7b129-faed-4b32-bcbf-54acd7ffd372
+        server-addr: 192.168.110.30:8848
+        file-extension: yaml
+        shared-configs:
+          - dataId: electricity-service.yaml
+          - dataId: zksy-shared-jdbc.yaml
+          - dataId: zksy-shared-log.yaml

+ 1 - 0
pom.xml

@@ -18,6 +18,7 @@
         <module>park-overview-service</module>
         <module>lamp-service</module>
         <module>screen-service</module>
+        <module>electricity-service</module>
     </modules>
 
     <parent>

+ 7 - 4
screen-service/src/main/java/com/zksy/screen/controller/TestController.java

@@ -11,11 +11,10 @@ import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 import lombok.extern.slf4j.Slf4j;
 import okhttp3.*;
+import okhttp3.RequestBody;
+import okhttp3.ResponseBody;
 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;
+import org.springframework.web.bind.annotation.*;
 
 import java.io.IOException;
 
@@ -27,6 +26,10 @@ public class TestController {
     @Autowired
     private OkHttpClient httpClient;
     private static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
+    @GetMapping("/a")
+    private String test(){
+        return "性与暴力";
+    }
     @ApiOperation(value = "清屏,清除顶层网页内容")
     @PostMapping("/clearTopWebPage")
     public Result clearTopWebPage(@ApiParam(value = "设备编码",required = true) @RequestParam(value = "deviceCode",defaultValue = "")String deviceCode,