开发进度-4

com.action包:

package com.action;

import java.util.List;
import java.util.Map;

import org.apache.struts2.ServletActionContext;

import com.dao.TAdminDAO;
import com.model.TAdmin;
import com.opensymphony.xwork2.ActionSupport;

public class adminAction extends ActionSupport
{
    private int userId;
    private String userName;
    private String userPw;
     
    private String message;
    private String path;
    
    private int index=1;

    private TAdminDAO adminDAO;
    
    
    public String adminAdd()
    {
        TAdmin admin=new TAdmin();
        admin.setUserName(userName);
        admin.setUserPw(userPw);
        adminDAO.save(admin);
        this.setMessage("�����ɹ�");
        this.setPath("adminManage.action");
        return "succeed";
    }
    
    
    
    public String adminManage()
    {
        List adminList=adminDAO.findAll();
        Map request=(Map)ServletActionContext.getContext().get("request");
        request.put("adminList", adminList);
        return ActionSupport.SUCCESS;
    }
    
    
    public String adminDel()
    {
        adminDAO.delete(adminDAO.findById(userId));
        this.setMessage("ɾ���ɹ�");
        this.setPath("adminManage.action");
        return "succeed";
    }
    
    

    public TAdminDAO getAdminDAO()
    {
        return adminDAO;
    }

    public void setAdminDAO(TAdminDAO adminDAO)
    {
        this.adminDAO = adminDAO;
    }

    public String getMessage()
    {
        return message;
    }

    public int getIndex()
    {
        return index;
    }



    public void setIndex(int index)
    {
        this.index = index;
    }



    public void setMessage(String message)
    {
        this.message = message;
    }

    public String getPath()
    {
        return path;
    }

    public void setPath(String path)
    {
        this.path = path;
    }

    public int getUserId()
    {
        return userId;
    }

    public void setUserId(int userId)
    {
        this.userId = userId;
    }

    public String getUserName()
    {
        return userName;
    }

    public void setUserName(String userName)
    {
        this.userName = userName;
    }

    public String getUserPw()
    {
        return userPw;
    }

    public void setUserPw(String userPw)
    {
        this.userPw = userPw;
    }
     
}
package com.action;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.apache.struts2.ServletActionContext;

import com.dao.TRizhiDAO;
import com.model.TAdmin;
import com.model.TRizhi;
import com.model.TUser;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class rizhiAction extends ActionSupport
{
    private Integer id;
    private String title;
    private String content;
    private String shijian;

    private Integer userId;
    
    private String message;
    private String path;
    
    private TRizhiDAO rizhiDAO;
    
    public String rizhiAdd()
    {
        Map session= ServletActionContext.getContext().getSession();
        TUser user=(TUser)session.get("user");
        
        TRizhi rizhi=new TRizhi();
        
        rizhi.setTitle(title);
        rizhi.setContent(content);
        rizhi.setShijian(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
        rizhi.setUserId(user.getUserId());
        
        rizhiDAO.save(rizhi);
        this.setMessage("������");
        this.setPath("rizhiMana.action");
        return "succeed";
    }
    
    
    public String rizhiMana()
    {
        Map session= ServletActionContext.getContext().getSession();
        TUser user=(TUser)session.get("user");
        
        String sql="from TRizhi where userId="+user.getUserId();
        List rizhiList =rizhiDAO.getHibernateTemplate().find(sql);
        Map request=(Map)ServletActionContext.getContext().get("request");
        request.put("rizhiList", rizhiList);
        return ActionSupport.SUCCESS;
    }
    
    public String rizhiDel()
    {
        TRizhi rizhi=rizhiDAO.findById(id);
        rizhiDAO.delete(rizhi);
        this.setMessage("ɾ�����");
        this.setPath("rizhiMana.action");
        return "succeed";
    }


    public String getContent()
    {
        return content;
    }


    public void setContent(String content)
    {
        this.content = content;
    }


    public Integer getId()
    {
        return id;
    }


    public void setId(Integer id)
    {
        this.id = id;
    }


    public String getMessage()
    {
        return message;
    }


    public void setMessage(String message)
    {
        this.message = message;
    }


    public String getPath()
    {
        return path;
    }


    public void setPath(String path)
    {
        this.path = path;
    }


    public TRizhiDAO getRizhiDAO()
    {
        return rizhiDAO;
    }


    public void setRizhiDAO(TRizhiDAO rizhiDAO)
    {
        this.rizhiDAO = rizhiDAO;
    }


    public String getShijian()
    {
        return shijian;
    }


    public void setShijian(String shijian)
    {
        this.shijian = shijian;
    }


    public String getTitle()
    {
        return title;
    }


    public void setTitle(String title)
    {
        this.title = title;
    }


    public Integer getUserId()
    {
        return userId;
    }


    public void setUserId(Integer userId)
    {
        this.userId = userId;
    }
    
}
package com.action;

import java.util.List;
import java.util.Map;

import org.apache.struts2.ServletActionContext;

import com.dao.TShouruDAO;
import com.model.TShouru;
import com.model.TUser;
import com.opensymphony.xwork2.ActionSupport;

public class shouruAction extends ActionSupport
{
    private Integer id;
    private String shijian;
    private Double jine;
    private String chengyuan;

    private String leixing;
    private String beizhu;
    private Integer userId;
    
    private String message;
    private String path;
    
    private TShouruDAO shouruDAO;
    
    
    public String shouruAdd()
    {
        Map session= ServletActionContext.getContext().getSession();
        TUser user=(TUser)session.get("user");
        
        TShouru shouru=new TShouru();
        
        shouru.setShijian(shijian);
        shouru.setJine(jine);
        shouru.setChengyuan(chengyuan);
        shouru.setLeixing(leixing);
        
        shouru.setBeizhu(beizhu);
        shouru.setUserId(user.getUserId());
        
        shouruDAO.save(shouru);
        this.setMessage("�����ɹ�");
        this.setPath("shouruMana.action");
        return "succeed";
    }
    
    public String shouruMana()
    {
        Map session= ServletActionContext.getContext().getSession();
        TUser user=(TUser)session.get("user");
        
        String sql ="from TShouru where userId="+user.getUserId();
        List shouruList=shouruDAO.getHibernateTemplate().find(sql);
        
        Map request=(Map)ServletActionContext.getContext().get("request");
        request.put("shouruList", shouruList);
        return ActionSupport.SUCCESS;
    }
    
    public String shouruDel()
    {
        TShouru shouru=shouruDAO.findById(id);
        shouruDAO.delete(shouru);
        this.setMessage("�����ɹ�");
        this.setPath("shouruMana.action");
        return "succeed";
    }

    public String getBeizhu()
    {
        return beizhu;
    }

    public void setBeizhu(String beizhu)
    {
        this.beizhu = beizhu;
    }

    public String getChengyuan()
    {
        return chengyuan;
    }

    public void setChengyuan(String chengyuan)
    {
        this.chengyuan = chengyuan;
    }

    public Integer getId()
    {
        return id;
    }

    public void setId(Integer id)
    {
        this.id = id;
    }

    public Double getJine()
    {
        return jine;
    }

    public void setJine(Double jine)
    {
        this.jine = jine;
    }

    public String getLeixing()
    {
        return leixing;
    }

    public void setLeixing(String leixing)
    {
        this.leixing = leixing;
    }

    public String getMessage()
    {
        return message;
    }

    public void setMessage(String message)
    {
        this.message = message;
    }

    public String getPath()
    {
        return path;
    }

    public void setPath(String path)
    {
        this.path = path;
    }


    public String getShijian()
    {
        return shijian;
    }

    public void setShijian(String shijian)
    {
        this.shijian = shijian;
    }

    public TShouruDAO getShouruDAO()
    {
        return shouruDAO;
    }

    public void setShouruDAO(TShouruDAO shouruDAO)
    {
        this.shouruDAO = shouruDAO;
    }

    public Integer getUserId()
    {
        return userId;
    }

    public void setUserId(Integer userId)
    {
        this.userId = userId;
    }
    
}
package com.action;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.dao.TShouruDAO;
import com.dao.TXiaofeiDAO;
import com.model.TUser;
import com.opensymphony.xwork2.ActionSupport;

public class tongjiAction extends ActionSupport
{
        
    private String message;
    private String path;
    
    private TShouruDAO shouruDAO;
    private TXiaofeiDAO xiaofeiDAO;
    
    
    public String tongji_meiri()
    {
        HttpServletRequest req=ServletActionContext.getRequest();
        HttpSession sess=req.getSession();
        TUser user=(TUser)sess.getAttribute("user");
        
        String shijian="";
        if(req.getParameter("shijian")==null)
        {
            shijian=new SimpleDateFormat("yyyy-MM-dd").format(new Date());
        }
        else
        {
            shijian=req.getParameter("shijian");
        }
        
        
        String sql ="from TShouru where shijian=? and userId="+user.getUserId();
        Object c[]={shijian};
        List shouruList=shouruDAO.getHibernateTemplate().find(sql,c);
        req.setAttribute("shouruList", shouruList);
        
        
        String sql1 ="from TXiaofei where shijian=? and userId="+user.getUserId();
        Object c1[]={shijian};
        List xiaofeiList=xiaofeiDAO.getHibernateTemplate().find(sql1,c1);
        req.setAttribute("xiaofeiList", xiaofeiList);
        
        req.setAttribute("shijian", shijian);
        
        return ActionSupport.SUCCESS;
    }
    
    
    public String tongji_meiyue()
    {
        HttpServletRequest req=ServletActionContext.getRequest();
        HttpSession sess=req.getSession();
        TUser user=(TUser)sess.getAttribute("user");
        
        String shijian="";
        if(req.getParameter("shijian")==null)
        {
            shijian=new SimpleDateFormat("yyyy-MM").format(new Date());
        }
        else
        {
            shijian=req.getParameter("shijian");
        }
        
        System.out.println(shijian+"RRR");
        
        String sql ="from TShouru where shijian like '%"+shijian+"%'"+" and userId="+user.getUserId();
        List shouruList=shouruDAO.getHibernateTemplate().find(sql);
        req.setAttribute("shouruList", shouruList);
        
        
        String sql1 ="from TXiaofei where shijian like '%"+shijian+"%'"+" and userId="+user.getUserId();
        List xiaofeiList=xiaofeiDAO.getHibernateTemplate().find(sql1);
        req.setAttribute("xiaofeiList", xiaofeiList);
        
        req.setAttribute("shijian", shijian);
        
        return ActionSupport.SUCCESS;
    }
    
    

    public String getMessage()
    {
        return message;
    }

    public void setMessage(String message)
    {
        this.message = message;
    }

    public String getPath()
    {
        return path;
    }

    public void setPath(String path)
    {
        this.path = path;
    }

    public TShouruDAO getShouruDAO()
    {
        return shouruDAO;
    }

    public void setShouruDAO(TShouruDAO shouruDAO)
    {
        this.shouruDAO = shouruDAO;
    }

    public TXiaofeiDAO getXiaofeiDAO()
    {
        return xiaofeiDAO;
    }



    public void setXiaofeiDAO(TXiaofeiDAO xiaofeiDAO)
    {
        this.xiaofeiDAO = xiaofeiDAO;
    }

}
package com.action;

import java.util.List;
import java.util.Map;

import org.apache.struts2.ServletActionContext;

import com.dao.TShouruDAO;
import com.dao.TTouziDAO;
import com.model.TShouru;
import com.model.TTouzi;
import com.model.TUser;
import com.opensymphony.xwork2.ActionSupport;

public class touziAction extends ActionSupport
{
    private Integer id;
    private String xangmu;
    private Double benjin;
    private String kaishi;

    private String jiehsu;
    private Double shouyi;
    private Integer userId;
    
    private String message;
    private String path;
    
    private TTouziDAO touziDAO;
    
    
    public String touziAdd()
    {
        Map session= ServletActionContext.getContext().getSession();
        TUser user=(TUser)session.get("user");
        
        TTouzi touzi=new TTouzi();
        
        touzi.setXangmu(xangmu);
        touzi.setBenjin(benjin);
        touzi.setKaishi(kaishi);
        touzi.setJiehsu(jiehsu);
        
        touzi.setShouyi(shouyi);
        touzi.setUserId(user.getUserId());
        
        touziDAO.save(touzi);
        this.setMessage("�����ɹ�");
        this.setPath("touziMana.action");
        return "succeed";
    }
    
    public String touziMana()
    {
        Map session= ServletActionContext.getContext().getSession();
        TUser user=(TUser)session.get("user");
        
        String sql ="from TTouzi where userId="+user.getUserId();
        List touziList=touziDAO.getHibernateTemplate().find(sql);
        
        Map request=(Map)ServletActionContext.getContext().get("request");
        request.put("touziList", touziList);
        return ActionSupport.SUCCESS;
    }
    
    public String touziDel()
    {
        TTouzi touzi=touziDAO.findById(id);
        touziDAO.delete(touzi);
        this.setMessage("�����ɹ�");
        this.setPath("touziMana.action");
        return "succeed";
    }

    public Double getBenjin()
    {
        return benjin;
    }

    public void setBenjin(Double benjin)
    {
        this.benjin = benjin;
    }

    public Integer getId()
    {
        return id;
    }

    public void setId(Integer id)
    {
        this.id = id;
    }

    public String getJiehsu()
    {
        return jiehsu;
    }

    public void setJiehsu(String jiehsu)
    {
        this.jiehsu = jiehsu;
    }

    public String getKaishi()
    {
        return kaishi;
    }

    public void setKaishi(String kaishi)
    {
        this.kaishi = kaishi;
    }

    public String getMessage()
    {
        return message;
    }

    public void setMessage(String message)
    {
        this.message = message;
    }

    public String getPath()
    {
        return path;
    }

    public void setPath(String path)
    {
        this.path = path;
    }

    public Double getShouyi()
    {
        return shouyi;
    }

    public void setShouyi(Double shouyi)
    {
        this.shouyi = shouyi;
    }

    public TTouziDAO getTouziDAO()
    {
        return touziDAO;
    }

    public void setTouziDAO(TTouziDAO touziDAO)
    {
        this.touziDAO = touziDAO;
    }

    public Integer getUserId()
    {
        return userId;
    }

    public void setUserId(Integer userId)
    {
        this.userId = userId;
    }

    public String getXangmu()
    {
        return xangmu;
    }

    public void setXangmu(String xangmu)
    {
        this.xangmu = xangmu;
    }
    
}
package com.action;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.dao.TUserDAO;
import com.model.TUser;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class UserAction extends ActionSupport
{
    private Integer userId;
    private String userRealname;
    private String userSex;
    private String userTel;
    
    private String userAddress;
    private String userName;
    private String userPw;
    private String userDel;
    
   
    
    
    
    private String message;
    private String path;
    
    private TUserDAO userDAO;
    
    
    public String userReg()
    {
        HttpServletRequest request=ServletActionContext.getRequest();
        
        String sql="from TUser where userName=?";
        Object[] c={userName.trim()};
        List list=userDAO.getHibernateTemplate().find(sql,c);
        if(list.size()>0)
        {
            request.setAttribute("msg", "�û����ѱ�ռ��,������ע��");
        }
        else
        {
            TUser user=new TUser();
            
            user.setUserRealname(userRealname);
            user.setUserSex(userSex);
            user.setUserTel(userTel);
            user.setUserAddress(userAddress);
            
            user.setUserName(userName.trim());
            user.setUserPw(userPw);
            user.setUserDel("no");
            
            userDAO.save(user);
            
            request.setAttribute("msg", "ע��ɹ������¼");
        }
        
        return "msg";
    }
    
    
    public String userDel()
    {
        TUser user=userDAO.findById(userId);
        user.setUserDel("yes");
        userDAO.getHibernateTemplate().update(user);
        this.setMessage("ɾ���ɹ�");
        this.setPath("userMana.action");
        return "succeed";
    }
    
    
    public String userMana()
    {
        List userList=userDAO.findAll();
        Map request=(Map)ServletActionContext.getContext().get("request");
        request.put("userList", userList);
        return ActionSupport.SUCCESS;
    }
    
    public String userEdit()
    {
        TUser user=userDAO.findById(userId);
        
        user.setUserPw(userPw);
        user.setUserRealname(userRealname);
        user.setUserSex(userSex);
        user.setUserTel(userTel);
        user.setUserAddress(userAddress);
        
        
        user.setUserDel("no");
        
        userDAO.attachDirty(user);
        
        Map request=(Map)ServletActionContext.getContext().get("request");
        request.put("msg", "�޸ijɹ������µ�¼����Ч");
        return "msg";
    }

    public String userLogout()
    {
        Map session= ServletActionContext.getContext().getSession();
        session.remove("user");
        return ActionSupport.SUCCESS;
    }

    public String getMessage()
    {
        return message;
    }


    public void setMessage(String message)
    {
        this.message = message;
    }


    public String getPath()
    {
        return path;
    }


    public void setPath(String path)
    {
        this.path = path;
    }


    public String getUserAddress()
    {
        return userAddress;
    }


    public void setUserAddress(String userAddress)
    {
        this.userAddress = userAddress;
    }


    public TUserDAO getUserDAO()
    {
        return userDAO;
    }


    public void setUserDAO(TUserDAO userDAO)
    {
        this.userDAO = userDAO;
    }


    public String getUserDel()
    {
        return userDel;
    }


    public void setUserDel(String userDel)
    {
        this.userDel = userDel;
    }


    public Integer getUserId()
    {
        return userId;
    }


    public void setUserId(Integer userId)
    {
        this.userId = userId;
    }


    public String getUserName()
    {
        return userName;
    }


    public void setUserName(String userName)
    {
        this.userName = userName;
    }


    public String getUserPw()
    {
        return userPw;
    }


    public void setUserPw(String userPw)
    {
        this.userPw = userPw;
    }


    public String getUserRealname()
    {
        return userRealname;
    }


    public void setUserRealname(String userRealname)
    {
        this.userRealname = userRealname;
    }


    public String getUserSex()
    {
        return userSex;
    }


    public void setUserSex(String userSex)
    {
        this.userSex = userSex;
    }


    public String getUserTel()
    {
        return userTel;
    }


    public void setUserTel(String userTel)
    {
        this.userTel = userTel;
    }
    
}
package com.action;

import java.util.List;
import java.util.Map;

import org.apache.struts2.ServletActionContext;

import com.dao.TShouruDAO;
import com.dao.TXiaofeiDAO;
import com.model.TShouru;
import com.model.TUser;
import com.model.TXiaofei;
import com.opensymphony.xwork2.ActionSupport;

public class xiaofeiAction extends ActionSupport
{
    private Integer id;
    private String shijian;
    private Double jine;
    private String chengyuan;

    private String leixing;
    private String beizhu;
    private Integer userId;
    
    private String message;
    private String path;
    
    private TXiaofeiDAO xiaofeiDAO;
    
    
    public String xiaofeiAdd()
    {
        Map session= ServletActionContext.getContext().getSession();
        TUser user=(TUser)session.get("user");
        
        TXiaofei xiaofei=new TXiaofei();
        
        xiaofei.setShijian(shijian);
        xiaofei.setJine(jine);
        xiaofei.setChengyuan(chengyuan);
        xiaofei.setLeixing(leixing);
        
        xiaofei.setBeizhu(beizhu);
        xiaofei.setUserId(user.getUserId());
        
        xiaofeiDAO.save(xiaofei);
        this.setMessage("�����ɹ�");
        this.setPath("xiaofeiMana.action");
        return "succeed";
    }
    
    public String xiaofeiMana()
    {
        Map session= ServletActionContext.getContext().getSession();
        TUser user=(TUser)session.get("user");
        
        String sql ="from TXiaofei where userId="+user.getUserId();
        List xiaofeiList=xiaofeiDAO.getHibernateTemplate().find(sql);
        
        Map request=(Map)ServletActionContext.getContext().get("request");
        request.put("xiaofeiList", xiaofeiList);
        return ActionSupport.SUCCESS;
    }
    
    public String xiaofeiDel()
    {
        TXiaofei xiaofei=xiaofeiDAO.findById(id);
        xiaofeiDAO.delete(xiaofei);
        this.setMessage("�����ɹ�");
        this.setPath("xiaofeiMana.action");
        return "succeed";
    }

    public String getBeizhu()
    {
        return beizhu;
    }

    public void setBeizhu(String beizhu)
    {
        this.beizhu = beizhu;
    }

    public String getChengyuan()
    {
        return chengyuan;
    }

    public void setChengyuan(String chengyuan)
    {
        this.chengyuan = chengyuan;
    }

    public TXiaofeiDAO getXiaofeiDAO()
    {
        return xiaofeiDAO;
    }

    public void setXiaofeiDAO(TXiaofeiDAO xiaofeiDAO)
    {
        this.xiaofeiDAO = xiaofeiDAO;
    }

    public Integer getId()
    {
        return id;
    }

    public void setId(Integer id)
    {
        this.id = id;
    }

    public Double getJine()
    {
        return jine;
    }

    public void setJine(Double jine)
    {
        this.jine = jine;
    }

    public String getLeixing()
    {
        return leixing;
    }

    public void setLeixing(String leixing)
    {
        this.leixing = leixing;
    }

    public String getMessage()
    {
        return message;
    }

    public void setMessage(String message)
    {
        this.message = message;
    }

    public String getPath()
    {
        return path;
    }

    public void setPath(String path)
    {
        this.path = path;
    }


    public String getShijian()
    {
        return shijian;
    }

    public void setShijian(String shijian)
    {
        this.shijian = shijian;
    }


    public Integer getUserId()
    {
        return userId;
    }

    public void setUserId(Integer userId)
    {
        this.userId = userId;
    }
    
}

com.dao包:

package com.dao;

import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.model.TAdmin;

/**
 * Data access object (DAO) for domain model class TAdmin.
 * 
 * @see com.model.TAdmin
 * @author MyEclipse Persistence Tools
 */

public class TAdminDAO extends HibernateDaoSupport {
    private static final Log log = LogFactory.getLog(TAdminDAO.class);

    // property constants
    public static final String USER_NAME = "userName";

    public static final String USER_PW = "userPw";

    protected void initDao() {
        // do nothing
    }

    public void save(TAdmin transientInstance) {
        log.debug("saving TAdmin instance");
        try {
            getHibernateTemplate().save(transientInstance);
            log.debug("save successful");
        } catch (RuntimeException re) {
            log.error("save failed", re);
            throw re;
        }
    }

    public void delete(TAdmin persistentInstance) {
        log.debug("deleting TAdmin instance");
        try {
            getHibernateTemplate().delete(persistentInstance);
            log.debug("delete successful");
        } catch (RuntimeException re) {
            log.error("delete failed", re);
            throw re;
        }
    }

    public TAdmin findById(java.lang.Integer id) {
        log.debug("getting TAdmin instance with id: " + id);
        try {
            TAdmin instance = (TAdmin) getHibernateTemplate().get(
                    "com.model.TAdmin", id);
            return instance;
        } catch (RuntimeException re) {
            log.error("get failed", re);
            throw re;
        }
    }

    public List findByExample(TAdmin instance) {
        log.debug("finding TAdmin instance by example");
        try {
            List results = getHibernateTemplate().findByExample(instance);
            log.debug("find by example successful, result size: "
                    + results.size());
            return results;
        } catch (RuntimeException re) {
            log.error("find by example failed", re);
            throw re;
        }
    }

    public List findByProperty(String propertyName, Object value) {
        log.debug("finding TAdmin instance with property: " + propertyName
                + ", value: " + value);
        try {
            String queryString = "from TAdmin as model where model."
                    + propertyName + "= ?";
            return getHibernateTemplate().find(queryString, value);
        } catch (RuntimeException re) {
            log.error("find by property name failed", re);
            throw re;
        }
    }

    public List findByUserName(Object userName) {
        return findByProperty(USER_NAME, userName);
    }

    public List findByUserPw(Object userPw) {
        return findByProperty(USER_PW, userPw);
    }

    public List findAll() {
        log.debug("finding all TAdmin instances");
        try {
            String queryString = "from TAdmin";
            return getHibernateTemplate().find(queryString);
        } catch (RuntimeException re) {
            log.error("find all failed", re);
            throw re;
        }
    }

    public TAdmin merge(TAdmin detachedInstance) {
        log.debug("merging TAdmin instance");
        try {
            TAdmin result = (TAdmin) getHibernateTemplate().merge(
                    detachedInstance);
            log.debug("merge successful");
            return result;
        } catch (RuntimeException re) {
            log.error("merge failed", re);
            throw re;
        }
    }

    public void attachDirty(TAdmin instance) {
        log.debug("attaching dirty TAdmin instance");
        try {
            getHibernateTemplate().saveOrUpdate(instance);
            log.debug("attach successful");
        } catch (RuntimeException re) {
            log.error("attach failed", re);
            throw re;
        }
    }

    public void attachClean(TAdmin instance) {
        log.debug("attaching clean TAdmin instance");
        try {
            getHibernateTemplate().lock(instance, LockMode.NONE);
            log.debug("attach successful");
        } catch (RuntimeException re) {
            log.error("attach failed", re);
            throw re;
        }
    }

    public static TAdminDAO getFromApplicationContext(ApplicationContext ctx) {
        return (TAdminDAO) ctx.getBean("TAdminDAO");
    }
}
package com.dao;

import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.model.TRizhi;

/**
 * Data access object (DAO) for domain model class TRizhi.
 * 
 * @see com.model.TRizhi
 * @author MyEclipse Persistence Tools
 */

public class TRizhiDAO extends HibernateDaoSupport
{
    private static final Log log = LogFactory.getLog(TRizhiDAO.class);

    protected void initDao()
    {
        // do nothing
    }

    public void save(TRizhi transientInstance)
    {
        log.debug("saving TRizhi instance");
        try
        {
            getHibernateTemplate().save(transientInstance);
            log.debug("save successful");
        } catch (RuntimeException re)
        {
            log.error("save failed", re);
            throw re;
        }
    }

    public void delete(TRizhi persistentInstance)
    {
        log.debug("deleting TRizhi instance");
        try
        {
            getHibernateTemplate().delete(persistentInstance);
            log.debug("delete successful");
        } catch (RuntimeException re)
        {
            log.error("delete failed", re);
            throw re;
        }
    }

    public TRizhi findById(java.lang.Integer id)
    {
        log.debug("getting TRizhi instance with id: " + id);
        try
        {
            TRizhi instance = (TRizhi) getHibernateTemplate().get(
                    "com.model.TRizhi", id);
            return instance;
        } catch (RuntimeException re)
        {
            log.error("get failed", re);
            throw re;
        }
    }

    public List findByExample(TRizhi instance)
    {
        log.debug("finding TRizhi instance by example");
        try
        {
            List results = getHibernateTemplate().findByExample(instance);
            log.debug("find by example successful, result size: "
                    + results.size());
            return results;
        } catch (RuntimeException re)
        {
            log.error("find by example failed", re);
            throw re;
        }
    }

    public List findByProperty(String propertyName, Object value)
    {
        log.debug("finding TRizhi instance with property: " + propertyName
                + ", value: " + value);
        try
        {
            String queryString = "from TRizhi as model where model."
                    + propertyName + "= ?";
            return getHibernateTemplate().find(queryString, value);
        } catch (RuntimeException re)
        {
            log.error("find by property name failed", re);
            throw re;
        }
    }

    public List findAll()
    {
        log.debug("finding all TRizhi instances");
        try
        {
            String queryString = "from TRizhi";
            return getHibernateTemplate().find(queryString);
        } catch (RuntimeException re)
        {
            log.error("find all failed", re);
            throw re;
        }
    }

    public TRizhi merge(TRizhi detachedInstance)
    {
        log.debug("merging TRizhi instance");
        try
        {
            TRizhi result = (TRizhi) getHibernateTemplate().merge(
                    detachedInstance);
            log.debug("merge successful");
            return result;
        } catch (RuntimeException re)
        {
            log.error("merge failed", re);
            throw re;
        }
    }

    public void attachDirty(TRizhi instance)
    {
        log.debug("attaching dirty TRizhi instance");
        try
        {
            getHibernateTemplate().saveOrUpdate(instance);
            log.debug("attach successful");
        } catch (RuntimeException re)
        {
            log.error("attach failed", re);
            throw re;
        }
    }

    public void attachClean(TRizhi instance)
    {
        log.debug("attaching clean TRizhi instance");
        try
        {
            getHibernateTemplate().lock(instance, LockMode.NONE);
            log.debug("attach successful");
        } catch (RuntimeException re)
        {
            log.error("attach failed", re);
            throw re;
        }
    }

    public static TRizhiDAO getFromApplicationContext(ApplicationContext ctx)
    {
        return (TRizhiDAO) ctx.getBean("TRizhiDAO");
    }
}
package com.dao;

import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.model.TShouru;

/**
 * Data access object (DAO) for domain model class TShouru.
 * 
 * @see com.model.TShouru
 * @author MyEclipse Persistence Tools
 */

public class TShouruDAO extends HibernateDaoSupport
{
    private static final Log log = LogFactory.getLog(TShouruDAO.class);

    protected void initDao()
    {
        // do nothing
    }

    public void save(TShouru transientInstance)
    {
        log.debug("saving TShouru instance");
        try
        {
            getHibernateTemplate().save(transientInstance);
            log.debug("save successful");
        } catch (RuntimeException re)
        {
            log.error("save failed", re);
            throw re;
        }
    }

    public void delete(TShouru persistentInstance)
    {
        log.debug("deleting TShouru instance");
        try
        {
            getHibernateTemplate().delete(persistentInstance);
            log.debug("delete successful");
        } catch (RuntimeException re)
        {
            log.error("delete failed", re);
            throw re;
        }
    }

    public TShouru findById(java.lang.Integer id)
    {
        log.debug("getting TShouru instance with id: " + id);
        try
        {
            TShouru instance = (TShouru) getHibernateTemplate().get(
                    "com.model.TShouru", id);
            return instance;
        } catch (RuntimeException re)
        {
            log.error("get failed", re);
            throw re;
        }
    }

    public List findByExample(TShouru instance)
    {
        log.debug("finding TShouru instance by example");
        try
        {
            List results = getHibernateTemplate().findByExample(instance);
            log.debug("find by example successful, result size: "
                    + results.size());
            return results;
        } catch (RuntimeException re)
        {
            log.error("find by example failed", re);
            throw re;
        }
    }

    public List findByProperty(String propertyName, Object value)
    {
        log.debug("finding TShouru instance with property: " + propertyName
                + ", value: " + value);
        try
        {
            String queryString = "from TShouru as model where model."
                    + propertyName + "= ?";
            return getHibernateTemplate().find(queryString, value);
        } catch (RuntimeException re)
        {
            log.error("find by property name failed", re);
            throw re;
        }
    }

    public List findAll()
    {
        log.debug("finding all TShouru instances");
        try
        {
            String queryString = "from TShouru";
            return getHibernateTemplate().find(queryString);
        } catch (RuntimeException re)
        {
            log.error("find all failed", re);
            throw re;
        }
    }

    public TShouru merge(TShouru detachedInstance)
    {
        log.debug("merging TShouru instance");
        try
        {
            TShouru result = (TShouru) getHibernateTemplate().merge(
                    detachedInstance);
            log.debug("merge successful");
            return result;
        } catch (RuntimeException re)
        {
            log.error("merge failed", re);
            throw re;
        }
    }

    public void attachDirty(TShouru instance)
    {
        log.debug("attaching dirty TShouru instance");
        try
        {
            getHibernateTemplate().saveOrUpdate(instance);
            log.debug("attach successful");
        } catch (RuntimeException re)
        {
            log.error("attach failed", re);
            throw re;
        }
    }

    public void attachClean(TShouru instance)
    {
        log.debug("attaching clean TShouru instance");
        try
        {
            getHibernateTemplate().lock(instance, LockMode.NONE);
            log.debug("attach successful");
        } catch (RuntimeException re)
        {
            log.error("attach failed", re);
            throw re;
        }
    }

    public static TShouruDAO getFromApplicationContext(ApplicationContext ctx)
    {
        return (TShouruDAO) ctx.getBean("TShouruDAO");
    }
}
package com.dao;

import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.model.TTouzi;

/**
 * Data access object (DAO) for domain model class TTouzi.
 * 
 * @see com.model.TTouzi
 * @author MyEclipse Persistence Tools
 */

public class TTouziDAO extends HibernateDaoSupport
{
    private static final Log log = LogFactory.getLog(TTouziDAO.class);

    protected void initDao()
    {
        // do nothing
    }

    public void save(TTouzi transientInstance)
    {
        log.debug("saving TTouzi instance");
        try
        {
            getHibernateTemplate().save(transientInstance);
            log.debug("save successful");
        } catch (RuntimeException re)
        {
            log.error("save failed", re);
            throw re;
        }
    }

    public void delete(TTouzi persistentInstance)
    {
        log.debug("deleting TTouzi instance");
        try
        {
            getHibernateTemplate().delete(persistentInstance);
            log.debug("delete successful");
        } catch (RuntimeException re)
        {
            log.error("delete failed", re);
            throw re;
        }
    }

    public TTouzi findById(java.lang.Integer id)
    {
        log.debug("getting TTouzi instance with id: " + id);
        try
        {
            TTouzi instance = (TTouzi) getHibernateTemplate().get(
                    "com.model.TTouzi", id);
            return instance;
        } catch (RuntimeException re)
        {
            log.error("get failed", re);
            throw re;
        }
    }

    public List findByExample(TTouzi instance)
    {
        log.debug("finding TTouzi instance by example");
        try
        {
            List results = getHibernateTemplate().findByExample(instance);
            log.debug("find by example successful, result size: "
                    + results.size());
            return results;
        } catch (RuntimeException re)
        {
            log.error("find by example failed", re);
            throw re;
        }
    }

    public List findByProperty(String propertyName, Object value)
    {
        log.debug("finding TTouzi instance with property: " + propertyName
                + ", value: " + value);
        try
        {
            String queryString = "from TTouzi as model where model."
                    + propertyName + "= ?";
            return getHibernateTemplate().find(queryString, value);
        } catch (RuntimeException re)
        {
            log.error("find by property name failed", re);
            throw re;
        }
    }

    public List findAll()
    {
        log.debug("finding all TTouzi instances");
        try
        {
            String queryString = "from TTouzi";
            return getHibernateTemplate().find(queryString);
        } catch (RuntimeException re)
        {
            log.error("find all failed", re);
            throw re;
        }
    }

    public TTouzi merge(TTouzi detachedInstance)
    {
        log.debug("merging TTouzi instance");
        try
        {
            TTouzi result = (TTouzi) getHibernateTemplate().merge(
                    detachedInstance);
            log.debug("merge successful");
            return result;
        } catch (RuntimeException re)
        {
            log.error("merge failed", re);
            throw re;
        }
    }

    public void attachDirty(TTouzi instance)
    {
        log.debug("attaching dirty TTouzi instance");
        try
        {
            getHibernateTemplate().saveOrUpdate(instance);
            log.debug("attach successful");
        } catch (RuntimeException re)
        {
            log.error("attach failed", re);
            throw re;
        }
    }

    public void attachClean(TTouzi instance)
    {
        log.debug("attaching clean TTouzi instance");
        try
        {
            getHibernateTemplate().lock(instance, LockMode.NONE);
            log.debug("attach successful");
        } catch (RuntimeException re)
        {
            log.error("attach failed", re);
            throw re;
        }
    }

    public static TTouziDAO getFromApplicationContext(ApplicationContext ctx)
    {
        return (TTouziDAO) ctx.getBean("TTouziDAO");
    }
}
package com.dao;

import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.model.TUser;

/**
 * Data access object (DAO) for domain model class TUser.
 * 
 * @see com.model.TUser
 * @author MyEclipse Persistence Tools
 */

public class TUserDAO extends HibernateDaoSupport
{
    private static final Log log = LogFactory.getLog(TUserDAO.class);

    protected void initDao()
    {
        // do nothing
    }

    public void save(TUser transientInstance)
    {
        log.debug("saving TUser instance");
        try
        {
            getHibernateTemplate().save(transientInstance);
            log.debug("save successful");
        } catch (RuntimeException re)
        {
            log.error("save failed", re);
            throw re;
        }
    }

    public void delete(TUser persistentInstance)
    {
        log.debug("deleting TUser instance");
        try
        {
            getHibernateTemplate().delete(persistentInstance);
            log.debug("delete successful");
        } catch (RuntimeException re)
        {
            log.error("delete failed", re);
            throw re;
        }
    }

    public TUser findById(java.lang.Integer id)
    {
        log.debug("getting TUser instance with id: " + id);
        try
        {
            TUser instance = (TUser) getHibernateTemplate().get(
                    "com.model.TUser", id);
            return instance;
        } catch (RuntimeException re)
        {
            log.error("get failed", re);
            throw re;
        }
    }

    public List findByExample(TUser instance)
    {
        log.debug("finding TUser instance by example");
        try
        {
            List results = getHibernateTemplate().findByExample(instance);
            log.debug("find by example successful, result size: "
                    + results.size());
            return results;
        } catch (RuntimeException re)
        {
            log.error("find by example failed", re);
            throw re;
        }
    }

    public List findByProperty(String propertyName, Object value)
    {
        log.debug("finding TUser instance with property: " + propertyName
                + ", value: " + value);
        try
        {
            String queryString = "from TUser as model where model."
                    + propertyName + "= ?";
            return getHibernateTemplate().find(queryString, value);
        } catch (RuntimeException re)
        {
            log.error("find by property name failed", re);
            throw re;
        }
    }

    public List findAll()
    {
        log.debug("finding all TUser instances");
        try
        {
            String queryString = "from TUser where userDel='no'";
            return getHibernateTemplate().find(queryString);
        } catch (RuntimeException re)
        {
            log.error("find all failed", re);
            throw re;
        }
    }
    
    
    

    public TUser merge(TUser detachedInstance)
    {
        log.debug("merging TUser instance");
        try
        {
            TUser result = (TUser) getHibernateTemplate().merge(
                    detachedInstance);
            log.debug("merge successful");
            return result;
        } catch (RuntimeException re)
        {
            log.error("merge failed", re);
            throw re;
        }
    }

    public void attachDirty(TUser instance)
    {
        log.debug("attaching dirty TUser instance");
        try
        {
            getHibernateTemplate().saveOrUpdate(instance);
            log.debug("attach successful");
        } catch (RuntimeException re)
        {
            log.error("attach failed", re);
            throw re;
        }
    }

    public void attachClean(TUser instance)
    {
        log.debug("attaching clean TUser instance");
        try
        {
            getHibernateTemplate().lock(instance, LockMode.NONE);
            log.debug("attach successful");
        } catch (RuntimeException re)
        {
            log.error("attach failed", re);
            throw re;
        }
    }

    public static TUserDAO getFromApplicationContext(ApplicationContext ctx)
    {
        return (TUserDAO) ctx.getBean("TUserDAO");
    }
}
package com.dao;

import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.model.TXiaofei;

/**
 * Data access object (DAO) for domain model class TXiaofei.
 * 
 * @see com.model.TXiaofei
 * @author MyEclipse Persistence Tools
 */

public class TXiaofeiDAO extends HibernateDaoSupport
{
    private static final Log log = LogFactory.getLog(TXiaofeiDAO.class);

    protected void initDao()
    {
        // do nothing
    }

    public void save(TXiaofei transientInstance)
    {
        log.debug("saving TXiaofei instance");
        try
        {
            getHibernateTemplate().save(transientInstance);
            log.debug("save successful");
        } catch (RuntimeException re)
        {
            log.error("save failed", re);
            throw re;
        }
    }

    public void delete(TXiaofei persistentInstance)
    {
        log.debug("deleting TXiaofei instance");
        try
        {
            getHibernateTemplate().delete(persistentInstance);
            log.debug("delete successful");
        } catch (RuntimeException re)
        {
            log.error("delete failed", re);
            throw re;
        }
    }

    public TXiaofei findById(java.lang.Integer id)
    {
        log.debug("getting TXiaofei instance with id: " + id);
        try
        {
            TXiaofei instance = (TXiaofei) getHibernateTemplate().get(
                    "com.model.TXiaofei", id);
            return instance;
        } catch (RuntimeException re)
        {
            log.error("get failed", re);
            throw re;
        }
    }

    public List findByExample(TXiaofei instance)
    {
        log.debug("finding TXiaofei instance by example");
        try
        {
            List results = getHibernateTemplate().findByExample(instance);
            log.debug("find by example successful, result size: "
                    + results.size());
            return results;
        } catch (RuntimeException re)
        {
            log.error("find by example failed", re);
            throw re;
        }
    }

    public List findByProperty(String propertyName, Object value)
    {
        log.debug("finding TXiaofei instance with property: " + propertyName
                + ", value: " + value);
        try
        {
            String queryString = "from TXiaofei as model where model."
                    + propertyName + "= ?";
            return getHibernateTemplate().find(queryString, value);
        } catch (RuntimeException re)
        {
            log.error("find by property name failed", re);
            throw re;
        }
    }

    public List findAll()
    {
        log.debug("finding all TXiaofei instances");
        try
        {
            String queryString = "from TXiaofei";
            return getHibernateTemplate().find(queryString);
        } catch (RuntimeException re)
        {
            log.error("find all failed", re);
            throw re;
        }
    }

    public TXiaofei merge(TXiaofei detachedInstance)
    {
        log.debug("merging TXiaofei instance");
        try
        {
            TXiaofei result = (TXiaofei) getHibernateTemplate().merge(
                    detachedInstance);
            log.debug("merge successful");
            return result;
        } catch (RuntimeException re)
        {
            log.error("merge failed", re);
            throw re;
        }
    }

    public void attachDirty(TXiaofei instance)
    {
        log.debug("attaching dirty TXiaofei instance");
        try
        {
            getHibernateTemplate().saveOrUpdate(instance);
            log.debug("attach successful");
        } catch (RuntimeException re)
        {
            log.error("attach failed", re);
            throw re;
        }
    }

    public void attachClean(TXiaofei instance)
    {
        log.debug("attaching clean TXiaofei instance");
        try
        {
            getHibernateTemplate().lock(instance, LockMode.NONE);
            log.debug("attach successful");
        } catch (RuntimeException re)
        {
            log.error("attach failed", re);
            throw re;
        }
    }

    public static TXiaofeiDAO getFromApplicationContext(ApplicationContext ctx)
    {
        return (TXiaofeiDAO) ctx.getBean("TXiaofeiDAO");
    }
}

com.model包

com.service包:

package com.service;

import java.util.List;

import javax.servlet.http.HttpSession;

import org.directwebremoting.WebContext;
import org.directwebremoting.WebContextFactory;

import com.dao.TAdminDAO;
import com.dao.TUserDAO;
import com.model.TAdmin;
import com.model.TUser;

public class loginService
{
    private TUserDAO userDAO;
    private TAdminDAO adminDAO;
    public TUserDAO getUserDAO()
    {
        return userDAO;
    }
    public void setUserDAO(TUserDAO userDAO)
    {
        this.userDAO = userDAO;
    }


    public TAdminDAO getAdminDAO()
    {
        return adminDAO;
    }
    public void setAdminDAO(TAdminDAO adminDAO)
    {
        this.adminDAO = adminDAO;
    }
    public String login(String userName,String userPw,int userType)
    {
        System.out.println("userType"+userType);
        try
        {
            Thread.sleep(700);
        } catch (InterruptedException e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        
        String result="no";
        
        if(userType==0)//ϵͳ����Ա��½
        {
            String sql="from TAdmin where userName=? and userPw=?";
            Object[] con={userName,userPw};
            List adminList=adminDAO.getHibernateTemplate().find(sql,con);
            if(adminList.size()==0)
            {
                 result="no";
            }
            else
            {
                 WebContext ctx = WebContextFactory.get(); 
                 HttpSession session=ctx.getSession(); 
                 TAdmin admin=(TAdmin)adminList.get(0);
                 session.setAttribute("userType", 0);
                 session.setAttribute("admin", admin);
                 result="yes";
            }
        }
        if(userType==1)//
        {
            String sql="from TUser where userName=? and userPw=?";
            Object[] con={userName.trim(),userPw};
            List userList=userDAO.getHibernateTemplate().find(sql,con);
            if(userList.size()==0)
            {
                 result="no";
            }
            else
            {
                 WebContext ctx = WebContextFactory.get(); 
                 HttpSession session=ctx.getSession(); 
                 TUser user=(TUser)userList.get(0);
                 session.setAttribute("userType", 1);
                 session.setAttribute("user", user);
                 result="yes";
            }
        }
        if(userType==2)//
        {
            
        }
        return result;
    }
    
    
    public String adminPwEdit(String userPwNew)
    {
        System.out.println("DDDD");
        try 
        {
            Thread.sleep(700);
        } 
        catch (InterruptedException e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        WebContext ctx = WebContextFactory.get(); 
        HttpSession session=ctx.getSession(); 
         
        TAdmin admin=(TAdmin)session.getAttribute("admin");
        admin.setUserPw(userPwNew);
        
        adminDAO.getHibernateTemplate().update(admin);
        session.setAttribute("admin", admin);
        
        return "yes";
    }
    
    
    public String userPwEdit(String userPwNew)
    {
        System.out.println("DDDD");
        try 
        {
            Thread.sleep(700);
        } 
        catch (InterruptedException e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        WebContext ctx = WebContextFactory.get(); 
        HttpSession session=ctx.getSession(); 
         
        TUser user=(TUser)session.getAttribute("user");
        user.setUserPw(userPwNew);
        
        userDAO.getHibernateTemplate().update(user);
        session.setAttribute("user", user);
        
        return "yes";
    }

}

com.util包:

package com.util;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Date;
import java.util.Map;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionSupport;

public class upload extends ActionSupport
{
    private static final int BUFFER_SIZE = 16 * 1024;
    private File fujian;
    private String fujianFileName;
    private String fujianContentType;
    
    
    public String upload()
    {
        String newFujianName=new Date().getTime()+fujianFileName.substring(fujianFileName.indexOf("."));
        String dstPath = ServletActionContext.getServletContext().getRealPath("upload")+ "\\" + newFujianName;
        File dstFile = new File(dstPath);
        copy(this.getFujian(),dstFile);
        Map request=(Map)ServletActionContext.getContext().get("request");
        request.put("newFujianName", newFujianName);
        request.put("oldFujianName", fujianFileName);
        request.put("fujianPath", "/upload"+ "/" + newFujianName);
        return ActionSupport.SUCCESS;
    }
    
    
    private static void copy(File src, File dst) 
    {
        InputStream in = null;
        OutputStream out = null;
        try 
        {
            in = new BufferedInputStream(new FileInputStream(src), BUFFER_SIZE);
            out = new BufferedOutputStream(new FileOutputStream(dst),BUFFER_SIZE);
            byte[] buffer = new byte[BUFFER_SIZE];
            int len = 0;
            while ((len = in.read(buffer)) > 0) 
            {
                out.write(buffer, 0, len);
            }
        } 
        catch (Exception e)
        {
            e.printStackTrace();
        } 
        finally
        {
            if (null != in) 
            {
                try 
                {
                    in.close();
                } 
                catch (IOException e) 
                {
                    e.printStackTrace();
                }
            }
            if (null != out) 
            {
                try 
                {
                    out.close();
                } 
                catch (IOException e) 
                {
                    e.printStackTrace();
                }
            }
        }
    }


    public File getFujian()
    {
        return fujian;
    }


    public void setFujian(File fujian)
    {
        this.fujian = fujian;
    }


    public String getFujianContentType()
    {
        return fujianContentType;
    }


    public void setFujianContentType(String fujianContentType)
    {
        this.fujianContentType = fujianContentType;
    }


    public String getFujianFileName()
    {
        return fujianFileName;
    }


    public void setFujianFileName(String fujianFileName)
    {
        this.fujianFileName = fujianFileName;
    }

}
package com.util;

import java.text.ParseException;
import java.util.Date;
import java.util.GregorianCalendar;

public class Util {
    public static Date newDate(String s) throws ParseException {
        java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(
                "yyyy-MM-dd");
        Date date = new Date();
        date = sdf.parse(s);
        return date;
    }

    public static Date newDate1(String s) throws ParseException {
        java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(
                "yyyy-MM-dd HH:mm");
        Date date = new Date();
        date = sdf.parse(s);
        return date;
    }

    public static Date FormatFullDate(String s) throws ParseException {
        java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(
                "yyyy-MM-dd HH:mm:ss");
        Date date = new Date();
        date = sdf.parse(s);
        return date;

    }

    public static String splitDate(Date d) {
        java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(
                "yyyy-MM-dd");
        return sdf.format(d);
    }

    public static String splitDate1(Date d) {
        java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(
                "yyyy��MM��dd��");
        return sdf.format(d);
    }

    /**
     * ���ַ����ض̣�ȡǰn���ַ���Ӣ�������ַ���
     * 
     * @param orignalString
     *            ԭ�ַ���
     * @param length
     *            ����
     * @param chopedString
     *            �������ֵı�ʾ�ַ���
     * @return ��ȡ���ַ���
     */
    public static String chop(String orignalString, double length,
            String chopedString) {
        if (orignalString == null || orignalString.length() == 0) {
            return orignalString;
        }
        orignalString = orignalString.replaceAll(" ", " ");
        if (orignalString.length() < length) {
            return orignalString;
        }
        StringBuffer buffer = new StringBuffer((int) length);
        length = length * 2;
        int count = 0;
        int stringLength = orignalString.length();
        int i = 0;
        for (; count < length && i < stringLength; i++) {
            char c = orignalString.charAt(i);
            if (c < '\u00ff') {
                count++;
            } else {
                count += 2;
            }
            buffer.append(c);
        }
        if (i < stringLength) {
            buffer.append(chopedString);
        }
        return buffer.toString();
    }

    public static long getPrimeKey() {
        GregorianCalendar calendar = new GregorianCalendar();
        return calendar.getTimeInMillis();
    }

    public static long stringToLong(String source) {
        return Long.parseLong(source);
    }
    /*
     * public static void main(String[] args){ for(int i=0;i<10;i++){
     * System.out.println(Util.getPrimeKey()); } }
     */
}

猜你喜欢

转载自www.cnblogs.com/lq13035130506/p/10423078.html