1
This commit is contained in:
@@ -45,49 +45,50 @@ func GetPrinters(db *sqlx.DB, appID int, printNo string, status, statusNeq, flow
|
|||||||
func GetPrintersPage(db *sqlx.DB, appID int, printNo, name string, status, isOnline, offset, pageSize int, userId string) (page *model.PagedInfo, err error) {
|
func GetPrintersPage(db *sqlx.DB, appID int, printNo, name string, status, isOnline, offset, pageSize int, userId string) (page *model.PagedInfo, err error) {
|
||||||
fmt.Println("print======================================")
|
fmt.Println("print======================================")
|
||||||
globals.SugarLogger.Debug("print=============", "========")
|
globals.SugarLogger.Debug("print=============", "========")
|
||||||
sqlCount := `SELECT COUNT(id) count `
|
//sqlCount := `SELECT COUNT(id) count `
|
||||||
sql := `SELECT * `
|
//sql := `SELECT * `
|
||||||
sqlOther := ` FROM printer WHERE 1 = 1 AND deleted_at = ?`
|
//sqlOther := ` FROM printer WHERE 1 = 1 AND deleted_at = ?`
|
||||||
sqlParams := []interface{}{utils.DefaultTimeValue}
|
//sqlParams := []interface{}{utils.DefaultTimeValue}
|
||||||
if appID != 0 {
|
//if appID != 0 {
|
||||||
sqlOther += " AND app_id = ?"
|
// sqlOther += " AND app_id = ?"
|
||||||
sqlParams = append(sqlParams, appID)
|
// sqlParams = append(sqlParams, appID)
|
||||||
}
|
//}
|
||||||
if printNo != "" {
|
//if printNo != "" {
|
||||||
sqlOther += " AND print_no = ?"
|
// sqlOther += " AND print_no = ?"
|
||||||
sqlParams = append(sqlParams, printNo)
|
// sqlParams = append(sqlParams, printNo)
|
||||||
}
|
//}
|
||||||
if name != "" {
|
//if name != "" {
|
||||||
sqlOther += " AND name LIKE ?"
|
// sqlOther += " AND name LIKE ?"
|
||||||
sqlParams = append(sqlParams, "%"+name+"%")
|
// sqlParams = append(sqlParams, "%"+name+"%")
|
||||||
}
|
//}
|
||||||
if status != model.StatusAll {
|
//if status != model.StatusAll {
|
||||||
sqlOther += " AND status = ?"
|
// sqlOther += " AND status = ?"
|
||||||
sqlParams = append(sqlParams, status)
|
// sqlParams = append(sqlParams, status)
|
||||||
}
|
//}
|
||||||
if isOnline != model.StatusAll {
|
//if isOnline != model.StatusAll {
|
||||||
sqlOther += " AND is_online = ?"
|
// sqlOther += " AND is_online = ?"
|
||||||
sqlParams = append(sqlParams, isOnline)
|
// sqlParams = append(sqlParams, isOnline)
|
||||||
}
|
//}
|
||||||
if userId != "" {
|
//if userId != "" {
|
||||||
sqlOther += " AND user_id = ?"
|
// sqlOther += " AND user_id = ?"
|
||||||
sqlParams = append(sqlParams, userId)
|
// sqlParams = append(sqlParams, userId)
|
||||||
}
|
//}
|
||||||
//查总数
|
////查总数
|
||||||
count := 0
|
//count := 0
|
||||||
row := db.DB.QueryRow(sqlCount+sqlOther, sqlParams...)
|
//row := db.DB.QueryRow(sqlCount+sqlOther, sqlParams...)
|
||||||
if err = row.Scan(&count); err != nil {
|
//if err = row.Scan(&count); err != nil {
|
||||||
return page, err
|
// return page, err
|
||||||
}
|
//}
|
||||||
sqlOther += " LIMIT ? OFFSET ?"
|
//sqlOther += " LIMIT ? OFFSET ?"
|
||||||
sqlParams = append(sqlParams, pageSize, offset)
|
//sqlParams = append(sqlParams, pageSize, offset)
|
||||||
|
//
|
||||||
var printers []model.Printer
|
//var printers []model.Printer
|
||||||
if err = db.Select(&printers, sql+sqlOther, sqlParams...); err != nil {
|
//if err = db.Select(&printers, sql+sqlOther, sqlParams...); err != nil {
|
||||||
return nil, err
|
// return nil, err
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
return &model.PagedInfo{TotalCount: count, Data: printers}, err
|
//return &model.PagedInfo{TotalCount: count, Data: printers}, err
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetPrintMessagesPage(db *sqlx.DB, printNo, msgID, beginAt, endAt string, offset, pageSize int) (page *model.PagedInfo, err error) {
|
func GetPrintMessagesPage(db *sqlx.DB, printNo, msgID, beginAt, endAt string, offset, pageSize int) (page *model.PagedInfo, err error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user