45 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			45 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 IncomeForm struct {
 | |
| 	ID          int64          `json:"id"`
 | |
| 	ProjectID   int64          `json:"project_id"`
 | |
| 	BudgetID    int64          `json:"budget_id"`
 | |
| 	Amount      float64        `json:"amount"`
 | |
| 	AmountF     pgtype.Numeric `comment:"收入金额"`
 | |
| 	IncomeAt    time.Time      `json:"income_at"`
 | |
| 	IncomeType  int32          `json:"income_type"`
 | |
| 	IncomeBank  int32          `json:"income_bank"`
 | |
| 	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 *IncomeForm) ToForm(p *db.Income) *IncomeForm {
 | |
| 	return &IncomeForm{
 | |
| 		ID:         p.ID,
 | |
| 		ProjectID:  p.ProjectID,
 | |
| 		BudgetID:   p.BudgetID,
 | |
| 		Amount:     convertor.NumericToFloat64(p.Amount),
 | |
| 		AmountF:    p.Amount,
 | |
| 		IncomeAt:   p.IncomeAt,
 | |
| 		IncomeType: p.IncomeType,
 | |
| 		IncomeBank: p.IncomeBank,
 | |
| 		Remark:     p.Remark,
 | |
| 		Status:     p.Status,
 | |
| 		CreatedAt:  p.CreatedAt,
 | |
| 		UpdatedAt:  p.UpdatedAt,
 | |
| 	}
 | |
| }
 |