(ctx *ctx.Context, where string, args ...interface{})
| 364 | } |
| 365 | |
| 366 | func 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 | |
| 384 | func UsersGet(ctx *ctx.Context, where string, args ...interface{}) ([]*User, error) { |
| 385 | var lst []*User |
no test coverage detected