Enhance Notification and User Models with New Fields and Update Swagger Documentation

- Added 'image' and 'link' fields to the NotificationRequest and NotificationResponse structures, improving the flexibility of notification content.
- Updated the 'created_at', 'updated_at', and 'schedule_at' fields to use integer types for Unix timestamps, ensuring consistency in time handling.
- Expanded the tender status enumeration to include 'closed', 'modified', 'suspended', and 'published', enhancing the representation of tender states.
- Reflected these changes in the Swagger documentation, ensuring accurate API specifications for clients.
This commit is contained in:
n.nakhostin
2025-10-16 16:47:36 +03:30
parent fe3ed00a24
commit 952986331a
9 changed files with 72 additions and 11 deletions
+16 -4
View File
@@ -7987,6 +7987,9 @@ const docTemplate = `{
"description": { "description": {
"type": "string" "type": "string"
}, },
"image": {
"type": "string"
},
"link": { "link": {
"type": "string" "type": "string"
}, },
@@ -8020,7 +8023,7 @@ const docTemplate = `{
"type": "object", "type": "object",
"properties": { "properties": {
"created_at": { "created_at": {
"type": "string" "type": "integer"
}, },
"event_type": { "event_type": {
"type": "string" "type": "string"
@@ -8053,6 +8056,7 @@ const docTemplate = `{
"priority": { "priority": {
"type": "string" "type": "string"
}, },
"recipient": {},
"schedule_at": { "schedule_at": {
"type": "integer" "type": "integer"
}, },
@@ -8075,7 +8079,7 @@ const docTemplate = `{
"type": "string" "type": "string"
}, },
"updated_at": { "updated_at": {
"type": "string" "type": "integer"
}, },
"user_id": { "user_id": {
"type": "string" "type": "string"
@@ -8355,14 +8359,22 @@ const docTemplate = `{
"expired", "expired",
"cancelled", "cancelled",
"awarded", "awarded",
"draft" "draft",
"closed",
"modified",
"suspended",
"published"
], ],
"x-enum-varnames": [ "x-enum-varnames": [
"TenderStatusActive", "TenderStatusActive",
"TenderStatusExpired", "TenderStatusExpired",
"TenderStatusCancelled", "TenderStatusCancelled",
"TenderStatusAwarded", "TenderStatusAwarded",
"TenderStatusDraft" "TenderStatusDraft",
"TenderStatusClosed",
"TenderStatusModified",
"TenderStatusSuspended",
"TenderStatusPublished"
] ]
}, },
"tender.UpdateTenderRequest": { "tender.UpdateTenderRequest": {
+16 -4
View File
@@ -7979,6 +7979,9 @@
"description": { "description": {
"type": "string" "type": "string"
}, },
"image": {
"type": "string"
},
"link": { "link": {
"type": "string" "type": "string"
}, },
@@ -8012,7 +8015,7 @@
"type": "object", "type": "object",
"properties": { "properties": {
"created_at": { "created_at": {
"type": "string" "type": "integer"
}, },
"event_type": { "event_type": {
"type": "string" "type": "string"
@@ -8045,6 +8048,7 @@
"priority": { "priority": {
"type": "string" "type": "string"
}, },
"recipient": {},
"schedule_at": { "schedule_at": {
"type": "integer" "type": "integer"
}, },
@@ -8067,7 +8071,7 @@
"type": "string" "type": "string"
}, },
"updated_at": { "updated_at": {
"type": "string" "type": "integer"
}, },
"user_id": { "user_id": {
"type": "string" "type": "string"
@@ -8347,14 +8351,22 @@
"expired", "expired",
"cancelled", "cancelled",
"awarded", "awarded",
"draft" "draft",
"closed",
"modified",
"suspended",
"published"
], ],
"x-enum-varnames": [ "x-enum-varnames": [
"TenderStatusActive", "TenderStatusActive",
"TenderStatusExpired", "TenderStatusExpired",
"TenderStatusCancelled", "TenderStatusCancelled",
"TenderStatusAwarded", "TenderStatusAwarded",
"TenderStatusDraft" "TenderStatusDraft",
"TenderStatusClosed",
"TenderStatusModified",
"TenderStatusSuspended",
"TenderStatusPublished"
] ]
}, },
"tender.UpdateTenderRequest": { "tender.UpdateTenderRequest": {
+13 -2
View File
@@ -719,6 +719,8 @@ definitions:
type: array type: array
description: description:
type: string type: string
image:
type: string
link: link:
type: string type: string
priority: priority:
@@ -741,7 +743,7 @@ definitions:
internal_notification.NotificationResponse: internal_notification.NotificationResponse:
properties: properties:
created_at: created_at:
type: string type: integer
event_type: event_type:
type: string type: string
id: id:
@@ -763,6 +765,7 @@ definitions:
type: object type: object
priority: priority:
type: string type: string
recipient: {}
schedule_at: schedule_at:
type: integer type: integer
scheduled_at: scheduled_at:
@@ -778,7 +781,7 @@ definitions:
type: type:
type: string type: string
updated_at: updated_at:
type: string type: integer
user_id: user_id:
type: string type: string
type: object type: object
@@ -974,6 +977,10 @@ definitions:
- cancelled - cancelled
- awarded - awarded
- draft - draft
- closed
- modified
- suspended
- published
type: string type: string
x-enum-varnames: x-enum-varnames:
- TenderStatusActive - TenderStatusActive
@@ -981,6 +988,10 @@ definitions:
- TenderStatusCancelled - TenderStatusCancelled
- TenderStatusAwarded - TenderStatusAwarded
- TenderStatusDraft - TenderStatusDraft
- TenderStatusClosed
- TenderStatusModified
- TenderStatusSuspended
- TenderStatusPublished
tender.UpdateTenderRequest: tender.UpdateTenderRequest:
properties: properties:
currency: currency:
+1
View File
@@ -15,6 +15,7 @@ type NotificationRequest struct {
Title string `json:"title" valid:"required"` Title string `json:"title" valid:"required"`
Description string `json:"description" valid:"required"` Description string `json:"description" valid:"required"`
Link *string `json:"link" valid:"optional,url"` Link *string `json:"link" valid:"optional,url"`
Image *string `json:"image" valid:"optional,url"`
ScheduleAt int64 `json:"schedule_at" valid:"optional"` ScheduleAt int64 `json:"schedule_at" valid:"optional"`
} }
+1 -1
View File
@@ -50,7 +50,7 @@ func (h *NotificationHandler) Send(c echo.Context) error {
} }
// Send notification // Send notification
go h.service.Send(context.Background(), &req) h.service.Send(context.Background(), &req)
return response.Created(c, nil, "Notification sent successfully") return response.Created(c, nil, "Notification sent successfully")
} }
+10
View File
@@ -54,6 +54,8 @@ func (s *notificationService) Send(ctx context.Context, req *NotificationRequest
"recipient": req.Recipient, "recipient": req.Recipient,
"type": req.Type, "type": req.Type,
"priority": req.Priority, "priority": req.Priority,
"link": req.Link,
"image": req.Image,
}) })
if req.Target == TargetAudienceAllUsers || req.Target == TargetAudienceSpecificUsers { if req.Target == TargetAudienceAllUsers || req.Target == TargetAudienceSpecificUsers {
@@ -71,6 +73,8 @@ func (s *notificationService) Send(ctx context.Context, req *NotificationRequest
Type: string(req.Type), Type: string(req.Type),
Priority: string(req.Priority), Priority: string(req.Priority),
EventType: notification.EventTypePush, EventType: notification.EventTypePush,
Link: *req.Link,
Image: *req.Image,
Metadata: map[string]any{ Metadata: map[string]any{
"tender": strings.TrimSpace(req.Tender), "tender": strings.TrimSpace(req.Tender),
}, },
@@ -92,6 +96,8 @@ func (s *notificationService) Send(ctx context.Context, req *NotificationRequest
Type: string(req.Type), Type: string(req.Type),
Priority: string(req.Priority), Priority: string(req.Priority),
EventType: notification.EventTypeEmail, EventType: notification.EventTypeEmail,
Link: *req.Link,
Image: *req.Image,
Metadata: map[string]any{ Metadata: map[string]any{
"tender": strings.TrimSpace(req.Tender), "tender": strings.TrimSpace(req.Tender),
}, },
@@ -118,6 +124,8 @@ func (s *notificationService) Send(ctx context.Context, req *NotificationRequest
Type: string(req.Type), Type: string(req.Type),
Priority: string(req.Priority), Priority: string(req.Priority),
EventType: notification.EventTypePush, EventType: notification.EventTypePush,
Link: *req.Link,
Image: *req.Image,
Methods: notification.NotificationMethods{ Methods: notification.NotificationMethods{
Push: v, Push: v,
}, },
@@ -138,6 +146,8 @@ func (s *notificationService) Send(ctx context.Context, req *NotificationRequest
Type: string(req.Type), Type: string(req.Type),
Priority: string(req.Priority), Priority: string(req.Priority),
EventType: notification.EventTypeEmail, EventType: notification.EventTypeEmail,
Link: *req.Link,
Image: *req.Image,
Methods: notification.NotificationMethods{ Methods: notification.NotificationMethods{
Email: recipient.Email, Email: recipient.Email,
}, },
+1
View File
@@ -132,6 +132,7 @@ func (u *User) ToResponse() *UserResponse {
Department: u.Department, Department: u.Department,
Position: u.Position, Position: u.Position,
Phone: u.Phone, Phone: u.Phone,
DeviceToken: u.DeviceToken,
ProfileImage: u.ProfileImage, ProfileImage: u.ProfileImage,
IsVerified: u.IsVerified, IsVerified: u.IsVerified,
LastLoginAt: u.LastLoginAt, LastLoginAt: u.LastLoginAt,
+2
View File
@@ -33,6 +33,8 @@ type NotificationRequest struct {
EventType EventType `json:"event_type"` EventType EventType `json:"event_type"`
Priority string `json:"priority"` Priority string `json:"priority"`
ScheduledAt int64 `json:"scheduled_at"` ScheduledAt int64 `json:"scheduled_at"`
Link string `json:"link"`
Image string `json:"image"`
Metadata map[string]any `json:"metadata"` Metadata map[string]any `json:"metadata"`
Methods NotificationMethods `json:"methods"` Methods NotificationMethods `json:"methods"`
} }
+12
View File
@@ -15,6 +15,8 @@ type Model struct {
Title string Title string
Type string Type string
Priority string Priority string
Link string
Image string
ScheduledAt int64 ScheduledAt int64
Recipient string Recipient string
UserID string UserID string
@@ -41,6 +43,8 @@ func (s *Service) SendEmail(ctx context.Context, model Model) (*NotificationResp
Type: model.Type, Type: model.Type,
Priority: model.Priority, Priority: model.Priority,
ScheduledAt: model.ScheduledAt, ScheduledAt: model.ScheduledAt,
Link: model.Link,
Image: model.Image,
Methods: NotificationMethods{ Methods: NotificationMethods{
Email: model.Recipient, Email: model.Recipient,
}, },
@@ -59,6 +63,8 @@ func (s *Service) SendSMS(ctx context.Context, model Model) (*NotificationRespon
Type: model.Type, Type: model.Type,
Priority: model.Priority, Priority: model.Priority,
ScheduledAt: model.ScheduledAt, ScheduledAt: model.ScheduledAt,
Link: model.Link,
Image: model.Image,
Methods: NotificationMethods{ Methods: NotificationMethods{
SMS: model.Recipient, SMS: model.Recipient,
}, },
@@ -77,6 +83,8 @@ func (s *Service) SendPush(ctx context.Context, model Model) (*NotificationRespo
Type: model.Type, Type: model.Type,
Priority: model.Priority, Priority: model.Priority,
ScheduledAt: model.ScheduledAt, ScheduledAt: model.ScheduledAt,
Link: model.Link,
Image: model.Image,
Methods: NotificationMethods{ Methods: NotificationMethods{
Push: model.Recipient, Push: model.Recipient,
}, },
@@ -95,6 +103,8 @@ func (s *Service) SendOTP(ctx context.Context, model Model) (*NotificationRespon
Type: model.Type, Type: model.Type,
Priority: model.Priority, Priority: model.Priority,
ScheduledAt: model.ScheduledAt, ScheduledAt: model.ScheduledAt,
Link: model.Link,
Image: model.Image,
Methods: NotificationMethods{ Methods: NotificationMethods{
OTP: model.Recipient, OTP: model.Recipient,
}, },
@@ -134,6 +144,8 @@ func (s *Service) Health(ctx context.Context) error {
Type: "info", Type: "info",
Priority: "low", Priority: "low",
ScheduledAt: 0, ScheduledAt: 0,
Link: "",
Image: "",
Methods: NotificationMethods{ Methods: NotificationMethods{
Email: "test@example.com", Email: "test@example.com",
}, },