如何删除以下通用

时间:2015-11-12 19:23:02

标签: java spring spring-mvc

@Autowired
SessionFactory sessionFactory;

public SPLoginUser loginUser(final LoginBean loginBean) {
    final Map<String, Object> inParamMap = new HashMap<String, Object>();
    inParamMap.put(DAOConstants.EMAIL, loginBean.getEmail());
    inParamMap.put(DAOConstants.PASSWORD, loginBean.getPassword());
    @SuppressWarnings("unchecked")
    final List<SPLoginUser> list = sessionFactory
            .getCurrentSession()
            .getNamedQuery(
                    DAOConstants.SQL_FUNCTIONS.NAMED_NATIVE_QUERY.LOGIN_USER)
            .setProperties(inParamMap).list();

    if (list != null && list.size() == 1) {
        if (list.get(0).getErrorCode() == 200) {
            return list.get(0);
        } else {
            throw new UserNotFoundException(list.get(0).getErrorMessage());
        }
    } else {
        throw new UserNotFoundException();
    }
}

在上面提到的我的弹簧控制器代码中我想删除:

    if (list != null && list.size() == 1) {
        if (list.get(0).getErrorCode() == 200) {
            return list.get(0);
        } else {
            throw new UserNotFoundException(list.get(0).getErrorMessage());
        }
    } else {
        throw new UserNotFoundException();
    }
enter code here

并希望这是通用的,并且在1或2行中。

请帮帮我。这是我的春季mvc 4申请。

0 个答案:

没有答案