From 09e7bdc35495d3297464c3e864850e85e3af5898 Mon Sep 17 00:00:00 2001 From: Unique-Jerry <10902054+unique-jerry@user.noreply.gitee.com> Date: Mon, 27 Nov 2023 16:31:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 13 +- .../AiInterviewerApplication.java | 1 - .../controller/InterviewController.java | 62 +++++--- .../controller/UploadController.java | 12 +- .../controller/UserController.java | 20 ++- .../controller/VxController.java | 73 +++++++++- .../entity/BackgroundEntity.java | 2 +- .../yzdx/AiInterviewer/entity/BaseEntity.java | 2 +- .../yzdx/AiInterviewer/entity/Company.java | 2 +- .../AiInterviewer/entity/ImagesEntity.java | 4 +- .../entity/InterviewSetting.java | 2 +- .../yzdx/AiInterviewer/entity/JobEntity.java | 2 +- .../yzdx/AiInterviewer/entity/LogoEntity.java | 2 +- .../yzdx/AiInterviewer/entity/Question.java | 2 +- .../AiInterviewer/entity/QuestionBank.java | 2 +- .../com/yzdx/AiInterviewer/entity/Resume.java | 2 +- .../AiInterviewer/entity/SharedQuestion.java | 2 +- .../entity/SharedQuestionBank.java | 2 +- .../com/yzdx/AiInterviewer/entity/User.java | 2 +- .../AiInterviewer/entity/dto/ImageDto.java | 12 ++ .../yzdx/AiInterviewer/entity/dto/JobDto.java | 2 +- .../service/InterviewImagesService.java | 11 +- .../AiInterviewer/service/UserService.java | 1 + .../impl/InterviewBackgroundServiceImpl.java | 14 ++ .../impl/InterviewImagesServiceImpl.java | 44 +++++- .../impl/InterviewLogoServiceImpl.java | 13 ++ .../service/impl/ResumeServiceImpl.java | 3 +- .../service/impl/UserServiceImpl.java | 41 ++++++ .../AiInterviewer/utiles/GetPostUntil.java | 132 ++++++++++++++++++ .../AiInterviewer/utiles/WechatUtils.java | 23 +++ 30 files changed, 441 insertions(+), 64 deletions(-) create mode 100644 src/main/java/com/yzdx/AiInterviewer/entity/dto/ImageDto.java create mode 100644 src/main/java/com/yzdx/AiInterviewer/utiles/GetPostUntil.java create mode 100644 src/main/java/com/yzdx/AiInterviewer/utiles/WechatUtils.java diff --git a/pom.xml b/pom.xml index 3d68b1d..dd4fa9d 100644 --- a/pom.xml +++ b/pom.xml @@ -24,12 +24,22 @@ - + com.alibaba fastjson 1.2.76 + + + + + org.bouncycastle + bcprov-jdk15on + 1.54 + + + org.projectlombok lombok @@ -148,6 +158,7 @@ + diff --git a/src/main/java/com/yzdx/AiInterviewer/AiInterviewerApplication.java b/src/main/java/com/yzdx/AiInterviewer/AiInterviewerApplication.java index ccf728c..a92fff7 100644 --- a/src/main/java/com/yzdx/AiInterviewer/AiInterviewerApplication.java +++ b/src/main/java/com/yzdx/AiInterviewer/AiInterviewerApplication.java @@ -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) { diff --git a/src/main/java/com/yzdx/AiInterviewer/controller/InterviewController.java b/src/main/java/com/yzdx/AiInterviewer/controller/InterviewController.java index 5d8f1bc..9d73028 100644 --- a/src/main/java/com/yzdx/AiInterviewer/controller/InterviewController.java +++ b/src/main/java/com/yzdx/AiInterviewer/controller/InterviewController.java @@ -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 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 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("删除成功"); } + } diff --git a/src/main/java/com/yzdx/AiInterviewer/controller/UploadController.java b/src/main/java/com/yzdx/AiInterviewer/controller/UploadController.java index c865f6e..17d23ed 100644 --- a/src/main/java/com/yzdx/AiInterviewer/controller/UploadController.java +++ b/src/main/java/com/yzdx/AiInterviewer/controller/UploadController.java @@ -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 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 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("删除失败"); } - - } - - - - } diff --git a/src/main/java/com/yzdx/AiInterviewer/controller/UserController.java b/src/main/java/com/yzdx/AiInterviewer/controller/UserController.java index ad56b25..f318285 100644 --- a/src/main/java/com/yzdx/AiInterviewer/controller/UserController.java +++ b/src/main/java/com/yzdx/AiInterviewer/controller/UserController.java @@ -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 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 diff --git a/src/main/java/com/yzdx/AiInterviewer/controller/VxController.java b/src/main/java/com/yzdx/AiInterviewer/controller/VxController.java index 3d4ffde..e4f0af4 100644 --- a/src/main/java/com/yzdx/AiInterviewer/controller/VxController.java +++ b/src/main/java/com/yzdx/AiInterviewer/controller/VxController.java @@ -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 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 addResumeInfo){ Integer id =(Integer) addResumeInfo.get("id"); diff --git a/src/main/java/com/yzdx/AiInterviewer/entity/BackgroundEntity.java b/src/main/java/com/yzdx/AiInterviewer/entity/BackgroundEntity.java index dce2acd..95e4673 100644 --- a/src/main/java/com/yzdx/AiInterviewer/entity/BackgroundEntity.java +++ b/src/main/java/com/yzdx/AiInterviewer/entity/BackgroundEntity.java @@ -10,7 +10,7 @@ import lombok.Data; @Data @ApiModel("面试背景实体类") @TableName("interview_background") -public class BackgroundEntity extends BaseEntity { +public class BackgroundEntity extends BaseEntity { @ApiModelProperty("背景图片id") @TableId(type = IdType.AUTO) private Integer id; diff --git a/src/main/java/com/yzdx/AiInterviewer/entity/BaseEntity.java b/src/main/java/com/yzdx/AiInterviewer/entity/BaseEntity.java index 400e6a9..8c75baf 100644 --- a/src/main/java/com/yzdx/AiInterviewer/entity/BaseEntity.java +++ b/src/main/java/com/yzdx/AiInterviewer/entity/BaseEntity.java @@ -4,7 +4,7 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; @Data -public class BaseEntity { +public class BaseEntity{ @ApiModelProperty("创建时间") private String createTime; @ApiModelProperty("更新时间") diff --git a/src/main/java/com/yzdx/AiInterviewer/entity/Company.java b/src/main/java/com/yzdx/AiInterviewer/entity/Company.java index 022b51f..7ca096f 100644 --- a/src/main/java/com/yzdx/AiInterviewer/entity/Company.java +++ b/src/main/java/com/yzdx/AiInterviewer/entity/Company.java @@ -10,7 +10,7 @@ import lombok.Data; @Data @ApiModel("公司主体类") @TableName("company") -public class Company extends BaseEntity { +public class Company extends BaseEntity { @ApiModelProperty("公司id") @TableId(type = IdType.AUTO) private Integer id; diff --git a/src/main/java/com/yzdx/AiInterviewer/entity/ImagesEntity.java b/src/main/java/com/yzdx/AiInterviewer/entity/ImagesEntity.java index 33f291f..b829375 100644 --- a/src/main/java/com/yzdx/AiInterviewer/entity/ImagesEntity.java +++ b/src/main/java/com/yzdx/AiInterviewer/entity/ImagesEntity.java @@ -9,7 +9,7 @@ import lombok.Data; @ApiModel("面试官形象实体类") @Data @TableName("interview_images") -public class ImagesEntity extends BaseEntity { +public class ImagesEntity extends BaseEntity{ @ApiModelProperty("面试官形象id") @TableId(type = IdType.AUTO) private Integer id; @@ -17,6 +17,8 @@ public class ImagesEntity extends BaseEntity { private String image; @ApiModelProperty("面试官形象视频url地址") private String video; + @ApiModelProperty("面试官性别") + private String sex; @ApiModelProperty("形象图片名称") private String picName; @ApiModelProperty("公司编码") diff --git a/src/main/java/com/yzdx/AiInterviewer/entity/InterviewSetting.java b/src/main/java/com/yzdx/AiInterviewer/entity/InterviewSetting.java index 02bc66e..70356ee 100644 --- a/src/main/java/com/yzdx/AiInterviewer/entity/InterviewSetting.java +++ b/src/main/java/com/yzdx/AiInterviewer/entity/InterviewSetting.java @@ -10,7 +10,7 @@ import lombok.Data; @Data @TableName("interview_setting") @ApiModel("面试设置实体类") -public class InterviewSetting extends BaseEntity { +public class InterviewSetting extends BaseEntity { @ApiModelProperty("面试设置id") @TableId(type = IdType.AUTO) private Integer Id; diff --git a/src/main/java/com/yzdx/AiInterviewer/entity/JobEntity.java b/src/main/java/com/yzdx/AiInterviewer/entity/JobEntity.java index 70a085c..5032039 100644 --- a/src/main/java/com/yzdx/AiInterviewer/entity/JobEntity.java +++ b/src/main/java/com/yzdx/AiInterviewer/entity/JobEntity.java @@ -10,7 +10,7 @@ import lombok.Data; @Data @ApiModel("工作实体类") @TableName("Job_list") -public class JobEntity extends BaseEntity { +public class JobEntity extends BaseEntity{ @ApiModelProperty("岗位id") @TableId(type = IdType.AUTO) diff --git a/src/main/java/com/yzdx/AiInterviewer/entity/LogoEntity.java b/src/main/java/com/yzdx/AiInterviewer/entity/LogoEntity.java index 07ddf71..6ae0009 100644 --- a/src/main/java/com/yzdx/AiInterviewer/entity/LogoEntity.java +++ b/src/main/java/com/yzdx/AiInterviewer/entity/LogoEntity.java @@ -9,7 +9,7 @@ import lombok.Data; @ApiModel("logo实体类") @Data @TableName("interview_logo") -public class LogoEntity extends BaseEntity { +public class LogoEntity extends BaseEntity{ @ApiModelProperty("公司logo id") @TableId(type = IdType.AUTO) private Integer id; diff --git a/src/main/java/com/yzdx/AiInterviewer/entity/Question.java b/src/main/java/com/yzdx/AiInterviewer/entity/Question.java index 5da86d1..6aee622 100644 --- a/src/main/java/com/yzdx/AiInterviewer/entity/Question.java +++ b/src/main/java/com/yzdx/AiInterviewer/entity/Question.java @@ -10,7 +10,7 @@ import lombok.Data; @Data @ApiModel("题目实体类") @TableName("question") -public class Question extends BaseEntity { +public class Question extends BaseEntity { @ApiModelProperty("题目id") @TableId(type = IdType.AUTO) private Integer id; diff --git a/src/main/java/com/yzdx/AiInterviewer/entity/QuestionBank.java b/src/main/java/com/yzdx/AiInterviewer/entity/QuestionBank.java index a1e3615..c4d5af5 100644 --- a/src/main/java/com/yzdx/AiInterviewer/entity/QuestionBank.java +++ b/src/main/java/com/yzdx/AiInterviewer/entity/QuestionBank.java @@ -10,7 +10,7 @@ import lombok.Data; @ApiModel("题库实体类") @Data @TableName("question_bank") -public class QuestionBank extends BaseEntity { +public class QuestionBank extends BaseEntity{ @ApiModelProperty("题库id") @TableId(type = IdType.AUTO) private Integer id; diff --git a/src/main/java/com/yzdx/AiInterviewer/entity/Resume.java b/src/main/java/com/yzdx/AiInterviewer/entity/Resume.java index 2a54e62..573e930 100644 --- a/src/main/java/com/yzdx/AiInterviewer/entity/Resume.java +++ b/src/main/java/com/yzdx/AiInterviewer/entity/Resume.java @@ -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; diff --git a/src/main/java/com/yzdx/AiInterviewer/entity/SharedQuestion.java b/src/main/java/com/yzdx/AiInterviewer/entity/SharedQuestion.java index cf4dab3..d0404b2 100644 --- a/src/main/java/com/yzdx/AiInterviewer/entity/SharedQuestion.java +++ b/src/main/java/com/yzdx/AiInterviewer/entity/SharedQuestion.java @@ -10,7 +10,7 @@ import lombok.Data; @Data @ApiModel("分享题目实体类") @TableName("sharedQuestion") -public class SharedQuestion extends BaseEntity { +public class SharedQuestion extends BaseEntity { @ApiModelProperty("题目id") @TableId(type = IdType.AUTO) private Integer id; diff --git a/src/main/java/com/yzdx/AiInterviewer/entity/SharedQuestionBank.java b/src/main/java/com/yzdx/AiInterviewer/entity/SharedQuestionBank.java index 838eedf..4a990e3 100644 --- a/src/main/java/com/yzdx/AiInterviewer/entity/SharedQuestionBank.java +++ b/src/main/java/com/yzdx/AiInterviewer/entity/SharedQuestionBank.java @@ -10,7 +10,7 @@ import lombok.Data; @ApiModel("分享题库实体类") @Data @TableName("sharedBank") -public class SharedQuestionBank extends BaseEntity { +public class SharedQuestionBank extends BaseEntity{ @ApiModelProperty("题库id") @TableId(type = IdType.AUTO) private Integer id; diff --git a/src/main/java/com/yzdx/AiInterviewer/entity/User.java b/src/main/java/com/yzdx/AiInterviewer/entity/User.java index 46b617b..9d21700 100644 --- a/src/main/java/com/yzdx/AiInterviewer/entity/User.java +++ b/src/main/java/com/yzdx/AiInterviewer/entity/User.java @@ -10,7 +10,7 @@ import lombok.Data; @ApiModel("用户实体类") @Data @TableName("user") -public class User extends BaseEntity { +public class User extends BaseEntity { @ApiModelProperty("用户id") @TableId(type = IdType.AUTO) private Integer id; diff --git a/src/main/java/com/yzdx/AiInterviewer/entity/dto/ImageDto.java b/src/main/java/com/yzdx/AiInterviewer/entity/dto/ImageDto.java new file mode 100644 index 0000000..0990189 --- /dev/null +++ b/src/main/java/com/yzdx/AiInterviewer/entity/dto/ImageDto.java @@ -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; + +} diff --git a/src/main/java/com/yzdx/AiInterviewer/entity/dto/JobDto.java b/src/main/java/com/yzdx/AiInterviewer/entity/dto/JobDto.java index f3567fc..06a962d 100644 --- a/src/main/java/com/yzdx/AiInterviewer/entity/dto/JobDto.java +++ b/src/main/java/com/yzdx/AiInterviewer/entity/dto/JobDto.java @@ -4,7 +4,7 @@ import com.yzdx.AiInterviewer.entity.BaseEntity; import lombok.Data; @Data -public class JobDto extends BaseEntity { +public class JobDto extends BaseEntity { private Integer id; diff --git a/src/main/java/com/yzdx/AiInterviewer/service/InterviewImagesService.java b/src/main/java/com/yzdx/AiInterviewer/service/InterviewImagesService.java index d1a371c..81a25a4 100644 --- a/src/main/java/com/yzdx/AiInterviewer/service/InterviewImagesService.java +++ b/src/main/java/com/yzdx/AiInterviewer/service/InterviewImagesService.java @@ -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 { * @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 { * * */ Integer deleteImageById(Integer id); + /** + * 生成数字人 + * @param imageId 形象ID + * @return ImageDto + * + * */ + ImageDto getDigitalHumanById(Integer imageId); + } diff --git a/src/main/java/com/yzdx/AiInterviewer/service/UserService.java b/src/main/java/com/yzdx/AiInterviewer/service/UserService.java index 6b61649..366e08d 100644 --- a/src/main/java/com/yzdx/AiInterviewer/service/UserService.java +++ b/src/main/java/com/yzdx/AiInterviewer/service/UserService.java @@ -97,5 +97,6 @@ public interface UserService extends IService { * */ User updateUserInfo(Integer userId,Integer updateId,String username,String age,String email,String sex); + R vxLogin(String phone); } diff --git a/src/main/java/com/yzdx/AiInterviewer/service/impl/InterviewBackgroundServiceImpl.java b/src/main/java/com/yzdx/AiInterviewer/service/impl/InterviewBackgroundServiceImpl.java index a35570c..50b5183 100644 --- a/src/main/java/com/yzdx/AiInterviewer/service/impl/InterviewBackgroundServiceImpl.java +++ b/src/main/java/com/yzdx/AiInterviewer/service/impl/InterviewBackgroundServiceImpl.java @@ -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 getBackgroundList(String encoding) { @@ -44,6 +48,16 @@ public class InterviewBackgroundServiceImpl extends ServiceImpl queryWrapper=new LambdaQueryWrapper<>(); + + queryWrapper.eq(InterviewSetting::getBackgroundId,id); + + List interviewSettings = interviewSettingMapper.selectList(queryWrapper); + + if(interviewSettings.size()!=0){ + return -1; + } Integer rows = backgroundMapper.deleteById(id); return rows; diff --git a/src/main/java/com/yzdx/AiInterviewer/service/impl/InterviewImagesServiceImpl.java b/src/main/java/com/yzdx/AiInterviewer/service/impl/InterviewImagesServiceImpl.java index dd918e4..c87c918 100644 --- a/src/main/java/com/yzdx/AiInterviewer/service/impl/InterviewImagesServiceImpl.java +++ b/src/main/java/com/yzdx/AiInterviewer/service/impl/InterviewImagesServiceImpl.java @@ -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 getImagesList(String encoding) { @@ -30,13 +37,14 @@ public class InterviewImagesServiceImpl extends ServiceImpl queryWrapper=new LambdaQueryWrapper<>(); + + queryWrapper.eq(InterviewSetting::getImagesId,id); + + List interviewSettings = interviewSettingMapper.selectList(queryWrapper); + + if(interviewSettings.size()!=0){ + return -1; + } Integer rows = imagesMapper.deleteById(id); return rows; } + + @Override + public ImageDto getDigitalHumanById(Integer imageId) { + LambdaQueryWrapper 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; + } } diff --git a/src/main/java/com/yzdx/AiInterviewer/service/impl/InterviewLogoServiceImpl.java b/src/main/java/com/yzdx/AiInterviewer/service/impl/InterviewLogoServiceImpl.java index 50ce01c..b98f743 100644 --- a/src/main/java/com/yzdx/AiInterviewer/service/impl/InterviewLogoServiceImpl.java +++ b/src/main/java/com/yzdx/AiInterviewer/service/impl/InterviewLogoServiceImpl.java @@ -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 getLogoList(String encoding) { @@ -46,6 +50,15 @@ public class InterviewLogoServiceImpl extends ServiceImpl queryWrapper=new LambdaQueryWrapper<>(); + + queryWrapper.eq(InterviewSetting::getLogoId,id); + + List interviewSettings = interviewSettingMapper.selectList(queryWrapper); + + if(interviewSettings.size()!=0){ + return -1; + } Integer rows = logoMapper.deleteById(id); return rows; diff --git a/src/main/java/com/yzdx/AiInterviewer/service/impl/ResumeServiceImpl.java b/src/main/java/com/yzdx/AiInterviewer/service/impl/ResumeServiceImpl.java index 43bfc5c..4a9a994 100644 --- a/src/main/java/com/yzdx/AiInterviewer/service/impl/ResumeServiceImpl.java +++ b/src/main/java/com/yzdx/AiInterviewer/service/impl/ResumeServiceImpl.java @@ -14,8 +14,7 @@ import java.util.List; @Service public class ResumeServiceImpl extends ServiceImpl implements ResumeService { - @Autowired - private ResumeService resumeService; + @Autowired private ResumeMapper resumeMapper; @Override diff --git a/src/main/java/com/yzdx/AiInterviewer/service/impl/UserServiceImpl.java b/src/main/java/com/yzdx/AiInterviewer/service/impl/UserServiceImpl.java index 7597f5c..ac3f562 100644 --- a/src/main/java/com/yzdx/AiInterviewer/service/impl/UserServiceImpl.java +++ b/src/main/java/com/yzdx/AiInterviewer/service/impl/UserServiceImpl.java @@ -309,6 +309,47 @@ public class UserServiceImpl extends ServiceImpl implements Us } + @Override + public R vxLogin(String phone) { + + LambdaQueryWrapper 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 findNewQueryWrapper=new LambdaQueryWrapper<>(); + + findNewQueryWrapper.eq(User::getPhone,phone); + + User findNew = userMapper.selectOne(queryWrapper); + + String jwToken = JWT.getJWToken(findNew.getId()); + + Map result=new HashMap<>(); + + result.put("token",jwToken); + result.put("userInfo",findNew); + return R.success(result); + }else{ + String jwToken = JWT.getJWToken(user.getId()); + + Map result=new HashMap<>(); + + result.put("token",jwToken); + result.put("userInfo",user); + return R.success(result); + } + + } + } diff --git a/src/main/java/com/yzdx/AiInterviewer/utiles/GetPostUntil.java b/src/main/java/com/yzdx/AiInterviewer/utiles/GetPostUntil.java new file mode 100644 index 0000000..46a1d8b --- /dev/null +++ b/src/main/java/com/yzdx/AiInterviewer/utiles/GetPostUntil.java @@ -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> 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; + } +} + diff --git a/src/main/java/com/yzdx/AiInterviewer/utiles/WechatUtils.java b/src/main/java/com/yzdx/AiInterviewer/utiles/WechatUtils.java new file mode 100644 index 0000000..9c8aeb3 --- /dev/null +++ b/src/main/java/com/yzdx/AiInterviewer/utiles/WechatUtils.java @@ -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"); + } + +}