|
@@ -15,7 +15,7 @@ type Expenses struct {
|
|
|
ExpensesGenre ExpensesGenre `json:"expensesGenre" form:"expensesGenre" gorm:"foreignKey:Genre;references:id;"`
|
|
|
ProjectId int `json:"projectId" form:"projectId" gorm:"comment:项目id"`
|
|
|
Project Project `json:"project" form:"project" gorm:"foreignKey:ProjectId;references:id"`
|
|
|
- ExpenseDetail string `json:"expenseDetail" form:"expenseDetail" gorm:"comment:费用明细"`
|
|
|
+ ExpenseDetail string `json:"expenseDetail" form:"expenseDetail" gorm:"comment:费用明细;type:varchar(400)"`
|
|
|
Remarks string `json:"remarks" form:"remarks" gorm:"comment:备注"`
|
|
|
ThenBalance float64 `json:"thenBalance" form:"thenBalance" gorm:"comment:当时余额;type:double(10,2)"`
|
|
|
}
|
|
@@ -105,12 +105,22 @@ func QuerySurplus() (interface{}, error) {
|
|
|
return results, err
|
|
|
}
|
|
|
|
|
|
+func QueryExpensesByGenre(genre int) (expenses []Expenses, err error) {
|
|
|
+ err = global.GVA_DB.Model(&Expenses{}).Where("genre = ?", genre).Find(&expenses).Error
|
|
|
+ return expenses, err
|
|
|
+}
|
|
|
+
|
|
|
+func QueryExpensesByProjectId(projectId int) (expenses []Expenses, err error) {
|
|
|
+ err = global.GVA_DB.Model(&Expenses{}).Where("project_id = ?", projectId).Find(&expenses).Error
|
|
|
+ return expenses, err
|
|
|
+}
|
|
|
+
|
|
|
func (e Expenses) CreateExpenses() error {
|
|
|
return global.GVA_DB.Create(&e).Error
|
|
|
}
|
|
|
|
|
|
func (e Expenses) UpdateExpenses() error {
|
|
|
- return global.GVA_DB.Model(&Expenses{}).Updates(&e).Error
|
|
|
+ return global.GVA_DB.Model(&Expenses{}).Where("id = ?", e.ID).Updates(&e).Error
|
|
|
}
|
|
|
|
|
|
func (e Expenses) DeleteExpenses() error {
|