whites = ignoreWhiteConfig.getWhites();
+
+ ServerHttpRequest request = exchange.getRequest();
+
+ String path = request.getURI().getPath();
+
+ if(StringUtils.matches(path,whites)){
+
+ chain.filter(exchange);
+
+ }
+
+ String first = request.getHeaders().getFirst("token");
+
+
+ if(StringUtils.isBlank(first)){
+
+ return GatewayUtils.errorResponse(exchange,"Token不可以为空");
+
+ }
+
+
+ try{
+ JwtUtils.parseToken(first);
+ }catch (Exception E){
+
+ return GatewayUtils.errorResponse(exchange,"Token不合法");
+
+ }
+
+ String userKey = JwtUtils.getUserKey(first);
+
+ String s = stringRedisTemplate.opsForValue().get(TokenConstants.LOGIN_TOKEN_KEY + userKey);
+
+ if(StringUtils.isNotBlank(s)){
+ return GatewayUtils.errorResponse(exchange,"Token过期");
+ }
+
+ stringRedisTemplate.expire(TokenConstants.LOGIN_TOKEN_KEY+userKey,15,TimeUnit.MINUTES);
+
+ return chain.filter(exchange);
+ }
+
+ /**
+ * Get the order value of this object.
+ * Higher values are interpreted as lower priority. As a consequence,
+ * the object with the lowest value has the highest priority (somewhat
+ * analogous to Servlet {@code load-on-startup} values).
+ *
Same order values will result in arbitrary sort positions for the
+ * affected objects.
+ *
+ * @return the order value
+ * @see #HIGHEST_PRECEDENCE
+ * @see #LOWEST_PRECEDENCE
+ */
+ @Override
+ public int getOrder() {
+ return 0;
+ }
+}
diff --git a/hamburg-gateway/src/main/java/com/hamburg/gateway/utils/GatewayUtils.java b/hamburg-gateway/src/main/java/com/hamburg/gateway/utils/GatewayUtils.java
new file mode 100644
index 0000000..71c8112
--- /dev/null
+++ b/hamburg-gateway/src/main/java/com/hamburg/gateway/utils/GatewayUtils.java
@@ -0,0 +1,98 @@
+package com.hamburg.gateway.utils;
+
+import com.alibaba.fastjson.JSONObject;
+import com.hamburg.common.result.Result;
+import com.hamburg.common.utils.StringUtils;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.core.io.buffer.DataBuffer;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.server.reactive.ServerHttpRequest;
+import org.springframework.http.server.reactive.ServerHttpResponse;
+import org.springframework.web.server.ServerWebExchange;
+import reactor.core.publisher.Mono;
+
+/**
+ * @author DongZl
+ * @description: 网关处理工具类
+ */
+@Log4j2
+public class GatewayUtils {
+ /**
+ * 添加请求头参数
+ * @param mutate 修改对象
+ * @param key 键
+ * @param value 值
+ */
+ public static void addHeader(ServerHttpRequest.Builder mutate, String key, Object value) {
+ if (StringUtils.isEmpty(key)){
+ log.warn("添加请求头参数键不可以为空");
+ return;
+ }
+ if (value == null) {
+ log.warn("添加请求头参数:[{}]值为空",key);
+ return;
+ }
+ String valueStr = value.toString();
+ mutate.header(key, valueStr);
+ log.info("添加请求头参数成功 - 键:[{}] , 值:[{}]", key , value);
+ }
+
+ /**
+ * 删除请求头参数
+ * @param mutate 修改对象
+ * @param key 键
+ */
+ public static void removeHeader(ServerHttpRequest.Builder mutate, String key) {
+ if (StringUtils.isEmpty(key)){
+ log.warn("删除请求头参数键不可以为空");
+ return;
+ }
+ mutate.headers(httpHeaders -> httpHeaders.remove(key)).build();
+ log.info("删除请求头参数 - 键:[{}]",key);
+ }
+
+ /**
+ * 错误结果响应
+ * @param exchange 响应上下文
+ * @param msg 响应消息
+ * @return
+ */
+ public static Mono errorResponse(ServerWebExchange exchange, String msg, HttpStatus httpStatus) {
+ ServerHttpResponse response = exchange.getResponse();
+ //设置HTTP响应头状态
+ response.setStatusCode(httpStatus);
+ //设置HTTP响应头文本格式
+ response.getHeaders().add(HttpHeaders.CONTENT_TYPE, "application/json");
+ //定义响应内容
+ Result> result = Result.error(msg);
+ String resultJson = JSONObject.toJSONString(result);
+ log.error("[鉴权异常处理]请求路径:[{}],异常信息:[{}],响应结果:[{}]", exchange.getRequest().getPath(), msg, resultJson);
+ DataBuffer dataBuffer = response.bufferFactory().wrap(resultJson.getBytes());
+ //进行响应
+ return response.writeWith(Mono.just(dataBuffer));
+ }
+
+ /**
+ * 错误结果响应
+ * @param exchange 响应上下文
+ * @param msg 响应消息
+ * @return
+ */
+ public static Mono errorResponse(ServerWebExchange exchange, String msg) {
+ ServerHttpResponse response = exchange.getResponse();
+ //设置HTTP响应头状态
+ response.setStatusCode(HttpStatus.OK);
+ //设置HTTP响应头文本格式
+ response.getHeaders().add(HttpHeaders.CONTENT_TYPE, "application/json");
+ //定义响应内容
+ Result> result = Result.error(msg);
+ String resultJson = JSONObject.toJSONString(result);
+ log.error("[鉴权异常处理]请求路径:[{}],异常信息:[{}],响应结果:[{}]", exchange.getRequest().getPath(), msg, resultJson);
+ DataBuffer dataBuffer = response.bufferFactory().wrap(resultJson.getBytes());
+ //进行响应
+ return response.writeWith(Mono.just(dataBuffer));
+ }
+
+
+}
diff --git a/hamburg-gateway/src/main/resources/bootstrap.yml b/hamburg-gateway/src/main/resources/bootstrap.yml
new file mode 100644
index 0000000..3c28634
--- /dev/null
+++ b/hamburg-gateway/src/main/resources/bootstrap.yml
@@ -0,0 +1,31 @@
+# Tomcat
+server:
+ port: 18080
+# Spring
+spring:
+ application:
+ # 应用名称
+ name: hamburg-gateway
+ profiles:
+ # 环境配置
+ active: dev
+ main:
+ # 允许使用循环引用
+ allow-circular-references: true
+ # 允许定义相同的bean对象 去覆盖原有的
+ allow-bean-definition-overriding: true
+ cloud:
+ nacos:
+ discovery:
+ # 服务注册地址
+ server-addr: 124.70.191.180:8848
+ namespace: High-five
+ config:
+ # 配置中心地址
+ server-addr: 124.70.191.180:8848
+ namespace: High-five
+ # 配置文件格式
+ file-extension: yml
+ # 共享配置
+ shared-configs:
+ - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
diff --git a/hamburg-modules/hamburg-candidate/pom.xml b/hamburg-modules/hamburg-candidate/pom.xml
new file mode 100644
index 0000000..08d8932
--- /dev/null
+++ b/hamburg-modules/hamburg-candidate/pom.xml
@@ -0,0 +1,20 @@
+
+
+ 4.0.0
+
+ org.example
+ hamburg-modules
+ 1.0-SNAPSHOT
+
+
+ hamburg-candidate
+
+
+ 8
+ 8
+ UTF-8
+
+
+
diff --git a/hamburg-modules/hamburg-candidate/src/main/java/com/hamburg/candidate/CandidateApplication.java b/hamburg-modules/hamburg-candidate/src/main/java/com/hamburg/candidate/CandidateApplication.java
new file mode 100644
index 0000000..ab13fa8
--- /dev/null
+++ b/hamburg-modules/hamburg-candidate/src/main/java/com/hamburg/candidate/CandidateApplication.java
@@ -0,0 +1,23 @@
+package com.hamburg.candidate;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+/**
+ * @Author:liuxinyue
+ * @Package:com.hamburg.candidate
+ * @Project:ZK8.6
+ * @name:CandidateApplication
+ * @Date:2024/8/6 11:41
+ */
+@SpringBootApplication
+public class CandidateApplication {
+
+ public static void main(String[] args) {
+
+ SpringApplication.run(CandidateApplication.class, args);
+
+
+ }
+
+}
diff --git a/hamburg-modules/hamburg-candidate/src/main/java/com/hamburg/candidate/controller/CandidateController.java b/hamburg-modules/hamburg-candidate/src/main/java/com/hamburg/candidate/controller/CandidateController.java
new file mode 100644
index 0000000..37fead9
--- /dev/null
+++ b/hamburg-modules/hamburg-candidate/src/main/java/com/hamburg/candidate/controller/CandidateController.java
@@ -0,0 +1,76 @@
+package com.hamburg.candidate.controller;
+
+import com.hamburg.candidate.service.CandidateService;
+import com.hamburg.common.domain.Candidate;
+import com.hamburg.common.domain.request.CandidateReq;
+import com.hamburg.common.result.Result;
+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 java.util.List;
+
+/**
+ * @Author:liuxinyue
+ * @Package:com.hamburg.candidate.controller
+ * @Project:ZK8.6
+ * @name:CandidateController
+ * @Date:2024/8/6 11:42
+ */
+@RestController
+@RequestMapping("/candidate")
+public class CandidateController {
+
+
+ @Autowired
+ private CandidateService candidateService;
+
+ /**
+ * 添加候选人
+ * @param candidateReq
+ * @return
+ */
+ @PostMapping("/sendAResume")
+ public Result sendAResume(@RequestBody CandidateReq candidateReq) {
+
+ return candidateService.addCandidate(candidateReq);
+
+ }
+
+
+ /**
+ * 候选人列表
+ * @param
+ * @return
+ */
+ @PostMapping("/findCandidate")
+ public Result findCandidate() {
+ List list=candidateService.findCandidate();
+ return Result.success(list);
+ }
+
+ /**
+ * 通过
+ * @param candidate
+ * @return
+ */
+ @PostMapping("/passCandidateStatus")
+ public Result passCandidateStatus(@RequestBody Candidate candidate) {
+
+ return candidateService.passCandidateStatus(candidate);
+
+ }
+
+ /**
+ * 不通过
+ * @param candidate
+ * @return
+ */
+ @PostMapping("/noPassCandidateStatus")
+ public Result noPassCandidateStatus(@RequestBody Candidate candidate) {
+ return candidateService.noPassCandidateStatus(candidate);
+ }
+
+}
diff --git a/hamburg-modules/hamburg-candidate/src/main/java/com/hamburg/candidate/mapper/CandidateMapper.java b/hamburg-modules/hamburg-candidate/src/main/java/com/hamburg/candidate/mapper/CandidateMapper.java
new file mode 100644
index 0000000..8fafd6c
--- /dev/null
+++ b/hamburg-modules/hamburg-candidate/src/main/java/com/hamburg/candidate/mapper/CandidateMapper.java
@@ -0,0 +1,38 @@
+package com.hamburg.candidate.mapper;
+
+import com.hamburg.common.domain.Candidate;
+import com.hamburg.common.domain.Middle;
+import com.hamburg.common.domain.request.CandidateReq;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * @Author:liuxinyue
+ * @Package:com.hamburg.candidate.mapper
+ * @Project:ZK8.6
+ * @name:CandidateMapper
+ * @Date:2024/8/6 11:43
+ */
+@Mapper
+public interface CandidateMapper {
+
+
+ Middle findMiddle(@Param("inviteName") String inviteName, @Param("userId") Integer userId);
+
+ int addCandidate(CandidateReq candidateReq);
+
+ void upd(@Param("inviteName") String inviteName);
+
+ void updUserNumber(@Param("userId") Integer userId);
+
+ List findCandidate();
+
+ int passCandidateStatus(@Param("candidateId") Integer candidateId);
+
+ int noPassCandidateStatus(@Param("candidateId") Integer candidateId);
+
+ void addMiddle(@Param("userId") Integer userId, @Param("inviteName") String inviteName);
+
+}
diff --git a/hamburg-modules/hamburg-candidate/src/main/java/com/hamburg/candidate/service/CandidateService.java b/hamburg-modules/hamburg-candidate/src/main/java/com/hamburg/candidate/service/CandidateService.java
new file mode 100644
index 0000000..462a87a
--- /dev/null
+++ b/hamburg-modules/hamburg-candidate/src/main/java/com/hamburg/candidate/service/CandidateService.java
@@ -0,0 +1,26 @@
+package com.hamburg.candidate.service;
+
+import com.hamburg.common.domain.Candidate;
+import com.hamburg.common.domain.request.CandidateReq;
+import com.hamburg.common.result.Result;
+
+import java.util.List;
+
+/**
+ * @Author:liuxinyue
+ * @Package:com.hamburg.candidate.service
+ * @Project:ZK8.6
+ * @name:CandidateService
+ * @Date:2024/8/6 11:42
+ */
+public interface CandidateService {
+
+ Result addCandidate(CandidateReq candidateReq);
+
+ List findCandidate();
+
+ Result passCandidateStatus(Candidate candidate);
+
+ Result noPassCandidateStatus(Candidate candidate);
+
+}
diff --git a/hamburg-modules/hamburg-candidate/src/main/java/com/hamburg/candidate/service/impl/CandidateServiceImpl.java b/hamburg-modules/hamburg-candidate/src/main/java/com/hamburg/candidate/service/impl/CandidateServiceImpl.java
new file mode 100644
index 0000000..e5e5a62
--- /dev/null
+++ b/hamburg-modules/hamburg-candidate/src/main/java/com/hamburg/candidate/service/impl/CandidateServiceImpl.java
@@ -0,0 +1,145 @@
+package com.hamburg.candidate.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.hamburg.candidate.mapper.CandidateMapper;
+import com.hamburg.candidate.service.CandidateService;
+import com.hamburg.common.constants.TokenConstants;
+import com.hamburg.common.domain.Candidate;
+import com.hamburg.common.domain.Middle;
+import com.hamburg.common.domain.User;
+import com.hamburg.common.domain.request.CandidateReq;
+import com.hamburg.common.result.Result;
+import com.hamburg.common.utils.JwtUtils;
+import org.springframework.amqp.core.Message;
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.StringRedisTemplate;
+import org.springframework.stereotype.Service;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.List;
+import java.util.UUID;
+
+/**
+ * @Author:liuxinyue
+ * @Package:com.hamburg.candidate.service.impl
+ * @Project:ZK8.6
+ * @name:CandidateServiceImpl
+ * @Date:2024/8/6 11:42
+ */
+@Service
+public class CandidateServiceImpl implements CandidateService{
+
+ @Autowired
+ private CandidateMapper candidateMapper;
+
+
+ @Autowired
+ private HttpServletRequest httpServletRequest;
+
+
+ @Autowired
+ private StringRedisTemplate stringRedisTemplate;
+
+ @Autowired
+ private RabbitTemplate rabbitTemplate;
+
+
+ @Override
+ public Result addCandidate(CandidateReq candidateReq) {
+
+ //投递的岗位名称
+ String inviteName = candidateReq.getInviteName();
+ User user = getUser();
+ //获取当前登录人的ID
+ Integer userId = user.getUserId();
+ //先判断当前用户是不是已经投过这个简历
+ Middle middle=candidateMapper.findMiddle(inviteName,userId);
+
+ if(null != middle){
+
+ return Result.error("请勿重复投递,请耐心等待!");
+
+ }
+ candidateReq.setUserName(user.getUserName());
+ System.out.println("哈哈哈哈哈哈"+user.getUserName()+user.getUserId());
+ candidateReq.setUserPhone(user.getUserPhone());
+ int add=candidateMapper.addCandidate(candidateReq);
+
+ //如果添加成功 相应的招聘列表中的候选人数加一
+ if(add>0){
+
+ //修改候选人的人数
+ candidateMapper.upd(inviteName);
+ //同时自己的投递简历的次数也加1
+ candidateMapper.updUserNumber(user.getUserId());
+ candidateMapper.addMiddle(user.getUserId(),inviteName);
+ }
+
+ return Result.success();
+
+ }
+
+ @Override
+ public List findCandidate() {
+ return candidateMapper.findCandidate();
+ }
+
+
+ @Override
+ public Result passCandidateStatus(Candidate candidate) {
+
+ //通过 修改状态
+ int updPass=candidateMapper.passCandidateStatus(candidate.getCandidateId());
+
+ if(updPass>0){
+
+
+ rabbitTemplate.convertAndSend(candidate.getUserPhone(),"pass_status_86",message->{
+
+ message.getMessageProperties().setMessageId(UUID.randomUUID().toString().replace("-",""));
+ return message;
+
+ });
+
+
+
+ }
+
+ return Result.success();
+ }
+
+ @Override
+ public Result noPassCandidateStatus(Candidate candidate) {
+ int updNoPass=candidateMapper.noPassCandidateStatus(candidate.getCandidateId());
+
+ if(updNoPass>0){
+
+
+ rabbitTemplate.convertAndSend("no_pass_status_86",candidate.getUserPhone(),message -> {
+ message.getMessageProperties().setMessageId(UUID.randomUUID().toString().replace("-",""));
+ return message;
+ });
+
+ }
+ return Result.success();
+ }
+
+
+
+ public User getUser(){
+
+ String header = httpServletRequest.getHeader(TokenConstants.TOKEN);
+
+ String userKey = JwtUtils.getUserKey(header);
+
+ String s = stringRedisTemplate.opsForValue().get(TokenConstants.LOGIN_TOKEN_KEY + userKey);
+
+ User user = JSONObject.parseObject(s, User.class);
+
+ return user;
+
+ }
+
+}
+
diff --git a/hamburg-modules/hamburg-candidate/src/main/resources/bootstrap.yml b/hamburg-modules/hamburg-candidate/src/main/resources/bootstrap.yml
new file mode 100644
index 0000000..2341206
--- /dev/null
+++ b/hamburg-modules/hamburg-candidate/src/main/resources/bootstrap.yml
@@ -0,0 +1,59 @@
+# Tomcat
+server:
+ port: 9007
+# Spring
+spring:
+ rabbitmq:
+ host: 124.70.191.180
+ port: 5672
+ username: guest
+ password: guest
+ virtual-host: /
+ listener:
+ simple:
+ prefetch: 1 # 每次取出一条消息消费消费完毕进行下一条
+ retry:
+ enabled: true
+ max-attempts: 3 # 重试次数
+ max-interval: 2000 # 重试间隔
+ acknowledge-mode: manual # 手动确认消息
+ publisher-confirm-type: correlated #确认消息已发送到交换机(Exchange)
+ publisher-returns: true #确认消息已发送到队列(Queue)
+ main:
+ allow-circular-references: true
+ jackson:
+ date-format: yyyy-MM-dd HH:mm:ss
+ time-zone: GMT+8
+ application:
+ # 应用名称
+ name: hamburg-candidate
+ profiles:
+ # 环境配置
+ active: dev
+ cloud:
+ nacos:
+ discovery:
+ # 服务注册地址
+ server-addr: 124.70.191.180:8848
+ namespace: High-five
+ config:
+ # 配置中心地址
+ server-addr: 124.70.191.180:8848
+ namespace: High-five
+ # 配置文件格式
+ file-extension: yml
+ # 共享配置
+ shared-configs:
+ - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
+fdfs:
+ so-timeout: 1500 # socket 连接时长
+ connect-timeout: 600 # 连接 tracker 服务器超时时长
+ # 这两个是你服务器的 IP 地址,注意 23000 端口也要打开,阿里云服务器记得配置安全组。tracker 要和 stroage 服务进行交流
+ tracker-list: 124.70.191.180:22122
+ web-server-url: 124.70.191.180:8888
+ pool:
+ jmx-enabled: false
+ # 生成缩略图
+ thumb-image:
+ height: 500
+ width: 500
diff --git a/hamburg-modules/hamburg-candidate/src/main/resources/mapper/ICandidateMapper.xml b/hamburg-modules/hamburg-candidate/src/main/resources/mapper/ICandidateMapper.xml
new file mode 100644
index 0000000..9ef555a
--- /dev/null
+++ b/hamburg-modules/hamburg-candidate/src/main/resources/mapper/ICandidateMapper.xml
@@ -0,0 +1,38 @@
+
+
+
+
+
+ INSERT INTO `86zk`.`t_candidate` ( `invite_name`, `user_name`, `user_phone`, `candidate_post`, `candidate_salary`, `candidate_time`, `candidate_status`)
+ VALUES ( #{inviteName}, #{userName}, #{userPhone}, #{candidatePost}, #{candidateSalary}, now(), 0);
+
+
+ INSERT INTO `86zk`.`t_middle` ( `user_id`, `invite_name`)
+ VALUES ( #{userId},#{inviteName});
+
+
+
+ update t_invite set invite_people=invite_people+1 where invite_name=#{inviteName}
+
+
+
+ update t_user set user_number=user_number+1 where user_id=#{userId}
+
+
+ update t_candidate set candidate_id=1 where candidate_id=#{candidateId}
+
+
+ update t_candidate set candidate_id=2 where candidate_id=#{candidateId}
+
+
+
+ select * from t_middle where user_id=#{userId} and invite_name=#{inviteName}
+
+
+ select * from t_candidate
+
+
+
+
diff --git a/hamburg-modules/hamburg-firm/pom.xml b/hamburg-modules/hamburg-firm/pom.xml
new file mode 100644
index 0000000..4912155
--- /dev/null
+++ b/hamburg-modules/hamburg-firm/pom.xml
@@ -0,0 +1,20 @@
+
+
+ 4.0.0
+
+ org.example
+ hamburg-modules
+ 1.0-SNAPSHOT
+
+
+ hamburg-firm
+
+
+ 8
+ 8
+ UTF-8
+
+
+
diff --git a/hamburg-modules/hamburg-firm/src/main/java/com/hamburg/firm/FirmApplication.java b/hamburg-modules/hamburg-firm/src/main/java/com/hamburg/firm/FirmApplication.java
new file mode 100644
index 0000000..ffddd9e
--- /dev/null
+++ b/hamburg-modules/hamburg-firm/src/main/java/com/hamburg/firm/FirmApplication.java
@@ -0,0 +1,23 @@
+package com.hamburg.firm;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+/**
+ * @Author:liuxinyue
+ * @Package:com.hamburg.firm
+ * @Project:ZK8.6
+ * @name:FirmApplication
+ * @Date:2024/8/6 12:59
+ */
+@SpringBootApplication
+public class FirmApplication {
+
+ public static void main(String[] args) {
+
+ SpringApplication.run(FirmApplication.class, args);
+
+
+ }
+
+}
diff --git a/hamburg-modules/hamburg-firm/src/main/java/com/hamburg/firm/controller/FirmController.java b/hamburg-modules/hamburg-firm/src/main/java/com/hamburg/firm/controller/FirmController.java
new file mode 100644
index 0000000..e8b4d61
--- /dev/null
+++ b/hamburg-modules/hamburg-firm/src/main/java/com/hamburg/firm/controller/FirmController.java
@@ -0,0 +1,43 @@
+package com.hamburg.firm.controller;
+
+import com.hamburg.common.domain.Firm;
+import com.hamburg.common.result.Result;
+import com.hamburg.firm.service.FirmService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * @Author:liuxinyue
+ * @Package:com.hamburg.firm.controller
+ * @Project:ZK8.6
+ * @name:FirmController
+ * @Date:2024/8/6 13:00
+ */
+@RestController
+@RequestMapping("/firm")
+public class FirmController {
+
+ @Autowired
+ private FirmService firmService;
+
+
+ /**
+ * 查询企业名称列表
+ * @return
+ */
+ @PostMapping("/findFirmList")
+ public Result> findFirmList() {
+
+
+ List list=firmService.findFirmList();
+
+ return Result.success(list);
+
+ }
+
+
+}
diff --git a/hamburg-modules/hamburg-firm/src/main/java/com/hamburg/firm/mapper/FirmMapper.java b/hamburg-modules/hamburg-firm/src/main/java/com/hamburg/firm/mapper/FirmMapper.java
new file mode 100644
index 0000000..741d81e
--- /dev/null
+++ b/hamburg-modules/hamburg-firm/src/main/java/com/hamburg/firm/mapper/FirmMapper.java
@@ -0,0 +1,20 @@
+package com.hamburg.firm.mapper;
+
+import com.hamburg.common.domain.Firm;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+/**
+ * @Author:liuxinyue
+ * @Package:com.hamburg.firm.mapper
+ * @Project:ZK8.6
+ * @name:FirmMapper
+ * @Date:2024/8/6 13:01
+ */
+@Mapper
+public interface FirmMapper {
+
+ List findFirmList();
+
+}
diff --git a/hamburg-modules/hamburg-firm/src/main/java/com/hamburg/firm/service/FirmService.java b/hamburg-modules/hamburg-firm/src/main/java/com/hamburg/firm/service/FirmService.java
new file mode 100644
index 0000000..e0a3c9f
--- /dev/null
+++ b/hamburg-modules/hamburg-firm/src/main/java/com/hamburg/firm/service/FirmService.java
@@ -0,0 +1,17 @@
+package com.hamburg.firm.service;
+
+import com.hamburg.common.domain.Firm;
+
+import java.util.List;
+
+/**
+ * @Author:liuxinyue
+ * @Package:com.hamburg.firm.service
+ * @Project:ZK8.6
+ * @name:FirmService
+ * @Date:2024/8/6 13:01
+ */
+public interface FirmService {
+ List findFirmList();
+
+}
diff --git a/hamburg-modules/hamburg-firm/src/main/java/com/hamburg/firm/service/impl/FirmServiceImpl.java b/hamburg-modules/hamburg-firm/src/main/java/com/hamburg/firm/service/impl/FirmServiceImpl.java
new file mode 100644
index 0000000..406f9b7
--- /dev/null
+++ b/hamburg-modules/hamburg-firm/src/main/java/com/hamburg/firm/service/impl/FirmServiceImpl.java
@@ -0,0 +1,67 @@
+package com.hamburg.firm.service.impl;
+
+import com.hamburg.common.domain.Firm;
+import com.hamburg.firm.mapper.FirmMapper;
+import com.hamburg.firm.service.FirmService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.StringRedisTemplate;
+import org.springframework.stereotype.Service;
+
+import java.util.*;
+
+/**
+ * @Author:liuxinyue
+ * @Package:com.hamburg.firm.service.impl
+ * @Project:ZK8.6
+ * @name:FirmServiceImpl
+ * @Date:2024/8/6 13:01
+ */
+@Service
+public class FirmServiceImpl implements FirmService {
+
+ @Autowired
+ private FirmMapper firmMapper;
+
+ @Autowired
+ private StringRedisTemplate stringRedisTemplate;
+
+
+ @Override
+ public List findFirmList() {
+
+ //判断这个键存不存在
+ Boolean firmList2 = stringRedisTemplate.hasKey("firmList");
+
+ //存在
+ ArrayList firms= new ArrayList<>();
+ if(firmList2){
+
+ //将redis中的map取出来
+ Map firmList1 = stringRedisTemplate.opsForHash().entries("firmList");
+
+ firmList1.entrySet().stream().forEach(entry -> {
+ Firm firm = new Firm();
+ firm.setFirmId(Integer.valueOf(String.valueOf(entry.getKey())));
+ firm.setFirmName((String) entry.getValue());
+ firms.add(firm);
+ });
+ return firms;
+ }
+ else{
+
+ List firmList = firmMapper.findFirmList();
+
+ HashMap map = new HashMap<>();
+
+ firmList.stream().forEach(firm -> {
+ map.put(String.valueOf(firm.getFirmId()),firm.getFirmName());
+ });
+ //将map 存入redis
+ stringRedisTemplate.opsForHash().putAll("firmList",map);
+
+ return firmList;
+
+ }
+
+ }
+}
diff --git a/hamburg-modules/hamburg-firm/src/main/resources/bootstrap.yml b/hamburg-modules/hamburg-firm/src/main/resources/bootstrap.yml
new file mode 100644
index 0000000..ccc1457
--- /dev/null
+++ b/hamburg-modules/hamburg-firm/src/main/resources/bootstrap.yml
@@ -0,0 +1,43 @@
+# Tomcat
+server:
+ port: 9006
+# Spring
+spring:
+ main:
+ allow-circular-references: true
+ jackson:
+ date-format: yyyy-MM-dd HH:mm:ss
+ time-zone: GMT+8
+ application:
+ # 应用名称
+ name: hamburg-firm
+ profiles:
+ # 环境配置
+ active: dev
+ cloud:
+ nacos:
+ discovery:
+ # 服务注册地址
+ server-addr: 124.70.191.180:8848
+ namespace: High-five
+ config:
+ # 配置中心地址
+ server-addr: 124.70.191.180:8848
+ namespace: High-five
+ # 配置文件格式
+ file-extension: yml
+ # 共享配置
+ shared-configs:
+ - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
+fdfs:
+ so-timeout: 1500 # socket 连接时长
+ connect-timeout: 600 # 连接 tracker 服务器超时时长
+ # 这两个是你服务器的 IP 地址,注意 23000 端口也要打开,阿里云服务器记得配置安全组。tracker 要和 stroage 服务进行交流
+ tracker-list: 124.70.191.180:22122
+ web-server-url: 124.70.191.180:8888
+ pool:
+ jmx-enabled: false
+ # 生成缩略图
+ thumb-image:
+ height: 500
+ width: 500
diff --git a/hamburg-modules/hamburg-firm/src/main/resources/mapper/IFirmMapper.xml b/hamburg-modules/hamburg-firm/src/main/resources/mapper/IFirmMapper.xml
new file mode 100644
index 0000000..28e6f6a
--- /dev/null
+++ b/hamburg-modules/hamburg-firm/src/main/resources/mapper/IFirmMapper.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+ select * from t_firm
+
+
+
diff --git a/hamburg-modules/hamburg-invite/pom.xml b/hamburg-modules/hamburg-invite/pom.xml
new file mode 100644
index 0000000..22202ad
--- /dev/null
+++ b/hamburg-modules/hamburg-invite/pom.xml
@@ -0,0 +1,20 @@
+
+
+ 4.0.0
+
+ org.example
+ hamburg-modules
+ 1.0-SNAPSHOT
+
+
+ hamburg-invite
+
+
+ 8
+ 8
+ UTF-8
+
+
+
diff --git a/hamburg-modules/hamburg-invite/src/main/java/com/hamburg/invite/InviteApplication.java b/hamburg-modules/hamburg-invite/src/main/java/com/hamburg/invite/InviteApplication.java
new file mode 100644
index 0000000..3a20670
--- /dev/null
+++ b/hamburg-modules/hamburg-invite/src/main/java/com/hamburg/invite/InviteApplication.java
@@ -0,0 +1,25 @@
+package com.hamburg.invite;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.scheduling.annotation.EnableScheduling;
+
+/**
+ * @Author:liuxinyue
+ * @Package:com.hamburg.invite
+ * @Project:ZK8.6
+ * @name:InviteApplication
+ * @Date:2024/8/6 11:07
+ */
+@EnableScheduling
+@SpringBootApplication
+public class InviteApplication {
+
+ public static void main(String[] args) {
+
+ SpringApplication.run(InviteApplication.class, args);
+
+
+ }
+
+}
diff --git a/hamburg-modules/hamburg-invite/src/main/java/com/hamburg/invite/controller/InviteController.java b/hamburg-modules/hamburg-invite/src/main/java/com/hamburg/invite/controller/InviteController.java
new file mode 100644
index 0000000..654bc84
--- /dev/null
+++ b/hamburg-modules/hamburg-invite/src/main/java/com/hamburg/invite/controller/InviteController.java
@@ -0,0 +1,59 @@
+package com.hamburg.invite.controller;
+
+import com.hamburg.common.domain.Invite;
+import com.hamburg.common.domain.request.InviteReq;
+import com.hamburg.common.result.Result;
+import com.hamburg.invite.service.InviteService;
+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 java.util.List;
+
+/**
+ * @Author:liuxinyue
+ * @Package:com.hamburg.invite.controller
+ * @Project:ZK8.6
+ * @name:InviteController
+ * @Date:2024/8/6 11:08
+ */
+@RestController
+@RequestMapping("/invite")
+public class InviteController {
+
+ @Autowired
+ private InviteService inviteService;
+
+
+ /**
+ * 查询企业招聘列表
+ * @param inviteReq
+ * @return
+ */
+ @PostMapping("/findInviteList")
+ public Result> findInviteList(@RequestBody InviteReq inviteReq) {
+
+ List list=inviteService.findInviteList(inviteReq);
+
+ return Result.success(list);
+
+ }
+
+ /**
+ * 最近岗位列表
+ * @return
+ */
+ @PostMapping("/recentJobListings")
+ public Result> recentJobListings(){
+
+ List list=inviteService.recentJobListings();
+
+ return Result.success(list);
+
+ }
+
+
+
+}
diff --git a/hamburg-modules/hamburg-invite/src/main/java/com/hamburg/invite/mapper/InviteMapper.java b/hamburg-modules/hamburg-invite/src/main/java/com/hamburg/invite/mapper/InviteMapper.java
new file mode 100644
index 0000000..c0443c2
--- /dev/null
+++ b/hamburg-modules/hamburg-invite/src/main/java/com/hamburg/invite/mapper/InviteMapper.java
@@ -0,0 +1,28 @@
+package com.hamburg.invite.mapper;
+
+import com.hamburg.common.domain.Invite;
+import com.hamburg.common.domain.request.InviteReq;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * @Author:liuxinyue
+ * @Package:com.hamburg.invite.mapper
+ * @Project:ZK8.6
+ * @name:InviteMapper
+ * @Date:2024/8/6 11:09
+ */
+@Mapper
+public interface InviteMapper {
+
+ List findInviteList(InviteReq inviteReq);
+
+ List recentJobListings();
+
+ List queryExpiredList();
+
+ void updInviteStatus(@Param("inviteId") Integer inviteId);
+
+}
diff --git a/hamburg-modules/hamburg-invite/src/main/java/com/hamburg/invite/service/InviteService.java b/hamburg-modules/hamburg-invite/src/main/java/com/hamburg/invite/service/InviteService.java
new file mode 100644
index 0000000..a814f35
--- /dev/null
+++ b/hamburg-modules/hamburg-invite/src/main/java/com/hamburg/invite/service/InviteService.java
@@ -0,0 +1,23 @@
+package com.hamburg.invite.service;
+
+import com.hamburg.common.domain.Invite;
+import com.hamburg.common.domain.request.InviteReq;
+
+import java.util.List;
+
+/**
+ * @Author:liuxinyue
+ * @Package:com.hamburg.invite.service
+ * @Project:ZK8.6
+ * @name:InviteService
+ * @Date:2024/8/6 11:09
+ */
+public interface InviteService {
+
+ List findInviteList(InviteReq inviteReq);
+
+ List recentJobListings();
+
+
+
+}
diff --git a/hamburg-modules/hamburg-invite/src/main/java/com/hamburg/invite/service/impl/InviteServiceImpl.java b/hamburg-modules/hamburg-invite/src/main/java/com/hamburg/invite/service/impl/InviteServiceImpl.java
new file mode 100644
index 0000000..2c685f6
--- /dev/null
+++ b/hamburg-modules/hamburg-invite/src/main/java/com/hamburg/invite/service/impl/InviteServiceImpl.java
@@ -0,0 +1,38 @@
+package com.hamburg.invite.service.impl;
+
+import com.hamburg.common.domain.Invite;
+import com.hamburg.common.domain.request.InviteReq;
+import com.hamburg.invite.mapper.InviteMapper;
+import com.hamburg.invite.service.InviteService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @Author:liuxinyue
+ * @Package:com.hamburg.invite.service.impl
+ * @Project:ZK8.6
+ * @name:InviteServiceImpl
+ * @Date:2024/8/6 11:09
+ */
+@Service
+public class InviteServiceImpl implements InviteService {
+
+ @Autowired
+ private InviteMapper inviteMapper;
+
+
+ @Override
+ public List findInviteList(InviteReq inviteReq) {
+ return inviteMapper.findInviteList(inviteReq);
+ }
+
+ @Override
+ public List recentJobListings() {
+ return inviteMapper.recentJobListings();
+ }
+
+
+}
diff --git a/hamburg-modules/hamburg-invite/src/main/java/com/hamburg/invite/task/scheduledTask.java b/hamburg-modules/hamburg-invite/src/main/java/com/hamburg/invite/task/scheduledTask.java
new file mode 100644
index 0000000..2349263
--- /dev/null
+++ b/hamburg-modules/hamburg-invite/src/main/java/com/hamburg/invite/task/scheduledTask.java
@@ -0,0 +1,45 @@
+package com.hamburg.invite.task;
+
+import com.hamburg.common.domain.Invite;
+import com.hamburg.invite.mapper.InviteMapper;
+import com.hamburg.invite.service.InviteService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+/**
+ * @Author:liuxinyue
+ * @Package:com.hamburg.invite.task
+ * @Project:ZK8.6
+ * @name:scheduledTask
+ * @Date:2024/8/6 12:39
+ */
+@Component
+public class scheduledTask {
+
+ @Autowired
+ private InviteMapper inviteMapper;
+
+
+ //秒 分 时 日 月 年
+ @Scheduled(cron = "* */1 * * * ?")
+ public void scheduledTask() {
+
+ //获取所有未过期 并且 超过当前日期10天的数据
+ List list=inviteMapper.queryExpiredList();
+
+ for (Invite invite : list) {
+
+ //将状态修改为已过期
+ inviteMapper.updInviteStatus(invite.getInviteId());
+
+ }
+
+
+ }
+
+
+
+}
diff --git a/hamburg-modules/hamburg-invite/src/main/resources/bootstrap.yml b/hamburg-modules/hamburg-invite/src/main/resources/bootstrap.yml
new file mode 100644
index 0000000..aa241af
--- /dev/null
+++ b/hamburg-modules/hamburg-invite/src/main/resources/bootstrap.yml
@@ -0,0 +1,43 @@
+# Tomcat
+server:
+ port: 9005
+# Spring
+spring:
+ main:
+ allow-circular-references: true
+ jackson:
+ date-format: yyyy-MM-dd HH:mm:ss
+ time-zone: GMT+8
+ application:
+ # 应用名称
+ name: hamburg-invite
+ profiles:
+ # 环境配置
+ active: dev
+ cloud:
+ nacos:
+ discovery:
+ # 服务注册地址
+ server-addr: 124.70.191.180:8848
+ namespace: High-five
+ config:
+ # 配置中心地址
+ server-addr: 124.70.191.180:8848
+ namespace: High-five
+ # 配置文件格式
+ file-extension: yml
+ # 共享配置
+ shared-configs:
+ - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
+fdfs:
+ so-timeout: 1500 # socket 连接时长
+ connect-timeout: 600 # 连接 tracker 服务器超时时长
+ # 这两个是你服务器的 IP 地址,注意 23000 端口也要打开,阿里云服务器记得配置安全组。tracker 要和 stroage 服务进行交流
+ tracker-list: 124.70.191.180:22122
+ web-server-url: 124.70.191.180:8888
+ pool:
+ jmx-enabled: false
+ # 生成缩略图
+ thumb-image:
+ height: 500
+ width: 500
diff --git a/hamburg-modules/hamburg-invite/src/main/resources/mapper/IInviteMapper.xml b/hamburg-modules/hamburg-invite/src/main/resources/mapper/IInviteMapper.xml
new file mode 100644
index 0000000..b91bb9d
--- /dev/null
+++ b/hamburg-modules/hamburg-invite/src/main/resources/mapper/IInviteMapper.xml
@@ -0,0 +1,58 @@
+
+
+
+
+ update t_invite set invite_status=1 where invite_id=#{inviteId}
+
+
+
+ SELECT
+ t_invite.*,
+ t_firm.firm_name
+ FROM
+ t_invite
+ LEFT JOIN t_firm ON t_firm.firm_id = t_invite.firm_id
+
+
+ t_invite.invite_status=2
+
+ and t_invite.firm_id=#{fireId}
+
+
+ and t_invite.invite_name like concat('%',#{inviteName},'%')
+
+
+ and t_invite.invite_salary > #{start}
+
+
+ and t_invite.invite_salary < #{end}
+
+
+
+
+
+ SELECT
+ t_invite.*,
+ t_firm.firm_name
+ FROM
+ t_invite
+ LEFT JOIN t_firm ON t_firm.firm_id = t_invite.firm_id
+ WHERE
+ t_invite.invite_status = 2
+ ORDER BY
+ t_invite.invite_time DESC
+ LIMIT 0,3
+
+
+
+ -- 10天外的数据 并且是未过期的 修改
+ SELECT
+ *
+ FROM
+ t_invite
+ where DATE_SUB(CURDATE(),INTERVAL 10 DAY)>t_invite.invite_time and t_invite.invite_status=2
+
+
+
diff --git a/hamburg-modules/hamburg-rabbit/pom.xml b/hamburg-modules/hamburg-rabbit/pom.xml
new file mode 100644
index 0000000..3871c82
--- /dev/null
+++ b/hamburg-modules/hamburg-rabbit/pom.xml
@@ -0,0 +1,20 @@
+
+
+ 4.0.0
+
+ org.example
+ hamburg-modules
+ 1.0-SNAPSHOT
+
+
+ hamburg-rabbit
+
+
+ 8
+ 8
+ UTF-8
+
+
+
diff --git a/hamburg-modules/hamburg-rabbit/src/main/java/com/hamburg/RabbitApplication.java b/hamburg-modules/hamburg-rabbit/src/main/java/com/hamburg/RabbitApplication.java
new file mode 100644
index 0000000..eed7b55
--- /dev/null
+++ b/hamburg-modules/hamburg-rabbit/src/main/java/com/hamburg/RabbitApplication.java
@@ -0,0 +1,22 @@
+package com.hamburg;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+/**
+ * @Author:liuxinyue
+ * @Package:com.hamburg
+ * @Project:ZK8.6
+ * @name:RabbitApplication
+ * @Date:2024/8/6 13:41
+ */
+@SpringBootApplication
+public class RabbitApplication {
+ public static void main(String[] args) {
+
+ SpringApplication.run(RabbitApplication.class, args);
+
+
+ }
+
+}
diff --git a/hamburg-modules/hamburg-rabbit/src/main/java/com/hamburg/rabbit/config/DelayedQueueUtil.java b/hamburg-modules/hamburg-rabbit/src/main/java/com/hamburg/rabbit/config/DelayedQueueUtil.java
new file mode 100644
index 0000000..6e8abde
--- /dev/null
+++ b/hamburg-modules/hamburg-rabbit/src/main/java/com/hamburg/rabbit/config/DelayedQueueUtil.java
@@ -0,0 +1,82 @@
+package com.hamburg.rabbit.config;
+
+import org.springframework.amqp.core.Binding;
+import org.springframework.amqp.core.BindingBuilder;
+import org.springframework.amqp.core.CustomExchange;
+import org.springframework.amqp.core.Queue;
+import org.springframework.amqp.rabbit.core.RabbitAdmin;
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.util.HashMap;
+import java.util.Map;
+
+
+
+@Component
+public class DelayedQueueUtil {
+
+ /**
+ * 延迟队列和延迟交换机绑定规则
+ */
+ private static final String DELAYED_ROUTING_KEY = "delayed.routingkey";
+
+ /**
+ * 延迟交换机的名称
+ */
+ private static final String DELAYED_EXCHANGE = "delayed.exchange";
+
+ @Autowired
+ private RabbitTemplate rabbitTemplate;
+
+ @Resource
+ private RabbitAdmin rabbitAdmin;
+
+ /**
+ * 发送延迟队列
+ *
+ * @param queueName 延迟队列名称
+ * @param params 消息内容
+ * @param delayedTime 延迟时间 毫秒
+ */
+ public void sendDelayedQueue(String queueName, Object params, Integer delayedTime) {
+ // 先创建一个队列
+ Queue queue = new Queue(queueName);
+ rabbitAdmin.declareQueue(queue);
+
+ // 创建延迟队列交换机
+ CustomExchange customExchange = createCustomExchange();
+ rabbitAdmin.declareExchange(customExchange);
+
+ // 将队列和交换机绑定
+ Binding binding = BindingBuilder.bind(queue).to(customExchange).with(DELAYED_ROUTING_KEY).noargs();
+ rabbitAdmin.declareBinding(binding);
+
+ // 发送延迟消息
+ rabbitTemplate.convertAndSend(DELAYED_EXCHANGE, DELAYED_ROUTING_KEY, params, msg -> {
+ // 发送消息的时候 延迟时长
+ msg.getMessageProperties().setDelay(delayedTime);
+ return msg;
+ });
+ }
+
+ /**
+ * 创建延迟交换机
+ */
+ private CustomExchange createCustomExchange() {
+ Map arguments = new HashMap<>();
+
+ /**
+ * 参数说明:
+ * 1.交换机的名称
+ * 2.交换机的类型
+ * 3.是否需要持久化
+ * 4.是否自动删除
+ * 5.其它参数
+ */
+ arguments.put("x-delayed-type", "direct");
+ return new CustomExchange(DELAYED_EXCHANGE, "x-delayed-message", true, false, arguments);
+ }
+}
diff --git a/hamburg-modules/hamburg-rabbit/src/main/java/com/hamburg/rabbit/config/RabbitAdminConfig.java b/hamburg-modules/hamburg-rabbit/src/main/java/com/hamburg/rabbit/config/RabbitAdminConfig.java
new file mode 100644
index 0000000..4768b2a
--- /dev/null
+++ b/hamburg-modules/hamburg-rabbit/src/main/java/com/hamburg/rabbit/config/RabbitAdminConfig.java
@@ -0,0 +1,53 @@
+package com.hamburg.rabbit.config;
+
+import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
+import org.springframework.amqp.rabbit.connection.ConnectionFactory;
+import org.springframework.amqp.rabbit.core.RabbitAdmin;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * RabbitAdmin是RabbitMQ的一个Java客户端库,它提供了管理RabbitMQ资源的功能。它是通过与RabbitMQ服务器进行交互来执行管理操作的。
+ */
+@Configuration
+public class RabbitAdminConfig {
+
+ @Value("${spring.rabbitmq.host}")
+ private String host;
+ @Value("${spring.rabbitmq.username}")
+ private String username;
+ @Value("${spring.rabbitmq.password}")
+ private String password;
+ @Value("${spring.rabbitmq.virtualhost}")
+ private String virtualhost;
+
+ /**
+ * 构建 RabbitMQ的连接工厂
+ * @return
+ */
+ @Bean
+ public ConnectionFactory connectionFactory() {
+ CachingConnectionFactory connectionFactory = new CachingConnectionFactory();
+ connectionFactory.setAddresses(host);
+ connectionFactory.setUsername(username);
+ connectionFactory.setPassword(password);
+ connectionFactory.setVirtualHost(virtualhost);
+ // 配置发送确认回调时,次配置必须配置,否则即使在RabbitTemplate配置了ConfirmCallback也不会生效
+ connectionFactory.setPublisherConfirmType(CachingConnectionFactory.ConfirmType.CORRELATED);
+ connectionFactory.setPublisherReturns(true);
+ return connectionFactory;
+ }
+
+ /**
+ * 自己初始化 RabbitAdmin
+ * @param connectionFactory
+ * @return
+ */
+ @Bean
+ public RabbitAdmin rabbitAdmin(ConnectionFactory connectionFactory) {
+ RabbitAdmin rabbitAdmin = new RabbitAdmin(connectionFactory);
+ rabbitAdmin.setAutoStartup(true);
+ return rabbitAdmin;
+ }
+}
diff --git a/hamburg-modules/hamburg-rabbit/src/main/java/com/hamburg/rabbit/config/RabbitConverterConfig.java b/hamburg-modules/hamburg-rabbit/src/main/java/com/hamburg/rabbit/config/RabbitConverterConfig.java
new file mode 100644
index 0000000..8ce381e
--- /dev/null
+++ b/hamburg-modules/hamburg-rabbit/src/main/java/com/hamburg/rabbit/config/RabbitConverterConfig.java
@@ -0,0 +1,18 @@
+package com.hamburg.rabbit.config;
+import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
+import org.springframework.amqp.support.converter.MessageConverter;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class RabbitConverterConfig {
+
+
+ //RabbitMQ 消息的转换设置
+ @Bean
+ public MessageConverter jsonMessageConverter() {
+ //SimpleMessageConverter 默认的消息转换器 String byte[] serializer
+ return new Jackson2JsonMessageConverter();
+ }
+
+}
diff --git a/hamburg-modules/hamburg-rabbit/src/main/java/com/hamburg/rabbit/customer/NoPassCustomer.java b/hamburg-modules/hamburg-rabbit/src/main/java/com/hamburg/rabbit/customer/NoPassCustomer.java
new file mode 100644
index 0000000..d4b2986
--- /dev/null
+++ b/hamburg-modules/hamburg-rabbit/src/main/java/com/hamburg/rabbit/customer/NoPassCustomer.java
@@ -0,0 +1,63 @@
+package com.hamburg.rabbit.customer;
+
+import cn.hutool.core.util.RandomUtil;
+import com.hamburg.rabbit.utils.TelSmsUtils;
+import com.hamburg.rabbit.utils.TelSmsUtils1;
+import com.rabbitmq.client.Channel;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.amqp.core.Message;
+import org.springframework.amqp.rabbit.annotation.Queue;
+import org.springframework.amqp.rabbit.annotation.RabbitListener;
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.StringRedisTemplate;
+import org.springframework.stereotype.Component;
+
+import java.io.IOException;
+import java.util.HashMap;
+
+/**
+ * @Author:liuxinyue
+ * @Package:com.hamburg.rabbit.customer
+ * @Project:ZK8.6
+ * @name:NoPassCustomer
+ * @Date:2024/8/6 13:43
+ */
+@Log4j2
+@Component
+public class NoPassCustomer {
+ @Autowired
+ private StringRedisTemplate redisTemplate;
+ @Autowired
+ private RabbitTemplate rabbitTemplate;
+ @RabbitListener(queuesToDeclare = @Queue("no_pass_status_86"))
+ public void sendCode(String userPhone, Message message, Channel channel){
+
+ String id = message.getMessageProperties().getMessageId();
+
+ //不重复消费
+ Long key = redisTemplate.opsForSet().add("no_pass_status_86", id);
+ try{
+ if(key!=null && key==1){
+
+ HashMap map = new HashMap<>();
+ map.put(userPhone,"很遗憾,你的简历不符合岗位要求,请再接再厉!");
+ TelSmsUtils1.sendSms(userPhone,map);
+ channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
+
+ }
+
+ }catch (IOException e){
+ try{
+ redisTemplate.opsForSet().remove("no_pass_status_86",id);
+ channel.basicReject(message.getMessageProperties().getDeliveryTag(),true);
+ }catch (Exception exception){
+
+ }
+
+ }
+
+
+ }
+
+}
diff --git a/hamburg-modules/hamburg-rabbit/src/main/java/com/hamburg/rabbit/customer/PassCustomer.java b/hamburg-modules/hamburg-rabbit/src/main/java/com/hamburg/rabbit/customer/PassCustomer.java
new file mode 100644
index 0000000..036b823
--- /dev/null
+++ b/hamburg-modules/hamburg-rabbit/src/main/java/com/hamburg/rabbit/customer/PassCustomer.java
@@ -0,0 +1,81 @@
+package com.hamburg.rabbit.customer;
+
+import cn.hutool.core.util.RandomUtil;
+import com.hamburg.rabbit.utils.TelSmsUtils;
+import com.rabbitmq.client.Channel;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.amqp.core.Message;
+import org.springframework.amqp.rabbit.annotation.Queue;
+import org.springframework.amqp.rabbit.annotation.RabbitListener;
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.StringRedisTemplate;
+import org.springframework.stereotype.Component;
+
+import java.io.IOException;
+import java.util.HashMap;
+
+/**
+ * @Author:liuxinyue
+ * @Package:com.hamburg.rabbit.customer
+ * @Project:ZK8.6
+ * @name:PassCustomer
+ * @Date:2024/8/6 13:43
+ */
+@Log4j2
+@Component
+public class PassCustomer {
+
+ @Autowired
+ private StringRedisTemplate redisTemplate;
+
+ @Autowired
+ private RabbitTemplate rabbitTemplate;
+
+
+ @RabbitListener(queuesToDeclare = @Queue("pass_status_86"))
+ public void sendCode(String userPhone, Message message, Channel channel){
+
+ //获取唯一的标识
+ String id = message.getMessageProperties().getMessageId();
+
+ //避免重复消费
+ Long key = redisTemplate.opsForSet().add("pass_status_86", id);
+
+ try{
+
+ if(key!=null && key==1){
+
+
+ HashMap map = new HashMap<>();
+ map.put(userPhone,"恭喜你,你的简历已通过,请前来面试!");
+ TelSmsUtils.sendSms(userPhone,map);
+ //消息消费确认
+ channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
+
+
+ }
+
+
+ }catch (IOException e){
+
+ try{
+
+ //删除缓存
+ redisTemplate.opsForSet().remove("pass_status_86",id);
+ //回退
+ channel.basicReject(message.getMessageProperties().getDeliveryTag(),true);
+ }catch (Exception exception){
+
+
+ }
+
+
+ }
+
+
+
+ }
+
+
+}
diff --git a/hamburg-modules/hamburg-rabbit/src/main/java/com/hamburg/rabbit/utils/DLXQueue.java b/hamburg-modules/hamburg-rabbit/src/main/java/com/hamburg/rabbit/utils/DLXQueue.java
new file mode 100644
index 0000000..8d9fd7f
--- /dev/null
+++ b/hamburg-modules/hamburg-rabbit/src/main/java/com/hamburg/rabbit/utils/DLXQueue.java
@@ -0,0 +1,98 @@
+package com.hamburg.rabbit.utils;
+
+import org.springframework.amqp.core.Binding;
+import org.springframework.amqp.core.BindingBuilder;
+import org.springframework.amqp.core.DirectExchange;
+import org.springframework.amqp.core.Queue;
+import org.springframework.amqp.rabbit.core.RabbitAdmin;
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 发送TTL消息 , 消息到达指定的时间没有被消费,消息成为死信,这条死信消息 回到发送到死信交换机,死信队列跟死信交换交换机绑定
+ */
+@Component
+public class DLXQueue {
+ /**
+ * 发送死信消息 绑定规则 routingKey
+ */
+ private static final String DEAD_ROUTING_KEY = "dead.routing.key";
+
+ /**
+ * 发送ttl 消息的 绑定规则 routingKey
+ */
+ private static final String ROUTING_KEY = "routing.key";
+
+ /**
+ * 死信交换机的名称
+ */
+ private static final String DEAD_EXCHANGE = "dead.exchange";
+
+ /**
+ * ttl 交换机的名称
+ */
+ private static final String EXCHANGE = "common.exchange";
+
+ @Autowired
+ private RabbitTemplate rabbitTemplate;
+
+ @Resource
+ private RabbitAdmin rabbitAdmin;
+
+ /**
+ * 发送TTL消息,消息过期后进入死信交换机,进入死信队列
+ *
+ * @param queueName 队列名称
+ * @param deadQueueName 死信队列名称
+ * @param params 消息内容
+ * @param expiration 过期时间 毫秒
+ */
+ public void sendDLXQueue(String queueName, String deadQueueName, Object params, Integer expiration) {
+ /**
+ * ----------------------------------先创建一个ttl队列和死信队列--------------------------------------------
+ */
+ Map map = new HashMap<>();
+ // 队列设置存活时间,单位ms, 必须是整形数据。
+ map.put("x-message-ttl", expiration);
+ // 设置死信交换机
+ map.put("x-dead-letter-exchange", DEAD_EXCHANGE);
+ // 设置死信交换器路由
+ map.put("x-dead-letter-routing-key", DEAD_ROUTING_KEY);
+ /*参数1:队列名称 参数2:持久化 参数3:是否排他 参数4:自动删除队列 参数5:队列参数*/
+ Queue queue = new Queue(queueName, true, false, false, map);
+ rabbitAdmin.declareQueue(queue);
+ /**
+ * ---------------------------------创建交换机---------------------------------------------
+ */
+ DirectExchange directExchange = new DirectExchange(EXCHANGE, true, false);
+ rabbitAdmin.declareExchange(directExchange);
+ /**
+ * ---------------------------------队列绑定交换机---------------------------------------------
+ */
+ Binding binding = BindingBuilder.bind(queue).to(directExchange).with(ROUTING_KEY);
+ rabbitAdmin.declareBinding(binding);
+
+ /**
+ * ---------------------------------在创建一个死信交换机和队列,接收死信队列---------------------------------------------
+ */
+ DirectExchange deadExchange = new DirectExchange(DEAD_EXCHANGE, true, false);
+ rabbitAdmin.declareExchange(deadExchange);
+
+ Queue deadQueue = new Queue(deadQueueName, true, false, false);
+ rabbitAdmin.declareQueue(deadQueue);
+ /**
+ * ---------------------------------队列绑定死信交换机---------------------------------------------
+ */
+ // 将队列和交换机绑定
+ Binding deadbinding = BindingBuilder.bind(deadQueue).to(deadExchange).with(DEAD_ROUTING_KEY);
+ rabbitAdmin.declareBinding(deadbinding);
+
+ // 发送消息
+ rabbitTemplate.convertAndSend(EXCHANGE, ROUTING_KEY, params);
+ }
+}
diff --git a/hamburg-modules/hamburg-rabbit/src/main/java/com/hamburg/rabbit/utils/DelayedQueue.java b/hamburg-modules/hamburg-rabbit/src/main/java/com/hamburg/rabbit/utils/DelayedQueue.java
new file mode 100644
index 0000000..67f76e3
--- /dev/null
+++ b/hamburg-modules/hamburg-rabbit/src/main/java/com/hamburg/rabbit/utils/DelayedQueue.java
@@ -0,0 +1,98 @@
+package com.hamburg.rabbit.utils;
+
+import org.springframework.amqp.core.Binding;
+import org.springframework.amqp.core.BindingBuilder;
+import org.springframework.amqp.core.CustomExchange;
+import org.springframework.amqp.core.Queue;
+import org.springframework.amqp.rabbit.core.RabbitAdmin;
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 发送延迟消息
+ *
+ * @author Administrator
+ */
+@Component
+public class DelayedQueue {
+
+ /**
+ * routingKey 绑定规则
+ */
+ private static final String DELAYED_ROUTING_KEY = "delayed.routing.key";
+
+ /**
+ * 延迟队列交换机 名称
+ */
+ private static final String DELAYED_EXCHANGE = "delayed.exchange";
+
+ @Autowired
+ private RabbitTemplate rabbitTemplate;
+
+ @Autowired
+ private RabbitAdmin rabbitAdmin;
+
+ /**
+ * 发送延迟队列
+ *
+ * @param queueName 队列名称
+ * @param params 消息内容
+ * @param delayedTime 延迟时间 毫秒
+ */
+ public void sendDelayedQueue(String queueName, Object params, Integer delayedTime) {
+ // 先创建一个队列
+ Queue queue = new Queue(queueName);
+ rabbitAdmin.declareQueue(queue);
+
+ // 创建延迟队列交换机
+ CustomExchange customExchange = createCustomExchange();
+ rabbitAdmin.declareExchange(customExchange);
+
+ // 将队列和交换机绑定
+ Binding binding = BindingBuilder.bind(queue).to(customExchange).with(DELAYED_ROUTING_KEY).noargs();
+ rabbitAdmin.declareBinding(binding);
+
+ // 发送延迟消息
+ // 第四个参数: MessagePostProcessor 消息发送处理器 如果希望对发送的消息做包装 或者处理 需要用到 例如现在需要给发送的消息设置延迟时间
+ // 参数是一个接口: 那么需要给 当前接口的实现类 匿名内部类
+// MyMessagePostProcessor postProcessor = new MyMessagePostProcessor();
+// rabbitTemplate.convertAndSend(DELAYED_EXCHANGE, DELAYED_ROUTING_KEY, params, new MessagePostProcessor() {
+// @Override
+// public Message postProcessMessage(Message message) throws AmqpException {
+// // 设置消息的延迟时间
+// message.getMessageProperties().setDelay(2000);
+// return message;
+// }
+// });
+ rabbitTemplate.convertAndSend(DELAYED_EXCHANGE, DELAYED_ROUTING_KEY, params, message -> {
+ // 设置消息的延迟时间
+ message.getMessageProperties().setDelay(2000);
+ return message;
+ });
+ }
+
+ /**
+ * 构建延迟交换机
+ *
+ * @return
+ */
+ private CustomExchange createCustomExchange() {
+ Map arguments = new HashMap<>();
+ /**
+ * 参数说明:
+ * 1.交换机的名称
+ * 2.交换机的类型
+ * 3.是否需要持久化
+ * 4.是否自动删除
+ * 5.其它参数
+ */
+ arguments.put("x-delayed-type", "direct");
+ return new CustomExchange(DELAYED_EXCHANGE, "x-delayed-message", true, false, arguments);
+ }
+
+}
+
diff --git a/hamburg-modules/hamburg-rabbit/src/main/java/com/hamburg/rabbit/utils/MyMessagePostProcessor.java b/hamburg-modules/hamburg-rabbit/src/main/java/com/hamburg/rabbit/utils/MyMessagePostProcessor.java
new file mode 100644
index 0000000..4e8221e
--- /dev/null
+++ b/hamburg-modules/hamburg-rabbit/src/main/java/com/hamburg/rabbit/utils/MyMessagePostProcessor.java
@@ -0,0 +1,20 @@
+package com.hamburg.rabbit.utils;
+
+import org.springframework.amqp.AmqpException;
+import org.springframework.amqp.core.Message;
+import org.springframework.amqp.core.MessagePostProcessor;
+
+/**
+ * @ClassName:
+ * @Description:
+ * @Author: zhuwenqiang
+ * @Date: 2024/4/28
+ */
+public class MyMessagePostProcessor implements MessagePostProcessor {
+ @Override
+ public Message postProcessMessage(Message message) throws AmqpException {
+ // 设置消息的延迟时间
+ message.getMessageProperties().setDelay(2000);
+ return message;
+ }
+}
diff --git a/hamburg-modules/hamburg-rabbit/src/main/java/com/hamburg/rabbit/utils/TelSmsUtils.java b/hamburg-modules/hamburg-rabbit/src/main/java/com/hamburg/rabbit/utils/TelSmsUtils.java
new file mode 100644
index 0000000..53b771f
--- /dev/null
+++ b/hamburg-modules/hamburg-rabbit/src/main/java/com/hamburg/rabbit/utils/TelSmsUtils.java
@@ -0,0 +1,96 @@
+package com.hamburg.rabbit.utils;
+
+import com.alibaba.fastjson.JSONObject;
+import com.aliyun.dysmsapi20170525.Client;
+import com.aliyun.dysmsapi20170525.models.SendSmsRequest;
+import com.aliyun.dysmsapi20170525.models.SendSmsResponse;
+import com.aliyun.dysmsapi20170525.models.SendSmsResponseBody;
+import com.aliyun.teaopenapi.models.Config;
+import lombok.extern.log4j.Log4j2;
+
+import java.util.Map;
+
+/**
+ * 短信工具类
+ */
+@Log4j2
+public class TelSmsUtils {
+
+ /**
+ * 阿里云主账号AccessKey,accessKeySecret拥有所有API的访问权限
+ */
+ private static String accessKeyId = "LTAI5tDbRqXkC5i3SMrCSDcX";
+
+ private static String accessKeySecret = "XUzMZoHPLsjNLafHsdQnMElBWZATsu";
+
+ /**
+ * 短信访问域名
+ */
+ private static String endpoint = "dysmsapi.aliyuncs.com";
+
+ /**
+ * 短信签名
+ */
+ private static String signName = "乐优购";
+
+ /**
+ * 模板编号
+ */
+ private static String templateCode = "SMS_163851467";
+
+ /**
+ * 实例化短信对象
+ */
+ private static Client client;
+
+ static {
+ log.info("初始化短信服务开始");
+ long startTime = System.currentTimeMillis();
+ try {
+ client = initClient();
+ log.info("初始化短信成功:{}", signName);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ log.info("初始化短信服务结束:耗时:{}MS", (System.currentTimeMillis() - startTime));
+ }
+
+ /**
+ * 初始化短信对象
+ *
+ * @return
+ * @throws Exception
+ */
+ private static Client initClient() throws Exception {
+ Config config = new Config()
+ // 您的AccessKey ID
+ .setAccessKeyId(accessKeyId)
+ // 您的AccessKey Secret
+ .setAccessKeySecret(accessKeySecret);
+ // 访问的域名
+ config.endpoint = endpoint;
+ return new Client(config);
+ }
+
+ /**
+ * 发送单条短信
+ *
+ * @param tel
+ */
+ public static SendSmsResponseBody sendSms(String tel, Map sendDataMap) {
+ SendSmsRequest sendSmsRequest = new SendSmsRequest()
+ .setPhoneNumbers(tel)
+ .setSignName(signName)
+ .setTemplateCode(templateCode)
+ .setTemplateParam(JSONObject.toJSONString(sendDataMap));
+ SendSmsResponse sendSmsResponse = null;
+ try {
+ log.info("审核通知:消息内容是:【{}】", JSONObject.toJSONString(sendDataMap));
+ sendSmsResponse = client.sendSms(sendSmsRequest);
+ } catch (Exception e) {
+ log.error("短信发送异常,手机号:【{}】,短信内容:【{}】,异常信息:【{}】", tel, sendDataMap, e);
+ }
+ return sendSmsResponse.getBody();
+ }
+
+}
diff --git a/hamburg-modules/hamburg-rabbit/src/main/java/com/hamburg/rabbit/utils/TelSmsUtils1.java b/hamburg-modules/hamburg-rabbit/src/main/java/com/hamburg/rabbit/utils/TelSmsUtils1.java
new file mode 100644
index 0000000..5875f38
--- /dev/null
+++ b/hamburg-modules/hamburg-rabbit/src/main/java/com/hamburg/rabbit/utils/TelSmsUtils1.java
@@ -0,0 +1,96 @@
+package com.hamburg.rabbit.utils;
+
+import com.alibaba.fastjson.JSONObject;
+import com.aliyun.dysmsapi20170525.Client;
+import com.aliyun.dysmsapi20170525.models.SendSmsRequest;
+import com.aliyun.dysmsapi20170525.models.SendSmsResponse;
+import com.aliyun.dysmsapi20170525.models.SendSmsResponseBody;
+import com.aliyun.teaopenapi.models.Config;
+import lombok.extern.log4j.Log4j2;
+
+import java.util.Map;
+
+/**
+ * 短信工具类
+ */
+@Log4j2
+public class TelSmsUtils1{
+
+ /**
+ * 阿里云主账号AccessKey,accessKeySecret拥有所有API的访问权限
+ */
+ private static String accessKeyId = "LTAI5tDbRqXkC5i3SMrCSDcX";
+
+ private static String accessKeySecret = "XUzMZoHPLsjNLafHsdQnMElBWZATsu";
+
+ /**
+ * 短信访问域名
+ */
+ private static String endpoint = "dysmsapi.aliyuncs.com";
+
+ /**
+ * 短信签名
+ */
+ private static String signName = "乐优购";
+
+ /**
+ * 模板编号
+ */
+ private static String templateCode = "SMS_163851467";
+
+ /**
+ * 实例化短信对象
+ */
+ private static Client client;
+
+ static {
+ log.info("初始化短信服务开始");
+ long startTime = System.currentTimeMillis();
+ try {
+ client = initClient();
+ log.info("初始化短信成功:{}", signName);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ log.info("初始化短信服务结束:耗时:{}MS", (System.currentTimeMillis() - startTime));
+ }
+
+ /**
+ * 初始化短信对象
+ *
+ * @return
+ * @throws Exception
+ */
+ private static Client initClient() throws Exception {
+ Config config = new Config()
+ // 您的AccessKey ID
+ .setAccessKeyId(accessKeyId)
+ // 您的AccessKey Secret
+ .setAccessKeySecret(accessKeySecret);
+ // 访问的域名
+ config.endpoint = endpoint;
+ return new Client(config);
+ }
+
+ /**
+ * 发送单条短信
+ *
+ * @param tel
+ */
+ public static SendSmsResponseBody sendSms(String tel, Map sendDataMap) {
+ SendSmsRequest sendSmsRequest = new SendSmsRequest()
+ .setPhoneNumbers(tel)
+ .setSignName(signName)
+ .setTemplateCode(templateCode)
+ .setTemplateParam(JSONObject.toJSONString(sendDataMap));
+ SendSmsResponse sendSmsResponse = null;
+ try {
+ log.info("审核通知:消息内容是:【{}】", JSONObject.toJSONString(sendDataMap));
+ sendSmsResponse = client.sendSms(sendSmsRequest);
+ } catch (Exception e) {
+ log.error("短信发送异常,手机号:【{}】,短信内容:【{}】,异常信息:【{}】", tel, sendDataMap, e);
+ }
+ return sendSmsResponse.getBody();
+ }
+
+}
diff --git a/hamburg-modules/hamburg-rabbit/src/main/java/com/hamburg/rabbit/utils/TtlQueue.java b/hamburg-modules/hamburg-rabbit/src/main/java/com/hamburg/rabbit/utils/TtlQueue.java
new file mode 100644
index 0000000..8f32fbc
--- /dev/null
+++ b/hamburg-modules/hamburg-rabbit/src/main/java/com/hamburg/rabbit/utils/TtlQueue.java
@@ -0,0 +1,67 @@
+package com.hamburg.rabbit.utils;
+
+import org.springframework.amqp.core.Binding;
+import org.springframework.amqp.core.BindingBuilder;
+import org.springframework.amqp.core.DirectExchange;
+import org.springframework.amqp.core.Queue;
+import org.springframework.amqp.rabbit.core.RabbitAdmin;
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 发送TTL消息 设置消息的过期时间
+ */
+@Component
+public class TtlQueue {
+
+ // routingKey
+ private static final String TTL_KEY = "ttl.routing.key";
+
+ private static final String TTL_EXCHANGE = "ttl.exchange";
+
+ @Autowired
+ private RabbitTemplate rabbitTemplate;
+
+ @Resource
+ RabbitAdmin rabbitAdmin;
+
+ /**
+ * 发送TTL队列
+ *
+ * @param queueName 队列名称
+ * @param params 消息内容
+ * @param expiration 过期时间 毫秒
+ */
+ public void sendTTLQueue(String queueName, Object params, Integer expiration) {
+ /**
+ * ----------------------------------先创建一个ttl队列--------------------------------------------
+ */
+ Map map = new HashMap<>();
+ // 队列设置存活时间,单位ms,必须是整形数据。
+ map.put("x-message-ttl", expiration);
+ /*参数1:队列名称 参数2:持久化 参数 3:是否排他 参数 4:自动删除队列 参数 5:队列参数*/
+ Queue queue = new Queue(queueName, true, false, false, map);
+ rabbitAdmin.declareQueue(queue);
+
+ /**
+ * ---------------------------------创建交换机---------------------------------------------
+ */
+ DirectExchange directExchange = new DirectExchange(TTL_EXCHANGE, true, false);
+ rabbitAdmin.declareExchange(directExchange);
+ /**
+ * ---------------------------------队列绑定交换机---------------------------------------------
+ */
+ // 将队列和交换机绑定
+ Binding binding = BindingBuilder.bind(queue).to(directExchange).with(TTL_KEY);
+ rabbitAdmin.declareBinding(binding);
+
+ // 发送消息
+ rabbitTemplate.convertAndSend(TTL_EXCHANGE, TTL_KEY, params);
+ }
+}
+
diff --git a/hamburg-modules/hamburg-rabbit/src/main/resources/bootstrap.yml b/hamburg-modules/hamburg-rabbit/src/main/resources/bootstrap.yml
new file mode 100644
index 0000000..dee6c75
--- /dev/null
+++ b/hamburg-modules/hamburg-rabbit/src/main/resources/bootstrap.yml
@@ -0,0 +1,47 @@
+# Tomcat
+server:
+ port: 9090
+# Spring
+spring:
+ rabbitmq:
+ host: 124.70.191.180
+ port: 5672
+ username: guest
+ password: guest
+ virtual-host: /
+ listener:
+ simple:
+ prefetch: 1 # 每次取出一条消息消费消费完毕进行下一条
+ retry:
+ enabled: true
+ max-attempts: 3 # 重试次数
+ max-interval: 2000 # 重试间隔
+ acknowledge-mode: manual # 手动确认消息
+ publisher-confirm-type: correlated #确认消息已发送到交换机(Exchange)
+ publisher-returns: true #确认消息已发送到队列(Queue)
+ main:
+ allow-circular-references: true
+ jackson:
+ date-format: yyyy-MM-dd HH:mm:ss
+ time-zone: GMT+8
+ application:
+ # 应用名称
+ name: hamburg-mq
+ profiles:
+ # 环境配置
+ active: dev
+ cloud:
+ nacos:
+ discovery:
+ # 服务注册地址
+ server-addr: 124.70.191.180:8848
+ namespace: High-five
+ config:
+ # 配置中心地址
+ server-addr: 124.70.191.180:8848
+ namespace: High-five
+ # 配置文件格式
+ file-extension: yml
+ # 共享配置
+ shared-configs:
+ - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
diff --git a/hamburg-modules/hamburg-user/pom.xml b/hamburg-modules/hamburg-user/pom.xml
new file mode 100644
index 0000000..b9820ce
--- /dev/null
+++ b/hamburg-modules/hamburg-user/pom.xml
@@ -0,0 +1,20 @@
+
+
+ 4.0.0
+
+ org.example
+ hamburg-modules
+ 1.0-SNAPSHOT
+
+
+ hamburg-user
+
+
+ 8
+ 8
+ UTF-8
+
+
+
diff --git a/hamburg-modules/hamburg-user/src/main/java/com/hamburg/user/UserApplication.java b/hamburg-modules/hamburg-user/src/main/java/com/hamburg/user/UserApplication.java
new file mode 100644
index 0000000..07c9612
--- /dev/null
+++ b/hamburg-modules/hamburg-user/src/main/java/com/hamburg/user/UserApplication.java
@@ -0,0 +1,25 @@
+package com.hamburg.user;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+
+/**
+ * @Author:liuxinyue
+ * @Package:com.hamburg.user
+ * @Project:ZK8.6
+ * @name:UserApplication
+ * @Date:2024/8/6 9:51
+ */
+@SpringBootApplication
+@EnableFeignClients
+public class UserApplication {
+
+ public static void main(String[] args) {
+
+ SpringApplication.run(UserApplication.class, args);
+
+
+ }
+
+}
diff --git a/hamburg-modules/hamburg-user/src/main/java/com/hamburg/user/controller/UserController.java b/hamburg-modules/hamburg-user/src/main/java/com/hamburg/user/controller/UserController.java
new file mode 100644
index 0000000..626f84d
--- /dev/null
+++ b/hamburg-modules/hamburg-user/src/main/java/com/hamburg/user/controller/UserController.java
@@ -0,0 +1,41 @@
+package com.hamburg.user.controller;
+
+import com.hamburg.common.domain.User;
+import com.hamburg.common.domain.request.UserReq;
+import com.hamburg.common.result.Result;
+import com.hamburg.user.service.UserService;
+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;
+
+/**
+ * @Author:liuxinyue
+ * @Package:com.hamburg.user.controller
+ * @Project:ZK8.6
+ * @name:UserController
+ * @Date:2024/8/6 10:33
+ */
+@RestController
+@RequestMapping("/user")
+public class UserController {
+
+ @Autowired
+ private UserService userService;
+
+ /**
+ * 查询手机号发送验证码
+ * @param userReq
+ * @return
+ */
+ @PostMapping("/findUser")
+ public Result findUser(@RequestBody UserReq userReq) {
+
+ return Result.success(userService.findUser(userReq));
+ }
+
+
+
+
+}
diff --git a/hamburg-modules/hamburg-user/src/main/java/com/hamburg/user/mapper/UserMapper.java b/hamburg-modules/hamburg-user/src/main/java/com/hamburg/user/mapper/UserMapper.java
new file mode 100644
index 0000000..09449c5
--- /dev/null
+++ b/hamburg-modules/hamburg-user/src/main/java/com/hamburg/user/mapper/UserMapper.java
@@ -0,0 +1,22 @@
+package com.hamburg.user.mapper;
+
+import com.hamburg.common.domain.User;
+import com.hamburg.common.domain.request.UserReq;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * @Author:liuxinyue
+ * @Package:com.hamburg.user.mapper
+ * @Project:ZK8.6
+ * @name:UserMapper
+ * @Date:2024/8/6 10:33
+ */
+@Mapper
+public interface UserMapper {
+
+
+ User findUser(UserReq userReq);
+
+
+
+}
diff --git a/hamburg-modules/hamburg-user/src/main/java/com/hamburg/user/service/UserService.java b/hamburg-modules/hamburg-user/src/main/java/com/hamburg/user/service/UserService.java
new file mode 100644
index 0000000..84a0e8e
--- /dev/null
+++ b/hamburg-modules/hamburg-user/src/main/java/com/hamburg/user/service/UserService.java
@@ -0,0 +1,23 @@
+package com.hamburg.user.service;
+
+import com.hamburg.common.domain.User;
+import com.hamburg.common.domain.request.UserReq;
+import com.hamburg.user.mapper.UserMapper;
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * @Author:liuxinyue
+ * @Package:com.hamburg.user.service
+ * @Project:ZK8.6
+ * @name:UserService
+ * @Date:2024/8/6 10:35
+ */
+
+public interface UserService {
+
+
+ User findUser(UserReq userReq);
+
+
+
+}
diff --git a/hamburg-modules/hamburg-user/src/main/java/com/hamburg/user/service/impl/UserServiceImpl.java b/hamburg-modules/hamburg-user/src/main/java/com/hamburg/user/service/impl/UserServiceImpl.java
new file mode 100644
index 0000000..8ea4c23
--- /dev/null
+++ b/hamburg-modules/hamburg-user/src/main/java/com/hamburg/user/service/impl/UserServiceImpl.java
@@ -0,0 +1,31 @@
+package com.hamburg.user.service.impl;
+
+import com.hamburg.common.domain.User;
+import com.hamburg.common.domain.request.UserReq;
+import com.hamburg.user.mapper.UserMapper;
+import com.hamburg.user.service.UserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * @Author:liuxinyue
+ * @Package:com.hamburg.user.service.impl
+ * @Project:ZK8.6
+ * @name:UserServiceImpl
+ * @Date:2024/8/6 10:35
+ */
+@Service
+public class UserServiceImpl implements UserService {
+
+
+ @Autowired
+ private UserMapper userMapper;
+
+ @Override
+ public User findUser(UserReq userReq) {
+ return userMapper.findUser(userReq);
+
+ }
+
+
+}
diff --git a/hamburg-modules/hamburg-user/src/main/resources/bootstrap.yml b/hamburg-modules/hamburg-user/src/main/resources/bootstrap.yml
new file mode 100644
index 0000000..51b69e7
--- /dev/null
+++ b/hamburg-modules/hamburg-user/src/main/resources/bootstrap.yml
@@ -0,0 +1,43 @@
+# Tomcat
+server:
+ port: 9004
+# Spring
+spring:
+ main:
+ allow-circular-references: true
+ jackson:
+ date-format: yyyy-MM-dd HH:mm:ss
+ time-zone: GMT+8
+ application:
+ # 应用名称
+ name: hamburg-user
+ profiles:
+ # 环境配置
+ active: dev
+ cloud:
+ nacos:
+ discovery:
+ # 服务注册地址
+ server-addr: 124.70.191.180:8848
+ namespace: High-five
+ config:
+ # 配置中心地址
+ server-addr: 124.70.191.180:8848
+ namespace: High-five
+ # 配置文件格式
+ file-extension: yml
+ # 共享配置
+ shared-configs:
+ - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
+fdfs:
+ so-timeout: 1500 # socket 连接时长
+ connect-timeout: 600 # 连接 tracker 服务器超时时长
+ # 这两个是你服务器的 IP 地址,注意 23000 端口也要打开,阿里云服务器记得配置安全组。tracker 要和 stroage 服务进行交流
+ tracker-list: 124.70.191.180:22122
+ web-server-url: 124.70.191.180:8888
+ pool:
+ jmx-enabled: false
+ # 生成缩略图
+ thumb-image:
+ height: 500
+ width: 500
diff --git a/hamburg-modules/hamburg-user/src/main/resources/mapper/IUserMapper.xml b/hamburg-modules/hamburg-user/src/main/resources/mapper/IUserMapper.xml
new file mode 100644
index 0000000..654e2df
--- /dev/null
+++ b/hamburg-modules/hamburg-user/src/main/resources/mapper/IUserMapper.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+ select * from t_user where user_phone=#{userPhone}
+
+
+
+
diff --git a/hamburg-modules/pom.xml b/hamburg-modules/pom.xml
new file mode 100644
index 0000000..95007ef
--- /dev/null
+++ b/hamburg-modules/pom.xml
@@ -0,0 +1,83 @@
+
+
+ 4.0.0
+
+ org.example
+ ZK8.6
+ 1.0-SNAPSHOT
+
+
+ hamburg-modules
+ pom
+
+ hamburg-user
+ hamburg-invite
+ hamburg-candidate
+ hamburg-firm
+ hamburg-rabbit
+
+
+
+ 8
+ 8
+ UTF-8
+
+
+
+
+
+ com.baomidou
+ lock4j-redis-template-spring-boot-starter
+ 2.2.7
+
+
+
+ org.example
+ hamburg-common
+ 1.0-SNAPSHOT
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ com.alibaba
+ druid-spring-boot-starter
+ 1.2.8
+
+
+
+ mysql
+ mysql-connector-java
+
+
+
+ org.mybatis.spring.boot
+ mybatis-spring-boot-starter
+ 2.2.2
+
+
+
+ com.github.pagehelper
+ pagehelper-spring-boot-starter
+ 1.4.1
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ com.github.tobato
+ fastdfs-client
+ 1.26.5
+
+
+
+
+
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..4870cde
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,67 @@
+
+
+ 4.0.0
+
+ org.example
+ ZK8.6
+ 1.0-SNAPSHOT
+ pom
+
+ hamburg-auth
+ hamburg-common
+ hamburg-gateway
+ hamburg-modules
+
+
+
+ 8
+ 8
+ UTF-8
+
+
+
+
+
+ spring-boot-starter-parent
+ org.springframework.boot
+ 2.6.2
+
+
+
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-dependencies
+ 2021.0.0
+ pom
+ import
+
+
+
+ com.alibaba.cloud
+ spring-cloud-alibaba-dependencies
+ 2021.1
+ pom
+ import
+
+
+
+ com.alibaba.nacos
+ nacos-client
+ 2.0.4
+
+
+
+
+ org.example
+ hamburg-common
+ 1.0-SNAPSHOT
+
+
+
+
+