enhance(god):清除报表中不同部分的时候同时重置报表的进度状态。
This commit is contained in:
parent
466d21e8b4
commit
62a9fec43f
|
@ -436,7 +436,12 @@ func searchReports(c *gin.Context) {
|
||||||
result.NotAccept("查询参数[page]格式不正确。")
|
result.NotAccept("查询参数[page]格式不正确。")
|
||||||
return
|
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 {
|
if err != nil {
|
||||||
result.NotFound(err.Error())
|
result.NotFound(err.Error())
|
||||||
return
|
return
|
||||||
|
|
|
@ -67,16 +67,27 @@ func (_GodModeService) resetReportSummary(tx *xorm.Session, reportId string) (bo
|
||||||
var summary = &model.ReportSummary{
|
var summary = &model.ReportSummary{
|
||||||
ReportId: reportId,
|
ReportId: reportId,
|
||||||
}
|
}
|
||||||
rows, err := tx.ID(reportId).AllCols().NoAutoCondition().Update(summary)
|
_, err := tx.ID(reportId).AllCols().NoAutoCondition().Update(summary)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
return false, err
|
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
|
return rows >= 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (_GodModeService) flushReportMaintenances(tx *xorm.Session, reportId string) (bool, error) {
|
func (_GodModeService) flushReportMaintenances(tx *xorm.Session, reportId string) (bool, error) {
|
||||||
rows, err := tx.
|
_, err := tx.
|
||||||
Where(builder.Eq{"report_id": reportId}).
|
Where(builder.Eq{"report_id": reportId}).
|
||||||
NoAutoCondition().
|
NoAutoCondition().
|
||||||
Delete(new(model.WillDilutedFee))
|
Delete(new(model.WillDilutedFee))
|
||||||
|
@ -84,6 +95,17 @@ func (_GodModeService) flushReportMaintenances(tx *xorm.Session, reportId string
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
return false, err
|
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
|
return rows >= 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,7 +191,18 @@ func (_GodModeService) resetEndUserRecords(tx *xorm.Session, reportId string) (b
|
||||||
return false, err
|
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 {
|
type ReportPeriod struct {
|
||||||
|
|
|
@ -430,10 +430,14 @@ func (_ReportService) PublishReport(report model.Report) (err error) {
|
||||||
return
|
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)
|
var conditions = make([]string, 0)
|
||||||
conditions = append(conditions, strconv.Itoa(requestPage))
|
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 {
|
if len(requestUser) > 0 {
|
||||||
cond = cond.And(builder.Eq{"u.id": requestUser})
|
cond = cond.And(builder.Eq{"u.id": requestUser})
|
||||||
conditions = append(conditions, requestUser)
|
conditions = append(conditions, requestUser)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user