|
@@ -8,8 +8,6 @@ import (
|
8
|
8
|
"strings"
|
9
|
9
|
"time"
|
10
|
10
|
|
11
|
|
- "github.com/astaxie/beego"
|
12
|
|
-
|
13
|
11
|
"github.com/go-xorm/xorm"
|
14
|
12
|
)
|
15
|
13
|
|
|
@@ -35,34 +33,34 @@ type BookTypeList struct {
|
35
|
33
|
func (m *BooktypeDAO) GetBookTypeList(caseid string, page, pageSize int) ([]model.TaBookType, error) {
|
36
|
34
|
var booktype []model.TaBookType
|
37
|
35
|
// sql := `select a.*,
|
38
|
|
- // (SELECT COUNT(1)FROM ta_book b where a.book_type_id = b.book_type_id AND b.status = '` + strconv.Itoa(models.STATUS_NORMAL) + `') as book_count where
|
|
36
|
+ // (SELECT COUNT(1)FROM ta_book b where a.book_type_id = b.book_type_id AND b.status = '` + strconv.Itoa(models.STATUS_NORMAL) + `') as book_count
|
|
37
|
+ // where
|
39
|
38
|
// a.status = '` + strconv.Itoa(models.STATUS_NORMAL) + `'
|
40
|
39
|
// and a.case_id in('` + strings.Replace(caseid, ",", "','", -1) + `')
|
41
|
40
|
// order by a.create_date desc limit ` + strconv.Itoa((page-1)*pageSize) + `, ` + strconv.Itoa(pageSize)
|
42
|
|
-
|
43
|
41
|
sql := `SELECT
|
44
|
|
- a.*, b.book_count
|
45
|
|
- FROM
|
46
|
|
- ta_book_type a
|
47
|
|
- LEFT JOIN (
|
48
|
|
- SELECT
|
49
|
|
- book_type_id,
|
50
|
|
- count(1) AS book_count
|
51
|
|
- FROM
|
52
|
|
- ta_book
|
53
|
|
- WHERE
|
54
|
|
- STATUS = '` + strconv.Itoa(models.STATUS_NORMAL) + `'
|
55
|
|
- GROUP BY
|
56
|
|
- book_type_id
|
57
|
|
- ) b ON a.book_type_id = b.book_type_id
|
58
|
|
- WHERE
|
59
|
|
- a. STATUS = '` + strconv.Itoa(models.STATUS_NORMAL) + `'
|
60
|
|
- AND a.case_id IN (
|
61
|
|
- '` + strings.Replace(caseid, ",", "','", -1) + `'
|
62
|
|
- )
|
63
|
|
- ORDER BY
|
64
|
|
- a.create_date DESC
|
65
|
|
- LIMIT ` + strconv.Itoa((page-1)*pageSize) + `,` + strconv.Itoa(pageSize)
|
|
42
|
+ a.*, b.book_count
|
|
43
|
+FROM
|
|
44
|
+ ta_book_type a
|
|
45
|
+LEFT JOIN (
|
|
46
|
+ SELECT
|
|
47
|
+ book_type_id,
|
|
48
|
+ count(1) AS book_count
|
|
49
|
+ FROM
|
|
50
|
+ ta_book
|
|
51
|
+ WHERE
|
|
52
|
+ STATUS = '` + strconv.Itoa(models.STATUS_NORMAL) + `'
|
|
53
|
+ GROUP BY
|
|
54
|
+ book_type_id
|
|
55
|
+) b ON a.book_type_id = b.book_type_id
|
|
56
|
+WHERE
|
|
57
|
+ a. STATUS = '` + strconv.Itoa(models.STATUS_NORMAL) + `'
|
|
58
|
+AND a.case_id IN (
|
|
59
|
+ '` + strings.Replace(caseid, ",", "','", -1) + `'
|
|
60
|
+)
|
|
61
|
+ORDER BY
|
|
62
|
+ a.create_date DESC
|
|
63
|
+LIMIT ` + strconv.Itoa((page-1)*pageSize) + `,` + strconv.Itoa(pageSize)
|
66
|
64
|
err := m.db.Sql(sql).Find(&booktype)
|
67
|
65
|
return booktype, err
|
68
|
66
|
}
|
|
@@ -70,7 +68,6 @@ func (m *BooktypeDAO) GetBookTypeListCount(caseid string) (int, error) {
|
70
|
68
|
var booktype []model.TaBookType
|
71
|
69
|
sql := `select * from ta_book_type where status = '` + strconv.Itoa(models.STATUS_NORMAL) + `'
|
72
|
70
|
and case_id in('` + strings.Replace(caseid, ",", "','", -1) + `')`
|
73
|
|
- beego.Error(sql)
|
74
|
71
|
err := m.db.Sql(sql).Find(&booktype)
|
75
|
72
|
return len(booktype), err
|
76
|
73
|
}
|