shjung 2 жил өмнө
parent
commit
9da6c83e9a

+ 18 - 0
pom.xml

@@ -25,6 +25,10 @@
 
     <properties>
         <java.version>1.8</java.version>
+        <swagger.version>2.9.2</swagger.version>
+        <org.projectlombok.version>1.18.20</org.projectlombok.version>
+        <org.mapstruct.version>1.4.2.Final</org.mapstruct.version>
+        <jackson.version>2.13.1</jackson.version>
         <!-- jar 배포용 -->
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
@@ -38,6 +42,20 @@
     </properties>
 
     <dependencies>
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger2</artifactId>
+            <version>${swagger.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger-ui</artifactId>
+            <version>${swagger.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-validation</artifactId>
+        </dependency>
          <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-test</artifactId>

+ 55 - 0
src/main/java/com/its/dsrc/config/SwaggerConfig.java

@@ -0,0 +1,55 @@
+package com.its.dsrc.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.HttpHeaders;
+import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.builders.ParameterBuilder;
+import springfox.documentation.builders.PathSelectors;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.schema.ModelRef;
+import springfox.documentation.service.ApiInfo;
+import springfox.documentation.service.Parameter;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Configuration
+@EnableSwagger2
+public class SwaggerConfig {
+
+    @Bean
+    public Docket commonApi() {
+        Parameter parameterBuilder = new ParameterBuilder()
+                .name(HttpHeaders.AUTHORIZATION)
+                .description("Access Token")
+                .modelRef(new ModelRef("string"))
+                .parameterType("header")
+                .required(false)
+                .build();
+
+        List<Parameter> globalParameters = new ArrayList<>();
+        globalParameters.add(parameterBuilder);
+        return new Docket(DocumentationType.SWAGGER_2)
+                .globalOperationParameters(globalParameters)
+                .groupName("rse-api")
+                .apiInfo(this.apiInfo())
+                .select()
+                .apis(RequestHandlerSelectors.basePackage("com.its.dsrc.api.controller"))
+                .paths(PathSelectors.any())
+                //.paths(PathSelectors.ant("/api/**"))
+                .build();
+    }
+
+    private ApiInfo apiInfo() {
+        return new ApiInfoBuilder()
+                .title("RSE(DSRC) Control API")
+                .description("RSE(DSRC) Communication Server API")
+                .version("0.0.1")
+                .build();
+    }
+
+}

+ 14 - 0
src/main/java/com/its/dsrc/webapp/config/WebSecurityConfig.java

@@ -4,6 +4,7 @@ import com.its.dsrc.webapp.security.SessionListener;
 import com.its.dsrc.webapp.service.UserService;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.http.HttpMethod;
 import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
 import org.springframework.security.config.annotation.web.builders.HttpSecurity;
 import org.springframework.security.config.annotation.web.builders.WebSecurity;
@@ -25,13 +26,26 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
         this.userService = userService;
     }
 
+    @Override
     public void configure(WebSecurity web) throws Exception {
+        web.ignoring().antMatchers("/favicon.ico");
         web.ignoring().antMatchers(new String[]{"/css/**", "/js/**", "/img/**", "/lib/**"});
+
+        web.ignoring().antMatchers(HttpMethod.GET, "/api/**");  // GET Method 는 모두 통과
+        web.ignoring().antMatchers(HttpMethod.POST, "/api/**");  // GET Method 는 모두 통과
+        web.ignoring().antMatchers(HttpMethod.PUT, "/api/**");  // GET Method 는 모두 통과
+        web.ignoring().antMatchers(HttpMethod.DELETE, "/api/**");  // GET Method 는 모두 통과
     }
 
+    @Override
     protected void configure(HttpSecurity http) throws Exception {
 
         http.authorizeRequests()
+                // SWAGGER 권한 설정
+                .antMatchers("/swagger-ui.html", "/swagger/**", "/swagger-resources/**", "/webjars/**", "/v2/api-docs").permitAll()
+                // 웹소켓 권한 설정하지
+                .antMatchers("/ws/**").permitAll()
+                .antMatchers("/api/**").permitAll()
                 .antMatchers(new String[]{"/index"})
                 .hasRole("ADMIN")
                 .antMatchers(new String[]{"/**"})

+ 3 - 4
src/main/java/com/its/dsrc/webapp/controller/WebAppController.java

@@ -1,6 +1,6 @@
 package com.its.dsrc.webapp.controller;
 
-import com.its.dsrc.config.RunningConfig;
+import com.its.dsrc.config.ApplicationConfig;
 import com.its.dsrc.entity.TbRseCtlr;
 import com.its.dsrc.global.AppRepository;
 import com.its.dsrc.vo.NET;
@@ -30,7 +30,7 @@ import java.util.concurrent.ConcurrentHashMap;
 public class WebAppController {
 
     private final ResourceLoader resourceLoader;
-    private final RunningConfig runningConfig;
+    private final ApplicationConfig applicationConfig;
     private final FileService fileService;
 
     @RequestMapping(value = {"/controller"})
@@ -39,7 +39,6 @@ public class WebAppController {
         SortedMap<Integer, TbRseCtlr> ctlrMap = new TreeMap<>();
         for (Map.Entry<String, TbRseCtlr> e : AppRepository.getInstance().getCtlrMap().entrySet()) {
             TbRseCtlr obj = e.getValue();
-            // 로인인 상태에서 통신중인데 화면에서 연결되지 않았다고 표출되는 경우가 있음
             if (obj.getNetState() == NET.CLOSED) {
                 if (obj.getChannel() != null || obj.getLogin() != null) {
                     obj.setNetState(NET.LOGINED);
@@ -47,7 +46,7 @@ public class WebAppController {
             }
             ctlrMap.put(Integer.valueOf(obj.getID()), obj);
         }
-        model.addAttribute("ServerConfig", this.runningConfig);
+        model.addAttribute("ServerConfig", this.applicationConfig);
         //model.addAttribute("list", AppRepository.getInstance().getCtlrMap().entrySet());
         model.addAttribute("list", ctlrMap);
         model.addAttribute("ServerTime", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));

+ 2 - 2
src/main/resources/application.yml

@@ -26,7 +26,7 @@ running:
   filtering-algorithm: 1
 
 server:
-  port: 9875
+  port: 8904
   shutdown: graceful
   error:
     whitelabel:
@@ -43,7 +43,7 @@ spring:
   profiles:
     active: dev
   main:
-    web-application-type: none
+    #web-application-type: none
     log-startup-info: true
     banner-mode: off
   mvc:

+ 7 - 7
src/main/webapp/WEB-INF/jsp/controller.jsp

@@ -30,10 +30,10 @@
                         </thead>
                         <c:forEach var="entry" items="${list}" varStatus="status">
                             <tr>
-                                <td align="center">${entry.value.ID}</td>
-                                <td align="center">${entry.value.RSE_ID}</td>
-                                <td>${entry.value.ISTL_LCTN_NM}</td>
-                                <td>&nbsp;${entry.value.IP_ADDR}&nbsp;</td>
+                                <td align="center">${entry.value.RSE_CTLR_NMBR}</td>
+                                <td align="center">${entry.value.RSE_CTLR_ID}</td>
+                                <td>${entry.value.RSE_NM}</td>
+                                <td>&nbsp;${entry.value.RSE_CTLR_IP}&nbsp;</td>
                                 <td align="center">
                                     <c:choose>
                                         <c:when test="${entry.value.netState eq '0'}">
@@ -48,9 +48,9 @@
                                 <td align="center">&nbsp;${entry.value.disConnectTm}&nbsp;</td>
                                 <td align="center">${entry.value.connectCount}</td>
                                 <td align="center">
-                                    &nbsp;<a href=javascript:disconnectController('${entry.value.ID}')>연결해제</a>&nbsp;&nbsp;
-                                    <!--<a href=javascript:resetController('${entry.value.ID}')>제어기리셋</a>&nbsp;&nbsp;-->
-                                    <a href=javascript:resetConnCount('${entry.value.ID}')>접속횟수초기화</a>&nbsp;</td>
+                                    &nbsp;<a href=javascript:disconnectController('${entry.value.RSE_CTLR_NMBR}')>연결해제</a>&nbsp;&nbsp;
+                                    <!--<a href=javascript:resetController('${entry.value.RSE_CTLR_NMBR}')>제어기리셋</a>&nbsp;&nbsp;-->
+                                    <a href=javascript:resetConnCount('${entry.value.RSE_CTLR_NMBR}')>접속횟수초기화</a>&nbsp;</td>
                             </tr>
                         </c:forEach>
                     </table>

+ 2 - 9
src/main/webapp/WEB-INF/jsp/head.jsp

@@ -1,17 +1,10 @@
 <head>
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-    <title>${ServerConfig.processName}</title>
-    <!--
-    <link rel="stylesheet" href="/js/bootstrap-5.0.0/css/bootstrap.css">
-    -->
+    <title>${ServerConfig.name}</title>
 </head>
 
-<!--
-<script type="text/javascript" src="/js/libs/jquery-3.6.0.min.js"></script>
-<script type="text/javascript" src="/js/bootstrap-5.0.0/js/bootstrap.js"></script>
--->
-<script type="text/javascript" src="/js/jquery-2.2.4.min.js"></script>
 <script type="text/javascript" src="/js/moment.min.js"></script>
+<script type="text/javascript" src="/js/jquery-2.2.4.min.js"></script>
 <script type="text/javascript" src="/js/ajax.js"></script>
 <script type="text/javascript" src="/js/main.js"></script>
 <script type="text/javascript" src="/js/login.js"></script>

+ 1 - 1
src/main/webapp/WEB-INF/jsp/header.jsp

@@ -1,6 +1,6 @@
 
 <table width="100%" style="font-family:tahoma;font-size:12pt;color:#808080;border-color:#6a5acd;margin-top: 5px;" border="0" cellpadding="10" cellspacing="0">
-    <tr align="center"><td style="font-size: 24px; font-weight: bold; color: black;">${ServerConfig.processName}</td></tr>
+    <tr align="center"><td style="font-size: 24px; font-weight: bold; color: black;">${ServerConfig.name}</td></tr>
 </table>
 <hr>
 <table width="100%" style="font-family:tahoma;font-size:12pt;color:#808080;border-color:#6a5acd;margin-top: -10px;" border="0" cellpadding="10" cellspacing="0" >

+ 3 - 9
src/main/webapp/WEB-INF/jsp/system.jsp

@@ -14,15 +14,9 @@
             <tr><td>
                 <fieldset><legend> System Information </legend>
                     <table border="0" cellpadding="1" cellspacing="0" style="font-weight: normal;font-family:tahoma;font-size:12pt;">
-                            <tr><td align="right" width="200">          system id : </td> <td><input type="text" value="${ServerConfig.processId}"         disabled /></td></tr>
-                            <tr><td align="right" width="200">tcp binding address : </td> <td><input type="text" value="${ServerConfig.tcpBindAddress}"    disabled /></td></tr>
-                            <tr><td align="right" width="200">   tcp binding port : </td> <td><input type="text" value="${ServerConfig.tcpBindPort}"       disabled /></td></tr>
-                            <tr><td align="right" width="200">   udp binding port : </td> <td><input type="text" value="${ServerConfig.centerBindPort}"    disabled /></td></tr>
-                            <!--
-                            <tr><td align="right" width="200">   data job threads : </td> <td><input type="text" value="${ServerConfig.serverDataThreads}" disabled /></td></tr>
-                            <tr><td align="right" width="200">   dbms job threads : </td> <td><input type="text" value="${ServerConfig.serverDbThreads}"   disabled /></td></tr>
-                            -->
-                            <tr><td align="right" width="200">       booting time : </td> <td><input type="text" value="${ServerConfig.bootingDateTime}"   disabled /></td></tr>
+                        <tr><td align="right" width="200">          system id : </td> <td><input type="text" value="${ServerConfig.id}" disabled /></td></tr>
+                        <tr><td align="right" width="200">center binding port : </td> <td><input type="text" value="${ServerConfig.listenPort}" disabled /></td></tr>
+                        <tr><td align="right" width="200">       booting time : </td> <td><input type="text" value="${ServerConfig.bootingDateTime}"   disabled /></td></tr>
                     </table>
                 </fieldset>
             </td></tr>