特朗普头像任务
This commit is contained in:
@@ -16,6 +16,7 @@ type (
|
||||
nhRoleModel
|
||||
withSession(session sqlx.Session) NhRoleModel
|
||||
AccountExist(ctx context.Context, account string) (bool, error)
|
||||
FindRoleUserId(ctx context.Context, roleId int64) (uint, error)
|
||||
}
|
||||
|
||||
customNhRoleModel struct {
|
||||
@@ -23,6 +24,20 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
func (m *customNhRoleModel) FindRoleUserId(ctx context.Context, roleId int64) (uint, error) {
|
||||
query := fmt.Sprintf("SELECT u.id FROM `nh_user` u JOIN %s r ON u.email = r.account WHERE r.role_id = ?", m.table)
|
||||
var resp uint
|
||||
err := m.conn.QueryRowPartialCtx(ctx, &resp, query, roleId)
|
||||
switch {
|
||||
case err == nil:
|
||||
return resp, nil
|
||||
case errors.Is(err, sqlx.ErrNotFound):
|
||||
return 0, nil
|
||||
default:
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
|
||||
func (m *customNhRoleModel) AccountExist(ctx context.Context, account string) (bool, error) {
|
||||
query := fmt.Sprintf("select count(*) as `count` from %s where `account` = ?", m.table)
|
||||
var count int64
|
||||
|
||||
Reference in New Issue
Block a user