@ -0,0 +1,4 @@
|
||||
sims_war.war
|
||||
out
|
||||
/hello.txt
|
||||
.idea
|
After Width: | Height: | Size: 109 KiB |
After Width: | Height: | Size: 168 KiB |
After Width: | Height: | Size: 95 KiB |
After Width: | Height: | Size: 49 KiB |
After Width: | Height: | Size: 78 KiB |
After Width: | Height: | Size: 922 KiB |
After Width: | Height: | Size: 78 KiB |
After Width: | Height: | Size: 70 KiB |
After Width: | Height: | Size: 89 KiB |
After Width: | Height: | Size: 230 KiB |
After Width: | Height: | Size: 179 KiB |
After Width: | Height: | Size: 95 KiB |
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="web" name="Web">
|
||||
<configuration>
|
||||
<descriptors>
|
||||
<deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/web/WEB-INF/web.xml" />
|
||||
</descriptors>
|
||||
<webroots>
|
||||
<root url="file://$MODULE_DIR$/web" relative="/" />
|
||||
</webroots>
|
||||
</configuration>
|
||||
</facet>
|
||||
<facet type="web" name="Web2">
|
||||
<configuration>
|
||||
<descriptors>
|
||||
<deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/sims_war/WEB-INF/web.xml" />
|
||||
</descriptors>
|
||||
<webroots>
|
||||
<root url="file://$MODULE_DIR$/sims_war" relative="/" />
|
||||
</webroots>
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Tomcat 8.5.53" level="application_server_libraries" />
|
||||
<orderEntry type="library" name="lib" level="project" />
|
||||
</component>
|
||||
</module>
|
@ -0,0 +1,11 @@
|
||||
package dao;
|
||||
|
||||
import domain.Admin;
|
||||
|
||||
public interface AdminDao {
|
||||
Admin findAdminidAndPassword(String id, String password);
|
||||
|
||||
void updatePassword(String adminid, String newpassword);
|
||||
|
||||
Admin findAdminById(String a_id);
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package dao;
|
||||
|
||||
import domain.CDC;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface CDCDao {
|
||||
List<CDC> findAllCollege();
|
||||
|
||||
List<CDC> findAllDepartment();
|
||||
|
||||
List<CDC> findAllClass();
|
||||
|
||||
List<CDC> findAll();
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package dao;
|
||||
|
||||
import domain.Complaint;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ComplaintDao {
|
||||
List<Complaint> findAllComplaint();
|
||||
|
||||
void addComplaint(Complaint complaint);
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package dao;
|
||||
|
||||
import domain.Course;
|
||||
|
||||
public interface CourseDao {
|
||||
void addOptionalCourse(Course course);
|
||||
|
||||
Course findSelectCourseByCourseId(String cid);
|
||||
|
||||
void deleteServiceById(String cid);
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package dao;
|
||||
|
||||
import domain.Notify;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface NotifyDao {
|
||||
void add(Notify notify);
|
||||
|
||||
List<Notify> findNotify();
|
||||
|
||||
List<Notify> findAllNotify();
|
||||
|
||||
void deleteNotifyById(String notifyid);
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package dao;
|
||||
|
||||
import domain.Photo;
|
||||
|
||||
public interface PhotoDao {
|
||||
void addPhoto(Photo photo);
|
||||
|
||||
Photo findPhotoByPhotoId(String id);
|
||||
|
||||
void updatePhoto(Photo photo);
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package dao;
|
||||
|
||||
import domain.SelectCourse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SelectCourseDao {
|
||||
List<SelectCourse> findStudentSelectedCourseByCourseId(String cid);
|
||||
|
||||
SelectCourse findScoreByCourseIdAndStudentId(String cid, String sid);
|
||||
|
||||
void upDateScoreByCidAndSid(String cid, String sid, String sScore);
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package dao;
|
||||
|
||||
import domain.Course;
|
||||
import domain.SelectCourse;
|
||||
import domain.Student;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 学生操作的DAO
|
||||
*/
|
||||
public interface StudentDao {
|
||||
List<Student> findByPage(int start, int rows, Map<String, String[]> condition);
|
||||
|
||||
List<Student> findAll();
|
||||
|
||||
Student findStudentidAndPassword(String id, String password);
|
||||
|
||||
Student findStudentById(String s_id);
|
||||
|
||||
void addStudent(Student student);
|
||||
|
||||
void updateInfo(Student student);
|
||||
|
||||
void updatePassword(String studentid, String newpassword);
|
||||
|
||||
List<SelectCourse> findAllSelectCourse(String studentid);
|
||||
|
||||
List<Course> findAllOptionalCourse();
|
||||
|
||||
void addSelectCourse(String studentid, String courseid);
|
||||
|
||||
void deleteStudentById(String studentid);
|
||||
|
||||
int findTotalCount(Map<String, String[]> condition);
|
||||
|
||||
void addStudentAllInfo(Student updateStudent);
|
||||
|
||||
List<SelectCourse> findSelectCourseAllStudent();
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package dao;
|
||||
|
||||
import domain.Course;
|
||||
import domain.Teacher;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 管理员操作的DAO
|
||||
*/
|
||||
public interface TeacherDao {
|
||||
Teacher findTeacheridAndPassword(String id, String password);
|
||||
|
||||
List<Teacher> findAll();
|
||||
|
||||
List<Course> findMySelfOptionalCourse(String t_id);
|
||||
|
||||
Course findOptionalCourseByCourseId(String cid);
|
||||
|
||||
void updateCourseInfo(Course updateCourse);
|
||||
|
||||
void deleteCourseById(String cid);
|
||||
|
||||
void updatePassword(String teacherid, String newpassword);
|
||||
|
||||
Teacher findTeacherById(String t_id);
|
||||
|
||||
void addTeacherAllInfo(Teacher updateTeacher);
|
||||
|
||||
void deleteTeacherById(String teacherid);
|
||||
|
||||
void updateInfo(Teacher updateTeacher);
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package dao.impl;
|
||||
|
||||
import dao.AdminDao;
|
||||
import domain.Admin;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import utils.JDBCUtils;
|
||||
|
||||
public class AdminDaoImpl implements AdminDao {
|
||||
private JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource());
|
||||
|
||||
@Override
|
||||
public Admin findAdminidAndPassword(String id, String password) {
|
||||
try {
|
||||
String sql = "select * from admin where a_id = ? and a_password = ?";
|
||||
Admin admin = template.queryForObject(sql,new BeanPropertyRowMapper<Admin>(Admin.class),id,password);
|
||||
return admin;
|
||||
} catch (DataAccessException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePassword(String adminid, String newpassword) {
|
||||
try {
|
||||
String sql = "update admin set a_password=? where a_id=?";
|
||||
template.update(sql,newpassword,adminid);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Admin findAdminById(String id) {
|
||||
try {
|
||||
String sql = "select * from admin where a_id = ?";
|
||||
Admin admin = template.queryForObject(sql,new BeanPropertyRowMapper<Admin>(Admin.class),id);
|
||||
return admin;
|
||||
} catch (DataAccessException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package dao.impl;
|
||||
|
||||
import dao.CDCDao;
|
||||
import domain.CDC;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import utils.JDBCUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CDCDaoImpl implements CDCDao {
|
||||
private JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource());
|
||||
|
||||
@Override
|
||||
public List<CDC> findAllCollege() {
|
||||
try {
|
||||
String sql = "select distinct college from college_department_class";
|
||||
List<CDC> cdcs = template.query(sql, new BeanPropertyRowMapper<CDC>(CDC.class));
|
||||
return cdcs;
|
||||
} catch (DataAccessException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CDC> findAllDepartment() {
|
||||
try {
|
||||
String sql = "select distinct department from college_department_class";
|
||||
List<CDC> cdcs = template.query(sql, new BeanPropertyRowMapper<CDC>(CDC.class));
|
||||
return cdcs;
|
||||
} catch (DataAccessException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CDC> findAllClass() {
|
||||
try {
|
||||
String sql = "select distinct cclass from college_department_class";
|
||||
List<CDC> cdcs = template.query(sql, new BeanPropertyRowMapper<CDC>(CDC.class));
|
||||
return cdcs;
|
||||
} catch (DataAccessException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CDC> findAll() {
|
||||
try {
|
||||
String sql = "select * from college_department_class";
|
||||
List<CDC> cdcs = template.query(sql, new BeanPropertyRowMapper<CDC>(CDC.class));
|
||||
return cdcs;
|
||||
} catch (DataAccessException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package dao.impl;
|
||||
|
||||
import dao.ComplaintDao;
|
||||
import domain.Complaint;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import utils.JDBCUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ComplaintDaoImpl implements ComplaintDao {
|
||||
private JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource());
|
||||
|
||||
@Override
|
||||
public List<Complaint> findAllComplaint() {
|
||||
try {
|
||||
String sql = "select * from complaint order by id DESC";
|
||||
List<Complaint> complaints = template.query(sql, new BeanPropertyRowMapper<Complaint>(Complaint.class));
|
||||
return complaints;
|
||||
} catch (DataAccessException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addComplaint(Complaint complaint) {
|
||||
try {
|
||||
String sql = "insert into complaint(cdate,content) values(?,?)";
|
||||
template.update(sql,complaint.getCdate(),complaint.getContent());
|
||||
} catch (DataAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package dao.impl;
|
||||
|
||||
import dao.CourseDao;
|
||||
import domain.Course;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import utils.JDBCUtils;
|
||||
|
||||
public class CourseDaoImpl implements CourseDao {
|
||||
private JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource());
|
||||
|
||||
@Override
|
||||
public void addOptionalCourse(Course c) {
|
||||
try {
|
||||
String sql = "insert into course values(?,?,?,?)";
|
||||
template.update(sql,c.getC_id(),c.getC_name(),c.getT_id(),c.getC_info());
|
||||
} catch (DataAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Course findSelectCourseByCourseId(String cid) {
|
||||
try {
|
||||
String sql = "select * from course where c_id = ?";
|
||||
Course course = template.queryForObject(sql,new BeanPropertyRowMapper<Course>(Course.class),cid);
|
||||
return course;
|
||||
} catch (DataAccessException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteServiceById(String cid) {
|
||||
try {
|
||||
String sql = "delete from course where c_id=?";
|
||||
template.update(sql,cid);
|
||||
} catch (DataAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
package dao.impl;
|
||||
|
||||
import dao.NotifyDao;
|
||||
import domain.Notify;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import utils.JDBCUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class NotifyDaoImpl implements NotifyDao {
|
||||
private JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource());
|
||||
|
||||
@Override
|
||||
public void add(Notify notify) {
|
||||
try {
|
||||
String sql = "insert into notify(notifyDate,notifyInfo) values(?,?)";
|
||||
template.update(sql,notify.getNotifyDate(),notify.getNotifyInfo());
|
||||
} catch (DataAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Notify> findAllNotify() {
|
||||
try {
|
||||
String sql = "select * from notify order by id DESC";
|
||||
List<Notify> notifys = template.query(sql, new BeanPropertyRowMapper<Notify>(Notify.class));
|
||||
return notifys;
|
||||
} catch (DataAccessException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteNotifyById(String notifyid) {
|
||||
try {
|
||||
String sql = "delete from notify where id=?";
|
||||
template.update(sql,notifyid);
|
||||
} catch (DataAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Notify> findNotify() {
|
||||
try {
|
||||
String sql = "select * from notify order by id DESC limit 3";
|
||||
List<Notify> notify = template.query(sql, new BeanPropertyRowMapper<Notify>(Notify.class));
|
||||
return notify;
|
||||
} catch (DataAccessException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package dao.impl;
|
||||
|
||||
import dao.PhotoDao;
|
||||
import domain.Photo;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import utils.JDBCUtils;
|
||||
|
||||
public class PhotoDaoImpl implements PhotoDao {
|
||||
private JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource());
|
||||
|
||||
@Override
|
||||
public void addPhoto(Photo photo) {
|
||||
try {
|
||||
String sql = "insert into photo(photo_id,photo_name) values(?,?)";
|
||||
template.update(sql,photo.getPhotoId(),photo.getPhotoName());
|
||||
} catch (DataAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Photo findPhotoByPhotoId(String id) {
|
||||
try {
|
||||
String sql = "select * from photo where photo_id = ?";
|
||||
Photo photo = template.queryForObject(sql,new BeanPropertyRowMapper<Photo>(Photo.class),id);
|
||||
return photo;
|
||||
} catch (DataAccessException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePhoto(Photo photo) {
|
||||
try {
|
||||
String sql = "update photo set photo_name=? where photo_id=?";
|
||||
template.update(sql,photo.getPhotoName(),photo.getPhotoId());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package dao.impl;
|
||||
|
||||
import dao.SelectCourseDao;
|
||||
import domain.SelectCourse;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import utils.JDBCUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SelectCourseDaoImpl implements SelectCourseDao {
|
||||
private JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource());
|
||||
|
||||
@Override
|
||||
public List<SelectCourse> findStudentSelectedCourseByCourseId(String cid) {
|
||||
try {
|
||||
String sql = "select course.c_id,course.c_name,course.c_info,student.s_id,student.s_name,select_course.score\n" +
|
||||
"from select_course,student,course\n" +
|
||||
"where student.s_id=select_course.s_id\n" +
|
||||
"and select_course.c_id=course.c_id\n" +
|
||||
"and select_course.c_id=?";
|
||||
List<SelectCourse> scs = template.query(sql, new BeanPropertyRowMapper<SelectCourse>(SelectCourse.class),cid);
|
||||
return scs;
|
||||
} catch (DataAccessException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SelectCourse findScoreByCourseIdAndStudentId(String cid, String sid) {
|
||||
try {
|
||||
String sql = "select * from select_course where c_id=? and s_id=?";
|
||||
SelectCourse sc = template.queryForObject(sql, new BeanPropertyRowMapper<SelectCourse>(SelectCourse.class), cid, sid);
|
||||
return sc;
|
||||
} catch (
|
||||
DataAccessException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void upDateScoreByCidAndSid(String cid, String sid, String sScore) {
|
||||
try {
|
||||
String sql = "update select_course set score = ? where c_id = ? and s_id = ?";
|
||||
template.update(sql,sScore,cid,sid);
|
||||
} catch (DataAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,233 @@
|
||||
package dao.impl;
|
||||
|
||||
import dao.StudentDao;
|
||||
import domain.Course;
|
||||
import domain.SelectCourse;
|
||||
import domain.Student;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import utils.JDBCUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class StudentDaoImpl implements StudentDao {
|
||||
private JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource());
|
||||
|
||||
@Override
|
||||
public List<Student> findAll() {
|
||||
//使用JDBC操作数据库
|
||||
try {
|
||||
String sql = "select * from student";
|
||||
List<Student> students = template.query(sql, new BeanPropertyRowMapper<Student>(Student.class));
|
||||
return students;
|
||||
} catch (DataAccessException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Student findStudentidAndPassword(String id,String password) {
|
||||
try {
|
||||
String sql = "select * from student where s_id = ? and s_password = ?";
|
||||
Student student = template.queryForObject(sql,new BeanPropertyRowMapper<Student>(Student.class),id,password);
|
||||
return student;
|
||||
} catch (DataAccessException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Student findStudentById(String id) {
|
||||
try {
|
||||
String sql = "select * from student where s_id = ?";
|
||||
Student student = template.queryForObject(sql,new BeanPropertyRowMapper<Student>(Student.class),id);
|
||||
return student;
|
||||
} catch (DataAccessException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addStudent(Student student) {
|
||||
try {
|
||||
String sql = "insert into student(s_id,s_password) values(?,?)";
|
||||
template.update(sql,student.getS_id(),student.getS_password());
|
||||
} catch (DataAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateInfo(Student student) {
|
||||
try {
|
||||
String sql = "update student set s_name =?,s_sex=?,s_age=?,s_phone=?,s_email=?,s_address=?,s_college=?,s_department=?,s_class=? where s_id=?";
|
||||
template.update(sql,student.getS_name(),student.getS_sex(),student.getS_age(),student.getS_phone(),student.getS_email(),student.getS_address(),student.getS_college(),student.getS_department(),student.getS_class(),student.getS_id());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePassword(String studentid, String newpassword) {
|
||||
try {
|
||||
String sql = "update student set s_password=? where s_id=?";
|
||||
template.update(sql,newpassword,studentid);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SelectCourse> findAllSelectCourse(String studentid) {
|
||||
try {
|
||||
String sql = "select student.s_id,student.s_name,course.c_id,course.c_name,course.c_info,teacher.t_id,t_name,select_course.score\n" +
|
||||
"from select_course,student,course,teacher\n" +
|
||||
"where student.s_id=select_course.s_id\n" +
|
||||
"and select_course.c_id=course.c_id\n" +
|
||||
"and course.t_id=teacher.t_id\n" +
|
||||
"and student.s_id=?";
|
||||
List<SelectCourse> scs = template.query(sql, new BeanPropertyRowMapper<SelectCourse>(SelectCourse.class),studentid);
|
||||
return scs;
|
||||
} catch (DataAccessException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Course> findAllOptionalCourse() {
|
||||
try {
|
||||
String sql = "select course.c_id,course.c_name,course.c_info,teacher.t_id,t_name\n" +
|
||||
"from course,teacher\n" +
|
||||
"where course.t_id=teacher.t_id";
|
||||
List<Course> cs = template.query(sql, new BeanPropertyRowMapper<Course>(Course.class));
|
||||
return cs;
|
||||
} catch (DataAccessException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSelectCourse(String studentid, String courseid) {
|
||||
try {
|
||||
String sql = "insert into select_course(s_id,c_id) values(?,?)";
|
||||
template.update(sql,studentid,courseid);
|
||||
} catch (DataAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteStudentById(String studentid) {
|
||||
try {
|
||||
String sql = "delete from student where s_id=?";
|
||||
template.update(sql,studentid);
|
||||
} catch (DataAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int findTotalCount(Map<String, String[]> condition) {
|
||||
//定义模板初始化sql
|
||||
String sql = "select count(*) from student where 1=1";
|
||||
StringBuilder sb = new StringBuilder(sql);
|
||||
//遍历map
|
||||
Set<String> keySet = condition.keySet();
|
||||
//定义参数集合
|
||||
List<Object> params = new ArrayList<Object>();
|
||||
for (String key : keySet) {
|
||||
System.out.println(key);
|
||||
//排除分页条件参数
|
||||
if ("currentPage".equals(key) || "rows".equals(key)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//获取value
|
||||
String value = condition.get(key)[0];
|
||||
//判断value是否有值
|
||||
if (value != null && !"".equals(value)) {
|
||||
//有值
|
||||
sb.append(" and "+key+" like ? ");
|
||||
params.add("%"+value+"%");//?条件的值
|
||||
}
|
||||
}
|
||||
System.out.println(sb.toString());
|
||||
System.out.println(params);
|
||||
return template.queryForObject(sb.toString(),Integer.class,params.toArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addStudentAllInfo(Student s) {
|
||||
try {
|
||||
String sql = "insert into student(s_id,s_college,s_department,s_class,s_name,s_sex,s_age,s_phone,s_email,s_address) values(?,?,?,?,?,?,?,?,?,?)";
|
||||
template.update(sql,s.getS_id(),s.getS_college(),s.getS_department(),s.getS_class(),s.getS_name(),s.getS_sex(),s.getS_age(),s.getS_phone(),s.getS_email(),s.getS_address());
|
||||
} catch (DataAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SelectCourse> findSelectCourseAllStudent() {
|
||||
try {
|
||||
String sql = "select student.s_id,student.s_name,course.c_id,course.c_name,course.c_info,teacher.t_id,t_name,select_course.score\n" +
|
||||
"from select_course,student,course,teacher\n" +
|
||||
"where student.s_id=select_course.s_id\n" +
|
||||
"and select_course.c_id=course.c_id\n" +
|
||||
"and course.t_id=teacher.t_id\n";
|
||||
List<SelectCourse> scs = template.query(sql, new BeanPropertyRowMapper<SelectCourse>(SelectCourse.class));
|
||||
return scs;
|
||||
} catch (DataAccessException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Student> findByPage(int start, int rows, Map<String, String[]> condition) {
|
||||
try {
|
||||
String sql = "select * from student where 1=1";
|
||||
StringBuilder sb = new StringBuilder(sql);
|
||||
//遍历map
|
||||
Set<String> keySet = condition.keySet();
|
||||
//定义参数集合
|
||||
List<Object> params = new ArrayList<Object>();
|
||||
for (String key : keySet) {
|
||||
//排除分页条件参数
|
||||
if ("currentPage".equals(key) || "rows".equals(key)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//获取value
|
||||
String value = condition.get(key)[0];
|
||||
//判断value是否有值
|
||||
if (value != null && !"".equals(value)) {
|
||||
//有值
|
||||
sb.append(" and "+key+" like ? ");
|
||||
params.add("%"+value+"%");//?条件的值
|
||||
}
|
||||
}
|
||||
//添加分页查询
|
||||
sb.append(" limit ? , ?");
|
||||
//添加分页查询参数值
|
||||
params.add(start);
|
||||
params.add(rows);
|
||||
System.out.println(sb.toString());
|
||||
System.out.println(params);
|
||||
return template.query(sb.toString(),new BeanPropertyRowMapper<Student>(Student.class),params.toArray());
|
||||
} catch (DataAccessException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,137 @@
|
||||
package dao.impl;
|
||||
|
||||
import dao.TeacherDao;
|
||||
import domain.Course;
|
||||
import domain.Student;
|
||||
import domain.Teacher;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import utils.JDBCUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TeacherDaoImpl implements TeacherDao {
|
||||
private JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource());
|
||||
|
||||
@Override
|
||||
public Teacher findTeacheridAndPassword(String id, String password) {
|
||||
try {
|
||||
String sql = "select * from teacher where t_id = ? and t_password = ?";
|
||||
Teacher teacher = template.queryForObject(sql,new BeanPropertyRowMapper<Teacher>(Teacher.class),id,password);
|
||||
return teacher;
|
||||
} catch (DataAccessException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Teacher> findAll() {
|
||||
try {
|
||||
String sql = "select * from teacher";
|
||||
List<Teacher> teachers = template.query(sql, new BeanPropertyRowMapper<Teacher>(Teacher.class));
|
||||
return teachers;
|
||||
} catch (DataAccessException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Course> findMySelfOptionalCourse(String t_id) {
|
||||
try {
|
||||
String sql = "select * from course where t_id = ?";
|
||||
List<Course> courses = template.query(sql, new BeanPropertyRowMapper<Course>(Course.class),t_id);
|
||||
return courses;
|
||||
} catch (DataAccessException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Course findOptionalCourseByCourseId(String cid) {
|
||||
try {
|
||||
String sql = "select * from course where c_id = ?";
|
||||
Course c = template.queryForObject(sql,new BeanPropertyRowMapper<Course>(Course.class),cid);
|
||||
return c;
|
||||
} catch (DataAccessException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCourseInfo(Course updateCourse) {
|
||||
try {
|
||||
String sql = "update course set c_name =?,c_info=? where c_id=?";
|
||||
template.update(sql,updateCourse.getC_name(),updateCourse.getC_info(),updateCourse.getC_id());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteCourseById(String cid) {
|
||||
try {
|
||||
String sql = "delete from course where c_id=?";
|
||||
template.update(sql,cid);
|
||||
} catch (DataAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePassword(String teacherid, String newpassword) {
|
||||
try {
|
||||
String sql = "update teacher set t_password=? where t_id=?";
|
||||
template.update(sql,newpassword,teacherid);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Teacher findTeacherById(String t_id) {
|
||||
try {
|
||||
String sql = "select * from teacher where t_id = ?";
|
||||
Teacher teacher = template.queryForObject(sql,new BeanPropertyRowMapper<Teacher>(Teacher.class),t_id);
|
||||
return teacher;
|
||||
} catch (DataAccessException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTeacherAllInfo(Teacher t) {
|
||||
try {
|
||||
String sql = "insert into teacher(t_id,t_name,t_sex,t_education,t_title) values(?,?,?,?,?)";
|
||||
template.update(sql,t.getT_id(),t.getT_name(),t.getT_sex(),t.getT_education(),t.getT_title());
|
||||
} catch (DataAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteTeacherById(String teacherid) {
|
||||
try {
|
||||
String sql = "delete from teacher where t_id=?";
|
||||
template.update(sql,teacherid);
|
||||
} catch (DataAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateInfo(Teacher t) {
|
||||
try {
|
||||
String sql = "update teacher set t_name =?,t_sex=?,t_education=?,t_title=? where t_id=?";
|
||||
template.update(sql,t.getT_name(),t.getT_sex(),t.getT_education(),t.getT_title(),t.getT_id());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package domain;
|
||||
|
||||
public class Admin {
|
||||
private String a_id;
|
||||
private String a_password;
|
||||
|
||||
public String getA_id() {
|
||||
return a_id;
|
||||
}
|
||||
|
||||
public void setA_id(String a_id) {
|
||||
this.a_id = a_id;
|
||||
}
|
||||
|
||||
public String getA_password() {
|
||||
return a_password;
|
||||
}
|
||||
|
||||
public void setA_password(String a_password) {
|
||||
this.a_password = a_password;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Admin{" +
|
||||
"a_id='" + a_id + '\'' +
|
||||
", a_password='" + a_password + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package domain;
|
||||
|
||||
public class CDC {
|
||||
|
||||
private String college;
|
||||
private String department;
|
||||
private String cclass;
|
||||
|
||||
public String getCollege() {
|
||||
return college;
|
||||
}
|
||||
|
||||
public void setCollege(String college) {
|
||||
this.college = college;
|
||||
}
|
||||
|
||||
public String getDepartment() {
|
||||
return department;
|
||||
}
|
||||
|
||||
public void setDepartment(String department) {
|
||||
this.department = department;
|
||||
}
|
||||
|
||||
public String getCclass() {
|
||||
return cclass;
|
||||
}
|
||||
|
||||
public void setCclass(String cclass) {
|
||||
this.cclass = cclass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CDC{" +
|
||||
"college='" + college + '\'' +
|
||||
", department='" + department + '\'' +
|
||||
", cclass='" + cclass + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package domain;
|
||||
|
||||
public class Complaint {
|
||||
private String id;
|
||||
private String cdate;
|
||||
private String content;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getCdate() {
|
||||
return cdate;
|
||||
}
|
||||
|
||||
public void setCdate(String cdate) {
|
||||
this.cdate = cdate;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Complaint{" +
|
||||
"id='" + id + '\'' +
|
||||
", cdate='" + cdate + '\'' +
|
||||
", content='" + content + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
package domain;
|
||||
|
||||
public class Course {
|
||||
private String c_id;
|
||||
private String c_name;
|
||||
private String c_info;
|
||||
private String t_id;
|
||||
private String t_name;
|
||||
|
||||
public String getC_id() {
|
||||
return c_id;
|
||||
}
|
||||
|
||||
public void setC_id(String c_id) {
|
||||
this.c_id = c_id;
|
||||
}
|
||||
|
||||
public String getC_name() {
|
||||
return c_name;
|
||||
}
|
||||
|
||||
public void setC_name(String c_name) {
|
||||
this.c_name = c_name;
|
||||
}
|
||||
|
||||
public String getC_info() {
|
||||
return c_info;
|
||||
}
|
||||
|
||||
public void setC_info(String c_info) {
|
||||
this.c_info = c_info;
|
||||
}
|
||||
|
||||
public String getT_id() {
|
||||
return t_id;
|
||||
}
|
||||
|
||||
public void setT_id(String t_id) {
|
||||
this.t_id = t_id;
|
||||
}
|
||||
|
||||
public String getT_name() {
|
||||
return t_name;
|
||||
}
|
||||
|
||||
public void setT_name(String t_name) {
|
||||
this.t_name = t_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Course{" +
|
||||
"c_id='" + c_id + '\'' +
|
||||
", c_name='" + c_name + '\'' +
|
||||
", c_info='" + c_info + '\'' +
|
||||
", t_id='" + t_id + '\'' +
|
||||
", t_name='" + t_name + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package domain;
|
||||
|
||||
public class FileClass {
|
||||
private String fileName;
|
||||
private String filePath;
|
||||
private String fileSize;
|
||||
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public void setFileName(String fileName) {
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
public String getFilePath() {
|
||||
return filePath;
|
||||
}
|
||||
|
||||
public void setFilePath(String filePath) {
|
||||
this.filePath = filePath;
|
||||
}
|
||||
|
||||
public String getFileSize() {
|
||||
return fileSize;
|
||||
}
|
||||
|
||||
public void setFileSize(String fileSize) {
|
||||
this.fileSize = fileSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "FileClass{" +
|
||||
"fileName='" + fileName + '\'' +
|
||||
", filePath='" + filePath + '\'' +
|
||||
", fileSize='" + fileSize + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package domain;
|
||||
|
||||
public class Notify {
|
||||
|
||||
private String id;
|
||||
private String notifyInfo;
|
||||
private String notifyDate;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getNotifyInfo() {
|
||||
return notifyInfo;
|
||||
}
|
||||
|
||||
public void setNotifyInfo(String notifyInfo) {
|
||||
this.notifyInfo = notifyInfo;
|
||||
}
|
||||
|
||||
public String getNotifyDate() {
|
||||
return notifyDate;
|
||||
}
|
||||
|
||||
public void setNotifyDate(String notifyDate) {
|
||||
this.notifyDate = notifyDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Notify{" +
|
||||
"id='" + id + '\'' +
|
||||
", notifyInfo='" + notifyInfo + '\'' +
|
||||
", notifyDate='" + notifyDate + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
package domain;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 分页对象
|
||||
*/
|
||||
public class PageBean<T> {
|
||||
private int totalCount; //总记录数
|
||||
private int totalPage; //总页码
|
||||
private List<T> list; //每页数据
|
||||
private int currentPage; //当前页码
|
||||
private int rows; //每页显示的记录数
|
||||
|
||||
public int getTotalCount() {
|
||||
return totalCount;
|
||||
}
|
||||
|
||||
public void setTotalCount(int totalCount) {
|
||||
this.totalCount = totalCount;
|
||||
}
|
||||
|
||||
public int getTotalPage() {
|
||||
return totalPage;
|
||||
}
|
||||
|
||||
public void setTotalPage(int totalPage) {
|
||||
this.totalPage = totalPage;
|
||||
}
|
||||
|
||||
public List<T> getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
public void setList(List<T> list) {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
public int getCurrentPage() {
|
||||
return currentPage;
|
||||
}
|
||||
|
||||
public void setCurrentPage(int currentPage) {
|
||||
this.currentPage = currentPage;
|
||||
}
|
||||
|
||||
public int getRows() {
|
||||
return rows;
|
||||
}
|
||||
|
||||
public void setRows(int rows) {
|
||||
this.rows = rows;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PageBean{" +
|
||||
"totalCount=" + totalCount +
|
||||
", totalPage=" + totalPage +
|
||||
", list=" + list +
|
||||
", currentPage=" + currentPage +
|
||||
", rows=" + rows +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package domain;
|
||||
|
||||
public class Photo {
|
||||
|
||||
private String photoId;
|
||||
private String photoName;
|
||||
|
||||
public String getPhotoId() {
|
||||
return photoId;
|
||||
}
|
||||
|
||||
public void setPhotoId(String photoId) {
|
||||
this.photoId = photoId;
|
||||
}
|
||||
|
||||
public String getPhotoName() {
|
||||
return photoName;
|
||||
}
|
||||
|
||||
public void setPhotoName(String photoName) {
|
||||
this.photoName = photoName;
|
||||
}
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
package domain;
|
||||
|
||||
public class SelectCourse {
|
||||
private String s_id;
|
||||
private String s_name;
|
||||
private String c_id;
|
||||
private String c_name;
|
||||
private String c_info;
|
||||
private String t_id;
|
||||
private String t_name;
|
||||
private String score;
|
||||
|
||||
public String getS_id() {
|
||||
return s_id;
|
||||
}
|
||||
|
||||
public void setS_id(String s_id) {
|
||||
this.s_id = s_id;
|
||||
}
|
||||
|
||||
public String getS_name() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
public void setS_name(String s_name) {
|
||||
this.s_name = s_name;
|
||||
}
|
||||
|
||||
public String getC_id() {
|
||||
return c_id;
|
||||
}
|
||||
|
||||
public void setC_id(String c_id) {
|
||||
this.c_id = c_id;
|
||||
}
|
||||
|
||||
public String getC_name() {
|
||||
return c_name;
|
||||
}
|
||||
|
||||
public void setC_name(String c_name) {
|
||||
this.c_name = c_name;
|
||||
}
|
||||
|
||||
public String getC_info() {
|
||||
return c_info;
|
||||
}
|
||||
|
||||
public void setC_info(String c_info) {
|
||||
this.c_info = c_info;
|
||||
}
|
||||
|
||||
public String getT_id() {
|
||||
return t_id;
|
||||
}
|
||||
|
||||
public void setT_id(String t_id) {
|
||||
this.t_id = t_id;
|
||||
}
|
||||
|
||||
public String getT_name() {
|
||||
return t_name;
|
||||
}
|
||||
|
||||
public void setT_name(String t_name) {
|
||||
this.t_name = t_name;
|
||||
}
|
||||
|
||||
public String getScore() {
|
||||
return score;
|
||||
}
|
||||
|
||||
public void setScore(String score) {
|
||||
this.score = score;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SelectCourse{" +
|
||||
"s_id='" + s_id + '\'' +
|
||||
", s_name='" + s_name + '\'' +
|
||||
", c_id='" + c_id + '\'' +
|
||||
", c_name='" + c_name + '\'' +
|
||||
", c_info='" + c_info + '\'' +
|
||||
", t_id='" + t_id + '\'' +
|
||||
", t_name='" + t_name + '\'' +
|
||||
", score='" + score + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,120 @@
|
||||
package domain;
|
||||
|
||||
public class Student {
|
||||
private String s_id;
|
||||
private String s_college;
|
||||
private String s_department;
|
||||
private String s_class;
|
||||
private String s_name;
|
||||
private String s_sex;
|
||||
private String s_age;
|
||||
private String s_address;
|
||||
private String s_phone;
|
||||
private String s_email;
|
||||
private String s_password;
|
||||
|
||||
public String getS_id() {
|
||||
return s_id;
|
||||
}
|
||||
|
||||
public void setS_id(String s_id) {
|
||||
this.s_id = s_id;
|
||||
}
|
||||
|
||||
public String getS_college() {
|
||||
return s_college;
|
||||
}
|
||||
|
||||
public void setS_college(String s_college) {
|
||||
this.s_college = s_college;
|
||||
}
|
||||
|
||||
public String getS_department() {
|
||||
return s_department;
|
||||
}
|
||||
|
||||
public void setS_department(String s_department) {
|
||||
this.s_department = s_department;
|
||||
}
|
||||
|
||||
public String getS_class() {
|
||||
return s_class;
|
||||
}
|
||||
|
||||
public void setS_class(String s_class) {
|
||||
this.s_class = s_class;
|
||||
}
|
||||
|
||||
public String getS_name() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
public void setS_name(String s_name) {
|
||||
this.s_name = s_name;
|
||||
}
|
||||
|
||||
public String getS_sex() {
|
||||
return s_sex;
|
||||
}
|
||||
|
||||
public void setS_sex(String s_sex) {
|
||||
this.s_sex = s_sex;
|
||||
}
|
||||
|
||||
public String getS_age() {
|
||||
return s_age;
|
||||
}
|
||||
|
||||
public void setS_age(String s_age) {
|
||||
this.s_age = s_age;
|
||||
}
|
||||
|
||||
public String getS_address() {
|
||||
return s_address;
|
||||
}
|
||||
|
||||
public void setS_address(String s_address) {
|
||||
this.s_address = s_address;
|
||||
}
|
||||
|
||||
public String getS_phone() {
|
||||
return s_phone;
|
||||
}
|
||||
|
||||
public void setS_phone(String s_phone) {
|
||||
this.s_phone = s_phone;
|
||||
}
|
||||
|
||||
public String getS_email() {
|
||||
return s_email;
|
||||
}
|
||||
|
||||
public void setS_email(String s_email) {
|
||||
this.s_email = s_email;
|
||||
}
|
||||
|
||||
public String getS_password() {
|
||||
return s_password;
|
||||
}
|
||||
|
||||
public void setS_password(String s_password) {
|
||||
this.s_password = s_password;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Student{" +
|
||||
"s_id='" + s_id + '\'' +
|
||||
", s_college='" + s_college + '\'' +
|
||||
", s_department='" + s_department + '\'' +
|
||||
", s_class='" + s_class + '\'' +
|
||||
", s_name='" + s_name + '\'' +
|
||||
", s_sex='" + s_sex + '\'' +
|
||||
", s_age=" + s_age +
|
||||
", s_address='" + s_address + '\'' +
|
||||
", s_phone='" + s_phone + '\'' +
|
||||
", s_email='" + s_email + '\'' +
|
||||
", s_password='" + s_password + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
package domain;
|
||||
|
||||
public class Teacher {
|
||||
private String t_id;
|
||||
private String t_name;
|
||||
private String t_sex;
|
||||
private String t_education;
|
||||
private String t_title;
|
||||
private String t_password;
|
||||
|
||||
public String getT_id() {
|
||||
return t_id;
|
||||
}
|
||||
|
||||
public void setT_id(String t_id) {
|
||||
this.t_id = t_id;
|
||||
}
|
||||
|
||||
public String getT_name() {
|
||||
return t_name;
|
||||
}
|
||||
|
||||
public void setT_name(String t_name) {
|
||||
this.t_name = t_name;
|
||||
}
|
||||
|
||||
public String getT_sex() {
|
||||
return t_sex;
|
||||
}
|
||||
|
||||
public void setT_sex(String t_sex) {
|
||||
this.t_sex = t_sex;
|
||||
}
|
||||
|
||||
public String getT_education() {
|
||||
return t_education;
|
||||
}
|
||||
|
||||
public void setT_education(String t_education) {
|
||||
this.t_education = t_education;
|
||||
}
|
||||
|
||||
public String getT_title() {
|
||||
return t_title;
|
||||
}
|
||||
|
||||
public void setT_title(String t_title) {
|
||||
this.t_title = t_title;
|
||||
}
|
||||
|
||||
public String getT_password() {
|
||||
return t_password;
|
||||
}
|
||||
|
||||
public void setT_password(String t_password) {
|
||||
this.t_password = t_password;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Teacher{" +
|
||||
"t_id='" + t_id + '\'' +
|
||||
", t_name='" + t_name + '\'' +
|
||||
", t_sex='" + t_sex + '\'' +
|
||||
", t_education='" + t_education + '\'' +
|
||||
", t_title='" + t_title + '\'' +
|
||||
", t_password='" + t_password + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
driverClassName=com.mysql.jdbc.Driver
|
||||
url=jdbc:mysql://127.0.0.1:3306/sims
|
||||
username=root
|
||||
password=root
|
||||
initialSize=5
|
||||
maxActive=10
|
||||
maxWait=3000
|
@ -0,0 +1,18 @@
|
||||
package service;
|
||||
|
||||
|
||||
import domain.Admin;
|
||||
|
||||
/**
|
||||
* 管理员的业务接口
|
||||
*/
|
||||
public interface AdminService {
|
||||
/**
|
||||
* 管理员登录
|
||||
*/
|
||||
Admin login(Admin admin);
|
||||
|
||||
void updatePassword(String adminid, String newpassword);
|
||||
|
||||
Admin findAdminById(Admin admin);
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package service;
|
||||
|
||||
|
||||
import domain.Admin;
|
||||
import domain.CDC;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 学院专业班级的业务接口
|
||||
*/
|
||||
public interface CDCService {
|
||||
List<CDC> findAllCollege();
|
||||
|
||||
List<CDC> findAllDepartment();
|
||||
|
||||
List<CDC> findAllClass();
|
||||
|
||||
List<CDC> findAll();
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package service;
|
||||
|
||||
import domain.Complaint;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 小吐槽的业务接口
|
||||
*/
|
||||
public interface ComplaintService {
|
||||
List<Complaint> findAll();
|
||||
|
||||
void addComplaint(Complaint complaint);
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package service;
|
||||
|
||||
import domain.Course;
|
||||
|
||||
public interface CourseService {
|
||||
void addOptionalCourse(Course course);
|
||||
|
||||
Course findSelectCourseByCourseId(String cid);
|
||||
|
||||
void deleteServiceById(String cid);
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package service;
|
||||
|
||||
import domain.Notify;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 公告的业务接口
|
||||
*/
|
||||
public interface NotifyService {
|
||||
/**
|
||||
* 公告发布
|
||||
*/
|
||||
void addNotify(Notify notify);
|
||||
|
||||
List<Notify> find();
|
||||
|
||||
List<Notify> findAll();
|
||||
|
||||
void deleteNotifyById(String notifyid);
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package service;
|
||||
|
||||
import domain.Photo;
|
||||
|
||||
public interface PhotoService {
|
||||
void addPhoto(Photo photo);
|
||||
|
||||
Photo findPhotoByPhotoId(String id);
|
||||
|
||||
void updatePhoto(Photo photo);
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package service;
|
||||
|
||||
import domain.SelectCourse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SelectCourseService {
|
||||
List<SelectCourse> findStudentSelectedCourseByCourseId(String cid);
|
||||
|
||||
SelectCourse findScoreByCourseIdAndStudentId(String cid,String sid);
|
||||
|
||||
void upDateScoreByCidAndSid(String cid, String sid, String sScore);
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package service;
|
||||
|
||||
import domain.Course;
|
||||
import domain.PageBean;
|
||||
import domain.SelectCourse;
|
||||
import domain.Student;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 学生管理的业务接口
|
||||
*/
|
||||
public interface StudentService {
|
||||
/**
|
||||
* 分页条件查询
|
||||
* @param currentPage
|
||||
* @param rows
|
||||
* @param condition
|
||||
* @return
|
||||
*/
|
||||
PageBean<Student> findStudentByPage(String currentPage, String rows, Map<String, String[]> condition);
|
||||
|
||||
/**
|
||||
* 查询所有学生信息
|
||||
*/
|
||||
List<Student> findAll();
|
||||
|
||||
Student login(Student student);
|
||||
|
||||
Student findStudentById(Student student);
|
||||
|
||||
void register(Student student);
|
||||
|
||||
void updateInfo(Student student);
|
||||
|
||||
void updatePassword(String studentid, String newpassword);
|
||||
|
||||
List<SelectCourse> findAllSelectCourse(String studentid);
|
||||
|
||||
List<Course> findAllOptionalCourse();
|
||||
|
||||
void addSelectCourse(String studentid, String courseid);
|
||||
|
||||
void deleteStudentById(String studentid);
|
||||
|
||||
void deleteSelectStudent(String[] sids);
|
||||
|
||||
void addStudentAllInfo(Student updateStudent);
|
||||
|
||||
List<SelectCourse> findSelectCourseAllStudent();
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package service;
|
||||
|
||||
import domain.Course;
|
||||
import domain.Teacher;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 教师管理的业务接口
|
||||
*/
|
||||
public interface TeacherService {
|
||||
/**
|
||||
* 教师登录
|
||||
*/
|
||||
Teacher login(Teacher teacher);
|
||||
|
||||
List<Teacher> findAll();
|
||||
|
||||
List<Course> findMySelfOptionalCourse(String T_id);
|
||||
|
||||
Course findOptionalCourseByCourseId(String cid);
|
||||
|
||||
void updateCourseInfo(Course updateCourse);
|
||||
|
||||
void deleteCourseById(String cid);
|
||||
|
||||
void updatePassword(String teacherid, String newpassword);
|
||||
|
||||
Teacher findTeacherById(Teacher teacher);
|
||||
|
||||
void addTeacherAllInfo(Teacher updateTeacher);
|
||||
|
||||
void deleteTeacherById(String teacherid);
|
||||
|
||||
void updateInfo(Teacher updateTeacher);
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package service.impl;
|
||||
|
||||
import dao.AdminDao;
|
||||
import dao.impl.AdminDaoImpl;
|
||||
import domain.Admin;
|
||||
import service.AdminService;
|
||||
|
||||
public class AdminServiceImpl implements AdminService {
|
||||
private AdminDao dao = new AdminDaoImpl();
|
||||
|
||||
@Override
|
||||
public Admin login(Admin admin) {
|
||||
return dao.findAdminidAndPassword(admin.getA_id(),admin.getA_password());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePassword(String adminid, String newpassword) {
|
||||
dao.updatePassword(adminid,newpassword);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Admin findAdminById(Admin admin) {
|
||||
return dao.findAdminById(admin.getA_id());
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package service.impl;
|
||||
|
||||
import dao.CDCDao;
|
||||
import dao.impl.CDCDaoImpl;
|
||||
import domain.CDC;
|
||||
import service.CDCService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CDCServiceImpl implements CDCService {
|
||||
private CDCDao dao = new CDCDaoImpl();
|
||||
|
||||
@Override
|
||||
public List<CDC> findAllCollege() {
|
||||
return dao.findAllCollege();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CDC> findAllDepartment() {
|
||||
return dao.findAllDepartment();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CDC> findAllClass() {
|
||||
return dao.findAllClass();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CDC> findAll() {
|
||||
return dao.findAll();
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package service.impl;
|
||||
|
||||
import dao.ComplaintDao;
|
||||
import dao.impl.ComplaintDaoImpl;
|
||||
import domain.Complaint;
|
||||
import service.ComplaintService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ComplaintServiceImpl implements ComplaintService {
|
||||
private ComplaintDao dao = new ComplaintDaoImpl();
|
||||
|
||||
@Override
|
||||
public List<Complaint> findAll() {
|
||||
return dao.findAllComplaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addComplaint(Complaint complaint) {
|
||||
dao.addComplaint(complaint);
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package service.impl;
|
||||
|
||||
import dao.CourseDao;
|
||||
import dao.impl.CourseDaoImpl;
|
||||
import domain.Course;
|
||||
import service.CourseService;
|
||||
|
||||
public class CourseServiceImpl implements CourseService {
|
||||
private CourseDao dao = new CourseDaoImpl();
|
||||
@Override
|
||||
public void addOptionalCourse(Course course) {
|
||||
dao.addOptionalCourse(course);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Course findSelectCourseByCourseId(String cid) {
|
||||
return dao.findSelectCourseByCourseId(cid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteServiceById(String cid) {
|
||||
dao.deleteServiceById(cid);
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package service.impl;
|
||||
|
||||
import dao.NotifyDao;
|
||||
import dao.impl.NotifyDaoImpl;
|
||||
import domain.Notify;
|
||||
import service.NotifyService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class NotifyServiceImpl implements NotifyService {
|
||||
private NotifyDao dao = new NotifyDaoImpl();
|
||||
|
||||
@Override
|
||||
public void addNotify(Notify notify) {
|
||||
dao.add(notify);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Notify> find() {
|
||||
return dao.findNotify();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Notify> findAll() {
|
||||
return dao.findAllNotify();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteNotifyById(String notifyid) {
|
||||
dao.deleteNotifyById(notifyid);
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package service.impl;
|
||||
|
||||
import dao.PhotoDao;
|
||||
import dao.impl.PhotoDaoImpl;
|
||||
import domain.Photo;
|
||||
import service.PhotoService;
|
||||
|
||||
public class PhotoServiceImpl implements PhotoService {
|
||||
private PhotoDao dao = new PhotoDaoImpl();
|
||||
|
||||
@Override
|
||||
public void addPhoto(Photo photo) {
|
||||
dao.addPhoto(photo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Photo findPhotoByPhotoId(String id) {
|
||||
return dao.findPhotoByPhotoId(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePhoto(Photo photo) {
|
||||
dao.updatePhoto(photo);
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package service.impl;
|
||||
|
||||
import dao.SelectCourseDao;
|
||||
import dao.impl.SelectCourseDaoImpl;
|
||||
import domain.SelectCourse;
|
||||
import service.SelectCourseService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SelectCourseServiceImpl implements SelectCourseService {
|
||||
private SelectCourseDao dao = new SelectCourseDaoImpl();
|
||||
|
||||
@Override
|
||||
public List<SelectCourse> findStudentSelectedCourseByCourseId(String cid) {
|
||||
return dao.findStudentSelectedCourseByCourseId(cid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SelectCourse findScoreByCourseIdAndStudentId(String cid, String sid) {
|
||||
return dao.findScoreByCourseIdAndStudentId(cid,sid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void upDateScoreByCidAndSid(String cid, String sid, String sScore) {
|
||||
dao.upDateScoreByCidAndSid(cid,sid,sScore);
|
||||
}
|
||||
}
|
@ -0,0 +1,114 @@
|
||||
package service.impl;
|
||||
|
||||
import dao.StudentDao;
|
||||
import dao.impl.StudentDaoImpl;
|
||||
import domain.Course;
|
||||
import domain.PageBean;
|
||||
import domain.SelectCourse;
|
||||
import domain.Student;
|
||||
import service.StudentService;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class StudentServiceImpl implements StudentService {
|
||||
private StudentDao dao = new StudentDaoImpl();
|
||||
|
||||
@Override
|
||||
public PageBean<Student> findStudentByPage(String _currentPage, String _rows, Map<String, String[]> condition) {
|
||||
|
||||
int currentPage = Integer.parseInt(_currentPage);
|
||||
int rows = Integer.parseInt(_rows);
|
||||
|
||||
//创建新的PageBean对象
|
||||
PageBean<Student> pb = new PageBean<Student>();
|
||||
|
||||
//设置参数
|
||||
pb.setCurrentPage(currentPage);
|
||||
pb.setRows(rows);
|
||||
|
||||
//调用dao查询总记录数
|
||||
int totalCount = dao.findTotalCount(condition);
|
||||
pb.setTotalCount(totalCount);
|
||||
|
||||
//调用dao查询List集合
|
||||
//计算开始记录的索引
|
||||
int start = (currentPage - 1) * rows;
|
||||
List<Student>list = dao.findByPage(start,rows,condition);
|
||||
pb.setList(list);
|
||||
|
||||
//计算总页码
|
||||
int totalPage = (totalCount % rows) == 0 ? totalCount/rows : (totalCount/rows) + 1;
|
||||
pb.setTotalPage(totalPage);
|
||||
return pb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Student> findAll() {
|
||||
return dao.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Student login(Student student) {
|
||||
return dao.findStudentidAndPassword(student.getS_id(),student.getS_password());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Student findStudentById(Student student) {
|
||||
return dao.findStudentById(student.getS_id());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(Student student) {
|
||||
dao.addStudent(student);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateInfo(Student student) {
|
||||
dao.updateInfo(student);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePassword(String studentid, String newpassword) {
|
||||
dao.updatePassword(studentid,newpassword);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SelectCourse> findAllSelectCourse(String studentid) {
|
||||
return dao.findAllSelectCourse(studentid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Course> findAllOptionalCourse() {
|
||||
return dao.findAllOptionalCourse();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSelectCourse(String studentid, String courseid) {
|
||||
dao.addSelectCourse(studentid,courseid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteStudentById(String studentid) {
|
||||
dao.deleteStudentById(studentid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteSelectStudent(String[] sids) {
|
||||
if (sids != null && sids.length > 0) {
|
||||
for (String sid: sids) {
|
||||
dao.deleteStudentById(sid);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addStudentAllInfo(Student updateStudent) {
|
||||
dao.addStudentAllInfo(updateStudent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SelectCourse> findSelectCourseAllStudent() {
|
||||
return dao.findSelectCourseAllStudent();
|
||||
}
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
package service.impl;
|
||||
|
||||
import dao.TeacherDao;
|
||||
import domain.Course;
|
||||
import domain.Teacher;
|
||||
import dao.impl.TeacherDaoImpl;
|
||||
import service.TeacherService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TeacherServiceImpl implements TeacherService {
|
||||
private TeacherDao dao = new TeacherDaoImpl();
|
||||
|
||||
@Override
|
||||
public Teacher login(Teacher teacher) {
|
||||
return dao.findTeacheridAndPassword(teacher.getT_id(),teacher.getT_password());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Teacher> findAll() {
|
||||
return dao.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Course> findMySelfOptionalCourse(String T_id) {
|
||||
return dao.findMySelfOptionalCourse(T_id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Course findOptionalCourseByCourseId(String cid) {
|
||||
return dao.findOptionalCourseByCourseId(cid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCourseInfo(Course updateCourse) {
|
||||
dao.updateCourseInfo(updateCourse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteCourseById(String cid) {
|
||||
dao.deleteCourseById(cid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePassword(String teacherid, String newpassword) {
|
||||
dao.updatePassword(teacherid,newpassword);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Teacher findTeacherById(Teacher teacher) {
|
||||
return dao.findTeacherById(teacher.getT_id());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTeacherAllInfo(Teacher updateTeacher) {
|
||||
dao.addTeacherAllInfo(updateTeacher);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteTeacherById(String teacherid) {
|
||||
dao.deleteTeacherById(teacherid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateInfo(Teacher updateTeacher) {
|
||||
dao.updateInfo(updateTeacher);
|
||||
}
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
package utils;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSourceFactory;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* Druid连接池工具类,将来dao层调用
|
||||
*/
|
||||
public class JDBCUtils {
|
||||
private static DataSource dataSource; //定义成员变量DataSource
|
||||
static {
|
||||
try {
|
||||
//加载配置文件
|
||||
Properties properties = new Properties();
|
||||
properties.load(JDBCUtils.class.getClassLoader().getResourceAsStream("druid.properties"));
|
||||
|
||||
//获取DataSource
|
||||
dataSource = DruidDataSourceFactory.createDataSource(properties);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取连接
|
||||
*/
|
||||
public static Connection getConnection() throws SQLException {
|
||||
return dataSource.getConnection();
|
||||
}
|
||||
|
||||
/**
|
||||
* 释放资源
|
||||
*/
|
||||
public static void close(Statement statement,Connection connection) {
|
||||
close(null,statement,connection);
|
||||
}
|
||||
|
||||
public static void close(ResultSet resultSet, Statement statement, Connection connection) {
|
||||
if (resultSet != null) {
|
||||
try {
|
||||
resultSet.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (statement != null) {
|
||||
try {
|
||||
statement.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (connection != null) {
|
||||
try {
|
||||
connection.close();//归还连接
|
||||
}catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取连接池方法
|
||||
*/
|
||||
public static DataSource getDataSource() {
|
||||
return dataSource;
|
||||
}
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package web.servlet.admin;
|
||||
|
||||
import domain.Student;
|
||||
import service.StudentService;
|
||||
import service.impl.StudentServiceImpl;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
@WebServlet("/addStudentInfoServlet")
|
||||
public class AddStudentInfoServlet extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
request.setCharacterEncoding("utf-8");
|
||||
StudentService service= new StudentServiceImpl();
|
||||
//先进行判断是否已存在该学生
|
||||
String sid = request.getParameter("student-id");
|
||||
Student s = new Student();
|
||||
s.setS_id(sid);
|
||||
Student newStudent = service.findStudentById(s);
|
||||
if (newStudent != null) {
|
||||
request.setAttribute("update_msg","已存在该学生,请重新添加!"+String.format("%tT",new Date()));
|
||||
request.getRequestDispatcher("addStudentServlet").forward(request, response);
|
||||
}else {
|
||||
String name = request.getParameter("student-name");
|
||||
String sex = request.getParameter("student-sex");
|
||||
String age = request.getParameter("student-age");
|
||||
String phone = request.getParameter("student-phone");
|
||||
String email = request.getParameter("student-email");
|
||||
String address = request.getParameter("student-address");
|
||||
String college = request.getParameter("selectCollege");
|
||||
String department = request.getParameter("selectDepartment");
|
||||
String cclass = request.getParameter("selectClass");
|
||||
if ("".equals(college)) {
|
||||
college = "待分配";
|
||||
}
|
||||
if ("".equals(department)) {
|
||||
department = "待分配";
|
||||
}
|
||||
if ("".equals(cclass)) {
|
||||
cclass = "待分配";
|
||||
}
|
||||
|
||||
Student updateStudent = new Student();
|
||||
|
||||
updateStudent.setS_id(sid);
|
||||
updateStudent.setS_name(name);
|
||||
updateStudent.setS_sex(sex);
|
||||
updateStudent.setS_age(age);
|
||||
updateStudent.setS_phone(phone);
|
||||
updateStudent.setS_email(email);
|
||||
updateStudent.setS_address(address);
|
||||
updateStudent.setS_college(college);
|
||||
updateStudent.setS_department(department);
|
||||
updateStudent.setS_class(cclass);
|
||||
|
||||
service.addStudentAllInfo(updateStudent);
|
||||
request.setAttribute("update_msg","添加成功!"+String.format("%tT",new Date()));
|
||||
request.getRequestDispatcher("addStudentServlet").forward(request, response);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
doPost(request,response);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package web.servlet.admin;
|
||||
|
||||
import domain.CDC;
|
||||
import domain.Student;
|
||||
import service.CDCService;
|
||||
import service.StudentService;
|
||||
import service.impl.CDCServiceImpl;
|
||||
import service.impl.StudentServiceImpl;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@WebServlet("/addStudentServlet")
|
||||
public class AddStudentServlet extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
request.setCharacterEncoding("utf-8");
|
||||
HttpSession session = request.getSession();
|
||||
|
||||
CDCService service2 = new CDCServiceImpl();
|
||||
List<CDC> collegeList = service2.findAllCollege();
|
||||
List<CDC> departmentList = service2.findAllDepartment();
|
||||
List<CDC> classList = service2.findAllClass();
|
||||
|
||||
session.setAttribute("collegeLists",collegeList);
|
||||
session.setAttribute("departmentLists",departmentList);
|
||||
session.setAttribute("classLists",classList);
|
||||
|
||||
request.getRequestDispatcher("/WEB-INF/admin/addStudent.jsp").forward(request,response);
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
doPost(request,response);
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package web.servlet.admin;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
@WebServlet("/adminPasswordIndexServlet")
|
||||
public class AdminPasswordIndexServlet extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
request.getRequestDispatcher("/WEB-INF/admin/adminUpdatePassword.jsp").forward(request,response);
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
doPost(request,response);
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package web.servlet.admin;
|
||||
|
||||
import domain.Admin;
|
||||
import domain.Student;
|
||||
import service.AdminService;
|
||||
import service.StudentService;
|
||||
import service.impl.AdminServiceImpl;
|
||||
import service.impl.StudentServiceImpl;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
@WebServlet("/adminPasswordUpdateServlet")
|
||||
public class AdminPasswordUpdateServlet extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
request.setCharacterEncoding("utf-8");
|
||||
HttpSession session = request.getSession();
|
||||
Admin admin= (Admin) session.getAttribute("admin");
|
||||
|
||||
String adminid = admin.getA_id();
|
||||
String newpassword = request.getParameter("admin-newpassword");
|
||||
String ennewpassword = request.getParameter("admin-ennewpassword");
|
||||
String regex = "^[\\w]{3,12}$";
|
||||
boolean flag = newpassword.matches(regex);
|
||||
if (!flag) {
|
||||
request.setAttribute("update_msg", "密码格式错误,重新提交!"+String.format("%tT",new Date()));
|
||||
request.getRequestDispatcher("/WEB-INF/admin/adminUpdatePassword.jsp").forward(request, response);
|
||||
} else if (!newpassword.equals(ennewpassword)) {
|
||||
request.setAttribute("update_msg", "密码确认错误,请重新提交!" + String.format("%tT", new Date()));
|
||||
request.getRequestDispatcher("/WEB-INF/admin/adminUpdatePassword.jsp").forward(request, response);
|
||||
} else {
|
||||
|
||||
AdminService service= new AdminServiceImpl();
|
||||
service.updatePassword(adminid,newpassword);
|
||||
|
||||
Admin newAdmin = service.findAdminById(admin);
|
||||
admin = newAdmin;
|
||||
session.setAttribute("admin",admin);
|
||||
|
||||
request.setAttribute("update_msg", "修改成功!" + String.format("%tT", new Date()));
|
||||
request.getRequestDispatcher("/WEB-INF/admin/adminUpdatePassword.jsp").forward(request, response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
doPost(request,response);
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package web.servlet.admin;
|
||||
|
||||
import domain.Course;
|
||||
import service.CourseService;
|
||||
import service.StudentService;
|
||||
import service.impl.CourseServiceImpl;
|
||||
import service.impl.StudentServiceImpl;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.IOException;
|
||||
|
||||
@WebServlet("/doDeleteSelectCourseServlet")
|
||||
public class DoDeleteSelectCourseServlet extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
request.setCharacterEncoding("utf-8");
|
||||
HttpSession session = request.getSession();
|
||||
String cid = request.getParameter("cid");
|
||||
CourseService service = new CourseServiceImpl();
|
||||
service.deleteServiceById(cid);
|
||||
request.getRequestDispatcher("/studentOptionalCourseServlet").forward(request,response);
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
doPost(request,response);
|
||||
}
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
package web.servlet.admin;
|
||||
|
||||
|
||||
|
||||
import domain.CDC;
|
||||
import domain.Student;
|
||||
import service.CDCService;
|
||||
import service.StudentService;
|
||||
import service.impl.CDCServiceImpl;
|
||||
import service.impl.StudentServiceImpl;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@WebServlet("/updateStudentInfoServlet")
|
||||
public class UpdateStudentInfoServlet extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
|
||||
request.setCharacterEncoding("utf-8");
|
||||
// HttpSession session = request.getSession();
|
||||
String sid = request.getParameter("student-id");
|
||||
System.out.println("sid:"+sid);
|
||||
|
||||
|
||||
//保存输入内容
|
||||
String name = request.getParameter("student-name");
|
||||
System.out.println("sname:"+name);
|
||||
String sex = request.getParameter("student-sex");
|
||||
System.out.println("ssex:"+sex);
|
||||
String age = request.getParameter("student-age");
|
||||
String phone = request.getParameter("student-phone");
|
||||
String email = request.getParameter("student-email");
|
||||
String address = request.getParameter("student-address");
|
||||
|
||||
String college = request.getParameter("selectCollege");
|
||||
String department = request.getParameter("selectDepartment");
|
||||
String cclass = request.getParameter("selectClass");
|
||||
|
||||
Student updateStudent = new Student();
|
||||
|
||||
//判断输入位数是否大于数据库位数
|
||||
if (name.length() > 4 || phone.length() > 11 || email.length()>24 || address.length() > 24 || age.length()>2 || name.contains("<") || phone.contains("<") || email.contains("<") || address.contains("<") || age.contains("<")) {
|
||||
request.setAttribute("update_msg","格式错误,请重新提交!"+String.format("%tT",new Date()));
|
||||
request.getRequestDispatcher("updateStudentServlet?sid="+sid).forward(request, response);
|
||||
}else {
|
||||
//封装学生对象
|
||||
updateStudent.setS_id(sid);
|
||||
updateStudent.setS_name(name);
|
||||
updateStudent.setS_sex(sex);
|
||||
updateStudent.setS_age(age);
|
||||
updateStudent.setS_phone(phone);
|
||||
updateStudent.setS_email(email);
|
||||
updateStudent.setS_address(address);
|
||||
updateStudent.setS_college(college);
|
||||
updateStudent.setS_department(department);
|
||||
updateStudent.setS_class(cclass);
|
||||
|
||||
//调用studentUpdata服务
|
||||
StudentService service= new StudentServiceImpl();
|
||||
service.updateInfo(updateStudent);
|
||||
|
||||
//成功则返回并给提示
|
||||
request.setAttribute("update_msg", "修改成功!"+String.format("%tT",new Date()));
|
||||
request.getRequestDispatcher("updateStudentServlet?sid="+sid).forward(request, response);
|
||||
}
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
doPost(request,response);
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package web.servlet.admin;
|
||||
|
||||
import domain.CDC;
|
||||
import domain.Student;
|
||||
import service.CDCService;
|
||||
import service.StudentService;
|
||||
import service.impl.CDCServiceImpl;
|
||||
import service.impl.StudentServiceImpl;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@WebServlet("/updateStudentServlet")
|
||||
public class UpdateStudentServlet extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
request.setCharacterEncoding("utf-8");
|
||||
HttpSession session = request.getSession();
|
||||
String studentid = request.getParameter("sid");
|
||||
// session.setAttribute("sid",studentid);
|
||||
|
||||
Student student = new Student();
|
||||
student.setS_id(studentid);
|
||||
StudentService service = new StudentServiceImpl();
|
||||
Student newStudent = service.findStudentById(student);
|
||||
request.setAttribute("student",newStudent);
|
||||
|
||||
CDCService service2 = new CDCServiceImpl();
|
||||
List<CDC> collegeList = service2.findAllCollege();
|
||||
List<CDC> departmentList = service2.findAllDepartment();
|
||||
List<CDC> classList = service2.findAllClass();
|
||||
|
||||
session.setAttribute("collegeLists",collegeList);
|
||||
session.setAttribute("departmentLists",departmentList);
|
||||
session.setAttribute("classLists",classList);
|
||||
|
||||
request.getRequestDispatcher("/WEB-INF/admin/updateStudent.jsp").forward(request,response);
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
doPost(request,response);
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package web.servlet.cdc;
|
||||
|
||||
import domain.Admin;
|
||||
import domain.CDC;
|
||||
import domain.Student;
|
||||
import domain.Teacher;
|
||||
import service.CDCService;
|
||||
import service.StudentService;
|
||||
import service.impl.CDCServiceImpl;
|
||||
import service.impl.StudentServiceImpl;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@WebServlet("/cdcListServlet")
|
||||
public class CDCListServlet extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
request.setCharacterEncoding("utf-8");
|
||||
//调用StudentService完成查询
|
||||
CDCService service = new CDCServiceImpl();
|
||||
List<CDC> cdcs = service.findAll();
|
||||
//将list存入request域
|
||||
request.setAttribute("cdcs",cdcs);
|
||||
|
||||
HttpSession session = request.getSession();
|
||||
Student student= (Student)session.getAttribute("student");
|
||||
Admin admin= (Admin)session.getAttribute("admin");
|
||||
Teacher teacher= (Teacher)session.getAttribute("teacher");
|
||||
|
||||
if (student != null && admin == null && teacher == null) {
|
||||
request.getRequestDispatcher("/WEB-INF/student/sCDCList.jsp").forward(request, response);
|
||||
} else if (admin != null && student == null && teacher == null) {
|
||||
request.getRequestDispatcher("/WEB-INF/admin/aCDCList.jsp").forward(request, response);
|
||||
} else if (teacher != null && admin == null && student == null) {
|
||||
request.getRequestDispatcher("/WEB-INF/teacher/tCDCList.jsp").forward(request, response);
|
||||
} else {
|
||||
request.getRequestDispatcher("error.jsp").forward(request, response);
|
||||
}
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
this.doPost(request,response);
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package web.servlet.complaints;
|
||||
|
||||
import domain.Complaint;
|
||||
import service.ComplaintService;
|
||||
import service.NotifyService;
|
||||
import service.impl.ComplaintServiceImpl;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
@WebServlet("/addComplaintsServlet")
|
||||
public class AddComplaintsServlet extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
request.setCharacterEncoding("utf-8");
|
||||
|
||||
//获取参数
|
||||
Complaint complaint = new Complaint();
|
||||
|
||||
String text = (String) request.getParameter("complaint");
|
||||
|
||||
if (text.contains("script") && text.contains("/script")) {
|
||||
text = text.replace("script","");
|
||||
text = text.replace("/script","");
|
||||
}
|
||||
|
||||
if (!text.equals("")) {
|
||||
complaint.setContent(text);
|
||||
Date d = new Date();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
complaint.setCdate(sdf.format(d));
|
||||
ComplaintService service = new ComplaintServiceImpl();
|
||||
service.addComplaint(complaint);
|
||||
}
|
||||
|
||||
response.sendRedirect("complaintServlet");
|
||||
// request.getRequestDispatcher("/complaintListServlet").forward(request,response);
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
doPost(request,response);
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package web.servlet.complaints;
|
||||
|
||||
import domain.Complaint;
|
||||
import service.ComplaintService;
|
||||
import service.impl.ComplaintServiceImpl;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@WebServlet("/complaintListServlet")
|
||||
public class ComplaintListServlet extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
request.setCharacterEncoding("utf-8");
|
||||
ComplaintService service = new ComplaintServiceImpl();
|
||||
List<Complaint> complaints = service.findAll();
|
||||
request.setAttribute("complaints",complaints);
|
||||
request.getRequestDispatcher("/WEB-INF/complaint/complaintsList.jsp").forward(request,response);
|
||||
}
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
doPost(request,response);
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package web.servlet.complaints;
|
||||
|
||||
import domain.Complaint;
|
||||
import service.ComplaintService;
|
||||
import service.impl.ComplaintServiceImpl;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@WebServlet("/complaintServlet")
|
||||
public class ComplaintServlet extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
request.setCharacterEncoding("utf-8");
|
||||
ComplaintService service = new ComplaintServiceImpl();
|
||||
List<Complaint> complaints = service.findAll();
|
||||
request.setAttribute("complaints",complaints);
|
||||
request.getRequestDispatcher("/WEB-INF/complaint/complaintsList.jsp").forward(request,response);
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
doPost(request,response);
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package web.servlet.file;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
@WebServlet("/deleteFileServlet")
|
||||
public class DeleteFileServlet extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
request.setCharacterEncoding("utf-8");
|
||||
String fileName = request.getParameter("filename");
|
||||
File file = new File(this.getServletContext().getRealPath("upload")+File.separator+fileName);
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
request.getRequestDispatcher("/fileListServlet").forward(request,response);
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
doPost(request,response);
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package web.servlet.file;
|
||||
|
||||
import domain.Admin;
|
||||
import domain.Student;
|
||||
import domain.Teacher;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
@WebServlet("/downloadServlet")
|
||||
public class DownloadServlet extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
String filename = request.getParameter("filename");
|
||||
if (filename.equalsIgnoreCase("../") || filename.equalsIgnoreCase("/")) {
|
||||
request.getRequestDispatcher("error.jsp").forward(request, response);
|
||||
}
|
||||
response.addHeader("content-Type", "application/octet-stream");
|
||||
|
||||
String agent = request.getHeader("User-Agent");
|
||||
|
||||
if (agent.toLowerCase().indexOf("chrome") > 0) {
|
||||
response.addHeader("content-Disposition", "attachment;filename=" + new String(filename.getBytes("UTF-8"), "ISO8859-1"));
|
||||
} else {
|
||||
response.addHeader("content-Disposition", "attachment;filename=" + URLEncoder.encode(filename, "UTF-8"));
|
||||
}
|
||||
InputStream in = getServletContext().getResourceAsStream("/upload/" + filename);
|
||||
ServletOutputStream out = response.getOutputStream();
|
||||
byte[] bs = new byte[1024];
|
||||
int len = -1;
|
||||
while ((len = in.read(bs)) != -1) {
|
||||
out.write(bs, 0, len);
|
||||
}
|
||||
out.close();
|
||||
in.close();
|
||||
|
||||
HttpSession session = request.getSession();
|
||||
Student student= (Student)session.getAttribute("student");
|
||||
Admin admin= (Admin)session.getAttribute("admin");
|
||||
Teacher teacher= (Teacher)session.getAttribute("teacher");
|
||||
if (student != null && admin == null && teacher == null) {
|
||||
request.getRequestDispatcher("/WEB-INF/student/sFindFileList.jsp").forward(request, response);
|
||||
} else if (admin != null && student == null && teacher == null) {
|
||||
request.getRequestDispatcher("/WEB-INF/admin/aFindFileList.jsp").forward(request, response);
|
||||
} else if (teacher != null && admin == null && student == null) {
|
||||
request.getRequestDispatcher("/WEB-INF/teacher/tFindFileList.jsp").forward(request, response);
|
||||
} else {
|
||||
request.getRequestDispatcher("error.jsp").forward(request, response);
|
||||
}
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
doPost(request, response);
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package web.servlet.file;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
@WebServlet("/fileServlet")
|
||||
public class FileServlet extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
request.getRequestDispatcher("/WEB-INF/admin/uploadFile.jsp").forward(request,response);
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
doPost(request,response);
|
||||
}
|
||||
}
|
@ -0,0 +1,107 @@
|
||||
package web.servlet.file;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.File;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import org.apache.commons.fileupload.FileItem;
|
||||
import org.apache.commons.fileupload.FileItemFactory;
|
||||
import org.apache.commons.fileupload.FileUploadException;
|
||||
import org.apache.commons.fileupload.ProgressListener;
|
||||
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
|
||||
import org.apache.commons.fileupload.servlet.ServletFileUpload;
|
||||
|
||||
@WebServlet("/uploadServlet")
|
||||
public class UploadServlet extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
request.setCharacterEncoding("utf-8");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setContentType("text/html; charset=utf-8");
|
||||
|
||||
|
||||
boolean isMultipart=ServletFileUpload.isMultipartContent(request);
|
||||
if (isMultipart) {
|
||||
FileItemFactory factory = new DiskFileItemFactory();
|
||||
ServletFileUpload upload = new ServletFileUpload(factory);
|
||||
upload.setHeaderEncoding("utf-8");
|
||||
|
||||
// upload.setProgressListener(new ProgressListener(){
|
||||
// public void update(long pBytesRead, long pContentLength, int pItems) {
|
||||
// ProcessInfo pri = new ProcessInfo();
|
||||
// pri.itemNum = pItems;
|
||||
// pri.readSize = pBytesRead;
|
||||
// pri.totalSize = pContentLength;
|
||||
// pri.show = pBytesRead+"/"+pContentLength+" byte";
|
||||
// pri.rate = Math.round(new Float(pBytesRead) / new Float(pContentLength)*100);
|
||||
// hs.setAttribute("proInfo", pri);
|
||||
// }
|
||||
// });
|
||||
|
||||
try {
|
||||
List<FileItem> items = upload.parseRequest(request);
|
||||
Iterator<FileItem> it = items.iterator();
|
||||
while (it.hasNext()) {
|
||||
FileItem item = it.next();
|
||||
String itemname = item.getFieldName();
|
||||
int sno = -1;
|
||||
String sname = null;
|
||||
|
||||
if (item.isFormField()) {
|
||||
if (itemname.equals("sno")) {
|
||||
sno = Integer.parseInt(item.getString("utf-8"));
|
||||
} else if (itemname.equals("sname")) {
|
||||
sname = item.getString("utf-8");
|
||||
sname = item.getName();
|
||||
} else {
|
||||
System.out.println("其他字段");
|
||||
}
|
||||
} else {
|
||||
String filename = item.getName();
|
||||
//String path=request.getSession().getServletContext().getRealPath("upload");
|
||||
String path = this.getServletContext().getRealPath("upload");
|
||||
if (filename.substring(filename.lastIndexOf(".") + 1).equals("jsp")
|
||||
|| filename.substring(filename.lastIndexOf(".") + 1).equals("htm")
|
||||
|| filename.substring(filename.lastIndexOf(".") + 1).equals("html")) {
|
||||
request.getRequestDispatcher("error.jsp").forward(request, response);
|
||||
} else {
|
||||
System.out.println(path);
|
||||
File file = new File(path);
|
||||
if (!file.exists() && !file.isDirectory()) {
|
||||
file.mkdir();
|
||||
}
|
||||
item.write(new File(path, filename));
|
||||
request.setAttribute("news", filename + " 上传成功!");
|
||||
request.getRequestDispatcher("/WEB-INF/admin/uploadFile.jsp").forward(request, response);
|
||||
// response.sendRedirect("fileUploadIndexServlet");
|
||||
System.out.println(filename + "上传成功!!!");
|
||||
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
} catch (FileUploadException e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ProcessInfo{
|
||||
public long totalSize = 1;
|
||||
public long readSize = 0;
|
||||
public String show = "";
|
||||
public int itemNum = 0;
|
||||
public int rate = 0;
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
doPost(request, response);
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package web.servlet.index;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
@WebServlet("/adminIndexServlet")
|
||||
public class AdminIndexServlet extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
request.getRequestDispatcher("/WEB-INF/admin/aIndex.jsp").forward(request,response);
|
||||
}
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
doPost(request,response);
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package web.servlet.index;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
@WebServlet("/studentIndexServlet")
|
||||
public class StudentIndexServlet extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
request.getRequestDispatcher("/WEB-INF/student/sIndex.jsp").forward(request,response);
|
||||
}
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
doPost(request,response);
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package web.servlet.index;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
@WebServlet("/teacherIndexServlet")
|
||||
public class TeacherIndexServlet extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
request.getRequestDispatcher("/WEB-INF/teacher/tIndex.jsp").forward(request,response);
|
||||
}
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
doPost(request,response);
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package web.servlet.login;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import domain.Student;
|
||||
import service.StudentService;
|
||||
import service.impl.StudentServiceImpl;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@WebServlet("/findStudentServlet")
|
||||
public class FindStudentServlet extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
response.setContentType("application/json;charset=utf-8");
|
||||
String studentId = request.getParameter("studentid");
|
||||
Student student = new Student();
|
||||
Student findStudent = new Student();
|
||||
student.setS_id(studentId);
|
||||
StudentService service = new StudentServiceImpl();
|
||||
findStudent = service.findStudentById(student);
|
||||
Map<String,Object>map = new HashMap<String,Object>();
|
||||
|
||||
try {
|
||||
if (studentId.equals(findStudent.getS_id())) {
|
||||
map.put("studentExsit", true);
|
||||
map.put("msg", "ID已存在");
|
||||
} else {
|
||||
map.put("studentExsit", false);
|
||||
map.put("msg", "用户名可用");
|
||||
}
|
||||
//map转为json传给客户端
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.writeValue(response.getWriter(),map);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
doPost(request,response);
|
||||
}
|
||||
}
|
@ -0,0 +1,133 @@
|
||||
package web.servlet.login;
|
||||
|
||||
import domain.Admin;
|
||||
import domain.Notify;
|
||||
import domain.Student;
|
||||
import domain.Teacher;
|
||||
import org.apache.commons.beanutils.BeanUtils;
|
||||
import service.AdminService;
|
||||
import service.NotifyService;
|
||||
import service.StudentService;
|
||||
import service.TeacherService;
|
||||
import service.impl.AdminServiceImpl;
|
||||
import service.impl.NotifyServiceImpl;
|
||||
import service.impl.StudentServiceImpl;
|
||||
import service.impl.TeacherServiceImpl;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@WebServlet("/loginServlet")
|
||||
public class LoginServlet extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
Student loginStudent = null;
|
||||
Teacher loginTeacher = null;
|
||||
Admin loginAdmin = null;
|
||||
|
||||
//设置编码
|
||||
request.setCharacterEncoding("utf-8");
|
||||
|
||||
//获取数据
|
||||
String verifycode = request.getParameter("verifycode");
|
||||
String loginid = request.getParameter("id");
|
||||
String loginpassword = request.getParameter("password");
|
||||
|
||||
//验证码校验
|
||||
HttpSession session = request.getSession();
|
||||
String checkcode_server = (String) session.getAttribute("CHECKCODE_SERVER");
|
||||
session.removeAttribute("CHECKCODE_SERVER");//确保验证一次性
|
||||
if (checkcode_server == null || !checkcode_server.equalsIgnoreCase(verifycode)) {
|
||||
//验证码不正确
|
||||
request.setAttribute("login_msg","验证码错误");
|
||||
//跳转页面
|
||||
request.setAttribute("loginid",loginid);
|
||||
request.setAttribute("loginpassword",loginpassword);
|
||||
request.getRequestDispatcher("/login.jsp").forward(request,response);
|
||||
return;
|
||||
}
|
||||
//封装对象
|
||||
String id = request.getParameter("id");
|
||||
String password = request.getParameter("password");
|
||||
String roles = request.getParameter("roles");
|
||||
|
||||
//公告加载
|
||||
NotifyService notifyService= new NotifyServiceImpl();
|
||||
List<Notify> notifys = notifyService.find();
|
||||
session.setAttribute("notifys",notifys);
|
||||
|
||||
//判断roles封装对象、保存session、调用不同Service查询
|
||||
if ("student".equals(roles)) {
|
||||
|
||||
Student student = new Student();
|
||||
student.setS_id(id);
|
||||
student.setS_password(password);
|
||||
|
||||
StudentService service= new StudentServiceImpl();
|
||||
loginStudent = service.login(student);
|
||||
|
||||
if (loginStudent != null) {
|
||||
session.setAttribute("student", loginStudent);
|
||||
session.setAttribute("html_title", "学生端");
|
||||
// request.getRequestDispatcher("/WEB-INF/student/sIndex.jsp").forward(request,response);
|
||||
response.sendRedirect("studentIndexServlet");
|
||||
}else {
|
||||
//登录失败 提示信息
|
||||
request.setAttribute("login_msg", "用户名或密码错误!");
|
||||
request.setAttribute("loginid",loginid);
|
||||
request.setAttribute("loginpassword",loginpassword);
|
||||
request.getRequestDispatcher("/login.jsp").forward(request, response);
|
||||
}
|
||||
}else if ("teacher".equals(roles)) {
|
||||
|
||||
Teacher teacher = new Teacher();
|
||||
teacher.setT_id(id);
|
||||
teacher.setT_password(password);
|
||||
|
||||
TeacherService service = new TeacherServiceImpl();
|
||||
loginTeacher = service.login(teacher);
|
||||
|
||||
if (loginTeacher != null) {
|
||||
session.setAttribute("teacher", loginTeacher);
|
||||
session.setAttribute("html_title", "教师端");
|
||||
// request.getRequestDispatcher("/WEB-INF/teacher/tIndex.jsp").forward(request, response);
|
||||
response.sendRedirect("teacherIndexServlet");
|
||||
}else {
|
||||
//登录失败 提示信息
|
||||
request.setAttribute("login_msg", "用户名或密码错误!");
|
||||
request.getRequestDispatcher("/login.jsp").forward(request, response);
|
||||
}
|
||||
|
||||
}else {
|
||||
|
||||
Admin admin = new Admin();
|
||||
admin.setA_id(id);
|
||||
admin.setA_password(password);
|
||||
|
||||
AdminService service = new AdminServiceImpl();
|
||||
loginAdmin = service.login(admin);
|
||||
|
||||
if (loginAdmin != null) {
|
||||
session.setAttribute("admin", loginAdmin);
|
||||
session.setAttribute("html_title", "管理员");
|
||||
// request.getRequestDispatcher("/WEB-INF/admin/aIndex.jsp").forward(request,response);
|
||||
response.sendRedirect("adminIndexServlet");
|
||||
}else {
|
||||
//登录失败 提示信息
|
||||
request.setAttribute("login_msg", "用户名或密码错误!");
|
||||
request.getRequestDispatcher("/login.jsp").forward(request, response);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
doPost(request,response);
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package web.servlet.login;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.IOException;
|
||||
|
||||
@WebServlet("/logoutServlet")
|
||||
public class LogoutServlet extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
request.setCharacterEncoding("UTF-8");
|
||||
HttpSession session = request.getSession();
|
||||
session.removeAttribute("student");
|
||||
session.removeAttribute("teacher");
|
||||
session.removeAttribute("admin");
|
||||
session.invalidate();
|
||||
response.sendRedirect("index.jsp");
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
doPost(request,response);
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package web.servlet.login;
|
||||
|
||||
import domain.Student;
|
||||
import service.StudentService;
|
||||
import service.impl.StudentServiceImpl;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.*;
|
||||
import java.io.IOException;
|
||||
|
||||
@WebServlet("/registerServlet")
|
||||
public class RegisterServlet extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
HttpSession session = request.getSession();
|
||||
String studentid = request.getParameter("studentid");
|
||||
String password = request.getParameter("password");
|
||||
String repassword = request.getParameter("repassword");
|
||||
String vcode = request.getParameter("verifycode");
|
||||
|
||||
String checkcode_server = (String) session.getAttribute("CHECKCODE_SERVER");
|
||||
session.removeAttribute("CHECKCODE_SERVER");//确保验证一次性
|
||||
if (!vcode.equalsIgnoreCase(checkcode_server)){
|
||||
request.setAttribute("msg","验证码错误");
|
||||
request.setAttribute("studentid",studentid);
|
||||
request.setAttribute("password",password);
|
||||
request.setAttribute("repassword",repassword);
|
||||
request.getRequestDispatcher("register.jsp").forward(request,response);
|
||||
return;
|
||||
}else {
|
||||
Student student = new Student();
|
||||
student.setS_id(studentid);
|
||||
student.setS_password(password);
|
||||
System.out.println(studentid);
|
||||
System.out.println(password);
|
||||
StudentService service= new StudentServiceImpl();
|
||||
service.register(student);
|
||||
request.setAttribute("msg","注册成功");
|
||||
request.setAttribute("studentid","");
|
||||
request.setAttribute("password","");
|
||||
request.setAttribute("repassword","");
|
||||
request.getRequestDispatcher("register.jsp").forward(request,response);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
doPost(request,response);
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package web.servlet.notify;
|
||||
|
||||
import domain.Notify;
|
||||
import org.apache.commons.beanutils.BeanUtils;
|
||||
import service.NotifyService;
|
||||
import service.impl.NotifyServiceImpl;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@WebServlet("/addNotifyServlet")
|
||||
public class AddNotifyServlet extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
request.setCharacterEncoding("utf-8");
|
||||
|
||||
//获取参数
|
||||
Notify notify = new Notify();
|
||||
notify.setNotifyInfo((String) request.getParameter("notifyInfo"));
|
||||
Date d = new Date();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
notify.setNotifyDate(sdf.format(d));
|
||||
NotifyService service = new NotifyServiceImpl();
|
||||
service.addNotify(notify);
|
||||
// response.sendRedirect("/notifyListServlet");
|
||||
request.getRequestDispatcher("/notifyListServlet").forward(request,response);
|
||||
}
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
doPost(request,response);
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package web.servlet.notify;
|
||||
|
||||
import domain.Student;
|
||||
import service.NotifyService;
|
||||
import service.impl.NotifyServiceImpl;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.IOException;
|
||||
|
||||
@WebServlet("/deleteNotifyServlet")
|
||||
public class DeleteNotifyServlet extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
request.setCharacterEncoding("utf-8");
|
||||
HttpSession session = request.getSession();
|
||||
String notifyid = request.getParameter("id");
|
||||
NotifyService service = new NotifyServiceImpl();
|
||||
service.deleteNotifyById(notifyid);
|
||||
request.getRequestDispatcher("/notifyListServlet").forward(request,response);
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
doPost(request,response);
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package web.servlet.notify;
|
||||
|
||||
import domain.Notify;
|
||||
import service.NotifyService;
|
||||
import service.impl.NotifyServiceImpl;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@WebServlet("/notifyListServlet")
|
||||
public class NotifyListServlet extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
request.setCharacterEncoding("utf-8");
|
||||
NotifyService service = new NotifyServiceImpl();
|
||||
List<Notify> notifys = service.findAll();
|
||||
request.setAttribute("notifys",notifys);
|
||||
request.getRequestDispatcher("/WEB-INF/notify/notifyList.jsp").forward(request,response);
|
||||
}
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
doPost(request,response);
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package web.servlet.notify;
|
||||
|
||||
import domain.Admin;
|
||||
import domain.Notify;
|
||||
import domain.Student;
|
||||
import domain.Teacher;
|
||||
import service.NotifyService;
|
||||
import service.impl.NotifyServiceImpl;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@WebServlet("/notifyListToServlet")
|
||||
public class NotifyListToServlet extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
request.setCharacterEncoding("utf-8");
|
||||
NotifyService service = new NotifyServiceImpl();
|
||||
List<Notify> notifys = service.findAll();
|
||||
request.setAttribute("notifys",notifys);
|
||||
|
||||
HttpSession session = request.getSession();
|
||||
Student student= (Student)session.getAttribute("student");
|
||||
Teacher teacher= (Teacher)session.getAttribute("teacher");
|
||||
if (student != null && teacher == null) {
|
||||
request.getRequestDispatcher("/WEB-INF/notify/notifyListToStudent.jsp").forward(request,response);
|
||||
} else if (teacher != null && student == null) {
|
||||
request.getRequestDispatcher("/WEB-INF/notify/notifyListToTeacher.jsp").forward(request,response);
|
||||
} else {
|
||||
request.getRequestDispatcher("error.jsp").forward(request, response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
doPost(request,response);
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package web.servlet.notify;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
@WebServlet("/notifyServlet")
|
||||
public class NotifyServlet extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
request.getRequestDispatcher("/WEB-INF/notify/addNotify.jsp").forward(request,response);
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
doPost(request,response);
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package web.servlet.page;
|
||||
|
||||
import domain.Admin;
|
||||
import domain.PageBean;
|
||||
import domain.Student;
|
||||
import domain.Teacher;
|
||||
import service.StudentService;
|
||||
import service.impl.StudentServiceImpl;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
@WebServlet("/findStudentByPageServlet")
|
||||
public class FindStudentByPageServlet extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
request.setCharacterEncoding("utf-8");
|
||||
String currentPage = request.getParameter("currentPage");//当前页码
|
||||
String rows = request.getParameter("rows");//每页显示条数
|
||||
|
||||
if (currentPage == null || "".equals(currentPage)) {
|
||||
currentPage = "1";
|
||||
}
|
||||
if (rows == null || "".equals(rows)) {
|
||||
rows = "5";
|
||||
}
|
||||
|
||||
//获取条件查询参数
|
||||
Map<String,String[]> condition = request.getParameterMap();
|
||||
|
||||
StudentService service = new StudentServiceImpl();
|
||||
PageBean<Student> pb = service.findStudentByPage(currentPage,rows,condition);
|
||||
|
||||
request.setAttribute("pb",pb);
|
||||
request.setAttribute("condition",condition);//存入查询条件
|
||||
request.setCharacterEncoding("utf-8");
|
||||
HttpSession session = request.getSession();
|
||||
Student student= (Student)session.getAttribute("student");
|
||||
|
||||
Admin admin= (Admin)session.getAttribute("admin");
|
||||
Teacher teacher= (Teacher)session.getAttribute("teacher");
|
||||
if (student != null && admin == null && teacher == null) {
|
||||
request.getRequestDispatcher("/WEB-INF/student/sFindStudentList.jsp").forward(request, response);
|
||||
} else if (admin != null && student == null && teacher == null) {
|
||||
request.getRequestDispatcher("/WEB-INF/admin/aFindStudentList.jsp").forward(request, response);
|
||||
} else if (teacher != null && admin == null && student == null) {
|
||||
request.getRequestDispatcher("/WEB-INF/teacher/tFindStudentList.jsp").forward(request, response);
|
||||
} else {
|
||||
request.getRequestDispatcher("error.jsp").forward(request, response);
|
||||
}
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
doPost(request,response);
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package web.servlet.student;
|
||||
|
||||
import service.StudentService;
|
||||
import service.impl.StudentServiceImpl;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
@WebServlet("/deleteSelectStudentServlet")
|
||||
public class DeleteSelectStudentServlet extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
String[] sids = request.getParameterValues("sid");
|
||||
StudentService service = new StudentServiceImpl();
|
||||
service.deleteSelectStudent(sids);
|
||||
response.sendRedirect(request.getContextPath()+"/findStudentByPageServlet");
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
doPost(request,response);
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package web.servlet.student;
|
||||
|
||||
import service.NotifyService;
|
||||
import service.StudentService;
|
||||
import service.impl.NotifyServiceImpl;
|
||||
import service.impl.StudentServiceImpl;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.IOException;
|
||||
|
||||
@WebServlet("/deleteStudentServlet")
|
||||
public class DeleteStudentServlet extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
request.setCharacterEncoding("utf-8");
|
||||
HttpSession session = request.getSession();
|
||||
String studentid = request.getParameter("s_id");
|
||||
StudentService service = new StudentServiceImpl();
|
||||
service.deleteStudentById(studentid);
|
||||
// request.getRequestDispatcher("/findStudentByPageServlet").forward(request,response);
|
||||
response.sendRedirect("findStudentByPageServlet");
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
doPost(request,response);
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package web.servlet.student;
|
||||
|
||||
import domain.Course;
|
||||
import domain.SelectCourse;
|
||||
import domain.Student;
|
||||
import service.StudentService;
|
||||
import service.impl.StudentServiceImpl;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@WebServlet("/doSelectCourseServlet")
|
||||
public class DoSelectCourseServlet extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
request.setCharacterEncoding("utf-8");
|
||||
HttpSession session = request.getSession();
|
||||
Student student= (Student)session.getAttribute("student");
|
||||
String courseid = request.getParameter("id");
|
||||
//存不存在已选该课
|
||||
boolean flag = false;
|
||||
|
||||
//判断是否已选
|
||||
StudentService studentService = new StudentServiceImpl();
|
||||
List<SelectCourse> selectcourses = studentService.findAllSelectCourse(student.getS_id());
|
||||
for (SelectCourse s:selectcourses) {
|
||||
if (s.getC_id().equals(courseid)) {
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (flag == true) {
|
||||
|
||||
request.setAttribute("select_msg", "你已选了该课程!" + String.format("%tT", new Date()));
|
||||
request.getRequestDispatcher("studentOptionalCourseServlet").forward(request, response);
|
||||
// response.sendRedirect("studentOptionalCourseServlet");
|
||||
} else {
|
||||
//获取到当前学生id
|
||||
String studentid = student.getS_id();
|
||||
|
||||
//获取当前行的课程id courseid
|
||||
|
||||
//调用学生添加选课服务s_id c_id score select_course添加
|
||||
StudentService Service = new StudentServiceImpl();
|
||||
Service.addSelectCourse(studentid,courseid);
|
||||
|
||||
//完成后给提示跳转
|
||||
request.setAttribute("select_msg", "选课成功!" + String.format("%tT", new Date()));
|
||||
request.getRequestDispatcher("studentOptionalCourseServlet").forward(request, response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
doPost(request,response);
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package web.servlet.student;
|
||||
|
||||
import domain.Student;
|
||||
import service.StudentService;
|
||||
import service.impl.StudentServiceImpl;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.IOException;
|
||||
|
||||
@WebServlet("/studentInfomationServlet")
|
||||
public class StudentInfomationServlet extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// HttpSession session = request.getSession();
|
||||
// Student s = (Student) session.getAttribute("student");
|
||||
// StudentService service = new StudentServiceImpl();
|
||||
// Student newStudent = service.findStudentById(s);
|
||||
// session.setAttribute("student",newStudent);
|
||||
request.getRequestDispatcher("/WEB-INF/student/sInformation.jsp").forward(request,response);
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
doPost(request,response);
|
||||
}
|
||||
}
|