基于javaweb+mysql的ssm+maven家教管理系统(java+ssm+mybatis+mysql+maven+html)
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SSM+Maven家教管理系统(java+ssm+mybatis+mysql+maven+html)
该系统分为前台和后台
前台功能有:登录、注册、查看学员、查看教师、个人中心等。
后台功能有:用户管理、学员管理、教师管理、审核管理、公告管理、新闻管理、简历管理等。前台注册分为学员和教师两个角色,学员负责找家教教师、发布需求。教师制作简历供学员选择、联系学员。类似于兼职系统。
本项目如环境一致包运行调试,如有问题可以联系我,右侧有我的联系方式
运行环境:JDK1.8、Mysql5.X、Tomcat7.0/8.5、Maven3.5/3.6、Eclipse
@Controller
@RequestMapping(value="/admin")
public class adminManageUserController {
@Autowired
AdminManageUser adminManageUser;
@Autowired
AdminManageResume adminManageResume;
@Autowired
AdminManagePosition adminManagePosition;
//查找所有的学生应聘者,并查看是否有简历
@RequestMapping(value="/getApplicant",method=RequestMethod.POST)
@ResponseBody
public String getStudents(){
List<Users> allStudents = adminManageUser.getAllStudents();
List<Applicant> applicants = new ArrayList<Applicant>();
Applicant applicant;
for (Users users : allStudents) {
applicant = new Applicant();
applicant.setAid(users.getId());
applicant.setAname(users.getName());
applicant.setEmail(users.getEmail());
List<Resume> resumes = adminManageResume.getResumeByuserId(users.getId());
if(resumes.isEmpty()){
System.out.println("简历列表为空的");
map.put("name", users.getName());
map.put("password", users.getPassword());
map.put("email", users.getEmail());
return map;
}
@RequestMapping(value="/checkEmail",method=RequestMethod.POST)
@ResponseBody
public Map<String, Object> checkEmail(@RequestParam("email")String email){
Map<String, Object> map = new HashMap<String, Object>();
Users users = adminManageUser.getUsersByEmail(email);
if(users == null){
map.put("result", "success");
}else{
map.put("result", "fail");
}
return map;
}
@RequestMapping(value="/updateUserIm",method=RequestMethod.POST)
@ResponseBody
public Map<String, Object> updateUserIm(@RequestParam("password")String password,@RequestParam("email")String email,HttpSession session){
Map<String, Object> map = new HashMap<String, Object>();
String userid = (String)session.getAttribute("loginid");
int id = Integer.parseInt(userid);
Users users = adminManageUser.getUsersByid(id);
if(users != null){
users.setPassword(password);
users.setEmail(email);
adminManageUser.updateUser(users);
map.put("result", "success");
}else{
map.put("result", "fail");
}
return map;
}
@RequestMapping(value="/removeStudent",method=RequestMethod.GET)
public String removeUser(@RequestParam("userid")int userid){
System.out.println("删除的id"+userid);
adminManageUser.deleteUser(userid);
return "system/admin/app_table.html";
}
@RequestMapping(value="/removeParent",method=RequestMethod.GET)
public String removeParent(@RequestParam("userid")int userid){
System.out.println("====删除家长招聘者");
adminManageUser.deleteUser(userid);
return "system/admin/rec_table.html";
List<Position> positions = adminManagePosition.getAuditedPositions();
JSONArray json = new JSONArray();
for (Position po : positions) {
JSONObject jo = new JSONObject();
jo.put("id", po.getId());
Users user = adminManageUser.getUsersByid(po.getUser());
jo.put("username", user.getName());
jo.put("title", po.getName());
jo.put("place", po.getPlace());
jo.put("information", po.getInformation());
jo.put("salary", po.getSalary());
jo.put("contact", po.getContact());
jo.put("createtime", po.getCreatetime());
json.put(jo);
}
System.out.println(json.toString());
return json.toString();
}
// 获取 该用户的招聘信息
@RequestMapping(value="/listPositionByUserid",method=RequestMethod.POST)
@ResponseBody
public String listPositionByUserid(HttpSession session){
System.out.println((String)session.getAttribute("useridforposition"));
int id = Integer.parseInt((String)session.getAttribute("useridforposition"));
System.out.println("=====--==="+id);
List<Position> positions = adminManagePosition.getPositionsByuserId(id);
JSONArray json = new JSONArray();
for (Position po : positions) {
JSONObject jo = new JSONObject();
jo.put("id", po.getId());
jo.put("title", po.getName());
jo.put("place", po.getPlace());
jo.put("information", po.getInformation());
jo.put("salary", po.getSalary());
jo.put("contact", po.getContact());
jo.put("createtime", po.getCreatetime());
json.put(jo);
/**
* 操作 简历的Controller
*/
@Controller
@RequestMapping(value="/admin")
public class adminManageLoginLogController {
@Autowired
private LoginLogService logService;
@RequestMapping(value="/listLogs",method=RequestMethod.POST)
@ResponseBody
public String listLogs(){
List<LoginLog> findLogs = logService.findLogs();
JSONArray json = new JSONArray();
for (LoginLog notice : findLogs) {
JSONObject jo = new JSONObject();
jo.put("userid", notice.getUserid());
jo.put("name", notice.getName());
jo.put("ip", notice.getIp());
jo.put("createtime", notice.getCreatetime());
json.put(jo);
}
System.out.println(json.toString());
return json.toString();
}
}
public class IPUtil {
public static String getIpAddr(HttpServletRequest request) {
String ip = request.getHeader("x-forwarded-for");
if(ip == null || ip.length() == 0 ||"unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
}
if(ip == null || ip.length() == 0 ||"unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP");
}
if(ip == null || ip.length() == 0 ||"unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
}
/**
* 应聘者 controller ,学生做家教
*
*/
@Controller
@RequestMapping("/applicant")
public class ApplicantController {
@Autowired
private CommonService commonService;
@Autowired
private CommentService commentService;
/**
* 搜索家教列表
* @param place
* @param kemu
* @param session
* @return
*/
@RequestMapping(value="/searchTeacher",method=RequestMethod.POST)
@ResponseBody
public Map<String,Object> searchTeacher(@RequestParam("place")String place,@RequestParam("kemu")String kemu,HttpSession session){
Map<String, Object> map = (Map<String, Object>) new HashMap<String, Object>();
map.put("type", "error");
if(StringUtils.isEmpty(place)) {
map.put("message", "请选择区域");
return map;
}
if(StringUtils.isEmpty(kemu)) {
map.put("message", "请选择科目");
map.put("type", "error");
if(StringUtils.isEmpty(username)) {
map.put("message", "请填写用户名");
return map;
}
Users users = commonService.getUsersByName(username);
if(users != null){
//用户名可以使用
map.put("type", "error");
map.put("message", "该用户名已被注册");
return map;
}
map.put("type", "success");
map.put("message", "用户名可以使用");
return map;
}
/**
* 邮箱验证
* @param email
* @return
*/
@RequestMapping(value="/checkEmail",method=RequestMethod.POST)
@ResponseBody
public Map<String, Object> checkEmail(@RequestParam("email")String email){
Map<String, Object> map = new HashMap<String, Object>();
map.put("type", "error");
if(StringUtils.isEmpty(email)) {
map.put("message", "请填写邮箱");
return map;
}
Users users = commonService.getUsersByEmail(email);
if(users != null){
//用户名可以使用
map.put("type", "error");
map.put("message", "该邮箱已被注册");
return map;
}
map.put("type", "success");
map.put("message", "该邮箱可以使用");
return map;
}
/**
* 注册
* @param username
@Autowired
private TnewsService tnewsService;
@Autowired
private LoginLogService logService;
@RequestMapping("/index")
public String index(){
return "system/applicant/index.html";
}
@RequestMapping("/register")
public String register(){
return "system/applicant/register.html";
}
@RequestMapping("/toCreateNote")
public String toCreateNote(){
return "system/applicant/create_note.html";
}
@RequestMapping("/addNotice")
public String addNotice(){
return "system/admin/notice_add.html";
}
@RequestMapping(value="/checkFlag",method=RequestMethod.POST)
@ResponseBody
public Map<String, Object> checkFlag(HttpSession session){
Map<String, Object> map = new HashMap<String, Object>();
if (session.getAttribute("flag")!=null) {
map.put("flag", session.getAttribute("flag"));
}else{
session.setAttribute("flag", 0);
}
//是否登录标记(登录教师为1 登录 学生家长为2)
return map;
}
/**
* 前台用户登录操作
* @param username
* @param password
* @param session
List<Position> positions = studentService.getPositions(id);
JSONArray json = new JSONArray();
if(!positions.isEmpty()){
for (Position po : positions) {
JSONObject jo = new JSONObject();
jo.put("id", po.getId());
jo.put("title", po.getName());
jo.put("place", po.getPlace());
jo.put("salary", po.getSalary());
jo.put("contact", po.getContact());
jo.put("createtime", po.getCreatetime());
json.put(jo);
}
}
System.out.println(json.toString());
return json.toString();
}
@RequestMapping(value="/deleteRecodeByuseridAndPositionid")
public String deleteRecodeByuseridAndPositionid(@RequestParam("id")int id,HttpSession session){
int userid = (Integer) session.getAttribute("userid");//session 中获取到的username
studentService.romoveUserPosition(userid, id);
return "system/applicant/myposition_record.html";
}
@RequestMapping(value="/applyPosition",method=RequestMethod.POST)
@ResponseBody
public Map<String, Object> applyPosition(@RequestParam("positionid")int positionid,HttpSession session){
Map<String, Object> map = new HashMap<String, Object>();
if(session.getAttribute("userid") == null){
map.put("result", 2);
}else{
int id = (Integer) session.getAttribute("userid");//session 中获取到的userid
String username = (String)session.getAttribute("username");
Users users = commonService.getUsersByName(username);
//学生家长自己申请自己的,这种操作是不能的
if(users.getStatue() == 3){
map.put("result", 3);
}else{
int i = studentService.findUserpositionByuseridAndpositonid(id, positionid);
if(i==1){
Userposition userposition = new Userposition();
userposition.setUser(id);
userposition.setPosition(positionid);
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式
@Controller
@RequestMapping(value="/admin")
public class adminManageTcommentController {
@Autowired
CommentService commentService;
@RequestMapping(value="/toCommentList",method=RequestMethod.GET)
public String toCommentList(@RequestParam("positionid") String positionid,@RequestParam("resumeid") String resumeid,HttpSession session){
session.setAttribute("positionid", positionid);
session.setAttribute("resumeid", resumeid);
return "system/admin/comment.html";
}
//查找关于职位 或者 教师的评价
@RequestMapping(value="/getCommentList",method=RequestMethod.POST)
@ResponseBody
public String getCommentList(HttpSession session){
String resumeid = (String) session.getAttribute("resumeid");
String positionid = (String) session.getAttribute("positionid");
List<Tcomment> tcomments;
if(resumeid !=null&&positionid!=null) {
if("0".equals(resumeid)){
// 代表: 不是教师评价,获取的是职位评价
long id = Long.parseLong(positionid);
tcomments = commentService.findTcommentByPositionID(id);
} else{
long id = Long.parseLong(resumeid);
tcomments = commentService.findTcommentsByResumtID(id);
}
JSONArray json = new JSONArray();
for (Tcomment a : tcomments) {
JSONObject jo = new JSONObject();
jo.put("id", a.getId());
jo.put("name", a.getName());
jo.put("content", a.getContent());
jo.put("createtime", a.getCreatetime());
json.put(jo);
if(StringUtils.isEmpty(user.getName())) {
ret.put("message", "请输入用户名");
return ret;
}
if(StringUtils.isEmpty(user.getPassword())) {
ret.put("message", "请输入密码");
return ret;
}
Users users = commonService.getUsersByName(user.getName());
if(users == null){
ret.put("message", "该用户未注册,请先去注册");
return ret;
}else{
String password = users.getPassword();
if(password.equals(user.getPassword())) {
//表示账号密码正确
session.setAttribute("userid", users.getId());
session.setAttribute("username", users.getName());
session.setAttribute("user", users);
if(users.getStatue()==2) {
session.setAttribute("flag", 1);
}else {
session.setAttribute("flag", 2);
}
}else {
ret.put("message", "密码错误");
return ret;
}
logService.addLoginLog(users.getId(), users.getName(), IPUtil.getIpAddr(request));
}
ret.put("type", "success");
ret.put("message", "注册成功");
return ret;
}
/**
* 注销
* @param session
* @return
*/
@RequestMapping(value="/loginout",method=RequestMethod.POST)
@ResponseBody
return "system/admin/recruit_fromuser.html";
}
//通过职位id 获取职位信息
@RequestMapping(value="/showPositionImByid",method=RequestMethod.POST)
@ResponseBody
public Map<String, Object> showPositionImByid(@RequestParam("id")int id){
System.out.println("要获取职位信息的id" + id);
Position position = adminManagePosition.getPositionByid(id);
Map<String, Object> map = new HashMap<String, Object>();
map.put("id", position.getId());
map.put("name", position.getName());
map.put("place", position.getPlace());
map.put("information", position.getInformation());
map.put("salary", position.getSalary());
map.put("contact", position.getContact());
map.put("statue", position.getStatue());
map.put("createtime", position.getCreatetime());
return map;
}
//通过招聘id 修改招聘信息的状态
@RequestMapping(value="/changePositionStatue")
@ResponseBody
public Map<String, Object> changePositionStatue(@RequestParam("id")int id){
Map<String, Object> map = new HashMap<String, Object>();
System.out.println("要修改状态的简历id"+id);
Position position = adminManagePosition.getPositionByid(id);
position.setStatue(0);
adminManagePosition.updatePosition(position);
map.put("value", "1");
return map;
}
//通过招聘id 修改招聘信息的状态
@RequestMapping(value="/changePositionStatueToUn")
@ResponseBody
public Map<String, Object> changePositionStatueToUn(@RequestParam("id")int id){
Map<String, Object> map = new HashMap<String, Object>();
System.out.println("要修改状态的简历id======"+id);
Position position = adminManagePosition.getPositionByid(id);
position.setStatue(1);
@Controller
@RequestMapping("/parent")
public class ParentConroller {
private Map<String, Object> map = new HashMap<String, Object>();
@Autowired
private CommonService commonService;
@Autowired
private ParentService parentService;
@Autowired
private StudentService studentService;
@RequestMapping("/index")
public String index(){
return "system/applicant/student_PersonCenter.html";
}
@RequestMapping(value="/getUserInfo",method=RequestMethod.POST)
@ResponseBody
public Map<String, Object> getUserInfo(HttpSession session){
String name = (String) session.getAttribute("username");
Users users = commonService.getUsersByName(name);
map.put("id", users.getId());
map.put("id", resume.getId());
map.put("name", resume.getName());
map.put("sex", resume.getSex());
map.put("birthday", resume.getBirthday());
map.put("phonenum", resume.getPhonenum());
map.put("email", resume.getEmail());
map.put("schoolname", resume.getSchoolname());
map.put("time", resume.getTime());
map.put("education", resume.getEducation());
map.put("major", resume.getMajor());
map.put("statue", resume.getStatue());
map.put("experience", resume.getExperience());
String[] strings = resume.getJobintension().split("-");
map.put("place", strings[0]);
map.put("kemu", strings[1]);
}
return map;
}
/**
* 制作简历
*/
@RequestMapping(value="/updateResume",method=RequestMethod.POST)
@ResponseBody
public Map<String, Object> updateResume(Resume resume,HttpSession session){
Integer userid = (Integer) session.getAttribute("userid");
Map<String, Object> map = new HashMap<String, Object>();
map.put("type", "error");
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式
String date = df.format(new Date());// new Date()为获取当前系统时间
if(StringUtils.isEmpty(resume.getName())) {
map.put("message", "请填写姓名");
return map;
}
if(StringUtils.isEmpty(resume.getPhonenum())) {
map.put("message", "请填写手机号");
return map;
}
if(StringUtils.isEmpty(resume.getBirthday())) {
map.put("message", "请填写生日");
return map;
}
if(StringUtils.isEmpty(resume.getEmail())) {
map.put("message", "请填写邮箱");
@ResponseBody
public String getParents(){
List<Users> allParents = adminManageUser.getAllParents();
List<Recruiter> recruiters = new ArrayList<Recruiter>();
Recruiter r ;
for (Users parent : allParents) {
r = new Recruiter();
r.setRid(parent.getId());
r.setRname(parent.getName());
r.setEmail(parent.getEmail());
List<Position> positionsByuserId = adminManagePosition.getPositionsByuserId(parent.getId());
if(positionsByuserId == null) {
r.setNum(0);
} else {
r.setNum(positionsByuserId.size());
}
recruiters.add(r);
}
JSONArray json = new JSONArray();
for (Recruiter re : recruiters) {
JSONObject jo = new JSONObject();
jo.put("rid", re.getRid());
jo.put("rname", re.getRname());
jo.put("email", re.getEmail());
jo.put("number", re.getNum());
json.put(jo);
}
System.out.println(json.toString());
return json.toString();
}
@RequestMapping(value="/getUserByid",method=RequestMethod.POST)
@ResponseBody
public Map<String, Object> getUserById(HttpSession session){
Map<String, Object> map = new HashMap<String, Object>();
String userid = (String)session.getAttribute("loginid");
int id = Integer.parseInt(userid);
Users users = adminManageUser.getUsersByid(id);
map.put("name", users.getName());
map.put("password", users.getPassword());
map.put("email", users.getEmail());
return map;
}
@RequestMapping(value="/checkEmail",method=RequestMethod.POST)
@ResponseBody
public Map<String, Object> checkEmail(@RequestParam("email")String email){
Map<String, Object> map = new HashMap<String, Object>();
Users users = adminManageUser.getUsersByEmail(email);
/**
* 搜索家教列表
* @param place
* @param kemu
* @param session
* @return
*/
@RequestMapping(value="/searchTeacher",method=RequestMethod.POST)
@ResponseBody
public Map<String,Object> searchTeacher(@RequestParam("place")String place,@RequestParam("kemu")String kemu,HttpSession session){
Map<String, Object> map = (Map<String, Object>) new HashMap<String, Object>();
map.put("type", "error");
if(StringUtils.isEmpty(place)) {
map.put("message", "请选择区域");
return map;
}
if(StringUtils.isEmpty(kemu)) {
map.put("message", "请选择科目");
return map;
}
session.setAttribute("place", place);
session.setAttribute("kemu", kemu);
map.put("type", "success");
return map;
}
/**
* 查询所有家教
* @param stage
* @param place
* @param session
* @return
*/
@RequestMapping(value="/listAllResume",method=RequestMethod.POST)
@ResponseBody
public Map<String,Object> listApplicants(@RequestParam("stage")String stage,@RequestParam("place")String place,@RequestParam(value = "name",required = false,defaultValue = "")String name,HttpSession session){
Map<String, Object> map =new HashMap<String, Object>();
Map<String, Object> ret = new HashMap<>();
if(session.getAttribute("place")!=null){
stage = (String)session.getAttribute("kemu");
place = (String) session.getAttribute("place");
session.removeAttribute("place");
session.removeAttribute("kemu");
}
String job="";
if(!"不限".equals(stage)) {
*/
@RequestMapping(value = "/stu_collect_list",method = RequestMethod.GET)
public String studentCollectList() {
return "system/applicant/student_collect.html";
}
}
/**
* 应聘者 controller ,学生做家教
*
*/
@Controller
@RequestMapping("/applicant")
public class ApplicantController {
@Autowired
public String deletePositionByid(@RequestParam("id")int id){
System.out.println("要删除的职位id为:"+id);
adminManagePosition.deletePositionByid(id);
return "system/admin/recruit_table.html";
}
// 删除招聘者管理中的 招聘信息
@RequestMapping(value="/deletePositionFromUserByid",method=RequestMethod.GET)
public String deletePositionFromUserByid(@RequestParam("id")int id){
System.out.println("要删除的职位id为:"+id);
adminManagePosition.deletePositionByid(id);
return "system/admin/recruit_fromuser.html";
}
//通过职位id 获取职位信息
@RequestMapping(value="/showPositionImByid",method=RequestMethod.POST)
@ResponseBody
public Map<String, Object> showPositionImByid(@RequestParam("id")int id){
System.out.println("要获取职位信息的id" + id);
Position position = adminManagePosition.getPositionByid(id);
Map<String, Object> map = new HashMap<String, Object>();
map.put("id", position.getId());
map.put("name", position.getName());
map.put("place", position.getPlace());
map.put("information", position.getInformation());
map.put("salary", position.getSalary());
map.put("contact", position.getContact());
map.put("statue", position.getStatue());
map.put("createtime", position.getCreatetime());
return map;
}
//通过招聘id 修改招聘信息的状态
@RequestMapping(value="/changePositionStatue")
@ResponseBody
public Map<String, Object> changePositionStatue(@RequestParam("id")int id){
Map<String, Object> map = new HashMap<String, Object>();
System.out.println("要修改状态的简历id"+id);
Position position = adminManagePosition.getPositionByid(id);
return ret;
}
findUserByNameAndEmail.setPassword(user.getPassword());
commonService.updateUsers(findUserByNameAndEmail);
ret.put("type", "success");
ret.put("message", "找回成功");
return ret;
}
}
@Controller
@RequestMapping("/teacher")
public class StudentController {
@Autowired StudentService studentService;
@Autowired
private CommonService commonService;
@RequestMapping("/index")
public String index(){
return "system/applicant/teacher_PersonCenter.html";
}