This commit is contained in:
邹宗楠
2022-07-28 17:40:27 +08:00
parent 21eb66b926
commit 099211f096
2 changed files with 14 additions and 14 deletions

View File

@@ -51,43 +51,43 @@ func GetPrintersPage(db *sqlx.DB, appID int, printNo, name string, status, isOnl
sql := `
SELECT *
`
sqlOhter := `
sqlOther := `
FROM printer
WHERE 1 = 1 AND deleted_at = ?
`
sqlParams := []interface{}{utils.DefaultTimeValue}
if appID != 0 {
sqlOhter += " AND app_id = ?"
sqlOther += " AND app_id = ?"
sqlParams = append(sqlParams, appID)
}
if printNo != "" {
sqlOhter += " AND print_no = ?"
sqlOther += " AND print_no = ?"
sqlParams = append(sqlParams, printNo)
}
if name != "" {
sqlOhter += " AND name LIKE ?"
sqlOther += " AND name LIKE ?"
sqlParams = append(sqlParams, "%"+name+"%")
}
if status != model.StatusAll {
sqlOhter += " AND status = ?"
sqlOther += " AND status = ?"
sqlParams = append(sqlParams, status)
}
if isOnline != model.StatusAll {
sqlOhter += " AND is_online = ?"
sqlOther += " AND is_online = ?"
sqlParams = append(sqlParams, isOnline)
}
if userId != "" {
sqlOhter += " AND user_id = ?"
sqlOther += " AND user_id = ?"
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 {
return page, err
}
sqlOhter += " LIMIT ? OFFSET ?"
sqlOther += " LIMIT ? 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{
TotalCount: count,
Data: printers,

View File

@@ -180,12 +180,12 @@ type Printer struct {
AppID int `json:"app_id" db:"app_id"` //应用编号
PrintNo string `json:"print_no" db:"print_no"` //打印机编号
PrintKey string `json:"print_key" db:"print_key"` //打印机识别码
Name string `json:"name"` //打印机备注名
Status int `json:"status"` //打印机状态
Name string `json:"name" db:"name"` //打印机备注名
Status int `json:"status" db:"status"` //打印机状态
IsOnline int `json:"is_online" db:"is_online"` //1在线0离线
IccID string `json:"icc_id" db:"icc_id"` //sim卡号
Sound string `json:"sound"` //声音类型 sounda ,b,c,d,e,f,g
Volume int `json:"volume"` //音量1-5 对应打印机2-10
Sound string `json:"sound" db:"sound"` //声音类型 sounda ,b,c,d,e,f,g
Volume int `json:"volume" db:"volume"` //音量1-5 对应打印机2-10
FlowFlag int `json:"flow_flag" db:"flow_flag"` //是否超流量了1表示超了
OfflineCount int `json:"-" db:"offline_count"` //掉线次数
UserId string `json:"user_id" db:"user_id"` //打印机所属用户