|
@@ -246,14 +246,32 @@ func (m *BookDAO) AddChangeRecord(change model.TaInStockChange) error {
|
246
|
246
|
return err
|
247
|
247
|
}
|
248
|
248
|
|
|
249
|
+// BookBorrowRecord 图书借阅记录
|
|
250
|
+type BookBorrowRecord struct {
|
|
251
|
+ model.TaBookBorrowRecord `xorm:"extends"`
|
|
252
|
+ BookName string
|
|
253
|
+ BookImg string
|
|
254
|
+ CaseName string
|
|
255
|
+}
|
|
256
|
+
|
249
|
257
|
// GetMineRecord 获取个人借阅记录
|
250
|
|
-func (m *BookDAO) GetMineRecord(customerid, status string, page, pagesize int) ([]model.TaBookBorrowRecord, error) {
|
251
|
|
- var records []model.TaBookBorrowRecord
|
252
|
|
- var db = m.db.Where("customer_id=?", customerid)
|
|
258
|
+func (m *BookDAO) GetMineRecord(customerid, status string, page, pagesize int) ([]BookBorrowRecord, error) {
|
|
259
|
+ var records []BookBorrowRecord
|
|
260
|
+ sql := `select a.*,b.book_name,b.book_img,c.case_name from ta_book_borrow_record a
|
|
261
|
+ inner join sys_case c on a.case_id=c.case_id
|
|
262
|
+ left join ta_book b on a.book_id=b.book_id
|
|
263
|
+ where a.customer_id=? `
|
253
|
264
|
if status != "" {
|
254
|
|
- db.And("borrow_status=?", status)
|
|
265
|
+ sql += ` and a.borrow_status in ('` + strings.Replace(status, ",", "','", -1) + `')`
|
|
266
|
+ }
|
|
267
|
+ sql += ` order by a.borrow_status asc`
|
|
268
|
+ if status == "4" {
|
|
269
|
+ sql += `,a.reserve_date asc`
|
|
270
|
+ } else {
|
|
271
|
+ sql += `,a.end_date asc`
|
255
|
272
|
}
|
256
|
|
- err := db.Limit(pagesize, pagesize*(page-1)).Find(&records)
|
|
273
|
+ sql += ` limit ` + strconv.Itoa((page-1)*pagesize) + `, ` + strconv.Itoa(pagesize)
|
|
274
|
+ err := m.db.Sql(sql, customerid).Find(&records)
|
257
|
275
|
return records, err
|
258
|
276
|
}
|
259
|
277
|
|
|
@@ -262,7 +280,7 @@ func (m *BookDAO) GetMineRecordCount(customerid, status string) (int, error) {
|
262
|
280
|
var records []model.TaBookBorrowRecord
|
263
|
281
|
var db = m.db.Where("customer_id=?", customerid)
|
264
|
282
|
if status != "" {
|
265
|
|
- db.And("borrow_status=?", status)
|
|
283
|
+ db.And("borrow_status in ('" + strings.Replace(status, ",", "','", -1) + "')")
|
266
|
284
|
}
|
267
|
285
|
err := db.Find(&records)
|
268
|
286
|
return len(records), err
|