Add event service, caddy test domain

Signed-off-by: Asai Neko <sugar@sne.moe>
This commit is contained in:
2025-12-27 03:45:31 +08:00
parent 2b99d415de
commit afc62f311b
12 changed files with 145 additions and 12 deletions

View File

@@ -0,0 +1 @@
package event

View File

@@ -35,7 +35,6 @@ func Info(c *gin.Context) {
}
c.JSON(200, gin.H{
"event_id": event.EventId,
"name": event.Name,
"start_time": event.StartTime,
"end_time": event.EndTime,

View File

@@ -0,0 +1 @@
package event

View File

@@ -0,0 +1 @@
package event

View File

@@ -2,7 +2,6 @@ package user
import (
"nixcn-cms/data"
"time"
"github.com/gin-gonic/gin"
"github.com/google/uuid"
@@ -35,7 +34,43 @@ func Checkin(c *gin.Context) {
})
return
}
data.UpdateCheckin(userId.(uuid.UUID), eventId, time.Now())
data.UserId = userId.(uuid.UUID)
code, err := data.GenCheckinCode(eventId)
if err != nil {
c.JSON(500, gin.H{
"status": "error generating code",
})
return
}
c.JSON(200, gin.H{
"checkin_code": code,
})
}
func CheckinSubmit(c *gin.Context) {
var req struct {
ChekinCode string `json:"checkin_code"`
}
c.ShouldBindJSON(&req)
data := new(data.User)
userId, err := data.VerifyCheckinCode(req.ChekinCode)
if err != nil {
c.JSON(400, gin.H{
"status": "error verify checkin code",
})
return
}
data.GetByUserId(*userId)
if data.PermissionLevel <= 20 {
c.JSON(403, gin.H{
"status": "access denied",
})
}
c.JSON(200, gin.H{
"status": "success",
})

View File

@@ -10,6 +10,7 @@ func Handler(r *gin.RouterGroup) {
r.Use(middleware.JWTAuth())
r.GET("/info", Info)
r.POST("/checkin", Checkin)
r.POST("/checkin/submit", CheckinSubmit)
r.PATCH("/update", Update)
r.GET("/list", List)
}