|
@@ -0,0 +1,40 @@
|
|
|
|
|
+package com.middle.platform.auth.biz.controller;
|
|
|
|
|
+
|
|
|
|
|
+import cn.dev33.satoken.stp.StpUtil;
|
|
|
|
|
+import com.middle.platform.auth.biz.pojo.LoginPara;
|
|
|
|
|
+import com.middle.platform.common.utils.Result;
|
|
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * @author xucaiqin
|
|
|
|
|
+ * @date 2023-12-15 08:46:49
|
|
|
|
|
+ */
|
|
|
|
|
+@RestController
|
|
|
|
|
+@RequestMapping("/auth")
|
|
|
|
|
+public class AuthController {
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("/login")
|
|
|
|
|
+ public Result<Object> login(@RequestBody LoginPara loginPara) {
|
|
|
|
|
+ StpUtil.login(loginPara.getUsername());
|
|
|
|
|
+ return Result.ok(true);
|
|
|
|
|
+ }
|
|
|
|
|
+ @PostMapping("/logout")
|
|
|
|
|
+ public Result<Object> logout() {
|
|
|
|
|
+ StpUtil.logout();
|
|
|
|
|
+ return Result.ok(true);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("/check")
|
|
|
|
|
+ public Result<Object> check() {
|
|
|
|
|
+ return Result.ok(StpUtil.isLogin());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("/get")
|
|
|
|
|
+ public Result<Object> get() {
|
|
|
|
|
+ return Result.ok(StpUtil.getTokenInfo());
|
|
|
|
|
+ }
|
|
|
|
|
+}
|