特朗普头像任务

This commit is contained in:
lianghuanjie
2025-01-20 21:55:43 +08:00
parent 38bb283fa1
commit 9c742c50c3
18 changed files with 266 additions and 32 deletions

View File

@@ -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