update expired repo methods
This commit is contained in:
parent
8adb6cdc04
commit
e860e550da
@ -266,6 +266,11 @@ type ShortPrivilege struct {
|
|||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ExpiredPrivileges struct {
|
||||||
|
UserID string
|
||||||
|
Privilege ShortPrivilege
|
||||||
|
}
|
||||||
|
|
||||||
type Account struct {
|
type Account struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
UserID string `json:"user_id"`
|
UserID string `json:"user_id"`
|
||||||
|
@ -206,13 +206,13 @@ func (r *AccountRepository) InsertPrivilege(ctx context.Context, privilege *mode
|
|||||||
}
|
}
|
||||||
|
|
||||||
// test +
|
// test +
|
||||||
func (r *AccountRepository) GetExpired(ctx context.Context, privilegeID string) ([]model.ShortPrivilege, error) {
|
func (r *AccountRepository) GetExpired(ctx context.Context, privilegeID string) ([]model.ExpiredPrivileges, error) {
|
||||||
rows, err := r.queries.GetExpiredDayPrivilege(ctx, sql.NullString{String: privilegeID, Valid: privilegeID != ""})
|
rows, err := r.queries.GetExpiredDayPrivilege(ctx, sql.NullString{String: privilegeID, Valid: privilegeID != ""})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var expiredRecords []model.ShortPrivilege
|
var expiredRecords []model.ExpiredPrivileges
|
||||||
|
|
||||||
for _, row := range rows {
|
for _, row := range rows {
|
||||||
privilege := model.ShortPrivilege{
|
privilege := model.ShortPrivilege{
|
||||||
@ -222,20 +222,23 @@ func (r *AccountRepository) GetExpired(ctx context.Context, privilegeID string)
|
|||||||
Amount: uint64(row.Amount.Int32),
|
Amount: uint64(row.Amount.Int32),
|
||||||
CreatedAt: row.CreatedAt.Time,
|
CreatedAt: row.CreatedAt.Time,
|
||||||
}
|
}
|
||||||
expiredRecords = append(expiredRecords, privilege)
|
expiredRecords = append(expiredRecords, model.ExpiredPrivileges{
|
||||||
|
UserID: row.UserID.String,
|
||||||
|
Privilege: privilege,
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return expiredRecords, nil
|
return expiredRecords, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *AccountRepository) GetExpiredCount(ctx context.Context, privilegeID string) ([]model.ShortPrivilege, error) {
|
func (r *AccountRepository) GetExpiredCount(ctx context.Context, privilegeID string) ([]model.ExpiredPrivileges, error) {
|
||||||
rows, err := r.queries.GetExpiredCountPrivilege(ctx, sql.NullString{String: privilegeID, Valid: privilegeID != ""})
|
rows, err := r.queries.GetExpiredCountPrivilege(ctx, sql.NullString{String: privilegeID, Valid: privilegeID != ""})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var expiredRecords []model.ShortPrivilege
|
var expiredRecords []model.ExpiredPrivileges
|
||||||
|
|
||||||
for _, row := range rows {
|
for _, row := range rows {
|
||||||
privilege := model.ShortPrivilege{
|
privilege := model.ShortPrivilege{
|
||||||
@ -245,7 +248,10 @@ func (r *AccountRepository) GetExpiredCount(ctx context.Context, privilegeID str
|
|||||||
Amount: uint64(row.Amount.Int32),
|
Amount: uint64(row.Amount.Int32),
|
||||||
CreatedAt: row.CreatedAt.Time,
|
CreatedAt: row.CreatedAt.Time,
|
||||||
}
|
}
|
||||||
expiredRecords = append(expiredRecords, privilege)
|
expiredRecords = append(expiredRecords, model.ExpiredPrivileges{
|
||||||
|
UserID: row.UserID.String,
|
||||||
|
Privilege: privilege,
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user