forked from nixcn/nixcn-cms
Migrate checkin to user service
Signed-off-by: Asai Neko <sugar@sne.moe>
This commit is contained in:
25
service/user/checkin.go
Normal file
25
service/user/checkin.go
Normal 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
7
service/user/create.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package user
|
||||
|
||||
import "github.com/gin-gonic/gin"
|
||||
|
||||
func Create(c *gin.Context) {
|
||||
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
0
service/user/update.go
Normal file
Reference in New Issue
Block a user