refactor(park):补充重构删除原time模块以后的问题。

This commit is contained in:
徐涛 2023-06-05 22:16:14 +08:00
parent 8aa3a054b0
commit bfb59a3626
2 changed files with 14 additions and 14 deletions

View File

@ -7,7 +7,7 @@ import (
"electricity_bill_calc/model" "electricity_bill_calc/model"
"electricity_bill_calc/tools" "electricity_bill_calc/tools"
"electricity_bill_calc/tools/serial" "electricity_bill_calc/tools/serial"
"electricity_bill_calc/tools/time" "electricity_bill_calc/types"
"fmt" "fmt"
"strings" "strings"
@ -99,7 +99,7 @@ func (pr _ParkRepository) CreatePark(ownerId string, park *model.Park) (bool, er
ctx, cancel := global.TimeoutContext() ctx, cancel := global.TimeoutContext()
defer cancel() defer cancel()
timeNow := time.Now() timeNow := types.Now()
createSql, createArgs, _ := pr.ds. createSql, createArgs, _ := pr.ds.
Insert("park"). Insert("park").
Cols( Cols(
@ -183,7 +183,7 @@ func (pr _ParkRepository) UpdatePark(pid string, park *model.Park) (bool, error)
ctx, cancel := global.TimeoutContext() ctx, cancel := global.TimeoutContext()
defer cancel() defer cancel()
timeNow := time.Now() timeNow := types.Now()
updateSql, updateArgs, _ := pr.ds. updateSql, updateArgs, _ := pr.ds.
Update("park"). Update("park").
Set(goqu.Record{ Set(goqu.Record{
@ -228,7 +228,7 @@ func (pr _ParkRepository) EnablingPark(pid string, enabled bool) (bool, error) {
ctx, cancel := global.TimeoutContext() ctx, cancel := global.TimeoutContext()
defer cancel() defer cancel()
timeNow := time.Now() timeNow := types.Now()
updateSql, updateArgs, _ := pr.ds. updateSql, updateArgs, _ := pr.ds.
Update("park"). Update("park").
Set(goqu.Record{ Set(goqu.Record{
@ -257,7 +257,7 @@ func (pr _ParkRepository) DeletePark(pid string) (bool, error) {
ctx, cancel := global.TimeoutContext() ctx, cancel := global.TimeoutContext()
defer cancel() defer cancel()
timeNow := time.Now() timeNow := types.Now()
updateSql, updateArgs, _ := pr.ds. updateSql, updateArgs, _ := pr.ds.
Update("park"). Update("park").
Set(goqu.Record{ Set(goqu.Record{
@ -346,7 +346,7 @@ func (pr _ParkRepository) CreateParkBuilding(pid, name string, floor *string) (b
ctx, cancel := global.TimeoutContext() ctx, cancel := global.TimeoutContext()
defer cancel() defer cancel()
timeNow := time.Now() timeNow := types.Now()
createSql, createArgs, _ := pr.ds. createSql, createArgs, _ := pr.ds.
Insert("park_building"). Insert("park_building").
Cols( Cols(
@ -378,7 +378,7 @@ func (pr _ParkRepository) ModifyParkBuilding(id, pid, name string, floor *string
ctx, cancel := global.TimeoutContext() ctx, cancel := global.TimeoutContext()
defer cancel() defer cancel()
timeNow := time.Now() timeNow := types.Now()
updateSql, updateArgs, _ := pr.ds. updateSql, updateArgs, _ := pr.ds.
Update("park_building"). Update("park_building").
Set(goqu.Record{ Set(goqu.Record{
@ -412,7 +412,7 @@ func (pr _ParkRepository) EnablingParkBuilding(id, pid string, enabled bool) (bo
ctx, cancel := global.TimeoutContext() ctx, cancel := global.TimeoutContext()
defer cancel() defer cancel()
timeNow := time.Now() timeNow := types.Now()
updateSql, updateArgs, _ := pr.ds. updateSql, updateArgs, _ := pr.ds.
Update("park_building"). Update("park_building").
Set(goqu.Record{ Set(goqu.Record{
@ -445,7 +445,7 @@ func (pr _ParkRepository) DeleteParkBuilding(id, pid string) (bool, error) {
ctx, cancel := global.TimeoutContext() ctx, cancel := global.TimeoutContext()
defer cancel() defer cancel()
timeNow := time.Now() timeNow := types.Now()
updateSql, updateArgs, _ := pr.ds. updateSql, updateArgs, _ := pr.ds.
Update("park_building"). Update("park_building").
Set(goqu.Record{ Set(goqu.Record{

View File

@ -8,10 +8,10 @@ import (
"electricity_bill_calc/logger" "electricity_bill_calc/logger"
"electricity_bill_calc/model" "electricity_bill_calc/model"
"electricity_bill_calc/tools" "electricity_bill_calc/tools"
"electricity_bill_calc/tools/time" "electricity_bill_calc/types"
"fmt" "fmt"
"strings" "strings"
stdTime "time" "time"
"github.com/doug-martin/goqu/v9" "github.com/doug-martin/goqu/v9"
_ "github.com/doug-martin/goqu/v9/dialect/postgres" _ "github.com/doug-martin/goqu/v9/dialect/postgres"
@ -181,7 +181,7 @@ func (ur _UserRepository) CreateUser(user model.User, detail model.UserDetail, o
return false, err return false, err
} }
createdTime := time.Now() createdTime := types.Now()
userSql, userParams, _ := ur.ds. userSql, userParams, _ := ur.ds.
Insert("user"). Insert("user").
Rows( Rows(
@ -331,7 +331,7 @@ func (ur _UserRepository) UpdateDetail(uid string, userDetail model.UserModifica
updates := goqu.Record{ updates := goqu.Record{
"name": userDetail.Name, "abbr": tools.PinyinAbbr(userDetail.Name), "region": userDetail.Region, "name": userDetail.Name, "abbr": tools.PinyinAbbr(userDetail.Name), "region": userDetail.Region,
"address": userDetail.Address, "contact": userDetail.Contact, "phone": userDetail.Phone, "address": userDetail.Address, "contact": userDetail.Contact, "phone": userDetail.Phone,
"last_modified_at": time.Now(), "last_modified_by": operator, "last_modified_at": types.Now(), "last_modified_by": operator,
} }
if userDetail.UnitServiceFee != nil { if userDetail.UnitServiceFee != nil {
updates = lo.Assign(updates, goqu.Record{"unit_service_fee": userDetail.UnitServiceFee}) updates = lo.Assign(updates, goqu.Record{"unit_service_fee": userDetail.UnitServiceFee})
@ -451,7 +451,7 @@ func (ur _UserRepository) SearchUsersWithLimit(userType *int16, keyword *string,
} }
// 更新指定用户的服务有效期限 // 更新指定用户的服务有效期限
func (ur _UserRepository) UpdateServiceExpiration(tx pgx.Tx, ctx context.Context, uid string, expiration stdTime.Time) (bool, error) { func (ur _UserRepository) UpdateServiceExpiration(tx pgx.Tx, ctx context.Context, uid string, expiration time.Time) (bool, error) {
ur.log.Info("更新指定用户的服务有效期限。", zap.String("user id", uid)) ur.log.Info("更新指定用户的服务有效期限。", zap.String("user id", uid))
userDetailUpdateQuery := ur.ds. userDetailUpdateQuery := ur.ds.