forked from free-lancers/electricity_bill_calc_service
		
	fix(#10):修复空指针
This commit is contained in:
		| @@ -9,6 +9,7 @@ import ( | ||||
| 	"electricity_bill_calc/tools" | ||||
| 	"electricity_bill_calc/types" | ||||
| 	"fmt" | ||||
| 	"log" | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/doug-martin/goqu/v9" | ||||
| @@ -238,8 +239,11 @@ func (ur _UserRepository) FindUser(keyword *string, userType int16, state *bool, | ||||
| 	} | ||||
|  | ||||
| 	if state != nil { | ||||
| 		userQuery = userQuery.Where(goqu.Ex{"u.enabled": state}) | ||||
| 		countQuery = countQuery.Where(goqu.Ex{"u.enabled": state}) | ||||
| 		//userQuery = userQuery.Where(goqu.C("u.enabled").Eq(*state)) | ||||
| 		userQuery = userQuery.Where(goqu.Ex{"u.enabled": *state}) | ||||
| 		countQuery = countQuery.Where(goqu.Ex{"u.enabled": *state}) | ||||
| 		//countQuery = countQuery.Where(goqu.C("u.enabled").Eq(*state)) | ||||
|  | ||||
| 	} | ||||
|  | ||||
| 	userQuery.Order(goqu.I("u.created_at").Desc()) | ||||
| @@ -249,8 +253,9 @@ func (ur _UserRepository) FindUser(keyword *string, userType int16, state *bool, | ||||
|  | ||||
| 	userSql, userParams, _ := userQuery.Prepared(true).ToSQL() | ||||
| 	countSql, countParams, _ := countQuery.Prepared(true).ToSQL() | ||||
| 	log.Println(">>>>>>>>>>>", userSql) | ||||
| 	if err := pgxscan.Select(ctx, global.DB, &userWithDetails, userSql, userParams...); err != nil { | ||||
| 		ur.log.Error("从数据库查询用户列表失败。", zap.Error(err)) | ||||
| 		ur.log.Error("从数据库查询用户列表失败。》》》》》》》》》》》》》》", zap.Error(err)) | ||||
| 		return make([]*model.UserWithDetail, 0), 0, err | ||||
| 	} | ||||
| 	if err := pgxscan.Get(ctx, global.DB, &userCount, countSql, countParams...); err != nil { | ||||
|   | ||||
| @@ -4,7 +4,7 @@ import ( | ||||
| 	"electricity_bill_calc/model" | ||||
| 	"electricity_bill_calc/model/calculate" | ||||
| 	"electricity_bill_calc/repository" | ||||
| 	"fmt" | ||||
| 	"electricity_bill_calc/types" | ||||
| 	"github.com/shopspring/decimal" | ||||
| 	"time" | ||||
| 	"unsafe" | ||||
| @@ -44,7 +44,10 @@ func PooledMetersCalculate(report *model.ReportIndex, periodStart time.Time, | ||||
| func determinePublicMeterConsumptions(meterId string, periodStart time.Time, | ||||
| 	periodEnd time.Time, readings []model.MeterReading, | ||||
| 	meterDetail model.MeterDetail, summary calculate.Summary) (calculate.Meter, error) { | ||||
| 	fmt.Println(meterDetail.DetachedAt) | ||||
| 	if meterDetail.DetachedAt == nil { | ||||
| 		zeroTime := time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC) | ||||
| 		meterDetail.DetachedAt = &types.DateTime{Time: zeroTime} | ||||
| 	} | ||||
| 	startReading, err := DeterminePublicMeterStartReading(meterId, periodStart, meterDetail.DetachedAt.Time, readings) | ||||
| 	if err != nil { | ||||
| 		return calculate.Meter{}, err | ||||
|   | ||||
| @@ -12,9 +12,9 @@ Server: | ||||
|   ReadTimeout: 60 | ||||
|   WriteTimeout: 60 | ||||
| Redis: | ||||
|   Host: 127.0.0.1 | ||||
|   Host: 192.168.88.129 | ||||
|   Port: 6379 | ||||
|   Password: | ||||
|   Password: 123456 | ||||
|   DB: 1 | ||||
| Service: | ||||
|   MaxSessionLife: 2h | ||||
|   | ||||
		Reference in New Issue
	
	Block a user