feat
parent
19d959db92
commit
b0b568a038
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,91 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/fonchain_enterprise/fonchain-approval/api/approval"
|
||||
m2 "github.com/fonchain_enterprise/fonchain-approval/pkg/m"
|
||||
"gorm.io/plugin/soft_delete"
|
||||
"time"
|
||||
)
|
||||
|
||||
// BundlePayPrice 画展包付款单审批
|
||||
type BundlePayPrice struct {
|
||||
ID uint64 `gorm:"column:id" json:"id"`
|
||||
DeletedAt soft_delete.DeletedAt `gorm:"column:deleted_at" json:"deletedAt"` // 删除时间
|
||||
CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"` // 创建时间
|
||||
UpdatedAt time.Time `gorm:"column:updated_at" json:"updatedAt"` // 更新时间
|
||||
ApprovalID uint64 `gorm:"type:int(11);column:approval_id;default:0;comment:画展的uid" json:"approvalId"`
|
||||
ShowUid string `gorm:"type:varchar(32);column:show_uid;default:'';comment:画展的uid" json:"showUid"`
|
||||
ShowName string `gorm:"type:varchar(32);column:show_name;default:'';comment:画展的名称" json:"showName"`
|
||||
ReceivedAt string `gorm:"type:varchar(32);column:received_at;default:'';comment:领取时间" json:"receivedAt"` // 领取时间
|
||||
ShowDate string `gorm:"type:varchar(32);column:show_date;default:'';comment:画展时间" json:"showDate"`
|
||||
ShowLowPrice string `gorm:"type:varchar(32);column:show_low_price;default:'';comment:画展宝低价" json:"showLowPrice"`
|
||||
ArtworkNum uint64 `gorm:"type:int(11);column:artworkNum;default:0;comment:作品数量" json:"artworkNum"`
|
||||
ArtworkSize string `gorm:"type:varchar(32);column:artwork_size;default:'';comment:作品总平尺" json:"artworkSize"`
|
||||
ShowAddress string `gorm:"type:varchar(32);column:show_address;default:'';comment:画展地址" json:"showAddress"`
|
||||
Status uint64 `gorm:"type:int(11);column:status;default:1;comment:状态" json:"status"`
|
||||
}
|
||||
|
||||
// TableName get sql table name.获取数据库表名
|
||||
func (m *BundlePayPrice) TableName() string {
|
||||
return "bundle_pay_price"
|
||||
}
|
||||
|
||||
func (m *BundlePayPrice) SaveApprovalContent(in *approval.CreateRequest, a *Approval) error {
|
||||
|
||||
m.ApprovalID = a.ID
|
||||
m.ShowUid = in.BundlePayPrice.ShowUid
|
||||
m.ShowName = in.BundlePayPrice.ShowName
|
||||
m.ReceivedAt = in.BundlePayPrice.ReceivedAt
|
||||
m.ShowDate = in.BundlePayPrice.ShowDate
|
||||
m.ShowLowPrice = in.BundlePayPrice.ShowLowPrice
|
||||
m.ArtworkNum = in.BundlePayPrice.ArtworkNum
|
||||
m.ArtworkSize = in.BundlePayPrice.ArtworkSize
|
||||
m.ShowAddress = in.BundlePayPrice.ShowAddress
|
||||
|
||||
return DB.Create(&m).Error
|
||||
}
|
||||
|
||||
func (m *BundlePayPrice) UpdateApprovalContent(in *approval.CreateRequest, a *Approval) error {
|
||||
|
||||
var entity *BundlePayPrice
|
||||
|
||||
if err := DB.Where(&BundlePayPrice{ApprovalID: a.ID}).First(&entity).Error; err != nil {
|
||||
return errors.New(m2.ErrorNotFound)
|
||||
}
|
||||
|
||||
m.ID = entity.ID
|
||||
m.ShowUid = in.BundlePayPrice.ShowUid
|
||||
m.ShowName = in.BundlePayPrice.ShowName
|
||||
m.ReceivedAt = in.BundlePayPrice.ReceivedAt
|
||||
m.ShowDate = in.BundlePayPrice.ShowDate
|
||||
m.ShowLowPrice = in.BundlePayPrice.ShowLowPrice
|
||||
m.ArtworkNum = in.BundlePayPrice.ArtworkNum
|
||||
m.ArtworkSize = in.BundlePayPrice.ArtworkSize
|
||||
m.ShowAddress = in.BundlePayPrice.ShowAddress
|
||||
|
||||
return DB.Model(&m).Updates(m).Error
|
||||
}
|
||||
|
||||
func (m *BundlePayPrice) BuildResContent(a *Approval, request *approval.CreateRequest) {
|
||||
|
||||
if a.BundlePayPrice != nil {
|
||||
request.BundlePayPrice = &approval.BundlePayPrice{
|
||||
ShowUid: a.BundlePayPrice.ShowUid,
|
||||
ApprovalID: a.BundlePayPrice.ApprovalID,
|
||||
ShowName: a.BundlePayPrice.ShowName,
|
||||
ReceivedAt: a.BundlePayPrice.ReceivedAt,
|
||||
ShowDate: a.BundlePayPrice.ShowDate,
|
||||
ShowLowPrice: a.BundlePayPrice.ShowLowPrice,
|
||||
ArtworkNum: a.BundlePayPrice.ArtworkNum,
|
||||
ArtworkSize: a.BundlePayPrice.ArtworkSize,
|
||||
ShowAddress: a.BundlePayPrice.ShowAddress,
|
||||
Status: a.BundlePayPrice.Status,
|
||||
ID: a.BundlePayPrice.ID,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (m *BundlePayPrice) DeleteApproval(p *Approval) error {
|
||||
return DB.Where(&BundlePayPrice{ApprovalID: p.ID}).Delete(&BundlePayPrice{}).Error
|
||||
}
|
Loading…
Reference in New Issue