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:
@@ -17,7 +17,7 @@ import (
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param request body service_event.EventJoinData true "Event Join Details (UserId and EventId are required)"
|
// @Param request body service_event.EventJoinData true "Event Join Details (UserId and EventId are required)"
|
||||||
// @Param X-Api-Version header string true "latest"
|
// @Param X-Api-Version header string true "latest"
|
||||||
// @Success 200 {object} utils.RespStatus{data=nil} "Successfully joined the event"
|
// @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 400 {object} utils.RespStatus{data=nil} "Invalid Input or UUID Parse Failed"
|
||||||
// @Failure 401 {object} utils.RespStatus{data=nil} "Missing User ID / Unauthorized"
|
// @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 403 {object} utils.RespStatus{data=nil} "Unauthorized / Missing User ID / Event Limit Exceeded"
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ func (self *Attendance) GetEventsByUserID(ctx context.Context, userID uuid.UUID)
|
|||||||
return &result, err
|
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.UUID = uuid.New()
|
||||||
self.AttendanceId = uuid.New()
|
self.AttendanceId = uuid.New()
|
||||||
|
|
||||||
@@ -124,10 +124,10 @@ func (self *Attendance) Create(ctx context.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
if err != 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) {
|
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",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"data": {
|
"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": {
|
"service_kyc.KycQueryData": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|||||||
@@ -1102,7 +1102,7 @@
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"data": {
|
"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": {
|
"service_kyc.KycQueryData": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|||||||
@@ -125,6 +125,11 @@ definitions:
|
|||||||
kyc_id:
|
kyc_id:
|
||||||
type: string
|
type: string
|
||||||
type: object
|
type: object
|
||||||
|
service_event.EventJoinResponse:
|
||||||
|
properties:
|
||||||
|
attendance_id:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
service_kyc.KycQueryData:
|
service_kyc.KycQueryData:
|
||||||
properties:
|
properties:
|
||||||
kyc_id:
|
kyc_id:
|
||||||
@@ -808,7 +813,7 @@ paths:
|
|||||||
- $ref: '#/definitions/utils.RespStatus'
|
- $ref: '#/definitions/utils.RespStatus'
|
||||||
- properties:
|
- properties:
|
||||||
data:
|
data:
|
||||||
type: object
|
$ref: '#/definitions/service_event.EventJoinResponse'
|
||||||
type: object
|
type: object
|
||||||
"400":
|
"400":
|
||||||
description: Invalid Input or UUID Parse Failed
|
description: Invalid Input or UUID Parse Failed
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import (
|
|||||||
// @license.name Apache 2.0
|
// @license.name Apache 2.0
|
||||||
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
|
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
// @host localhost:8000
|
// @host localhost:8000
|
||||||
// @BasePath /api/v1
|
// @BasePath /app/api/v1
|
||||||
// @schemes http https
|
// @schemes http https
|
||||||
func Start(ctx context.Context) {
|
func Start(ctx context.Context) {
|
||||||
if !viper.GetBool("server.debug_mode") {
|
if !viper.GetBool("server.debug_mode") {
|
||||||
@@ -46,7 +46,7 @@ func Start(ctx context.Context) {
|
|||||||
|
|
||||||
r.Use(gin.Recovery())
|
r.Use(gin.Recovery())
|
||||||
|
|
||||||
api.Handler(r.Group("/api/v1"))
|
api.Handler(r.Group("/app/api/v1"))
|
||||||
|
|
||||||
// Start http server
|
// Start http server
|
||||||
server := &http.Server{
|
server := &http.Server{
|
||||||
|
|||||||
@@ -24,8 +24,13 @@ type EventJoinPayload struct {
|
|||||||
Data *EventJoinData
|
Data *EventJoinData
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type EventJoinResponse struct {
|
||||||
|
AttendanceId string `json:"attendance_id"`
|
||||||
|
}
|
||||||
|
|
||||||
type EventJoinResult struct {
|
type EventJoinResult struct {
|
||||||
Common shared.CommonResult
|
Common shared.CommonResult
|
||||||
|
Data *EventJoinResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *EventServiceImpl) JoinEvent(payload *EventJoinPayload) (result *EventJoinResult) {
|
func (self *EventServiceImpl) JoinEvent(payload *EventJoinPayload) (result *EventJoinResult) {
|
||||||
@@ -49,6 +54,7 @@ func (self *EventServiceImpl) JoinEvent(payload *EventJoinPayload) (result *Even
|
|||||||
HttpCode: 400,
|
HttpCode: 400,
|
||||||
Exception: exception,
|
Exception: exception,
|
||||||
},
|
},
|
||||||
|
Data: nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
@@ -71,6 +77,7 @@ func (self *EventServiceImpl) JoinEvent(payload *EventJoinPayload) (result *Even
|
|||||||
HttpCode: 500,
|
HttpCode: 500,
|
||||||
Exception: exception,
|
Exception: exception,
|
||||||
},
|
},
|
||||||
|
Data: nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
@@ -91,6 +98,7 @@ func (self *EventServiceImpl) JoinEvent(payload *EventJoinPayload) (result *Even
|
|||||||
HttpCode: 400,
|
HttpCode: 400,
|
||||||
Exception: exception,
|
Exception: exception,
|
||||||
},
|
},
|
||||||
|
Data: nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
@@ -112,6 +120,7 @@ func (self *EventServiceImpl) JoinEvent(payload *EventJoinPayload) (result *Even
|
|||||||
HttpCode: 400,
|
HttpCode: 400,
|
||||||
Exception: exception,
|
Exception: exception,
|
||||||
},
|
},
|
||||||
|
Data: nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
@@ -132,6 +141,7 @@ func (self *EventServiceImpl) JoinEvent(payload *EventJoinPayload) (result *Even
|
|||||||
SetError(err).
|
SetError(err).
|
||||||
Throw(payload.Context),
|
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")).
|
SetError(errors.New("user already joined this event")).
|
||||||
Throw(payload.Context),
|
Throw(payload.Context),
|
||||||
},
|
},
|
||||||
|
Data: nil,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,6 +178,7 @@ func (self *EventServiceImpl) JoinEvent(payload *EventJoinPayload) (result *Even
|
|||||||
SetError(err).
|
SetError(err).
|
||||||
Throw(payload.Context),
|
Throw(payload.Context),
|
||||||
},
|
},
|
||||||
|
Data: nil,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,6 +196,7 @@ func (self *EventServiceImpl) JoinEvent(payload *EventJoinPayload) (result *Even
|
|||||||
SetError(errors.New("event limit exceeded")).
|
SetError(errors.New("event limit exceeded")).
|
||||||
Throw(payload.Context),
|
Throw(payload.Context),
|
||||||
},
|
},
|
||||||
|
Data: nil,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
attendenceData.SetState("out_of_limit")
|
attendenceData.SetState("out_of_limit")
|
||||||
@@ -192,7 +205,7 @@ func (self *EventServiceImpl) JoinEvent(payload *EventJoinPayload) (result *Even
|
|||||||
}
|
}
|
||||||
attendenceData.SetRole("normal")
|
attendenceData.SetRole("normal")
|
||||||
|
|
||||||
err = attendenceData.Create(payload.Context)
|
attendanceId, err := attendenceData.Create(payload.Context)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &EventJoinResult{
|
return &EventJoinResult{
|
||||||
Common: shared.CommonResult{
|
Common: shared.CommonResult{
|
||||||
@@ -206,6 +219,7 @@ func (self *EventServiceImpl) JoinEvent(payload *EventJoinPayload) (result *Even
|
|||||||
SetError(err).
|
SetError(err).
|
||||||
Throw(payload.Context),
|
Throw(payload.Context),
|
||||||
},
|
},
|
||||||
|
Data: nil,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,6 +237,9 @@ func (self *EventServiceImpl) JoinEvent(payload *EventJoinPayload) (result *Even
|
|||||||
HttpCode: 200,
|
HttpCode: 200,
|
||||||
Exception: exception,
|
Exception: exception,
|
||||||
},
|
},
|
||||||
|
Data: &EventJoinResponse{
|
||||||
|
AttendanceId: attendanceId.String(),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user