// @Author gmy 2024/9/19 15:13:00 package document_manage_model import ( "github.com/beego/beego/v2/client/orm" ) type OutsideReportAttachment struct { OutsideReportAttachmentId int `orm:"column(outside_report_attachment_id);pk" description:"外部报告附件ID"` OutsideReportId int `orm:"column(outside_report_id)" description:"报告id"` Title string `orm:"column(title)" description:"附件名称"` Url string `orm:"column(url)" description:"附件地址"` CreateTime string `orm:"column(create_time)" description:"附件新增时间"` FileSize int64 `orm:"column(file_size)" description:"附件大小"` } // 在 init 函数中注册模型 func init() { orm.RegisterModel(new(OutsideReportAttachment)) } // SaveOutsideReportAttachment 保存附件 func SaveOutsideReportAttachment(attachment *OutsideReportAttachment) (int64, error) { o := orm.NewOrmUsingDB("rddp") return o.Insert(attachment) } // GetOutsideReportAttachmentListByReportId 根据报告id获取附件列表 func GetOutsideReportAttachmentListByReportId(outsideReportId int) ([]*OutsideReportAttachment, error) { o := orm.NewOrmUsingDB("rddp") var attachmentList []*OutsideReportAttachment _, err := o.QueryTable("outside_report_attachment"). Filter("outside_report_id", outsideReportId). All(&attachmentList) if err != nil { return nil, err } return attachmentList, nil } // DeleteReportAttachmentByReportId 根据报告id删除附件 func DeleteReportAttachmentByReportId(outsideReportId int) error { o := orm.NewOrmUsingDB("rddp") _, err := o.QueryTable("outside_report_attachment"). Filter("outside_report_id", outsideReportId). Delete() return err }