forked from free-lancers/electricity_bill_calc_service
enhance(report):在初始化报表的时候,一并初始化园区电量概要。
This commit is contained in:
@@ -104,13 +104,30 @@ func (_ReportService) IsNewPeriodValid(uid string, period time.Time) (bool, erro
|
||||
}
|
||||
}
|
||||
|
||||
func (_ReportService) InitializeNewReport(report model.Report) (err error) {
|
||||
report.Id = uuid.New().String()
|
||||
report.StepState = model.NewSteps()
|
||||
report.Published = false
|
||||
report.Withdraw = model.REPORT_NOT_WITHDRAW
|
||||
_, err = global.DBConn.Insert(report)
|
||||
func (_ReportService) InitializeNewReport(parkId string, period time.Time) (err error) {
|
||||
newReport := model.Report{
|
||||
Id: uuid.New().String(),
|
||||
ParkId: parkId,
|
||||
StepState: model.NewSteps(),
|
||||
Published: false,
|
||||
Withdraw: model.REPORT_NOT_WITHDRAW,
|
||||
}
|
||||
newReportSummary := model.ReportSummary{
|
||||
ReportId: newReport.Id,
|
||||
}
|
||||
tx := global.DBConn.NewSession()
|
||||
if err = tx.Begin(); err != nil {
|
||||
return
|
||||
}
|
||||
defer tx.Close()
|
||||
_, err = tx.Insert(newReport, newReportSummary)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return
|
||||
}
|
||||
err = tx.Commit()
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return
|
||||
}
|
||||
return nil
|
||||
|
Reference in New Issue
Block a user