forked from nixcn/nixcn-cms
Add meilisearch for user and event
Signed-off-by: Asai Neko <sugar@sne.moe>
This commit is contained in:
@@ -107,6 +107,7 @@ func VerifyMagicLink(c *gin.Context) {
|
||||
c.JSON(500, gin.H{
|
||||
"status": "error generating tokens",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(200, gin.H{
|
||||
|
||||
0
service/event/create.go
Normal file
0
service/event/create.go
Normal file
7
service/event/handler.go
Normal file
7
service/event/handler.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package event
|
||||
|
||||
import "github.com/gin-gonic/gin"
|
||||
|
||||
func Handler(r *gin.RouterGroup) {
|
||||
r.GET("/info", Info)
|
||||
}
|
||||
44
service/event/info.go
Normal file
44
service/event/info.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package event
|
||||
|
||||
import (
|
||||
"nixcn-cms/data"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
func Info(c *gin.Context) {
|
||||
event := new(data.Event)
|
||||
eventIdOrig, ok := c.GetQuery("event_id")
|
||||
if !ok {
|
||||
c.JSON(400, gin.H{
|
||||
"status": "undefinded event id",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Parse event id
|
||||
eventId, err := uuid.Parse(eventIdOrig)
|
||||
if err != nil {
|
||||
c.JSON(500, gin.H{
|
||||
"status": "error parsing string to uuid",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
err = event.GetEventById(eventId)
|
||||
if err != nil {
|
||||
c.JSON(404, gin.H{
|
||||
"status": "event id not found",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(200, gin.H{
|
||||
"event_id": event.EventId,
|
||||
"name": event.Name,
|
||||
"start_time": event.StartTime,
|
||||
"end_time": event.EndTime,
|
||||
"joined_users": event.JoinedUsers,
|
||||
})
|
||||
}
|
||||
0
service/event/list.go
Normal file
0
service/event/list.go
Normal file
0
service/event/update.go
Normal file
0
service/event/update.go
Normal file
@@ -21,7 +21,7 @@ func Checkin(c *gin.Context) {
|
||||
// Get event id from query
|
||||
eventIdOrig, ok := c.GetQuery("event_id")
|
||||
if !ok {
|
||||
c.JSON(403, gin.H{
|
||||
c.JSON(400, gin.H{
|
||||
"status": "undefinded event id",
|
||||
})
|
||||
return
|
||||
@@ -33,6 +33,7 @@ func Checkin(c *gin.Context) {
|
||||
c.JSON(500, gin.H{
|
||||
"status": "error parsing string to uuid",
|
||||
})
|
||||
return
|
||||
}
|
||||
data.UpdateCheckin(userId.(uuid.UUID), eventId, time.Now())
|
||||
c.JSON(200, gin.H{
|
||||
|
||||
@@ -12,14 +12,16 @@ func Info(c *gin.Context) {
|
||||
data := new(data.User)
|
||||
userId, ok := c.Get("user_id")
|
||||
if !ok {
|
||||
c.JSON(403, gin.H{
|
||||
c.JSON(404, gin.H{
|
||||
"status": "user not found",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Get user from database
|
||||
err := data.GetByUserId(userId.(uuid.UUID))
|
||||
if err != nil {
|
||||
c.JSON(403, gin.H{
|
||||
c.JSON(404, gin.H{
|
||||
"status": "user not found",
|
||||
})
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user