From 84232c9860500bd25bb453b902f41bba101a13db Mon Sep 17 00:00:00 2001
From: Unique-Jerry <10902054+unique-jerry@user.noreply.gitee.com>
Date: Fri, 10 Nov 2023 18:28:31 +0800
Subject: [PATCH] =?UTF-8?q?=E6=8B=9B=E8=81=98=E9=83=A8=E5=88=86=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD=E5=AE=8C=E5=96=84?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pom.xml | 15 +
.../controller/RecruitmentController.java | 75 ++-
.../controller/UploadController.java | 178 ++++++-
.../yzdx/AiInterviewer/entity/Company.java | 5 +-
.../AiInterviewer/entity/CompanyImage.java | 11 +
.../mapper/CompanyImageMapper.java | 9 +
.../AiInterviewer/service/CompanyService.java | 15 +
.../service/InterviewSettingService.java | 39 +-
.../service/impl/CompanyServiceImpl.java | 27 +
.../impl/InterviewSettingServiceImpl.java | 42 ++
.../yzdx/AiInterviewer/utiles/HttpUtil.java | 468 ++++++++++++++++++
.../AiInterviewer/utiles/ParseResumeUtil.java | 28 ++
.../yzdx/AiInterviewer/utiles/ParseTest.java | 10 +
src/main/resources/application.yml | 4 +-
14 files changed, 901 insertions(+), 25 deletions(-)
create mode 100644 src/main/java/com/yzdx/AiInterviewer/entity/CompanyImage.java
create mode 100644 src/main/java/com/yzdx/AiInterviewer/mapper/CompanyImageMapper.java
create mode 100644 src/main/java/com/yzdx/AiInterviewer/service/CompanyService.java
create mode 100644 src/main/java/com/yzdx/AiInterviewer/service/impl/CompanyServiceImpl.java
create mode 100644 src/main/java/com/yzdx/AiInterviewer/utiles/HttpUtil.java
create mode 100644 src/main/java/com/yzdx/AiInterviewer/utiles/ParseResumeUtil.java
create mode 100644 src/main/java/com/yzdx/AiInterviewer/utiles/ParseTest.java
diff --git a/pom.xml b/pom.xml
index 6a1f860..9ecb6c3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -101,7 +101,22 @@
commons-io
2.4
+
+
+ org.apache.poi
+ poi
+ 5.2.3
+
+
+ org.apache.httpcomponents
+ httpclient
+
+
+ commons-httpclient
+ commons-httpclient
+ 3.0
+
diff --git a/src/main/java/com/yzdx/AiInterviewer/controller/RecruitmentController.java b/src/main/java/com/yzdx/AiInterviewer/controller/RecruitmentController.java
index bf2a37f..d7d02aa 100644
--- a/src/main/java/com/yzdx/AiInterviewer/controller/RecruitmentController.java
+++ b/src/main/java/com/yzdx/AiInterviewer/controller/RecruitmentController.java
@@ -1,18 +1,22 @@
package com.yzdx.AiInterviewer.controller;
import com.yzdx.AiInterviewer.comment.R;
+import com.yzdx.AiInterviewer.entity.Company;
import com.yzdx.AiInterviewer.entity.JobEntity;
import com.yzdx.AiInterviewer.entity.dto.JobDto;
import com.yzdx.AiInterviewer.entity.dto.JobSettingDto;
+import com.yzdx.AiInterviewer.service.CompanyService;
import com.yzdx.AiInterviewer.service.InterviewSettingService;
import com.yzdx.AiInterviewer.service.JobListService;
import com.yzdx.AiInterviewer.utiles.MyStringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
+import javax.servlet.http.HttpSession;
+import java.io.File;
+import java.io.IOException;
+import java.util.*;
@RestController
@@ -23,6 +27,8 @@ public class RecruitmentController {
private JobListService jobListService;
@Autowired
private InterviewSettingService interviewSettingService;
+ @Autowired
+ private CompanyService companyService;
@PostMapping("/add_job")
public R addJob(@RequestBody Map addInfo){
@@ -204,4 +210,67 @@ public class RecruitmentController {
List jobSettingList = interviewSettingService.getJobSettingList(encoding);
return R.success(jobSettingList);
}
+
+ @GetMapping("/delete_jobJobSetting")
+ public R deleteJobSetting(Integer id){
+
+ Integer rows = interviewSettingService.deleteJobSetting(id);
+
+ if(rows==-1){
+ R.error("删除失败,请联系管理员");
+ }
+ return R.success("删除成功!");
+ }
+ @PostMapping("/update_jobJobSetting")
+ public R updateJobSetting(@RequestBody Map updateInfo){
+ Integer id = (Integer) updateInfo.get("id");
+ Integer jobId = (Integer) updateInfo.get("jobId");
+ Integer imagesId = (Integer) updateInfo.get("imagesId");
+ Integer backgroundId = (Integer) updateInfo.get("backgroundId");
+ Integer logoId = (Integer) updateInfo.get("logoId");
+ Integer Professional = null;
+ try {
+ Professional = (Integer) updateInfo.get("professional");
+ } catch (Exception e) {
+
+ }
+ Integer Comprehensive = null;
+ try {
+ Comprehensive = (Integer) updateInfo.get("comprehensive");
+ } catch (Exception e) {
+
+ }
+ Integer Psychology = null;
+ try {
+ Psychology = (Integer) updateInfo.get("psychology");
+ } catch (Exception e) {
+
+ }
+ Integer userId = (Integer) updateInfo.get("userId");
+ String jobPromote = (String) updateInfo.get("jobPromote");
+ String encoding = (String) updateInfo.get("encoding");
+
+ Integer rows= interviewSettingService.updateJobSetting(id,jobId, imagesId, backgroundId, logoId, Professional, Comprehensive, Psychology, userId, jobPromote, encoding);
+
+ if(rows==-1){
+ return R.error("修改失败");
+ }
+ return R.success("修改成功");
+ }
+
+
+ @GetMapping("/get_companyDetail")
+ public R getCompanyDetail(String encoding){
+
+ if(encoding==null){
+ return R.error("获取失败");
+ }
+
+ Company companyDetail = companyService.getCompanyDetail(encoding);
+ if(companyDetail==null){
+ return R.error("获取失败");
+ }
+ return R.success(companyDetail);
+ }
+
}
diff --git a/src/main/java/com/yzdx/AiInterviewer/controller/UploadController.java b/src/main/java/com/yzdx/AiInterviewer/controller/UploadController.java
index eed627d..23cfa26 100644
--- a/src/main/java/com/yzdx/AiInterviewer/controller/UploadController.java
+++ b/src/main/java/com/yzdx/AiInterviewer/controller/UploadController.java
@@ -1,7 +1,12 @@
package com.yzdx.AiInterviewer.controller;
+
import com.yzdx.AiInterviewer.comment.R;
+import com.yzdx.AiInterviewer.entity.CompanyImage;
+import com.yzdx.AiInterviewer.mapper.CompanyImageMapper;
+import com.yzdx.AiInterviewer.utiles.ParseResumeUtil;
import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
@@ -17,9 +22,14 @@ import java.util.*;
@Slf4j
public class UploadController {
+
+ @Autowired
+ private CompanyImageMapper companyImageMapper;
//设置上传文件的最大大小
public static final int MAX_SIZE=10*1024*1024;
- public static final String UPLOAD_PATH = "D:\\vue学习\\Ai-interviewer-ui\\src\\upload";//获取上传文件的路径(获取项目中名为‘upload’的文件夹)
+ public static final String UPLOAD_AVATAR_PATH = "D:\\vueStudy\\Ai-interviewer-ui\\src\\upload\\picture";//获取上传文件的路径(获取项目中名为‘upload’的文件夹)
+ public static final String UPLOAD_RESUME_PATH = "D:\\vueStudy\\Ai-interviewer-ui\\src\\upload\\resume";//获取上传文件的路径(获取项目中名为‘upload’的文件夹)
+
//设置文件的类型
public static final List AVATAR_TYPE=new ArrayList<>();
@@ -31,8 +41,8 @@ public class UploadController {
AVATAR_TYPE.add("image/jpeg");
}
- @PostMapping("/upload_picture")
- public R upLoadPicture(HttpSession session, @RequestParam("file") MultipartFile file){
+ @PostMapping("/upload_companyImage")
+ public R upLoadPicture(HttpSession session, @RequestParam("file") MultipartFile file ,String encoding){
//MultipartFile是spring提供的类,可以接收所有的文件的类
@@ -51,11 +61,11 @@ public class UploadController {
}
// String uploadPath = session.getServletContext().getRealPath("upload");//获取上传文件的路径(获取项目中名为‘upload’的文件夹)
- String uploadPath = "D:\\vue学习\\Ai-interviewer-ui\\src\\upload";//获取上传文件的路径(获取项目中名为‘upload’的文件夹)
+// String uploadPath = "D:\\vue学习\\Ai-interviewer-ui\\src\\upload";//获取上传文件的路径(获取项目中名为‘upload’的文件夹)
+//
+// log.info(uploadPath);
- log.info(uploadPath);
-
- File dir=new File(UPLOAD_PATH);//指向名为‘upload’文件夹
+ File dir=new File(UPLOAD_AVATAR_PATH);//指向名为‘upload’文件夹
if(!dir.exists()){
dir.mkdirs();//若不存在,则创建该文件夹
@@ -80,15 +90,15 @@ public class UploadController {
return R.error("文件存储出现异常");
}
- String RealFilePath="http://localhost:5173/src/upload/"+filename;
-
- Map data=new HashMap<>();
- data.put("image",RealFilePath);
- data.put("filename",filename);
-
- return R.success(data);//返回图片存储在服务器的地址
+ String RealFilePath="http://localhost:5173/src/upload/picture/"+filename;
+ CompanyImage companyImage=new CompanyImage();
+ companyImage.setImage(RealFilePath);
+ companyImage.setFilename(filename);
+ companyImage.setEncoding(encoding);
+ companyImageMapper.insert(companyImage);
+ return R.success(companyImage);//返回图片存储在服务器的地址
}
@GetMapping("/delete_picture")
@@ -98,7 +108,7 @@ public class UploadController {
}
try {
- File folder = new File(UPLOAD_PATH);
+ File folder = new File(UPLOAD_AVATAR_PATH);
File[] files = folder.listFiles();
for(File file:files){
if(file.getName().equals(imagePath)){
@@ -112,4 +122,142 @@ public class UploadController {
}
+
+ @PostMapping("/upload_resume")
+ public R uploadResume(HttpSession session, @RequestParam("file") MultipartFile file){
+ if(file.isEmpty()){
+ return R.error("请选择文件");
+ }
+
+ if (file.getSize() >50*1024*1024){//file.getSize()获取接收文件的大小
+ return R.error("文件大小超出最大限制");
+ }
+
+// String uploadPath = session.getServletContext().getRealPath("upload");//获取上传文件的路径(获取项目中名为‘upload’的文件夹)
+// String uploadPath = "D:\\vue学习\\Ai-interviewer-ui\\src\\upload";//获取上传文件的路径(获取项目中名为‘upload’的文件夹)
+//
+// log.info(uploadPath);
+
+ File dir=new File(UPLOAD_RESUME_PATH);//指向名为‘upload’文件夹
+
+ if(!dir.exists()){
+ dir.mkdirs();//若不存在,则创建该文件夹
+ }
+
+ String originalFilename = file.getOriginalFilename();//获取文件的真实文件名
+
+ int index = originalFilename.lastIndexOf(".");//获取文件的后缀名‘.’的位置
+
+ String substring = originalFilename.substring(index);//返回文件类型名 例如:.jpg
+
+ String filename = UUID.randomUUID().toString().toUpperCase()+substring;//新创建的文件名
+
+ File dest=new File(dir,filename);//创建一个空的文件
+
+ try {
+
+ file.transferTo(dest);
+
+ } catch (IOException e) {
+
+ return R.error("文件存储出现异常");
+
+ }
+ String RealFilePath="http://localhost:5173/src/upload/resume/"+filename;
+
+ ParseResumeUtil.ParseChineseResume(UPLOAD_RESUME_PATH+"\\"+filename);
+
+ Map data=new HashMap<>();
+ data.put("resume",RealFilePath);
+ data.put("filename",filename);
+
+ return R.success(data);//返回图片存储在服务器的地址
+
+
+
+ }
+
+ @GetMapping("/delete_resume")
+ public R deleteResume(String resumePath){
+ if(resumePath==null||resumePath.equals("")){
+ return R.error("删除失败!");
+ }
+
+ try {
+ File folder = new File(UPLOAD_AVATAR_PATH);
+ File[] files = folder.listFiles();
+ for(File file:files){
+ if(file.getName().equals(resumePath)){
+ file.delete();
+ }
+ }
+ return R.success("删除成功");
+ } catch (Exception e) {
+ return R.error("删除失败");
+ }
+
+
+ }
+
+
+ @PostMapping("/upload_picture")
+ public R uploadCompanyImage(HttpSession session, @RequestParam("file") MultipartFile file){
+ //MultipartFile是spring提供的类,可以接收所有的文件的类
+
+ log.info(file.getContentType());
+
+ if(file.isEmpty()){
+ return R.error("请选择文件");
+ }
+
+ if (file.getSize() >MAX_SIZE){//file.getSize()获取接收文件的大小
+ return R.error("文件大小超出最大限制");
+ }
+ if(!AVATAR_TYPE.contains(file.getContentType())){//自定义接收文件的类型
+ return R.error("文件类型不匹配");
+ }
+
+// String uploadPath = session.getServletContext().getRealPath("upload");//获取上传文件的路径(获取项目中名为‘upload’的文件夹)
+// String uploadPath = "D:\\vue学习\\Ai-interviewer-ui\\src\\upload";//获取上传文件的路径(获取项目中名为‘upload’的文件夹)
+//
+// log.info(uploadPath);
+
+ File dir=new File(UPLOAD_AVATAR_PATH);//指向名为‘upload’文件夹
+
+ if(!dir.exists()){
+ dir.mkdirs();//若不存在,则创建该文件夹
+ }
+
+ String originalFilename = file.getOriginalFilename();//获取文件的真实文件名
+
+ int index = originalFilename.lastIndexOf(".");//获取文件的后缀名‘.’的位置
+
+ String substring = originalFilename.substring(index);//返回文件类型名 例如:.jpg
+
+ String filename= UUID.randomUUID().toString().toUpperCase()+substring;//新创建的文件名
+
+ File dest=new File(dir,filename);//创建一个空的文件
+
+ try {
+
+ file.transferTo(dest);
+
+ } catch (IOException e) {
+
+ return R.error("文件存储出现异常");
+
+ }
+ String RealFilePath="http://localhost:5173/src/upload/picture/"+filename;
+
+ Map data=new HashMap<>();
+ data.put("image",RealFilePath);
+ data.put("filename",filename);
+
+ return R.success(data);//返回图片存储在服务器的地址
+
+ }
+
+
}
+
+
diff --git a/src/main/java/com/yzdx/AiInterviewer/entity/Company.java b/src/main/java/com/yzdx/AiInterviewer/entity/Company.java
index 351f821..9c75bf0 100644
--- a/src/main/java/com/yzdx/AiInterviewer/entity/Company.java
+++ b/src/main/java/com/yzdx/AiInterviewer/entity/Company.java
@@ -19,15 +19,14 @@ public class Company extends BaseEntity{
private Integer id;
@ApiModelProperty("公司名称")
private String companyName;
- @ApiModelProperty("公司全称")
- @TableField(value = "company_allname")
- private String companyAllName;
@ApiModelProperty("公司详情")
private String companyDetail;
@ApiModelProperty("公司类型")
private String type;
@ApiModelProperty("公司地址")
private String address;
+ @ApiModelProperty("公司详细地址")
+ private String addressDetail;
@ApiModelProperty("公司待遇")
private String treatment;
@ApiModelProperty("法定代表人")
diff --git a/src/main/java/com/yzdx/AiInterviewer/entity/CompanyImage.java b/src/main/java/com/yzdx/AiInterviewer/entity/CompanyImage.java
new file mode 100644
index 0000000..75cc9ec
--- /dev/null
+++ b/src/main/java/com/yzdx/AiInterviewer/entity/CompanyImage.java
@@ -0,0 +1,11 @@
+package com.yzdx.AiInterviewer.entity;
+
+import lombok.Data;
+
+@Data
+public class CompanyImage {
+ private Integer id;
+ private String filename;
+ private String image;
+ private String encoding;
+}
diff --git a/src/main/java/com/yzdx/AiInterviewer/mapper/CompanyImageMapper.java b/src/main/java/com/yzdx/AiInterviewer/mapper/CompanyImageMapper.java
new file mode 100644
index 0000000..741abac
--- /dev/null
+++ b/src/main/java/com/yzdx/AiInterviewer/mapper/CompanyImageMapper.java
@@ -0,0 +1,9 @@
+package com.yzdx.AiInterviewer.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.yzdx.AiInterviewer.entity.CompanyImage;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface CompanyImageMapper extends BaseMapper {
+}
diff --git a/src/main/java/com/yzdx/AiInterviewer/service/CompanyService.java b/src/main/java/com/yzdx/AiInterviewer/service/CompanyService.java
new file mode 100644
index 0000000..278c060
--- /dev/null
+++ b/src/main/java/com/yzdx/AiInterviewer/service/CompanyService.java
@@ -0,0 +1,15 @@
+package com.yzdx.AiInterviewer.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.yzdx.AiInterviewer.entity.Company;
+
+public interface CompanyService extends IService {
+
+ /**
+ * 获取公司详情
+ * @param encoding 公司编码
+ * @return 公司详情对象
+ *
+ * */
+ Company getCompanyDetail(String encoding);
+}
diff --git a/src/main/java/com/yzdx/AiInterviewer/service/InterviewSettingService.java b/src/main/java/com/yzdx/AiInterviewer/service/InterviewSettingService.java
index 0789965..aa93b04 100644
--- a/src/main/java/com/yzdx/AiInterviewer/service/InterviewSettingService.java
+++ b/src/main/java/com/yzdx/AiInterviewer/service/InterviewSettingService.java
@@ -35,8 +35,43 @@ public interface InterviewSettingService extends IService {
String encoding);
/**
* 获取岗位设置列表
- *
- *
+ * @param encoding 公司编码
+ * @return 返回JobSettingDto列表
* */
List getJobSettingList(String encoding);
+
+ /**
+ * 根据没你事设置id删除面试设置
+ * @param id 岗位设置的id
+ * @return 返回影响的行数
+ * */
+ Integer deleteJobSetting(Integer id);
+
+ /**
+ * 修改岗位设置
+ * @param id 岗位设置id
+ * @param jobId 岗位id
+ * @param imagesId 形象id
+ * @param backgroundId 面试背景id
+ * @param logoId 公司logoId
+ * @param Professional 专业题库id
+ * @param Comprehensive 综合面试题库id
+ * @param Psychology 心理测试id
+ * @param userId 创建人id
+ * @param jobPromote 岗位promote
+ * @param encoding 公司编码
+ * @return 影响的行数
+ * */
+
+ Integer updateJobSetting(Integer id,
+ Integer jobId,
+ Integer imagesId,
+ Integer backgroundId,
+ Integer logoId,
+ Integer Professional,
+ Integer Comprehensive,
+ Integer Psychology,
+ Integer userId,
+ String jobPromote,
+ String encoding);
}
diff --git a/src/main/java/com/yzdx/AiInterviewer/service/impl/CompanyServiceImpl.java b/src/main/java/com/yzdx/AiInterviewer/service/impl/CompanyServiceImpl.java
new file mode 100644
index 0000000..f271bbb
--- /dev/null
+++ b/src/main/java/com/yzdx/AiInterviewer/service/impl/CompanyServiceImpl.java
@@ -0,0 +1,27 @@
+package com.yzdx.AiInterviewer.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.yzdx.AiInterviewer.entity.Company;
+import com.yzdx.AiInterviewer.mapper.CompanyMapper;
+import com.yzdx.AiInterviewer.service.CompanyService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class CompanyServiceImpl extends ServiceImpl implements CompanyService {
+
+ @Autowired
+ private CompanyMapper companyMapper;
+
+ @Override
+ public Company getCompanyDetail(String encoding) {
+ LambdaQueryWrapper queryWrapper=new LambdaQueryWrapper<>();
+
+ queryWrapper.eq(Company::getEncoding,encoding);
+
+ Company company = companyMapper.selectOne(queryWrapper);
+
+ return company;
+ }
+}
diff --git a/src/main/java/com/yzdx/AiInterviewer/service/impl/InterviewSettingServiceImpl.java b/src/main/java/com/yzdx/AiInterviewer/service/impl/InterviewSettingServiceImpl.java
index 6f961d5..d259b28 100644
--- a/src/main/java/com/yzdx/AiInterviewer/service/impl/InterviewSettingServiceImpl.java
+++ b/src/main/java/com/yzdx/AiInterviewer/service/impl/InterviewSettingServiceImpl.java
@@ -150,4 +150,46 @@ public class InterviewSettingServiceImpl extends ServiceImpl queryWrapper=new LambdaQueryWrapper<>();
+
+ queryWrapper.eq(InterviewSetting::getId,id);
+
+ InterviewSetting findJobSetting = interviewSettingMapper.selectOne(queryWrapper);
+
+ if(findJobSetting==null){
+ return -1;
+ }
+ Integer rows = interviewSettingMapper.deleteById(id);
+
+ return rows;
+ }
+
+ @Override
+ public Integer updateJobSetting(Integer id, Integer jobId, Integer imagesId, Integer backgroundId, Integer logoId, Integer Professional, Integer Comprehensive, Integer Psychology, Integer userId, String jobPromote, String encoding) {
+ //根据id查找岗位设置
+ LambdaQueryWrapper queryWrapper=new LambdaQueryWrapper<>();
+
+ queryWrapper.eq(InterviewSetting::getId,id);
+
+ InterviewSetting findSetting = interviewSettingMapper.selectOne(queryWrapper);
+
+ if(findSetting==null){
+ return -1;
+ }
+
+ findSetting.setImagesId(imagesId);
+ findSetting.setLogoId(logoId);
+ findSetting.setBackgroundId(backgroundId);
+ findSetting.setPsychology(Psychology);
+ findSetting.setProfessional(Professional);
+ findSetting.setComprehensive(Comprehensive);
+ findSetting.setUpdateTime(TimeUtil.getTime());
+ findSetting.setUpdateUser(userId);
+
+ return interviewSettingMapper.updateById(findSetting);
+
+ }
}
diff --git a/src/main/java/com/yzdx/AiInterviewer/utiles/HttpUtil.java b/src/main/java/com/yzdx/AiInterviewer/utiles/HttpUtil.java
new file mode 100644
index 0000000..8793ee8
--- /dev/null
+++ b/src/main/java/com/yzdx/AiInterviewer/utiles/HttpUtil.java
@@ -0,0 +1,468 @@
+package com.yzdx.AiInterviewer.utiles;
+import io.netty.util.internal.StringUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.httpclient.DefaultHttpMethodRetryHandler;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpStatus;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.RequestEntity;
+import org.apache.commons.httpclient.methods.StringRequestEntity;
+import org.apache.commons.httpclient.params.HttpClientParams;
+import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
+import org.apache.commons.httpclient.params.HttpMethodParams;
+import org.apache.http.HttpEntity;
+import org.apache.http.NameValuePair;
+import org.apache.http.ParseException;
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.params.CoreConnectionPNames;
+import org.apache.http.protocol.HTTP;
+import org.apache.http.util.EntityUtils;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+@Slf4j
+public class HttpUtil {
+
+ private HttpUtil(){
+ }
+
+ private static void configTimeout(HttpClient httpClient){
+ HttpConnectionManagerParams params = httpClient.getHttpConnectionManager().getParams();
+ params.setConnectionTimeout(20000);
+ params.setSoTimeout(20000);
+ }
+
+ public static String post(String url, String reqParam) throws Exception {
+
+ HttpClient httpClient = new HttpClient();
+
+ // 请求url
+ PostMethod method = new PostMethod(url);
+
+ configTimeout(httpClient);
+ // 设置请求编码UTF-8
+ method.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");
+ method.addRequestHeader(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");
+
+ RequestEntity entity = new StringRequestEntity(reqParam);
+
+ method.setRequestEntity(entity);
+
+ // 执行post请求
+ httpClient.executeMethod(method);
+
+ // 请求返回
+ String respResult = method.getResponseBodyAsString();
+
+ // 释放连接
+ method.releaseConnection();
+
+ return respResult;
+ }
+
+ public static String jsonPost(String url, String reqParam) throws Exception {
+
+ HttpClient httpClient = new HttpClient();
+
+ // 请求url
+ PostMethod method = new PostMethod(url);
+
+ configTimeout(httpClient);
+
+ // 设置请求编码UTF-8
+ method.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");
+ method.addRequestHeader(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");
+
+ RequestEntity entity = new StringRequestEntity(reqParam, "application/json", "utf-8");
+
+ method.setRequestEntity(entity);
+
+ // 执行post请求
+ httpClient.executeMethod(method);
+
+ // 请求返回
+ String respResult = method.getResponseBodyAsString();
+
+ // 释放连接
+ method.releaseConnection();
+ log.info("请求{}返回:{}", url, respResult);
+ return respResult;
+ }
+
+ public static String post(String url, String reqParam, String charSet) throws Exception {
+
+ HttpClient httpClient = new HttpClient();
+
+ // 请求url
+ PostMethod method = new PostMethod(url);
+
+ configTimeout(httpClient);
+ // 设置请求编码UTF-8
+ method.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, charSet);
+ method.addRequestHeader(HttpMethodParams.HTTP_CONTENT_CHARSET, charSet);
+
+ RequestEntity entity = new StringRequestEntity(reqParam);
+
+ method.setRequestEntity(entity);
+ // 执行post请求
+ httpClient.executeMethod(method);
+
+ // 请求返回
+ String respResult = method.getResponseBodyAsString();
+
+ // 释放连接
+ method.releaseConnection();
+ log.info("请求{}返回:{}", url, respResult);
+ return respResult;
+ }
+
+ public static String get(String url, String reqParam) throws Exception {
+
+// reqParam = URLEncoder.encode(reqParam, "UTF-8");
+
+ HttpClient httpClient = new HttpClient();
+ GetMethod method;
+
+ if(StringUtil.isNullOrEmpty(reqParam)){
+ // 请求url及参数
+ method = new GetMethod(url);
+ }
+ else {
+ System.out.println("------请求URL:"+url + "?" +reqParam);
+ // 请求url及参数
+ method = new GetMethod(url + "?" +reqParam);
+ }
+ configTimeout(httpClient);
+ // 设置请求编码UTF-8
+ method.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");
+ method.addRequestHeader(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");
+
+ // 执行get请求
+ httpClient.executeMethod(method);
+
+ // 请求返回
+ String respResult = method.getResponseBodyAsString();
+
+ // 释放连接
+ method.releaseConnection();
+ log.info("请求{}返回:{}", url, respResult);
+ return respResult;
+ }
+
+ public static String get(String url, String reqParam, String charSet) throws Exception {
+
+// reqParam = URLEncoder.encode(reqParam, "UTF-8");
+
+ HttpClient httpClient = new HttpClient();
+ GetMethod method;
+
+ if(StringUtil.isNullOrEmpty(reqParam)){
+ // 请求url及参数
+ method = new GetMethod(url);
+ }
+ else {
+ System.out.println("请求URL字符串:"+url + "?" +reqParam);
+ // 请求url及参数
+ method = new GetMethod(url + "?" +reqParam);
+ }
+ configTimeout(httpClient);
+ // 设置请求编码UTF-8
+ method.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, charSet);
+ method.addRequestHeader(HttpMethodParams.HTTP_CONTENT_CHARSET, charSet);
+
+ // 执行get请求
+ httpClient.executeMethod(method);
+
+ // 请求返回
+ String respResult = method.getResponseBodyAsString();
+
+ // 释放连接
+ method.releaseConnection();
+ log.info("请求{}返回:{}", url, respResult);
+ return respResult;
+ }
+ /**
+ * 添加header "Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"
+ */
+ public static String postHeader(String url, String reqParam) throws Exception {
+
+ HttpClient httpClient = new HttpClient();
+
+ HttpClientParams params = new HttpClientParams();
+ //另外设置http client的重试次数,默认是3次;当前是禁用掉(如果项目量不到,这个默认即可)
+ params.setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(0, false));
+ httpClient.setParams(params);
+
+ // 请求url
+ PostMethod method = new PostMethod(url);
+ configTimeout(httpClient);
+ // 设置请求编码UTF-8
+ method.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");
+ method.addRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
+ RequestEntity entity = new StringRequestEntity(reqParam);
+
+ method.setRequestEntity(entity);
+
+
+ // 执行post请求
+ httpClient.executeMethod(method);
+
+ // 请求返回
+ String respResult = method.getResponseBodyAsString();
+
+ // 释放连接
+ method.releaseConnection();
+ log.info("请求{}返回:{}", url, respResult);
+ return respResult;
+ }
+
+ @SuppressWarnings({ "deprecation", "unused" })
+ private static HttpPost postForm(String url, Map params){
+
+ HttpPost httpost = new HttpPost(url);
+ List nvps = new ArrayList <>();
+
+ Set keySet = params.keySet();
+ for(String key : keySet) {
+ nvps.add(new BasicNameValuePair(key, params.get(key)));
+ }
+
+ try {
+ httpost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ }
+
+ return httpost;
+ }
+
+ /**
+ * post请求<设置请求头>
+ * @param url 请求地址
+ * @param reqParamName 请求参数名称
+ * @param reqParamValue 请求参数值
+ * @param charSet 编码格式
+ * @author yew
+ * date 2017年7月26日 下午2:11:40
+ */
+ public static String postRequset(String url, String reqParamName, String reqParamValue, String charSet) throws Exception {
+
+ HttpClient httpClient = new HttpClient();
+
+ // 请求url
+ PostMethod method = new PostMethod(url);
+ configTimeout(httpClient);
+ // 设置请求编码UTF-8
+ method.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, charSet);
+ method.addRequestHeader(HttpMethodParams.HTTP_CONTENT_CHARSET, charSet);
+ //设置参数请求头
+ method.setParameter(reqParamName, reqParamValue);
+
+ // 执行post请求
+ httpClient.executeMethod(method);
+
+ // 请求返回
+ String respResult = method.getResponseBodyAsString();
+
+ // 释放连接
+ method.releaseConnection();
+ log.info("请求{}返回:{}", url, respResult);
+ return respResult;
+ }
+
+ public static String jsonPostHeader(String url, String reqParam, String accessToken, String version) throws Exception {
+
+ HttpClient httpClient = new HttpClient();
+
+ // 请求url
+ PostMethod method = new PostMethod(url);
+ configTimeout(httpClient);
+ // 设置请求编码UTF-8
+ method.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");
+ method.addRequestHeader(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");
+ method.addRequestHeader("accessToken", accessToken);
+ method.addRequestHeader("version", version);
+
+ RequestEntity entity = new StringRequestEntity(reqParam, "application/json", "utf-8");
+
+ method.setRequestEntity(entity);
+
+ // 执行post请求
+ httpClient.executeMethod(method);
+
+ // 请求返回
+ String respResult = method.getResponseBodyAsString();
+
+ // 释放连接
+ method.releaseConnection();
+ log.info("请求{}返回:{}", url, respResult);
+ return respResult;
+ }
+
+ public static String jsonPostHeader(String url, String reqParam) throws Exception {
+
+ HttpClient httpClient = new HttpClient();
+
+ // 请求url
+ PostMethod method = new PostMethod(url);
+ configTimeout(httpClient);
+ // 设置请求编码UTF-8
+ method.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");
+ method.addRequestHeader(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");
+ RequestEntity entity = new StringRequestEntity(reqParam, "application/xml", "utf-8");
+
+ method.setRequestEntity(entity);
+
+ // 执行post请求
+ httpClient.executeMethod(method);
+
+ // 请求返回
+ String respResult = method.getResponseBodyAsString();
+
+ // 释放连接
+ method.releaseConnection();
+ log.info("请求{}返回:{}", url, respResult);
+ return respResult;
+ }
+
+ /**
+ * post key-value形式传参
+ * @param url 请求url
+ * @param paramsMap 请求的map数据
+ * @return
+ */
+ public static String postFormMap(String url, Map paramsMap) {
+ CloseableHttpClient closeableHttpClient = HttpClients.createDefault();
+ //配置连接超时时间
+ RequestConfig requestConfig = RequestConfig.custom()
+ .setConnectTimeout(5000)
+ .setConnectionRequestTimeout(5000)
+ .setSocketTimeout(5000)
+ .setRedirectsEnabled(true)
+ .build();
+ HttpPost httpPost = new HttpPost(url);
+ //设置超时时间
+ httpPost.setConfig(requestConfig);
+ //装配post请求参数
+ List list = new ArrayList<>();
+ for (String key : paramsMap.keySet()) {
+ list.add(new BasicNameValuePair(key, String.valueOf(paramsMap.get(key))));
+ }
+ try {
+ //将参数进行编码为合适的格式,如将键值对编码为param1=value1¶m2=value2
+ UrlEncodedFormEntity urlEncodedFormEntity = new UrlEncodedFormEntity(list, "utf-8");
+ httpPost.setEntity(urlEncodedFormEntity);
+ //执行 post请求
+ CloseableHttpResponse closeableHttpResponse = closeableHttpClient.execute(httpPost);
+ String result = "";
+ if (null != closeableHttpResponse) {
+ System.out.println(closeableHttpResponse.getStatusLine().getStatusCode());
+ if (closeableHttpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
+ HttpEntity httpEntity = closeableHttpResponse.getEntity();
+ result = EntityUtils.toString(httpEntity);
+ } else {
+ result = "Error Response" + closeableHttpResponse.getStatusLine().getStatusCode();
+ }
+ }
+ log.info("请求{}返回:{}", url, result);
+ return result;
+ } catch (ClientProtocolException e) {
+ e.printStackTrace();
+ return "协议异常";
+ } catch (ParseException e) {
+ e.printStackTrace();
+ return "解析异常";
+ } catch (IOException e) {
+ e.printStackTrace();
+ return "传输异常";
+ } finally {
+ try {
+ if (closeableHttpClient != null) {
+ closeableHttpClient.close();
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * @param url
+ * @param reqParam 请求参数
+ * @param headerParam 请求头参数
+ * @return
+ */
+
+ public static String post(String url, String reqParam,Map headerParam) throws Exception {
+
+ HttpClient httpClient = new HttpClient();
+ httpClient.getParams().setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 5000);
+ httpClient.getParams().setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 3000);
+
+ // 请求url
+ PostMethod method = new PostMethod(url);
+
+ configTimeout(httpClient);
+ // 设置请求编码UTF-8
+ method.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");
+ method.addRequestHeader(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");
+ for (Map.Entry vo : headerParam.entrySet()) {
+ method.addRequestHeader(vo.getKey(),vo.getKey());
+ }
+ RequestEntity entity = new StringRequestEntity(reqParam);
+
+ method.setRequestEntity(entity);
+
+ // 执行post请求
+ httpClient.executeMethod(method);
+
+ // 请求返回
+ String respResult = method.getResponseBodyAsString();
+
+ // 释放连接
+ method.releaseConnection();
+
+ return respResult;
+ }
+
+ public static String get(String url, Map headerParam) throws Exception {
+
+ HttpClient httpClient = new HttpClient();
+ httpClient.getParams().setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 5000);
+ httpClient.getParams().setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 3000);
+ GetMethod method;
+ method = new GetMethod(url);
+ configTimeout(httpClient);
+ // 设置请求编码UTF-8
+ method.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");
+ method.addRequestHeader(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");
+ for (Map.Entry vo : headerParam.entrySet()) {
+ method.addRequestHeader(vo.getKey(),vo.getKey());
+ }
+ // 执行get请求
+ httpClient.executeMethod(method);
+
+ // 请求返回
+ String respResult = method.getResponseBodyAsString();
+
+ // 释放连接
+ method.releaseConnection();
+ log.info("请求{}返回:{}", url, respResult);
+ return respResult;
+ }
+
+}
+
diff --git a/src/main/java/com/yzdx/AiInterviewer/utiles/ParseResumeUtil.java b/src/main/java/com/yzdx/AiInterviewer/utiles/ParseResumeUtil.java
new file mode 100644
index 0000000..8bfa14c
--- /dev/null
+++ b/src/main/java/com/yzdx/AiInterviewer/utiles/ParseResumeUtil.java
@@ -0,0 +1,28 @@
+package com.yzdx.AiInterviewer.utiles;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class ParseResumeUtil {
+
+ public static Map ParseChineseResume(String filePath){
+
+ Map data;
+ String s=null;
+ try {
+ s = HttpUtil.get("http://127.0.0.1:5000/getParseResume?filePath="+filePath, "");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ JSONObject jsonObject = JSON.parseObject(s);
+
+ data = jsonObject.getInnerMap();
+
+ return data;
+ }
+
+}
diff --git a/src/main/java/com/yzdx/AiInterviewer/utiles/ParseTest.java b/src/main/java/com/yzdx/AiInterviewer/utiles/ParseTest.java
new file mode 100644
index 0000000..4c144c7
--- /dev/null
+++ b/src/main/java/com/yzdx/AiInterviewer/utiles/ParseTest.java
@@ -0,0 +1,10 @@
+package com.yzdx.AiInterviewer.utiles;
+import java.util.Map;
+
+public class ParseTest {
+ public static void main(String[] args) {
+
+ Map stringObjectMap = ParseResumeUtil.ParseChineseResume("D:\\94011899\\djangoProject2\\submit-file\\files\\101.docx");
+ System.out.println(stringObjectMap);
+ }
+ }
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index a4dbbc1..6fa8e38 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -25,5 +25,5 @@ spring:
servlet:
multipart:
- max-file-size: 10MB #单个文件大小限制
- max-request-size: 10MB #总文件大小限制(允许存储文件的文件夹大小)
\ No newline at end of file
+ max-file-size: 50MB #单个文件大小限制
+ max-request-size: 50MB #总文件大小限制(允许存储文件的文件夹大小)
\ No newline at end of file