基于javaweb+mysql的springboot+mybatis招聘平台(平台、企业、用户)(java+springboot+jsp+mysql)
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
平台:管理企业、用户
企业:发部职位,查看投递
用户:查找职位,收藏职位,投递职位
用户
企业
管理员
技术框架
JSP CSS JavaScript jQuery SpringBoot SpringMVC MyBatis
基于javaweb+mysql的SpringBoot+MyBatis招聘平台(平台、企业、用户)(java+springboot+jsp+mysql)
* 职位收藏
* */
@Autowired
private IFavoriteService favoriteService;
@RequestMapping("favorite")
@ResponseBody
public Message favorite(String jobName, String jobAddress, Date saveTime,
String realname, Double jobSalary, String companyName) {
Message message=new Message();
if(realname==null ||realname.isEmpty()){//判断用户是否登录
message.setStr("您还没有登录!");
return message;
}
Favorites favorites = favoriteService.findFavoriteByAll_(realname,jobAddress,jobName,companyName);
if(favorites==null){
//插入职位具体数据
Favorites favorites_=new Favorites();
favorites_.setJobAddress(jobAddress);
favorites_.setJobName(jobName);
favorites_.setJobSalary(jobSalary);
favorites_.setRealname(realname);
favorites_.setReleaseTime(saveTime);//收藏时的时间
favorites_.setCompanyName(companyName);
int result=favoriteService.insertFavorite(favorites_);
if(result==1){
message.setStr("收藏成功!");
return message;
}else{
message.setStr("不好意思,收藏失败!");
return message;
}
}else{
//第二次申请
message.setStr("请不要重复收藏!");
return message;
}
}
/**
* 职位收藏记录
public String editUserSubmit(Integer uid, User user) {
userService.updateUser(uid, user);
return "redirect:findAllUser";
}
@RequestMapping("registUser")
@ResponseBody
public Message registUser(User user) {
Message msg=new Message();
//根据登录名来判断
int result = userService.findByUserLoginName(user.getLoginName());
if(result==1){//登录名已经有了
msg.setStr("用户登录名已经存在");
return msg;
}else{
userService.save(user);//插入具体数据
msg.setStr("success");
return msg;
}
}
/**
* 企业根据用户真实名字查询其详细
*/
@RequestMapping("findUserByRealname")
public String findUserByRealname(String realname,Model model) {
User user = userService.findUserByRealname(realname);
if(user!=null){
model.addAttribute("user", user);
return "/company/listUser";
}else{
throw new RuntimeException("对不起,没有该用户的具体信息");
}
}
/**
* 用户登录
*/
@RequestMapping("login")
public String login(Model model) {
return "/login/login";
}
/**
* 跳转到注册页面
*/
@RequestMapping("regist")
public String toRegist(Model model) {
return "/regist/registUser";
}
@RequestMapping(value = "/exit")
public String exit(HttpServletRequest request) throws Exception {
//退出时清空session
//request.getSession().invalidate();
request.getSession().removeAttribute("currUser");
@Controller
@RequestMapping
public class KapthaController {
@Autowired
DefaultKaptcha defaultKaptcha;
@RequestMapping("/kapcha")
public void defaultKaptcha(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
byte[] captchaChallengeAsJpeg = null;
ByteArrayOutputStream jpegOutputStream = new ByteArrayOutputStream();
try {
// 生产验证码字符串并保存到session中
String createText = defaultKaptcha.createText();
httpServletRequest.getSession().setAttribute("verificationCode", createText);
// 使用生成的验证码字符串返回一个BufferedImage对象并转为byte写入到byte数组中
BufferedImage challenge = defaultKaptcha.createImage(createText);
ImageIO.write(challenge, "jpg", jpegOutputStream);
} catch (IllegalArgumentException e) {
httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
// 定义response输出类型为image/jpeg类型,使用response输出流输出图片的byte数组
captchaChallengeAsJpeg = jpegOutputStream.toByteArray();
httpServletResponse.setHeader("Cache-Control", "no-store");
httpServletResponse.setHeader("Pragma", "no-cache");
httpServletResponse.setDateHeader("Expires", 0);
httpServletResponse.setContentType("image/jpeg");
ServletOutputStream responseOutputStream = httpServletResponse.getOutputStream();
responseOutputStream.write(captchaChallengeAsJpeg);
responseOutputStream.flush();
responseOutputStream.close();
}
//验证输入的验证码是否正确。
@PostMapping("/checkVerificationCode")
public String checkVerificationCode(@RequestParam(value = "verificationCode") String verificationCode, HttpServletRequest httpServletRequest, Model model) {
String verificationCodeIn = (String) httpServletRequest.getSession().getAttribute("verificationCode");
httpServletRequest.getSession().removeAttribute("verificationCode");
if (StringUtils.isEmpty(verificationCodeIn) || !verificationCodeIn.equals(verificationCode)) {
model.addAttribute("result", "验证码错误,或已失效");
return "1";
}
model.addAttribute("result", "验证码正确");
return "2";
}
}
package com.demo.controller;
@Controller
@RequestMapping("/favorite")
public class FavoritesController {
/**
* 职位收藏
* */
@Autowired
private IFavoriteService favoriteService;
@RequestMapping("favorite")
@ResponseBody
public Message favorite(String jobName, String jobAddress, Date saveTime,
String realname, Double jobSalary, String companyName) {
Message message=new Message();
if(realname==null ||realname.isEmpty()){//判断用户是否登录
message.setStr("您还没有登录!");
return message;
}
Favorites favorites = favoriteService.findFavoriteByAll_(realname,jobAddress,jobName,companyName);
if(favorites==null){
//插入职位具体数据
Favorites favorites_=new Favorites();
favorites_.setJobAddress(jobAddress);
favorites_.setJobName(jobName);
favorites_.setJobSalary(jobSalary);
favorites_.setRealname(realname);
favorites_.setReleaseTime(saveTime);//收藏时的时间
favorites_.setCompanyName(companyName);
int result=favoriteService.insertFavorite(favorites_);
if(result==1){
public IEboardService eboardService;
@RequestMapping("/showNews")
public String showJournalism(Model model){
List<Eboard> eboardList = eboardService.findAllJournalism();
model.addAttribute("eboardList", eboardList);
return "/main/listEboard";
}
@RequestMapping("/findAllEboard")
public String findAllEboard(Model model) {
List<Eboard> eboardList = eboardService.findAllJournalism();
model.addAttribute("eboardList", eboardList);
return "/eboard/listEboard";
}
@RequestMapping("/deleteEboard")
public String deleteEboard(Integer eid) {
eboardService.delete(eid);
return "redirect:findAllEboard";
}
@RequestMapping("/updateEboard")
public String updateEboard(Integer eid,Model model) {
Eboard eboard = eboardService.selectOne(eid);
model.addAttribute("eboard",eboard);
return "/eboard/editEboard";
}
@RequestMapping("/updateEboardSubmit")
public String updateEboardSubmit(Eboard eboard) {
eboardService.update(eboard);
return "redirect:findAllEboard";
}
@RequestMapping("/insertEboard")
public String insertEboard(Eboard eboard) {
eboardService.insert(eboard);
return "redirect:findAllEboard";
}
}
package com.demo.controller;
@Controller
@RequestMapping("/main")
public class MainController {
/**
* 跳转到主页
*/
//request.getSession().invalidate();
request.getSession().removeAttribute("currUser");
return "/login/login";
}
@RequestMapping("exportSheet")
public void exportSheet(HttpServletResponse response, HttpSession session) {
List<User> list = userService.findAll();
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("用户信息", "user"),
User.class, list);
String encode = null;
try {
encode = URLEncoder.encode("用户信息.xls", "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
response.addHeader("Content-Disposition", "attachment;filename=" + encode);// 设置文件名
ServletOutputStream os = null;
try {
os = response.getOutputStream();
} catch (IOException e) {
e.printStackTrace();
}
try {
workbook.write(os);
workbook.close();
} catch (IOException e) {
e.printStackTrace();
}
}
@RequestMapping("importSheet")
public String importSheet(@RequestParam("file")MultipartFile file, HttpServletResponse response, HttpSession session) {
/**
* 管理员登录
* */
@RequestMapping("login")
public String AdminLogin(Model model){
return "/admin/login";//admin目录下的login页面
}
/**
* 后台首页
* */
@RequestMapping("index")
public String AdminIndex(Model model){
return "/admin/index";
}
/**
* 跳转到后台top.jsp
*/
@RequestMapping("top")
public String toTop() {
return "/admin/top";
}
/**
* 跳转到left.jsp
*/
@RequestMapping("left")
public String toLeft() {
return "/admin/left";
}
/**
* 跳转到body.jsp
*/
@RequestMapping("body")
public String toBody() {
return "/admin/body";
}
/**
* 进入管理员登录
* */
@RequestMapping("accessLogin")
@ResponseBody
public Message accessLogin(HttpServletRequest request, String adminName, String adminPwd, Model model) {
Admin currAdmin = adminService.getAdminByNameAndPwd(adminName,adminPwd);//根据登录名向数据库中查询用户
Message msg=new Message();
if(currAdmin==null){
msg.setStr("fail");
return msg;
}else{
HttpSession session = request.getSession();
session.setAttribute("currAdmin", currAdmin);
return "/company/top";
}
/**
* 跳转到left.jsp
*/
@RequestMapping("left")
public String toLeft() {
return "/company/left";
}
/**
* 跳转到body.jsp
*/
@RequestMapping("body")
public String toBody() {
return "/company/body";
}
@RequestMapping("exportSheet")
public void exportSheet(HttpServletResponse response, HttpSession session) {
List<Company> list = companyService.findAll();
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("公司信息", "company"),
Company.class, list);
String encode = null;
try {
encode = URLEncoder.encode("公司信息.xls", "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
response.addHeader("Content-Disposition", "attachment;filename=" + encode);// 设置文件名
ServletOutputStream os = null;
try {
os = response.getOutputStream();
} catch (IOException e) {
e.printStackTrace();
}
try {
workbook.write(os);
workbook.close();
} catch (IOException e) {
e.printStackTrace();
}
}
@Controller
@RequestMapping("/admin")
public class AdminController {
@Autowired
private IAdminService adminService;
/**
* 管理员登录
* */
@RequestMapping("login")
public String AdminLogin(Model model){
return "/admin/login";//admin目录下的login页面
}
/**
* 后台首页
* */
@RequestMapping("index")
public String AdminIndex(Model model){
return "/admin/index";
}
/**
* 跳转到后台top.jsp
*/
@RequestMapping("top")
public String toTop() {
return "/admin/top";
}
/**
* 跳转到left.jsp
*/
@RequestMapping("left")
public String toLeft() {
return "/admin/left";
}
/**
* 跳转到body.jsp
*/
@RequestMapping("body")
@RequestMapping("editUserSubmit")
public String editUserSubmit(Integer uid, User user) {
userService.updateUser(uid, user);
return "redirect:findAllUser";
}
@RequestMapping("registUser")
@ResponseBody
public Message registUser(User user) {
Message msg=new Message();
//根据登录名来判断
int result = userService.findByUserLoginName(user.getLoginName());
if(result==1){//登录名已经有了
msg.setStr("用户登录名已经存在");
return msg;
}else{
userService.save(user);//插入具体数据
msg.setStr("success");
return msg;
}
}
/**
* 企业根据用户真实名字查询其详细
*/
@RequestMapping("findUserByRealname")
public String findUserByRealname(String realname,Model model) {
User user = userService.findUserByRealname(realname);
if(user!=null){
model.addAttribute("user", user);
return "/company/listUser";
}else{
throw new RuntimeException("对不起,没有该用户的具体信息");
}
}
/**
* 用户登录
*/
@RequestMapping("login")
public String login(Model model) {
return "/login/login";
}
/**
* 跳转到注册页面
return msg;
}
}
}
package com.demo.controller;
@Controller
@RequestMapping("/eboard")
public class EBoardController {//系统公告以及职位新闻
@Autowired
public IEboardService eboardService;
@RequestMapping("/showNews")
public String showJournalism(Model model){
List<Eboard> eboardList = eboardService.findAllJournalism();
model.addAttribute("eboardList", eboardList);
return "/main/listEboard";
}
@RequestMapping("/findAllEboard")
public String findAllEboard(Model model) {
List<Eboard> eboardList = eboardService.findAllJournalism();
model.addAttribute("eboardList", eboardList);
return "/eboard/listEboard";
}
@RequestMapping("/deleteEboard")
public String deleteEboard(Integer eid) {
eboardService.delete(eid);
return "redirect:findAllEboard";
}
@RequestMapping("/updateEboard")
public String updateEboard(Integer eid,Model model) {
Eboard eboard = eboardService.selectOne(eid);
model.addAttribute("eboard",eboard);
@Controller
@RequestMapping("/admin")
public class AdminController {
@Autowired
private IAdminService adminService;
/**
* 管理员登录
* */
@RequestMapping("login")
public String AdminLogin(Model model){
return "/admin/login";//admin目录下的login页面
}
/**
* 后台首页
* */
@RequestMapping("index")
public String AdminIndex(Model model){
return "/admin/index";
}
/**
* 跳转到后台top.jsp
*/
@RequestMapping("top")
public String toTop() {
return "/admin/top";
}
/**
* 跳转到left.jsp
*/
@RequestMapping("left")
public String toLeft() {
return "/admin/left";
}
/**
* 跳转到body.jsp
*/
@RequestMapping("body")
public String toBody() {
return "/admin/body";
}
/**
String verificationCodeIn = (String) request.getSession().getAttribute("verificationCode");
request.removeAttribute("verificationCode");
if (StringUtils.isEmpty(verificationCodeIn) || !verificationCodeIn.equals(verificationCode)) {
model.addAttribute("result", "验证码错误,或已失效");
msg.setStr("fail2");
return msg;
}
Company currCom = companyService.getCompanyByNameAndPwd(companyLoginName,companyPwd);//根据登录名向数据库中查询用户
if(currCom==null){
msg.setStr("fail");
return msg;
}else{
HttpSession session = request.getSession();
session.setAttribute("currCom", currCom);
msg.setStr("success");
return msg;
}
}
/**
* 跳转到添加职位页面
* */
@RequestMapping("toAddPost")
public String toAddPost(Model model) {
return "/company/addPost";
}
/**
* 添加职位
* */
@RequestMapping("addPost")
@ResponseBody
public Message addPost(HttpServletRequest request,String jobName,String jobAddress,Double jobSalary,
Integer cid) {
Message msg=new Message();
Company company = (Company) request.getSession().getAttribute("currCom");
if(company!=null){
Job job= iJobService.findByCidAndJobName(cid,jobName);
if(job==null){
/**
* 求职申请控制
* */
@Controller
@RequestMapping("/apply")
public class ApplyJobController {
@Autowired
private IApplyJobService applyJobService;
/**
* 企业查询所有的申请者
* */
@RequestMapping("/findApply")
public String findAllApply(String companyName,Model model,HttpServletRequest request){
Company company = (Company) request.getSession().getAttribute("currCom");
if(company!=null){
//String currCompanyName= EncodingTool.encodeStr(companyName);
List<Apply> applyList = applyJobService.findAllByCompanyName(companyName);
model.addAttribute("applyList", applyList);
return "/apply/showApply";
}else{
return "/company/relogin";
}
}
/**
* 接收界面参数,判断是否是第一次插入
* */
@RequestMapping("/accpet")
@ResponseBody
public Message accpet(String jobName,String jobAddress,String releaseTime,
String realname,Double jobSalary,String companyName){
Message message=new Message();
if(realname==null ||realname.isEmpty()){//判断用户是否登录
message.setStr("您还没有登录!");
}
package com.demo.controller;
@Controller
@RequestMapping("/favorite")
public class FavoritesController {
/**
* 职位收藏
* */
@Autowired
private IFavoriteService favoriteService;
@RequestMapping("favorite")
@ResponseBody
public Message favorite(String jobName, String jobAddress, Date saveTime,
String realname, Double jobSalary, String companyName) {
Message message=new Message();
if(realname==null ||realname.isEmpty()){//判断用户是否登录
message.setStr("您还没有登录!");
return message;
}
Favorites favorites = favoriteService.findFavoriteByAll_(realname,jobAddress,jobName,companyName);
if(favorites==null){
//插入职位具体数据
Favorites favorites_=new Favorites();
favorites_.setJobAddress(jobAddress);
favorites_.setJobName(jobName);
favorites_.setJobSalary(jobSalary);
favorites_.setRealname(realname);
favorites_.setReleaseTime(saveTime);//收藏时的时间
favorites_.setCompanyName(companyName);
int result=favoriteService.insertFavorite(favorites_);
if(result==1){
@Controller
@RequestMapping("/user")
public class UserController {
@Autowired
public IUserService userService;
// 查询所有用户
@RequestMapping("findAllUser")
public String findAllUser(Model model) {
List<User> userList = userService.findAll();
model.addAttribute("userList", userList);
return "/user/listUser";
}
@RequestMapping("showResume")
public String showResume(Model model,HttpServletRequest request) {
//获得session中存的当前对象
User currUser = (User) request.getSession().getAttribute("currUser");
String realname=currUser.getRealname();
public Message accessLogin(HttpServletRequest request, String loginName, String loginPwd,String verificationCode, Model model) {
Message msg=new Message();
String verificationCodeIn = (String) request.getSession().getAttribute("verificationCode");
request.removeAttribute("verificationCode");
if (StringUtils.isEmpty(verificationCodeIn) || !verificationCodeIn.equals(verificationCode)) {
model.addAttribute("result", "验证码错误,或已失效");
msg.setStr("fail2");
return msg;
}
User currUser = userService.getUserByNameAndPwd(loginName,loginPwd);//根据登录名向数据库中查询用户
if(currUser==null){
msg.setStr("fail");
return msg;
}else{
HttpSession session = request.getSession();
session.setAttribute("currUser", currUser);
msg.setStr("success");
return msg;
}
}
}
package com.demo.controller;
@Controller
@RequestMapping("/eboard")
public class EBoardController {//系统公告以及职位新闻
@Autowired
public IEboardService eboardService;
@RequestMapping("/showNews")
public String showJournalism(Model model){
List<Eboard> eboardList = eboardService.findAllJournalism();
@Controller
@RequestMapping("/eboard")
public class EBoardController {//系统公告以及职位新闻
@Autowired
public IEboardService eboardService;
@RequestMapping("/showNews")
public String showJournalism(Model model){
List<Eboard> eboardList = eboardService.findAllJournalism();
model.addAttribute("eboardList", eboardList);
return "/main/listEboard";
}
@RequestMapping("/findAllEboard")
public String findAllEboard(Model model) {
List<Eboard> eboardList = eboardService.findAllJournalism();
model.addAttribute("eboardList", eboardList);
return "/eboard/listEboard";
}
@RequestMapping("/deleteEboard")
public String deleteEboard(Integer eid) {
eboardService.delete(eid);
return "redirect:findAllEboard";
}
@RequestMapping("/updateEboard")
public String updateEboard(Integer eid,Model model) {
Eboard eboard = eboardService.selectOne(eid);
model.addAttribute("eboard",eboard);
return "/eboard/editEboard";
}
@RequestMapping("/updateEboardSubmit")
public String updateEboardSubmit(Eboard eboard) {
eboardService.update(eboard);
return "redirect:findAllEboard";
}
@RequestMapping("/insertEboard")
public String insertEboard(Eboard eboard) {
eboardService.insert(eboard);
model.addAttribute("user", user);
return "/user/editUser";
}
// 根据ID进行删除
@RequestMapping("deleteById")
public String deleteById(Integer uid) {
userService.deleteById(uid);
// 重定向到用户列表界面
return "redirect:findAllUser";
}
@RequestMapping("editUserSubmit")
public String editUserSubmit(Integer uid, User user) {
userService.updateUser(uid, user);
return "redirect:findAllUser";
}
@RequestMapping("registUser")
@ResponseBody
public Message registUser(User user) {
Message msg=new Message();
//根据登录名来判断
int result = userService.findByUserLoginName(user.getLoginName());
if(result==1){//登录名已经有了
msg.setStr("用户登录名已经存在");
return msg;
}else{
userService.save(user);//插入具体数据
msg.setStr("success");
return msg;
}
}
/**
* 企业根据用户真实名字查询其详细
*/
@RequestMapping("findUserByRealname")
public String findUserByRealname(String realname,Model model) {
User user = userService.findUserByRealname(realname);
if(user!=null){
model.addAttribute("user", user);
return "/company/listUser";
}else{
throw new RuntimeException("对不起,没有该用户的具体信息");
@ResponseBody
public Message accessComLogin(HttpServletRequest request, String companyLoginName, String verificationCode,String companyPwd,Model model) {
Message msg=new Message();
String verificationCodeIn = (String) request.getSession().getAttribute("verificationCode");
request.removeAttribute("verificationCode");
if (StringUtils.isEmpty(verificationCodeIn) || !verificationCodeIn.equals(verificationCode)) {
model.addAttribute("result", "验证码错误,或已失效");
msg.setStr("fail2");
return msg;
}
Company currCom = companyService.getCompanyByNameAndPwd(companyLoginName,companyPwd);//根据登录名向数据库中查询用户
if(currCom==null){
msg.setStr("fail");
return msg;
}else{
HttpSession session = request.getSession();
session.setAttribute("currCom", currCom);
msg.setStr("success");
return msg;
}
}
/**
* 跳转到添加职位页面
* */
@RequestMapping("toAddPost")
public String toAddPost(Model model) {
return "/company/addPost";
}
/**
* 添加职位
* */
@RequestMapping("addPost")
@ResponseBody
public Message addPost(HttpServletRequest request,String jobName,String jobAddress,Double jobSalary,
Integer cid) {
Message msg=new Message();
Company company = (Company) request.getSession().getAttribute("currCom");
if(company!=null){
@Controller
@RequestMapping("/login")
public class LoginController {
@Autowired
private IUserService userService;
/**
* 跳转至登录页面
*/
@RequestMapping("login")
public String login(Model model) {
return "/login/login";
}
/**
* 进入用户登录
* */
@RequestMapping("/accessLogin")
@ResponseBody
public Message accessLogin(HttpServletRequest request, String loginName, String loginPwd,String verificationCode, Model model) {
Message msg=new Message();
String verificationCodeIn = (String) request.getSession().getAttribute("verificationCode");
request.removeAttribute("verificationCode");
if (StringUtils.isEmpty(verificationCodeIn) || !verificationCodeIn.equals(verificationCode)) {
model.addAttribute("result", "验证码错误,或已失效");
msg.setStr("fail2");
return msg;
}
User currUser = userService.getUserByNameAndPwd(loginName,loginPwd);//根据登录名向数据库中查询用户
if(currUser==null){
msg.setStr("fail");
return msg;
}else{
HttpSession session = request.getSession();
session.setAttribute("currUser", currUser);
msg.setStr("success");
return msg;
}
/**
* 验证码功能的实现
*/
@Controller
@RequestMapping
public class KapthaController {
@Autowired
DefaultKaptcha defaultKaptcha;
@RequestMapping("/kapcha")
public void defaultKaptcha(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
byte[] captchaChallengeAsJpeg = null;
ByteArrayOutputStream jpegOutputStream = new ByteArrayOutputStream();
try {
// 生产验证码字符串并保存到session中
String createText = defaultKaptcha.createText();
httpServletRequest.getSession().setAttribute("verificationCode", createText);
// 使用生成的验证码字符串返回一个BufferedImage对象并转为byte写入到byte数组中
BufferedImage challenge = defaultKaptcha.createImage(createText);
ImageIO.write(challenge, "jpg", jpegOutputStream);
} catch (IllegalArgumentException e) {
httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
// 定义response输出类型为image/jpeg类型,使用response输出流输出图片的byte数组
captchaChallengeAsJpeg = jpegOutputStream.toByteArray();
httpServletResponse.setHeader("Cache-Control", "no-store");
httpServletResponse.setHeader("Pragma", "no-cache");
httpServletResponse.setDateHeader("Expires", 0);
httpServletResponse.setContentType("image/jpeg");
ServletOutputStream responseOutputStream = httpServletResponse.getOutputStream();
responseOutputStream.write(captchaChallengeAsJpeg);
responseOutputStream.flush();
responseOutputStream.close();
}
//验证输入的验证码是否正确。
@PostMapping("/checkVerificationCode")
public String checkVerificationCode(@RequestParam(value = "verificationCode") String verificationCode, HttpServletRequest httpServletRequest, Model model) {
String verificationCodeIn = (String) httpServletRequest.getSession().getAttribute("verificationCode");
httpServletRequest.getSession().removeAttribute("verificationCode");
if (StringUtils.isEmpty(verificationCodeIn) || !verificationCodeIn.equals(verificationCode)) {
@Controller
@RequestMapping("/user")
public class UserController {
@Autowired
public IUserService userService;
// 查询所有用户
@RequestMapping("findAllUser")
public String findAllUser(Model model) {
List<User> userList = userService.findAll();
model.addAttribute("userList", userList);
return "/user/listUser";
}
@RequestMapping("showResume")
public String showResume(Model model,HttpServletRequest request) {
//获得session中存的当前对象
User currUser = (User) request.getSession().getAttribute("currUser");
String realname=currUser.getRealname();
//根据真实姓名查询用户
User user = userService.findUserByRealname(realname);
model.addAttribute("user", user);
return "/user/showUserResume";
}
/**
* 修改简历
* */
@RequestMapping("editResume")
public String editResume(Model model,Integer uid) {
User user = userService.findById(uid);
if(user!=null){
}
// 根据ID进行删除
@RequestMapping("deleteById")
public String deleteById(Integer uid) {
userService.deleteById(uid);
// 重定向到用户列表界面
return "redirect:findAllUser";
}
@RequestMapping("editUserSubmit")
public String editUserSubmit(Integer uid, User user) {
userService.updateUser(uid, user);
return "redirect:findAllUser";
}
@RequestMapping("registUser")
@ResponseBody
public Message registUser(User user) {
Message msg=new Message();
//根据登录名来判断
int result = userService.findByUserLoginName(user.getLoginName());
if(result==1){//登录名已经有了
msg.setStr("用户登录名已经存在");
return msg;
}else{
userService.save(user);//插入具体数据
msg.setStr("success");
return msg;
}
}
/**
* 企业根据用户真实名字查询其详细
*/
@RequestMapping("findUserByRealname")
public String findUserByRealname(String realname,Model model) {
User user = userService.findUserByRealname(realname);
if(user!=null){
model.addAttribute("user", user);
return "/company/listUser";
}else{
throw new RuntimeException("对不起,没有该用户的具体信息");
}
}
/**
public class MainController {
/**
* 跳转到主页
*/
@RequestMapping("index")
public String toIndex() {
return "/main/index";
}
/**
* 跳转到top.jsp
*/
@RequestMapping("top")
public String toTop() {
return "/main/top";
}
/**
* 跳转到left.jsp
*/
@RequestMapping("left")
public String toLeft() {
return "/main/left";
}
/**
* 跳转到body.jsp
*/
@RequestMapping("body")
public String toBody() {
return "/main/body";
}
/**
* 跳转到用户注册页面
*/
@RequestMapping("registUser")
public String toRegistUser() {
return "/regist/registUser";
}
/**
* 跳转到企业注册页面
*/
@RequestMapping("registCom")
public String toRegistCom() {
return "/regist/registCom";
}
}
package com.demo.controller;
* */
@RequestMapping("accessComLogin")
@ResponseBody
public Message accessComLogin(HttpServletRequest request, String companyLoginName, String verificationCode,String companyPwd,Model model) {
Message msg=new Message();
String verificationCodeIn = (String) request.getSession().getAttribute("verificationCode");
request.removeAttribute("verificationCode");
if (StringUtils.isEmpty(verificationCodeIn) || !verificationCodeIn.equals(verificationCode)) {
model.addAttribute("result", "验证码错误,或已失效");
msg.setStr("fail2");
return msg;
}
Company currCom = companyService.getCompanyByNameAndPwd(companyLoginName,companyPwd);//根据登录名向数据库中查询用户
if(currCom==null){
msg.setStr("fail");
return msg;
}else{
HttpSession session = request.getSession();
session.setAttribute("currCom", currCom);
msg.setStr("success");
return msg;
}
}
/**
* 跳转到添加职位页面
* */
@RequestMapping("toAddPost")
public String toAddPost(Model model) {
return "/company/addPost";
}
/**
* 添加职位
* */
@RequestMapping("addPost")
@ResponseBody
public Message addPost(HttpServletRequest request,String jobName,String jobAddress,Double jobSalary,
Integer cid) {
Message msg=new Message();
Company company = (Company) request.getSession().getAttribute("currCom");
if(company!=null){
Job job= iJobService.findByCidAndJobName(cid,jobName);
if(job==null){
//将数据封装到新的job对象,插入数据库
Job job_=new Job();