34 lines
864 B
Go
34 lines
864 B
Go
package handler
|
||
|
||
import (
|
||
"net/http"
|
||
|
||
"github.com/gin-gonic/gin"
|
||
)
|
||
|
||
// AdminCheck GET /api/admin 鉴权检查
|
||
func AdminCheck(c *gin.Context) {
|
||
// TODO: 校验 session/token,返回 success: true 或 401
|
||
c.JSON(http.StatusOK, gin.H{"success": true})
|
||
}
|
||
|
||
// AdminLogin POST /api/admin 登录
|
||
func AdminLogin(c *gin.Context) {
|
||
var body struct {
|
||
Username string `json:"username" binding:"required"`
|
||
Password string `json:"password" binding:"required"`
|
||
}
|
||
if err := c.ShouldBindJSON(&body); err != nil {
|
||
c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": "参数错误"})
|
||
return
|
||
}
|
||
// TODO: 校验用户名密码,写 session,返回 success
|
||
c.JSON(http.StatusOK, gin.H{"success": true})
|
||
}
|
||
|
||
// AdminLogout POST /api/admin/logout
|
||
func AdminLogout(c *gin.Context) {
|
||
// TODO: 清除 session
|
||
c.JSON(http.StatusOK, gin.H{"success": true})
|
||
}
|