修复 model 生成脚本,统一时间字段类型为 common.LocalDateTime
This commit is contained in:
@@ -3,6 +3,7 @@ package services
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"platform/web/common"
|
||||
m "platform/web/models"
|
||||
q "platform/web/queries"
|
||||
"time"
|
||||
@@ -121,7 +122,7 @@ func (s *authService) OauthPassword(ctx context.Context, _ *m.Client, data *Gran
|
||||
}
|
||||
|
||||
// 更新用户的登录时间
|
||||
user.LastLogin = time.Now()
|
||||
user.LastLogin = common.LocalDateTime(time.Now())
|
||||
user.LastLoginHost = ip
|
||||
user.LastLoginAgent = agent
|
||||
if err := tx.User.Omit(q.User.AdminID).Save(user); err != nil {
|
||||
|
||||
@@ -299,7 +299,7 @@ func (s *channelService) CreateChannel(
|
||||
step = time.Now()
|
||||
|
||||
now := time.Now()
|
||||
expiration := now.Add(time.Duration(resource.Live) * time.Second)
|
||||
expiration := common.LocalDateTime(now.Add(time.Duration(resource.Live) * time.Second))
|
||||
_addr, channels, err := assignPort(q, edgeAssigns, auth.Payload.Id, protocol, authType, expiration, filter)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -426,7 +426,7 @@ func assignEdge(q *q.Query, count int, filter NodeFilterConfig) (*AssignEdgeResu
|
||||
q.Channel.ProxyPort).
|
||||
Where(
|
||||
q.Channel.ProxyID.In(proxyIds...),
|
||||
q.Channel.Expiration.Gt(time.Now())).
|
||||
q.Channel.Expiration.Gt(common.LocalDateTime(time.Now()))).
|
||||
Group(
|
||||
q.Channel.ProxyPort,
|
||||
q.Channel.ProxyID).
|
||||
@@ -547,7 +547,7 @@ func assignPort(
|
||||
userId int32,
|
||||
protocol ChannelProtocol,
|
||||
authType ChannelAuthType,
|
||||
expiration time.Time,
|
||||
expiration common.LocalDateTime,
|
||||
filter NodeFilterConfig,
|
||||
) ([]*PortInfo, []*models.Channel, error) {
|
||||
var step time.Time
|
||||
@@ -745,9 +745,10 @@ func cache(ctx context.Context, channels []*models.Channel) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
pipe.Set(ctx, chKey(channel), string(marshal), time.Until(channel.Expiration))
|
||||
expiration := time.Time(channel.Expiration)
|
||||
pipe.Set(ctx, chKey(channel), string(marshal), time.Until(expiration))
|
||||
zList = append(zList, redis.Z{
|
||||
Score: float64(channel.Expiration.Unix()),
|
||||
Score: float64(expiration.Unix()),
|
||||
Member: channel.ID,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -45,7 +45,8 @@ func (s *transactionService) PrepareTransaction(ctx context.Context, q *q.Query,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if !coupon.ExpireAt.IsZero() && coupon.ExpireAt.Before(time.Now()) {
|
||||
var expireAt = time.Time(coupon.ExpireAt)
|
||||
if !expireAt.IsZero() && expireAt.Before(time.Now()) {
|
||||
_, err = q.Coupon.
|
||||
Where(q.Coupon.ID.Eq(coupon.ID)).
|
||||
Update(q.Coupon.Status, 2)
|
||||
@@ -71,7 +72,7 @@ func (s *transactionService) PrepareTransaction(ctx context.Context, q *q.Query,
|
||||
// 指定用户的优惠券
|
||||
case coupon.UserID == uid:
|
||||
amount = amount - coupon.Amount
|
||||
if coupon.ExpireAt.IsZero() {
|
||||
if time.Time(coupon.ExpireAt).IsZero() {
|
||||
_, err = q.Coupon.
|
||||
Where(q.Coupon.ID.Eq(coupon.ID)).
|
||||
Update(q.Coupon.Status, 1)
|
||||
|
||||
Reference in New Issue
Block a user