目录
4.2 查看职位申请表
说明
此项目为笔者大学毕业设计,整个项目前后端、设计测试基本都由一个人完成,可能在技术方面并不是很成熟,存在很多疏漏的地方,后期发现代码不规范但是时间来不及修改,项目整体思想比较完善,可用于练手。
一、登录模块
二、应聘者信息管理模块
登录成功后,判断用户身份,如果为管理员身份则跳转到管理员界面,点击应聘者信息管理可进入到应聘者信息管理模块,此模块中包括查询、增加、删除、修改、上传简历、查看简历、导入excel解析、导出excel功能。
2.1 数据表结构
CREATE TABLE `student` (
`studentId` int NOT NULL AUTO_INCREMENT,
`candidateName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '名字',
`sex` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '性别',
`datename` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '出生年月',
`age` int DEFAULT NULL COMMENT '年龄',
`background` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '学历',
`major` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '专业',
`phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '联系方式',
`email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '邮箱',
`station` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '岗位',
`department` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '应聘部门',
`state` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '状态',
PRIMARY KEY (`studentId`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=121 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC;
2.2 应聘者信息列表
逻辑:应聘者信息列表只是做一个简单的查询,查询表student中的数据
接口url:/AdminStudentManage
请求参数:Model 模型、pageNum 当前页数
编码:
model层
//其中@ExcelImport注解是为了后面导入导出excel表格使用
@Entity
public class Student {
@ExcelImport("序号")
private Integer studentId;
@ExcelImport("姓名")
private String candidateName;
@ExcelImport("性别")
private String sex;
@ExcelImport("出生年月")
private String datename;
@ExcelImport("年龄")
private Integer age;
@ExcelImport("学历")
private String background;
@ExcelImport("专业")
private String major;
@ExcelImport("联系方式")
private String phone;
@ExcelImport("邮箱")
private String email;
@ExcelImport("岗位")
private String station;
@ExcelImport("应聘部门")
private String department;
@ExcelImport("状态")
private String state;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "studentId", nullable = false)
public Integer getStudentId() {
return studentId;
}
public void setStudentId(Integer studentId) {
this.studentId = studentId;
}
@Basic
@Column(name = "candidateName", nullable = true)
public String getCandidateName() {
return candidateName;
}
public void setCandidateName(String candidateName) {
this.candidateName = candidateName;
}
@Basic
@Column(name = "sex", nullable = true)
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
@Basic
@Column(name = "datename", nullable = true)
public String getDatename() {
return datename;
}
public void setDatename(String datename) {
this.datename = datename;
}
@Basic
@Column(name = "age", nullable = true)
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
@Basic
@Column(name = "background", nullable = true)
public String getBackground() {
return background;
}
public void setBackground(String background) {
this.background = background;
}
@Basic
@Column(name = "major", nullable = true)
public String getMajor() {
return major;
}
public void setMajor(String major) {
this.major = major;
}
@Basic
@Column(name = "phone", nullable = true)
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
@Basic
@Column(name = "email", nullable = true)
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
@Basic
@Column(name = "station", nullable = true)
public String getStation() {
return station;
}
public void setStation(String station) {
this.station = station;
}
@Basic
@Column(name = "department", nullable = true)
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
@Basic
@Column(name = "state", nullable = true)
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
}
controller层
@RequestMapping("/AdminStudentManage")
private String AdminStudentManage(Model model, Integer pageNum){
if (pageNum == null){
pageNum = 1;
}
Sort sort = new Sort(Sort.Direction.ASC, "studentId"); // 这里的"recordNo"是实体类的主键
Pageable pageable = new PageRequest(pageNum - 1, 5, sort);
Page<Student> students =studentDao.findStudent(pageable);
model.addAttribute("students",students);
return "/admin/StudentList";
}
Dao层
@Query(value ="select * from student", nativeQuery = true)
Page<Student> findStudent(Pageable pageable);
2.3 导入excel表格
逻辑:点击导入excel上传文件后,用工具类对excel进行解析放入list中,逐条数据插入到数据库中,这里有限制,要求上传的excel文件内容必须与数据库字段内容对应。
接口url:/importExcel
请求参数:MultipartFile file 上传的excel文件
编码:
model层内容同应聘者信息列表
controller层
//这里说明一下,当成功后重定向到应聘者信息列表界面
@PostMapping("/importExcel")
public String importExcel(@RequestParam("fileName")MultipartFile file) throws Exception {
if(file==null||file.isEmpty()){
return "admin/error";
}else {
List<Student> students = ExcelUtils.readMultipartFile(file, Student.class);
for (Student student : students) {
studentDao.save(student);
}
}
return "redirect:/AdminStudentManage";
}
ExcelUtils工具类在网上搜的内容太多不附上具体代码
转发和重定向(完整理解及总结)_艾艾猫dori的博客-CSDN博客
2.4 导出excel
逻辑:点击导出按钮时,用HSSFWorkbook根据要求画excel表格,从数据库中提取应聘者信息列表,将数据填充到excel表格中
接口url:/exportExcel
请求参数:无
编码:
model层同应聘者信息列表
controller层
/**
* 导出
* @return
*/
@PostMapping("/exportExcel")
@ResponseBody
public void exportExcel(){
//第一步创建workbook
HSSFWorkbook wb = new HSSFWorkbook();
//第二步创建sheet
HSSFSheet sheet = wb.createSheet();
//第三步创建行row:添加表头0行
//4个参数依次为:开始行,结束行,开始列,结束列
sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 6));
HSSFRow row = sheet.createRow(0);
HSSFCell cell1 = row.createCell(0);
cell1.setCellValue("候选人信息表");
HSSFCellStyle style = wb.createCellStyle();
style.setAlignment(HSSFCellStyle.ALIGN_CENTER); //居中
HSSFRow row1 = sheet.createRow(1);
//第四步创建单元格
HSSFCell cell = row1.createCell(0); //第一个单元格
cell.setCellValue("id"); //设定值
cell.setCellStyle(style); //内容居中
cell = row1.createCell(1); //第二个单元格
cell.setCellValue("姓名");
cell.setCellStyle(style);
cell = row1.createCell(2); //第三个单元格
cell.setCellValue("性别");
cell.setCellStyle(style);
cell = row1.createCell(3); //第四个单元格
cell.setCellValue("出生年月");
cell.setCellStyle(style);
cell = row1.createCell(4); //第五个单元格
cell.setCellValue("年龄");
cell.setCellStyle(style);
cell = row1.createCell(5); //第六个单元格
cell.setCellValue("学历");
cell.setCellStyle(style);
cell = row1.createCell(6); //第七个单元格
cell.setCellValue("专业");
cell.setCellStyle(style);
cell = row1.createCell(7); //第七个单元格
cell.setCellValue("联系方式");
cell.setCellStyle(style);
cell = row1.createCell(8); //第七个单元格
cell.setCellValue("邮箱");
cell.setCellStyle(style);
cell = row1.createCell(9); //第七个单元格
cell.setCellValue("岗位");
cell.setCellStyle(style);
cell = row1.createCell(10); //第七个单元格
cell.setCellValue("应聘部门");
cell.setCellStyle(style);
cell = row1.createCell(11); //第七个单元格
cell.setCellValue("状态");
cell.setCellStyle(style);
//第五步插入数据
Student student = new Student();
//findAll()为jpa中方法可以直接使用
List<Student> list = studentDao.findAll();
for (int i = 0; i < list.size(); i++) {
//创建行
row = sheet.createRow(i+2);
//创建单元格并且添加数据
row.createCell(0).setCellValue(list.get(i).getStudentId());
row.createCell(1).setCellValue(list.get(i).getCandidateName());
row.createCell(2).setCellValue(list.get(i).getSex());
row.createCell(3).setCellValue(list.get(i).getDatename());
row.createCell(4).setCellValue(list.get(i).getAge());
row.createCell(5).setCellValue(list.get(i).getBackground());
row.createCell(6).setCellValue(list.get(i).getMajor());
row.createCell(7).setCellValue(list.get(i).getPhone());
row.createCell(8).setCellValue(list.get(i).getEmail());
row.createCell(9).setCellValue(list.get(i).getStation());
row.createCell(10).setCellValue(list.get(i).getDepartment());
row.createCell(11).setCellValue(list.get(i).getState());
}
File file=new File("F:\\CentOS\\候选人信息表.xls");
if(file.exists()){
file.delete();
}
FileOutputStream fileOutputStream= null;
try {
fileOutputStream = new FileOutputStream(file);
wb.write(fileOutputStream);
fileOutputStream.close();
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
2.5 上传简历
逻辑:后端接收前端传过来的文件后进行保存,这里需要传过来应聘者的id根据id保存文件。
接口url:/fileUpload
请求参数:MultipartFile file,Integer uploadStudentId 其中file为文件名称,studentid为应聘者id
编码:
model层内容同应聘者信息列表
controller层
/**
* 实现文件上传
* @param file
* @param uploadStudentId
* @return
* @throws IOException
*/
@PostMapping ("/fileUpload")
public String fileUpload(@RequestParam("fileName") MultipartFile file,@RequestParam("uploadStudentId") Integer uploadStudentId) throws IOException {
System.out.println(uploadStudentId);
if(file.isEmpty()){
return "admin/error";
}
String filename = file.getOriginalFilename();
String sys = System.getProperty("os.name");
System.out.println("sys = " + sys);
if(sys.startsWith("Linux")){}
String dict = sys.startsWith("Windows") ? "E:\\resumedoc\\"+uploadStudentId:"/resumedoc/"+uploadStudentId;
File dicFile = new File(dict);
if(dicFile.exists()){
deleteFile(dicFile);
}
dicFile.mkdirs();
String pathNew = sys.startsWith("Windows") ? dict+"\\"+filename:dict+"/"+filename;
File fileNew = new File(pathNew);
file.transferTo(fileNew);
return "redirect:/AdminStudentManage";
}
2.6 简历预览
逻辑:后端接收前端传过来的文件后进行保存,这里需要穿过来改应聘者的id根据id保存文件,用系统浏览器进行查看。
接口url:/fileUpload
请求参数:MultipartFile file,Integer uploadStudentId 其中file为文件名称,studentid为应聘者id
编码:
model层内容同应聘者信息列表
controller层
/**
* 上传简历的预览
* @param studentId
* @param request
* @param response
*/
@RequestMapping(value = "/preview", method = RequestMethod.GET)
public void prePDF(Integer studentId, HttpServletRequest request, HttpServletResponse response) {
String sys = System.getProperty("os.name");
if(sys.startsWith("Linux")){}
String dict = sys.startsWith("Windows") ? "E:\\resumedoc\\"+studentId:"/resumedoc/"+studentId;
// String rootPath = System.getProperty("user.dir");
File file = new File(dict);
System.out.println(file);
Map<String, Object> map = new HashMap<>();
if(!file.exists()){
System.out.println("不存在文件内容");
response.setCharacterEncoding("UTF-8");
response.setContentType("application/json");
map.put("w","不存在文件内容");
map.put("status1",-1);
return;
}
File []file1=file.listFiles();
if(!file1[0].exists()){
System.out.println("出现错误");
}
System.out.println(file1[0]);
if (file1[0].exists()) {
byte[] data = null;
try {
FileInputStream input = new FileInputStream(file1[0]);
data = new byte[input.available()];
input.read(data);
response.getOutputStream().write(data);
input.close();
} catch (Exception e) {
System.out.println("文件处理异常");
// logger.info("pdf文件处理异常...");
}
}
map.put("w","成功");
map.put("status1",0);
}
2.7 查询应聘者信息
逻辑:通过输入的信息查询符合条件的应聘者信息,此处查询为模糊查询且为全局查询
接口url:/getTableList
请求参数:Model model模型返回前端信息显示在页面中,String selectKey要查询的关键字
编码:
model层内容同应聘者信息列表
controller层
/**
* 查询
* @param model
* @param selectKey
* @return
*/
@PostMapping("/getTableList")
private String getTableList(Model model,String selectKey){
Sort sort = new Sort(Sort.Direction.ASC, "studentId"); // 这里的"recordNo"是实体类的主键,记住一定要是实体类的属性,而不能是数据库的字段
Pageable pageable = new PageRequest(0, 5, sort);
Page<Student> students =studentDao.getTableList(pageable,selectKey);
model.addAttribute("students",students);
return "/admin/StudentList";
}
dao层
@Query(value="select * from student where candidateName like %?1% or phone like %?1% or email like %?1% or sex like %?1% or datename like %?1% or age like %?1% or background like %?1%" +
" or major like %?1% or station like %?1% or department like %?1% or state like %?1%",nativeQuery = true)
Page<Student> getTableList(Pageable pageable,String key);
2.8 添加应聘者信息
逻辑:输入信息后进行检查,后端添加到数据库中
接口url:/addStudent
编码:
model层内容同应聘者信息列表
controller层
/**
* 增加候选人
* @param candidateName
* @param sex
* @param datename
* @param age
* @param background
* @param major
* @param phone
* @param email
* @param station
* @param department
* @param state
* @return
*/
@RequestMapping("/addStudent")
private String addStudent(String candidateName,String sex,String datename,Integer age,String background,String major,String phone,String email,String station,String department,String state){
Student student=new Student();
student.setCandidateName(candidateName);
student.setSex(sex);
student.setDatename(datename);
student.setAge(age);
student.setBackground(background);
student.setMajor(major);
student.setPhone(phone);
student.setEmail(email);
student.setStation(station);
student.setDepartment(department);
student.setState(state);
studentDao.save(student);
return "redirect:/AdminStudentManage";
}
2.9 修改应聘者信息
逻辑:修改这里设计到两个接口一个是修改前回显,通过修改应聘者的id进行查找应聘者信息,返回给前端,另外一个就是修改接口,根据修改的数据进行更新保存
修改前回显接口url:/studentEdit
编码:
model层内容同应聘者信息列表
controller层
/**
* 查找修改候选人数据
* @param students
* @return
*/
@ResponseBody
@RequestMapping("/studentEdit")
private Student StudentEdit(@RequestBody Student students){
Student student = studentDao.findByUserid(students.getStudentId());
if (student!= null) {
return student;
} else {
return null;
}
}
dao层
@Query(value ="select * from student where studentId=?", nativeQuery = true)
Student findByUserid(Integer studentId);
修改接口url:/updateStudent
编码:
model层同应聘者信息列表
controller层
/**
* 修改候选人信息
* @param student
* @return
*/
@PostMapping("/updateStudent")
private String updateStudent(Student student){
System.out.println(student.getStudentId()+"+++++++++++++++++");
studentDao.save(student);
return "redirect:/AdminStudentManage";
}
2.10 删除应聘者信息
逻辑:根据id删除数据库中内容即可
接口url:/deleteStudent
编码:
model层内容同应聘者信息列表
controller层
这里存在positionDao为后续设计内容关联,position为职位表
@RequestMapping("/deleteStudent")
private String deleteStudent(Integer studentId){
positionDao.deleteByStudentId(studentId);
studentDao.deleteByStudentId(studentId);
return "redirect:/AdminStudentManage";
}
dao层
@Modifying
@Transactional
@Query(value ="delete from student where studentId =?",nativeQuery = true)
Integer deleteByStudentId(Integer studentId);
2.11 前端代码内容
由于前端并不是很熟练,且这个项目前端大体框架是copy过来的,只会用就行,有兴趣的自己研究吧。
管理员主页面:
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Title</title>
<div th:replace="include/bootstrap :: bootstrap"></div>
</head>
<body style="background-color: #EEEEEE;">
<div th:replace="include/AdminNav :: AdminNav"></div>
<div class="jumbotron" style="height: 630px;padding-top: 50px; padding-bottom: 0px; margin-bottom: 0px; margin-left: 18%">
<div style="padding-left: 20px;">
<h2>
  简历管理系统
</h2>
<!-- <p>-->
<!-- <a class="btn btn-primary btn-large" href="https://www.baidu.com">Learn more</a>-->
<!-- </p>-->
</div>
</div>
</body>
</html>
应聘者信息管理前端页面
主要代码都在这里,主要就是实现页面上的几个按钮功能
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<div th:replace="include/bootstrap :: bootstrap"></div>
</head>
<body>
<div th:replace="include/AdminNav :: AdminNav"></div>
<div class="table-responsive" style="margin-left: 18%">
<table class="table table-striped" >
<thead>
<tr>
<div>
<form class="form-horizontal" th:action="@{/getTableList}" method="post">
<input type="text" name="selectKey">
<button type="submit" class="line btn btn-primary btn-sm" id="upaddbut11">查询</button>
</form>
<th colspan="5" style="text-align:left ;font-size: 20px"><button class="line btn btn-primary btn-sm" onclick="add()" >添加候选人</button>
<a th:onclick="'javascript:importExcel();'" style="text-decoration: none;">
<button class="line btn btn-primary btn-sm" >导入</button>
</a>
<button class="line btn btn-primary btn-sm" onclick="exportExcel()" >导出</button>
</div>
</tr>
<tr>
<th>姓名</th>
<th>性别</th>
<th>出生年月</th>
<th>年龄</th>
<th>学历</th>
<th>专业</th>
<th>联系方式</th>
<th>邮箱</th>
<th>岗位</th>
<th>应聘部门</th>
<th>状态</th>
<th>编辑</th>
</tr>
</thead>
<tbody>
<tr th:each="students: ${students.getContent()}">
<!-- <td><li type=""></li></td>-->
<td th:text="${students.candidateName}"></td>
<td th:text="${students.sex}"></td>
<td th:text="${students.datename}"></td>
<td th:text="${students.age}"></td>
<td th:text="${students.background}"></td>
<td th:text="${students.major}"></td>
<td th:text="${students.phone}"></td>
<td th:text="${students.email}"></td>
<td th:text="${students.station}"></td>
<td th:text="${students.department}"></td>
<td th:text="${students.state}"></td>
<td>
<a th:onclick="'javascript:edit(\''+${students.studentId}+'\');'" style="text-decoration: none;">
<button class="btn btn-default" style="width: 50px;height: 30px;background: #3e8f3e">修改</button>
</a>
<a th:onclick="'javascript:trash(\''+${students.studentId}+'\');'" style="text-decoration: none;"
data-toggle="modal" data-target="#trashModal">
<button class="btn btn-default" style="width: 50px;height: 30px;background: red">
删除
</button>
</a>
<a th:onclick="'javascript:upload(\''+${students.studentId}+'\');'" style="text-decoration: none;">
<button class="btn btn-default" style="width: 50px;height: 30px;background: #3e6d8f">上传</button>
</a>
<a th:onclick="'javascript:preview(\''+${students.studentId}+'\');'" style="text-decoration: none;">
<button class="btn btn-default" style="width: 50px;height: 30px;background: #3e6d8f">查看</button>
</a>
<!-- <a>-->
<!-- <input type="button" value="预览" id="viewBtn">-->
<!-- </a>-->
</td>
</tr>
</tbody>
</table>
</div>
<div class="row" style="margin-left: 18%">
<!--分页文字信息 -->
<div class="col-md-6">当前 <span th:text="${students.getNumber()} + 1"></span>页,总<span th:text="${students.totalPages}"></span>
页,总 <span th:text="${students.totalElements}"></span> 个内容</div>
<!-- 分页条信息 -->
<div class="col-md-6">
<nav aria-label="Page navigation">
<ul class="pagination">
<li><a th:href="@{/AdminStudentManage}">首页</a></li>
<li><a th:href="@{/AdminStudentManage(pageNum = ${students.hasPrevious()} ? ${students.getNumber() } : 1)}">上一页</a></li>
<li><a th:href="@{/AdminStudentManage(pageNum = ${students.hasNext()} ? ${students.getNumber()} + 2 : ${students.totalPages})}">下一页</a></li>
<li><a th:href="@{/AdminStudentManage(pageNum = ${students.totalPages})}">末页</a></li>
</ul>
</nav>
</div>
</div>
</div>
<div class="modal fade" id="addch" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="my" style="text-align:center">添加候选人</h4>
</div>
<form class="form-horizontal" th:action="@{/addStudent}" method="post" onsubmit="return toadd()">
<div class="modal-body">
<div class="form-group">
<label class="col-sm-2 control-label">姓名</label>
<div class="col-sm-10">
<input type="text" name="candidateName" class="form-control" id="candidateName"
placeholder="">
<span class="help-block"></span>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">性别</label>
<div class="col-sm-10">
<select id="sex" name="sex" οnchange="show_sub(this.options[this.options.selectedIndex].value)">
<option value="男">男</option>
<option value="女">女</option>
</select>
<!-- <select id="sid">-->
<!-- <option>---请选择---</option>-->
<!-- <option>男</option>-->
<!-- <option>女</option>-->
<!-- </select>-->
<!-- <input type="text" name="sex" class="form-control" id="sex"-->
<!-- placeholder="">-->
<span class="help-block"></span>
</div>
</div>
<div class="form-group ">
<label class="col-sm-2 control-label">出生年月</label>
<div class="col-sm-10">
<input type="date" name="datename" class="form-control" id="datename"
placeholder="" onchange="submitBday()">
<span class="help-block"></span>
</div>
</div>
<div class="form-group ">
<label class="col-sm-2 control-label">年龄</label>
<div class="col-sm-10">
<input type="text" name="age" class="form-control" id="age"
placeholder="">
<span class="help-block"></span>
</div>
</div>
<div class="form-group ">
<label class="col-sm-2 control-label">学历</label>
<div class="col-sm-10">
<input type="text" name="background" class="form-control" id="background"
placeholder="">
<span class="help-block"></span>
</div>
</div>
<div class="form-group ">
<label class="col-sm-2 control-label">专业</label>
<div class="col-sm-10">
<input type="text" name="major" class="form-control" id="major"
placeholder="">
<span class="help-block"></span>
</div>
</div>
<div class="form-group ">
<label class="col-sm-2 control-label">联系方式</label>
<div class="col-sm-10">
<input type="text" name="phone" class="form-control" id="phone"
placeholder="">
<span class="help-block"></span>
</div>
</div>
<div class="form-group ">
<label class="col-sm-2 control-label">邮箱</label>
<div class="col-sm-10">
<input type="text" name="email" class="form-control" id="email"
placeholder="">
<span class="help-block"></span>
</div>
</div>
<div class="form-group ">
<label class="col-sm-2 control-label">岗位</label>
<div class="col-sm-10">
<input type="text" name="station" class="form-control" id="station"
placeholder="">
<span class="help-block"></span>
</div>
</div>
<div class="form-group ">
<label class="col-sm-2 control-label">应聘部门</label>
<div class="col-sm-10">
<input type="text" name="department" class="form-control" id="department"
placeholder="">
<span class="help-block"></span>
</div>
</div>
<div class="form-group ">
<label class="col-sm-2 control-label">状态</label>
<div class="col-sm-10">
<select id="state" name="state" οnchange="show_sub(this.options[this.options.selectedIndex].value)">
<option value="简历筛选">简历筛选</option>
<option value="约面">约面</option>
<option value="初试">初试</option>
<option value="复试">复试</option>
<option value="谈薪">谈薪</option>
<option value="审批">审批</option>
<option value="未通过">未通过</option>
</select>
<!-- <input type="text" name="state" class="form-control" id="state"-->
<!-- placeholder="">-->
<span class="help-block"></span>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
<button type="submit" class="btn btn-primary" id="addbut">提交</button>
</div>
</form>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!--<form class="form-horizontal" th:action="@{/getTableList}" method="post">-->
<!-- <input type="text" name="selectKey">-->
<!-- <button type="submit" class="line btn btn-primary btn-sm" id="upaddbut11">查询</button>-->
<!--</form>-->
<!--上传文件-->
<div class="modal fade" id="uploadch" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="my1" style="text-align:center">上传文件</h4>
</div>
<form align="center" th:action="@{/fileUpload}" method="post" enctype="multipart/form-data">
<input id="uploadStudentIddd" name="uploadStudentId" hidden="hidden"/>
<input type="file" name="fileName"/>
<input type="submit" value="提交"/>
</form>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<div class="modal fade" id="importExcelch" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="my2" style="text-align:center">导入文件</h4>
</div>
<form th:action="@{/importExcel}" method="post" enctype="multipart/form-data">
<!-- <input id="uploadStudentIddd" name="uploadStudentId" hidden="hidden"/>-->
<input type="file" name="fileName"/>
<br/>
<input class="line btn btn-primary btn-sm" type="submit" value="提交"/>
</form>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- Modal编辑模态框 -->
<div class="modal fade" id="editch" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myedit">编辑</h4>
</div>
<form class="form-horizontal" th:action="@{/updateStudent}" method="post" onsubmit="return toupdate()">
<div class="modal-body">
<input name="studentId" id="studentId1" hidden="hidden"/>
<!-- <input name="roleid" value="1" hidden="hidden"/>-->
<div class="form-group">
<label class="col-sm-2 control-label">姓名</label>
<div class="col-sm-10">
<input type="text" name="candidateName" class="form-control" id="candidateName1">
<span class="help-block"></span>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">性别</label>
<div class="col-sm-10">
<select id="sex1" name="sex" οnchange="show_sub(this.options[this.options.selectedIndex].value)">
<option value="男">男</option>
<option value="女">女</option>
</select>
<!-- <input type="text" name="sex" class="form-control" id="sex1">-->
<span class="help-block"></span>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">出生年月</label>
<div class="col-sm-10">
<input type="text" name="datename" class="form-control" id="datename1">
<span class="help-block"></span>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">年龄</label>
<div class="col-sm-10">
<input type="text" name="age" class="form-control" id="age1">
<span class="help-block"></span>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">学历</label>
<div class="col-sm-10">
<input type="text" name="background" class="form-control" id="background1">
<span class="help-block"></span>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">专业</label>
<div class="col-sm-10">
<input type="text" name="major" class="form-control" id="major1">
<span class="help-block"></span>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">联系方式</label>
<div class="col-sm-10">
<input type="text" name="phone" class="form-control" id="phone1">
<span class="help-block"></span>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">邮箱</label>
<div class="col-sm-10">
<input type="text" name="email" class="form-control" id="email1">
<span class="help-block"></span>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">岗位</label>
<div class="col-sm-10">
<input type="text" name="station" class="form-control" id="station1">
<span class="help-block"></span>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">应聘部门</label>
<div class="col-sm-10">
<input type="text" name="department" class="form-control" id="department1">
<span class="help-block"></span>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">状态</label>
<div class="col-sm-10">
<select id="state1" name="state" οnchange="show_sub(this.options[this.options.selectedIndex].value)">
<option value="简历筛选">简历筛选</option>
<option value="约面">约面</option>
<option value="初试">初试</option>
<option value="复试">复试</option>
<option value="谈薪">谈薪</option>
<option value="审批">审批</option>
<option value="未通过">未通过</option>
</select>
<!-- <input type="text" name="state" class="form-control" id="state1">-->
<span class="help-block"></span>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
<button type="submit" class="btn btn-primary" id="upaddbut">提交</button>
</div>
</form>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!--删除的模态框-->
<div class="modal fade" id="trashModal">
<div class="modal-dialog">
<div class="modal-content">
<!-- 模糊框头部 -->
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×
</button>
<h4 class="modal-title">删除!</h4>
</div>
<!-- 模糊框主体 -->
<div class="modal-body">
<strong>你确定要删除吗?</strong>
(将删除与该数据相关联的所有数据)
</div>
<!-- 模糊框底部 -->
<div class="modal-footer">
<button type="button" class="delSure btn btn-info" data-dismiss="modal">确定</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
</div>
</div>
</div>
</div>
<!-- /.container-fluid -->
</div>
<!-- /#page-wrapper -->
</div>
</div>
<script>
var pathAll = window.document.location.pathname;
var contextPath="/"+pathAll.split("/")[1];
console.log("pathc ****",pathAll,contextPath)
function toadd(){
var val = document.getElementById("candidateName").value;
var datename=document.getElementById("datename").value;
var age=document.getElementById("age").value;
var background=document.getElementById("background").value;
var major=document.getElementById("major").value;
var phone=document.getElementById("phone").value;
var email=document.getElementById("email").value;
var regExp = new RegExp("^1[356789]\\d{9}$");//手机号规则
var reg=/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;//邮箱规则
var station=document.getElementById("station").value;
var department=document.getElementById("department").value;
if(val ==null||val==""){
alert("候选人姓名不可以为空");
return false;
}
if(datename==null||datename==""){
alert("出生年月不可以为空");
return false;
}
if(age==null||age==""){
alert("年龄不可以为空");
return false;
}
if(background==null||background==""){
alert("学历不可以为空");
return false;
}if(major==null||major==""){
alert("专业不可以为空");
return false;
}
if(phone==null||phone==""){
alert("手机号码不可以为空");
return false;
}if(!regExp.test(phone)){
alert("手机号必须满足11位数字!");
return false;
}
if(email==null||email==""){
alert("邮箱不可以为空");
return false;
}
if(!reg.test(email)){
alert("邮箱不符合规则");
return false;
}
if(station==null||station==""){
alert("岗位不可以为空");
return false;
}
if(department==null||department==""){
alert("应聘部门不可以为空");
return false;
}
alert("填写信息格式正确,提交成功");
return true;
}
function toupdate(){
var val = document.getElementById("candidateName1").value;
var datename=document.getElementById("datename1").value;
var age=document.getElementById("age1").value;
var background=document.getElementById("background1").value;
var major=document.getElementById("major1").value;
var phone=document.getElementById("phone1").value;
var email=document.getElementById("email1").value;
var regExp = new RegExp("^1[356789]\\d{9}$");//手机号规则
var reg=/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;//邮箱规则
var station=document.getElementById("station1").value;
var department=document.getElementById("department1").value;
if(val ==null||val==""){
alert("候选人姓名不可以为空");
return false;
}
if(datename==null||datename==""){
alert("出生年月不可以为空");
return false;
}
if(age==null||age==""){
alert("年龄不可以为空");
return false;
}
if(background==null||background==""){
alert("学历不可以为空");
return false;
}if(major==null||major==""){
alert("专业不可以为空");
return false;
}
if(phone==null||phone==""){
alert("手机号码不可以为空");
return false;
}if(!regExp.test(phone)){
alert("手机号必须满足11位数字!");
return false;
}
if(email==null||email==""){
alert("邮箱不可以为空");
return false;
}
if(!reg.test(email)){
alert("邮箱不符合规则");
return false;
}
if(station==null||station==""){
alert("岗位不可以为空");
return false;
}
if(department==null||department==""){
alert("应聘部门不可以为空");
return false;
}
alert("修改信息格式正确,提交成功");
return true;
}
function submitBday() {
var Q4A;
var Bdate = document.getElementById('datename').value;
var Bday = +new Date(Bdate);
Q4A = ~~ ((Date.now() - Bday) / (31557600000));
$("#age").val(Q4A);
}
function preview(studentId){
var str=contextPath+"/preview?studentId="+studentId;
var curWwwPath = window.document.location.href;
var pathName = window.document.location.pathname;
var pos = curWwwPath.indexOf(pathName);
var localhostPath = curWwwPath.substring(0, pos);
window.open(localhostPath
+ contextPath+"/pdf/web/viewer.html?file="
+ encodeURIComponent(str));
}
function importSubmit() {
var config = layui.config;
//请求的数据是FormData类型
var formData = new FormData();
//获取上传的文件
formData.append("file",$("#file")[0].files[0]);
//url为文件读取的后台controller请求路径
var url = '###';
//ajax提交请求,注意data、contentType、processData和dataType的设置
$.ajax({
type: "POST",
url: contextPath+'/importSubmit',
data: formData,
contentType: false,
processData:false,
dataType: "json",
success: function(resp_data) {
if (resp_data.resp_code==0){
//js封装了admin对象
var admin = layui.admin;
//admin对象封装了缓存和弹窗方法
admin.putTempData("importData",resp_data.data);
//可以使用普通弹窗,弹出层用于文件解析后的页面渲染
admin.popupCenter({
title: '导入内容',
area:['800px','600px'],
path: 'pages/import_form.html',
finish: function () {
//完成后可以根据自己需求刷新表格展示数据
layui.table.reload('mytable', {});
}
});
}else {
if (resp_data.resp_msg) {
layui.layer.msg(resp_data.resp_msg, {icon: 2, time: 2000});
}else {
layui.layer.msg(resp_data.msg, {icon: 2, time: 2000});
}
}
},
error: function(xhr, textStatus, errorThrown) {
if (xhr.status == 401) {
localStorage.removeItem("access_token");
}
}
});
}
function getTableList(){
console.log("1234555")
var name = $('#studentName_select').val();
var phone = $('#phone_select').val();
var email = $('#email_select').val();
console.log("&&",name,phone,email);
$.ajax({
url: contextPath+'/getTableList',
type: 'POST',
dataType: 'json',
contentType: 'application/json;charset=UTF-8',
data: JSON.stringify({
candidateName: name,
phone: phone,
email: email
}),
success: function (data) {
console.log(data);
},
error: function () {
alert("错误!!!");
}
});
}
function F_Open_dialog() {
document.getElementById("btn_file").click();
}
function show_sub(v){
alert(v);
}
function upload(studentId) {
var obj = document.getElementById("uploadStudentIddd");
obj.value = studentId;
let newValue = $('#uploadStudentIddd').val() ;
console.log("新的id",newValue);
// studenId 放到定义的虚拟 input
$("#uploadch").modal({
backdrop: "static"
});
};
function importExcel(){
$("#importExcelch").modal({
backdrop: "static"
});
};
// 查看附件
function look(studentId) {
let url = '***.pdf' // '***.word' '***.xls'
if(url.endsWith('.pdf')){ // PDF 预览
window.open("https://view.xdocin.com/xdoc?_xdoc=" + encodeURIComponent("https://view.xdocin.com/doc/preview.docx"));
} else { // 微软或者其它的预览方式
window.open("http://view.officeapps.live.com/op/view.aspx?src=" + encodeURIComponent("https://www.***.com/upload_files/编号12的.xls"));
}
};
//添加
function add() {
$("#addch").modal({
backdrop: "static"
});
};
function edit(studentId) {
if (!studentId) {
alert("error");
} else {
// 先去查询数据
$.ajax({
url: contextPath+'/studentEdit',
type: 'POST',
dataType: 'json',
contentType: 'application/json;charset=UTF-8',
data: JSON.stringify({
studentId: studentId
}),
success: function (data) {
$("#studentId1").val(data.studentId);
console.log("学生id"+studentId);
$("#candidateName1").val(data.candidateName);
$("#sex1").val(data.sex);
$("#datename1").val(data.datename);
$("#age1").val(data.age);
$("#background1").val(data.background);
$("#major1").val(data.major)
$("#phone1").val(data.phone);
$("#email1").val(data.email);
$("#station1").val(data.station);
$("#department1").val(data.department);
$("#state1").val(data.state);
$("#editch").modal('show');
},
error: function () {
alert("错误");
}
});
}
}
//删除
function trash(studentId) {
if (!studentId) {
alert("error");
} else {
$(".delSure").click(function () {
$.ajax({
url: contextPath+'/deleteStudent?studentId=' + studentId,
type: 'POST',
success: function (data) {
$("body").html(data);
}
});
});
}
}
//导出数据库的数据
function exportExcel() {
$.ajax({
url: contextPath+'/exportExcel',
type: 'POST',
success: function () {
alert("导出成功");
},
error: function () {
alert("错误");
}
});
}
</script>
</body>
</html>
三、职位申请表链接
3.1 数据库表结构
其中sid为外键,表student的主键
CREATE TABLE `position` (
`pid` int NOT NULL AUTO_INCREMENT,
`sid` int NOT NULL COMMENT '外键连接student表',
`channel` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '招聘渠道',
`nativePlace` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '籍贯',
`salaryCurrent` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '目前薪资',
`salaryNext` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '期望薪资',
`workHistory` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '工作经历',
`nameCheck` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '是否愿意接受背景调查',
`huKou` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '户口所在地',
`ResidentialAddress` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '现居住地',
`workDate` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '工作日期',
`IDCard` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '身份证号',
`socialInsurance` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '社保类型',
`friendWork` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '您是否有亲戚朋友在本公司工作',
`discipline` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '你是否曾因为行为或工作受到原公司的纪律处分(包括过失性解除劳动合同)?',
`disease` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '你是否有下列身体状况:残疾、慢性病、在一年内住过院或其他正在治疗的疾病?',
`crime` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '您是否有过犯罪记录?',
PRIMARY KEY (`pid`) USING BTREE,
KEY `sid` (`sid`) USING BTREE,
CONSTRAINT `sid` FOREIGN KEY (`sid`) REFERENCES `student` (`studentId`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC;
3.2 职位申请表
逻辑:相当于一个新增的过程,将链接发给应聘者,然后应聘者填写信息,填写后的信息将保存在数据库内。
接口url:/applyInformationManage打开页面的接口即发送的链接
/addStudentInfor点击保存时调用的接口
model层
@Entity
public class Position {
private Long pid;
private String channel;
private String nativePlace;
private String salaryCurrent;
private String salaryNext;
private String workHistory;
private String nameCheck;
private String huKou;
private String ResidentialAddress;
private String workDate;
private String IDCard;
private String socialInsurance;
private String friendWork;
private String discipline;
private String disease;
private String crime;
@Basic
@Column(name = "IDCard", nullable = true)
public String getIDCard() {
return IDCard;
}
public void setIDCard(String IDCard) {
this.IDCard = IDCard;
}
@Basic
@Column(name = "socialInsurance", nullable = true)
public String getSocialInsurance() {
return socialInsurance;
}
public void setSocialInsurance(String socialInsurance) {
this.socialInsurance = socialInsurance;
}
@Basic
@Column(name = "friendWork", nullable = true)
public String getFriendWork() {
return friendWork;
}
public void setFriendWork(String friendWork) {
this.friendWork = friendWork;
}
@Basic
@Column(name = "discipline", nullable = true)
public String getDiscipline() {
return discipline;
}
public void setDiscipline(String discipline) {
this.discipline = discipline;
}
@Basic
@Column(name = "disease", nullable = true)
public String getDisease() {
return disease;
}
public void setDisease(String disease) {
this.disease = disease;
}
@Basic
@Column(name = "crime", nullable = true)
public String getCrime() {
return crime;
}
public void setCrime(String crime) {
this.crime = crime;
}
@Basic
@Column(name = "workDate", nullable = true)
public String getWorkDate() {
return workDate;
}
public void setWorkDate(String workDate) {
this.workDate = workDate;
}
private Integer sid;
@Basic
@Column(name = "sid", nullable = true)
public Integer getSid() {
return sid;
}
public void setSid(Integer sid) {
this.sid = sid;
}
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "pid", nullable = false)
public Long getPid() {
return pid;
}
public void setPid(Long pid) {
this.pid = pid;
}
@Basic
@Column(name = "channel", nullable = true)
public String getChannel() {
return channel;
}
public void setChannel(String channel) {
this.channel = channel;
}
@Basic
@Column(name = "nativePlace", nullable = true)
public String getNativePlace() {
return nativePlace;
}
public void setNativePlace(String nativePlace) {
this.nativePlace = nativePlace;
}
@Basic
@Column(name = "salaryCurrent", nullable = true)
public String getSalaryCurrent() {
return salaryCurrent;
}
public void setSalaryCurrent(String salaryCurrent) {
this.salaryCurrent = salaryCurrent;
}
@Basic
@Column(name = "salaryNext", nullable = true)
public String getSalaryNext() {
return salaryNext;
}
public void setSalaryNext(String salaryNext) {
this.salaryNext = salaryNext;
}
@Basic
@Column(name = "workHistory", nullable = true)
public String getWorkHistory() {
return workHistory;
}
public void setWorkHistory(String workHistory) {
this.workHistory = workHistory;
}
@Basic
@Column(name = "nameCheck", nullable = true)
public String getNameCheck() {
return nameCheck;
}
public void setNameCheck(String nameCheck) {
this.nameCheck = nameCheck;
}
@Basic
@Column(name = "huKou", nullable = true)
public String getHuKou() {
return huKou;
}
public void setHuKou(String huKou) {
this.huKou = huKou;
}
@Basic
@Column(name = "ResidentialAddress", nullable = true)
public String getResidentialAddress() {
return ResidentialAddress;
}
public void setResidentialAddress(String residentialAddress) {
ResidentialAddress = residentialAddress;
}
}
controller层
@RequestMapping("/applyInformationManage")
private String applyInformationManage(){
return "/admin/apply";
}
@RequestMapping("/addStudentInfor")
@ResponseBody
private Map<String, Object> addStudentInfor(String name, String phone, String channel, String nativePlace, String salaryCurrent, String salaryNext, String workHistory,
String nameCheck, String huKou, String ResidentialAddress, String workDate, String IDCard, String socialInsurance
, String friendWork, String discipline, String disease, String crime, HttpServletRequest request, HttpServletResponse response) throws IOException {
Integer sid =studentDao.selectPhone(phone,name);
Map<String, Object> map = new HashMap<>();
String error="";
if(sid==null){
// map.put("ok","1");
response.setCharacterEncoding("UTF-8");
response.setContentType("application/json");
map.put("data","填写信息不存在,请检查姓名和联系方式后重试");
map.put("status",-1);
// System.out.println("1111");
// response.setContentType("text/html;charset=utf-8");
// response.sendRedirect("/yonyou-resume/applyInformationManage");
// PrintWriter out = response.getWriter();
// out.flush();
// out.println("<script>");
// out.println("alert('未找到信息!');");
// out.println("history.back();");
// out.println("</script>");
return map;
}
Position position=new Position();
position.setSid(sid);
position.setChannel(channel);
position.setNativePlace(nativePlace);
position.setSalaryCurrent(salaryCurrent);
position.setSalaryNext(salaryNext);
position.setWorkHistory(workHistory);
position.setNameCheck(nameCheck);
position.setHuKou(huKou);
position.setResidentialAddress(ResidentialAddress);
position.setWorkDate(workDate);
position.setIDCard(IDCard);
position.setFriendWork(friendWork);
position.setSocialInsurance(socialInsurance);
position.setDiscipline(discipline);
position.setDisease(disease);
position.setCrime(crime);
positionDao.save(position);
map.put("data","添加成功");
map.put("status",0);
return map;
}
dao层
判断是否已经存在应聘者基本信息如果存在才能继续填写
@Query(value ="select studentId from student where phone=? and candidateName=?", nativeQuery = true)
Integer selectPhone(String phone,String name);
3.3 前端页面
<!DOCTYPE html>
<meta name="viewport"
content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=2.0, user-scalable=yes"/>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>职位申请</title>
<div th:replace="include/bootstrap :: bootstrap"></div>
<style>
.in {
width: 200px;
height: 25px;
/*margin-left: 10px;*/
}
.in1 {
width: 200px;
height: 200px;
/*margin-left: 10px;*/
}
tr {
line-height: 20px;
/*margin-top:10px;*/
}
a {
width: 100px;
height: 25px;
}
</style>
</head>
<body>
<script src="https://cdn.bootcss.com/jquery.form/4.2.2/jquery.form.js"></script>
<!--th:action="@{/addStudentInfor}" method="post"-->
<h2 style="border: #1e1b29" align="center">职位申请表</h2>
<form class="form-horizontal" th:action="@{/addStudentInfor}" method="post" id="frm-reg" name="frm-reg">
<table style="border: 1px;margin: 0px auto;">
<td align="left">姓名:</td>
<tr>
<td colspan="2"><input id="name" name="name" type="text" class="in" placeholder="请输入姓名"><span
id="unameSpan"></span></td>
</tr>
<td align="left">性别:</td>
<tr>
<td class="in">
<select class="in" οnchange="show_sub(this.options[this.options.selectedIndex].value)">
<option value="男">男</option>
<option value="女">女</option>
</select>
</td>
</tr>
<td align="left">联系方式</td>
<tr>
<td colspan="2"><input id="phone" name="phone" type="text" class="in" placeholder="请输入联系方式"></td>
</tr>
<td align="left">邮箱</td>
<tr>
<td colspan="2"><input id="email" name="email" type="text" class="in" placeholder="Email"></td>
</tr>
<td align="left">招聘渠道</td>
<tr>
<td colspan="2" class="in"><select id="channel" name="channel" class="in"
οnchange="show_sub(this.options[this.options.selectedIndex].value)">
<option value="内部员工推荐">内部员工推荐</option>
<option value="外部推荐">外部推荐</option>
<option value="boss直聘">boss直聘</option>
<option value="其他">其他</option>
</select></td>
</tr>
<td align="right"></td>
<tr>
<td colspan="2"><input type="text" class="in" placeholder="若为其他请填写何种渠道"></td>
</tr>
<td align="left">籍贯</td>
<tr>
<td colspan="2"><input name="nativePlace" id="nativePlace" type="text" class="in"
placeholder="请输入籍贯"><span id="nativePlaceSpan"></span></td>
</tr>
<td align="left">目前薪资</td>
<tr>
<td colspan="2"><input name="salaryCurrent" id="salaryCurrent" type="text" class="in"
placeholder="请输入当前薪资"></td>
</tr>
<td align="left">期望薪资</td>
<tr>
<td colspan="2"><input name="salaryNext" id="salaryNext" type="text" class="in"
placeholder="期望薪资(税前)"></td>
</tr>
<td align="left">是否接受背景调查</td>
<tr>
<td colspan="2" class="in"><select id="nameCheck" name="nameCheck" class="in"
οnchange="show_sub(this.options[this.options.selectedIndex].value)">
<option value="是">是</option>
<option value="是">否</option>
</select></td>
</tr>
<td align="left">户口所在地</td>
<tr>
<td colspan="2"><input name="huKou" id="huKou" type="text" class="in" placeholder="输入户口所在地"></td>
</tr>
<td align="left">现居住地</td>
<tr>
<td colspan="2"><input name="ResidentialAddress" id="ResidentialAddress" type="text" class="in"
placeholder="请输入现居住地"></td>
</tr>
<td align="left">工作日期</td>
<tr>
<td colspan="2"><input name="workDate" id="workDate" type="date" class="in" placeholder="可以开始工作日期" onchange="submitBday()">
</td>
</tr>
<td align="left">工作经历</td>
<tr>
<td colspan="2"><input id="workHistory" name="workHistory" type="text" class="in1"
placeholder="请输入工作经历"><span id="workHistorySpan"></span></td>
</tr>
<td align="left">身份证号</td>
<tr>
<td colspan="2"><input id="IDCard" name="IDCard" type="text" class="in" placeholder="请输入身份证号"><span
id="IDCardSpan"></span></td>
</tr>
<td align="left">目前所缴社保种类</td>
<tr>
<td colspan="2" class="in"><select id="socialInsurance" name="socialInsurance" class="in"
οnchange="show_sub(this.options[this.options.selectedIndex].value)">
<option value="五险一金">五险一金</option>
<option value="三险一金">三险一金</option>
</select></td>
</tr>
<td align="left">是否有亲戚朋友在本公司工作</td>
<tr>
<td colspan="2" class="in"><select id="friendWork" name="friendWork" class="in"
οnchange="show_sub(this.options[this.options.selectedIndex].value)">
<option value="是">是</option>
<option value="否">否</option>
</select></td>
</tr>
<td align="left" class="center">是否因为行为或工作受到公司的纪律处分</td>
<tr>
<td colspan="2" class="in"><select id="discipline" name="discipline" class="in"
οnchange="show_sub(this.options[this.options.selectedIndex].value)">
<option value="是">是</option>
<option value="否">否</option>
</select></td>
</tr>
<td align="left">残疾、慢性病、在一年内住过院或其他正在治疗的疾病?</td>
<tr>
<td colspan="2" class="in"><select id="disease" name="disease" class="in"
οnchange="show_sub(this.options[this.options.selectedIndex].value)">
<option value="是">是</option>
<option value="否">否</option>
</select></td>
</tr>
<td align="left">是否有过犯罪记录</td>
<tr>
<td colspan="2" class="in"><select id="crime" name="crime" class="in"
οnchange="show_sub(this.options[this.options.selectedIndex].value)">
<option value="是">是</option>
<option value="否">否</option>
</select></td>
</tr>
<tr>
<td colspan="4" align="right">感谢您的参与</td>
</tr>
<!-- <input type="hidden" id="err" th:value="${error}"/>-->
<!-- th:action="@{/addStudentInfor}"-->
<tr>
<td colspan="4" align="right">
<input type="submit" id="submit" value="提交">
<input type="reset" value="退出">
</td>
</tr>
</table>
</form>
<script>
//表单提交,会把所有有name属性的值提交到后台
$("#submit").click(function () {
let check = checkSub();
if (!check){
return false;
}
$("#frm-reg").ajaxSubmit(function (data) {
console.log(data)
alert(data.data);
});
return false;
});
var pathAll = window.document.location.pathname;
var contextPath = "/" + pathAll.split("/")[1];
function check(){
var name = document.getElementById("name").value;
var phone=document.getElementById("phone").value;
var nativePlace=document.getElementById("nativePlace").value;
var salaryCurrent=document.getElementById("salaryCurrent").value;
var salaryNext=document.getElementById("salaryNext").value;
var huKou=document.getElementById("huKou").value;
var ResidentialAddress=document.getElementById("ResidentialAddress").value;
var workDate=document.getElementById("workDate").value;
var workHistory=document.getElementById("workHistory").value;
var IDCard=document.getElementById("IDCard").value;
console.log(name);
$.ajax({
type: "post",
url: contextPath+'/addStudentInfor',
data: {
"name": name,
phone: phone,
channel: channel,
nativePlace: nativePlace,
salaryCurrent: salaryCurrent,
salaryNext: salaryNext,
workHistory: workHistory,
huKou: huKou,
ResidentialAddress: ResidentialAddress,
workDate: workDate,
IDCard: IDCard,
nameCheck: nameCheck,
socialInsurance: socialInsurance,
friendWork: friendWork,
discipline: discipline,
disease: disease,
crime: crime,
},
success: function(status, resp) {
console.log("响应状态码:" + status + ",响应正文:" + resp);
//转换响应正文json字符串为json对象
var json = JSON.parse(resp);
if(json.ok){//登陆
alert("用户信息不存在,请确认后在提交");
}else{
alert("提交成功");
location.href = contextPath+'/addStudentInfor';
}
}
})
}
// 检验身份证号格式
function checkeNO(NO){
var str=NO;
//在JavaScript中,正则表达式只能使用"/"开头和结束,不能使用双引号
var Expression=/^\d{17}[\d|X]$|^\d{15}$/;
var objExp=new RegExp(Expression);
if(objExp.test(str)==true){
return true;
}else{
return false;
}
}
var pathAll = window.document.location.pathname;
var contextPath = "/" + pathAll.split("/")[1];
function submitBday() {
var Q4A;
var Bdate = document.getElementById('time').value;
var Bday = +new Date(Bdate);
Q4A = ~~ ((Date.now() - Bday) / (31557600000));
$("#age").val(Q4A);
}
function edit(studentId) {
if (!studentId) {
alert("error");
} else {
// 先去查询数据
$.ajax({
url: contextPath + '/studentEdit',
type: 'POST',
dataType: 'json',
contentType: 'application/json;charset=UTF-8',
data: JSON.stringify({
studentId: studentId
}),
success: function (data) {
$("#studentId").val(data.studentId);
console.log("学生id" + studentId);
$("#candidateName").val(data.candidateName);
$("#sex").val(data.sex);
$("#datename").val(data.datename);
$("#age").val(data.age);
$("#background").val(data.background);
$("#major").val(data.major);
$("#phone").val(data.phone);
$("#email").val(data.email);
$("#station").val(data.station);
$("#department").val(data.department);
$("#state").val(data.state);
$("#editch").modal('show');
},
error: function () {
alert("错误");
}
});
}
}
function show_sub(v) {
alert(v);
}
function checkSub() {
var name = document.getElementById("name").value;
var phone=document.getElementById("phone").value;
var email=document.getElementById("email").value;
var regExp = new RegExp("^1[356789]\\d{9}$");//手机号码规则
var regEmail=/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;//邮箱规则
//创建校验规则
var reg = /^[\u4e00-\u9fa5]{2,4}$/;
var nativePlace=document.getElementById("nativePlace").value;
var salaryCurrent=document.getElementById("salaryCurrent").value;
var salaryNext=document.getElementById("salaryNext").value;
var huKou=document.getElementById("huKou").value;
var ResidentialAddress=document.getElementById("ResidentialAddress").value;
var workDate=document.getElementById("workDate").value;
var workHistory=document.getElementById("workHistory").value;
var IDCard=document.getElementById("IDCard").value;
// var error=document.getElementById("err").value;
// console.log(error);
//获取span对象
// var span = document.getElementById("unameSpan");
//开始校验
if (name == "" || name == null) {
alert("用户名不能为空");
return false;
//输出校验结果
} if (!reg.test(name)) {
//输出校验结果
alert("用户名错误");
return false;
}if(phone==""||phone==null){
alert("联系方式不可以为空");
return false;
}if(!regExp.test(phone)){
alert("联系方式必须为11位!");
return false;
}if(email==""||email==null){
alert("邮箱不能为空");
return false;
}
if(!regEmail.test(email)){
alert("邮箱格式错误");
return false;
}
if(nativePlace==""||nativePlace==null){
alert("籍贯不能为空");
return false;
}
if(salaryCurrent==""||salaryCurrent==null){
alert("目前薪资不能为空");
return false;
}
if(salaryNext==""||salaryNext==null){
alert("期望薪资不能为空");
return false;
}
if(huKou==""||huKou==null){
alert("户口所在地不可以为空");
return false;
}
if(ResidentialAddress==""||ResidentialAddress==null){
alert("现居住地不可以为空");
return false;
}
if(workDate==""||workDate==null){
alert("工作日期不可以为空");
return false;
}
if(workHistory==""||workHistory==null){
alert("工作经历不可以为空");
return false;
}if(IDCard==""||IDCard==null){
alert("身份证号不可以为空");
return false;
}if(!checkeNO(IDCard)) {
alert("身份证号格式错误!");
return false;
}
return true;
}
</script>
</body>
</html>
四、职位申请信息管理
4.1 职位申请列表
这里的职位申请列表和应聘者信息列表是一个接口但是在前端显示的内容不同
4.2 查看职位申请表
逻辑:在填写完职位申请表链接后,数据库存储应聘者职位申请信息,会有一个没有存储信息的word模版,在点击查看之后,会把信息填充到word模版对应位置,转成pdf显示在浏览器
接口url:/look
请求参数:Integer studentId, HttpServletResponse response
/**
* 查看职位申请者表格
* 1、首先将数据库中的数据填充到word表格中
* 2、将word转成pdf
* 3、在前端显示pdf文件
* @param studentId
* @param response
* @throws IOException
*/
@RequestMapping(value = "/look", method = RequestMethod.GET)
public void look(Integer studentId, HttpServletResponse response) throws IOException {
String sys = System.getProperty("os.name");
if(sys.startsWith("Linux")){}
String dict = sys.startsWith("Windows") ? "E:\\print\\"+studentId:"/print/"+studentId;
String rootPath = System.getProperty("user.dir");
File file1=new File(dict+"/doc");
if (!file1.exists()) {
file1.mkdirs();
}
File file2=new File(dict+"/pdf");
if (!file2.exists()) {
file2.mkdirs();
}
Word word=new Word();
Student student=studentDao.findByUserid(studentId);
Position position=positionDao.selectById(studentId);
if(position!=null) {
word.readTableData("Job_application.doc", student, position, studentId);
String s = String.valueOf(studentId);
String docPath = dict + "/doc/" + s + ".docx";
String pdfPath = dict + "/pdf/" + s + ".pdf";
PdfUtil.doc2pdf(docPath, pdfPath);
File file = new File(pdfPath);
if (file.exists()) {
byte[] data = null;
try {
FileInputStream input = new FileInputStream(file);
data = new byte[input.available()];
input.read(data);
response.getOutputStream().write(data);
input.close();
} catch (Exception e) {
System.out.println("文件处理异常");
// logger.info("pdf文件处理异常...");
}
}
}else{
System.out.println("该用户还没有填写职位申请表");
}
}
dao层
@Query(value ="select * from student where studentId=?", nativeQuery = true)
Student findByUserid(Integer studentId);
@Query(value ="select * from position where sid=? limit 0,1", nativeQuery = true)
Position selectById(Integer sid);