|
@@ -25,25 +25,31 @@ func NewBookDAO(ctx *utils.Context) *BookDAO {
|
25
|
25
|
}
|
26
|
26
|
}
|
27
|
27
|
|
28
|
|
-func (m *BookDAO) GetBookList(bookType, caseid string, page, pageSize int) ([]model.TaBook, error) {
|
|
28
|
+func (m *BookDAO) GetBookList(bookType, name, caseid string, page, pageSize int) ([]model.TaBook, error) {
|
29
|
29
|
var book []model.TaBook
|
30
|
30
|
sql := `select * from ta_book where status = '` + strconv.Itoa(models.STATUS_NORMAL) + `'
|
31
|
|
- and a.case_id in('` + strings.Replace(caseid, ",", "','", -1) + `')`
|
|
31
|
+ and case_id in('` + strings.Replace(caseid, ",", "','", -1) + `')`
|
32
|
32
|
if bookType != "" {
|
33
|
33
|
sql += ` and book_type_id = '` + bookType + `'`
|
34
|
34
|
}
|
|
35
|
+ if name != "" {
|
|
36
|
+ sql += ` and (book_name like '%` + name + `%' or author like '%` + name + `%')`
|
|
37
|
+ }
|
35
|
38
|
sql += ` order by create_date desc limit ` + strconv.Itoa((page-1)*pageSize) + `, ` + strconv.Itoa(pageSize)
|
36
|
39
|
err := m.db.Sql(sql).Find(&book)
|
37
|
40
|
return book, err
|
38
|
41
|
|
39
|
42
|
}
|
40
|
|
-func (m *BookDAO) GetBookListCount(bookType, caseid string) (int, error) {
|
|
43
|
+func (m *BookDAO) GetBookListCount(bookType, name, caseid string) (int, error) {
|
41
|
44
|
var book []model.TaBook
|
42
|
45
|
sql := `select * from ta_book where status = '` + strconv.Itoa(models.STATUS_NORMAL) + `'
|
43
|
|
- and a.case_id in('` + strings.Replace(caseid, ",", "','", -1) + `')`
|
|
46
|
+ and case_id in('` + strings.Replace(caseid, ",", "','", -1) + `')`
|
44
|
47
|
if bookType != "" {
|
45
|
48
|
sql += ` and book_type_id = '` + bookType + `'`
|
46
|
49
|
}
|
|
50
|
+ if name != "" {
|
|
51
|
+ sql += ` and (book_name like '%` + name + `%' or author like '%` + name + `%')`
|
|
52
|
+ }
|
47
|
53
|
sql += ` order by create_date desc`
|
48
|
54
|
err := m.db.Sql(sql).Find(&book)
|
49
|
55
|
return len(book), err
|
|
@@ -198,5 +204,9 @@ func (m *BookDAO) AddChangeRecord(change model.TaInStockChange) error {
|
198
|
204
|
change.RecordId = utils.GetGUID()
|
199
|
205
|
_, err := m.db.Insert(change)
|
200
|
206
|
return err
|
|
207
|
+}
|
201
|
208
|
|
|
209
|
+// GetMineRecord 获取个人借阅记录
|
|
210
|
+func (m *BookDAO) GetMineRecord(page, pagesize int) ([]model.TaBookBorrowRecord, error) {
|
|
211
|
+ return nil, nil
|
202
|
212
|
}
|