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

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/linhaiyun_ytdx/article/details/78571250

该模块的主要功能如下:

                  

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


















示例程序(教师出题)代码:

#数据模型层

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);
	
	/*
	 * 教师出题
	 */
	@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="/Drawing")
	public ModelAndView Drawing(String subject_title,String subject_condition,ModelAndView mv,HttpSession session){
        Teacher tea = (Teacher) session.getAttribute("user");
		String tea_name = tea.getTea_name();
		String degree = tea.getDegree();
		
		Subject sub = new Subject();
		sub.setSubject_title(subject_title);
		sub.setSubject_condition(subject_condition);
		sub.setTea_name(tea_name);
		sub.setDegree(degree);
		
		subjectBiz.AddSubjet(sub);
        
		mv.setViewName("/teacher/Drawing");
		return mv;     
	}
	
	/*
	 * 删除某个教师的课题
	 */
	@RequestMapping(value="/DeleteSub")
	public ModelAndView DeleteSub(ModelAndView mv,HttpSession session){
        Teacher tea = (Teacher) session.getAttribute("user");
		String tea_name = tea.getTea_name();
		
		Subject sub = new Subject();
		sub.setTea_name(tea_name);
		subjectBiz.DeleteSub(sub);       //删除信息
        
		mv.setViewName("/teacher/MySubject");
		return mv;     
	}
	
}

#视图层

<%@page import="com.east.entity.Subject"%>
<%@page import="com.east.entity.Teacher"%>
<%@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 check(){
	var subject_title = document.getElementById("subject_title").value;
	var subject_condition = document.getElementById("subject_condition").value;
	if(subject_title==""){
		alert("请输入论文题目!");
		return false;
	}
	if(subject_condition==""){
		alert("请输入论文要求!");
		return false;
	}
 }
</script> 
</head>
<body>
<%
    ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
    SubjectBiz subjectBiz = (SubjectBiz) ctx.getBean("subjectBiz");
    Teacher tea = (Teacher) session.getAttribute("user");
    String tea_name = tea.getTea_name();
    Subject sub = subjectBiz.findByTeaName(tea_name);
%>
<%
    if(sub==null){
%>
<div class="container-fluid row form-group">
  <div class="panel panel-info"> 
     <div class="panel-heading">
          <strong>我要出题</strong>
     </div>
     <div class="panel-body">
     <form action="${pageContext.request.contextPath }/Drawing" method="post" οnsubmit="return check()">
      <table class="table table-hover" border="1">
        <tr style="height: 40px;" class="success">
            <td>
               <label style="width: 100px;text-align: right;padding-right: 15px;">论文题目:</label>
               <input type="text" name="subject_title" id="subject_title"  style="height: 32px;"/>
            </td>
        </tr>
        <tr style="height: 40px;">
            <td>
               <label style="width: 100px;text-align: right;padding-right: 15px;">论文要求:</label>
               <textarea rows="6" cols="120" name="subject_condition" id="subject_condition" ></textarea>
            </td>
        </tr>
        <tr style="height: 40px;">
           <td>
              <label style="width: 100px;text-align: right;padding-right: 15px;"></label>
              <button type="submit" class="btn btn-success">
                 <span class="glyphicon glyphicon-saved"></span>提交
              </button>
           </td>
        </tr>
     </table>
     </form>
    </div>
  </div>
</div>

<%
    }else{
%>
<div class="container-fluid row form-group">
  <div class="panel panel-info"> 
     <div class="panel-heading">
          <strong>我要出题</strong>
     </div>
     <div class="panel-body">
      <table class="table table-hover" border="1">
        <tr style="height: 40px;" class="success">
            <td>
               <label style="width: 100px;text-align: right;color: red;">你已出过题目!</label>
            </td>
        </tr>
     </table>
    </div>
  </div>
</div>
<%
    }
%>
</body>
</html>



展开阅读全文

没有更多推荐了,返回首页