This commit is contained in:
Unique-Jerry 2023-11-27 16:31:15 +08:00
parent 5afe95f67a
commit 09e7bdc354
30 changed files with 441 additions and 64 deletions

13
pom.xml
View File

@ -24,12 +24,22 @@
</properties>
<dependencies>
<!-- 阿里JSON解析器 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.76</version>
</dependency>
<!-- bouncycastle-->
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.54</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
@ -148,6 +158,7 @@
</dependency>
</dependencies>
<build>
<plugins>

View File

@ -2,7 +2,6 @@ package com.yzdx.AiInterviewer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class AiInterviewerApplication {
public static void main(String[] args) {

View File

@ -4,14 +4,19 @@ import com.yzdx.AiInterviewer.comment.R;
import com.yzdx.AiInterviewer.entity.BackgroundEntity;
import com.yzdx.AiInterviewer.entity.ImagesEntity;
import com.yzdx.AiInterviewer.entity.LogoEntity;
import com.yzdx.AiInterviewer.entity.dto.ImageDto;
import com.yzdx.AiInterviewer.service.InterviewBackgroundService;
import com.yzdx.AiInterviewer.service.InterviewImagesService;
import com.yzdx.AiInterviewer.service.InterviewLogoService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
@ -48,21 +53,26 @@ public class InterviewController {
/**
* 添加公司Logo
* @param addInfo:图片名称,公司编码,添加人的id,添加图片的地址,添加的文件名
* @return R
*/
@ResponseBody
@ApiImplicitParams({
@ApiImplicitParam(name = "name", required = true),
@ApiImplicitParam(name = "encoding", required = true),
@ApiImplicitParam(name = "image", required = true),
@ApiImplicitParam(name = "userId", required = true),
@ApiImplicitParam(name = "filename", required = true),
}
)
@PostMapping("/add_logo")
@ApiOperation(value = "添加logo图片",notes = "")
public R addLogo(@RequestBody @ApiParam("传入的值为addInfo:{(String)name,(String)encoding,(String)image,(Integer)userId,(String)filename}") Map<String,Object> addInfo) {
public R addLogo( String name,
@RequestParam(required = true, value = "encoding") String encoding,
@RequestParam(required = true, value = "image") String image,
@RequestParam(required = true, value = "userId") Integer userId,
@RequestParam(required = true, value = "filename") String filename
) {
if(addInfo.size()==0){
return R.error("添加失败!");
}
String name=(String)addInfo.get("name");
String encoding=(String)addInfo.get("encoding");
String image=(String)addInfo.get("image");
Integer userId=(Integer) addInfo.get("userId");
String filename=(String) addInfo.get("filename");
if(filename.equals("")){
return R.error("请添加图片!");
}
@ -85,8 +95,9 @@ public class InterviewController {
public R deleteLogoById(@ApiParam("传入的值为:(Integer)id") Integer id){
Integer rows = LogoService.deleteLogoById(id);
if(rows!=1){
return R.error("删除失败,请联系管理员");
if(rows==-1){
return R.error("删除失败面试设置中使用了该LOGO");
}
return R.success("删除成功");
@ -150,8 +161,9 @@ public class InterviewController {
public R deleteBackgroundById(@ApiParam("传入的值为:(Integer)id") Integer id){
Integer rows = backgroundService.deleteBackgroundById(id);
if(rows!=1){
return R.error("删除失败,请联系管理员");
if(rows==-1){
return R.error("删除失败,面试设置中使用了该背景");
}
return R.success("删除成功");
@ -176,6 +188,17 @@ public class InterviewController {
}
@GetMapping("/getDigitalHuman")
@ApiOperation(value = "根据形象id获取数字人形象",notes = "")
public R<ImageDto> getDigitalHuman(@ApiParam("Integer imageId")Integer imageId){
ImageDto imageDto= imagesService.getDigitalHumanById(imageId);
return R.success(imageDto);
}
/**
* 添加面试官形象照片
* @param addInfo 图片名称,公司编码,添加人的id,添加图片的地址,添加的文件名
@ -194,11 +217,12 @@ public class InterviewController {
String video=(String)addInfo.get("video");
Integer userId=(Integer) addInfo.get("userId");
String filename=(String) addInfo.get("filename");
String sex=(String) addInfo.get("sex");
if(filename.equals("")){
return R.error("请添加图片!");
}
Integer row = imagesService.addImageLogo(name,encoding,image,video,userId,filename);
Integer row = imagesService.addImage(name,encoding,image,video,userId,filename,sex);
if(row!=1){
return R.error("添加失败!");
@ -217,14 +241,16 @@ public class InterviewController {
public R deleteImageById(@ApiParam("传入的值:(Integer)id") Integer id){
Integer rows = imagesService.deleteImageById(id);
if(rows!=1){
return R.error("删除失败,请联系管理员");
if(rows==-1){
return R.error("删除失败,面试设置中使用了该形象");
}
return R.success("删除成功");
}
}

View File

@ -94,7 +94,7 @@ public class UploadController {
return R.error("文件存储出现异常");
}
String RealFilePath="http://101.43.255.47/upload/picture/"+filename;
String RealFilePath="http://117.88.94.226:8080/upload/picture/"+filename;
Map<String,Object> data=new HashMap<>();
data.put("image",RealFilePath);
data.put("filename",filename);
@ -155,7 +155,7 @@ public class UploadController {
}
String RealFilePath="http://101.43.255.47:8080/upload/video/"+filename;
String RealFilePath="http://117.88.94.226:8080/upload/video/"+filename;
Map<String,Object> data=new HashMap<>();
data.put("video",RealFilePath);
data.put("filename",filename);
@ -267,7 +267,7 @@ public class UploadController {
return R.error("文件存储出现异常");
}
String RealFilePath="http://101.43.255.47:8080/upload/resume/"+fileName;
String RealFilePath="http://117.88.94.226:8080/upload/resume/"+fileName;
ExecutorService pool= Executors.newCachedThreadPool();
pool.submit(new Runnable() {
@Override
@ -315,13 +315,7 @@ public class UploadController {
} catch (Exception e) {
return R.error("删除失败");
}
}
}

View File

@ -23,22 +23,20 @@ public class UserController {
* @param loginForm 用户输入的账号密码公司编码
* @return R
* */
@ApiOperation(value = "管理员登录",notes = "")
@ResponseBody
@ApiOperation(value = "管理员登录",notes = "")
@PostMapping("/login")
public R adminLogin(@RequestBody @ApiParam("传入的值:loginForm:{" +
"(String)phone," +
"(String)encoding," +
"(String)password}") Map<String,Object> loginForm){
if(loginForm.size()==0){
return R.error("传来的数据有误,请检查输入");
public R adminLogin(@RequestParam(required = true, value = "phone") String phone,
@RequestParam(required = true, value = "encoding") String encoding,
@RequestParam(required = true, value = "password") String password){
}
String phone=(String)loginForm.get("phone");
String encoding=(String)loginForm.get("encoding");
String password=(String)loginForm.get("password");
return userService.adminLogin(phone, encoding, password);
}
/**
* 用户信息
* @param token 用户登录时返回的token

View File

@ -1,14 +1,20 @@
package com.yzdx.AiInterviewer.controller;
import com.yzdx.AiInterviewer.comment.R;
import com.yzdx.AiInterviewer.service.QuestionService;
import com.yzdx.AiInterviewer.service.ResumeService;
import com.yzdx.AiInterviewer.service.UserService;
import com.yzdx.AiInterviewer.utiles.GetPostUntil;
import com.yzdx.AiInterviewer.utiles.WechatUtils;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import org.apache.commons.codec.binary.Base64;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;
@ -17,6 +23,63 @@ import java.util.Map;
public class VxController {
@Autowired
private ResumeService resumeService;
@Autowired
private UserService userService;
@ApiImplicitParams({
@ApiImplicitParam(name = "js_code", required = true)
}
)
@ResponseBody
@ApiOperation(value = "求职者登陆(vx)",notes = "")
@PostMapping("/WxLogin")
public R<String> R (@RequestParam(value = "js_code", required = true) String js_code) throws Exception {
//测试数据code
// js_code = "0a3wuc0w3wd6M137CR2w3u7DoF1wuc0f";
//微信获取session_key接口地址
String wxLoginUrl = "https://api.weixin.qq.com/sns/jscode2session";
//接口参数
String param = "appid=wx7c972ceb65b45c49&secret=72ad166ce138375593026a2fc5bf9eee&js_code=" + js_code + "&grant_type=authorization_code";
//调用获取session_key接口 请求方式get
String jsonString = GetPostUntil.sendGet(wxLoginUrl, param);
System.out.println(jsonString);
//因为json字符串是大括号包围所以用JSONObject解析
JSONObject json = new JSONObject(jsonString);
//json解析session_key值
String session_key = json.getString("session_key");
System.out.println("session_key" + session_key);
//返回给前端
return R.success(session_key);
}
@ResponseBody
@ApiImplicitParams({
@ApiImplicitParam(name = "encryptedData", required = true),
@ApiImplicitParam(name = "iv", required = true),
@ApiImplicitParam(name = "sessionKey", required = true)
}
)
@ApiOperation(value = "求职者登陆(vx)",notes = "")
@PostMapping(value = "/decodeUserInfo")
public R decodeUserInfo(@RequestParam(required = true, value = "encryptedData") String encryptedData,
@RequestParam(required = true, value = "iv") String iv,
@RequestParam(required = true, value = "sessionKey") String sessionKey
) throws Exception {
byte[] encrypData = Base64.decodeBase64(encryptedData);
byte[] ivData = Base64.decodeBase64(iv);
byte[] sKey = Base64.decodeBase64(sessionKey);
String decrypt = WechatUtils.decrypt(sKey,ivData,encrypData);
System.out.println(decrypt);
JSONObject jsonObject=new JSONObject(decrypt);
String phoneNumber = jsonObject.getString("phoneNumber");
return userService.vxLogin(phoneNumber);
}
@PostMapping("/write_resume")
public R writeResume(@RequestBody Map<String,Object> addResumeInfo){
Integer id =(Integer) addResumeInfo.get("id");

View File

@ -10,7 +10,7 @@ import lombok.Data;
@Data
@ApiModel("面试背景实体类")
@TableName("interview_background")
public class BackgroundEntity extends BaseEntity<J> {
public class BackgroundEntity extends BaseEntity {
@ApiModelProperty("背景图片id")
@TableId(type = IdType.AUTO)
private Integer id;

View File

@ -4,7 +4,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class BaseEntity<J> {
public class BaseEntity{
@ApiModelProperty("创建时间")
private String createTime;
@ApiModelProperty("更新时间")

View File

@ -10,7 +10,7 @@ import lombok.Data;
@Data
@ApiModel("公司主体类")
@TableName("company")
public class Company extends BaseEntity<J> {
public class Company extends BaseEntity {
@ApiModelProperty("公司id")
@TableId(type = IdType.AUTO)
private Integer id;

View File

@ -9,7 +9,7 @@ import lombok.Data;
@ApiModel("面试官形象实体类")
@Data
@TableName("interview_images")
public class ImagesEntity extends BaseEntity<J> {
public class ImagesEntity extends BaseEntity{
@ApiModelProperty("面试官形象id")
@TableId(type = IdType.AUTO)
private Integer id;
@ -17,6 +17,8 @@ public class ImagesEntity extends BaseEntity<J> {
private String image;
@ApiModelProperty("面试官形象视频url地址")
private String video;
@ApiModelProperty("面试官性别")
private String sex;
@ApiModelProperty("形象图片名称")
private String picName;
@ApiModelProperty("公司编码")

View File

@ -10,7 +10,7 @@ import lombok.Data;
@Data
@TableName("interview_setting")
@ApiModel("面试设置实体类")
public class InterviewSetting extends BaseEntity<J> {
public class InterviewSetting extends BaseEntity {
@ApiModelProperty("面试设置id")
@TableId(type = IdType.AUTO)
private Integer Id;

View File

@ -10,7 +10,7 @@ import lombok.Data;
@Data
@ApiModel("工作实体类")
@TableName("Job_list")
public class JobEntity extends BaseEntity<J> {
public class JobEntity extends BaseEntity{
@ApiModelProperty("岗位id")
@TableId(type = IdType.AUTO)

View File

@ -9,7 +9,7 @@ import lombok.Data;
@ApiModel("logo实体类")
@Data
@TableName("interview_logo")
public class LogoEntity extends BaseEntity<J> {
public class LogoEntity extends BaseEntity{
@ApiModelProperty("公司logo id")
@TableId(type = IdType.AUTO)
private Integer id;

View File

@ -10,7 +10,7 @@ import lombok.Data;
@Data
@ApiModel("题目实体类")
@TableName("question")
public class Question extends BaseEntity<J> {
public class Question extends BaseEntity {
@ApiModelProperty("题目id")
@TableId(type = IdType.AUTO)
private Integer id;

View File

@ -10,7 +10,7 @@ import lombok.Data;
@ApiModel("题库实体类")
@Data
@TableName("question_bank")
public class QuestionBank extends BaseEntity<J> {
public class QuestionBank extends BaseEntity{
@ApiModelProperty("题库id")
@TableId(type = IdType.AUTO)
private Integer id;

View File

@ -10,7 +10,7 @@ import lombok.Data;
@Data
@ApiModel("简历实体类")
@TableName("resume")
public class Resume {
public class Resume extends BaseEntity{
@ApiModelProperty("简历id")
@TableId(type= IdType.AUTO)
private Integer id;

View File

@ -10,7 +10,7 @@ import lombok.Data;
@Data
@ApiModel("分享题目实体类")
@TableName("sharedQuestion")
public class SharedQuestion extends BaseEntity<J> {
public class SharedQuestion extends BaseEntity {
@ApiModelProperty("题目id")
@TableId(type = IdType.AUTO)
private Integer id;

View File

@ -10,7 +10,7 @@ import lombok.Data;
@ApiModel("分享题库实体类")
@Data
@TableName("sharedBank")
public class SharedQuestionBank extends BaseEntity<J> {
public class SharedQuestionBank extends BaseEntity{
@ApiModelProperty("题库id")
@TableId(type = IdType.AUTO)
private Integer id;

View File

@ -10,7 +10,7 @@ import lombok.Data;
@ApiModel("用户实体类")
@Data
@TableName("user")
public class User extends BaseEntity<J> {
public class User extends BaseEntity {
@ApiModelProperty("用户id")
@TableId(type = IdType.AUTO)
private Integer id;

View File

@ -0,0 +1,12 @@
package com.yzdx.AiInterviewer.entity.dto;
import com.yzdx.AiInterviewer.entity.ImagesEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class ImageDto extends ImagesEntity {
@ApiModelProperty("文件类型")
private Boolean Static;
}

View File

@ -4,7 +4,7 @@ import com.yzdx.AiInterviewer.entity.BaseEntity;
import lombok.Data;
@Data
public class JobDto extends BaseEntity<J> {
public class JobDto extends BaseEntity {
private Integer id;

View File

@ -3,6 +3,7 @@ package com.yzdx.AiInterviewer.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yzdx.AiInterviewer.entity.ImagesEntity;
import com.yzdx.AiInterviewer.entity.LogoEntity;
import com.yzdx.AiInterviewer.entity.dto.ImageDto;
import java.util.List;
@ -25,7 +26,7 @@ public interface InterviewImagesService extends IService<ImagesEntity> {
* @return 映像的行数
*
* */
Integer addImageLogo(String name,String encoding,String image,String video,Integer userId,String filename);
Integer addImage(String name,String encoding,String image,String video,Integer userId,String filename,String sex);
/**
* 删除logo
@ -34,4 +35,12 @@ public interface InterviewImagesService extends IService<ImagesEntity> {
*
* */
Integer deleteImageById(Integer id);
/**
* 生成数字人
* @param imageId 形象ID
* @return ImageDto
*
* */
ImageDto getDigitalHumanById(Integer imageId);
}

View File

@ -97,5 +97,6 @@ public interface UserService extends IService<User> {
* */
User updateUserInfo(Integer userId,Integer updateId,String username,String age,String email,String sex);
R vxLogin(String phone);
}

View File

@ -3,7 +3,9 @@ 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.BackgroundEntity;
import com.yzdx.AiInterviewer.entity.InterviewSetting;
import com.yzdx.AiInterviewer.mapper.InterviewBackgroundMapper;
import com.yzdx.AiInterviewer.mapper.InterviewSettingMapper;
import com.yzdx.AiInterviewer.service.InterviewBackgroundService;
import com.yzdx.AiInterviewer.utiles.TimeUtil;
import org.springframework.beans.factory.annotation.Autowired;
@ -16,6 +18,8 @@ public class InterviewBackgroundServiceImpl extends ServiceImpl<InterviewBackgro
@Autowired
private InterviewBackgroundMapper backgroundMapper;
@Autowired
private InterviewSettingMapper interviewSettingMapper;
@Override
public List<BackgroundEntity> getBackgroundList(String encoding) {
@ -44,6 +48,16 @@ public class InterviewBackgroundServiceImpl extends ServiceImpl<InterviewBackgro
@Override
public Integer deleteBackgroundById(Integer id) {
LambdaQueryWrapper<InterviewSetting> queryWrapper=new LambdaQueryWrapper<>();
queryWrapper.eq(InterviewSetting::getBackgroundId,id);
List<InterviewSetting> interviewSettings = interviewSettingMapper.selectList(queryWrapper);
if(interviewSettings.size()!=0){
return -1;
}
Integer rows = backgroundMapper.deleteById(id);
return rows;

View File

@ -3,10 +3,14 @@ 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.ImagesEntity;
import com.yzdx.AiInterviewer.entity.InterviewSetting;
import com.yzdx.AiInterviewer.entity.LogoEntity;
import com.yzdx.AiInterviewer.entity.dto.ImageDto;
import com.yzdx.AiInterviewer.mapper.InterviewImagesMapper;
import com.yzdx.AiInterviewer.mapper.InterviewSettingMapper;
import com.yzdx.AiInterviewer.service.InterviewImagesService;
import com.yzdx.AiInterviewer.utiles.TimeUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -17,6 +21,9 @@ public class InterviewImagesServiceImpl extends ServiceImpl<InterviewImagesMappe
@Autowired
private InterviewImagesMapper imagesMapper;
@Autowired
private InterviewSettingMapper interviewSettingMapper;
@Override
public List<ImagesEntity> getImagesList(String encoding) {
@ -30,13 +37,14 @@ public class InterviewImagesServiceImpl extends ServiceImpl<InterviewImagesMappe
}
@Override
public Integer addImageLogo(String name, String encoding, String image, String video,Integer userId, String filename) {
public Integer addImage(String name, String encoding, String image, String video,Integer userId, String filename,String sex) {
if(video.equals("")||video==null){
ImagesEntity imageEntity=new ImagesEntity();
imageEntity.setCreateUser(userId);
imageEntity.setCreateTime(TimeUtil.getTime());
imageEntity.setImage(image);
imageEntity.setVideo("");
imageEntity.setSex(sex);
imageEntity.setPicName(name);
imageEntity.setEncoding(encoding);
imageEntity.setFilename(filename);
@ -49,10 +57,10 @@ public class InterviewImagesServiceImpl extends ServiceImpl<InterviewImagesMappe
imageEntity.setCreateTime(TimeUtil.getTime());
imageEntity.setVideo(video);
imageEntity.setImage("");
imageEntity.setSex(sex);
imageEntity.setPicName(name);
imageEntity.setEncoding(encoding);
imageEntity.setFilename(filename);
Integer rows = imagesMapper.insert(imageEntity);
return rows;
}
@ -60,8 +68,40 @@ public class InterviewImagesServiceImpl extends ServiceImpl<InterviewImagesMappe
@Override
public Integer deleteImageById(Integer id) {
LambdaQueryWrapper<InterviewSetting> queryWrapper=new LambdaQueryWrapper<>();
queryWrapper.eq(InterviewSetting::getImagesId,id);
List<InterviewSetting> interviewSettings = interviewSettingMapper.selectList(queryWrapper);
if(interviewSettings.size()!=0){
return -1;
}
Integer rows = imagesMapper.deleteById(id);
return rows;
}
@Override
public ImageDto getDigitalHumanById(Integer imageId) {
LambdaQueryWrapper<ImagesEntity> queryWrapper=new LambdaQueryWrapper<>();
queryWrapper.eq(ImagesEntity::getId,imageId);
ImagesEntity imagesEntity = imagesMapper.selectOne(queryWrapper);
ImageDto imageDto=new ImageDto();
BeanUtils.copyProperties(imagesEntity,imageDto);
if(imagesEntity.getImage()==null||imagesEntity.getImage().equals("")){
imageDto.setStatic(false);
}else {
imageDto.setStatic(true);
}
return imageDto;
}
}

View File

@ -2,8 +2,10 @@ 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.InterviewSetting;
import com.yzdx.AiInterviewer.entity.LogoEntity;
import com.yzdx.AiInterviewer.mapper.InterviewLogoMapper;
import com.yzdx.AiInterviewer.mapper.InterviewSettingMapper;
import com.yzdx.AiInterviewer.service.InterviewLogoService;
import com.yzdx.AiInterviewer.utiles.TimeUtil;
import org.springframework.beans.factory.annotation.Autowired;
@ -16,6 +18,8 @@ public class InterviewLogoServiceImpl extends ServiceImpl<InterviewLogoMapper, L
@Autowired
private InterviewLogoMapper logoMapper;
@Autowired
private InterviewSettingMapper interviewSettingMapper;
@Override
public List<LogoEntity> getLogoList(String encoding) {
@ -46,6 +50,15 @@ public class InterviewLogoServiceImpl extends ServiceImpl<InterviewLogoMapper, L
@Override
public Integer deleteLogoById(Integer id) {
LambdaQueryWrapper<InterviewSetting> queryWrapper=new LambdaQueryWrapper<>();
queryWrapper.eq(InterviewSetting::getLogoId,id);
List<InterviewSetting> interviewSettings = interviewSettingMapper.selectList(queryWrapper);
if(interviewSettings.size()!=0){
return -1;
}
Integer rows = logoMapper.deleteById(id);
return rows;

View File

@ -14,8 +14,7 @@ import java.util.List;
@Service
public class ResumeServiceImpl extends ServiceImpl<ResumeMapper, Resume> implements ResumeService {
@Autowired
private ResumeService resumeService;
@Autowired
private ResumeMapper resumeMapper;
@Override

View File

@ -309,6 +309,47 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
}
@Override
public R vxLogin(String phone) {
LambdaQueryWrapper<User> queryWrapper=new LambdaQueryWrapper<>();
queryWrapper.eq(User::getPhone,phone);
User user = userMapper.selectOne(queryWrapper);
if(user==null){
User createUser=new User();
createUser.setPhone(phone);
createUser.setCreateTime(TimeUtil.getTime());
createUser.setUsername(MD5Util.getSalt());
userMapper.insert(createUser);
LambdaQueryWrapper<User> findNewQueryWrapper=new LambdaQueryWrapper<>();
findNewQueryWrapper.eq(User::getPhone,phone);
User findNew = userMapper.selectOne(queryWrapper);
String jwToken = JWT.getJWToken(findNew.getId());
Map<String,Object> result=new HashMap<>();
result.put("token",jwToken);
result.put("userInfo",findNew);
return R.success(result);
}else{
String jwToken = JWT.getJWToken(user.getId());
Map<String,Object> result=new HashMap<>();
result.put("token",jwToken);
result.put("userInfo",user);
return R.success(result);
}
}
}

View File

@ -0,0 +1,132 @@
package com.yzdx.AiInterviewer.utiles;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.URL;
import java.net.URLConnection;
import java.util.List;
import java.util.Map;
/**
* @Author Songzhongjin
* @Date 2020/7/15 10:37
* @Version 1.0
*/
public class GetPostUntil {
/**
* 向指定URL发送GET方法的请求
*
* @param url
* 发送请求的URL
* @param param
* 请求参数请求参数应该是 name1=value1&name2=value2 的形式
* @return URL 所代表远程资源的响应结果
*/
public static String sendGet(String url, String param) {
String result = "";
BufferedReader in = null;
try {
String urlNameString = url + "?" + param;
URL realUrl = new URL(urlNameString);
// 打开和URL之间的连接
URLConnection connection = realUrl.openConnection();
// 设置通用的请求属性
connection.setRequestProperty("accept", "*/*");
connection.setRequestProperty("connection", "Keep-Alive");
connection.setRequestProperty("user-agent",
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
// 建立实际的连接
connection.connect();
// 获取所有响应头字段
Map<String, List<String>> map = connection.getHeaderFields();
// 遍历所有的响应头字段
for (String key : map.keySet()) {
System.out.println(key + "--->" + map.get(key));
}
// 定义 BufferedReader输入流来读取URL的响应
in = new BufferedReader(new InputStreamReader(
connection.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
result += line;
}
} catch (Exception e) {
System.out.println("发送GET请求出现异常" + e);
e.printStackTrace();
}
// 使用finally块来关闭输入流
finally {
try {
if (in != null) {
in.close();
}
} catch (Exception e2) {
e2.printStackTrace();
}
}
return result;
}
/**
* 向指定 URL 发送POST方法的请求
*
* @param url
* 发送请求的 URL
* @param param
* 请求参数请求参数应该是 name1=value1&name2=value2 的形式
* @return 所代表远程资源的响应结果
*/
public static String sendPost(String url, String param) {
PrintWriter out = null;
BufferedReader in = null;
String result = "";
try {
URL realUrl = new URL(url);
// 打开和URL之间的连接
URLConnection conn = realUrl.openConnection();
// 设置通用的请求属性
conn.setRequestProperty("accept", "*/*");
conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("user-agent",
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
// 发送POST请求必须设置如下两行
conn.setDoOutput(true);
conn.setDoInput(true);
// 获取URLConnection对象对应的输出流
out = new PrintWriter(conn.getOutputStream());
// 发送请求参数
out.print(param);
// flush输出流的缓冲
out.flush();
// 定义BufferedReader输入流来读取URL的响应
in = new BufferedReader(
new InputStreamReader(conn.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
result += line;
}
} catch (Exception e) {
System.out.println("发送 POST 请求出现异常!"+e);
e.printStackTrace();
}
//使用finally块来关闭输出流输入流
finally{
try{
if(out!=null){
out.close();
}
if(in!=null){
in.close();
}
}
catch(IOException ex){
ex.printStackTrace();
}
}
return result;
}
}

View File

@ -0,0 +1,23 @@
package com.yzdx.AiInterviewer.utiles;
import java.security.spec.AlgorithmParameterSpec;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class WechatUtils {
public static String decrypt(byte[] key, byte[] iv, byte[] encData) throws Exception {
AlgorithmParameterSpec ivSpec = new IvParameterSpec(iv);
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
SecretKeySpec keySpec = new SecretKeySpec(key, "AES");
cipher.init(Cipher.DECRYPT_MODE, keySpec, ivSpec);
//解析解密后的字符串
return new String(cipher.doFinal(encData),"UTF-8");
}
}