基于Spring+SpringMvc+Hibernate的JSP+MYSQL学生就业管理 课设

基于Spring+SpringMvc+Hibernate的JSP+MYSQL学生就业管理系统课设

1.包含源程序,数据库脚本。代码和数据库脚本都有详细注释。
2.课题设计仅供参考学习使用,可以在此基础上进行扩展完善

代码已经上传github, https://github.com/21503882/student-job
开发环境:
Eclipse ,MYSQL,JDK1.7,Tomcat 7
涉及技术点:
MVC模式、springMvc、Hibernate、Spring、HTML、JavaScript、CSS、JQUERY、poi、jpa、Ajax等
系统采用Hibernate框架实现ORM对象关系映射,前台JSP实现,后台springMvc映射,使用Spring框架进行整合。适合学习J2EE的一段时间的熟手,代码思路清晰,注解详细,数据库用的是mysql5.1,服务器用的tomcat7,JDK版本1.7. 编程软件Eclispe J2EE版本。是典型MVC架构,并且前后台分离;
主要功能:

package com.sy.mapper; 
import java.util.List; 
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
 
import com.cck.Reply;
import com.sy.map.ReplyResultMap;
import com.sy.sql.ReplySql;
 
/**
 *
 * @author cck
 */
public interface ReplyMapper extends ReplyResultMap {
 
    @InsertProvider(type = ReplySql.class, method = "save")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int save(Reply reply);
    
    @UpdateProvider(type = ReplySql.class, method = "updatePath")
    void updatePath(
            @Param("id")Integer id, 
            @Param("path")String path);
    
    @ResultMap("map")
    @SelectProvider(type = ReplySql.class, method = "getByTopicId")
    List<Reply> getByTopicId(Integer topicId);
    
    @ResultMap("map")
    @SelectProvider(type = ReplySql.class, method = "getByPath")
    List<Reply> getByPath(String path);
    
    @SelectProvider(type = ReplySql.class, method = "getPath")
    String getPath(Integer id);
    
}
 

package com.chengxusheji.dao;
 
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Service; 
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
 
import com.chengxusheji.domain.Admin;
import com.chengxusheji.domain.UserInfo;
 
@Service @Transactional
public class UserInfoDAO {
 
    @Resource SessionFactory factory;
    /*每页显示记录数目*/
    private final int PAGE_SIZE = 10;
 
    /*保存查询后总的页数*/
    private int totalPage;
    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }
    public int getTotalPage() {
        return totalPage;
    }
 
    /*保存查询到的总记录数*/
    private int recordNumber;
    public void setRecordNumber(int recordNumber) {
        this.recordNumber = recordNumber;
    }
    public int getRecordNumber() {
        return recordNumber;
    }
    
    private String errMessage; 
    
    public String getErrMessage() {
        return errMessage;
    }
    public void setErrMessage(String errMessage) {
        this.errMessage = errMessage;
    }
    /*验证用户登录*/
    @Transactional(propagation=Propagation.NOT_SUPPORTED)
    public boolean CheckLogin(String userName,String password) { 
        Session s = factory.getCurrentSession();  
        UserInfo db_userInfo = (UserInfo)s.get(UserInfo.class, userName);
        if(db_userInfo == null) { 
            this.errMessage = " 账号不存在 ";
            System.out.print(this.errMessage);
            return false;
        } else if( !db_userInfo.getPassword().equals(password)) {
            this.errMessage = " 密码不正确! ";
            System.out.print(this.errMessage);
            return false;
        }
        
        return true;
    }
    
    
    /*添加用户信息*/
    public void AddUserInfo(UserInfo userInfo) throws Exception {
        Session s = factory.getCurrentSession();
     s.save(userInfo);
    }
 
    @Transactional(propagation=Propagation.NOT_SUPPORTED)
    public ArrayList<UserInfo> QueryUserInfoInfo(String user_name,String realName,String birthday,String cardNumber,String city,int currentPage) { 
        Session s = factory.getCurrentSession();
        String hql = "From UserInfo userInfo where 1=1";
        if(!user_name.equals("")) hql = hql + " and userInfo.user_name like '%" + user_name + "%'";
        if(!realName.equals("")) hql = hql + " and userInfo.realName like '%" + realName + "%'";
        if(!birthday.equals("")) hql = hql + " and userInfo.birthday like '%" + birthday + "%'";
        if(!cardNumber.equals("")) hql = hql + " and userInfo.cardNumber like '%" + cardNumber + "%'";
        if(!city.equals("")) hql = hql + " and userInfo.city like '%" + city + "%'";
        Query q = s.createQuery(hql);
        /*计算当前显示页码的开始记录*/
        int startIndex = (currentPage-1) * this.PAGE_SIZE;
        q.setFirstResult(startIndex);
        q.setMaxResults(this.PAGE_SIZE);
        List userInfoList = q.list();
        return (ArrayList<UserInfo>) userInfoList;
    }
 
    @Transactional(propagation=Propagation.NOT_SUPPORTED)
    public ArrayList<UserInfo> QueryUserInfoInfo(String user_name,String realName,String birthday,String cardNumber,String city) { 
        Session s = factory.getCurrentSession();
        String hql = "From UserInfo userInfo where 1=1";
        if(!user_name.equals("")) hql = hql + " and userInfo.user_name like '%" + user_name + "%'";
        if(!realName.equals("")) hql = hql + " and userInfo.realName like '%" + realName + "%'";
        if(!birthday.equals("")) hql = hql + " and userInfo.birthday like '%" + birthday + "%'";
        if(!cardNumber.equals("")) hql = hql + " and userInfo.cardNumber like '%" + cardNumber + "%'";
        if(!city.equals("")) hql = hql + " and userInfo.city like '%" + city + "%'";
        Query q = s.createQuery(hql);
        List userInfoList = q.list();
        return (ArrayList<UserInfo>) userInfoList;
    }
 
    @Transactional(propagation=Propagation.NOT_SUPPORTED)
    public ArrayList<UserInfo> QueryAllUserInfoInfo() {
        Session s = factory.getCurrentSession(); 
        String hql = "From UserInfo";
        Query q = s.createQuery(hql);
        List userInfoList = q.list();
        return (ArrayList<UserInfo>) userInfoList;
    }
 
    /*计算总的页数和记录数*/
    @Transactional(propagation=Propagation.NOT_SUPPORTED)
    public void CalculateTotalPageAndRecordNumber(String user_name,String realName,String birthday,String cardNumber,String city) {
        Session s = factory.getCurrentSession();
        String hql = "From UserInfo userInfo where 1=1";
        if(!user_name.equals("")) hql = hql + " and userInfo.user_name like '%" + user_name + "%'";
        if(!realName.equals("")) hql = hql + " and userInfo.realName like '%" + realName + "%'";
        if(!birthday.equals("")) hql = hql + " and userInfo.birthday like '%" + birthday + "%'";
        if(!cardNumber.equals("")) hql = hql + " and userInfo.cardNumber like '%" + cardNumber + "%'";
        if(!city.equals("")) hql = hql + " and userInfo.city like '%" + city + "%'";
        Query q = s.createQuery(hql);
        List userInfoList = q.list();
        recordNumber = userInfoList.size();
        int mod = recordNumber % this.PAGE_SIZE;
        totalPage = recordNumber / this.PAGE_SIZE;
        if(mod != 0) totalPage++;
    }
 
    /*根据主键获取对象*/
    @Transactional(propagation=Propagation.NOT_SUPPORTED)
    public UserInfo GetUserInfoByUser_name(String user_name) {
        Session s = factory.getCurrentSession();
        UserInfo userInfo = (UserInfo)s.get(UserInfo.class, user_name);
        return userInfo;
    }
 
    /*更新UserInfo信息*/
    public void UpdateUserInfo(UserInfo userInfo) throws Exception {
        Session s = factory.getCurrentSession();
        s.update(userInfo);
    }
 
    /*删除UserInfo信息*/
    public void DeleteUserInfo (String user_name) throws Exception {
        Session s = factory.getCurrentSession();
        Object userInfo = s.load(UserInfo.class, user_name);
        s.delete(userInfo);
    }
 
}
 
 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值