fix: type overriding
This commit is contained in:
@ -11,14 +11,13 @@ import (
|
||||
"gitea.local/admin/hspguard/internal/web"
|
||||
"github.com/go-chi/chi/v5"
|
||||
"github.com/google/uuid"
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
)
|
||||
|
||||
type ApiServiceDTO struct {
|
||||
ID uuid.UUID `json:"id"`
|
||||
ClientID string `json:"client_id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Description *string `json:"description"`
|
||||
RedirectUris []string `json:"redirect_uris"`
|
||||
Scopes []string `json:"scopes"`
|
||||
GrantTypes []string `json:"grant_types"`
|
||||
@ -32,7 +31,7 @@ func NewApiServiceDTO(service repository.ApiService) ApiServiceDTO {
|
||||
ID: service.ID,
|
||||
ClientID: service.ClientID,
|
||||
Name: service.Name,
|
||||
Description: service.Description.String,
|
||||
Description: service.Description,
|
||||
RedirectUris: service.RedirectUris,
|
||||
Scopes: service.Scopes,
|
||||
GrantTypes: service.GrantTypes,
|
||||
@ -129,10 +128,7 @@ func (h *AdminHandler) AddApiService(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
if req.Description != "" {
|
||||
params.Description = pgtype.Text{
|
||||
String: req.Description,
|
||||
Valid: true,
|
||||
}
|
||||
params.Description = &req.Description
|
||||
}
|
||||
|
||||
service, err := h.repo.CreateApiService(r.Context(), params)
|
||||
@ -262,12 +258,9 @@ func (h *AdminHandler) UpdateApiService(w http.ResponseWriter, r *http.Request)
|
||||
}
|
||||
|
||||
updated, err := h.repo.UpdateApiService(r.Context(), repository.UpdateApiServiceParams{
|
||||
ClientID: service.ClientID,
|
||||
Name: req.Name,
|
||||
Description: pgtype.Text{
|
||||
String: req.Description,
|
||||
Valid: true,
|
||||
},
|
||||
ClientID: service.ClientID,
|
||||
Name: req.Name,
|
||||
Description: &req.Description,
|
||||
RedirectUris: req.RedirectUris,
|
||||
Scopes: req.Scopes,
|
||||
GrantTypes: req.GrantTypes,
|
||||
|
Reference in New Issue
Block a user