-
This commit is contained in:
@ -26,11 +26,11 @@ func NewApplicationRepository(db repository.DatabaseProvider) repository.Applica
|
||||
func (r *ApplicationRepository) Create(ctx context.Context, app *domain.Application) error {
|
||||
query := `
|
||||
INSERT INTO applications (
|
||||
app_id, app_link, type, callback_url, hmac_key,
|
||||
app_id, app_link, type, callback_url, hmac_key, token_prefix,
|
||||
token_renewal_duration, max_token_duration,
|
||||
owner_type, owner_name, owner_owner,
|
||||
created_at, updated_at
|
||||
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)
|
||||
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)
|
||||
`
|
||||
|
||||
db := r.db.GetDB().(*sql.DB)
|
||||
@ -48,6 +48,7 @@ func (r *ApplicationRepository) Create(ctx context.Context, app *domain.Applicat
|
||||
pq.Array(typeStrings),
|
||||
app.CallbackURL,
|
||||
app.HMACKey,
|
||||
app.TokenPrefix,
|
||||
app.TokenRenewalDuration.Duration.Nanoseconds(),
|
||||
app.MaxTokenDuration.Duration.Nanoseconds(),
|
||||
string(app.Owner.Type),
|
||||
@ -73,7 +74,7 @@ func (r *ApplicationRepository) Create(ctx context.Context, app *domain.Applicat
|
||||
// GetByID retrieves an application by its ID
|
||||
func (r *ApplicationRepository) GetByID(ctx context.Context, appID string) (*domain.Application, error) {
|
||||
query := `
|
||||
SELECT app_id, app_link, type, callback_url, hmac_key,
|
||||
SELECT app_id, app_link, type, callback_url, hmac_key, token_prefix,
|
||||
token_renewal_duration, max_token_duration,
|
||||
owner_type, owner_name, owner_owner,
|
||||
created_at, updated_at
|
||||
@ -95,6 +96,7 @@ func (r *ApplicationRepository) GetByID(ctx context.Context, appID string) (*dom
|
||||
&typeStrings,
|
||||
&app.CallbackURL,
|
||||
&app.HMACKey,
|
||||
&app.TokenPrefix,
|
||||
&tokenRenewalNanos,
|
||||
&maxTokenNanos,
|
||||
&ownerType,
|
||||
@ -130,7 +132,7 @@ func (r *ApplicationRepository) GetByID(ctx context.Context, appID string) (*dom
|
||||
// List retrieves applications with pagination
|
||||
func (r *ApplicationRepository) List(ctx context.Context, limit, offset int) ([]*domain.Application, error) {
|
||||
query := `
|
||||
SELECT app_id, app_link, type, callback_url, hmac_key,
|
||||
SELECT app_id, app_link, type, callback_url, hmac_key, token_prefix,
|
||||
token_renewal_duration, max_token_duration,
|
||||
owner_type, owner_name, owner_owner,
|
||||
created_at, updated_at
|
||||
@ -160,6 +162,7 @@ func (r *ApplicationRepository) List(ctx context.Context, limit, offset int) ([]
|
||||
&typeStrings,
|
||||
&app.CallbackURL,
|
||||
&app.HMACKey,
|
||||
&app.TokenPrefix,
|
||||
&tokenRenewalNanos,
|
||||
&maxTokenNanos,
|
||||
&ownerType,
|
||||
@ -231,6 +234,12 @@ func (r *ApplicationRepository) Update(ctx context.Context, appID string, update
|
||||
argIndex++
|
||||
}
|
||||
|
||||
if updates.TokenPrefix != nil {
|
||||
setParts = append(setParts, fmt.Sprintf("token_prefix = $%d", argIndex))
|
||||
args = append(args, *updates.TokenPrefix)
|
||||
argIndex++
|
||||
}
|
||||
|
||||
if updates.TokenRenewalDuration != nil {
|
||||
setParts = append(setParts, fmt.Sprintf("token_renewal_duration = $%d", argIndex))
|
||||
args = append(args, updates.TokenRenewalDuration.Duration.Nanoseconds())
|
||||
|
||||
Reference in New Issue
Block a user