mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
add log for endpoints
This commit is contained in:
@@ -17,6 +17,7 @@ import { TracingType } from '../../monitoring/opentelemetry/tracer';
|
||||
import { APINODReturn, APIReturn } from '../../decorator/api-validate-schema.decorator';
|
||||
import { EventListDataOutputDTOSchema, EventListOutputDTOSchema } from './model/eventListDTOOutput';
|
||||
import { EventToApproveDataOutputDTOSchema } from './model/eventToApproveListOutputDTO';
|
||||
import { EventOutputDTOSchema } from './model/eventDTOOutput';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -58,16 +59,23 @@ export class AgendaDataRepositoryService {
|
||||
}
|
||||
}
|
||||
|
||||
async getEventToApproveById(id: string) {
|
||||
async getEventToApproveById(id: string, tracing?: TracingType) {
|
||||
|
||||
try {
|
||||
const result = await this.agendaDataService.getEvent(id).pipe(
|
||||
map((response) => {
|
||||
return EventToApproveDetailsMapper.toDomain(response.data)
|
||||
APINODReturn(EventOutputDTOSchema, response, 'get/Events/${id}', tracing)
|
||||
return EventToApproveDetailsMapper.toDomain(response)
|
||||
})
|
||||
).toPromise()
|
||||
return ok(result)
|
||||
} catch (e) {
|
||||
if(isHttpError(e)) {
|
||||
tracing?.setAttribute('status.code', e.status.toString())
|
||||
} else {
|
||||
tracing?.setAttribute('map.error', 'true')
|
||||
tracing?.setAttribute('map.error.context', JSON.stringify(e))
|
||||
}
|
||||
return err(e as HttpErrorResponse)
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,9 @@ function getTextInsideParentheses(inputString) {
|
||||
export class EventMapper {
|
||||
|
||||
constructor() {}
|
||||
static toDomain(dto: EventOutputDTO) {
|
||||
static toDomain(_dto: EventOutputDTO) {
|
||||
|
||||
const dto = _dto.data;
|
||||
|
||||
let category;
|
||||
if(dto.category == EEventCategory.Oficial) {
|
||||
@@ -74,7 +76,7 @@ export class EventMapper {
|
||||
IsRequired: FEAttendeeType(e.attendeeType) == 'Required',
|
||||
UserType: "GD",
|
||||
// "IsPR": false,
|
||||
attendeeType: FEAttendeeType(e.attendeeType)
|
||||
attendeeType: FEAttendeeType(e.attendeeType)
|
||||
// "RoleDescription": null,
|
||||
// "RoleId": 0
|
||||
})),
|
||||
|
||||
@@ -16,7 +16,9 @@ function getTextInsideParentheses(inputString) {
|
||||
export class EventToApproveDetailsMapper {
|
||||
|
||||
constructor() {}
|
||||
static toDomain(dto: EventOutputDTO): EventToApproveDetails {
|
||||
static toDomain(_dto: EventOutputDTO): EventToApproveDetails {
|
||||
|
||||
let dto = _dto.data
|
||||
|
||||
let category;
|
||||
if(dto.category == EEventCategory.Oficial) {
|
||||
@@ -36,7 +38,7 @@ export class EventToApproveDetailsMapper {
|
||||
} else if(dto.ownerType == EEventOwnerType.Others) {
|
||||
ownerType = 'Other'
|
||||
}
|
||||
|
||||
|
||||
let activityInstanceName;
|
||||
let taskStatus;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { z } from 'zod';
|
||||
import { EAttendeeType, EEventCategory, EEventOwnerType, EEventStatus, EEventType } from './enums';
|
||||
|
||||
export const AttachmentInputDTOSchema = z.object({
|
||||
id: z.string().nullable(),
|
||||
@@ -7,7 +8,7 @@ export const AttachmentInputDTOSchema = z.object({
|
||||
description: z.string().nullable(),
|
||||
applicationId: z.number().int(),
|
||||
}).strict();
|
||||
const EAttendeeTypeDTO = z.enum(["Required", "Acknowledgment", "Optional"]);
|
||||
const EAttendeeTypeDTO = z.nativeEnum(EAttendeeType);
|
||||
|
||||
|
||||
const CommentSchema = z.object({
|
||||
@@ -18,7 +19,7 @@ const CommentSchema = z.object({
|
||||
const AttendeeSchema = z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
attendeeType: z.enum(["Required", "Acknowledgment", "Optional"]), // ["Required", "Acknowledgment", "Optional"] = [1,2,3]
|
||||
attendeeType: z.nativeEnum(EAttendeeType), // ["Required", "Acknowledgment", "Optional"] = [1,2,3]
|
||||
emailAddress: z.string(),
|
||||
wxUserId: z.number(),
|
||||
});
|
||||
@@ -47,27 +48,32 @@ const EventRecurrenceSchema = z.object({
|
||||
until: z.string()
|
||||
});
|
||||
|
||||
|
||||
export const EventOutputDTOSchema = z.object({
|
||||
id: z.string(),
|
||||
owner: OwnerSchema,
|
||||
ownerType: z.number(), // ["PR", "MD", "Other"] = [1,2,3],
|
||||
subject: z.string(),
|
||||
body: z.string(),
|
||||
location: z.string(),
|
||||
startDate: z.string(),
|
||||
endDate: z.string(),
|
||||
type: z.string(),
|
||||
category: z.number(), // ['Oficial', 'Pessoal'] = [1, 2]
|
||||
attendees: z.array(AttendeeSchema),
|
||||
isRecurring: z.boolean(),
|
||||
eventRecurrence: EventRecurrenceSchema,
|
||||
hasAttachments: z.boolean(),
|
||||
attachments: z.array(AttachmentInputDTOSchema),
|
||||
comments: z.array(CommentSchema),
|
||||
isPrivate: z.boolean(),
|
||||
isAllDayEvent: z.boolean(),
|
||||
organizer: OrganizerSchema,
|
||||
status: z.number(), // ['Pending', 'Revision', 'Approved', 'Declined', 'Communicated', 'ToCommunicate'] = [1, 2, 3, 4, 5, 6]
|
||||
});
|
||||
success: z.boolean(),
|
||||
message: z.string(),
|
||||
data: z.object({
|
||||
id: z.string(),
|
||||
owner: OwnerSchema,
|
||||
ownerType: z.nativeEnum(EEventOwnerType), // ["PR", "MD", "Other"] = [1,2,3],
|
||||
subject: z.string(),
|
||||
body: z.string(),
|
||||
location: z.string(),
|
||||
startDate: z.string(),
|
||||
endDate: z.string(),
|
||||
type: z.nativeEnum(EEventType),
|
||||
category: z.nativeEnum(EEventCategory), // ['Oficial', 'Pessoal'] = [1, 2]
|
||||
attendees: z.array(AttendeeSchema),
|
||||
isRecurring: z.boolean(),
|
||||
eventRecurrence: EventRecurrenceSchema,
|
||||
hasAttachments: z.boolean(),
|
||||
attachments: z.array(AttachmentInputDTOSchema),
|
||||
comments: z.array(CommentSchema),
|
||||
isPrivate: z.boolean(),
|
||||
isAllDayEvent: z.boolean(),
|
||||
organizer: OrganizerSchema,
|
||||
status: z.nativeEnum(EEventStatus), // ['Pending', 'Revision', 'Approved', 'Declined', 'Communicated', 'ToCommunicate'] = [1, 2, 3, 4, 5, 6]
|
||||
}),
|
||||
}).nullable();
|
||||
|
||||
export type EventOutputDTO = z.infer<typeof EventOutputDTOSchema>
|
||||
|
||||
@@ -1,15 +1,24 @@
|
||||
import { z } from "zod";
|
||||
import { EEventOwnerType, EEventType, EEventCategory, EEventStatus } from "./enums";
|
||||
|
||||
const OwnerSchema = z.object({
|
||||
wxUserId: z.number(),
|
||||
wxFullName: z.string(),
|
||||
wxeMail: z.string(),
|
||||
userPhoto: z.string(),
|
||||
});
|
||||
|
||||
|
||||
|
||||
const EventToApproveList = z.array(z.object({
|
||||
id: z.string().uuid(),
|
||||
owner: z.string().nullable(),
|
||||
owner: OwnerSchema,
|
||||
ownerType: z.nativeEnum(EEventOwnerType),
|
||||
subject: z.string(),
|
||||
body: z.string(),
|
||||
location: z.string().nullable(),
|
||||
startDate: z.string().datetime(),
|
||||
endDate: z.string().datetime(),
|
||||
startDate: z.string().datetime({ offset: true }),
|
||||
endDate: z.string().datetime({ offset: true }),
|
||||
type: z.nativeEnum(EEventType),
|
||||
category: z.nativeEnum(EEventCategory),
|
||||
isRecurring: z.boolean(),
|
||||
|
||||
Reference in New Issue
Block a user