func (s UserResource) Find(ctx context.Context, param string, condition bson.M, p api.Page) (v api.Responder, e error) { // validate authority uid, err := objectID(ctx) if err != nil { return nil, api.NewHTTPError(api.ErrAuthorization, api.CodeTokenAuthFailed) } rid, err := RoleID(s.UserStorage, uid) if err != nil { return nil, api.NewHTTPError(api.ErrAuthorization, api.CodeTokenAuthFailed) } permission, err := readAuthority(s.AuthorityStorage, rid, ModuleUserID) if err != nil { return nil, api.NewHTTPError(err, api.CodeNotEnoughAuthority) } // admin and customer account have access permission switch permission { case ReadWrite, OnlyRead: if param == "" { if !p.Valid { users, err := s.UserStorage.GetAll(condition) for k := range users { users[k].Password = utils.PasswordFormat } return &api.Response{Total: len(users), Data: interface{}(users), Status: http.StatusOK}, err } total, users, err := s.UserStorage.GetPage(p.Offset, p.Limit, condition) if err != nil { return &api.Response{}, api.NewHTTPError(err, api.CodeResourceNotFound) } for k := range users { users[k].Password = utils.PasswordFormat } return &api.Response{Total: total, Data: users, Status: http.StatusOK}, nil } default: return nil, api.NewHTTPError(api.ErrNotEnoughAuthority, api.CodeNotEnoughAuthority) } return nil, api.NewHTTPError(api.ErrInvalidURL, api.CodeInvalidURL) }
哪位大佬帮忙写一下啊,刚开始,写不来,求教一下,利用HTTP server和HTTP client
有疑问加站长微信联系(非本文作者)