MCPcopy
hub / github.com/ccfos/nightingale / UserGet

Function UserGet

models/user.go:366–382  ·  view source on GitHub ↗
(ctx *ctx.Context, where string, args ...interface{})

Source from the content-addressed store, hash-verified

364}
365
366func UserGet(ctx *ctx.Context, where string, args ...interface{}) (*User, error) {
367 var lst []*User
368 err := DB(ctx).Where(where, args...).Find(&lst).Error
369 if err != nil {
370 return nil, err
371 }
372
373 if len(lst) == 0 {
374 return nil, nil
375 }
376
377 lst[0].RolesLst = strings.Fields(lst[0].Roles)
378 lst[0].Admin = lst[0].IsAdmin()
379 lst[0].DecryptPhone() // 解密手机号
380
381 return lst[0], nil
382}
383
384func UsersGet(ctx *ctx.Context, where string, args ...interface{}) ([]*User, error) {
385 var lst []*User

Callers 6

loginCallbackMethod · 0.92
loginCallbackCasMethod · 0.92
loginCallbackDingTalkMethod · 0.92
loginCallbackOAuthMethod · 0.92
UserGetByUsernameFunction · 0.85
UserGetByIdFunction · 0.85

Calls 3

DBFunction · 0.85
IsAdminMethod · 0.80
DecryptPhoneMethod · 0.80

Tested by

no test coverage detected