|
|
|
@ -1,12 +1,12 @@ |
|
|
|
|
package com.gyf.csams |
|
|
|
|
|
|
|
|
|
import io.ktor.application.* |
|
|
|
|
import io.ktor.features.* |
|
|
|
|
import io.ktor.request.* |
|
|
|
|
import io.ktor.response.* |
|
|
|
|
import io.ktor.routing.* |
|
|
|
|
import org.slf4j.LoggerFactory |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private val logger = LoggerFactory.getLogger(Application::class.java) |
|
|
|
|
fun Application.AccountController() { |
|
|
|
|
|
|
|
|
|
routing { |
|
|
|
@ -45,7 +45,9 @@ fun Application.AccountController() { |
|
|
|
|
route(path = "/login"){ |
|
|
|
|
post{ |
|
|
|
|
val userLoginVo= call.receive<UserLoginVo>() |
|
|
|
|
val tokenResDto:TokenResDto=AccountService.login(userLoginVo,call.request.origin.remoteHost) |
|
|
|
|
logger.info("执行登陆") |
|
|
|
|
val tokenResDto:TokenResDto=AccountService.login(userLoginVo,call.request.host()) |
|
|
|
|
logger.info("登录请求处理完毕") |
|
|
|
|
call.respond(ApiResponse(message = if(tokenResDto.token!=null) "登陆成功" else "账号或密码错误!!!",body = tokenResDto)) |
|
|
|
|
} |
|
|
|
|
post(path = "/token"){ |
|
|
|
@ -54,6 +56,14 @@ fun Application.AccountController() { |
|
|
|
|
call.respond(ApiResponse(message = if(isValid) "令牌合法" else "令牌不合法",body = isValid)) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
post(path = "/logout"){ |
|
|
|
|
logger.info("退出登录") |
|
|
|
|
val userLogoutVo=call.receive<UserLogoutVo>() |
|
|
|
|
logger.info("$userLogoutVo") |
|
|
|
|
val flag=AccountService.logout(userLogoutVo.studentId) |
|
|
|
|
call.respond(ApiResponse(message = if(flag) "退出成功" else "退出失败",body = flag)) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|