fix: issues

This commit is contained in:
Rogee
2024-12-13 10:38:54 +08:00
parent 5a6b7bcdae
commit 19f445144d
13 changed files with 262 additions and 67 deletions

View File

@@ -54,6 +54,7 @@ func (c *Controller) Info(ctx fiber.Ctx) error {
return errors.Wrapf(err, "get tenant: %d", claim.TenantID)
}
info.IsAdmin = tenant.BindUserID == claim.UserID
info.AdminContact = tenant.BindUserContact
return ctx.JSON(info)
}
@@ -92,3 +93,26 @@ func (c *Controller) GetChargeCodes(ctx fiber.Ctx) error {
return ctx.JSON(codes)
}
// BalanceHistory
func (c *Controller) BalanceHistory(ctx fiber.Ctx) error {
claim := fiber.Locals[*jwt.Claims](ctx, consts.CtxKeyClaim)
log.Debug(claim)
histories, err := c.svc.GetBalanceHistory(ctx.Context(), claim.TenantID, claim.UserID)
if err != nil {
return errorx.Wrap(err)
}
items := []BalanceHistory{}
for _, h := range histories {
items = append(items, BalanceHistory{
Balance: h.Balance,
Type: h.Type,
Target: h.Target,
CreatedAt: h.CreatedAt,
})
}
return ctx.JSON(items)
}