Package com.sishuok.es.sys.user.entity

Examples of com.sishuok.es.sys.user.entity.User


            BindingResult result,
            @RequestParam(value = "receiver", required = false) String receiverUsername,
            Model model,
            RedirectAttributes redirectAttributes) {

        User receiver = userService.findByUsername(receiverUsername);
        if (receiver == null) {
            result.rejectValue("receiverId", "receiver.not.exists");
        }
        if (receiver.equals(user)) {
            result.rejectValue("receiverId", "receiver.not.self");
        }

        if (result.hasErrors()) {
            return showSendForm(model);
        }
        message.setReceiverId(receiver.getId());
        message.setSenderId(user.getId());
        messageApi.send(message);


        redirectAttributes.addFlashAttribute(Constants.MESSAGE, "发送成功!");
View Full Code Here


            @ModelAttribute("m") Message m, BindingResult result,
            RedirectAttributes redirectAttributes,
            Model model) {


        User receiver = userService.findByUsername(username);
        if (receiver == null) {
            result.rejectValue("receiverId", "receiver.not.exists");
        }

        if (receiver.equals(user)) {
            result.rejectValue("receiverId", "receiver.not.self");
        }

        if (result.hasErrors()) {
            return showForwardForm(parent, model);
        }
        m.setReceiverId(receiver.getId());
        m.setSenderId(user.getId());
        messageApi.send(m);

        redirectAttributes.addFlashAttribute(Constants.MESSAGE, "转发成功!");
        return redirectToUrl(viewName(MessageState.out_box + "/list"));
View Full Code Here

            @CurrentUser User user,
            @RequestParam(value = "username", required = false) String username,
            @ModelAttribute("m") Message m,
            RedirectAttributes redirectAttributes) {

        User receiver = userService.findByUsername(username);
        if (receiver != null) {
            m.setReceiverId(receiver.getId());
        }
        m.setSenderId(user.getId());

        messageApi.saveDraft(m);
View Full Code Here


    @RequestMapping(value = "draft/{m}/send", method = RequestMethod.GET)
    public String showResendDraftForm(@PathVariable("m") Message m, Model model) {
        if (m.getReceiverId() != null) {
            User user = userService.findOne(m.getReceiverId());
            if (user != null) {
                model.addAttribute("username", user.getUsername());
            }
        }
        model.addAttribute("m", m);
        String viewName = showSendForm(model);
        model.addAttribute(Constants.OP_NAME, "发送草稿");
View Full Code Here

    }

    @Override
    protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
        String username = (String) principals.getPrimaryPrincipal();
        User user = userService.findByUsername(username);

        SimpleAuthorizationInfo authorizationInfo = new SimpleAuthorizationInfo();
        authorizationInfo.setRoles(userAuthService.findStringRoles(user));
        authorizationInfo.setStringPermissions(userAuthService.findStringPermissions(user));
View Full Code Here

        String password = "";
        if (upToken.getPassword() != null) {
            password = new String(upToken.getPassword());
        }

        User user = null;
        try {
            user = userService.login(username, password);
        } catch (UserNotExistsException e) {
            throw new UnknownAccountException(e.getMessage(), e);
        } catch (UserPasswordNotMatchException e) {
            throw new AuthenticationException(e.getMessage(), e);
        } catch (UserPasswordRetryLimitExceedException e) {
            throw new ExcessiveAttemptsException(e.getMessage(), e);
        } catch (UserBlockedException e) {
            throw new LockedAccountException(e.getMessage(), e);
        } catch (Exception e) {
            log.error("login error", e);
            throw new AuthenticationException(new UserException("user.unknown.error", null));
        }

        SimpleAuthenticationInfo info = new SimpleAuthenticationInfo(user.getUsername(), password.toCharArray(), getName());
        return info;
    }
View Full Code Here


    @Test
    public void testSendSystemMessageToAllUserSuccess() throws ExecutionException, InterruptedException {

        User user1 = createDefaultUser();

        Long expectedCount = userService.count();

        Message message = new Message();
        message.setSenderId(senderId);
        message.setTitle("abcded");
        MessageContent content = new MessageContent();
        content.setContent("abcde");
        message.setContent(content);

        if(AopProxyUtils.isAsync(messageApi)) {
            AopProxyUtils.removeAsync(messageApi);
        }

        messageApi.sendSystemMessageToAllUser(message);

        Long actualCount = messageService.count();
        Assert.assertEquals(expectedCount, actualCount);

        Long[] userIds = new Long[]{user1.getId()};
        Searchable searchable = Searchable.newSearchable();
        searchable.addSearchFilter("receiverId", SearchOperator.in, userIds);
        List<Message> list = messageService.findAllWithNoPageNoSort(searchable);
        Assert.assertEquals(userIds.length, list.size());
        Assert.assertEquals(MessageType.system_message, list.get(0).getType());
View Full Code Here

    //////////////////////////////////////////////////////////////////////////////////
    ////查询时 查缓存/加缓存
    //////////////////////////////////////////////////////////////////////////////////
    @Around(value = "userAuthServicePointcut() && cacheFindRolesPointcut(arg)", argNames = "pjp,arg")
    public Object findRolesCacheableAdvice(ProceedingJoinPoint pjp, User arg) throws Throwable {
        User user = arg;

        String key = null;
        if (user != null) {
            key = rolesKey(user.getId());
        }

        Object retVal = get(key);

        if (retVal != null) {
View Full Code Here

        return retVal;
    }

    @Around(value = "userAuthServicePointcut() && cacheFindStringRolesPointcut(arg)", argNames = "pjp,arg")
    public Object findStringRolesCacheableAdvice(ProceedingJoinPoint pjp, User arg) throws Throwable {
        User user = arg;

        String key = null;
        if (user != null) {
            key = stringRolesKey(user.getId());
        }

        Object retVal = get(key);

        if (retVal != null) {
View Full Code Here

    }


    @Around(value = "userAuthServicePointcut() && cacheFindStringPermissionsPointcut(arg)", argNames = "pjp,arg")
    public Object findStringPermissionsCacheableAdvice(ProceedingJoinPoint pjp, User arg) throws Throwable {
        User user = arg;

        String key = stringPermissionsKey(user.getId());

        Object retVal = get(key);

        if (retVal != null) {
            log.debug("cacheName:{}, method:findStringPermissionsCacheableAdvice, hit key:{}", cacheName, key);
View Full Code Here

TOP

Related Classes of com.sishuok.es.sys.user.entity.User

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.