Add user profile response for schedule_get service #13
@@ -19,7 +19,7 @@ import (
|
||||
// @Produce json
|
||||
// @Security Bearer
|
||||
// @Param event_id query string true "Event ID"
|
||||
// @Success 200 {object} utils.RespStatus{data=[]data.AgendaDoc}
|
||||
// @Success 200 {object} utils.RespStatus{data=[]service_agenda.AgendaListItem}
|
||||
// @Failure 400 {object} utils.RespStatus{data=nil} "Invalid Input"
|
||||
// @Failure 403 {object} utils.RespStatus{data=nil} "Agenda Not Published"
|
||||
// @Failure 404 {object} utils.RespStatus{data=nil} "Event Not Found"
|
||||
|
||||
30
docs/docs.go
30
docs/docs.go
@@ -415,7 +415,7 @@ const docTemplate = `{
|
||||
"data": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/data.AgendaDoc"
|
||||
"$ref": "#/definitions/service_agenda.AgendaListItem"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2631,7 +2631,7 @@ const docTemplate = `{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "Allows the event owner (Manager) to update name, subtitle, description, start_time, end_time, thumbnail, and is_agenda_published. Changes to type or enable_kyc are rejected. is_agenda_published is write-once: it can only be set to true (requires at least one agenda submission) and cannot be reverted.",
|
||||
"description": "Allows the event owner (Manager) to update name, subtitle, description, start_time, end_time, thumbnail, and is_agenda_published. Lv40+ users (admins) bypass the owner restriction and may update any event. Changes to type or enable_kyc are rejected. is_agenda_published is write-once: it can only be set to true (requires at least one agenda submission) and cannot be reverted.",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -3664,32 +3664,6 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"data.AgendaDoc": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"agenda_id": {
|
||||
"type": "string"
|
||||
},
|
||||
"attendance_id": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"end_time": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"start_time": {
|
||||
"type": "string"
|
||||
},
|
||||
"status": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"data.EventStatDoc": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
@@ -413,7 +413,7 @@
|
||||
"data": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/data.AgendaDoc"
|
||||
"$ref": "#/definitions/service_agenda.AgendaListItem"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2629,7 +2629,7 @@
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "Allows the event owner (Manager) to update name, subtitle, description, start_time, end_time, thumbnail, and is_agenda_published. Changes to type or enable_kyc are rejected. is_agenda_published is write-once: it can only be set to true (requires at least one agenda submission) and cannot be reverted.",
|
||||
"description": "Allows the event owner (Manager) to update name, subtitle, description, start_time, end_time, thumbnail, and is_agenda_published. Lv40+ users (admins) bypass the owner restriction and may update any event. Changes to type or enable_kyc are rejected. is_agenda_published is write-once: it can only be set to true (requires at least one agenda submission) and cannot be reverted.",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -3662,32 +3662,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"data.AgendaDoc": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"agenda_id": {
|
||||
"type": "string"
|
||||
},
|
||||
"attendance_id": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"end_time": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"start_time": {
|
||||
"type": "string"
|
||||
},
|
||||
"status": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"data.EventStatDoc": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
@@ -23,23 +23,6 @@ definitions:
|
||||
uuid:
|
||||
type: string
|
||||
type: object
|
||||
data.AgendaDoc:
|
||||
properties:
|
||||
agenda_id:
|
||||
type: string
|
||||
attendance_id:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
end_time:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
start_time:
|
||||
type: string
|
||||
status:
|
||||
type: string
|
||||
type: object
|
||||
data.EventStatDoc:
|
||||
properties:
|
||||
checkin_count:
|
||||
@@ -804,7 +787,7 @@ paths:
|
||||
- properties:
|
||||
data:
|
||||
items:
|
||||
$ref: '#/definitions/data.AgendaDoc'
|
||||
$ref: '#/definitions/service_agenda.AgendaListItem'
|
||||
type: array
|
||||
type: object
|
||||
"400":
|
||||
@@ -2018,9 +2001,10 @@ paths:
|
||||
consumes:
|
||||
- application/json
|
||||
description: 'Allows the event owner (Manager) to update name, subtitle, description,
|
||||
start_time, end_time, thumbnail, and is_agenda_published. Changes to type
|
||||
or enable_kyc are rejected. is_agenda_published is write-once: it can only
|
||||
be set to true (requires at least one agenda submission) and cannot be reverted.'
|
||||
start_time, end_time, thumbnail, and is_agenda_published. Lv40+ users (admins)
|
||||
bypass the owner restriction and may update any event. Changes to type or
|
||||
enable_kyc are rejected. is_agenda_published is write-once: it can only be
|
||||
set to true (requires at least one agenda submission) and cannot be reverted.'
|
||||
parameters:
|
||||
- description: Fields to update (all optional except event_id)
|
||||
in: body
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"nixcn-cms/internal/exception"
|
||||
"nixcn-cms/service/shared"
|
||||
"nixcn-cms/tracer"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
@@ -22,7 +23,7 @@ type AgendaScheduleGetPayload struct {
|
||||
|
||||
type AgendaScheduleGetResult struct {
|
||||
Common shared.CommonResult
|
||||
Data *[]data.AgendaDoc
|
||||
Data *[]AgendaListItem
|
||||
}
|
||||
|
||||
func (self *AgendaServiceImpl) ScheduleGet(payload *AgendaScheduleGetPayload) (result *AgendaScheduleGetResult) {
|
||||
@@ -93,6 +94,55 @@ func (self *AgendaServiceImpl) ScheduleGet(payload *AgendaScheduleGetPayload) (r
|
||||
return
|
||||
}
|
||||
|
||||
attendanceIds := make([]uuid.UUID, 0, len(*agendas))
|
||||
for _, a := range *agendas {
|
||||
attendanceIds = append(attendanceIds, a.AttendanceId)
|
||||
}
|
||||
|
||||
userProfiles, err := new(data.Attendance).GetUserProfilesByAttendanceIds(ctx, attendanceIds)
|
||||
if err != nil {
|
||||
exc := exception.New(
|
||||
exception.WithStatus(exception.StatusServer),
|
||||
exception.WithType(exception.TypeCommon),
|
||||
exception.WithOriginal(exception.CommonErrorDatabase),
|
||||
exception.WithError(err),
|
||||
).Throw(ctx)
|
||||
|
||||
result = &AgendaScheduleGetResult{
|
||||
Common: shared.CommonResult{HttpCode: 500, Exception: exc},
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
zero := time.Time{}
|
||||
items := make([]AgendaListItem, 0, len(*agendas))
|
||||
for _, a := range *agendas {
|
||||
profile := userProfiles[a.AttendanceId]
|
||||
|
||||
var startTime, endTime *time.Time
|
||||
if a.StartTime != zero {
|
||||
startTime = &a.StartTime
|
||||
}
|
||||
if a.EndTime != zero {
|
||||
endTime = &a.EndTime
|
||||
}
|
||||
|
||||
items = append(items, AgendaListItem{
|
||||
AgendaId: a.AgendaId,
|
||||
AttendanceId: a.AttendanceId,
|
||||
Name: a.Name,
|
||||
Description: a.Description,
|
||||
Status: a.Status,
|
||||
StartTime: startTime,
|
||||
EndTime: endTime,
|
||||
UserProfile: &AgendaUserProfile{
|
||||
UserId: profile.UserId,
|
||||
Nickname: profile.Nickname,
|
||||
Username: profile.Username,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
exc := exception.New(
|
||||
exception.WithStatus(exception.StatusSuccess),
|
||||
exception.WithType(exception.TypeCommon),
|
||||
@@ -101,7 +151,7 @@ func (self *AgendaServiceImpl) ScheduleGet(payload *AgendaScheduleGetPayload) (r
|
||||
|
||||
result = &AgendaScheduleGetResult{
|
||||
Common: shared.CommonResult{HttpCode: 200, Exception: exc},
|
||||
Data: agendas,
|
||||
Data: &items,
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user