1
This commit is contained in:
@@ -51,43 +51,43 @@ func GetPrintersPage(db *sqlx.DB, appID int, printNo, name string, status, isOnl
|
|||||||
sql := `
|
sql := `
|
||||||
SELECT *
|
SELECT *
|
||||||
`
|
`
|
||||||
sqlOhter := `
|
sqlOther := `
|
||||||
FROM printer
|
FROM printer
|
||||||
WHERE 1 = 1 AND deleted_at = ?
|
WHERE 1 = 1 AND deleted_at = ?
|
||||||
`
|
`
|
||||||
sqlParams := []interface{}{utils.DefaultTimeValue}
|
sqlParams := []interface{}{utils.DefaultTimeValue}
|
||||||
if appID != 0 {
|
if appID != 0 {
|
||||||
sqlOhter += " AND app_id = ?"
|
sqlOther += " AND app_id = ?"
|
||||||
sqlParams = append(sqlParams, appID)
|
sqlParams = append(sqlParams, appID)
|
||||||
}
|
}
|
||||||
if printNo != "" {
|
if printNo != "" {
|
||||||
sqlOhter += " AND print_no = ?"
|
sqlOther += " AND print_no = ?"
|
||||||
sqlParams = append(sqlParams, printNo)
|
sqlParams = append(sqlParams, printNo)
|
||||||
}
|
}
|
||||||
if name != "" {
|
if name != "" {
|
||||||
sqlOhter += " AND name LIKE ?"
|
sqlOther += " AND name LIKE ?"
|
||||||
sqlParams = append(sqlParams, "%"+name+"%")
|
sqlParams = append(sqlParams, "%"+name+"%")
|
||||||
}
|
}
|
||||||
if status != model.StatusAll {
|
if status != model.StatusAll {
|
||||||
sqlOhter += " AND status = ?"
|
sqlOther += " AND status = ?"
|
||||||
sqlParams = append(sqlParams, status)
|
sqlParams = append(sqlParams, status)
|
||||||
}
|
}
|
||||||
if isOnline != model.StatusAll {
|
if isOnline != model.StatusAll {
|
||||||
sqlOhter += " AND is_online = ?"
|
sqlOther += " AND is_online = ?"
|
||||||
sqlParams = append(sqlParams, isOnline)
|
sqlParams = append(sqlParams, isOnline)
|
||||||
}
|
}
|
||||||
if userId != "" {
|
if userId != "" {
|
||||||
sqlOhter += " AND user_id = ?"
|
sqlOther += " AND user_id = ?"
|
||||||
sqlParams = append(sqlParams, userId)
|
sqlParams = append(sqlParams, userId)
|
||||||
}
|
}
|
||||||
//查总数
|
//查总数
|
||||||
row := db.DB.QueryRow(sqlCount+sqlOhter, 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
|
||||||
}
|
}
|
||||||
sqlOhter += " LIMIT ? OFFSET ?"
|
sqlOther += " LIMIT ? OFFSET ?"
|
||||||
sqlParams = append(sqlParams, pageSize, offset)
|
sqlParams = append(sqlParams, pageSize, offset)
|
||||||
if err = db.Select(&printers, sql+sqlOhter, sqlParams...); err == nil {
|
if err = db.Select(&printers, sql+sqlOther, sqlParams...); err == nil {
|
||||||
return &model.PagedInfo{
|
return &model.PagedInfo{
|
||||||
TotalCount: count,
|
TotalCount: count,
|
||||||
Data: printers,
|
Data: printers,
|
||||||
|
|||||||
@@ -180,12 +180,12 @@ type Printer struct {
|
|||||||
AppID int `json:"app_id" db:"app_id"` //应用编号
|
AppID int `json:"app_id" db:"app_id"` //应用编号
|
||||||
PrintNo string `json:"print_no" db:"print_no"` //打印机编号
|
PrintNo string `json:"print_no" db:"print_no"` //打印机编号
|
||||||
PrintKey string `json:"print_key" db:"print_key"` //打印机识别码
|
PrintKey string `json:"print_key" db:"print_key"` //打印机识别码
|
||||||
Name string `json:"name"` //打印机备注名
|
Name string `json:"name" db:"name"` //打印机备注名
|
||||||
Status int `json:"status"` //打印机状态
|
Status int `json:"status" db:"status"` //打印机状态
|
||||||
IsOnline int `json:"is_online" db:"is_online"` //1在线,0离线
|
IsOnline int `json:"is_online" db:"is_online"` //1在线,0离线
|
||||||
IccID string `json:"icc_id" db:"icc_id"` //sim卡号
|
IccID string `json:"icc_id" db:"icc_id"` //sim卡号
|
||||||
Sound string `json:"sound"` //声音类型 sounda ,b,c,d,e,f,g
|
Sound string `json:"sound" db:"sound"` //声音类型 sounda ,b,c,d,e,f,g
|
||||||
Volume int `json:"volume"` //音量,1-5 ,对应打印机2-10
|
Volume int `json:"volume" db:"volume"` //音量,1-5 ,对应打印机2-10
|
||||||
FlowFlag int `json:"flow_flag" db:"flow_flag"` //是否超流量了,1表示超了
|
FlowFlag int `json:"flow_flag" db:"flow_flag"` //是否超流量了,1表示超了
|
||||||
OfflineCount int `json:"-" db:"offline_count"` //掉线次数
|
OfflineCount int `json:"-" db:"offline_count"` //掉线次数
|
||||||
UserId string `json:"user_id" db:"user_id"` //打印机所属用户
|
UserId string `json:"user_id" db:"user_id"` //打印机所属用户
|
||||||
|
|||||||
Reference in New Issue
Block a user