code refactor
This commit is contained in:
+7
-7
@@ -24,7 +24,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// AccountListHandler returns accounts list of current user
|
// AccountListHandler returns accounts list of current user
|
||||||
func (a *AccountsApi) AccountListHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *AccountsApi) AccountListHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var accountListReq models.AccountListRequest
|
var accountListReq models.AccountListRequest
|
||||||
err := c.ShouldBindQuery(&accountListReq)
|
err := c.ShouldBindQuery(&accountListReq)
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ func (a *AccountsApi) AccountListHandler(c *core.Context) (interface{}, *errs.Er
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AccountGetHandler returns one specific account of current user
|
// AccountGetHandler returns one specific account of current user
|
||||||
func (a *AccountsApi) AccountGetHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *AccountsApi) AccountGetHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var accountGetReq models.AccountGetRequest
|
var accountGetReq models.AccountGetRequest
|
||||||
err := c.ShouldBindQuery(&accountGetReq)
|
err := c.ShouldBindQuery(&accountGetReq)
|
||||||
|
|
||||||
@@ -127,7 +127,7 @@ func (a *AccountsApi) AccountGetHandler(c *core.Context) (interface{}, *errs.Err
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AccountCreateHandler saves a new account by request parameters for current user
|
// AccountCreateHandler saves a new account by request parameters for current user
|
||||||
func (a *AccountsApi) AccountCreateHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *AccountsApi) AccountCreateHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var accountCreateReq models.AccountCreateRequest
|
var accountCreateReq models.AccountCreateRequest
|
||||||
err := c.ShouldBindJSON(&accountCreateReq)
|
err := c.ShouldBindJSON(&accountCreateReq)
|
||||||
|
|
||||||
@@ -226,7 +226,7 @@ func (a *AccountsApi) AccountCreateHandler(c *core.Context) (interface{}, *errs.
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AccountModifyHandler saves an existed account by request parameters for current user
|
// AccountModifyHandler saves an existed account by request parameters for current user
|
||||||
func (a *AccountsApi) AccountModifyHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *AccountsApi) AccountModifyHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var accountModifyReq models.AccountModifyRequest
|
var accountModifyReq models.AccountModifyRequest
|
||||||
err := c.ShouldBindJSON(&accountModifyReq)
|
err := c.ShouldBindJSON(&accountModifyReq)
|
||||||
|
|
||||||
@@ -332,7 +332,7 @@ func (a *AccountsApi) AccountModifyHandler(c *core.Context) (interface{}, *errs.
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AccountHideHandler hides an existed account by request parameters for current user
|
// AccountHideHandler hides an existed account by request parameters for current user
|
||||||
func (a *AccountsApi) AccountHideHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *AccountsApi) AccountHideHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var accountHideReq models.AccountHideRequest
|
var accountHideReq models.AccountHideRequest
|
||||||
err := c.ShouldBindJSON(&accountHideReq)
|
err := c.ShouldBindJSON(&accountHideReq)
|
||||||
|
|
||||||
@@ -354,7 +354,7 @@ func (a *AccountsApi) AccountHideHandler(c *core.Context) (interface{}, *errs.Er
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AccountMoveHandler moves display order of existed accounts by request parameters for current user
|
// AccountMoveHandler moves display order of existed accounts by request parameters for current user
|
||||||
func (a *AccountsApi) AccountMoveHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *AccountsApi) AccountMoveHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var accountMoveReq models.AccountMoveRequest
|
var accountMoveReq models.AccountMoveRequest
|
||||||
err := c.ShouldBindJSON(&accountMoveReq)
|
err := c.ShouldBindJSON(&accountMoveReq)
|
||||||
|
|
||||||
@@ -389,7 +389,7 @@ func (a *AccountsApi) AccountMoveHandler(c *core.Context) (interface{}, *errs.Er
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AccountDeleteHandler deletes an existed account by request parameters for current user
|
// AccountDeleteHandler deletes an existed account by request parameters for current user
|
||||||
func (a *AccountsApi) AccountDeleteHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *AccountsApi) AccountDeleteHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var accountDeleteReq models.AccountDeleteRequest
|
var accountDeleteReq models.AccountDeleteRequest
|
||||||
err := c.ShouldBindJSON(&accountDeleteReq)
|
err := c.ShouldBindJSON(&accountDeleteReq)
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// AuthorizeHandler verifies and authorizes current login request
|
// AuthorizeHandler verifies and authorizes current login request
|
||||||
func (a *AuthorizationsApi) AuthorizeHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *AuthorizationsApi) AuthorizeHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var credential models.UserLoginRequest
|
var credential models.UserLoginRequest
|
||||||
err := c.ShouldBindJSON(&credential)
|
err := c.ShouldBindJSON(&credential)
|
||||||
|
|
||||||
@@ -109,7 +109,7 @@ func (a *AuthorizationsApi) AuthorizeHandler(c *core.Context) (interface{}, *err
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TwoFactorAuthorizeHandler verifies and authorizes current 2fa login by passcode
|
// TwoFactorAuthorizeHandler verifies and authorizes current 2fa login by passcode
|
||||||
func (a *AuthorizationsApi) TwoFactorAuthorizeHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *AuthorizationsApi) TwoFactorAuthorizeHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var credential models.TwoFactorLoginRequest
|
var credential models.TwoFactorLoginRequest
|
||||||
err := c.ShouldBindJSON(&credential)
|
err := c.ShouldBindJSON(&credential)
|
||||||
|
|
||||||
@@ -172,7 +172,7 @@ func (a *AuthorizationsApi) TwoFactorAuthorizeHandler(c *core.Context) (interfac
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TwoFactorAuthorizeByRecoveryCodeHandler verifies and authorizes current 2fa login by recovery code
|
// TwoFactorAuthorizeByRecoveryCodeHandler verifies and authorizes current 2fa login by recovery code
|
||||||
func (a *AuthorizationsApi) TwoFactorAuthorizeByRecoveryCodeHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *AuthorizationsApi) TwoFactorAuthorizeByRecoveryCodeHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var credential models.TwoFactorRecoveryCodeLoginRequest
|
var credential models.TwoFactorRecoveryCodeLoginRequest
|
||||||
err := c.ShouldBindJSON(&credential)
|
err := c.ShouldBindJSON(&credential)
|
||||||
|
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ func (a *DataManagementsApi) ExportDataHandler(c *core.Context) ([]byte, string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DataStatisticsHandler returns user data statistics
|
// DataStatisticsHandler returns user data statistics
|
||||||
func (a *DataManagementsApi) DataStatisticsHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *DataManagementsApi) DataStatisticsHandler(c *core.Context) (any, *errs.Error) {
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
totalAccountCount, err := a.accounts.GetTotalAccountCountByUid(c, uid)
|
totalAccountCount, err := a.accounts.GetTotalAccountCountByUid(c, uid)
|
||||||
|
|
||||||
@@ -160,7 +160,7 @@ func (a *DataManagementsApi) DataStatisticsHandler(c *core.Context) (interface{}
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ClearDataHandler deletes all user data
|
// ClearDataHandler deletes all user data
|
||||||
func (a *DataManagementsApi) ClearDataHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *DataManagementsApi) ClearDataHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var clearDataReq models.ClearDataRequest
|
var clearDataReq models.ClearDataRequest
|
||||||
err := c.ShouldBindJSON(&clearDataReq)
|
err := c.ShouldBindJSON(&clearDataReq)
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -14,11 +14,11 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// ApiNotFound returns api not found error
|
// ApiNotFound returns api not found error
|
||||||
func (a *DefaultApi) ApiNotFound(c *core.Context) (interface{}, *errs.Error) {
|
func (a *DefaultApi) ApiNotFound(c *core.Context) (any, *errs.Error) {
|
||||||
return nil, errs.ErrApiNotFound
|
return nil, errs.ErrApiNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
// MethodNotAllowed returns method not allowed error
|
// MethodNotAllowed returns method not allowed error
|
||||||
func (a *DefaultApi) MethodNotAllowed(c *core.Context) (interface{}, *errs.Error) {
|
func (a *DefaultApi) MethodNotAllowed(c *core.Context) (any, *errs.Error) {
|
||||||
return nil, errs.ErrMethodNotAllowed
|
return nil, errs.ErrMethodNotAllowed
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// LatestExchangeRateHandler returns latest exchange rate data
|
// LatestExchangeRateHandler returns latest exchange rate data
|
||||||
func (a *ExchangeRatesApi) LatestExchangeRateHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *ExchangeRatesApi) LatestExchangeRateHandler(c *core.Context) (any, *errs.Error) {
|
||||||
dataSource := exchangerates.Container.Current
|
dataSource := exchangerates.Container.Current
|
||||||
|
|
||||||
if dataSource == nil {
|
if dataSource == nil {
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// UserForgetPasswordRequestHandler generates password reset link and send user an email with this link
|
// UserForgetPasswordRequestHandler generates password reset link and send user an email with this link
|
||||||
func (a *ForgetPasswordsApi) UserForgetPasswordRequestHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *ForgetPasswordsApi) UserForgetPasswordRequestHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var request models.ForgetPasswordRequest
|
var request models.ForgetPasswordRequest
|
||||||
err := c.ShouldBindJSON(&request)
|
err := c.ShouldBindJSON(&request)
|
||||||
|
|
||||||
@@ -80,7 +80,7 @@ func (a *ForgetPasswordsApi) UserForgetPasswordRequestHandler(c *core.Context) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UserResetPasswordHandler resets user password by request parameters
|
// UserResetPasswordHandler resets user password by request parameters
|
||||||
func (a *ForgetPasswordsApi) UserResetPasswordHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *ForgetPasswordsApi) UserResetPasswordHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var request models.PasswordResetRequest
|
var request models.PasswordResetRequest
|
||||||
err := c.ShouldBindJSON(&request)
|
err := c.ShouldBindJSON(&request)
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -15,7 +15,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// HealthStatusHandler returns the health status of current service
|
// HealthStatusHandler returns the health status of current service
|
||||||
func (a *HealthsApi) HealthStatusHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *HealthsApi) HealthStatusHandler(c *core.Context) (any, *errs.Error) {
|
||||||
result := make(map[string]string)
|
result := make(map[string]string)
|
||||||
|
|
||||||
result["version"] = settings.Version
|
result["version"] = settings.Version
|
||||||
|
|||||||
+5
-5
@@ -26,7 +26,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// TokenListHandler returns available token list of current user
|
// TokenListHandler returns available token list of current user
|
||||||
func (a *TokensApi) TokenListHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TokensApi) TokenListHandler(c *core.Context) (any, *errs.Error) {
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
tokens, err := a.tokens.GetAllUnexpiredNormalTokensByUid(c, uid)
|
tokens, err := a.tokens.GetAllUnexpiredNormalTokensByUid(c, uid)
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ func (a *TokensApi) TokenListHandler(c *core.Context) (interface{}, *errs.Error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TokenRevokeCurrentHandler revokes current token of current user
|
// TokenRevokeCurrentHandler revokes current token of current user
|
||||||
func (a *TokensApi) TokenRevokeCurrentHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TokensApi) TokenRevokeCurrentHandler(c *core.Context) (any, *errs.Error) {
|
||||||
_, claims, err := a.tokens.ParseTokenByHeader(c)
|
_, claims, err := a.tokens.ParseTokenByHeader(c)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -94,7 +94,7 @@ func (a *TokensApi) TokenRevokeCurrentHandler(c *core.Context) (interface{}, *er
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TokenRevokeHandler revokes specific token of current user
|
// TokenRevokeHandler revokes specific token of current user
|
||||||
func (a *TokensApi) TokenRevokeHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TokensApi) TokenRevokeHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var tokenRevokeReq models.TokenRevokeRequest
|
var tokenRevokeReq models.TokenRevokeRequest
|
||||||
err := c.ShouldBindJSON(&tokenRevokeReq)
|
err := c.ShouldBindJSON(&tokenRevokeReq)
|
||||||
|
|
||||||
@@ -132,7 +132,7 @@ func (a *TokensApi) TokenRevokeHandler(c *core.Context) (interface{}, *errs.Erro
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TokenRevokeAllHandler revokes all tokens of current user except current token
|
// TokenRevokeAllHandler revokes all tokens of current user except current token
|
||||||
func (a *TokensApi) TokenRevokeAllHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TokensApi) TokenRevokeAllHandler(c *core.Context) (any, *errs.Error) {
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
tokens, err := a.tokens.GetAllTokensByUid(c, uid)
|
tokens, err := a.tokens.GetAllTokensByUid(c, uid)
|
||||||
|
|
||||||
@@ -167,7 +167,7 @@ func (a *TokensApi) TokenRevokeAllHandler(c *core.Context) (interface{}, *errs.E
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TokenRefreshHandler refresh current token of current user
|
// TokenRefreshHandler refresh current token of current user
|
||||||
func (a *TokensApi) TokenRefreshHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TokensApi) TokenRefreshHandler(c *core.Context) (any, *errs.Error) {
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
user, err := a.users.GetUserById(c, uid)
|
user, err := a.users.GetUserById(c, uid)
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// CategoryListHandler returns transaction category list of current user
|
// CategoryListHandler returns transaction category list of current user
|
||||||
func (a *TransactionCategoriesApi) CategoryListHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TransactionCategoriesApi) CategoryListHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var categoryListReq models.TransactionCategoryListRequest
|
var categoryListReq models.TransactionCategoryListRequest
|
||||||
err := c.ShouldBindQuery(&categoryListReq)
|
err := c.ShouldBindQuery(&categoryListReq)
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ func (a *TransactionCategoriesApi) CategoryListHandler(c *core.Context) (interfa
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CategoryGetHandler returns one specific transaction category of current user
|
// CategoryGetHandler returns one specific transaction category of current user
|
||||||
func (a *TransactionCategoriesApi) CategoryGetHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TransactionCategoriesApi) CategoryGetHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var categoryGetReq models.TransactionCategoryGetRequest
|
var categoryGetReq models.TransactionCategoryGetRequest
|
||||||
err := c.ShouldBindQuery(&categoryGetReq)
|
err := c.ShouldBindQuery(&categoryGetReq)
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ func (a *TransactionCategoriesApi) CategoryGetHandler(c *core.Context) (interfac
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CategoryCreateHandler saves a new transaction category by request parameters for current user
|
// CategoryCreateHandler saves a new transaction category by request parameters for current user
|
||||||
func (a *TransactionCategoriesApi) CategoryCreateHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TransactionCategoriesApi) CategoryCreateHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var categoryCreateReq models.TransactionCategoryCreateRequest
|
var categoryCreateReq models.TransactionCategoryCreateRequest
|
||||||
err := c.ShouldBindJSON(&categoryCreateReq)
|
err := c.ShouldBindJSON(&categoryCreateReq)
|
||||||
|
|
||||||
@@ -134,7 +134,7 @@ func (a *TransactionCategoriesApi) CategoryCreateHandler(c *core.Context) (inter
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CategoryCreateBatchHandler saves some new transaction category by request parameters for current user
|
// CategoryCreateBatchHandler saves some new transaction category by request parameters for current user
|
||||||
func (a *TransactionCategoriesApi) CategoryCreateBatchHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TransactionCategoriesApi) CategoryCreateBatchHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var categoryCreateBatchReq models.TransactionCategoryCreateBatchRequest
|
var categoryCreateBatchReq models.TransactionCategoryCreateBatchRequest
|
||||||
err := c.ShouldBindBodyWith(&categoryCreateBatchReq, binding.JSON)
|
err := c.ShouldBindBodyWith(&categoryCreateBatchReq, binding.JSON)
|
||||||
|
|
||||||
@@ -155,7 +155,7 @@ func (a *TransactionCategoriesApi) CategoryCreateBatchHandler(c *core.Context) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CategoryModifyHandler saves an existed transaction category by request parameters for current user
|
// CategoryModifyHandler saves an existed transaction category by request parameters for current user
|
||||||
func (a *TransactionCategoriesApi) CategoryModifyHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TransactionCategoriesApi) CategoryModifyHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var categoryModifyReq models.TransactionCategoryModifyRequest
|
var categoryModifyReq models.TransactionCategoryModifyRequest
|
||||||
err := c.ShouldBindJSON(&categoryModifyReq)
|
err := c.ShouldBindJSON(&categoryModifyReq)
|
||||||
|
|
||||||
@@ -208,7 +208,7 @@ func (a *TransactionCategoriesApi) CategoryModifyHandler(c *core.Context) (inter
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CategoryHideHandler hides an existed transaction category by request parameters for current user
|
// CategoryHideHandler hides an existed transaction category by request parameters for current user
|
||||||
func (a *TransactionCategoriesApi) CategoryHideHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TransactionCategoriesApi) CategoryHideHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var categoryHideReq models.TransactionCategoryHideRequest
|
var categoryHideReq models.TransactionCategoryHideRequest
|
||||||
err := c.ShouldBindJSON(&categoryHideReq)
|
err := c.ShouldBindJSON(&categoryHideReq)
|
||||||
|
|
||||||
@@ -230,7 +230,7 @@ func (a *TransactionCategoriesApi) CategoryHideHandler(c *core.Context) (interfa
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CategoryMoveHandler moves display order of existed transaction categories by request parameters for current user
|
// CategoryMoveHandler moves display order of existed transaction categories by request parameters for current user
|
||||||
func (a *TransactionCategoriesApi) CategoryMoveHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TransactionCategoriesApi) CategoryMoveHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var categoryMoveReq models.TransactionCategoryMoveRequest
|
var categoryMoveReq models.TransactionCategoryMoveRequest
|
||||||
err := c.ShouldBindJSON(&categoryMoveReq)
|
err := c.ShouldBindJSON(&categoryMoveReq)
|
||||||
|
|
||||||
@@ -265,7 +265,7 @@ func (a *TransactionCategoriesApi) CategoryMoveHandler(c *core.Context) (interfa
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CategoryDeleteHandler deletes an existed transaction category by request parameters for current user
|
// CategoryDeleteHandler deletes an existed transaction category by request parameters for current user
|
||||||
func (a *TransactionCategoriesApi) CategoryDeleteHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TransactionCategoriesApi) CategoryDeleteHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var categoryDeleteReq models.TransactionCategoryDeleteRequest
|
var categoryDeleteReq models.TransactionCategoryDeleteRequest
|
||||||
err := c.ShouldBindJSON(&categoryDeleteReq)
|
err := c.ShouldBindJSON(&categoryDeleteReq)
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// TagListHandler returns transaction tag list of current user
|
// TagListHandler returns transaction tag list of current user
|
||||||
func (a *TransactionTagsApi) TagListHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TransactionTagsApi) TagListHandler(c *core.Context) (any, *errs.Error) {
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
tags, err := a.tags.GetAllTagsByUid(c, uid)
|
tags, err := a.tags.GetAllTagsByUid(c, uid)
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ func (a *TransactionTagsApi) TagListHandler(c *core.Context) (interface{}, *errs
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TagGetHandler returns one specific transaction tag of current user
|
// TagGetHandler returns one specific transaction tag of current user
|
||||||
func (a *TransactionTagsApi) TagGetHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TransactionTagsApi) TagGetHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var tagGetReq models.TransactionTagGetRequest
|
var tagGetReq models.TransactionTagGetRequest
|
||||||
err := c.ShouldBindQuery(&tagGetReq)
|
err := c.ShouldBindQuery(&tagGetReq)
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@ func (a *TransactionTagsApi) TagGetHandler(c *core.Context) (interface{}, *errs.
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TagCreateHandler saves a new transaction tag by request parameters for current user
|
// TagCreateHandler saves a new transaction tag by request parameters for current user
|
||||||
func (a *TransactionTagsApi) TagCreateHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TransactionTagsApi) TagCreateHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var tagCreateReq models.TransactionTagCreateRequest
|
var tagCreateReq models.TransactionTagCreateRequest
|
||||||
err := c.ShouldBindJSON(&tagCreateReq)
|
err := c.ShouldBindJSON(&tagCreateReq)
|
||||||
|
|
||||||
@@ -102,7 +102,7 @@ func (a *TransactionTagsApi) TagCreateHandler(c *core.Context) (interface{}, *er
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TagModifyHandler saves an existed transaction tag by request parameters for current user
|
// TagModifyHandler saves an existed transaction tag by request parameters for current user
|
||||||
func (a *TransactionTagsApi) TagModifyHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TransactionTagsApi) TagModifyHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var tagModifyReq models.TransactionTagModifyRequest
|
var tagModifyReq models.TransactionTagModifyRequest
|
||||||
err := c.ShouldBindJSON(&tagModifyReq)
|
err := c.ShouldBindJSON(&tagModifyReq)
|
||||||
|
|
||||||
@@ -145,7 +145,7 @@ func (a *TransactionTagsApi) TagModifyHandler(c *core.Context) (interface{}, *er
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TagHideHandler hides an transaction tag by request parameters for current user
|
// TagHideHandler hides an transaction tag by request parameters for current user
|
||||||
func (a *TransactionTagsApi) TagHideHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TransactionTagsApi) TagHideHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var tagHideReq models.TransactionTagHideRequest
|
var tagHideReq models.TransactionTagHideRequest
|
||||||
err := c.ShouldBindJSON(&tagHideReq)
|
err := c.ShouldBindJSON(&tagHideReq)
|
||||||
|
|
||||||
@@ -167,7 +167,7 @@ func (a *TransactionTagsApi) TagHideHandler(c *core.Context) (interface{}, *errs
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TagMoveHandler moves display order of existed transaction tags by request parameters for current user
|
// TagMoveHandler moves display order of existed transaction tags by request parameters for current user
|
||||||
func (a *TransactionTagsApi) TagMoveHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TransactionTagsApi) TagMoveHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var tagMoveReq models.TransactionTagMoveRequest
|
var tagMoveReq models.TransactionTagMoveRequest
|
||||||
err := c.ShouldBindJSON(&tagMoveReq)
|
err := c.ShouldBindJSON(&tagMoveReq)
|
||||||
|
|
||||||
@@ -202,7 +202,7 @@ func (a *TransactionTagsApi) TagMoveHandler(c *core.Context) (interface{}, *errs
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TagDeleteHandler deletes an existed transaction tag by request parameters for current user
|
// TagDeleteHandler deletes an existed transaction tag by request parameters for current user
|
||||||
func (a *TransactionTagsApi) TagDeleteHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TransactionTagsApi) TagDeleteHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var tagDeleteReq models.TransactionTagDeleteRequest
|
var tagDeleteReq models.TransactionTagDeleteRequest
|
||||||
err := c.ShouldBindJSON(&tagDeleteReq)
|
err := c.ShouldBindJSON(&tagDeleteReq)
|
||||||
|
|
||||||
|
|||||||
+10
-10
@@ -37,7 +37,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// TransactionCountHandler returns transaction total count of current user
|
// TransactionCountHandler returns transaction total count of current user
|
||||||
func (a *TransactionsApi) TransactionCountHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TransactionsApi) TransactionCountHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var transactionCountReq models.TransactionCountRequest
|
var transactionCountReq models.TransactionCountRequest
|
||||||
err := c.ShouldBindQuery(&transactionCountReq)
|
err := c.ShouldBindQuery(&transactionCountReq)
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ func (a *TransactionsApi) TransactionCountHandler(c *core.Context) (interface{},
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TransactionListHandler returns transaction list of current user
|
// TransactionListHandler returns transaction list of current user
|
||||||
func (a *TransactionsApi) TransactionListHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TransactionsApi) TransactionListHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var transactionListReq models.TransactionListByMaxTimeRequest
|
var transactionListReq models.TransactionListByMaxTimeRequest
|
||||||
err := c.ShouldBindQuery(&transactionListReq)
|
err := c.ShouldBindQuery(&transactionListReq)
|
||||||
|
|
||||||
@@ -168,7 +168,7 @@ func (a *TransactionsApi) TransactionListHandler(c *core.Context) (interface{},
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TransactionMonthListHandler returns all transaction list of current user by month
|
// TransactionMonthListHandler returns all transaction list of current user by month
|
||||||
func (a *TransactionsApi) TransactionMonthListHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TransactionsApi) TransactionMonthListHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var transactionListReq models.TransactionListInMonthByPageRequest
|
var transactionListReq models.TransactionListInMonthByPageRequest
|
||||||
err := c.ShouldBindQuery(&transactionListReq)
|
err := c.ShouldBindQuery(&transactionListReq)
|
||||||
|
|
||||||
@@ -232,7 +232,7 @@ func (a *TransactionsApi) TransactionMonthListHandler(c *core.Context) (interfac
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TransactionStatisticsHandler returns transaction statistics of current user
|
// TransactionStatisticsHandler returns transaction statistics of current user
|
||||||
func (a *TransactionsApi) TransactionStatisticsHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TransactionsApi) TransactionStatisticsHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var statisticReq models.TransactionStatisticRequest
|
var statisticReq models.TransactionStatisticRequest
|
||||||
err := c.ShouldBindQuery(&statisticReq)
|
err := c.ShouldBindQuery(&statisticReq)
|
||||||
|
|
||||||
@@ -269,7 +269,7 @@ func (a *TransactionsApi) TransactionStatisticsHandler(c *core.Context) (interfa
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TransactionAmountsHandler returns transaction amounts of current user
|
// TransactionAmountsHandler returns transaction amounts of current user
|
||||||
func (a *TransactionsApi) TransactionAmountsHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TransactionsApi) TransactionAmountsHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var transactionAmountsReq models.TransactionAmountsRequest
|
var transactionAmountsReq models.TransactionAmountsRequest
|
||||||
err := c.ShouldBindQuery(&transactionAmountsReq)
|
err := c.ShouldBindQuery(&transactionAmountsReq)
|
||||||
|
|
||||||
@@ -382,7 +382,7 @@ func (a *TransactionsApi) TransactionAmountsHandler(c *core.Context) (interface{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TransactionMonthAmountsHandler returns every month transaction amounts of current user
|
// TransactionMonthAmountsHandler returns every month transaction amounts of current user
|
||||||
func (a *TransactionsApi) TransactionMonthAmountsHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TransactionsApi) TransactionMonthAmountsHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var transactionAmountsReq models.TransactionMonthAmountsRequest
|
var transactionAmountsReq models.TransactionMonthAmountsRequest
|
||||||
err := c.ShouldBindQuery(&transactionAmountsReq)
|
err := c.ShouldBindQuery(&transactionAmountsReq)
|
||||||
|
|
||||||
@@ -496,7 +496,7 @@ func (a *TransactionsApi) TransactionMonthAmountsHandler(c *core.Context) (inter
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TransactionGetHandler returns one specific transaction of current user
|
// TransactionGetHandler returns one specific transaction of current user
|
||||||
func (a *TransactionsApi) TransactionGetHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TransactionsApi) TransactionGetHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var transactionGetReq models.TransactionGetRequest
|
var transactionGetReq models.TransactionGetRequest
|
||||||
err := c.ShouldBindQuery(&transactionGetReq)
|
err := c.ShouldBindQuery(&transactionGetReq)
|
||||||
|
|
||||||
@@ -612,7 +612,7 @@ func (a *TransactionsApi) TransactionGetHandler(c *core.Context) (interface{}, *
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TransactionCreateHandler saves a new transaction by request parameters for current user
|
// TransactionCreateHandler saves a new transaction by request parameters for current user
|
||||||
func (a *TransactionsApi) TransactionCreateHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TransactionsApi) TransactionCreateHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var transactionCreateReq models.TransactionCreateRequest
|
var transactionCreateReq models.TransactionCreateRequest
|
||||||
err := c.ShouldBindJSON(&transactionCreateReq)
|
err := c.ShouldBindJSON(&transactionCreateReq)
|
||||||
|
|
||||||
@@ -684,7 +684,7 @@ func (a *TransactionsApi) TransactionCreateHandler(c *core.Context) (interface{}
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TransactionModifyHandler saves an existed transaction by request parameters for current user
|
// TransactionModifyHandler saves an existed transaction by request parameters for current user
|
||||||
func (a *TransactionsApi) TransactionModifyHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TransactionsApi) TransactionModifyHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var transactionModifyReq models.TransactionModifyRequest
|
var transactionModifyReq models.TransactionModifyRequest
|
||||||
err := c.ShouldBindJSON(&transactionModifyReq)
|
err := c.ShouldBindJSON(&transactionModifyReq)
|
||||||
|
|
||||||
@@ -804,7 +804,7 @@ func (a *TransactionsApi) TransactionModifyHandler(c *core.Context) (interface{}
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TransactionDeleteHandler deletes an existed transaction by request parameters for current user
|
// TransactionDeleteHandler deletes an existed transaction by request parameters for current user
|
||||||
func (a *TransactionsApi) TransactionDeleteHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TransactionsApi) TransactionDeleteHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var transactionDeleteReq models.TransactionDeleteRequest
|
var transactionDeleteReq models.TransactionDeleteRequest
|
||||||
err := c.ShouldBindJSON(&transactionDeleteReq)
|
err := c.ShouldBindJSON(&transactionDeleteReq)
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// TwoFactorStatusHandler returns 2fa status of current user
|
// TwoFactorStatusHandler returns 2fa status of current user
|
||||||
func (a *TwoFactorAuthorizationsApi) TwoFactorStatusHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TwoFactorAuthorizationsApi) TwoFactorStatusHandler(c *core.Context) (any, *errs.Error) {
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
twoFactorSetting, err := a.twoFactorAuthorizations.GetUserTwoFactorSettingByUid(c, uid)
|
twoFactorSetting, err := a.twoFactorAuthorizations.GetUserTwoFactorSettingByUid(c, uid)
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ func (a *TwoFactorAuthorizationsApi) TwoFactorStatusHandler(c *core.Context) (in
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TwoFactorEnableRequestHandler returns a new 2fa secret and qr code for current user to set 2fa and verify passcode next
|
// TwoFactorEnableRequestHandler returns a new 2fa secret and qr code for current user to set 2fa and verify passcode next
|
||||||
func (a *TwoFactorAuthorizationsApi) TwoFactorEnableRequestHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TwoFactorAuthorizationsApi) TwoFactorEnableRequestHandler(c *core.Context) (any, *errs.Error) {
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
enabled, err := a.twoFactorAuthorizations.ExistsTwoFactorSetting(c, uid)
|
enabled, err := a.twoFactorAuthorizations.ExistsTwoFactorSetting(c, uid)
|
||||||
|
|
||||||
@@ -110,7 +110,7 @@ func (a *TwoFactorAuthorizationsApi) TwoFactorEnableRequestHandler(c *core.Conte
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TwoFactorEnableConfirmHandler enables 2fa for current user
|
// TwoFactorEnableConfirmHandler enables 2fa for current user
|
||||||
func (a *TwoFactorAuthorizationsApi) TwoFactorEnableConfirmHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TwoFactorAuthorizationsApi) TwoFactorEnableConfirmHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var confirmReq models.TwoFactorEnableConfirmRequest
|
var confirmReq models.TwoFactorEnableConfirmRequest
|
||||||
err := c.ShouldBindJSON(&confirmReq)
|
err := c.ShouldBindJSON(&confirmReq)
|
||||||
|
|
||||||
@@ -209,7 +209,7 @@ func (a *TwoFactorAuthorizationsApi) TwoFactorEnableConfirmHandler(c *core.Conte
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TwoFactorDisableHandler disables 2fa for current user
|
// TwoFactorDisableHandler disables 2fa for current user
|
||||||
func (a *TwoFactorAuthorizationsApi) TwoFactorDisableHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TwoFactorAuthorizationsApi) TwoFactorDisableHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var disableReq models.TwoFactorDisableRequest
|
var disableReq models.TwoFactorDisableRequest
|
||||||
err := c.ShouldBindJSON(&disableReq)
|
err := c.ShouldBindJSON(&disableReq)
|
||||||
|
|
||||||
@@ -264,7 +264,7 @@ func (a *TwoFactorAuthorizationsApi) TwoFactorDisableHandler(c *core.Context) (i
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TwoFactorRecoveryCodeRegenerateHandler returns new 2fa recovery codes and revokes old recovery codes for current user
|
// TwoFactorRecoveryCodeRegenerateHandler returns new 2fa recovery codes and revokes old recovery codes for current user
|
||||||
func (a *TwoFactorAuthorizationsApi) TwoFactorRecoveryCodeRegenerateHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TwoFactorAuthorizationsApi) TwoFactorRecoveryCodeRegenerateHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var regenerateReq models.TwoFactorRegenerateRecoveryCodeRequest
|
var regenerateReq models.TwoFactorRegenerateRecoveryCodeRequest
|
||||||
err := c.ShouldBindJSON(®enerateReq)
|
err := c.ShouldBindJSON(®enerateReq)
|
||||||
|
|
||||||
|
|||||||
+6
-6
@@ -32,7 +32,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// UserRegisterHandler saves a new user by request parameters
|
// UserRegisterHandler saves a new user by request parameters
|
||||||
func (a *UsersApi) UserRegisterHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *UsersApi) UserRegisterHandler(c *core.Context) (any, *errs.Error) {
|
||||||
if !settings.Container.Current.EnableUserRegister {
|
if !settings.Container.Current.EnableUserRegister {
|
||||||
return nil, errs.ErrUserRegistrationNotAllowed
|
return nil, errs.ErrUserRegistrationNotAllowed
|
||||||
}
|
}
|
||||||
@@ -130,7 +130,7 @@ func (a *UsersApi) UserRegisterHandler(c *core.Context) (interface{}, *errs.Erro
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UserEmailVerifyHandler sets user email address verified
|
// UserEmailVerifyHandler sets user email address verified
|
||||||
func (a *UsersApi) UserEmailVerifyHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *UsersApi) UserEmailVerifyHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var userVerifyEmailReq models.UserVerifyEmailRequest
|
var userVerifyEmailReq models.UserVerifyEmailRequest
|
||||||
err := c.ShouldBindJSON(&userVerifyEmailReq)
|
err := c.ShouldBindJSON(&userVerifyEmailReq)
|
||||||
|
|
||||||
@@ -192,7 +192,7 @@ func (a *UsersApi) UserEmailVerifyHandler(c *core.Context) (interface{}, *errs.E
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UserProfileHandler returns user profile of current user
|
// UserProfileHandler returns user profile of current user
|
||||||
func (a *UsersApi) UserProfileHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *UsersApi) UserProfileHandler(c *core.Context) (any, *errs.Error) {
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
user, err := a.users.GetUserById(c, uid)
|
user, err := a.users.GetUserById(c, uid)
|
||||||
|
|
||||||
@@ -209,7 +209,7 @@ func (a *UsersApi) UserProfileHandler(c *core.Context) (interface{}, *errs.Error
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UserUpdateProfileHandler saves user profile by request parameters for current user
|
// UserUpdateProfileHandler saves user profile by request parameters for current user
|
||||||
func (a *UsersApi) UserUpdateProfileHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *UsersApi) UserUpdateProfileHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var userUpdateReq models.UserProfileUpdateRequest
|
var userUpdateReq models.UserProfileUpdateRequest
|
||||||
err := c.ShouldBindJSON(&userUpdateReq)
|
err := c.ShouldBindJSON(&userUpdateReq)
|
||||||
|
|
||||||
@@ -409,7 +409,7 @@ func (a *UsersApi) UserUpdateProfileHandler(c *core.Context) (interface{}, *errs
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UserSendVerifyEmailByUnloginUserHandler sends unlogin user verify email
|
// UserSendVerifyEmailByUnloginUserHandler sends unlogin user verify email
|
||||||
func (a *UsersApi) UserSendVerifyEmailByUnloginUserHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *UsersApi) UserSendVerifyEmailByUnloginUserHandler(c *core.Context) (any, *errs.Error) {
|
||||||
if !settings.Container.Current.EnableUserVerifyEmail {
|
if !settings.Container.Current.EnableUserVerifyEmail {
|
||||||
return nil, errs.ErrEmailValidationNotAllowed
|
return nil, errs.ErrEmailValidationNotAllowed
|
||||||
}
|
}
|
||||||
@@ -465,7 +465,7 @@ func (a *UsersApi) UserSendVerifyEmailByUnloginUserHandler(c *core.Context) (int
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UserSendVerifyEmailByLoginedUserHandler sends logined user verify email
|
// UserSendVerifyEmailByLoginedUserHandler sends logined user verify email
|
||||||
func (a *UsersApi) UserSendVerifyEmailByLoginedUserHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *UsersApi) UserSendVerifyEmailByLoginedUserHandler(c *core.Context) (any, *errs.Error) {
|
||||||
if !settings.Container.Current.EnableUserVerifyEmail {
|
if !settings.Container.Current.EnableUserVerifyEmail {
|
||||||
return nil, errs.ErrEmailValidationNotAllowed
|
return nil, errs.ErrEmailValidationNotAllowed
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@ import (
|
|||||||
type MiddlewareHandlerFunc func(*Context)
|
type MiddlewareHandlerFunc func(*Context)
|
||||||
|
|
||||||
// ApiHandlerFunc represents the api handler function
|
// ApiHandlerFunc represents the api handler function
|
||||||
type ApiHandlerFunc func(*Context) (interface{}, *errs.Error)
|
type ApiHandlerFunc func(*Context) (any, *errs.Error)
|
||||||
|
|
||||||
// DataHandlerFunc represents the handler function that returns byte array
|
// DataHandlerFunc represents the handler function that returns byte array
|
||||||
type DataHandlerFunc func(*Context) ([]byte, string, *errs.Error)
|
type DataHandlerFunc func(*Context) ([]byte, string, *errs.Error)
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ func (s *DataStore) DoTransaction(key int64, c *core.Context, fn func(sess *xorm
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SyncStructs updates database structs by database models
|
// SyncStructs updates database structs by database models
|
||||||
func (s *DataStore) SyncStructs(beans ...interface{}) error {
|
func (s *DataStore) SyncStructs(beans ...any) error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
for i := 0; i < len(s.databases); i++ {
|
for i := 0; i < len(s.databases); i++ {
|
||||||
|
|||||||
@@ -14,42 +14,42 @@ type XOrmLoggerAdapter struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Debug logs debug log
|
// Debug logs debug log
|
||||||
func (logger XOrmLoggerAdapter) Debug(v ...interface{}) {
|
func (logger XOrmLoggerAdapter) Debug(v ...any) {
|
||||||
log.SqlQuery(v...)
|
log.SqlQuery(v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Debugf logs debug log with custom format
|
// Debugf logs debug log with custom format
|
||||||
func (logger XOrmLoggerAdapter) Debugf(format string, v ...interface{}) {
|
func (logger XOrmLoggerAdapter) Debugf(format string, v ...any) {
|
||||||
log.SqlQueryf(format, v...)
|
log.SqlQueryf(format, v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Info logs info log
|
// Info logs info log
|
||||||
func (logger XOrmLoggerAdapter) Info(v ...interface{}) {
|
func (logger XOrmLoggerAdapter) Info(v ...any) {
|
||||||
log.SqlQuery(v...)
|
log.SqlQuery(v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Infof logs info log with custom format
|
// Infof logs info log with custom format
|
||||||
func (logger XOrmLoggerAdapter) Infof(format string, v ...interface{}) {
|
func (logger XOrmLoggerAdapter) Infof(format string, v ...any) {
|
||||||
log.SqlQueryf(format, v...)
|
log.SqlQueryf(format, v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Warn logs warn log
|
// Warn logs warn log
|
||||||
func (logger XOrmLoggerAdapter) Warn(v ...interface{}) {
|
func (logger XOrmLoggerAdapter) Warn(v ...any) {
|
||||||
log.SqlQuery(v...)
|
log.SqlQuery(v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Warnf logs warn log with custom format
|
// Warnf logs warn log with custom format
|
||||||
func (logger XOrmLoggerAdapter) Warnf(format string, v ...interface{}) {
|
func (logger XOrmLoggerAdapter) Warnf(format string, v ...any) {
|
||||||
log.SqlQueryf(format, v...)
|
log.SqlQueryf(format, v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Error logs error log
|
// Error logs error log
|
||||||
func (logger XOrmLoggerAdapter) Error(v ...interface{}) {
|
func (logger XOrmLoggerAdapter) Error(v ...any) {
|
||||||
log.SqlQuery(v...)
|
log.SqlQuery(v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Errorf logs error log with custom format
|
// Errorf logs error log with custom format
|
||||||
func (logger XOrmLoggerAdapter) Errorf(format string, v ...interface{}) {
|
func (logger XOrmLoggerAdapter) Errorf(format string, v ...any) {
|
||||||
log.SqlQueryf(format, v...)
|
log.SqlQueryf(format, v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -38,7 +38,7 @@ type Error struct {
|
|||||||
HttpStatusCode int
|
HttpStatusCode int
|
||||||
Message string
|
Message string
|
||||||
BaseError []error
|
BaseError []error
|
||||||
Context interface{}
|
Context any
|
||||||
}
|
}
|
||||||
|
|
||||||
// Error returns the error message
|
// Error returns the error message
|
||||||
@@ -83,7 +83,7 @@ func NewIncompleteOrIncorrectSubmissionError(err error) *Error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewErrorWithContext returns a new error instance with specified context
|
// NewErrorWithContext returns a new error instance with specified context
|
||||||
func NewErrorWithContext(baseError *Error, context interface{}) *Error {
|
func NewErrorWithContext(baseError *Error, context any) *Error {
|
||||||
return &Error{
|
return &Error{
|
||||||
Category: baseError.Category,
|
Category: baseError.Category,
|
||||||
SubCategory: baseError.SubCategory,
|
SubCategory: baseError.SubCategory,
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ type BankOfCanadaExchangeRateData struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// BankOfCanadaObservationData represents the observation data from bank of Canada
|
// BankOfCanadaObservationData represents the observation data from bank of Canada
|
||||||
type BankOfCanadaObservationData map[string]interface{}
|
type BankOfCanadaObservationData map[string]any
|
||||||
|
|
||||||
// ToLatestExchangeRateResponse returns a view-object according to original data from bank of Canada
|
// ToLatestExchangeRateResponse returns a view-object according to original data from bank of Canada
|
||||||
func (e *BankOfCanadaExchangeRateData) ToLatestExchangeRateResponse(c *core.Context) *models.LatestExchangeRateResponse {
|
func (e *BankOfCanadaExchangeRateData) ToLatestExchangeRateResponse(c *core.Context) *models.LatestExchangeRateResponse {
|
||||||
@@ -62,7 +62,7 @@ func (e *BankOfCanadaExchangeRateData) ToLatestExchangeRateResponse(c *core.Cont
|
|||||||
|
|
||||||
currencyCode := utils.SubString(typeName, 2, 3)
|
currencyCode := utils.SubString(typeName, 2, 3)
|
||||||
|
|
||||||
if data, ok := exchangeRateData.(map[string]interface{}); ok {
|
if data, ok := exchangeRateData.(map[string]any); ok {
|
||||||
exchangeRate := data["v"]
|
exchangeRate := data["v"]
|
||||||
|
|
||||||
if exchangeRateValue, ok2 := exchangeRate.(string); ok2 {
|
if exchangeRateValue, ok2 := exchangeRate.(string); ok2 {
|
||||||
|
|||||||
+16
-16
@@ -99,93 +99,93 @@ func SetLoggerConfiguration(config *settings.Config, isDisableBootLog bool) erro
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Debugf logs debug log with custom format
|
// Debugf logs debug log with custom format
|
||||||
func Debugf(format string, args ...interface{}) {
|
func Debugf(format string, args ...any) {
|
||||||
defaultLogger.Debug(getFinalLog(format, args...))
|
defaultLogger.Debug(getFinalLog(format, args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
// DebugfWithRequestId logs debug log with custom format and request id
|
// DebugfWithRequestId logs debug log with custom format and request id
|
||||||
func DebugfWithRequestId(c *core.Context, format string, args ...interface{}) {
|
func DebugfWithRequestId(c *core.Context, format string, args ...any) {
|
||||||
defaultLogger.WithField(logFieldRequestId, c.GetRequestId()).Debug(getFinalLog(format, args...))
|
defaultLogger.WithField(logFieldRequestId, c.GetRequestId()).Debug(getFinalLog(format, args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Infof logs info log with custom format
|
// Infof logs info log with custom format
|
||||||
func Infof(format string, args ...interface{}) {
|
func Infof(format string, args ...any) {
|
||||||
defaultLogger.Info(getFinalLog(format, args...))
|
defaultLogger.Info(getFinalLog(format, args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
// InfofWithRequestId logs info log with custom format and request id
|
// InfofWithRequestId logs info log with custom format and request id
|
||||||
func InfofWithRequestId(c *core.Context, format string, args ...interface{}) {
|
func InfofWithRequestId(c *core.Context, format string, args ...any) {
|
||||||
defaultLogger.WithField(logFieldRequestId, c.GetRequestId()).Info(getFinalLog(format, args...))
|
defaultLogger.WithField(logFieldRequestId, c.GetRequestId()).Info(getFinalLog(format, args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Warnf logs warn log with custom format
|
// Warnf logs warn log with custom format
|
||||||
func Warnf(format string, args ...interface{}) {
|
func Warnf(format string, args ...any) {
|
||||||
defaultLogger.Warn(getFinalLog(format, args...))
|
defaultLogger.Warn(getFinalLog(format, args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
// WarnfWithRequestId logs warn log with custom format and request id
|
// WarnfWithRequestId logs warn log with custom format and request id
|
||||||
func WarnfWithRequestId(c *core.Context, format string, args ...interface{}) {
|
func WarnfWithRequestId(c *core.Context, format string, args ...any) {
|
||||||
defaultLogger.WithField(logFieldRequestId, c.GetRequestId()).Warn(getFinalLog(format, args...))
|
defaultLogger.WithField(logFieldRequestId, c.GetRequestId()).Warn(getFinalLog(format, args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Errorf logs error log with custom format
|
// Errorf logs error log with custom format
|
||||||
func Errorf(format string, args ...interface{}) {
|
func Errorf(format string, args ...any) {
|
||||||
defaultLogger.Error(getFinalLog(format, args...))
|
defaultLogger.Error(getFinalLog(format, args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
// ErrorfWithRequestId logs error log with custom format and request id
|
// ErrorfWithRequestId logs error log with custom format and request id
|
||||||
func ErrorfWithRequestId(c *core.Context, format string, args ...interface{}) {
|
func ErrorfWithRequestId(c *core.Context, format string, args ...any) {
|
||||||
defaultLogger.WithField(logFieldRequestId, c.GetRequestId()).Error(getFinalLog(format, args...))
|
defaultLogger.WithField(logFieldRequestId, c.GetRequestId()).Error(getFinalLog(format, args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
// ErrorfWithRequestIdAndExtra logs error log with custom format and request id and extra info
|
// ErrorfWithRequestIdAndExtra logs error log with custom format and request id and extra info
|
||||||
func ErrorfWithRequestIdAndExtra(c *core.Context, extraString string, format string, args ...interface{}) {
|
func ErrorfWithRequestIdAndExtra(c *core.Context, extraString string, format string, args ...any) {
|
||||||
defaultLogger.WithField(logFieldRequestId, c.GetRequestId()).WithField(logFieldExtra, extraString).Error(getFinalLog(format, args...))
|
defaultLogger.WithField(logFieldRequestId, c.GetRequestId()).WithField(logFieldExtra, extraString).Error(getFinalLog(format, args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
// BootInfof logs boot info log
|
// BootInfof logs boot info log
|
||||||
func BootInfof(format string, args ...interface{}) {
|
func BootInfof(format string, args ...any) {
|
||||||
if bootLogger != nil {
|
if bootLogger != nil {
|
||||||
bootLogger.Info(getFinalLog(format, args...))
|
bootLogger.Info(getFinalLog(format, args...))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// BootWarnf logs boot warn log
|
// BootWarnf logs boot warn log
|
||||||
func BootWarnf(format string, args ...interface{}) {
|
func BootWarnf(format string, args ...any) {
|
||||||
if bootLogger != nil {
|
if bootLogger != nil {
|
||||||
bootLogger.Warn(getFinalLog(format, args...))
|
bootLogger.Warn(getFinalLog(format, args...))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// BootErrorf logs boot error log
|
// BootErrorf logs boot error log
|
||||||
func BootErrorf(format string, args ...interface{}) {
|
func BootErrorf(format string, args ...any) {
|
||||||
if bootLogger != nil {
|
if bootLogger != nil {
|
||||||
bootLogger.Error(getFinalLog(format, args...))
|
bootLogger.Error(getFinalLog(format, args...))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Requestf logs http request log with custom format
|
// Requestf logs http request log with custom format
|
||||||
func Requestf(c *core.Context, format string, args ...interface{}) {
|
func Requestf(c *core.Context, format string, args ...any) {
|
||||||
if requestLogger != nil {
|
if requestLogger != nil {
|
||||||
requestLogger.WithField(logFieldRequestId, c.GetRequestId()).Info(getFinalLog(format, args...))
|
requestLogger.WithField(logFieldRequestId, c.GetRequestId()).Info(getFinalLog(format, args...))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SqlQuery logs sql query log
|
// SqlQuery logs sql query log
|
||||||
func SqlQuery(args ...interface{}) {
|
func SqlQuery(args ...any) {
|
||||||
if sqlQueryLogger != nil {
|
if sqlQueryLogger != nil {
|
||||||
sqlQueryLogger.Info(args...)
|
sqlQueryLogger.Info(args...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SqlQueryf logs sql query log with custom format
|
// SqlQueryf logs sql query log with custom format
|
||||||
func SqlQueryf(format string, args ...interface{}) {
|
func SqlQueryf(format string, args ...any) {
|
||||||
if sqlQueryLogger != nil {
|
if sqlQueryLogger != nil {
|
||||||
sqlQueryLogger.Info(getFinalLog(format, args...))
|
sqlQueryLogger.Info(getFinalLog(format, args...))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getFinalLog(format string, args ...interface{}) string {
|
func getFinalLog(format string, args ...any) string {
|
||||||
result := fmt.Sprintf(format, args...)
|
result := fmt.Sprintf(format, args...)
|
||||||
result = strings.Replace(result, "\n", " ", -1)
|
result = strings.Replace(result, "\n", " ", -1)
|
||||||
|
|
||||||
|
|||||||
@@ -58,9 +58,9 @@ func (s *ForgetPasswordService) SendPasswordResetEmail(c *core.Context, user *mo
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
templateParams := map[string]interface{}{
|
templateParams := map[string]any{
|
||||||
"AppName": s.CurrentConfig().AppName,
|
"AppName": s.CurrentConfig().AppName,
|
||||||
"ForgetPasswordMail": map[string]interface{}{
|
"ForgetPasswordMail": map[string]any{
|
||||||
"Title": forgetPasswordTextItems.Title,
|
"Title": forgetPasswordTextItems.Title,
|
||||||
"Salutation": fmt.Sprintf(forgetPasswordTextItems.SalutationFormat, user.Nickname),
|
"Salutation": fmt.Sprintf(forgetPasswordTextItems.SalutationFormat, user.Nickname),
|
||||||
"DescriptionAboveBtn": forgetPasswordTextItems.DescriptionAboveBtn,
|
"DescriptionAboveBtn": forgetPasswordTextItems.DescriptionAboveBtn,
|
||||||
|
|||||||
@@ -237,7 +237,7 @@ func (s *TokenService) parseToken(c *core.Context, extractor request.Extractor)
|
|||||||
claims := &core.UserTokenClaims{}
|
claims := &core.UserTokenClaims{}
|
||||||
|
|
||||||
token, err := request.ParseFromRequest(c.Request, extractor,
|
token, err := request.ParseFromRequest(c.Request, extractor,
|
||||||
func(token *jwt.Token) (interface{}, error) {
|
func(token *jwt.Token) (any, error) {
|
||||||
now := time.Now().Unix()
|
now := time.Now().Unix()
|
||||||
userTokenId, err := utils.StringToInt64(claims.UserTokenId)
|
userTokenId, err := utils.StringToInt64(claims.UserTokenId)
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ func (s *TransactionCategoryService) GetAllCategoriesByUid(c *core.Context, uid
|
|||||||
}
|
}
|
||||||
|
|
||||||
condition := "uid=? AND deleted=?"
|
condition := "uid=? AND deleted=?"
|
||||||
conditionParams := make([]interface{}, 0, 8)
|
conditionParams := make([]any, 0, 8)
|
||||||
conditionParams = append(conditionParams, uid)
|
conditionParams = append(conditionParams, uid)
|
||||||
conditionParams = append(conditionParams, false)
|
conditionParams = append(conditionParams, false)
|
||||||
|
|
||||||
|
|||||||
@@ -1115,7 +1115,7 @@ func (s *TransactionService) GetAccountsAndCategoriesTotalIncomeAndExpense(c *co
|
|||||||
}
|
}
|
||||||
|
|
||||||
condition := "uid=? AND deleted=? AND (type=? OR type=?)"
|
condition := "uid=? AND deleted=? AND (type=? OR type=?)"
|
||||||
conditionParams := make([]interface{}, 0, 8)
|
conditionParams := make([]any, 0, 8)
|
||||||
conditionParams = append(conditionParams, uid)
|
conditionParams = append(conditionParams, uid)
|
||||||
conditionParams = append(conditionParams, false)
|
conditionParams = append(conditionParams, false)
|
||||||
conditionParams = append(conditionParams, models.TRANSACTION_DB_TYPE_INCOME)
|
conditionParams = append(conditionParams, models.TRANSACTION_DB_TYPE_INCOME)
|
||||||
@@ -1153,9 +1153,9 @@ func (s *TransactionService) GetTransactionMapByList(transactions []*models.Tran
|
|||||||
return transactionMap
|
return transactionMap
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *TransactionService) getTransactionQueryCondition(uid int64, maxTransactionTime int64, minTransactionTime int64, transactionType models.TransactionDbType, categoryIds []int64, accountIds []int64, keyword string, noDuplicated bool) (string, []interface{}) {
|
func (s *TransactionService) getTransactionQueryCondition(uid int64, maxTransactionTime int64, minTransactionTime int64, transactionType models.TransactionDbType, categoryIds []int64, accountIds []int64, keyword string, noDuplicated bool) (string, []any) {
|
||||||
condition := "uid=? AND deleted=?"
|
condition := "uid=? AND deleted=?"
|
||||||
conditionParams := make([]interface{}, 0, 16)
|
conditionParams := make([]any, 0, 16)
|
||||||
conditionParams = append(conditionParams, uid)
|
conditionParams = append(conditionParams, uid)
|
||||||
conditionParams = append(conditionParams, false)
|
conditionParams = append(conditionParams, false)
|
||||||
|
|
||||||
|
|||||||
@@ -439,9 +439,9 @@ func (s *UserService) SendVerifyEmail(user *models.User, verifyEmailToken string
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
templateParams := map[string]interface{}{
|
templateParams := map[string]any{
|
||||||
"AppName": s.CurrentConfig().AppName,
|
"AppName": s.CurrentConfig().AppName,
|
||||||
"VerifyEmail": map[string]interface{}{
|
"VerifyEmail": map[string]any{
|
||||||
"Title": verifyEmailTextItems.Title,
|
"Title": verifyEmailTextItems.Title,
|
||||||
"Salutation": fmt.Sprintf(verifyEmailTextItems.SalutationFormat, user.Nickname),
|
"Salutation": fmt.Sprintf(verifyEmailTextItems.SalutationFormat, user.Nickname),
|
||||||
"DescriptionAboveBtn": verifyEmailTextItems.DescriptionAboveBtn,
|
"DescriptionAboveBtn": verifyEmailTextItems.DescriptionAboveBtn,
|
||||||
|
|||||||
+1
-1
@@ -12,7 +12,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// PrintJsonSuccessResult writes success response in json format to current http context
|
// PrintJsonSuccessResult writes success response in json format to current http context
|
||||||
func PrintJsonSuccessResult(c *core.Context, result interface{}) {
|
func PrintJsonSuccessResult(c *core.Context, result any) {
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"success": true,
|
"success": true,
|
||||||
"result": result,
|
"result": result,
|
||||||
|
|||||||
+2
-2
@@ -8,7 +8,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Clone deep-clones src object to dst object
|
// Clone deep-clones src object to dst object
|
||||||
func Clone(src, dst interface{}) error {
|
func Clone(src, dst any) error {
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
|
|
||||||
if err := gob.NewEncoder(&buf).Encode(src); err != nil {
|
if err := gob.NewEncoder(&buf).Encode(src); err != nil {
|
||||||
@@ -25,7 +25,7 @@ func Clone(src, dst interface{}) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PrintObjectFields prints all fields in specified object
|
// PrintObjectFields prints all fields in specified object
|
||||||
func PrintObjectFields(obj interface{}) {
|
func PrintObjectFields(obj any) {
|
||||||
if obj == nil {
|
if obj == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user