Commit 6e150202 by zwb

修改简历的用户登录校验

parent e19a9939
......@@ -122,11 +122,11 @@ public class NewEditionResumeController {
throw new JxgException("简历id不能为空");
}
this.newEditionResumeService.delResume(dto);
Long userId = 1L;
UserLoginInfo userLoginInfo = SecurityUtils.getUser();
if (userLoginInfo!=null){
userId = userLoginInfo.getId();
LoginUser loginUser = LoginHelper.getLoginUser();
if (null == loginUser){
throw new WarnException("用户信息获取失败");
}
Long userId = loginUser.getUserId();
this.resumeCacheService.delResumeCache(Long.valueOf(dto.getResumeId()), userId);
return R.ok();
}
......
......@@ -10,6 +10,7 @@ import com.alibaba.fastjson2.JSONObject;
import com.alibaba.fastjson2.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.bkty.system.api.model.LoginUser;
import com.bkty.system.config.AiConfigProperties;
import com.bkty.system.config.CommonAsyncThreadPool;
import com.bkty.system.domain.dto.ResumeByPdfDto;
......@@ -37,6 +38,7 @@ import org.dromara.common.core.utils.SecurityUtils;
import org.dromara.common.core.utils.SnowFlakeUtil;
import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.core.utils.WebUtils;
import org.dromara.common.satoken.utils.LoginHelper;
import org.springframework.beans.BeanUtils;
import org.springframework.context.ApplicationContext;
import org.springframework.data.redis.core.RedisTemplate;
......@@ -104,15 +106,16 @@ public class NewEditionResumeServiceImpl implements NewEditionResumeService {
private final AiConfigProperties properties;
@Override
public void insertNewEditionResume(MultipartFile file, String type){
public void insertNewEditionResume(MultipartFile file, String type) {
UserLoginInfo user = SecurityUtils.getUser();
if (user==null){
user = new UserLoginInfo();
AuthFrontUser frontUser = frontUserMapper.selectById(1L);
BeanUtils.copyProperties(frontUser,user);
LoginUser user = LoginHelper.getLoginUser();
if (user == null) {
throw new WarnException("用户信息获取失败");
}
AuthFrontUser frontUser = frontUserMapper.selectById(user.getUserId());
UserLoginInfo finalUser = new UserLoginInfo();
BeanUtils.copyProperties(frontUser, finalUser);
FunctionResumeBase resumeBase = new FunctionResumeBase();
resumeBase.setId(SnowFlakeUtil.newId());
......@@ -131,7 +134,6 @@ public class NewEditionResumeServiceImpl implements NewEditionResumeService {
throw new RuntimeException("读取文件失败", e);
}
UserLoginInfo finalUser = user;
CompletableFuture.runAsync(() -> {
String fileUrl = "";
try {
......@@ -168,12 +170,12 @@ public class NewEditionResumeServiceImpl implements NewEditionResumeService {
FunctionResumeBase resumeNew = new FunctionResumeBase();
BeanUtil.copyProperties(base, resumeNew);
resumeNew.setId(resumeBase.getId());
if(StringUtils.isBlank(resumeNew.getPhone())){
if (StringUtils.isBlank(resumeNew.getPhone())) {
resumeNew.setPhone(finalUser.getPhone());
}
resumeNew.setRunType(0);
if(StringUtils.isBlank(resumeNew.getResumeName())){
resumeNew.setResumeName((StringUtils.isNotBlank(finalUser.getUsername()) ? finalUser.getUsername() : "未实名用户")+"的求职简历");
if (StringUtils.isBlank(resumeNew.getResumeName())) {
resumeNew.setResumeName((StringUtils.isNotBlank(finalUser.getUsername()) ? finalUser.getUsername() : "未实名用户") + "的求职简历");
}
ResumeMakeDto dto = new ResumeMakeDto();
dto.setUserId(finalUser.getId());
......@@ -183,54 +185,54 @@ public class NewEditionResumeServiceImpl implements NewEditionResumeService {
this.resumeCacheService.refreshResumeListCache(caches, null == dto.getUserId() ? SecurityUtils.getUser().getId() : dto.getUserId());
}
List<String> list = caches.stream().map(ResumeListItemCache::getResumeName).filter(name -> name != null && !name.trim().isEmpty()).toList();
resumeNew.setResumeName(generate(resumeNew.getResumeName(),list));
resumeNew.setResumeName(generate(resumeNew.getResumeName(), list));
resumeNew.setTemplateId("1");
resumeNew.setTemplateName("tpl1.ejs");
resumeNew.setUserId(finalUser.getId());
resumeNew.setUserId(frontUser.getId());
newEditionResumeUtil.initResumeModel(resumeNew, finalUser);
// 教育背景模块(可包含多个教育经历)
JSONObject edus = result.getJSONObject("edus");
resumeEdus(String.valueOf(resumeNew.getId()),ResumeEnum.ResumeModel.EDU.getName(),edus);
resumeEdus(String.valueOf(resumeNew.getId()), ResumeEnum.ResumeModel.EDU.getName(), edus);
// 工作经历模块
JSONObject workExps = result.getJSONObject("workExps");
resumeWorkExps(String.valueOf(resumeNew.getId()),ResumeEnum.ResumeModel.WORK_EXP.getName(),workExps);
resumeWorkExps(String.valueOf(resumeNew.getId()), ResumeEnum.ResumeModel.WORK_EXP.getName(), workExps);
// 项目经历模块
JSONObject projects = result.getJSONObject("projects");
resumeProjects(String.valueOf(resumeNew.getId()), ResumeEnum.ResumeModel.PROJECT.getName(),projects, finalUser);
resumeProjects(String.valueOf(resumeNew.getId()), ResumeEnum.ResumeModel.PROJECT.getName(), projects, finalUser);
// 实习经历模块(结构与工作经历类似)
JSONObject internships = result.getJSONObject("internships");
resumeInternships(String.valueOf(resumeNew.getId()),ResumeEnum.ResumeModel.INTERNSHIP.getName(),internships);
resumeInternships(String.valueOf(resumeNew.getId()), ResumeEnum.ResumeModel.INTERNSHIP.getName(), internships);
// 社团经历模块
JSONObject clubs = result.getJSONObject("clubs");
resumeClubs(String.valueOf(resumeNew.getId()),ResumeEnum.ResumeModel.CLUB.getName(),clubs);
resumeClubs(String.valueOf(resumeNew.getId()), ResumeEnum.ResumeModel.CLUB.getName(), clubs);
// 专业技能模块
JSONObject skill = result.getJSONObject("skill");
resumeSkillAdvantageAwardsHobbles(String.valueOf(resumeNew.getId()),ResumeEnum.ResumeModel.SKILL.getName(),skill,ResumeEnum.ResumeModel.SKILL.getCode());
resumeSkillAdvantageAwardsHobbles(String.valueOf(resumeNew.getId()), ResumeEnum.ResumeModel.SKILL.getName(), skill, ResumeEnum.ResumeModel.SKILL.getCode());
// 个人优势模块
JSONObject advantage = result.getJSONObject("advantage");
resumeSkillAdvantageAwardsHobbles(String.valueOf(resumeNew.getId()),ResumeEnum.ResumeModel.ADVANTAGE.getName(),advantage,ResumeEnum.ResumeModel.ADVANTAGE.getCode());
resumeSkillAdvantageAwardsHobbles(String.valueOf(resumeNew.getId()), ResumeEnum.ResumeModel.ADVANTAGE.getName(), advantage, ResumeEnum.ResumeModel.ADVANTAGE.getCode());
// 荣誉奖项模块
JSONObject awards = result.getJSONObject("awards");
resumeSkillAdvantageAwardsHobbles(String.valueOf(resumeNew.getId()),ResumeEnum.ResumeModel.AWARDS.getName(),awards,ResumeEnum.ResumeModel.AWARDS.getCode());
resumeSkillAdvantageAwardsHobbles(String.valueOf(resumeNew.getId()), ResumeEnum.ResumeModel.AWARDS.getName(), awards, ResumeEnum.ResumeModel.AWARDS.getCode());
// 兴趣爱好模块
JSONObject hobbles = result.getJSONObject("hobbles");
resumeSkillAdvantageAwardsHobbles(String.valueOf(resumeNew.getId()),ResumeEnum.ResumeModel.HOBBLES.getName(),hobbles,ResumeEnum.ResumeModel.HOBBLES.getCode());
resumeSkillAdvantageAwardsHobbles(String.valueOf(resumeNew.getId()), ResumeEnum.ResumeModel.HOBBLES.getName(), hobbles, ResumeEnum.ResumeModel.HOBBLES.getCode());
this.functionResumeBaseMapper.updateById(resumeNew);
this.resumeCacheService.saveUserResumeListCache(resumeNew, finalUser.getId());
this.resumeCacheService.delResumeListCache(finalUser.getId());
Map<String,Object> templateMap = new HashMap<>();
Map<String, Object> templateMap = new HashMap<>();
templateMap.put("templateId", resumeNew.getTemplateId());
templateMap.put("templateName", resumeNew.getTemplateName());
this.resumeCacheService.saveResumeTemplateCache(templateMap, String.valueOf(resumeNew.getId()));
......@@ -254,7 +256,7 @@ public class NewEditionResumeServiceImpl implements NewEditionResumeService {
}, commonAsyncThreadPool.getExecutor().getThreadPoolExecutor());
}
public static String generate(String baseName,List<String> names) {
public static String generate(String baseName, List<String> names) {
int maxNumber = -1; // 初始为-1表示尚未发现数字编号
Pattern pattern = Pattern.compile(Pattern.quote(baseName) + "(\\d+)?$");
......@@ -279,10 +281,10 @@ public class NewEditionResumeServiceImpl implements NewEditionResumeService {
}
// 教育背景模块(可包含多个教育经历)
public void resumeEdus(String resumeId,String name,JSONObject object){
if(object != null){
public void resumeEdus(String resumeId, String name, JSONObject object) {
if (object != null) {
JSONArray value = object.getJSONArray("value");
if(value != null && value.size() > 0){
if (value != null && value.size() > 0) {
ResumeMakeDto resumeMakeDto = new ResumeMakeDto();
resumeMakeDto.setResumeId(resumeId);
......@@ -298,10 +300,10 @@ public class NewEditionResumeServiceImpl implements NewEditionResumeService {
}
// 工作经历模块
public void resumeWorkExps(String resumeId,String name,JSONObject object) {
if(object != null){
public void resumeWorkExps(String resumeId, String name, JSONObject object) {
if (object != null) {
JSONArray value = object.getJSONArray("value");
if(value != null && value.size() > 0){
if (value != null && value.size() > 0) {
ResumeMakeDto resumeMakeDto = new ResumeMakeDto();
resumeMakeDto.setResumeId(resumeId);
......@@ -316,10 +318,10 @@ public class NewEditionResumeServiceImpl implements NewEditionResumeService {
}
//项目经历模块
public void resumeProjects(String resumeId,String name,JSONObject object,UserLoginInfo user) {
if(object != null){
public void resumeProjects(String resumeId, String name, JSONObject object, UserLoginInfo user) {
if (object != null) {
JSONArray value = object.getJSONArray("value");
if(value != null && value.size() > 0){
if (value != null && value.size() > 0) {
ResumeMakeDto resumeMakeDto = new ResumeMakeDto();
resumeMakeDto.setResumeId(resumeId);
resumeMakeDto.setUserId(user.getId());
......@@ -334,10 +336,11 @@ public class NewEditionResumeServiceImpl implements NewEditionResumeService {
}
// 专业技能模块 个人优势模块 荣誉奖项模块 兴趣爱好模块
public void resumeSkillAdvantageAwardsHobbles(String resumeId,String name,JSONObject object,int code) {
if(object != null){
List<AdvantageSkillAwardsHobbles> value = object.getObject("value",new TypeReference<List<AdvantageSkillAwardsHobbles>>() {});
if(value != null && value.size() > 0){
public void resumeSkillAdvantageAwardsHobbles(String resumeId, String name, JSONObject object, int code) {
if (object != null) {
List<AdvantageSkillAwardsHobbles> value = object.getObject("value", new TypeReference<List<AdvantageSkillAwardsHobbles>>() {
});
if (value != null && value.size() > 0) {
ResumeMakeDto resumeMakeDto = new ResumeMakeDto();
resumeMakeDto.setResumeId(resumeId);
......@@ -358,10 +361,10 @@ public class NewEditionResumeServiceImpl implements NewEditionResumeService {
}
// 社团经历模块
public void resumeClubs(String resumeId,String name,JSONObject object) {
if(object != null){
public void resumeClubs(String resumeId, String name, JSONObject object) {
if (object != null) {
JSONArray value = object.getJSONArray("value");
if(value != null && value.size() > 0){
if (value != null && value.size() > 0) {
ResumeMakeDto resumeMakeDto = new ResumeMakeDto();
resumeMakeDto.setResumeId(resumeId);
......@@ -375,10 +378,10 @@ public class NewEditionResumeServiceImpl implements NewEditionResumeService {
}
// 实习经历模块(结构与工作经历类似)
public void resumeInternships(String resumeId,String name,JSONObject object) {
if(object != null){
public void resumeInternships(String resumeId, String name, JSONObject object) {
if (object != null) {
JSONArray value = object.getJSONArray("value");
if(value != null && value.size() > 0){
if (value != null && value.size() > 0) {
ResumeMakeDto resumeMakeDto = new ResumeMakeDto();
resumeMakeDto.setResumeId(resumeId);
......@@ -599,10 +602,14 @@ public class NewEditionResumeServiceImpl implements NewEditionResumeService {
case "edus" -> dataMap.put("data", newEditionResumeUtil.queryEduInfo(dto));
case "workExps" -> dataMap.put("data", newEditionResumeUtil.queryExtraInfo(dto));
case "projects" -> dataMap.put("data", newEditionResumeUtil.queryProjectInfo(dto));
case "skill" -> dataMap.put("data", newEditionResumeUtil.queryExtra(dto, ResumeEnum.ResumeModel.SKILL.getCode()));
case "advantage" -> dataMap.put("data", newEditionResumeUtil.queryExtra(dto, ResumeEnum.ResumeModel.ADVANTAGE.getCode()));
case "awards" -> dataMap.put("data", newEditionResumeUtil.queryExtra(dto, ResumeEnum.ResumeModel.AWARDS.getCode()));
case "hobbles" -> dataMap.put("data", newEditionResumeUtil.queryExtra(dto, ResumeEnum.ResumeModel.HOBBLES.getCode()));
case "skill" ->
dataMap.put("data", newEditionResumeUtil.queryExtra(dto, ResumeEnum.ResumeModel.SKILL.getCode()));
case "advantage" ->
dataMap.put("data", newEditionResumeUtil.queryExtra(dto, ResumeEnum.ResumeModel.ADVANTAGE.getCode()));
case "awards" ->
dataMap.put("data", newEditionResumeUtil.queryExtra(dto, ResumeEnum.ResumeModel.AWARDS.getCode()));
case "hobbles" ->
dataMap.put("data", newEditionResumeUtil.queryExtra(dto, ResumeEnum.ResumeModel.HOBBLES.getCode()));
case "clubs" -> dataMap.put("data", newEditionResumeUtil.queryClubInfo(dto));
case "internships" -> dataMap.put("data", newEditionResumeUtil.queryInternshipExp(dto));
case "custom" -> dataMap.put("data", newEditionResumeUtil.queryCustom(dto));
......@@ -612,9 +619,13 @@ public class NewEditionResumeServiceImpl implements NewEditionResumeService {
@Override
public Object updateModule(String modelName, ResumeMakeDto resumeMakeDto) throws Exception {
LoginUser loginUser = LoginHelper.getLoginUser();
if (loginUser == null) {
throw new WarnException("用户信息获取失败");
}
UserLoginInfo user = new UserLoginInfo();
AuthFrontUser frontUser = frontUserMapper.selectById(1L);
BeanUtils.copyProperties(frontUser,user);
AuthFrontUser frontUser = frontUserMapper.selectById(loginUser.getUserId());
BeanUtils.copyProperties(frontUser, user);
resumeMakeDto.setUserId(user.getId());
Long modelId = null;
......@@ -625,7 +636,8 @@ public class NewEditionResumeServiceImpl implements NewEditionResumeService {
case "workExps" -> newEditionResumeUtil.updateExtraInfo(resumeMakeDto);
case "projects" -> newEditionResumeUtil.updateProjectInfo(resumeMakeDto);
case "skill" -> newEditionResumeUtil.updateExtra(resumeMakeDto, ResumeEnum.ResumeModel.SKILL.getCode());
case "advantage" -> newEditionResumeUtil.updateExtra(resumeMakeDto, ResumeEnum.ResumeModel.ADVANTAGE.getCode());
case "advantage" ->
newEditionResumeUtil.updateExtra(resumeMakeDto, ResumeEnum.ResumeModel.ADVANTAGE.getCode());
case "awards" -> newEditionResumeUtil.updateExtra(resumeMakeDto, ResumeEnum.ResumeModel.AWARDS.getCode());
case "hobbles" -> newEditionResumeUtil.updateExtra(resumeMakeDto, ResumeEnum.ResumeModel.HOBBLES.getCode());
case "clubs" -> newEditionResumeUtil.updateClubInfo(resumeMakeDto);
......@@ -648,10 +660,10 @@ public class NewEditionResumeServiceImpl implements NewEditionResumeService {
@Override
public List<ResumeListItemCache> resumeList(Long userId) {
List<ResumeListItemCache> caches = this.resumeCacheService.queryResumeList(null == userId ? SecurityUtils.getUser().getId() : userId);
List<ResumeListItemCache> caches = this.resumeCacheService.queryResumeList(userId);
if (caches == null) {
caches = this.functionResumeBaseMapper.queryResumeListV2(null == userId ? SecurityUtils.getUser().getId() : userId);
this.resumeCacheService.refreshResumeListCache(caches, null == userId ? SecurityUtils.getUser().getId() : userId);
caches = this.functionResumeBaseMapper.queryResumeListV2(userId);
this.resumeCacheService.refreshResumeListCache(caches, userId);
}
return caches;
}
......@@ -659,9 +671,9 @@ public class NewEditionResumeServiceImpl implements NewEditionResumeService {
@Override
public void delResume(ResumeMakeDto dto) {
Long userId = 1L;
UserLoginInfo userLoginInfo = SecurityUtils.getUser();
if (userLoginInfo!=null){
userId = userLoginInfo.getId();
LoginUser userLoginInfo = LoginHelper.getLoginUser();
if (userLoginInfo != null) {
userId = userLoginInfo.getUserId();
}
String resumeKey = CacheConstants.REDIS_USER_RESUME_KEY.formatted(userId, dto.getResumeId());
redisTemplate.delete(resumeKey);
......@@ -680,7 +692,7 @@ public class NewEditionResumeServiceImpl implements NewEditionResumeService {
@Override
public String createResumeHtml(String resumeId) {
if (StringUtils.isBlank(resumeId)){
if (StringUtils.isBlank(resumeId)) {
throw new WarnException("简历ID不能为空");
}
ResumeByPdfVo vo = new ResumeByPdfVo();
......@@ -701,11 +713,11 @@ public class NewEditionResumeServiceImpl implements NewEditionResumeService {
}
String jsonString = JSON.toJSONString(objectMap);
if(objectMap.get("base") != null){
if (objectMap.get("base") != null) {
Map<String, Object> map = JSON.parseObject(String.valueOf(objectMap.get("base")), Map.class);
if(map.get("resumeName") != null){
if (map.get("resumeName") != null) {
vo.setResumeName(map != null ? String.valueOf(map.get("resumeName")) : "");
}else {
} else {
FunctionResumeBase resumeBase = this.functionResumeBaseMapper.selectById(resumeId);
vo.setResumeName(resumeBase.getResumeName());
this.resumeCacheService.saveResumeModelDataCache(Long.valueOf(resumeId), Long.valueOf(resumeId), JSON.toJSONString(resumeBase));
......@@ -714,10 +726,10 @@ public class NewEditionResumeServiceImpl implements NewEditionResumeService {
}
String data = redisTemplate.opsForValue().get(CacheConstants.CREATE_RESUME_HTML_DATA.formatted(resumeId));
if (StringUtils.isNotBlank(data)){
if(jsonString.equals(data)){
if (StringUtils.isNotBlank(data)) {
if (jsonString.equals(data)) {
String json = redisTemplate.opsForValue().get(CacheConstants.CREATE_RESUME_HTML.formatted(resumeId));
if(StringUtils.isNotBlank(json)){
if (StringUtils.isNotBlank(json)) {
return json;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment