diff --git a/controller/report.go b/controller/report.go index 5456d12..216c0c8 100644 --- a/controller/report.go +++ b/controller/report.go @@ -436,7 +436,12 @@ func searchReports(c *gin.Context) { result.NotAccept("查询参数[page]格式不正确。") return } - records, totalItems, err := service.ReportService.SearchReport(requestUser, requestPark, requestKeyword, requestPeriod, requestPage) + requestAllReports, err := strconv.ParseBool(c.DefaultQuery("all", "false")) + if err != nil { + result.NotAccept("查询参数[all]格式不正确。") + return + } + records, totalItems, err := service.ReportService.SearchReport(requestUser, requestPark, requestKeyword, requestPeriod, requestPage, !requestAllReports) if err != nil { result.NotFound(err.Error()) return diff --git a/service/god_mode.go b/service/god_mode.go index 9649f90..1171f65 100644 --- a/service/god_mode.go +++ b/service/god_mode.go @@ -67,16 +67,27 @@ func (_GodModeService) resetReportSummary(tx *xorm.Session, reportId string) (bo var summary = &model.ReportSummary{ ReportId: reportId, } - rows, err := tx.ID(reportId).AllCols().NoAutoCondition().Update(summary) + _, err := tx.ID(reportId).AllCols().NoAutoCondition().Update(summary) if err != nil { tx.Rollback() return false, err } + var report = new(model.Report) + _, err = tx.ID(reportId).NoAutoCondition().Unscoped().Get(report) + if err != nil { + tx.Rollback() + return false, err + } + report.StepState.Summary = false + rows, err := tx.ID(reportId).Cols("step_state").NoAutoCondition().Update(report) + if err != nil { + tx.Rollback() + } return rows >= 0, err } func (_GodModeService) flushReportMaintenances(tx *xorm.Session, reportId string) (bool, error) { - rows, err := tx. + _, err := tx. Where(builder.Eq{"report_id": reportId}). NoAutoCondition(). Delete(new(model.WillDilutedFee)) @@ -84,6 +95,17 @@ func (_GodModeService) flushReportMaintenances(tx *xorm.Session, reportId string tx.Rollback() return false, err } + var report = new(model.Report) + _, err = tx.ID(reportId).NoAutoCondition().Unscoped().Get(report) + if err != nil { + tx.Rollback() + return false, err + } + report.StepState.WillDiluted = false + rows, err := tx.ID(reportId).Cols("step_state").NoAutoCondition().Update(report) + if err != nil { + tx.Rollback() + } return rows >= 0, err } @@ -169,7 +191,18 @@ func (_GodModeService) resetEndUserRecords(tx *xorm.Session, reportId string) (b return false, err } } - return true, nil + var report = new(model.Report) + _, err = tx.ID(reportId).NoAutoCondition().Unscoped().Get(report) + if err != nil { + tx.Rollback() + return false, err + } + report.StepState.Submeter = false + rows, err := tx.ID(reportId).Cols("step_state").NoAutoCondition().Update(report) + if err != nil { + tx.Rollback() + } + return rows >= 0, nil } type ReportPeriod struct { diff --git a/service/report.go b/service/report.go index 08726a4..e5603a0 100644 --- a/service/report.go +++ b/service/report.go @@ -430,10 +430,14 @@ func (_ReportService) PublishReport(report model.Report) (err error) { return } -func (_ReportService) SearchReport(requestUser, requestPark, requestKeyword string, requestPeriod *time.Time, requestPage int) ([]model.JoinedReportForWithdraw, int64, error) { +func (_ReportService) SearchReport(requestUser, requestPark, requestKeyword string, requestPeriod *time.Time, requestPage int, onlyPublished bool) ([]model.JoinedReportForWithdraw, int64, error) { var conditions = make([]string, 0) conditions = append(conditions, strconv.Itoa(requestPage)) - cond := builder.NewCond().And(builder.Eq{"r.published": true}) + cond := builder.NewCond() + if onlyPublished { + cond = cond.And(builder.Eq{"r.published": true}) + } + conditions = append(conditions, strconv.FormatBool(onlyPublished)) if len(requestUser) > 0 { cond = cond.And(builder.Eq{"u.id": requestUser}) conditions = append(conditions, requestUser)