Package com.mossle.auth.component

Source Code of com.mossle.auth.component.UserStatusChecker

package com.mossle.auth.component;

import com.mossle.auth.domain.UserStatus;
import com.mossle.auth.support.CheckUserStatusException;

import org.springframework.context.MessageSource;
import org.springframework.context.MessageSourceAware;
import org.springframework.context.support.MessageSourceAccessor;

import org.springframework.stereotype.Component;

@Component
public class UserStatusChecker implements MessageSourceAware {
    private MessageSourceAccessor messages;

    public void check(UserStatus userStatus) {
        if ((userStatus.getId() != null) && (userStatus.getId() == 1)) {
            throw new CheckUserStatusException(messages.getMessage(
                    "user.superuser.edit", "不允许修改超级管理员"));
        }
    }

    public void setMessageSource(MessageSource messageSource) {
        this.messages = new MessageSourceAccessor(messageSource);
    }
}
TOP

Related Classes of com.mossle.auth.component.UserStatusChecker

TOP
Copyright © 2018 www.massapi.com. 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.