Sfoglia il codice sorgente

1、增加职位分享的接口

rayson 9 mesi fa
parent
commit
2ddc860be7

+ 16 - 4
menduner/menduner-system-biz/src/main/java/com/citu/module/menduner/system/controller/app/jobhunt/job/AppJobAdvertisedController.java

@@ -14,14 +14,12 @@ import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import javax.validation.Valid;
 import java.util.List;
+import java.util.Map;
 
 import static com.citu.framework.common.pojo.CommonResult.success;
 
@@ -44,6 +42,7 @@ public class AppJobAdvertisedController {
     @Resource
     private EnterpriseJobService enterpriseJobService;
 
+
     @GetMapping("/get/recommended")
     @Operation(summary = "获取推荐招聘职位分页")
     public CommonResult<PageResult<AppJobAdvertisedHomeRespVO>> getRecommendedPage(@Valid PageParam pageParam) {
@@ -115,4 +114,17 @@ public class AppJobAdvertisedController {
         return success(list);
     }
 
+    @GetMapping("/get/share")
+    @Operation(summary = "根据id获取职位分享真实参数")
+    public CommonResult<Object> getShareById
+            (@RequestParam("id") Long id) {
+        return success(jobAdvertisedService.getShareById(id));
+    }
+
+    @PostMapping("/share")
+    @Operation(summary = "分享职位")
+    public CommonResult<Long> share(@Valid @RequestBody Map<String, Object> map) {
+        return success(jobAdvertisedService.share(map));
+    }
+
 }

+ 7 - 1
menduner/menduner-system-biz/src/main/java/com/citu/module/menduner/system/dal/redis/RedisKeyConstants.java

@@ -130,5 +130,11 @@ public interface RedisKeyConstants {
     String MDE_ENTERPRISE_TREE ="mde_enterprise_tree";
 
 
-
+    /**
+     * 职位分享
+     * <p>
+     * KEY 格式:job_share:{id}
+     * VALUE 数据类型:Object
+     */
+    String JOB_SHARE = "job_share";
 }

+ 20 - 3
menduner/menduner-system-biz/src/main/java/com/citu/module/menduner/system/service/job/JobAdvertisedService.java

@@ -18,6 +18,7 @@ import com.citu.module.menduner.system.dal.dataobject.job.JobAdvertisedDO;
 
 import javax.validation.Valid;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 招聘职位 Service 接口
@@ -150,6 +151,7 @@ public interface JobAdvertisedService {
 
     /**
      * 获取发布的职位
+     *
      * @return 简易职位信息的集合
      **/
     List<AppRecruitJobSimpleRespVO> getList();
@@ -165,15 +167,30 @@ public interface JobAdvertisedService {
     void renewal(AppRecruitJobRenewalReqVO reqVO);
 
 
+    /**
+     * 根据id 获取分享内容参数
+     **/
+    Object getShareById(Long id);
+
+    /**
+     * 设置分享内容
+     **/
+    Long share(Map<String, Object> map);
     // ========== 统计分析 ==========
 
-    /** 获取发布职位浏览量明细 */
+    /**
+     * 获取发布职位浏览量明细
+     */
     PageResult<RecruitJobAnalysisRespVO> getBrowseNum(RecruitAnalysisPageReqVO reqVO);
 
-    /** 获取发布职位浏览量总数 */
+    /**
+     * 获取发布职位浏览量总数
+     */
     Long getBrowseNumCount(RecruitAnalysisPageReqVO reqVO);
 
-    /** 获取发布职位明细 */
+    /**
+     * 获取发布职位明细
+     */
     PageResult<RecruitJobAnalysisRespVO> getJobNum(RecruitAnalysisPageReqVO reqVO);
 
 

+ 35 - 2
menduner/menduner-system-biz/src/main/java/com/citu/module/menduner/system/service/job/JobAdvertisedServiceImpl.java

@@ -2,6 +2,7 @@ package com.citu.module.menduner.system.service.job;
 
 
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.IdUtil;
 import cn.hutool.http.HtmlUtil;
 import com.baomidou.dynamic.datasource.annotation.DSTransactional;
 import com.citu.framework.common.pojo.PageParam;
@@ -32,6 +33,7 @@ import com.citu.module.menduner.system.enums.sync.SyncConstants;
 import com.citu.module.menduner.system.mq.producer.ESProducer;
 import com.citu.module.menduner.system.mq.producer.GraphProducer;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
@@ -42,12 +44,14 @@ import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
 import static com.citu.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static com.citu.module.menduner.common.util.TimeUtils.generateDateTimeRange;
+import static com.citu.module.menduner.system.dal.redis.RedisKeyConstants.JOB_SHARE;
 import static com.citu.module.menduner.system.enums.DictTypeConstants.*;
 import static com.citu.module.menduner.system.enums.ErrorCodeConstants.*;
-import static com.citu.module.menduner.common.util.TimeUtils.generateDateTimeRange;
 
 /**
  * 招聘职位 Service 实现类
@@ -72,6 +76,9 @@ public class JobAdvertisedServiceImpl implements JobAdvertisedService {
     @Resource
     private GraphApi graphApi;
 
+    @Resource
+    private RedisTemplate<String, Object> redisTemplate;
+
 
     @Override
     public Long createJobAdvertised(JobAdvertisedSaveReqVO createReqVO) {
@@ -468,7 +475,7 @@ public class JobAdvertisedServiceImpl implements JobAdvertisedService {
     @Override
     public void renewal(AppRecruitJobRenewalReqVO reqVO) {
         JobAdvertisedDO job = get(reqVO.getId());
-        if(null == reqVO.getTime() || LocalDateTime.now().isAfter(reqVO.getTime())) {
+        if (null == reqVO.getTime() || LocalDateTime.now().isAfter(reqVO.getTime())) {
             // 时间不能小于当前时间
             throw exception(MDE_JOB_ADVERTISED_TIME_ERROR);
         }
@@ -476,6 +483,32 @@ public class JobAdvertisedServiceImpl implements JobAdvertisedService {
         mapper.updateById(job);
     }
 
+    @Override
+    public Object getShareById(Long id) {
+
+        Map<Object, Object> value = redisTemplate.opsForHash().entries(JOB_SHARE + "_" + id);
+
+        if (null == value || value.isEmpty()) {
+            return null;
+        }
+
+        return value.get("data");
+    }
+
+    @Override
+    public Long share(Map<String, Object> map) {
+        // 生成一个唯一的ID
+        Long id = IdUtil.getSnowflakeNextId();
+        String key = JOB_SHARE + "_" + id;
+        // 将数据存入Redis哈希表
+        redisTemplate.opsForHash().put(key, "data", map);
+
+        // 设置整个键的过期时间(例如:30天后过期)
+        redisTemplate.expire(key, 30, TimeUnit.DAYS);
+
+        return id;
+    }
+
     /**
      * 职位操作最后的操作
      *