mirror of
				https://github.com/suyiiyii/SIMS.git
				synced 2025-11-04 15:54:52 +08:00 
			
		
		
		
	feat: 添加健康检查和问候控制器 (#7)
实现新的健康检查端点和Hello控制器以响应GET和POST请求。健康检查返回"ok"或自定义响应,而Hello控制器返回带参数的问候信息。另外,引入了springdoc-openapi以增强API文档生成能力。
This commit is contained in:
		
							parent
							
								
									4fb6e0566b
								
							
						
					
					
						commit
						3b44def8aa
					
				
							
								
								
									
										5
									
								
								pom.xml
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								pom.xml
									
									
									
									
									
								
							@ -77,6 +77,11 @@
 | 
			
		||||
            <artifactId>spring-restdocs-mockmvc</artifactId>
 | 
			
		||||
            <scope>test</scope>
 | 
			
		||||
        </dependency>
 | 
			
		||||
        <dependency>
 | 
			
		||||
            <groupId>org.springdoc</groupId>
 | 
			
		||||
            <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
 | 
			
		||||
            <version>2.3.0</version>
 | 
			
		||||
        </dependency>
 | 
			
		||||
    </dependencies>
 | 
			
		||||
 | 
			
		||||
    <build>
 | 
			
		||||
 | 
			
		||||
@ -0,0 +1,27 @@
 | 
			
		||||
package top.suyiiyii.sims.controller;
 | 
			
		||||
 | 
			
		||||
import lombok.AllArgsConstructor;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
import org.springframework.web.bind.annotation.GetMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.PostMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.RestController;
 | 
			
		||||
 | 
			
		||||
@RestController
 | 
			
		||||
public class HealthzController {
 | 
			
		||||
    @GetMapping("/healthz")
 | 
			
		||||
    public String healthz() {
 | 
			
		||||
        return "ok";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @PostMapping("/healthz")
 | 
			
		||||
    public HealthzResponse healthzPost() {
 | 
			
		||||
        return new HealthzResponse("health");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @AllArgsConstructor
 | 
			
		||||
    @Data
 | 
			
		||||
    public static class HealthzResponse {
 | 
			
		||||
        private String status;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,13 @@
 | 
			
		||||
package top.suyiiyii.sims.controller;
 | 
			
		||||
 | 
			
		||||
import org.springframework.web.bind.annotation.GetMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.RestController;
 | 
			
		||||
 | 
			
		||||
@RestController
 | 
			
		||||
public class HelloController {
 | 
			
		||||
 | 
			
		||||
    @GetMapping("/hello")
 | 
			
		||||
    public String hello(String username) {
 | 
			
		||||
        return "Hello " + username;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user