Add attendance id resp for event join api, set root api to /app/api/v1
Signed-off-by: Asai Neko <sugar@sne.moe>
This commit is contained in:
@@ -15,13 +15,13 @@ import (
|
||||
// @Tags Event
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param request body service_event.EventJoinData true "Event Join Details (UserId and EventId are required)"
|
||||
// @Param X-Api-Version header string true "latest"
|
||||
// @Success 200 {object} utils.RespStatus{data=nil} "Successfully joined the event"
|
||||
// @Failure 400 {object} utils.RespStatus{data=nil} "Invalid Input or UUID Parse Failed"
|
||||
// @Failure 401 {object} utils.RespStatus{data=nil} "Missing User ID / Unauthorized"
|
||||
// @Failure 403 {object} utils.RespStatus{data=nil} "Unauthorized / Missing User ID / Event Limit Exceeded"
|
||||
// @Failure 500 {object} utils.RespStatus{data=nil} "Internal Server Error / Database Error"
|
||||
// @Param request body service_event.EventJoinData true "Event Join Details (UserId and EventId are required)"
|
||||
// @Param X-Api-Version header string true "latest"
|
||||
// @Success 200 {object} utils.RespStatus{data=service_event.EventJoinResponse} "Successfully joined the event"
|
||||
// @Failure 400 {object} utils.RespStatus{data=nil} "Invalid Input or UUID Parse Failed"
|
||||
// @Failure 401 {object} utils.RespStatus{data=nil} "Missing User ID / Unauthorized"
|
||||
// @Failure 403 {object} utils.RespStatus{data=nil} "Unauthorized / Missing User ID / Event Limit Exceeded"
|
||||
// @Failure 500 {object} utils.RespStatus{data=nil} "Internal Server Error / Database Error"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /event/join [post]
|
||||
func (self *EventHandler) Join(c *gin.Context) {
|
||||
|
||||
@@ -112,7 +112,7 @@ func (self *Attendance) GetEventsByUserID(ctx context.Context, userID uuid.UUID)
|
||||
return &result, err
|
||||
}
|
||||
|
||||
func (self *Attendance) Create(ctx context.Context) error {
|
||||
func (self *Attendance) Create(ctx context.Context) (uuid.UUID, error) {
|
||||
self.UUID = uuid.New()
|
||||
self.AttendanceId = uuid.New()
|
||||
|
||||
@@ -124,10 +124,10 @@ func (self *Attendance) Create(ctx context.Context) error {
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
return uuid.Nil, err
|
||||
}
|
||||
|
||||
return nil
|
||||
return self.AttendanceId, nil
|
||||
}
|
||||
|
||||
func (self *Attendance) GetAttendanceListByEventId(ctx context.Context, eventId uuid.UUID) (*[]Attendance, error) {
|
||||
|
||||
10
docs/docs.go
10
docs/docs.go
@@ -1104,7 +1104,7 @@ const docTemplate = `{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"type": "object"
|
||||
"$ref": "#/definitions/service_event.EventJoinResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2186,6 +2186,14 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"service_event.EventJoinResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"attendance_id": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"service_kyc.KycQueryData": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
@@ -1102,7 +1102,7 @@
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"type": "object"
|
||||
"$ref": "#/definitions/service_event.EventJoinResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2184,6 +2184,14 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"service_event.EventJoinResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"attendance_id": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"service_kyc.KycQueryData": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
@@ -125,6 +125,11 @@ definitions:
|
||||
kyc_id:
|
||||
type: string
|
||||
type: object
|
||||
service_event.EventJoinResponse:
|
||||
properties:
|
||||
attendance_id:
|
||||
type: string
|
||||
type: object
|
||||
service_kyc.KycQueryData:
|
||||
properties:
|
||||
kyc_id:
|
||||
@@ -808,7 +813,7 @@ paths:
|
||||
- $ref: '#/definitions/utils.RespStatus'
|
||||
- properties:
|
||||
data:
|
||||
type: object
|
||||
$ref: '#/definitions/service_event.EventJoinResponse'
|
||||
type: object
|
||||
"400":
|
||||
description: Invalid Input or UUID Parse Failed
|
||||
|
||||
@@ -28,7 +28,7 @@ import (
|
||||
// @license.name Apache 2.0
|
||||
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
// @host localhost:8000
|
||||
// @BasePath /api/v1
|
||||
// @BasePath /app/api/v1
|
||||
// @schemes http https
|
||||
func Start(ctx context.Context) {
|
||||
if !viper.GetBool("server.debug_mode") {
|
||||
@@ -46,7 +46,7 @@ func Start(ctx context.Context) {
|
||||
|
||||
r.Use(gin.Recovery())
|
||||
|
||||
api.Handler(r.Group("/api/v1"))
|
||||
api.Handler(r.Group("/app/api/v1"))
|
||||
|
||||
// Start http server
|
||||
server := &http.Server{
|
||||
|
||||
@@ -24,8 +24,13 @@ type EventJoinPayload struct {
|
||||
Data *EventJoinData
|
||||
}
|
||||
|
||||
type EventJoinResponse struct {
|
||||
AttendanceId string `json:"attendance_id"`
|
||||
}
|
||||
|
||||
type EventJoinResult struct {
|
||||
Common shared.CommonResult
|
||||
Data *EventJoinResponse
|
||||
}
|
||||
|
||||
func (self *EventServiceImpl) JoinEvent(payload *EventJoinPayload) (result *EventJoinResult) {
|
||||
@@ -49,6 +54,7 @@ func (self *EventServiceImpl) JoinEvent(payload *EventJoinPayload) (result *Even
|
||||
HttpCode: 400,
|
||||
Exception: exception,
|
||||
},
|
||||
Data: nil,
|
||||
}
|
||||
|
||||
return
|
||||
@@ -71,6 +77,7 @@ func (self *EventServiceImpl) JoinEvent(payload *EventJoinPayload) (result *Even
|
||||
HttpCode: 500,
|
||||
Exception: exception,
|
||||
},
|
||||
Data: nil,
|
||||
}
|
||||
|
||||
return
|
||||
@@ -91,6 +98,7 @@ func (self *EventServiceImpl) JoinEvent(payload *EventJoinPayload) (result *Even
|
||||
HttpCode: 400,
|
||||
Exception: exception,
|
||||
},
|
||||
Data: nil,
|
||||
}
|
||||
|
||||
return
|
||||
@@ -112,6 +120,7 @@ func (self *EventServiceImpl) JoinEvent(payload *EventJoinPayload) (result *Even
|
||||
HttpCode: 400,
|
||||
Exception: exception,
|
||||
},
|
||||
Data: nil,
|
||||
}
|
||||
|
||||
return
|
||||
@@ -132,6 +141,7 @@ func (self *EventServiceImpl) JoinEvent(payload *EventJoinPayload) (result *Even
|
||||
SetError(err).
|
||||
Throw(payload.Context),
|
||||
},
|
||||
Data: nil,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,6 +158,7 @@ func (self *EventServiceImpl) JoinEvent(payload *EventJoinPayload) (result *Even
|
||||
SetError(errors.New("user already joined this event")).
|
||||
Throw(payload.Context),
|
||||
},
|
||||
Data: nil,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,6 +178,7 @@ func (self *EventServiceImpl) JoinEvent(payload *EventJoinPayload) (result *Even
|
||||
SetError(err).
|
||||
Throw(payload.Context),
|
||||
},
|
||||
Data: nil,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,6 +196,7 @@ func (self *EventServiceImpl) JoinEvent(payload *EventJoinPayload) (result *Even
|
||||
SetError(errors.New("event limit exceeded")).
|
||||
Throw(payload.Context),
|
||||
},
|
||||
Data: nil,
|
||||
}
|
||||
}
|
||||
attendenceData.SetState("out_of_limit")
|
||||
@@ -192,7 +205,7 @@ func (self *EventServiceImpl) JoinEvent(payload *EventJoinPayload) (result *Even
|
||||
}
|
||||
attendenceData.SetRole("normal")
|
||||
|
||||
err = attendenceData.Create(payload.Context)
|
||||
attendanceId, err := attendenceData.Create(payload.Context)
|
||||
if err != nil {
|
||||
return &EventJoinResult{
|
||||
Common: shared.CommonResult{
|
||||
@@ -206,6 +219,7 @@ func (self *EventServiceImpl) JoinEvent(payload *EventJoinPayload) (result *Even
|
||||
SetError(err).
|
||||
Throw(payload.Context),
|
||||
},
|
||||
Data: nil,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,6 +237,9 @@ func (self *EventServiceImpl) JoinEvent(payload *EventJoinPayload) (result *Even
|
||||
HttpCode: 200,
|
||||
Exception: exception,
|
||||
},
|
||||
Data: &EventJoinResponse{
|
||||
AttendanceId: attendanceId.String(),
|
||||
},
|
||||
}
|
||||
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user