Skip to content

Commit

Permalink
feat: BillingRecordQueryStatus add TotalCount (#3686)
Browse files Browse the repository at this point in the history
* recordquery return TotalCount

* fix controller ci lint
  • Loading branch information
bxy4543 committed Aug 16, 2023
1 parent 7dbf9ed commit a17d932
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 9 deletions.
1 change: 1 addition & 0 deletions controllers/account/api/v1/billingrecordquery_types.go
Expand Up @@ -39,6 +39,7 @@ type BillingRecordQuerySpec struct {
type BillingRecordQueryStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
TotalCount int `json:"totalCount"`
PageLength int `json:"pageLength"`
RechargeAmount int64 `json:"rechargeAmount"`
DeductionAmount Costs `json:"deductionAmount,omitempty"`
Expand Down
Expand Up @@ -100,16 +100,19 @@ spec:
type: object
type: array
pageLength:
description: 'INSERT ADDITIONAL STATUS FIELD - define observed state
of cluster Important: Run "make" to regenerate code after modifying
this file'
type: integer
rechargeAmount:
format: int64
type: integer
totalCount:
description: 'INSERT ADDITIONAL STATUS FIELD - define observed state
of cluster Important: Run "make" to regenerate code after modifying
this file'
type: integer
required:
- pageLength
- rechargeAmount
- totalCount
type: object
type: object
served: true
Expand Down
Expand Up @@ -40,6 +40,7 @@ spec:
format: int64
type: integer
paymentMethod:
default: wechat
description: e.g. wechat, alipay, creditcard, etc.
type: string
userID:
Expand Down
2 changes: 1 addition & 1 deletion controllers/account/controllers/account_controller.go
Expand Up @@ -281,7 +281,7 @@ func (r *AccountReconciler) syncAccount(ctx context.Context, name, accountNamesp
if err != nil {
return nil, fmt.Errorf("sync init balance failed: %v", err)
}
err = crypto.RechargeBalance(account.Status.EncryptBalance, int64(amount))
err = crypto.RechargeBalance(account.Status.EncryptBalance, amount)
if err != nil {
return nil, fmt.Errorf("recharge balance failed: %v", err)
}
Expand Down
10 changes: 7 additions & 3 deletions controllers/account/deploy/manifests/deploy.yaml.tmpl
Expand Up @@ -280,16 +280,19 @@ spec:
type: object
type: array
pageLength:
description: 'INSERT ADDITIONAL STATUS FIELD - define observed state
of cluster Important: Run "make" to regenerate code after modifying
this file'
type: integer
rechargeAmount:
format: int64
type: integer
totalCount:
description: 'INSERT ADDITIONAL STATUS FIELD - define observed state
of cluster Important: Run "make" to regenerate code after modifying
this file'
type: integer
required:
- pageLength
- rechargeAmount
- totalCount
type: object
type: object
served: true
Expand Down Expand Up @@ -418,6 +421,7 @@ spec:
format: int64
type: integer
paymentMethod:
default: wechat
description: e.g. wechat, alipay, creditcard, etc.
type: string
userID:
Expand Down
4 changes: 2 additions & 2 deletions controllers/pkg/database/mongodb.go
Expand Up @@ -516,8 +516,8 @@ func (m *MongoDB) QueryBillingRecords(billingRecordQuery *accountv1.BillingRecor
}

totalPages := (totalCount + billingRecordQuery.Spec.PageSize - 1) / billingRecordQuery.Spec.PageSize
billingRecordQuery.Status.Items, billingRecordQuery.Status.PageLength,
billingRecordQuery.Status.RechargeAmount, billingRecordQuery.Status.DeductionAmount = billingRecords, totalPages, totalRechargeAmount, totalDeductionAmount
billingRecordQuery.Status.Items, billingRecordQuery.Status.PageLength, billingRecordQuery.Status.TotalCount,
billingRecordQuery.Status.RechargeAmount, billingRecordQuery.Status.DeductionAmount = billingRecords, totalPages, totalCount, totalRechargeAmount, totalDeductionAmount
return nil
}

Expand Down

0 comments on commit a17d932

Please sign in to comment.