WIP Add join_event in service_event
Signed-off-by: Asai Neko <sugar@sne.moe>
This commit is contained in:
@@ -17,7 +17,7 @@ import (
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @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 404 {object} utils.RespStatus{data=nil} "Event Not Found"
|
||||
// @Failure 500 {object} utils.RespStatus{data=nil} "Internal Server Error"
|
||||
|
||||
@@ -20,7 +20,7 @@ type Attendance struct {
|
||||
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"`
|
||||
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"`
|
||||
CheckinAt time.Time `json:"checkin_at"`
|
||||
}
|
||||
@@ -33,6 +33,31 @@ type AttendanceSearchDoc struct {
|
||||
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) {
|
||||
var checkin Attendance
|
||||
|
||||
@@ -105,7 +130,7 @@ func (self *Attendance) Create(ctx context.Context) error {
|
||||
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
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
updates := map[string]any{}
|
||||
|
||||
if checkinTime != nil {
|
||||
updates["checkin_at"] = *checkinTime
|
||||
}
|
||||
|
||||
if len(updates) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := tx.
|
||||
Model(&attendance).
|
||||
Updates(updates).Error; err != nil {
|
||||
Updates(self).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -196,8 +211,8 @@ func (self *Attendance) VerifyCheckinCode(ctx context.Context, checkinCode strin
|
||||
return err
|
||||
}
|
||||
|
||||
time := time.Now()
|
||||
_, err = self.Update(ctx, attendanceData.AttendanceId, &time)
|
||||
self.CheckinAt = time.Now()
|
||||
_, err = self.Update(ctx, attendanceData.AttendanceId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -13,10 +13,11 @@ type Event struct {
|
||||
UUID uuid.UUID `json:"uuid" 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"`
|
||||
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"`
|
||||
StartTime time.Time `json:"start_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"`
|
||||
EnableKYC bool `json:"enable_kyc" gorm:"not null"`
|
||||
}
|
||||
@@ -28,6 +29,7 @@ type EventIndexDoc struct {
|
||||
Description string `json:"description"`
|
||||
StartTime time.Time `json:"start_time"`
|
||||
EndTime time.Time `json:"end_time"`
|
||||
Thumbnail string `json:"thumbnail"`
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
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) {
|
||||
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) {
|
||||
var results []UserIndexDoc
|
||||
|
||||
|
||||
19
docs/docs.go
19
docs/docs.go
@@ -809,7 +809,7 @@ const docTemplate = `{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"$ref": "#/definitions/service_event.EventInfoResponse"
|
||||
"$ref": "#/definitions/data.EventIndexDoc"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1280,6 +1280,9 @@ const docTemplate = `{
|
||||
"start_time": {
|
||||
"type": "string"
|
||||
},
|
||||
"thumbnail": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"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": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
@@ -807,7 +807,7 @@
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"$ref": "#/definitions/service_event.EventInfoResponse"
|
||||
"$ref": "#/definitions/data.EventIndexDoc"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1278,6 +1278,9 @@
|
||||
"start_time": {
|
||||
"type": "string"
|
||||
},
|
||||
"thumbnail": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"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": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
@@ -12,6 +12,8 @@ definitions:
|
||||
type: string
|
||||
start_time:
|
||||
type: string
|
||||
thumbnail:
|
||||
type: string
|
||||
type:
|
||||
type: string
|
||||
type: object
|
||||
@@ -98,15 +100,6 @@ definitions:
|
||||
checkin_code:
|
||||
type: string
|
||||
type: object
|
||||
service_event.EventInfoResponse:
|
||||
properties:
|
||||
end_time:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
start_time:
|
||||
type: string
|
||||
type: object
|
||||
service_user.UserInfoData:
|
||||
properties:
|
||||
allow_public:
|
||||
@@ -591,7 +584,7 @@ paths:
|
||||
- $ref: '#/definitions/utils.RespStatus'
|
||||
- properties:
|
||||
data:
|
||||
$ref: '#/definitions/service_event.EventInfoResponse'
|
||||
$ref: '#/definitions/data.EventIndexDoc'
|
||||
type: object
|
||||
"400":
|
||||
description: Invalid Input
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"nixcn-cms/data"
|
||||
"nixcn-cms/internal/exception"
|
||||
"nixcn-cms/service/shared"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
@@ -19,15 +18,9 @@ type EventInfoPayload struct {
|
||||
Data *EventInfoData
|
||||
}
|
||||
|
||||
type EventInfoResponse struct {
|
||||
Name string `json:"name"`
|
||||
StartTime time.Time `json:"start_time"`
|
||||
EndTime time.Time `json:"end_time"`
|
||||
}
|
||||
|
||||
type EventInfoResult struct {
|
||||
Common shared.CommonResult
|
||||
Data *EventInfoResponse
|
||||
Data *data.EventIndexDoc
|
||||
}
|
||||
|
||||
func (self *EventServiceImpl) GetEventInfo(payload *EventInfoPayload) (result *EventInfoResult) {
|
||||
@@ -63,10 +56,14 @@ func (self *EventServiceImpl) GetEventInfo(payload *EventInfoPayload) (result *E
|
||||
SetOriginal(exception.CommonSuccess).
|
||||
Throw(payload.Context),
|
||||
},
|
||||
Data: &EventInfoResponse{
|
||||
Data: &data.EventIndexDoc{
|
||||
EventId: event.EventId.String(),
|
||||
Name: event.Name,
|
||||
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
|
||||
GetEventInfo(*EventInfoPayload) *EventInfoResult
|
||||
ListEvents(*EventListPayload) *EventListResult
|
||||
JoinEvent(*EventJoinPayload) *EventJoinResult
|
||||
}
|
||||
|
||||
type EventServiceImpl struct{}
|
||||
|
||||
Reference in New Issue
Block a user