43 lines
1.2 KiB
Go
43 lines
1.2 KiB
Go
package form
|
|
|
|
import (
|
|
"time"
|
|
|
|
db "management/internal/db/sqlc"
|
|
"management/internal/pkg/convertor"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
type ExpenseForm struct {
|
|
ID int64 `json:"id"`
|
|
ProjectID int64 `json:"project_id"`
|
|
BudgetID int64 `json:"budget_id"`
|
|
Amount float64 `json:"amount"`
|
|
AmountF pgtype.Numeric `comment:"报销金额"`
|
|
ExpensesAt time.Time `json:"expenses_at"`
|
|
ExpensesType int32 `json:"expenses_type"`
|
|
Remark string `json:"remark"`
|
|
Status int16 `json:"status"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
CreatedName string `comment:"创建人"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
UpdatedName string `comment:"更新人"`
|
|
}
|
|
|
|
func (f *ExpenseForm) ToForm(p *db.Expense) *ExpenseForm {
|
|
return &ExpenseForm{
|
|
ID: p.ID,
|
|
ProjectID: p.ProjectID,
|
|
BudgetID: p.BudgetID,
|
|
Amount: convertor.NumericToFloat64(p.Amount),
|
|
AmountF: p.Amount,
|
|
ExpensesAt: p.ExpensesAt,
|
|
ExpensesType: p.ExpensesType,
|
|
Remark: p.Remark,
|
|
Status: p.Status,
|
|
CreatedAt: p.CreatedAt,
|
|
UpdatedAt: p.UpdatedAt,
|
|
}
|
|
}
|