Эх сурвалжийг харах

文档管理-报告复制链接

gmy 3 сар өмнө
parent
commit
78372ed23d

+ 7 - 6
models/outside_report_attachment.go

@@ -17,14 +17,15 @@ func init() {
 }
 
 // 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)
+func GetOutsideReportAttachmentListByReportId(outsideReportId int) (attachmentList []*OutsideReportAttachment, err error) {
+	o := orm.NewOrm()
+	// 改写成通过ql查询
+	sql := `select * from outside_report_attachment where outside_report_id = ?`
+
+	_, err = o.Raw(sql, outsideReportId).QueryRows(&attachmentList)
 	if err != nil {
 		return nil, err
 	}
+
 	return attachmentList, nil
 }