代码拉取完成,页面将自动刷新
package authing_v2
import (
"errors"
"log"
"gitee.com/carlmax_my/console-core-go/pkg/authing/authing_model"
"github.com/Authing/authing-go-sdk/lib/enum"
"github.com/Authing/authing-go-sdk/lib/model"
)
func (a *AuthingCli) GetUserList(page int, limit int) (list *[]authing_model.User) {
var userList []authing_model.User
custom := true
req := model.QueryListRequest{
Page: page,
Limit: limit,
SortBy: enum.SortByCreatedAtAsc,
WithCustomData: &custom,
}
userListRsp, _err := a.Cli.GetUserList(req)
if _err != nil {
log.Println("GetUserList err:" + _err.Error())
return
}
for _, user := range userListRsp.List {
u := new(authing_model.User)
u.InitFrom(&user)
userList = append(userList, *u)
}
return &userList
}
// with_custom_data=true&with_identities=true&withUserSource=true
func (a *AuthingCli) GetUser(userId *string) (*authing_model.User, error) {
resp, err := a.Cli.Detail(*userId)
if err != nil {
return nil, err
}
u := new(authing_model.User)
u.InitFrom(resp)
return u, nil
}
func (a *AuthingCli) CreateUser(user *authing_model.CreateUserInput) (*authing_model.User, error) {
req := model.CreateUserRequest{
UserInfo: model.CreateUserInput{
Username: user.Username,
Name: user.Name,
Email: user.Email,
Password: user.Password,
},
}
resp, err := a.Cli.CreateUser(req)
if err != nil {
return nil, err
}
u := new(authing_model.User)
u.InitFrom(resp)
return u, nil
}
func (a *AuthingCli) DeleteUser(id *string) (bool, error) {
resp, err := a.Cli.DeleteUser(*id)
if err != nil {
return false, err
}
if resp.Code != 200 {
return false, errors.New("delete user error:" + resp.Message)
}
return true, nil
}
func (a *AuthingCli) BatchDeleteUser(ids []string) (bool, error) {
resp, err := a.Cli.BatchDeleteUser(ids)
if err != nil {
return false, err
}
if resp.Code != 200 {
return false, errors.New("batch delete user error:" + resp.Message)
}
return true, nil
}
func (a *AuthingCli) UpdateUser(id *string, user *authing_model.UpdateUserInput) error {
req := model.UpdateUserInput{
Username: user.Username,
Email: user.Email,
Phone: user.Phone,
Name: user.Name,
Address: user.Address,
Password: user.Password,
}
if _, err := a.Cli.UpdateUser(*id, req); err != nil {
return err
}
return nil
}
func (a *AuthingCli) ActiveUser(id *string) error {
if _, err := a.Cli.ActivateUser(*id); err != nil {
return err
}
return nil
}
func (a *AuthingCli) DeActiveUser(id *string) error {
if _, err := a.Cli.SuspendUser(*id); err != nil {
return err
}
return nil
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。