mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-15 23:47:33 +08:00
format code
This commit is contained in:
+11
-11
@@ -63,7 +63,7 @@ func (s *TokenService) ParseToken(c *core.Context) (*jwt.Token, *core.UserTokenC
|
||||
claims := &core.UserTokenClaims{}
|
||||
|
||||
token, err := request.ParseFromRequest(c.Request, request.AuthorizationHeaderExtractor,
|
||||
func (token *jwt.Token) (interface{}, error) {
|
||||
func(token *jwt.Token) (interface{}, error) {
|
||||
uid, err := utils.StringToInt64(claims.Id)
|
||||
now := time.Now().Unix()
|
||||
|
||||
@@ -205,8 +205,8 @@ func (s *TokenService) ParseFromTokenId(tokenId string) (*models.TokenRecord, er
|
||||
}
|
||||
|
||||
tokenRecord := &models.TokenRecord{
|
||||
Uid: uid,
|
||||
UserTokenId: userTokenId,
|
||||
Uid: uid,
|
||||
UserTokenId: userTokenId,
|
||||
CreatedUnixTime: createdUnixTime,
|
||||
}
|
||||
|
||||
@@ -222,10 +222,10 @@ func (s *TokenService) createToken(user *models.User, tokenType core.TokenType,
|
||||
now := time.Now()
|
||||
|
||||
tokenRecord := &models.TokenRecord{
|
||||
Uid: user.Uid,
|
||||
UserTokenId: s.getUserTokenId(),
|
||||
TokenType: tokenType,
|
||||
UserAgent: userAgent,
|
||||
Uid: user.Uid,
|
||||
UserTokenId: s.getUserTokenId(),
|
||||
TokenType: tokenType,
|
||||
UserAgent: userAgent,
|
||||
CreatedUnixTime: now.Unix(),
|
||||
ExpiredUnixTime: now.Add(expiryDate).Unix(),
|
||||
}
|
||||
@@ -236,11 +236,11 @@ func (s *TokenService) createToken(user *models.User, tokenType core.TokenType,
|
||||
|
||||
claims := &core.UserTokenClaims{
|
||||
UserTokenId: utils.Int64ToString(tokenRecord.UserTokenId),
|
||||
Username: user.Username,
|
||||
Type: tokenRecord.TokenType,
|
||||
Username: user.Username,
|
||||
Type: tokenRecord.TokenType,
|
||||
StandardClaims: jwt.StandardClaims{
|
||||
Id: utils.Int64ToString(tokenRecord.Uid),
|
||||
IssuedAt: tokenRecord.CreatedUnixTime,
|
||||
Id: utils.Int64ToString(tokenRecord.Uid),
|
||||
IssuedAt: tokenRecord.CreatedUnixTime,
|
||||
ExpiresAt: tokenRecord.ExpiredUnixTime,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ func (s *TransactionCategoryService) HideCategory(uid int64, ids []int64, hidden
|
||||
now := time.Now().Unix()
|
||||
|
||||
updateModel := &models.TransactionCategory{
|
||||
Hidden: hidden,
|
||||
Hidden: hidden,
|
||||
UpdatedUnixTime: now,
|
||||
}
|
||||
|
||||
@@ -264,7 +264,7 @@ func (s *TransactionCategoryService) DeleteCategory(uid int64, categoryId int64)
|
||||
now := time.Now().Unix()
|
||||
|
||||
updateModel := &models.TransactionCategory{
|
||||
Deleted: true,
|
||||
Deleted: true,
|
||||
DeletedUnixTime: now,
|
||||
}
|
||||
|
||||
|
||||
@@ -164,7 +164,7 @@ func (s *TransactionTagService) HideTag(uid int64, ids []int64, hidden bool) err
|
||||
now := time.Now().Unix()
|
||||
|
||||
updateModel := &models.TransactionTag{
|
||||
Hidden: hidden,
|
||||
Hidden: hidden,
|
||||
UpdatedUnixTime: now,
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ func (s *TransactionService) GetTransactionsInMonthByPage(uid int64, year int, m
|
||||
endUnixTime := endTime.Unix()
|
||||
|
||||
var transactions []*models.Transaction
|
||||
err = s.UserDataDB(uid).Where("uid=? AND deleted=? AND transaction_time>=? AND transaction_time<?", uid, false, startUnixTime, endUnixTime).Limit(count, count * (page - 1)).OrderBy("transaction_time desc").Find(&transactions)
|
||||
err = s.UserDataDB(uid).Where("uid=? AND deleted=? AND transaction_time>=? AND transaction_time<?", uid, false, startUnixTime, endUnixTime).Limit(count, count*(page-1)).OrderBy("transaction_time desc").Find(&transactions)
|
||||
|
||||
return transactions, err
|
||||
}
|
||||
@@ -268,7 +268,7 @@ func (s *TransactionService) CreateTransaction(transaction *models.Transaction,
|
||||
return err
|
||||
} else if !has {
|
||||
return errs.ErrDatabaseOperationFailed
|
||||
} else if sameSecondLatestTransaction.TransactionTime == maxTransactionTime - 1 {
|
||||
} else if sameSecondLatestTransaction.TransactionTime == maxTransactionTime-1 {
|
||||
return errs.ErrTooMuchTransactionInOneSecond
|
||||
}
|
||||
|
||||
@@ -465,9 +465,9 @@ func (s *TransactionService) ModifyTransaction(transaction *models.Transaction,
|
||||
|
||||
has, err = sess.Where("uid=? AND deleted=? AND transaction_time>=? AND transaction_time<=?", transaction.Uid, false, minTransactionTime, maxTransactionTime).OrderBy("transaction_time desc").Limit(1).Get(sameSecondLatestTransaction)
|
||||
|
||||
if has && sameSecondLatestTransaction.TransactionTime < maxTransactionTime - 1 {
|
||||
if has && sameSecondLatestTransaction.TransactionTime < maxTransactionTime-1 {
|
||||
transaction.TransactionTime = sameSecondLatestTransaction.TransactionTime + 1
|
||||
} else if has && sameSecondLatestTransaction.TransactionTime == maxTransactionTime - 1 {
|
||||
} else if has && sameSecondLatestTransaction.TransactionTime == maxTransactionTime-1 {
|
||||
return errs.ErrTooMuchTransactionInOneSecond
|
||||
}
|
||||
|
||||
@@ -634,7 +634,7 @@ func (s *TransactionService) DeleteTransaction(uid int64, transactionId int64) e
|
||||
now := time.Now().Unix()
|
||||
|
||||
updateModel := &models.Transaction{
|
||||
Deleted: true,
|
||||
Deleted: true,
|
||||
DeletedUnixTime: now,
|
||||
}
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@ package services
|
||||
import (
|
||||
"time"
|
||||
|
||||
"xorm.io/xorm"
|
||||
"github.com/pquerna/otp"
|
||||
"github.com/pquerna/otp/totp"
|
||||
"xorm.io/xorm"
|
||||
|
||||
"github.com/mayswind/lab/pkg/datastore"
|
||||
"github.com/mayswind/lab/pkg/errs"
|
||||
|
||||
Reference in New Issue
Block a user