+ AuthBind中添加BindType
- 合并函数GetAuthBindsByAuthID2 - User中的mobile与email改为可为null
This commit is contained in:
@@ -7,14 +7,19 @@ const (
|
||||
|
||||
const (
|
||||
AdminName = "jxadmin"
|
||||
|
||||
AuthBindTypeAll = -1
|
||||
AuthBindTypeAuth = 0 // 绑定类型为认证
|
||||
AuthBindTypeID = 1 // 绑定类型为用户标识,不做为认证
|
||||
)
|
||||
|
||||
type AuthBind struct {
|
||||
ModelIDCULD
|
||||
|
||||
UserID string `orm:"size(48);column(user_id)" json:"userID"`
|
||||
Type string `orm:"size(16)" json:"type"`
|
||||
Status int8 `json:"status"`
|
||||
UserID string `orm:"size(48);column(user_id)" json:"userID"`
|
||||
BindType int8 `json:"bindType"`
|
||||
Type string `orm:"size(16)" json:"type"`
|
||||
Status int8 `json:"status"`
|
||||
|
||||
AuthID string `orm:"size(48);column(auth_id)" json:"authID"`
|
||||
AuthID2 string `orm:"size(48);column(auth_id2);index" json:"authID2"`
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
)
|
||||
|
||||
func GetAuthBind(db *DaoDB, userID, authType, authID string) (authBind *model.AuthBind, err error) {
|
||||
func GetAuthBind(db *DaoDB, userID string, bindType int, authType, authID string) (authBind *model.AuthBind, err error) {
|
||||
if userID == "" && authID == "" {
|
||||
return nil, errors.New("userID, authID, authID2不能全为空")
|
||||
}
|
||||
@@ -24,6 +24,10 @@ func GetAuthBind(db *DaoDB, userID, authType, authID string) (authBind *model.Au
|
||||
sql += " AND t1.user_id = ?"
|
||||
sqlParams = append(sqlParams, userID)
|
||||
}
|
||||
if bindType != model.AuthBindTypeAll {
|
||||
sql += " AND t1.bind_type = ?"
|
||||
sqlParams = append(sqlParams, bindType)
|
||||
}
|
||||
if authType != "" {
|
||||
sql += " AND t1.type = ?"
|
||||
sqlParams = append(sqlParams, authType)
|
||||
@@ -37,32 +41,32 @@ func GetAuthBind(db *DaoDB, userID, authType, authID string) (authBind *model.Au
|
||||
return authBind, err
|
||||
}
|
||||
|
||||
func GetAuthBindsByAuthID2(db *DaoDB, authID2 string, typeList []string) (authBinds []*model.AuthBind, err error) {
|
||||
func GetUserBindAuthInfo(db *DaoDB, userID string, bindType int, authID2 string, typeList []string) (authList []*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 = ?
|
||||
`
|
||||
WHERE t1.deleted_at = ? AND t1.status = ?`
|
||||
sqlParams := []interface{}{
|
||||
utils.DefaultTimeValue,
|
||||
model.UserStatusNormal,
|
||||
userID,
|
||||
}
|
||||
if userID != "" {
|
||||
sql += " AND t1.user_id = ?"
|
||||
sqlParams = append(sqlParams, userID)
|
||||
}
|
||||
if bindType != model.AuthBindTypeAll {
|
||||
sql += " AND t1.bind_type = ?"
|
||||
sqlParams = append(sqlParams, bindType)
|
||||
}
|
||||
if authID2 != "" {
|
||||
sql += " AND t1.auth_id2 = ?"
|
||||
sqlParams = append(sqlParams, authID2)
|
||||
}
|
||||
if len(typeList) > 0 {
|
||||
sql += " AND t1.type IN (" + GenQuestionMarks(len(typeList)) + ")"
|
||||
sqlParams = append(sqlParams, typeList)
|
||||
}
|
||||
|
||||
err = GetRows(db, &authList, sql, sqlParams...)
|
||||
return authList, err
|
||||
}
|
||||
|
||||
@@ -24,24 +24,23 @@ var (
|
||||
|
||||
type User struct {
|
||||
ModelIDCULD
|
||||
UserID string `orm:"size(48);column(user_id)" json:"userID" compact:"userID"` // 内部唯一标识
|
||||
UserID2 string `orm:"size(48);column(user_id2)" json:"userID2" compact:"userID2"` // 外部唯一标识(一般用于登录)
|
||||
Name string `orm:"size(48);index" json:"name" compact:"name"` // 外部唯一显示 标识(一般用于显示)
|
||||
Mobile string `orm:"size(32)" json:"mobile" compact:"mobile"`
|
||||
Email string `orm:"size(32);index" json:"email" compact:"email"`
|
||||
Status int8 `json:"status" compact:"status"`
|
||||
Type int8 `json:"type" compact:"type"` // 用户类型
|
||||
IDCardNo string `orm:"size(18);column(id_card_no)" json:"idCardNo" compact:"idCardNo"` // 身份证号
|
||||
Remark string `orm:"size(255)" json:"remark"`
|
||||
UserID string `orm:"size(48);column(user_id)" json:"userID" compact:"userID"` // 内部唯一标识
|
||||
UserID2 string `orm:"size(48);column(user_id2)" json:"userID2" compact:"userID2"` // 外部唯一标识(一般用于登录)
|
||||
Name string `orm:"size(48);index" json:"name" compact:"name"` // 外部显示标识(当前可以重复)
|
||||
Mobile *string `orm:"size(32);null" json:"mobile" compact:"mobile"`
|
||||
Email *string `orm:"size(32);null" json:"email" compact:"email"`
|
||||
Status int8 `json:"status" compact:"status"`
|
||||
Type int8 `json:"type" compact:"type"` // 用户类型
|
||||
IDCardNo string `orm:"size(18);column(id_card_no)" json:"idCardNo" compact:"idCardNo"` // 身份证号
|
||||
Remark string `orm:"size(255)" json:"remark"`
|
||||
}
|
||||
|
||||
func (*User) TableUnique() [][]string {
|
||||
return [][]string{
|
||||
[]string{"UserID"},
|
||||
[]string{"UserID2", "DeletedAt"},
|
||||
// []string{"Name", "DeletedAt"},
|
||||
[]string{"Mobile"},
|
||||
// []string{"Email", "DeletedAt"},
|
||||
[]string{"Mobile", "DeletedAt"},
|
||||
[]string{"Email", "DeletedAt"},
|
||||
// []string{"IDCardNo", "DeletedAt"},
|
||||
}
|
||||
}
|
||||
@@ -55,11 +54,11 @@ func (user *User) GetID2() string {
|
||||
}
|
||||
|
||||
func (user *User) GetMobile() string {
|
||||
return user.Mobile
|
||||
return *user.Mobile
|
||||
}
|
||||
|
||||
func (user *User) GetEmail() string {
|
||||
return user.Email
|
||||
return *user.Email
|
||||
}
|
||||
|
||||
func (user *User) GetName() string {
|
||||
|
||||
Reference in New Issue
Block a user