Files
jx-callback/business/model/dao/dao_auth2.go
gazebo 25ac631c5c - refactor jxcontent and tasksch (remove dependency from jxcontent to tasksch)
- send dingding msg to user when async task finished
2019-03-22 15:04:28 +08:00

70 lines
1.8 KiB
Go

package dao
import (
"errors"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/jx-callback/globals"
)
func GetAuthBind(db *DaoDB, userID, authType, authID string) (authBind *model.AuthBind, err error) {
if userID == "" && authID == "" {
return nil, errors.New("userID, authID, authID2不能全为空")
}
sql := `
SELECT *
FROM auth_bind t1
WHERE t1.deleted_at = ? AND t1.status = ?
`
sqlParams := []interface{}{
utils.DefaultTimeValue,
model.AuthBindStatusNormal,
}
if userID != "" {
sql += " AND t1.user_id = ?"
sqlParams = append(sqlParams, userID)
}
if authType != "" {
sql += " AND t1.type = ?"
sqlParams = append(sqlParams, authType)
}
if authID != "" {
sql += " AND t1.auth_id = ?"
sqlParams = append(sqlParams, authID)
}
globals.SugarLogger.Debugf("GetAuthBind sql:%s, sqlParams:%s", sql, utils.Format4Output(sqlParams, false))
err = GetRow(db, &authBind, sql, sqlParams...)
return authBind, err
}
func GetAuthBindsByAuthID2(db *DaoDB, authID2 string, typeList []string) (authBinds []*model.AuthBind, err error) {
sql := `
SELECT *
FROM auth_bind t1
WHERE t1.deleted_at = ? AND t1.status = ? AND t1.auth_id2 = ? AND t1.type IN (` + GenQuestionMarks(len(typeList)) + ")"
sqlParams := []interface{}{
utils.DefaultTimeValue,
model.AuthBindStatusNormal,
authID2,
typeList,
}
err = GetRows(db, &authBinds, sql, sqlParams...)
return authBinds, err
}
func GetUserBindAuthInfo(db *DaoDB, userID string) (authList []*model.AuthBind, err error) {
sql := `
SELECT *
FROM auth_bind t1
WHERE t1.deleted_at = ? AND t1.status = ? AND t1.user_id = ?
`
sqlParams := []interface{}{
utils.DefaultTimeValue,
model.UserStatusNormal,
userID,
}
err = GetRows(db, &authList, sql, sqlParams...)
return authList, err
}