1
This commit is contained in:
49
dao/print_bind_store.go
Normal file
49
dao/print_bind_store.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/jx-print/globals"
|
||||
storeModel "git.rosy.net.cn/jx-print/model/app_model"
|
||||
)
|
||||
|
||||
// CreatePrintStoreBind 创建绑定
|
||||
func CreatePrintStoreBind(param *storeModel.PrintBindStore) error {
|
||||
return Insert(globals.GetDB(), param)
|
||||
}
|
||||
|
||||
// QueryBindNumber 查询门店绑定数量
|
||||
func QueryBindNumber(userId, printNo string) (int, error) {
|
||||
sql := `SELECT count(*) FROM print_bind_store WHERE user_id = ? AND print_no = ?`
|
||||
|
||||
count := 0
|
||||
row := globals.GetDB().DB.QueryRow(sql, []interface{}{userId, printNo}...)
|
||||
if err := row.Scan(&count); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
// RelieveToken 解除授权绑定门店信息
|
||||
func RelieveToken(userId, printNo string, storeId int64) error {
|
||||
_, err := globals.GetDB().Exec(`UPDATE print_bind_store SET bind_status = ? WHERE user_id = ? AND print_no = ? AND store_id = ?`, []interface{}{storeModel.StoreBindPrintFail, userId, printNo, storeId}...)
|
||||
return err
|
||||
}
|
||||
|
||||
// QueryStoreAndUserManager 查询用户门店的绑定关系
|
||||
func QueryStoreAndUserManager(userId, printNo string, storeId int64) (bool, error) {
|
||||
count := 0
|
||||
err := globals.GetDB().DB.QueryRow(`SELECT count(*) FROM print_bind_store WHERE user_id = ? AND print_no = ? AND store_id = ?`, []interface{}{userId, printNo, storeId}...).Scan(&count)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if count != 1 {
|
||||
return false, nil
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// UpdateStoreAuthorize 失去授权
|
||||
func UpdateStoreAuthorize(storeId int64) error {
|
||||
_, err := globals.GetDB().Exec(`UPDATE print_bind_store SET store_status = ? WHERE store_id = ?`, []interface{}{storeModel.StoreStatusLose, storeId}...)
|
||||
return err
|
||||
}
|
||||
Reference in New Issue
Block a user