This commit is contained in:
2021-11-14 12:36:16 +08:00
parent 6d8b51374a
commit bb8ffe2920
2 changed files with 36 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
package me.hatter.sample.common;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class CustomConfiguration {
public static class CustomObject {
private String name;
public CustomObject(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
@Bean
public CustomObject customObject() {
return new CustomObject("Hello: custom object");
}
}

View File

@@ -1,8 +1,10 @@
package me.hatter.sample.web.controller;
import me.hatter.sample.common.CustomConfiguration;
import me.hatter.sample.common.annotation.Permission;
import me.hatter.sample.common.annotation.SystemTime;
import me.hatter.sample.common.session.CustomSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@@ -12,6 +14,9 @@ import java.util.Date;
@RestController
public class SampleController {
@Autowired
CustomConfiguration.CustomObject customObject;
@Permission
@GetMapping("/")
public String home(@SystemTime Date time) {
@@ -35,6 +40,12 @@ public class SampleController {
return "Hello: " + id;
}
@Permission
@GetMapping("/custom-object")
public String customObject() {
return "Custom object: " + customObject.getName();
}
@Permission
@GetMapping("/count")
public String count(CustomSession session) {