SSM整合开发的小Demo----毕业设计管理系统之学生模块

该模块的主要功能如下:

                     

先看看结果怎样,一睹为快















示例程序(学生选课)代码:

#数据模型层

package com.east.entity;

import java.io.Serializable;

public class Subject implements Serializable {
  private Integer subject_id;               //课题ID
  private String  subject_title;            //课题名称
  private String  subject_condition;        //课题要求
  private String  tea_name;                 //导师名称
  private String  degree;                   //导师职称
  private String  stu_name;                 //选课学生
  private String  status;                   //论文状态
  private String  audit;                    //编辑状态
  private String  AuditSituation;           //审核情况
public Integer getSubject_id() {
	return subject_id;
}
public void setSubject_id(Integer subject_id) {
	this.subject_id = subject_id;
}
public String getSubject_title() {
	return subject_title;
}
public void setSubject_title(String subject_title) {
	this.subject_title = subject_title;
}

public String getSubject_condition() {
	return subject_condition;
}
public void setSubject_condition(String subject_condition) {
	this.subject_condition = subject_condition;
}
public String getTea_name() {
	return tea_name;
}
public void setTea_name(String tea_name) {
	this.tea_name = tea_name;
}
public String getDegree() {
	return degree;
}
public void setDegree(String degree) {
	this.degree = degree;
}
public String getStu_name() {
	return stu_name;
}
public void setStu_name(String stu_name) {
	this.stu_name = stu_name;
}
public String getStatus() {
	return status;
}
public void setStatus(String status) {
	this.status = status;
}
public String getAudit() {
	return audit;
}
public void setAudit(String audit) {
	this.audit = audit;
}

public String getAuditSituation() {
	return AuditSituation;
}
public void setAuditSituation(String auditSituation) {
	AuditSituation = auditSituation;
}
@Override
public String toString() {
	return "Subject [subject_id=" + subject_id + ", subject_title=" + subject_title + ", subject_condition="
			+ subject_condition + ", tea_name=" + tea_name + ", degree=" + degree + ", stu_name=" + stu_name
			+ ", status=" + status + ", audit=" + audit + ", AuditSituation=" + AuditSituation + "]";
}
  
}

#数据访问层

package com.east.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.east.entity.Subject;

public interface SubjectDao {
   /*
    * 查询所有课题
    */
	@Select("select * from subject where status = #{status}")
	List<Subject> findByStatus(Subject subject);
	
	/*
	 * 查询某个学生的课题
	 */
	@Select("select * from subject where stu_name = #{stu_name}")
	Subject findByStuName(String stu_name);
	
	/*
	 * 学生选题
	 */
	@Update("update subject set stu_name =#{stu_name} ,status=#{status} where subject_id = #{subject_id}")
	void UpdateSub(Subject subject);
	
	/*
	 * 教师出题
	 */
	@Insert("insert into subject(subject_title,subject_condition,tea_name,degree) "
			+ " values(#{subject_title},#{subject_condition},#{tea_name},#{degree})")
	@Options(useGeneratedKeys = true,keyProperty="subject_id")
    void AddSubjet(Subject subject);
	
	/*
	 * 查询某个老师出的题
	 */
	@Select("select * from subject where tea_name = #{tea_name}")
	Subject findByTeaName(String tea_name);
	
	/*
	 * 删除某个教师的课题
	 */
	@Delete("delete from subject where tea_name = #{tea_name}")
	void DeleteSub(Subject subject);
	
	/*
	 * 获取所有课题
	 */
	@Select("select * from subject")
	List<Subject> findAll();
}

#业务逻辑层

package com.east.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.east.dao.SubjectDao;
import com.east.entity.Subject;

@Transactional(propagation=Propagation.REQUIRED,isolation=Isolation.DEFAULT)
@Service("subjectBiz")
public class SubjectBiz {
    /*
     * 自动注入SubjectBiz
     */
	@Autowired
	private SubjectDao subjectDao;
	
	/*
	 * 查询所有课题
	 */
	public List<Subject> findByStatus(Subject subject){
		return subjectDao.findByStatus(subject);
	}
	
	/*
	 * 查询某个学生的课题
	 */
	public Subject findByStuName(String stu_name){
		return subjectDao.findByStuName(stu_name);
	}
	
	/*
	 * 学生选题
	 */
	public void UpdateSub(Subject subject){
		subjectDao.UpdateSub(subject);
	}
	
	/*
	 * 教师出题
	 */
	public void AddSubjet(Subject subject){
		subjectDao.AddSubjet(subject);
	}
	
	/*
	 * 查询某个老师出的题
	 */
	public Subject findByTeaName(String tea_name){
		return subjectDao.findByTeaName(tea_name);
	}
	
	/*
	 * 删除某个教师的课题
	 */
	public void DeleteSub(Subject subject){
		subjectDao.DeleteSub(subject);
	}
	
	/*
	 * 获取所有课题
	 */
	public List<Subject> findAll(){
		return subjectDao.findAll();
	}
}

#控制层

package com.east.action;

import java.io.IOException;
import java.util.List;

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

import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.servlet.ServletUtilities;
import org.jfree.data.general.DefaultPieDataset;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.east.entity.Student;
import com.east.entity.Subject;
import com.east.entity.Teacher;
import com.east.service.SubjectBiz;
//import com.east.util.JFreeUtil;
import com.east.util.JFreeUtil;

/*
 * 处理用户请求的控制器
 */
@Controller
public class SubjectAction {
    //自动注入UserService
	@Autowired
	@Qualifier("subjectBiz")
	private SubjectBiz subjectBiz;
	
	/*
	 * 学生选题
	 */
	@RequestMapping(value="/SelectSub")
	public ModelAndView SelectSub(String id,ModelAndView mv,HttpSession session){
		int subject_id = Integer.parseInt(id);
		Student stu = (Student) session.getAttribute("user");
		String stu_name = stu.getStu_name();
		String status = "已选";
		
		Subject sub = new Subject();
		sub.setSubject_id(subject_id);
		sub.setStu_name(stu_name);
		sub.setStatus(status);
		subjectBiz.UpdateSub(sub);
		
		mv.setViewName("/student/MySubject");
		return mv;     
	}
	
	/*
	 * 学生退选课题
	 */
	@RequestMapping(value="/Chosen")
	public ModelAndView Chosen(String id,ModelAndView mv,HttpSession session){
		int subject_id = Integer.parseInt(id);
		String stu_name = "无";
		String status = "未选";
		
		Subject sub = new Subject();
		sub.setSubject_id(subject_id);
		sub.setStu_name(stu_name);
		sub.setStatus(status);
		subjectBiz.UpdateSub(sub);
		
		mv.setViewName("/student/MySubject");
		return mv;     
	}
	
}

#视图层

<%@page import="java.util.List"%>
<%@page import="com.east.entity.Student"%>
<%@page import="com.east.entity.Subject"%>
<%@page import="com.east.service.SubjectBiz"%>
<%@page import="org.springframework.context.support.ClassPathXmlApplicationContext"%>
<%@page import="org.springframework.context.ApplicationContext"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>我的课题</title>
<link rel="stylesheet" href="../bootstrap-3.3.7/css/bootstrap.min.css"> 
<link rel="stylesheet" href="bootstrap-3.3.7/css/bootstrap.min.css">  
<script src="../js/jquery-3.2.1.min.js"></script>   
<script src="js/jquery-3.2.1.min.js"></script>  
<script src="../js/bootstrap.min.js"></script> 
<script src="js/bootstrap.min.js"></script> 
<script type="text/javascript">
function checkbox()
{
    var check=$("input[name='data']:checked");//选中的复选框  
    var length = check.length;                //获取勾选的个数 
    if(length>1){
    	alert("操作有误,你只能选一个课题!");
    }else{
      check.each(function(){  
         var row=$(this).parent("td").parent("tr");  
         var subject_id=row.find("[name='subject_id']").html();
         alert("选题成功! ");
         window.location.href="${pageContext.request.contextPath}/SelectSub?id="+subject_id;
      });  
    }
  $('#myModal').modal('hide');
}
</script>
</head>
<body>
<div class="container-fluid row form-group">
  <div class="panel panel-success"> 
     <div class="panel-heading">
        <div>
          <strong>我的课题</strong>
        </div>
     </div>
     <%
	    ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
        SubjectBiz subjectBiz = (SubjectBiz) ctx.getBean("subjectBiz");
	    Subject sub = new Subject();
        Student student = (Student) session.getAttribute("user");
        String stu_name = student.getStu_name();
	    sub.setStu_name(stu_name);
	    Subject subject = subjectBiz.findByStuName(stu_name);
     %>
     <div class="panel-body">
      <table class="table table-hover" border="1">
      <%
         if(subject !=null){
      %>
        <tr style="height: 40px;" class="success">
            <td>
               <label style="width: 100px;text-align: right;padding-right: 15px;">课题标题:</label>
               <label><%=subject.getSubject_title()%></label>
            </td>
        </tr>
        <tr style="height: 40px;">
            <td>
               <label style="width: 100px;text-align: right;padding-right: 15px;">指导老师:</label>
               <label><%=subject.getTea_name() %></label>
            </td>
        </tr>
        <tr style="height: 40px;">
            <td>
               <label style="width: 100px;text-align: right;padding-right: 15px;">导师职称:</label>
               <label><%=subject.getDegree() %></label>
            </td>
        </tr>
        <tr style="height: 40px;">
            <td>
               <label style="width: 100px;text-align: right;padding-right: 15px;">编辑状态:</label>
               <label><%=subject.getAudit() %></label>
            </td>
        </tr>
        <tr style="height: 40px;">
            <td>
               <label style="width: 100px;text-align: right;padding-right: 15px;">我要操作:</label>
               <label><a href="${pageContext.request.contextPath }/Chosen?id=<%=subject.getSubject_id()%>">退选课题</a></label>
            </td>
        </tr>
        <%
            }else{
        %>
        <tr>
           <td>
              <label><b style="font-size: 18px;">你还没有选题!</b></label>
                 <a href="#" class="btn btn-primary btn-sm" style="float: right;" data-toggle="modal" data-target="#myModal">
                   <span class="glyphicon glyphicon-plus" ></span> 我要选题
                 </a>
           </td>
        </tr>
        <%
            }
        %>
     </table>
    </div>
  </div>
</div>

<!-- 模态框(Modal) -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header" style="text-align: center;">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
					×
				</button>
			  <div class="container-fluid row form-group">
				<ul class="nav nav-pills nav-stacked">
                   <li class="active"><a href="#" style="text-align: left;" class="glyphicon glyphicon-edit" >我要选题</a></li>
                </ul>
              </div>
			</div>
	<div class="modal-body">
	  <table class="table table-hover" border="1">
	    <tr>
		  <td>序号</td>
		  <td>课题题目</td>
		  <td>指导教师</td>
		  <td>导师职称</td>
		  <td>操作</td>
	    </tr>
        <%
     
	        Subject subjects = new Subject();
	        subjects.setStatus("未选");
	        List<Subject> list = subjectBiz.findByStatus(subjects);
	        for(Subject subs :list){
         %>
		<tr>
	       <td name="subject_id"><%=subs.getSubject_id() %></td>
		   <td><%=subs.getSubject_title() %></td>
		   <td><%=subs.getTea_name() %></td>
		   <td><%=subs.getDegree() %></td>
		   <td><input name="data" type="checkbox" /></td>
		</tr>
		<%
            }
		%>
	  </table>
	</div>
    <div class="modal-footer">
	   <button type="button" class="btn btn-primary" οnclick="checkbox()">
	     <span class="glyphicon glyphicon-open"></span>确定
	   </button>
	   <button type="button" class="btn btn-default" data-dismiss="modal">关闭
	   </button>
    </div>
  </div><!-- /.modal-content -->
 </div><!-- /.modal -->
</body>
</html>


  • 11
    点赞
  • 36
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 36
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 36
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

潇潇雨歇_

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值