WIP Add join_event in service_event
Signed-off-by: Asai Neko <sugar@sne.moe>
This commit is contained in:
@@ -16,11 +16,11 @@ import (
|
|||||||
// @Tags Event
|
// @Tags Event
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param event_id query string true "Event UUID"
|
// @Param event_id query string true "Event UUID"
|
||||||
// @Success 200 {object} utils.RespStatus{data=service_event.EventInfoResponse} "Successful retrieval"
|
// @Success 200 {object} utils.RespStatus{data=data.EventIndexDoc} "Successful retrieval"
|
||||||
// @Failure 400 {object} utils.RespStatus{data=nil} "Invalid Input"
|
// @Failure 400 {object} utils.RespStatus{data=nil} "Invalid Input"
|
||||||
// @Failure 404 {object} utils.RespStatus{data=nil} "Event Not Found"
|
// @Failure 404 {object} utils.RespStatus{data=nil} "Event Not Found"
|
||||||
// @Failure 500 {object} utils.RespStatus{data=nil} "Internal Server Error"
|
// @Failure 500 {object} utils.RespStatus{data=nil} "Internal Server Error"
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Router /event/info [get]
|
// @Router /event/info [get]
|
||||||
func (self *EventHandler) Info(c *gin.Context) {
|
func (self *EventHandler) Info(c *gin.Context) {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ type Attendance struct {
|
|||||||
EventId uuid.UUID `json:"event_id" gorm:"type:uuid;uniqueIndex:unique_event_user;not null"`
|
EventId uuid.UUID `json:"event_id" gorm:"type:uuid;uniqueIndex:unique_event_user;not null"`
|
||||||
UserId uuid.UUID `json:"user_id" gorm:"type:uuid;uniqueIndex:unique_event_user;not null"`
|
UserId uuid.UUID `json:"user_id" gorm:"type:uuid;uniqueIndex:unique_event_user;not null"`
|
||||||
Role string `json:"role" gorm:"type:varchar(255);not null"`
|
Role string `json:"role" gorm:"type:varchar(255);not null"`
|
||||||
State string `json:"state" gorm:"type:varchar(255);not null"`
|
State string `json:"state" gorm:"type:varchar(255);not null"` // suspended | out_of_limit | success
|
||||||
KycInfo string `json:"kyc_info" gorm:"type:text"`
|
KycInfo string `json:"kyc_info" gorm:"type:text"`
|
||||||
CheckinAt time.Time `json:"checkin_at"`
|
CheckinAt time.Time `json:"checkin_at"`
|
||||||
}
|
}
|
||||||
@@ -33,6 +33,31 @@ type AttendanceSearchDoc struct {
|
|||||||
CheckinAt time.Time `json:"checkin_at"`
|
CheckinAt time.Time `json:"checkin_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *Attendance) SetEventId(s uuid.UUID) *Attendance {
|
||||||
|
self.EventId = s
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *Attendance) SetUserId(s uuid.UUID) *Attendance {
|
||||||
|
self.UserId = s
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *Attendance) SetRole(s string) *Attendance {
|
||||||
|
self.Role = s
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *Attendance) SetState(s string) *Attendance {
|
||||||
|
self.State = s
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *Attendance) SetKycInfo(s string) *Attendance {
|
||||||
|
self.KycInfo = s
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
func (self *Attendance) GetAttendance(ctx context.Context, userId, eventId uuid.UUID) (*Attendance, error) {
|
func (self *Attendance) GetAttendance(ctx context.Context, userId, eventId uuid.UUID) (*Attendance, error) {
|
||||||
var checkin Attendance
|
var checkin Attendance
|
||||||
|
|
||||||
@@ -105,7 +130,7 @@ func (self *Attendance) Create(ctx context.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *Attendance) Update(ctx context.Context, attendanceId uuid.UUID, checkinTime *time.Time) (*Attendance, error) {
|
func (self *Attendance) Update(ctx context.Context, attendanceId uuid.UUID) (*Attendance, error) {
|
||||||
var attendance Attendance
|
var attendance Attendance
|
||||||
|
|
||||||
err := Database.WithContext(ctx).Transaction(func(tx *gorm.DB) error {
|
err := Database.WithContext(ctx).Transaction(func(tx *gorm.DB) error {
|
||||||
@@ -116,19 +141,9 @@ func (self *Attendance) Update(ctx context.Context, attendanceId uuid.UUID, chec
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
updates := map[string]any{}
|
|
||||||
|
|
||||||
if checkinTime != nil {
|
|
||||||
updates["checkin_at"] = *checkinTime
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(updates) == 0 {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := tx.
|
if err := tx.
|
||||||
Model(&attendance).
|
Model(&attendance).
|
||||||
Updates(updates).Error; err != nil {
|
Updates(self).Error; err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,8 +211,8 @@ func (self *Attendance) VerifyCheckinCode(ctx context.Context, checkinCode strin
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
time := time.Now()
|
self.CheckinAt = time.Now()
|
||||||
_, err = self.Update(ctx, attendanceData.AttendanceId, &time)
|
_, err = self.Update(ctx, attendanceData.AttendanceId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,10 +13,11 @@ type Event struct {
|
|||||||
UUID uuid.UUID `json:"uuid" gorm:"type:uuid;uniqueIndex;not null"`
|
UUID uuid.UUID `json:"uuid" gorm:"type:uuid;uniqueIndex;not null"`
|
||||||
EventId uuid.UUID `json:"event_id" gorm:"type:uuid;uniqueIndex;not null"`
|
EventId uuid.UUID `json:"event_id" gorm:"type:uuid;uniqueIndex;not null"`
|
||||||
Name string `json:"name" gorm:"type:varchar(255);index;not null"`
|
Name string `json:"name" gorm:"type:varchar(255);index;not null"`
|
||||||
Type string `json:"type" gotm:"type:varchar(255);index;not null"`
|
Type string `json:"type" gotm:"type:varchar(255);index;not null"` // official | party
|
||||||
Description string `json:"description" gorm:"type:text;not null"`
|
Description string `json:"description" gorm:"type:text;not null"`
|
||||||
StartTime time.Time `json:"start_time" gorm:"index"`
|
StartTime time.Time `json:"start_time" gorm:"index"`
|
||||||
EndTime time.Time `json:"end_time" gorm:"index"`
|
EndTime time.Time `json:"end_time" gorm:"index"`
|
||||||
|
Thumbnail string `json:"thumbnail" gorm:"type:varchar(255)"`
|
||||||
Owner uuid.UUID `json:"owner" gorm:"type:uuid;index;not null"`
|
Owner uuid.UUID `json:"owner" gorm:"type:uuid;index;not null"`
|
||||||
EnableKYC bool `json:"enable_kyc" gorm:"not null"`
|
EnableKYC bool `json:"enable_kyc" gorm:"not null"`
|
||||||
}
|
}
|
||||||
@@ -28,6 +29,7 @@ type EventIndexDoc struct {
|
|||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
StartTime time.Time `json:"start_time"`
|
StartTime time.Time `json:"start_time"`
|
||||||
EndTime time.Time `json:"end_time"`
|
EndTime time.Time `json:"end_time"`
|
||||||
|
Thumbnail string `json:"thumbnail"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *Event) GetEventById(ctx context.Context, eventId uuid.UUID) (*Event, error) {
|
func (self *Event) GetEventById(ctx context.Context, eventId uuid.UUID) (*Event, error) {
|
||||||
@@ -86,15 +88,6 @@ func (self *Event) Create(ctx context.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *Event) GetFullTable(ctx context.Context) (*[]Event, error) {
|
|
||||||
var events []Event
|
|
||||||
err := Database.WithContext(ctx).Find(&events).Error
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &events, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (self *Event) FastListEvents(ctx context.Context, limit, offset int64) (*[]EventIndexDoc, error) {
|
func (self *Event) FastListEvents(ctx context.Context, limit, offset int64) (*[]EventIndexDoc, error) {
|
||||||
var results []EventIndexDoc
|
var results []EventIndexDoc
|
||||||
|
|
||||||
|
|||||||
@@ -135,15 +135,6 @@ func (self *User) UpdateByUserID(ctx context.Context, userId *uuid.UUID, updates
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *User) GetFullTable(ctx context.Context) (*[]User, error) {
|
|
||||||
var users []User
|
|
||||||
err := Database.WithContext(ctx).Find(&users).Error
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &users, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (self *User) FastListUsers(ctx context.Context, limit, offset *int) (*[]UserIndexDoc, error) {
|
func (self *User) FastListUsers(ctx context.Context, limit, offset *int) (*[]UserIndexDoc, error) {
|
||||||
var results []UserIndexDoc
|
var results []UserIndexDoc
|
||||||
|
|
||||||
|
|||||||
19
docs/docs.go
19
docs/docs.go
@@ -809,7 +809,7 @@ const docTemplate = `{
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"data": {
|
"data": {
|
||||||
"$ref": "#/definitions/service_event.EventInfoResponse"
|
"$ref": "#/definitions/data.EventIndexDoc"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1280,6 +1280,9 @@ const docTemplate = `{
|
|||||||
"start_time": {
|
"start_time": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"thumbnail": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"type": {
|
"type": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
@@ -1415,20 +1418,6 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"service_event.EventInfoResponse": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"end_time": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"start_time": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"service_user.UserInfoData": {
|
"service_user.UserInfoData": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|||||||
@@ -807,7 +807,7 @@
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"data": {
|
"data": {
|
||||||
"$ref": "#/definitions/service_event.EventInfoResponse"
|
"$ref": "#/definitions/data.EventIndexDoc"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1278,6 +1278,9 @@
|
|||||||
"start_time": {
|
"start_time": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"thumbnail": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"type": {
|
"type": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
@@ -1413,20 +1416,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"service_event.EventInfoResponse": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"end_time": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"start_time": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"service_user.UserInfoData": {
|
"service_user.UserInfoData": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ definitions:
|
|||||||
type: string
|
type: string
|
||||||
start_time:
|
start_time:
|
||||||
type: string
|
type: string
|
||||||
|
thumbnail:
|
||||||
|
type: string
|
||||||
type:
|
type:
|
||||||
type: string
|
type: string
|
||||||
type: object
|
type: object
|
||||||
@@ -98,15 +100,6 @@ definitions:
|
|||||||
checkin_code:
|
checkin_code:
|
||||||
type: string
|
type: string
|
||||||
type: object
|
type: object
|
||||||
service_event.EventInfoResponse:
|
|
||||||
properties:
|
|
||||||
end_time:
|
|
||||||
type: string
|
|
||||||
name:
|
|
||||||
type: string
|
|
||||||
start_time:
|
|
||||||
type: string
|
|
||||||
type: object
|
|
||||||
service_user.UserInfoData:
|
service_user.UserInfoData:
|
||||||
properties:
|
properties:
|
||||||
allow_public:
|
allow_public:
|
||||||
@@ -591,7 +584,7 @@ paths:
|
|||||||
- $ref: '#/definitions/utils.RespStatus'
|
- $ref: '#/definitions/utils.RespStatus'
|
||||||
- properties:
|
- properties:
|
||||||
data:
|
data:
|
||||||
$ref: '#/definitions/service_event.EventInfoResponse'
|
$ref: '#/definitions/data.EventIndexDoc'
|
||||||
type: object
|
type: object
|
||||||
"400":
|
"400":
|
||||||
description: Invalid Input
|
description: Invalid Input
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import (
|
|||||||
"nixcn-cms/data"
|
"nixcn-cms/data"
|
||||||
"nixcn-cms/internal/exception"
|
"nixcn-cms/internal/exception"
|
||||||
"nixcn-cms/service/shared"
|
"nixcn-cms/service/shared"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
@@ -19,15 +18,9 @@ type EventInfoPayload struct {
|
|||||||
Data *EventInfoData
|
Data *EventInfoData
|
||||||
}
|
}
|
||||||
|
|
||||||
type EventInfoResponse struct {
|
|
||||||
Name string `json:"name"`
|
|
||||||
StartTime time.Time `json:"start_time"`
|
|
||||||
EndTime time.Time `json:"end_time"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type EventInfoResult struct {
|
type EventInfoResult struct {
|
||||||
Common shared.CommonResult
|
Common shared.CommonResult
|
||||||
Data *EventInfoResponse
|
Data *data.EventIndexDoc
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *EventServiceImpl) GetEventInfo(payload *EventInfoPayload) (result *EventInfoResult) {
|
func (self *EventServiceImpl) GetEventInfo(payload *EventInfoPayload) (result *EventInfoResult) {
|
||||||
@@ -63,10 +56,14 @@ func (self *EventServiceImpl) GetEventInfo(payload *EventInfoPayload) (result *E
|
|||||||
SetOriginal(exception.CommonSuccess).
|
SetOriginal(exception.CommonSuccess).
|
||||||
Throw(payload.Context),
|
Throw(payload.Context),
|
||||||
},
|
},
|
||||||
Data: &EventInfoResponse{
|
Data: &data.EventIndexDoc{
|
||||||
Name: event.Name,
|
EventId: event.EventId.String(),
|
||||||
StartTime: event.StartTime,
|
Name: event.Name,
|
||||||
EndTime: event.EndTime,
|
Type: event.Type,
|
||||||
|
Description: event.Description,
|
||||||
|
StartTime: event.StartTime,
|
||||||
|
EndTime: event.EndTime,
|
||||||
|
Thumbnail: event.Thumbnail,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
17
service/service_event/join_event.go
Normal file
17
service/service_event/join_event.go
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
package service_event
|
||||||
|
|
||||||
|
import "nixcn-cms/service/shared"
|
||||||
|
|
||||||
|
type EventJoinData struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
type EventJoinPayload struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
type EventJoinResult struct {
|
||||||
|
Common shared.CommonResult
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *EventServiceImpl) JoinEvent(payload *EventJoinPayload) (result *EventJoinResult) {
|
||||||
|
return
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ type EventService interface {
|
|||||||
CheckinQuery(*CheckinQueryPayload) *CheckinQueryResult
|
CheckinQuery(*CheckinQueryPayload) *CheckinQueryResult
|
||||||
GetEventInfo(*EventInfoPayload) *EventInfoResult
|
GetEventInfo(*EventInfoPayload) *EventInfoResult
|
||||||
ListEvents(*EventListPayload) *EventListResult
|
ListEvents(*EventListPayload) *EventListResult
|
||||||
|
JoinEvent(*EventJoinPayload) *EventJoinResult
|
||||||
}
|
}
|
||||||
|
|
||||||
type EventServiceImpl struct{}
|
type EventServiceImpl struct{}
|
||||||
|
|||||||
Reference in New Issue
Block a user