Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions pkg/models/licenses.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ func (l *LicenseDB) ConvertToLicenseResponseDTO() LicenseResponseDTO {
response.Text = *l.Text
response.TextUpdatable = *l.TextUpdatable
response.Url = *l.Url
response.User = l.User
if l.User.Id != uuid.Nil {
response.User = &l.User
}

obligations := []string{}
for _, o := range l.Obligations {
Expand Down Expand Up @@ -177,7 +179,7 @@ type LicenseResponseDTO struct {
Risk int64 `json:"risk" example:"1"`
ExternalRef LicenseDBSchemaExtension `json:"external_ref"`
Obligations []string `json:"obligations"`
User User `json:"created_by"`
User *User `json:"created_by,omitempty"`
AddDate time.Time `json:"add_date"`
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/models/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ type SearchLicense struct {
// It has user id as a foreign key
type Audit struct {
Id uuid.UUID `json:"id" gorm:"primary_key;type:uuid;column:id;default:uuid_generate_v4()" swaggertype:"string" example:"f81d4fae-7dec-11d0-a765-00a0c91e6bf6"`
UserId uuid.UUID `json:"user_id" gorm:"type:uuid;column:user_id" example:"f81d4fae-7dec-11d0-a765-00a0c91e6bf6" swaggertype:"string"`
UserId uuid.UUID `json:"-" gorm:"type:uuid;column:user_id"`
User User `gorm:"foreignKey:UserId;references:Id" json:"user"`
Timestamp time.Time `json:"timestamp" gorm:"column:timestamp" example:"2023-12-01T18:10:25.00+05:30"`
Type string `json:"type" gorm:"column:type" enums:"OBLIGATION,LICENSE,USER" example:"LICENSE"`
Expand Down