electricity_bill_calc_service/model/report.go

89 lines
3.2 KiB
Go

package model
import "time"
const (
REPORT_NOT_WITHDRAW int8 = iota
REPORT_WITHDRAW_APPLIED
REPORT_WITHDRAW_DENIED
REPORT_WITHDRAW_GRANTED
)
type Report struct {
CreatedAndModified `xorm:"extends"`
Id string `xorm:"varchar(120) pk not null" json:"id"`
ParkId string `xorm:"varchar(120) not null" json:"parkId"`
Period time.Time `xorm:"date not null" json:"period" time_format:"simple_date" time_location:"shanghai"`
StepState Steps `xorm:"text not null json" json:"stepState"`
Published bool `xorm:"bool not null default false" json:"published"`
PublishedAt *time.Time `xorm:"timestampz" json:"publishedAt" time_format:"simple_datetime" time_location:"shanghai"`
Withdraw int8 `xorm:"smallint not null default 0" json:"withdraw"`
LastWithdrawAppliedAt *time.Time `xorm:"timestampz" json:"lastWithdrawAppliedAt" time_format:"simple_datetime" time_location:"shanghai"`
LastWithdrawAuditAt *time.Time `xorm:"timestampz" json:"lastWithdrawAuditAt" time_format:"simple_datetime" time_location:"shanghai"`
}
type Steps struct {
Summary bool `json:"summary"`
WillDiluted bool `json:"willDiluted"`
Submeter bool `json:"submeter"`
Calculate bool `json:"calculate"`
Preview bool `json:"preview"`
Publish bool `json:"publish"`
}
func (Report) TableName() string {
return "report"
}
func NewSteps() Steps {
return Steps{
Summary: false,
WillDiluted: false,
Submeter: false,
Calculate: false,
Preview: false,
Publish: false,
}
}
type ParkNewestReport struct {
Park Park `xorm:"extends" json:"park"`
Report *Report `xorm:"extends" json:"report"`
}
func (ParkNewestReport) TableName() string {
return "park"
}
func (p *ParkNewestReport) AfterLoad() {
if p.Report != nil && len(p.Report.Id) == 0 {
p.Report = nil
}
}
type ReportIndexSimplified struct {
Id string `xorm:"varchar(120) pk not null" json:"id"`
ParkId string `xorm:"varchar(120) not null" json:"parkId"`
Period time.Time `xorm:"date not null" json:"period" time_format:"simple_date" time_location:"shanghai"`
StepState Steps `xorm:"text not null json" json:"stepState"`
Published bool `xorm:"bool not null default false" json:"published"`
PublishedAt *time.Time `xorm:"timestampz" json:"publishedAt" time_format:"simple_datetime" time_location:"shanghai"`
Withdraw int8 `xorm:"smallint not null default 0" json:"withdraw"`
LastWithdrawAppliedAt *time.Time `xorm:"timestampz" json:"lastWithdrawAppliedAt" time_format:"simple_datetime" time_location:"shanghai"`
LastWithdrawAuditAt *time.Time `xorm:"timestampz" json:"lastWithdrawAuditAt" time_format:"simple_datetime" time_location:"shanghai"`
}
func (ReportIndexSimplified) TableName() string {
return "report"
}
type JoinedReportForWithdraw struct {
Report ReportIndexSimplified `xorm:"extends" json:"report"`
Park ParkSimplified `xorm:"extends" json:"park"`
User UserDetailSimplified `xorm:"extends" json:"user"`
}
func (JoinedReportForWithdraw) TableName() string {
return "report"
}