Migrate checkin to user service

Signed-off-by: Asai Neko <sugar@sne.moe>
This commit is contained in:
2025-12-25 20:30:21 +08:00
parent 9e649d83e5
commit bfeb46a61f
7 changed files with 18 additions and 20 deletions

25
service/user/checkin.go Normal file
View File

@@ -0,0 +1,25 @@
package user
import (
"net/http"
"nixcn-cms/data"
"time"
"github.com/gin-gonic/gin"
"github.com/google/uuid"
)
func Checkin(ctx *gin.Context) {
data := new(data.User)
userId, ok := ctx.Get("user_id")
if !ok {
ctx.JSON(http.StatusUnauthorized, gin.H{
"status": "unauthorized",
})
return
}
data.UpdateCheckin(userId.(uuid.UUID), time.Now())
ctx.JSON(http.StatusOK, gin.H{
"status": "success",
})
}

7
service/user/create.go Normal file
View File

@@ -0,0 +1,7 @@
package user
import "github.com/gin-gonic/gin"
func Create(c *gin.Context) {
}

View File

@@ -8,5 +8,8 @@ import (
func Handler(r *gin.RouterGroup) {
r.Use(middleware.JWTAuth())
r.GET("/info", UserInfo)
r.GET("/info", Info)
r.POST("/checkin", Checkin)
r.PATCH("/update", Update)
r.POST("/create", Create)
}

View File

@@ -8,7 +8,7 @@ import (
"github.com/google/uuid"
)
func UserInfo(c *gin.Context) {
func Info(c *gin.Context) {
data := new(data.User)
userId, ok := c.Get("user_id")
if !ok {

0
service/user/update.go Normal file
View File