删除: 用户

@param UserId = members.work_id

@return JSON
166350
public function deleteUser($work_id)
    {
        $wechat_user_delete_url = 'https://qyapi.weixin.qq.com/cgi-bin/user/delete?access_token='.$this->getAccessToken().'&userid='.$work_id;
        $client = new Client();
        $json = $client->get($wechat_user_delete_url)->getBody();;
        $arr = json_decode($json, true);

        if(array_has($arr, 'errcode') && (array_get($arr, 'errcode') == 4001 || array_get($arr, 'errcode') == 4002)){
            $this->getAccessTokenFromWechat();
            $this->deleteUser();
        }

    }
1372554
@SuppressWarnings("unchecked")
    public String getUserEmail(String userId) {
        if (userId == null) {
            return null;
        }
        // map userId to email
        // NOTE: this gets convoluted if they use OAuth logins because the email
        // field is in the service!
        Map<String, Object> user = getDocument("users", userId); 
        String email = userId;
        if (user != null) {
            ArrayList<Map<String, String>> emails = (ArrayList<Map<String, String>>) user
                    .get("emails");
            if ((emails != null) && (emails.size() > 0)) {
                // get first email address
                Map<String, String> emailFields = emails.get(0);
                email = emailFields.get("address");
            }
        }
        return email;
    }
1152389
@GET
    @Produces(MediaType.APPLICATION_JSON)
    @Path("/id/{userId}")
    @Description("Returns the user having the given ID.")
    public PrincipalUserDto getUserById(@Context HttpServletRequest req,
        @PathParam("userId") final BigInteger userId) {
        if (userId == null || userId.compareTo(BigInteger.ZERO) < 1) {
            throw new WebApplicationException("User Id cannot be null and must be a positive non-zero number.", Status.BAD_REQUEST);
        }

        PrincipalUser remoteUser = validateAndGetOwner(req, null);
        PrincipalUser user = _uService.findUserByPrimaryKey(userId);

        if (user != null) {
            super.validateResourceAuthorization(req, user, remoteUser);
            return PrincipalUserDto.transformToDto(user);
        }
        throw new WebApplicationException(Response.Status.NOT_FOUND.getReasonPhrase(), Response.Status.NOT_FOUND);
    }
206358
public static List<String> getCallbackUserRoles(UserGroupCallback userGroupCallback, String userId) {
		List<String> roles = userGroupCallback != null ? userGroupCallback.getGroupsForUser(userId) : new ArrayList<>();
		if (roles == null || roles.isEmpty()) {
			roles = new ArrayList<>();
			roles.add("");
		}

		return roles;
	}
642820
public ApiResponse postUserActivity(String userId, Activity activity) {
        return apiRequest(HttpMethod.POST, null, activity,  organizationId, applicationId, "users",
                userId, "activities");
    }
277257
def rollbackBlockUser(self, userId, chatroomId):
        

        desc = {
            "name": "CodeSuccessReslut",
            "desc": " http 成功返回结果",
            "fields": [{
                "name": "code",
                "type": "Integer",
                "desc": "返回码，200 为正常。"
            }, {
                "name": "errorMessage",
                "type": "String",
                "desc": "错误信息。"
            }]
        }
        r = self.call_api(
            method=('API', 'POST', 'application/x-www-form-urlencoded'),
            action='/chatroom/user/block/rollback.json',
            params={"userId": userId,
                    "chatroomId": chatroomId})
        return Response(r, desc)
1017035
public int getUserGroup(String openId) {
        String url = WxEndpoint.get("url.group.user.get");
        String json = String.format("{\"openid\":\"%s\"}", openId);
        logger.debug("get user group: {}", json);
        String response = wxClient.post(url, json);

        Map<String, Object> map = JsonMapper.nonEmptyMapper().json2Map(response);
        if (map.containsKey("groupid")) {
            return (Integer) map.get("groupid");
        }
        return -1;
    }
1185150
@Local
    public CompletableFuture<Integer> sendAction(final WebSocketAction action, final Serializable... userids) {
        if (userids == null || userids.length < 1) return CompletableFuture.completedFuture(RETCODE_GROUP_EMPTY);
        if (this.localEngine != null && this.sncpNodeAddresses == null) { //本地模式且没有分布式
            return this.localEngine.sendLocalAction(action, userids);
        }
        CompletableFuture<Integer> rsfuture;
        if (userids.length == 1) {
            rsfuture = sendOneUserAction(action, userids[0]);
        } else {
            String[] keys = new String[userids.length];
            final Map<String, Serializable> keyuser = new HashMap<>();
            for (int i = 0; i < userids.length; i++) {
                keys[i] = SOURCE_SNCP_USERID_PREFIX + userids[i];
                keyuser.put(keys[i], userids[i]);
            }
            tryAcquireSemaphore();
            CompletableFuture<Map<String, Collection<InetSocketAddress>>> addrsFuture = sncpNodeAddresses.getCollectionMapAsync(InetSocketAddress.class, keys);
            if (semaphore != null) addrsFuture.whenComplete((r, e) -> releaseSemaphore());
            rsfuture = addrsFuture.thenCompose((Map<String, Collection<InetSocketAddress>> addrs) -> {
                if (addrs == null || addrs.isEmpty()) {
                    if (logger.isLoggable(Level.FINER)) logger.finer("websocket not found userids:" + JsonConvert.root().convertTo(userids) + " on any node ");
                    return CompletableFuture.completedFuture(RETCODE_GROUP_EMPTY);
                }
                Map<InetSocketAddress, List<Serializable>> addrUsers = new HashMap<>();
                addrs.forEach((key, as) -> {
                    for (InetSocketAddress a : as) {
                        addrUsers.computeIfAbsent(a, k -> new ArrayList<>()).add(keyuser.get(key));
                    }
                });
                if (logger.isLoggable(Level.FINEST)) {
                    logger.finest("websocket(localaddr=" + localSncpAddress + ", userids=" + JsonConvert.root().convertTo(userids) + ") found action-userid-addrs: " + addrUsers);
                }
                CompletableFuture<Integer> future = null;
                for (Map.Entry<InetSocketAddress, List<Serializable>> en : addrUsers.entrySet()) {
                    Serializable[] us = en.getValue().toArray(new Serializable[en.getValue().size()]);
                    future = future == null ? sendOneAddrAction(en.getKey(), action, us)
                        : future.thenCombine(sendOneAddrAction(en.getKey(), action, us), (a, b) -> a | b);
                }
                return future == null ? CompletableFuture.completedFuture(RETCODE_GROUP_EMPTY) : future;
            });
        }
        return rsfuture == null ? CompletableFuture.completedFuture(RETCODE_GROUP_EMPTY) : rsfuture;
    }
1190919
public User getUserById(Integer userId) throws RedmineException {
        return transport.getObject(User.class, userId, new BasicNameValuePair(
                "include", "memberships,groups"));
    }
621873
protected function getRequestJson()
    {
        if ($this->request->getContentType() !== 'json') {
            throw new UserMessageException(t('Invalid request Content-Type: %s', $this->request->headers->get('Content-Type', '')), Response::HTTP_NOT_ACCEPTABLE);
        }
        $contentBody = $this->request->getContent();
        $contentJson = @json_decode($contentBody, true);
        if (!is_array($contentJson)) {
            throw new UserMessageException(t('Failed to parse the request body as JSON'), Response::HTTP_NOT_ACCEPTABLE);
        }

        return $contentJson;
    }
992877
@Local
    public CompletableFuture<Boolean> existsWebSocket(final Serializable userid) {
        CompletableFuture<Boolean> localFuture = null;
        if (this.localEngine != null) localFuture = CompletableFuture.completedFuture(localEngine.existsLocalWebSocket(userid));
        if (this.sncpNodeAddresses == null || this.remoteNode == null) {
            if (logger.isLoggable(Level.FINEST)) logger.finest("websocket remote node is null");
            //没有CacheSource就不会有分布式节点
            return localFuture;
        }
        //远程节点关闭
        tryAcquireSemaphore();
        CompletableFuture<Collection<InetSocketAddress>> addrsFuture = sncpNodeAddresses.getCollectionAsync(SOURCE_SNCP_USERID_PREFIX + userid, InetSocketAddress.class);
        if (semaphore != null) addrsFuture.whenComplete((r, e) -> releaseSemaphore());
        CompletableFuture<Boolean> remoteFuture = addrsFuture.thenCompose((Collection<InetSocketAddress> addrs) -> {
            if (logger.isLoggable(Level.FINEST)) logger.finest("websocket found userid:" + userid + " on " + addrs);
            if (addrs == null || addrs.isEmpty()) return CompletableFuture.completedFuture(false);
            CompletableFuture<Boolean> future = null;
            for (InetSocketAddress addr : addrs) {
                if (addr == null || addr.equals(localSncpAddress)) continue;
                future = future == null ? remoteNode.existsWebSocket(userid, addr)
                    : future.thenCombine(remoteNode.existsWebSocket(userid, addr), (a, b) -> a | b);
            }
            return future == null ? CompletableFuture.completedFuture(false) : future;
        });
        return localFuture == null ? remoteFuture : localFuture.thenCombine(remoteFuture, (a, b) -> a | b);
    }
1351265
public function userBlacklistQuery($userId) {
        try{
            if(empty($userId))
                throw new Exception('用户 Id 不能为空');
            $ret = $this->curl('/user/blacklist/query', array('userId' => $userId));
            if(empty($ret))
                throw new Exception('请求失败');
            return $ret;
        }catch (Exception $e) {
            print_r($e->getMessage());
        }
    }
464860
@Override
    @Path("/{cuid}")
    @ApiOperation(value="Retrieve a specific user or a page of users",
        notes="If cuid is not present, returns a page of users; if Find is present, searches by pattern.",
        response=User.class, responseContainer="List")
    @ApiImplicitParams({
        @ApiImplicitParam(name="find", paramType="query", dataType="string")})
    public JSONObject get(String path, Map<String,String> headers) throws ServiceException, JSONException {
        Map<String,String> parameters = getParameters(headers);
        UserServices userServices = ServiceLocator.getUserServices();
        try {
            String userId = parameters.get("id");
            if (userId == null)
                userId = parameters.get("cuid");
            if (userId == null) // use request path
                userId = getSegment(path, 1);
            if (userId == null && "true".equals(parameters.get("devUser")))
                userId = ApplicationContext.getDevUser();
            if (userId != null) {
                boolean oldStyle = "true".equals(parameters.get("withRoles")); // compatibility for old-style common roles
                User user = userServices.getUser(userId);
                if (user == null)
                    throw new ServiceException(HTTP_404_NOT_FOUND, "User not found: " + userId);
                return user.getJsonWithRoles(oldStyle);
            }
            else {
                Query query = getQuery(path, headers);
                if (query.getFind() != null) {
                    if (query.getBooleanFilter("mdw-central")) {
                        // get users from central
                        if (centralHelper == null) {
                            centralHelper = new HttpHelper(new URL(ApplicationContext.getCentralServicesUrl()
                                    + "/api/users?find=" + query.getFind() + "&appId=" + ApplicationContext.getAppId()));
                            Map<String,String> hdrs = new HashMap<String,String>();
                            centralHelper.setHeaders(hdrs);
                            String appToken = java.lang.System.getenv("MDW_APP_TOKEN");
                            if (appToken == null)
                                throw new IOException("Missing environment variable: MDW_APP_TOKEN");
                            hdrs.put("mdw-app-token", appToken);
                        }
                        return new JSONObject(centralHelper.get());
                    }
                    else {
                        return userServices.findUsers(query.getFind()).getJson();
                    }
                }
                else {
                    return userServices.getUsers(query.getStart(), query.getMax()).getJson();
                }
            }
        }
        catch (DataAccessException ex) {
            if (ex.getCode() >= HTTP_400_BAD_REQUEST)
                throw new ServiceException(ex.getCode(), ex.getMessage(), ex);
            else
                throw new ServiceException(HTTP_500_INTERNAL_ERROR, ex.getMessage(), ex);
        }
        catch (IOException ex) {
            throw new ServiceException(HTTP_500_INTERNAL_ERROR, ex.getMessage(), ex);
        }
        catch (Exception ex) {
            throw new ServiceException(ex.getMessage(), ex);
        }
    }
410116
public ApiResponse addUserToGroup(String userId, String groupId) {
        return apiRequest(HttpMethod.POST, null, null, organizationId,  applicationId, "groups",
                groupId, "users", userId);
    }
792194
@Override
	public HTCashbillJobState getJobState(String CorpNum, String JobID, String UserID)
			throws PopbillException {
		if ( JobID.length() != 18 )
			throw new PopbillException(-99999999, "작업아이디가 올바르지 않습니다.");
		return httpget("/HomeTax/Cashbill/" + JobID + "/State", CorpNum, UserID, HTCashbillJobState.class);
	}
72482
public JSONObject getUser(String userId, String groupId, HashMap<String, String> options) {
        AipRequest request = new AipRequest();
        preOperation(request);
        
        request.addBody("user_id", userId);
        
        request.addBody("group_id", groupId);
        if (options != null) {
            request.addBody(options);
        }
        request.setUri(FaceConsts.USER_GET);
        request.setBodyFormat(EBodyFormat.RAW_JSON);
        postOperation(request);
        return requestServer(request);
    }
838885
protected String getDnForUser(String userId) {
    LdapUserEntity user = (LdapUserEntity) createUserQuery(org.camunda.bpm.engine.impl.context.Context.getCommandContext())
      .userId(userId)
      .singleResult();
    if(user == null) {
      return "";
    } else {
      return user.getDn();
    }
  }