About
Last updated
Last updated
ΠΠ° ΠΌΠΎΠ΅ΠΌ Github ΠΌΠΎΠΆΠ½ΠΎ Π½Π°ΠΉΡΠΈ ΠΌΠ°Π»Π΅Π½ΡΠΊΠΈΠ΅ ΠΏΡΠΈΠΌΠ΅ΡΡ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠΉ Π½Π° Spring Framework.
Spring: https://spring.io/ Tutorial: https://kotlinlang.org/docs/jvm-spring-boot-restful.html
Configurator β ΠΈΠ½ΠΈΡΠΈΠ°Π»ΠΈΠ·ΠΈΡΡΠ΅Ρ HttpClient, Service, Controller, ...
Controller β ΠΏΡΠΈΠ½ΠΈΠΌΠ°Π΅Ρ Service, ΠΎΠ±ΡΠ°Π±Π°ΡΡΠ²Π°Π΅Ρ API Π²ΡΠ·ΠΎΠ²Ρ ΠΈ ΠΏΠ΅ΡΠ΅Π΄Π°Π΅Ρ ΡΠ΅ΡΠ²ΠΈΡΡ
Service β ΡΡΠΎΠ²Π΅Π½Ρ Π»ΠΎΠ³ΠΈΠΊΠΈ, Π±Π΅ΡΠ΅Ρ Π½Π° ΡΠ΅Π±Ρ ΡΠ°ΡΠΊΠΈ Π² ΡΠΎΠ½Π΅
// ...
@Configurator
public class SomeContextConfigurator {
@Bean
public SomeController someController( ... ) {
return new SomeController(someService, ...
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping(value = "/some")
public class SomeController {
private final SomeService someService;
public SomeController(
SomeService someService
) {
this.someService = someService;
}
@RequestMapping(value = "send", method = RequestMethod.POST)
public SomeResult someAction(
@RequestParam("post_param") String postParam
) {
// ...
someService.someAction(postParam);
// ...
}
}
Interface
public interface SomeService {
SomeResult someAction(String postParam);
}
Impl
public class ConnectorSendSmsServiceImpl implements ConnectorSendSmsService {
// ...
}