sample-modules/demo/src/main/kotlin/com/example/demo/DemoApplication.kt

41 lines
1.3 KiB
Kotlin
Raw Normal View History

package com.example.demo
import com.example.lib.MyLib
2021-01-26 13:28:23 +07:00
import com.example.lib.MyUtils
2021-01-28 13:22:46 +07:00
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.CommandLineRunner
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import org.springframework.security.access.prepost.PreAuthorize
import org.springframework.security.core.Authentication
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
@SpringBootApplication (scanBasePackages = ["com.example.demo", "com.example.loginapi","com.example.customerapi"])
2021-01-28 13:22:46 +07:00
class DemoApplication @Autowired constructor(
//customerRepository: CustomerRepository,
) : CommandLineRunner {
override fun run(vararg args: String?) {
MyLib.doOnMe()
2021-01-26 13:28:23 +07:00
2021-01-26 13:40:45 +07:00
println()
2021-01-26 13:28:23 +07:00
println("Hello JJKK: ${MyUtils.helloWorld()}")
}
}
fun main(args: Array<String>) {
runApplication<DemoApplication>(*args)
}
@RestController
@RequestMapping("/oauth")
@PreAuthorize("isAuthenticated()")
class OAuthController {
@GetMapping
fun getMe(authentication: Authentication) : Any? {
return authentication
}
}