- user2
This commit is contained in:
@@ -12,8 +12,8 @@ type AuthBind struct {
|
||||
Type string `orm:"size(16)" json:"type"`
|
||||
Status int8 `json:"status"`
|
||||
|
||||
AuthID string `orm:"size(48);index" json:"authID"`
|
||||
AuthID2 string `orm:"size(48);index" json:"authID2"`
|
||||
AuthID string `orm:"size(48);column(auth_id);index" json:"authID"`
|
||||
AuthID2 string `orm:"size(48);column(auth_id2);index" json:"authID2"`
|
||||
AuthSecret string `orm:"size(48)" json:"authSecret"`
|
||||
AuthSecret2 string `orm:"size(48)" json:"authSecret2"`
|
||||
Remark string `orm:"size(255)" json:"remark"`
|
||||
|
||||
@@ -1,11 +1,50 @@
|
||||
package dao
|
||||
|
||||
import "git.rosy.net.cn/jx-callback/business/model"
|
||||
import (
|
||||
"errors"
|
||||
|
||||
func GetAuthBind(db *DaoDB, userID, authType, authID, authID2 string) (authBind *model.AuthBind, err error) {
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
)
|
||||
|
||||
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 = ?
|
||||
`
|
||||
sqlParams := []interface{}{
|
||||
utils.DefaultTimeValue,
|
||||
}
|
||||
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)
|
||||
}
|
||||
err = GetRow(db, &authBind, sql, sqlParams...)
|
||||
return authBind, err
|
||||
}
|
||||
|
||||
func GetAuthBindsByWXUnionID(db *DaoDB, unionID string) (authBinds []*model.AuthBind, err error) {
|
||||
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.auth_id2 = ? AND t1.type IN (` + GenQuestionMarks(len(typeList)) + ")"
|
||||
sqlParams := []interface{}{
|
||||
utils.DefaultTimeValue,
|
||||
authID2,
|
||||
typeList,
|
||||
}
|
||||
err = GetRows(db, &authBinds, sql, sqlParams...)
|
||||
return authBinds, err
|
||||
}
|
||||
|
||||
18
business/model/dao/dao_user2.go
Normal file
18
business/model/dao/dao_user2.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
)
|
||||
|
||||
func GetUserByID(db *DaoDB, fieldName, fieldValue string) (user *model.User, err error) {
|
||||
sql := fmt.Sprintf(`
|
||||
SELECT *
|
||||
FROM user t1
|
||||
WHERE t1.deleted_at = ? AND t1.%s = ?
|
||||
`, fieldName)
|
||||
err = GetRows(db, &user, sql, utils.DefaultTimeValue, fieldValue)
|
||||
return user, err
|
||||
}
|
||||
Reference in New Issue
Block a user