⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 userlogin.java

📁 信息发布 发布系统 动态的菜单 和 信息统计
💻 JAVA
字号:
package com.xuntian.material.model.service.portal;

import java.sql.SQLException;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionForm;

import com.xuntian.material.bean.ItemBean;
import com.xuntian.material.bean.UserBean;
import com.xuntian.material.bean.entity.UserEntity;
import com.xuntian.material.exception.ConnectPoolException;
import com.xuntian.material.exception.PortalException;
import com.xuntian.material.model.iservice.portal.IUserLogin;
import com.xuntian.material.util.Constants;
import com.xuntian.material.util.LogUtil;

public class UserLogin implements IUserLogin {
    public static IUserLogin getInstance() {
        return new UserLogin();
    }

    private UserLogin() {
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.xuntian.material.model.service.common.IUserLogin#isUserLogin(java.lang.String,
     *      java.lang.String)
     */
    public boolean isUserLogin(UserBean user) throws PortalException {
        UserEntity entity = new UserEntity(user);
        try {
            if (entity.isLogin()) {
                entity.fillRole();
                return true;
            }
        } catch (ConnectPoolException cpe) {
            logAndThrowsPortalException(cpe,
                    "the connection pool or the database is error");
        } catch (SQLException sqle) {
            logAndThrowsPortalException(sqle,
                    "the connection pool or the database is error");
        }
        return false;
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.xuntian.material.model.iservice.portal.IUserLogin#itemList(int[])
     */
    public List<ItemBean> itemList(int[] itemIDs) throws PortalException {
        List<ItemBean> itemList = null;
        return itemList;
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.xuntian.material.model.iservice.portal.IUserLogin#projectList(int[])
     */
   
    /*
     * (non-Javadoc)
     * 
     * @see com.xuntian.material.model.iservice.portal.IUserLogin#fill(javax.servlet.http.HttpServletRequest,
     *      org.apache.struts.action.ActionForm)
     */
    public void fill(HttpServletRequest request, ActionForm form)
            throws PortalException {
        UserBean user = (UserBean) form;
        UserBean sessionUser = (UserBean) request.getSession().getAttribute(
                Constants.SESSION_USER);
        user.setUserID(sessionUser.getUserID());
        UserEntity userEntity = new UserEntity(user);
        try {
            userEntity.fill();
        } catch (ConnectPoolException cpe) {
            logAndThrowsPortalException(cpe, "保存时出现错误!");
        } catch (SQLException sqle) {
            logAndThrowsPortalException(sqle, "保存时出现错误!");
        }
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.xuntian.material.model.iservice.portal.IUserLogin#save(javax.servlet.http.HttpServletRequest,
     *      org.apache.struts.action.ActionForm)
     */
    public int save(HttpServletRequest request, ActionForm form)
            throws PortalException {
        UserBean user = (UserBean) form;
        UserBean sessionUser = (UserBean) request.getSession().getAttribute(
                Constants.SESSION_USER);
        user.setUserID(sessionUser.getUserID());
        UserEntity userEntity = new UserEntity(user);
        int result = 0;
        String password = user.getPassword();
        if (password != null && !password.equals("")) {
            String inpwd = user.getUsername();
            String oldpwd = sessionUser.getPassword();
            if (inpwd == null || !inpwd.equals(oldpwd)) {
                return -2;
            }
        }
        try {
            result = userEntity.save(null, null);
        } catch (ConnectPoolException cpe) {
            logAndThrowsPortalException(cpe, "保存时出现错误!");
        }
        return result;
    }

    /**
     * @param t
     * @param message
     * @throws PortalException
     */
    private void logAndThrowsPortalException(Throwable t, String message)
            throws PortalException {
        LogUtil.getLogger(this).error(message);
        throw new PortalException(message, t);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -