fix(service):修正一些使用错误。
This commit is contained in:
parent
60d2db6cdd
commit
ffaccc4c88
|
@ -1,12 +0,0 @@
|
|||
package service
|
||||
|
||||
func _postProcessSingle[T interface{}](instance *T, has bool, err error) (*T, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if has {
|
||||
return instance, nil
|
||||
} else {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
|
@ -69,7 +69,7 @@ func (_EndUserService) SearchEndUserRecord(reportId, keyword string, page int) (
|
|||
|
||||
relations := []string{"end_user", "report", "park"}
|
||||
for _, eu := range endUsers {
|
||||
relations = append(relations, fmt.Sprintf("end_user:%s:%d", eu.ReportId, eu.MeterId))
|
||||
relations = append(relations, fmt.Sprintf("end_user:%s:%s", eu.ReportId, eu.MeterId))
|
||||
}
|
||||
cache.CacheCount(relations, "end_user_detail", int64(total), conditions...)
|
||||
cache.CacheSearch(endUsers, relations, "end_user_detail", conditions...)
|
||||
|
@ -164,7 +164,7 @@ func (es _EndUserService) BatchImportNonPVRegister(reportId string, file io.Read
|
|||
errs.AddError(es.newVirtualExcelAnalysisError(err))
|
||||
return errs
|
||||
}
|
||||
reportDetail := new(model.Report)
|
||||
var reportDetail *model.Report
|
||||
err = global.DB.NewSelect().Model(reportDetail).
|
||||
Where("id = ?", reportId).
|
||||
Scan(ctx)
|
||||
|
@ -269,7 +269,7 @@ func (es _EndUserService) BatchImportPVRegister(reportId string, file io.Reader)
|
|||
errs.AddError(es.newVirtualExcelAnalysisError(err))
|
||||
return errs
|
||||
}
|
||||
reportDetail := new(model.Report)
|
||||
var reportDetail *model.Report
|
||||
err = global.DB.NewSelect().Model(reportDetail).Where("id = ?", reportId).Scan(ctx)
|
||||
if err != nil {
|
||||
errs.AddError(es.newVirtualExcelAnalysisError(err))
|
||||
|
|
|
@ -28,7 +28,7 @@ var GodModeService = _GodModeService{
|
|||
// 从此处开始为删除报表相关的部分
|
||||
|
||||
func (_GodModeService) resetReportIndex(tx *bun.Tx, ctx *context.Context, reportId string) (bool, error) {
|
||||
var report = new(model.Report)
|
||||
var report *model.Report
|
||||
err := tx.NewSelect().Model(report).Where("id = ?", reportId).Scan(*ctx)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
|
|
|
@ -66,7 +66,7 @@ func (_ReportService) FetchParksWithNewestReport(uid string) ([]model.ParkNewest
|
|||
make(map[string]model.ParkNewestReport, 0),
|
||||
)
|
||||
relations := lo.Map(reports, func(r model.Report, _ int) string {
|
||||
return fmt.Sprint("report:%s", r.Id)
|
||||
return fmt.Sprintf("report:%s", r.Id)
|
||||
})
|
||||
relations = append(relations, "park", "report")
|
||||
cache.CacheSearch(reducedParks, relations, "park_newest_report", uid)
|
||||
|
@ -277,7 +277,7 @@ func (_ReportService) RetreiveReportIndex(rid string) (*model.Report, error) {
|
|||
}
|
||||
ctx, cancel := global.TimeoutContext()
|
||||
defer cancel()
|
||||
report := new(model.Report)
|
||||
var report *model.Report
|
||||
err := global.DB.NewSelect().Model(report).
|
||||
Where("id = ?", rid).
|
||||
Scan(ctx)
|
||||
|
|
Loading…
Reference in New Issue
Block a user