seal_attachment.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package seal
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. //Attachment 用印附件结构体
  7. type Attachment struct {
  8. Id int `orm:"column(id);pk"`
  9. SealId int `description:"用印ID"`
  10. FileUrl string `description:"文件附件地址"`
  11. ModifyTime time.Time `description:"最近一次修改时间"`
  12. CreateTime time.Time `description:"添加时间"`
  13. }
  14. func (a *Attachment) TableName() string {
  15. return "seal_attachment"
  16. }
  17. //GetAttachmentBySealId 根据用印id获取合同附件信息
  18. func GetAttachmentBySealId(sealId int) ( list []*Attachment, err error) {
  19. o := orm.NewOrm()
  20. sql := `select * from seal_attachment where seal_id = ? `
  21. _, err = o.Raw(sql, sealId).QueryRows(&list)
  22. return
  23. }
  24. //DelAttachmentBySealId 删除用印相关的合同附件信息
  25. func DelAttachmentBySealId(sealId int) (err error) {
  26. o := orm.NewOrm()
  27. sql := `delete from seal_attachment where seal_id = ? `
  28. _, err = o.Raw(sql, sealId).Exec()
  29. return
  30. }
  31. //AddAttachments 用印附件添加
  32. func AddAttachments(list []*Attachment) (err error) {
  33. o := orm.NewOrm()
  34. _, err = o.InsertMulti(1, list)
  35. return
  36. }