32 lines
624 B
Go
32 lines
624 B
Go
package dao
|
|
|
|
import (
|
|
"git.rosy.net.cn/jx-print/model"
|
|
"github.com/jmoiron/sqlx"
|
|
)
|
|
|
|
func GetApps(db *sqlx.DB, id int, userID, mobile string) (apps []*model.Apps, err error) {
|
|
var sqlParams []interface{}
|
|
sql := `
|
|
SELECT *
|
|
FROM apps
|
|
WHERE 1 = 1
|
|
`
|
|
if id != 0 {
|
|
sql += " AND id = ?"
|
|
sqlParams = append(sqlParams, id)
|
|
}
|
|
if userID != "" {
|
|
sql += " AND user_id = ?"
|
|
sqlParams = append(sqlParams, userID)
|
|
}
|
|
if mobile != "" {
|
|
sql += " AND mobile = ?"
|
|
sqlParams = append(sqlParams, mobile)
|
|
}
|
|
if err = db.Select(&apps, sql, sqlParams...); err == nil {
|
|
return apps, err
|
|
}
|
|
return apps, err
|
|
}
|