strs) {
+ if (isEmpty(str) || isEmpty(strs)) {
+ return false;
+ }
+ for (String pattern : strs) {
+ if (isMatch(pattern, str))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * 判断url是否与规则配置:
+ * ? 表示单个字符;
+ * * 表示一层路径内的任意字符串,不可跨层级;
+ * ** 表示任意层路径;
+ *
+ * @param pattern 匹配规则
+ * @param url 需要匹配的url
+ * @return
+ */
+ public static boolean isMatch(String pattern, String url) {
+ AntPathMatcher matcher = new AntPathMatcher();
+ return matcher.match(pattern, url);
+ }
+}
diff --git a/cloud-common/src/main/java/com/muyu/common/utils/TelSmsUtils.java b/cloud-common/src/main/java/com/muyu/common/utils/TelSmsUtils.java
new file mode 100644
index 0000000..4528a09
--- /dev/null
+++ b/cloud-common/src/main/java/com/muyu/common/utils/TelSmsUtils.java
@@ -0,0 +1,125 @@
+package com.muyu.common.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.HashMap;
+import java.util.Map;
+import java.util.Random;
+
+/**
+ * 短信工具类
+ */
+@Log4j2
+public class TelSmsUtils {
+
+ /**
+ * 阿里云主账号AccessKey,accessKeySecret拥有所有API的访问权限
+ *
+ * LTAI5tN9vdDeBioiVbGG3UG3
+ * gzhfYLb0UX0zH35DOki9yi1Q35ndgS
+ */
+ private static final String accessKeyId = "LTAI5tN9vdDeBioiVbGG3UG3";
+
+ private static final String accessKeySecret = "gzhfYLb0UX0zH35DOki9yi1Q35ndgS";
+
+ /**
+ * 短信访问域名
+ */
+ private static final String endpoint = "dysmsapi.aliyuncs.com";
+
+ /**
+ * 短信签名
+ */
+ private static final String signName = "登录验证";
+
+ /**
+ * 模板编号
+ */
+ private static final String templateCode = "SMS_467560395";
+
+ /**
+ * 实例化短信对象
+ */
+ 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 手机号
+ * @param sendDataMap 验证码对象
+ */
+ 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();
+ }
+
+ /**
+ * 发送手机验证码
+ * @param tel 手机号
+ * @param code 验证码
+ */
+ public static SendSmsResponseBody sendSms(String tel, String code) {
+
+ Map map = new HashMap<>();
+
+ map.put("code",code);
+
+ return sendSms(tel, map);
+ }
+
+
+
+ public static void main(String[] args) {
+
+ HashMap map = new HashMap<>();
+ int code = new Random().nextInt(900000) + 100000;
+ map.put("code", String.valueOf(code));
+ sendSms("15335893491", map);
+ }
+
+}
diff --git a/cloud-common/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/cloud-common/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
new file mode 100644
index 0000000..f79b8c9
--- /dev/null
+++ b/cloud-common/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
@@ -0,0 +1,7 @@
+com.muyu.common.redis.configure.RedisConfig
+com.muyu.common.redis.service.RedisService
+com.muyu.common.config.ExceptionHandler
+com.muyu.common.redis.configure.RedissonConfig
+com.muyu.common.config.MyConfirmCallback
+com.muyu.common.config.RabbitmqConfig
+com.muyu.common.config.ReturnCallbackConfig
diff --git a/cloud-gateway/pom.xml b/cloud-gateway/pom.xml
new file mode 100644
index 0000000..f29f44d
--- /dev/null
+++ b/cloud-gateway/pom.xml
@@ -0,0 +1,59 @@
+
+
+ 4.0.0
+
+ com.muyu
+ zg6-week2
+ 1.0.0
+
+
+ cloud-gateway
+
+
+ 8
+ 8
+ UTF-8
+
+
+
+
+
+ com.muyu
+ cloud-common
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-gateway
+
+
+
+ com.alibaba.cloud
+ spring-cloud-alibaba-sentinel-gateway
+
+
+
+ com.alibaba.csp
+ sentinel-spring-cloud-gateway-adapter
+
+
+
+
+ ${project.artifactId}
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+ repackage
+
+
+
+
+
+
+
diff --git a/cloud-gateway/src/main/java/com/muyu/CloudGatewayApplication.java b/cloud-gateway/src/main/java/com/muyu/CloudGatewayApplication.java
new file mode 100644
index 0000000..817350b
--- /dev/null
+++ b/cloud-gateway/src/main/java/com/muyu/CloudGatewayApplication.java
@@ -0,0 +1,22 @@
+package com.muyu;
+
+import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
+import org.springframework.scheduling.annotation.EnableScheduling;
+
+/**
+ * @Author: xiexyinyue
+ * @date: 2024/5/23
+ * @Description: 云网关启动类
+ * @Version: 1.0
+ */
+@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class, DruidDataSourceAutoConfigure.class})
+@EnableScheduling
+public class CloudGatewayApplication {
+
+ public static void main (String[] args) {
+ SpringApplication.run(CloudGatewayApplication.class, args);
+ }
+}
diff --git a/cloud-gateway/src/main/java/com/muyu/config/GatewaySentinelConfig.java b/cloud-gateway/src/main/java/com/muyu/config/GatewaySentinelConfig.java
new file mode 100644
index 0000000..da3d9ac
--- /dev/null
+++ b/cloud-gateway/src/main/java/com/muyu/config/GatewaySentinelConfig.java
@@ -0,0 +1,71 @@
+package com.muyu.config;
+
+import com.alibaba.csp.sentinel.adapter.gateway.common.rule.GatewayFlowRule;
+import com.alibaba.csp.sentinel.adapter.gateway.common.rule.GatewayRuleManager;
+import com.alibaba.csp.sentinel.adapter.gateway.sc.exception.SentinelGatewayBlockExceptionHandler;
+import org.springframework.beans.factory.ObjectProvider;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.Ordered;
+import org.springframework.core.annotation.Order;
+import org.springframework.http.codec.ServerCodecConfigurer;
+import org.springframework.web.reactive.result.view.ViewResolver;
+
+import javax.annotation.PostConstruct;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @deprecation: 网关限流控件
+ * @author xiexyinyue
+ */
+@Configuration
+public class GatewaySentinelConfig {
+ /**
+ * 查看解析器
+ */
+ private final List viewResolvers;
+ /**
+ * 服务器编解码器配置
+ */
+ private final ServerCodecConfigurer serverCodecConfigurer;
+ public GatewaySentinelConfig(ObjectProvider> viewResolversProvider,
+ ServerCodecConfigurer serverCodecConfigurer) {
+ this.viewResolvers = viewResolversProvider.getIfAvailable(Collections::emptyList);
+ this.serverCodecConfigurer = serverCodecConfigurer;
+ }
+ /**
+ * Sentinel 网关块异常处理程序
+ * @return
+ */
+ @Bean
+ @Order(Ordered.HIGHEST_PRECEDENCE)
+ public SentinelGatewayBlockExceptionHandler sentinelGatewayBlockExceptionHandler() {
+ // 给 Spring Cloud Gateway 注册块异常处理程序。
+ return new SentinelGatewayBlockExceptionHandler(viewResolvers, serverCodecConfigurer);
+ }
+
+ /**
+ * 初始化网关配置
+ */
+ @PostConstruct
+ public void doInit() {
+ initGatewayRules();
+ }
+ /**
+ * 配置限流规则
+ */
+ private void initGatewayRules() {
+ Set rules = new HashSet<>();
+ rules.add(new GatewayFlowRule("cloud-user")
+ // 限流阈值
+ .setCount(1)
+ // 统计时间窗口,单位是秒,默认是 1 秒
+ .setIntervalSec(5)
+ );
+ //添加到限流规则当中
+ GatewayRuleManager.loadRules(rules);
+ }
+}
diff --git a/cloud-gateway/src/main/java/com/muyu/config/IgnoreWhiteConfig.java b/cloud-gateway/src/main/java/com/muyu/config/IgnoreWhiteConfig.java
new file mode 100644
index 0000000..5a9c08d
--- /dev/null
+++ b/cloud-gateway/src/main/java/com/muyu/config/IgnoreWhiteConfig.java
@@ -0,0 +1,31 @@
+package com.muyu.config;
+
+import com.alibaba.fastjson.JSONObject;
+import lombok.Data;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.cloud.context.config.annotation.RefreshScope;
+import org.springframework.context.annotation.Configuration;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @description: 放行白名单配置
+ * @author xiexyinyue
+ */
+@Configuration
+@RefreshScope
+@ConfigurationProperties(prefix = "ignore")
+@Data
+@Log4j2
+public class IgnoreWhiteConfig {
+ /**
+ * 放行白名单配置,网关不校验此处的白名单
+ */
+ private List whites = new ArrayList<>();
+ public void setWhites(List whites) {
+ log.info("加载网关路径白名单:{}", JSONObject.toJSONString(whites));
+ this.whites = whites;
+ }
+}
diff --git a/cloud-gateway/src/main/java/com/muyu/filter/AuthFilter.java b/cloud-gateway/src/main/java/com/muyu/filter/AuthFilter.java
new file mode 100644
index 0000000..7763974
--- /dev/null
+++ b/cloud-gateway/src/main/java/com/muyu/filter/AuthFilter.java
@@ -0,0 +1,97 @@
+package com.muyu.filter;
+
+import com.muyu.common.constant.JwtConstants;
+import com.muyu.common.constant.TokenConstants;
+import com.muyu.common.redis.service.RedisService;
+import com.muyu.common.utils.JwtUtils;
+import com.muyu.common.utils.StringUtils;
+import com.muyu.config.IgnoreWhiteConfig;
+import com.muyu.utils.GatewayUtils;
+import io.jsonwebtoken.Claims;
+import lombok.AllArgsConstructor;
+import org.springframework.cloud.gateway.filter.GatewayFilterChain;
+import org.springframework.cloud.gateway.filter.GlobalFilter;
+import org.springframework.core.Ordered;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.server.RequestPath;
+import org.springframework.http.server.reactive.ServerHttpRequest;
+import org.springframework.stereotype.Component;
+import org.springframework.web.server.ServerWebExchange;
+import reactor.core.publisher.Mono;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.nio.charset.StandardCharsets;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @Author: xiexyinyue
+ * @date: 2024/7/10
+ * @Description: 权限过滤器
+ * @Version: 1.0
+ */
+@Component
+@AllArgsConstructor
+public class AuthFilter implements GlobalFilter, Ordered {
+
+ private final IgnoreWhiteConfig ignoreWhiteConfig;
+
+ private final RedisService redisService;
+
+ @Override
+ public Mono filter (ServerWebExchange exchange, GatewayFilterChain chain) {
+
+ ServerHttpRequest request = exchange.getRequest();
+ URI uri = request.getURI();
+ String path = uri.getPath();
+ if (StringUtils.matches(path, ignoreWhiteConfig.getWhites())){
+ return chain.filter(exchange);
+ }
+ HttpHeaders requestHeaders = request.getHeaders();
+ String token = requestHeaders.getFirst(TokenConstants.TOKEN);
+ if (StringUtils.isEmpty(token)){
+ return GatewayUtils.errorResponse(exchange, "token不合法");
+ }
+ Claims claims = JwtUtils.parseToken(token);
+ if (claims == null){
+ return GatewayUtils.errorResponse(exchange, "token不合法");
+ }
+ String userKey = JwtUtils.getUserKey(claims);
+ if (!redisService.hasKey(JwtConstants.USER_KEY + userKey)){
+ return GatewayUtils.errorResponse(exchange, "token已过期");
+ }else{
+ //每次访问后台gateway进行拦截10分钟内访问后台自动续期Token到15分钟
+ long expire = redisService.getExpire(JwtConstants.USER_KEY + userKey);
+ if(expire >5){
+ redisService.expire(JwtConstants.USER_KEY+userKey,15L, TimeUnit.MINUTES);
+ }
+ }
+ ServerHttpRequest.Builder mutate = request.mutate();
+ GatewayUtils.addHeader(mutate, JwtConstants.USER_KEY, userKey);
+ GatewayUtils.addHeader(mutate, JwtConstants.DETAILS_USER_ID, JwtUtils.getUserId(claims));
+ String userName = JwtUtils.getUserName(claims);
+ if (userName.matches(".*[\\u4E00-\\u9FA5]+.*")){
+ userName = new String(userName.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1);
+ }
+ GatewayUtils.addHeader(mutate, JwtConstants.DETAILS_USERNAME,userName );
+ 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/cloud-gateway/src/main/java/com/muyu/utils/GatewayUtils.java b/cloud-gateway/src/main/java/com/muyu/utils/GatewayUtils.java
new file mode 100644
index 0000000..183ed04
--- /dev/null
+++ b/cloud-gateway/src/main/java/com/muyu/utils/GatewayUtils.java
@@ -0,0 +1,73 @@
+package com.muyu.utils;
+
+import com.alibaba.fastjson.JSONObject;
+import com.muyu.common.result.Result;
+import com.muyu.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 xiexyinyue
+ * @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) {
+ 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/cloud-gateway/src/main/resources/bootstrap.yml b/cloud-gateway/src/main/resources/bootstrap.yml
new file mode 100644
index 0000000..6a550f2
--- /dev/null
+++ b/cloud-gateway/src/main/resources/bootstrap.yml
@@ -0,0 +1,32 @@
+# 指定项目启动的端口号
+server:
+ port: 8081
+
+# 配置nacos的地址
+nacos:
+ server-addr: 60.204.221.52:8848
+
+spring:
+ application:
+ # 配置项目的名称
+ name: cloud-gateway
+ profiles:
+ # 指定项目启动使用的环境配置文件
+ active: dev
+ cloud:
+ nacos:
+ discovery:
+ # nacos 注册中心的地址
+ server-addr: ${nacos.server-addr}
+ config:
+ # nacos 配置中心的地址
+ server-addr: ${nacos.server-addr}
+ # nacos 配置中心使用的文件后缀(格式)
+ file-extension: yml
+ # nacos 配置中心的共享配置文件
+ shared-configs:
+ # 程序公共配置文件
+ - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
+ # 程序Redis公共配置文件
+ - redis-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
+ - cloud-gateway-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
diff --git a/modules/cloud-system/pom.xml b/modules/cloud-system/pom.xml
new file mode 100644
index 0000000..32b0ebd
--- /dev/null
+++ b/modules/cloud-system/pom.xml
@@ -0,0 +1,27 @@
+
+
+ 4.0.0
+
+ com.muyu
+ modules
+ 1.0.0
+
+
+ cloud-system
+ pom
+
+ system-common
+ system-remote
+ system-server
+ system-house
+
+
+
+ 8
+ 8
+ UTF-8
+
+
+
diff --git a/modules/cloud-system/system-common/pom.xml b/modules/cloud-system/system-common/pom.xml
new file mode 100644
index 0000000..6d35f31
--- /dev/null
+++ b/modules/cloud-system/system-common/pom.xml
@@ -0,0 +1,28 @@
+
+
+ 4.0.0
+
+ com.muyu
+ cloud-system
+ 1.0.0
+
+
+ system-common
+
+
+ 8
+ 8
+ UTF-8
+
+
+
+
+
+ com.muyu
+ cloud-common
+
+
+
+
diff --git a/modules/cloud-system/system-common/src/main/java/com/muyu/cloud/system/domain/Audit.java b/modules/cloud-system/system-common/src/main/java/com/muyu/cloud/system/domain/Audit.java
new file mode 100644
index 0000000..91a7949
--- /dev/null
+++ b/modules/cloud-system/system-common/src/main/java/com/muyu/cloud/system/domain/Audit.java
@@ -0,0 +1,37 @@
+package com.muyu.cloud.system.domain;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * @version 1.0
+ * @Author xiexyinyue
+ * @Date 2024/7/30 10:42
+ * @注释
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+public class Audit {
+ private Integer auditId;
+ private Integer id;
+ @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ private Date auditStartDate;
+ private Integer houseId;
+
+ private BigDecimal auditActualPrice;
+ private BigDecimal auditDiscountPrice;
+ private String auditDesc;
+ private Integer loadStatus;
+ private Integer contractId;
+
+}
diff --git a/modules/cloud-system/system-common/src/main/java/com/muyu/cloud/system/domain/Contract.java b/modules/cloud-system/system-common/src/main/java/com/muyu/cloud/system/domain/Contract.java
new file mode 100644
index 0000000..54d2547
--- /dev/null
+++ b/modules/cloud-system/system-common/src/main/java/com/muyu/cloud/system/domain/Contract.java
@@ -0,0 +1,22 @@
+package com.muyu.cloud.system.domain;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * @version 1.0
+ * @Author xiexyinyue
+ * @Date 2024/7/30
+ * @注释
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+public class Contract {
+ private Integer contractId;
+ private Integer contractTime;
+
+}
diff --git a/modules/cloud-system/system-common/src/main/java/com/muyu/cloud/system/domain/House.java b/modules/cloud-system/system-common/src/main/java/com/muyu/cloud/system/domain/House.java
new file mode 100644
index 0000000..a2e6cfc
--- /dev/null
+++ b/modules/cloud-system/system-common/src/main/java/com/muyu/cloud/system/domain/House.java
@@ -0,0 +1,38 @@
+package com.muyu.cloud.system.domain;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springframework.boot.convert.DurationFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * @version 1.0
+ * @Author xiexyinyue
+ * @Date 2024/7/30 10:37
+ * @注释
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+public class House {
+ private Integer houseId;
+ private String houseName;
+ private Integer methodId;
+ private Double houseArea;
+ private String houseImg;
+ private BigDecimal houseMonthMoney;
+ private BigDecimal houseBigMoney;
+ private BigDecimal houseMinMoney;
+
+ private Integer pageNum=1;
+ private Integer pageSize=3;
+
+
+}
diff --git a/modules/cloud-system/system-common/src/main/java/com/muyu/cloud/system/domain/Method.java b/modules/cloud-system/system-common/src/main/java/com/muyu/cloud/system/domain/Method.java
new file mode 100644
index 0000000..e8e7576
--- /dev/null
+++ b/modules/cloud-system/system-common/src/main/java/com/muyu/cloud/system/domain/Method.java
@@ -0,0 +1,21 @@
+package com.muyu.cloud.system.domain;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * @version 1.0
+ * @Author xiexyinyue
+ * @Date 2024/7/30
+ * @注释
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+public class Method {
+ private Integer methodId;
+ private String methodName;
+}
diff --git a/modules/cloud-system/system-common/src/main/java/com/muyu/cloud/system/domain/UserInfo.java b/modules/cloud-system/system-common/src/main/java/com/muyu/cloud/system/domain/UserInfo.java
new file mode 100644
index 0000000..a574f0c
--- /dev/null
+++ b/modules/cloud-system/system-common/src/main/java/com/muyu/cloud/system/domain/UserInfo.java
@@ -0,0 +1,36 @@
+package com.muyu.cloud.system.domain;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * @version 1.0
+ * @Author xiexyinyue
+ * @Date 2024/7/10 15:27
+ * @注释
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+public class UserInfo {
+
+ private Integer id ;
+ private String username ;
+ private String userTel ;
+ private String password ;
+ private Integer number ;
+ private Integer role ;
+ private Integer creditScore ;
+ private Integer userSex ;
+ private Integer userAge ;
+
+
+
+
+
+
+
+}
diff --git a/modules/cloud-system/system-common/src/main/java/com/muyu/cloud/system/domain/response/AuditResp.java b/modules/cloud-system/system-common/src/main/java/com/muyu/cloud/system/domain/response/AuditResp.java
new file mode 100644
index 0000000..d7d0e97
--- /dev/null
+++ b/modules/cloud-system/system-common/src/main/java/com/muyu/cloud/system/domain/response/AuditResp.java
@@ -0,0 +1,40 @@
+package com.muyu.cloud.system.domain.response;
+
+import com.muyu.cloud.system.domain.Audit;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+
+import java.math.BigDecimal;
+
+/**
+ * @version 1.0
+ * @Author xiexyinyue
+ * @Date 2024/7/30 10:44
+ * @注释
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class AuditResp extends Audit {
+ private String username ;
+ private String userTel ;
+ private String password ;
+ private Integer number ;
+ private Integer role ;
+ private Integer creditScore ;
+ private Integer userSex ;
+ private Integer userAge ;
+ private String houseName;
+ private Integer methodId;
+ private Double houseArea;
+ private String houseImg;
+ private BigDecimal houseMonthMoney;
+ private Integer contractTime;
+
+
+
+
+}
diff --git a/modules/cloud-system/system-common/src/main/java/com/muyu/cloud/system/domain/response/HouseResp.java b/modules/cloud-system/system-common/src/main/java/com/muyu/cloud/system/domain/response/HouseResp.java
new file mode 100644
index 0000000..b699b90
--- /dev/null
+++ b/modules/cloud-system/system-common/src/main/java/com/muyu/cloud/system/domain/response/HouseResp.java
@@ -0,0 +1,21 @@
+package com.muyu.cloud.system.domain.response;
+
+import com.muyu.cloud.system.domain.House;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+
+/**
+ * @version 1.0
+ * @Author xiexyinyue
+ * @Date 2024/7/30 10:40
+ * @注释
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class HouseResp extends House {
+ private String methodName;
+}
diff --git a/modules/cloud-system/system-house/pom.xml b/modules/cloud-system/system-house/pom.xml
new file mode 100644
index 0000000..84d7fc6
--- /dev/null
+++ b/modules/cloud-system/system-house/pom.xml
@@ -0,0 +1,32 @@
+
+
+ 4.0.0
+
+ com.muyu
+ cloud-system
+ 1.0.0
+
+
+ system-house
+
+
+ 17
+ 17
+ UTF-8
+
+
+
+
+
+ com.muyu
+ system-common
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
diff --git a/modules/cloud-system/system-house/src/main/java/com/muyu/house/HouseApplication.java b/modules/cloud-system/system-house/src/main/java/com/muyu/house/HouseApplication.java
new file mode 100644
index 0000000..31ef26e
--- /dev/null
+++ b/modules/cloud-system/system-house/src/main/java/com/muyu/house/HouseApplication.java
@@ -0,0 +1,21 @@
+package com.muyu.house;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+import org.springframework.scheduling.annotation.EnableScheduling;
+
+/**
+ * @version 1.0
+ * @Author xiexyinyue
+ * @Date 2024/7/30 10:37
+ * @注释
+ */
+@SpringBootApplication
+@EnableFeignClients( basePackages = {"com.muyu.**"})
+@EnableScheduling
+public class HouseApplication {
+ public static void main(String[] args) {
+ SpringApplication.run(HouseApplication.class,args);
+ }
+}
diff --git a/modules/cloud-system/system-house/src/main/java/com/muyu/house/controller/AuditController.java b/modules/cloud-system/system-house/src/main/java/com/muyu/house/controller/AuditController.java
new file mode 100644
index 0000000..e4444ab
--- /dev/null
+++ b/modules/cloud-system/system-house/src/main/java/com/muyu/house/controller/AuditController.java
@@ -0,0 +1,107 @@
+package com.muyu.house.controller;
+
+import com.muyu.cloud.system.domain.Audit;
+import com.muyu.cloud.system.domain.UserInfo;
+import com.muyu.cloud.system.domain.response.AuditResp;
+import com.muyu.common.constant.JwtConstants;
+import com.muyu.common.redis.service.RedisService;
+import com.muyu.common.result.Result;
+import com.muyu.house.service.AuditService;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import java.math.BigDecimal;
+import java.util.List;
+
+/**
+ * @version 1.0
+ * @Author xiexyinyue
+ * @Date 2024/7/30 11:03
+ * @注释
+ */
+@RestController
+@RequestMapping("/audit")
+public class AuditController {
+ @Resource
+ private AuditService auditService;
+
+ @Resource
+ private HttpServletRequest request;
+
+ @Resource
+ private RedisService redisService;
+
+ @PostMapping("/findByAudit")
+ public Result findByAudit(UserInfo userInfo){
+ return Result.success(auditService.findByAudit(userInfo));
+ }
+
+ @PostMapping("/addAudit")
+ public Result addAudit(@RequestBody Audit audit){
+ auditService.addAudit(audit);
+ return Result.success();
+ }
+
+ @GetMapping("/showAudit")
+ public Result> showAudit(){
+ UserInfo userInfo = getUserinfo();
+ return Result.success(auditService.showAudit(userInfo));
+ }
+
+
+
+ @Scheduled(cron = "0/30 * * * * ?")
+ public void updateAudit(){
+ UserInfo userInfo = getUserinfo();
+ Integer creditScore = userInfo.getCreditScore();
+ int i = creditScore % 100;
+ Integer finalMoney = 0;
+ if( i >0){
+ finalMoney = 1000 * ((creditScore / 100) +1);
+
+ }else{
+ finalMoney = 1000 * (creditScore / 100);
+ }
+ List data = getData();
+
+ Integer finalMoney1 = finalMoney;
+ data.forEach(auditResp -> {
+ int i1 = auditResp.getAuditDiscountPrice().compareTo(new BigDecimal(finalMoney1));
+
+ if(i1 < 0){
+ data.forEach(audit -> {
+ audit.setLoadStatus(3); //驳回
+ updateStatus(audit,userInfo);
+ });
+ return;
+ }else{
+ data.forEach(audit -> {
+ audit.setLoadStatus(2); //通过
+ updateStatus(audit,userInfo);
+ });
+ return;
+ }
+
+ });
+
+ }
+
+ /*
+ *修改审核和驳回
+ */
+ private void updateStatus(Audit audit,UserInfo userInfo){
+ auditService.updateStatus(audit,userInfo);
+ }
+
+ private List getData(){
+ return auditService.showAu();
+ }
+
+ private UserInfo getUserinfo(){
+ String userKey = request.getHeader("user_key");
+ UserInfo cacheUserInfo = redisService.getCacheObject(JwtConstants.USER_KEY+userKey);
+ return cacheUserInfo;
+ }
+}
diff --git a/modules/cloud-system/system-house/src/main/java/com/muyu/house/controller/ContractController.java b/modules/cloud-system/system-house/src/main/java/com/muyu/house/controller/ContractController.java
new file mode 100644
index 0000000..40e24cd
--- /dev/null
+++ b/modules/cloud-system/system-house/src/main/java/com/muyu/house/controller/ContractController.java
@@ -0,0 +1,29 @@
+package com.muyu.house.controller;
+
+import com.muyu.cloud.system.domain.Contract;
+import com.muyu.common.result.Result;
+import com.muyu.house.service.ContractService;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * @version 1.0
+ * @Author xiexyinyue
+ * @Date 2024/7/30 13:54
+ * @注释
+ */
+@RestController
+@RequestMapping("/contract")
+public class ContractController {
+ @Resource
+ private ContractService contractService;
+
+ @GetMapping("/selectContractData")
+ public Result> selectContractData(){
+ return Result.success(contractService.showContract());
+ }
+}
diff --git a/modules/cloud-system/system-house/src/main/java/com/muyu/house/controller/HouseController.java b/modules/cloud-system/system-house/src/main/java/com/muyu/house/controller/HouseController.java
new file mode 100644
index 0000000..4a91139
--- /dev/null
+++ b/modules/cloud-system/system-house/src/main/java/com/muyu/house/controller/HouseController.java
@@ -0,0 +1,46 @@
+package com.muyu.house.controller;
+
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import com.muyu.cloud.system.domain.House;
+import com.muyu.cloud.system.domain.response.HouseResp;
+import com.muyu.common.result.Result;
+import com.muyu.common.utils.OssUtil;
+import com.muyu.house.service.HouseService;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * @version 1.0
+ * @Author xiexyinyue
+ * @Date 2024/7/30 10:46
+ * @注释
+ */
+@RestController
+@RequestMapping("/house")
+public class HouseController {
+
+ @Resource
+ private HouseService houseService;
+
+ @PostMapping("/showHouses")
+ public Result> showHouses(@RequestBody House house){
+ PageHelper.startPage(house.getPageNum(),house.getPageSize());
+ List houseRespList = houseService.showHouses(house);
+ PageInfo pageInfo = new PageInfo<>(houseRespList);
+ return Result.success(pageInfo);
+ }
+
+ @PostMapping("/findHouseById/{houseId}")
+ public Result findHouseById(@PathVariable("houseId") Integer houseId){
+ return Result.success(houseService.findHouseById(houseId));
+ }
+
+ @PostMapping("/upload")
+ public String upload(@RequestParam MultipartFile file){
+ return OssUtil.uploadMultipartFile(file);
+ }
+}
diff --git a/modules/cloud-system/system-house/src/main/java/com/muyu/house/controller/MethodController.java b/modules/cloud-system/system-house/src/main/java/com/muyu/house/controller/MethodController.java
new file mode 100644
index 0000000..bc4e2a9
--- /dev/null
+++ b/modules/cloud-system/system-house/src/main/java/com/muyu/house/controller/MethodController.java
@@ -0,0 +1,30 @@
+package com.muyu.house.controller;
+
+import com.muyu.cloud.system.domain.Method;
+import com.muyu.common.result.Result;
+import com.muyu.house.service.MethodService;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * @version 1.0
+ * @Author xiexyinyue
+ * @Date 2024/7/30 11:08
+ * @注释
+ */
+@RestController
+@RequestMapping("/method")
+public class MethodController {
+ @Resource
+ private MethodService methodService;
+
+ @GetMapping("/showMethod")
+ public Result> showMethod(){
+ List methodList = methodService.showMethod();
+ return Result.success(methodList);
+ }
+}
diff --git a/modules/cloud-system/system-house/src/main/java/com/muyu/house/mapper/AuditMapper.java b/modules/cloud-system/system-house/src/main/java/com/muyu/house/mapper/AuditMapper.java
new file mode 100644
index 0000000..5f93e7e
--- /dev/null
+++ b/modules/cloud-system/system-house/src/main/java/com/muyu/house/mapper/AuditMapper.java
@@ -0,0 +1,27 @@
+package com.muyu.house.mapper;
+
+import com.muyu.cloud.system.domain.Audit;
+import com.muyu.cloud.system.domain.UserInfo;
+import com.muyu.cloud.system.domain.response.AuditResp;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+/**
+ * @version 1.0
+ * @Author xiexyinyue
+ * @Date 2024/7/30 11:04
+ * @注释
+ */
+@Mapper
+public interface AuditMapper {
+ Integer findByAudit(Integer id);
+
+ void addAudit(Audit audit);
+
+ List showAudit(UserInfo userInfo);
+
+ void updateStatus(Audit audit);
+
+ List showAu();
+}
diff --git a/modules/cloud-system/system-house/src/main/java/com/muyu/house/mapper/ContractMapper.java b/modules/cloud-system/system-house/src/main/java/com/muyu/house/mapper/ContractMapper.java
new file mode 100644
index 0000000..75f6a1e
--- /dev/null
+++ b/modules/cloud-system/system-house/src/main/java/com/muyu/house/mapper/ContractMapper.java
@@ -0,0 +1,17 @@
+package com.muyu.house.mapper;
+
+import com.muyu.cloud.system.domain.Contract;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+/**
+ * @version 1.0
+ * @Author xiexyinyue
+ * @Date 2024/7/30 13:55
+ * @注释
+ */
+@Mapper
+public interface ContractMapper {
+ List showContract();
+}
diff --git a/modules/cloud-system/system-house/src/main/java/com/muyu/house/mapper/HouseMapper.java b/modules/cloud-system/system-house/src/main/java/com/muyu/house/mapper/HouseMapper.java
new file mode 100644
index 0000000..fff6e31
--- /dev/null
+++ b/modules/cloud-system/system-house/src/main/java/com/muyu/house/mapper/HouseMapper.java
@@ -0,0 +1,22 @@
+package com.muyu.house.mapper;
+
+import com.muyu.cloud.system.domain.House;
+import com.muyu.cloud.system.domain.response.HouseResp;
+import com.muyu.common.result.Result;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+/**
+ * @version 1.0
+ * @Author xiexyinyue
+ * @Date 2024/7/30 10:45
+ * @注释
+ */
+@Mapper
+public interface HouseMapper {
+
+ List showHouses(House house);
+
+ House findHouseById(Integer houseId);
+}
diff --git a/modules/cloud-system/system-house/src/main/java/com/muyu/house/mapper/MethodMapper.java b/modules/cloud-system/system-house/src/main/java/com/muyu/house/mapper/MethodMapper.java
new file mode 100644
index 0000000..f7b9107
--- /dev/null
+++ b/modules/cloud-system/system-house/src/main/java/com/muyu/house/mapper/MethodMapper.java
@@ -0,0 +1,18 @@
+package com.muyu.house.mapper;
+
+import com.muyu.cloud.system.domain.Method;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+/**
+ * @version 1.0
+ * @Author xiexyinyue
+ * @Date 2024/7/30 11:06
+ * @注释
+ */
+@Mapper
+public interface MethodMapper {
+
+ List showMethods();
+}
diff --git a/modules/cloud-system/system-house/src/main/java/com/muyu/house/service/AuditService.java b/modules/cloud-system/system-house/src/main/java/com/muyu/house/service/AuditService.java
new file mode 100644
index 0000000..1a9d529
--- /dev/null
+++ b/modules/cloud-system/system-house/src/main/java/com/muyu/house/service/AuditService.java
@@ -0,0 +1,26 @@
+package com.muyu.house.service;
+
+import com.muyu.cloud.system.domain.Audit;
+import com.muyu.cloud.system.domain.UserInfo;
+import com.muyu.cloud.system.domain.response.AuditResp;
+
+import java.util.List;
+
+/**
+ * @version 1.0
+ * @Author xiexyinyue
+ * @Date 2024/7/30 11:03
+ * @注释
+ */
+public interface AuditService {
+ Integer findByAudit(UserInfo userInfo);
+
+ void addAudit(Audit audit);
+
+ List showAudit(UserInfo userInfo);
+
+ void updateStatus(Audit audit,UserInfo userInfo);
+
+ List showAu();
+
+}
diff --git a/modules/cloud-system/system-house/src/main/java/com/muyu/house/service/ContractService.java b/modules/cloud-system/system-house/src/main/java/com/muyu/house/service/ContractService.java
new file mode 100644
index 0000000..7be9dd1
--- /dev/null
+++ b/modules/cloud-system/system-house/src/main/java/com/muyu/house/service/ContractService.java
@@ -0,0 +1,16 @@
+package com.muyu.house.service;
+
+import com.muyu.cloud.system.domain.Contract;
+
+import java.util.List;
+
+/**
+ * @version 1.0
+ * @Author xiexyinyue
+ * @Date 2024/7/30 13:55
+ * @注释
+ */
+public interface ContractService {
+ List showContract();
+
+}
diff --git a/modules/cloud-system/system-house/src/main/java/com/muyu/house/service/HouseService.java b/modules/cloud-system/system-house/src/main/java/com/muyu/house/service/HouseService.java
new file mode 100644
index 0000000..1e6ef27
--- /dev/null
+++ b/modules/cloud-system/system-house/src/main/java/com/muyu/house/service/HouseService.java
@@ -0,0 +1,19 @@
+package com.muyu.house.service;
+
+import com.muyu.cloud.system.domain.House;
+import com.muyu.cloud.system.domain.response.HouseResp;
+import com.muyu.common.result.Result;
+
+import java.util.List;
+
+/**
+ * @version 1.0
+ * @Author xiexyinyue
+ * @Date 2024/7/30 10:45
+ * @注释
+ */
+public interface HouseService {
+ List showHouses(House house);
+
+ House findHouseById(Integer houseId);
+}
diff --git a/modules/cloud-system/system-house/src/main/java/com/muyu/house/service/MethodService.java b/modules/cloud-system/system-house/src/main/java/com/muyu/house/service/MethodService.java
new file mode 100644
index 0000000..2be0b3a
--- /dev/null
+++ b/modules/cloud-system/system-house/src/main/java/com/muyu/house/service/MethodService.java
@@ -0,0 +1,15 @@
+package com.muyu.house.service;
+
+import com.muyu.cloud.system.domain.Method;
+
+import java.util.List;
+
+/**
+ * @version 1.0
+ * @Author xiexyinyue
+ * @Date 2024/7/30 11:07
+ * @注释
+ */
+public interface MethodService {
+ List showMethod();
+}
diff --git a/modules/cloud-system/system-house/src/main/java/com/muyu/house/service/impl/AuditServiceImpl.java b/modules/cloud-system/system-house/src/main/java/com/muyu/house/service/impl/AuditServiceImpl.java
new file mode 100644
index 0000000..da3fa4d
--- /dev/null
+++ b/modules/cloud-system/system-house/src/main/java/com/muyu/house/service/impl/AuditServiceImpl.java
@@ -0,0 +1,73 @@
+package com.muyu.house.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.muyu.cloud.system.domain.Audit;
+import com.muyu.cloud.system.domain.UserInfo;
+import com.muyu.cloud.system.domain.response.AuditResp;
+import com.muyu.common.constant.MQQueueNameConstants;
+import com.muyu.common.utils.TelSmsUtils;
+import com.muyu.house.mapper.AuditMapper;
+import com.muyu.house.service.AuditService;
+import org.springframework.amqp.rabbit.annotation.Queue;
+import org.springframework.amqp.rabbit.annotation.RabbitListener;
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import java.util.List;
+import java.util.UUID;
+
+/**
+ * @version 1.0
+ * @Author xiexyinyue
+ * @Date 2024/7/30 11:04
+ * @注释
+ */
+@Service
+public class AuditServiceImpl implements AuditService {
+ @Resource
+ private AuditMapper auditMapper;
+
+ @Resource
+ private RabbitTemplate rabbitTemplate;
+ @Override
+ public Integer findByAudit(UserInfo userInfo) {
+ return auditMapper.findByAudit(userInfo.getId());
+ }
+
+ @Override
+ public void addAudit(Audit audit) {
+ auditMapper.addAudit(audit);
+ }
+
+ @Override
+ public List showAudit(UserInfo userInfo) {
+ return auditMapper.showAudit(userInfo);
+ }
+
+ @Transactional
+ @Override
+ public void updateStatus(Audit audit,UserInfo userInfo) {
+
+ auditMapper.updateStatus(audit);
+ if(audit.getLoadStatus() == 3){
+ rabbitTemplate.convertAndSend(MQQueueNameConstants.SMS_QUEUE_NAME, JSONObject.toJSONString(userInfo), message -> {
+ message.getMessageProperties().setMessageId(UUID.randomUUID().toString());
+ return message;
+ });
+ }
+ }
+
+ @RabbitListener(queuesToDeclare = {@Queue(name = MQQueueNameConstants.SMS_QUEUE_NAME)})
+ public void getMessage(String message){
+ System.out.println(message);
+ UserInfo userInfo = JSONObject.parseObject(message, UserInfo.class);
+ TelSmsUtils.sendSms(userInfo.getUserTel(),"你的信誉值过低,尚不能贷款这么多金额");
+ }
+
+ @Override
+ public List showAu() {
+ return auditMapper.showAu();
+ }
+}
diff --git a/modules/cloud-system/system-house/src/main/java/com/muyu/house/service/impl/ContractServiceImpl.java b/modules/cloud-system/system-house/src/main/java/com/muyu/house/service/impl/ContractServiceImpl.java
new file mode 100644
index 0000000..cc0742f
--- /dev/null
+++ b/modules/cloud-system/system-house/src/main/java/com/muyu/house/service/impl/ContractServiceImpl.java
@@ -0,0 +1,38 @@
+package com.muyu.house.service.impl;
+
+import com.muyu.cloud.system.domain.Contract;
+import com.muyu.cloud.system.domain.Method;
+import com.muyu.common.redis.service.RedisService;
+import com.muyu.house.mapper.ContractMapper;
+import com.muyu.house.service.ContractService;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * @version 1.0
+ * @Author xiexyinyue
+ * @Date 2024/7/30 13:55
+ * @注释
+ */
+@Service
+public class ContractServiceImpl implements ContractService {
+ @Resource
+ private ContractMapper contractMapper;
+ @Resource
+ private RedisService redisService;
+
+ private static final String CONTRACT_DATA="contract:AllData";
+ @Override
+ public List showContract() {
+ if(redisService.hasKey(CONTRACT_DATA)){
+ return redisService.getCacheObject(CONTRACT_DATA);
+ }
+ List contractList = contractMapper.showContract();
+ redisService.setCacheObject(CONTRACT_DATA,contractList);
+ return contractList;
+ }
+
+
+}
diff --git a/modules/cloud-system/system-house/src/main/java/com/muyu/house/service/impl/HouseServiceImpl.java b/modules/cloud-system/system-house/src/main/java/com/muyu/house/service/impl/HouseServiceImpl.java
new file mode 100644
index 0000000..2183e51
--- /dev/null
+++ b/modules/cloud-system/system-house/src/main/java/com/muyu/house/service/impl/HouseServiceImpl.java
@@ -0,0 +1,35 @@
+package com.muyu.house.service.impl;
+
+import com.muyu.cloud.system.domain.House;
+import com.muyu.cloud.system.domain.Method;
+import com.muyu.cloud.system.domain.response.HouseResp;
+import com.muyu.common.result.Result;
+import com.muyu.house.mapper.HouseMapper;
+import com.muyu.house.service.HouseService;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * @version 1.0
+ * @Author xiexyinyue
+ * @Date 2024/7/30 10:46
+ * @注释
+ */
+@Service
+public class HouseServiceImpl implements HouseService {
+ @Resource
+ private HouseMapper houseMapper;
+
+ @Override
+ public List showHouses(House house) {
+ return houseMapper.showHouses(house);
+ }
+
+ @Override
+ public House findHouseById(Integer houseId) {
+
+ return houseMapper.findHouseById(houseId);
+ }
+}
diff --git a/modules/cloud-system/system-house/src/main/java/com/muyu/house/service/impl/MethodServiceImpl.java b/modules/cloud-system/system-house/src/main/java/com/muyu/house/service/impl/MethodServiceImpl.java
new file mode 100644
index 0000000..cb42074
--- /dev/null
+++ b/modules/cloud-system/system-house/src/main/java/com/muyu/house/service/impl/MethodServiceImpl.java
@@ -0,0 +1,36 @@
+package com.muyu.house.service.impl;
+
+import com.muyu.cloud.system.domain.Method;
+import com.muyu.common.redis.service.RedisService;
+import com.muyu.house.mapper.MethodMapper;
+import com.muyu.house.service.MethodService;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * @version 1.0
+ * @Author xiexyinyue
+ * @Date 2024/7/30 11:07
+ * @注释
+ */
+@Service
+public class MethodServiceImpl implements MethodService {
+ @Resource
+ private MethodMapper methodMapper;
+
+ @Resource
+ private RedisService redisService;
+
+ private static final String METHOD_DATA="method:AllData";
+ @Override
+ public List showMethod() {
+ if(redisService.hasKey(METHOD_DATA)){
+ return redisService.getCacheObject(METHOD_DATA);
+ }
+ List methodList = methodMapper.showMethods();
+ redisService.setCacheObject(METHOD_DATA,methodList);
+ return methodList;
+ }
+}
diff --git a/modules/cloud-system/system-house/src/main/resources/bootstrap.yml b/modules/cloud-system/system-house/src/main/resources/bootstrap.yml
new file mode 100644
index 0000000..229d786
--- /dev/null
+++ b/modules/cloud-system/system-house/src/main/resources/bootstrap.yml
@@ -0,0 +1,60 @@
+# Tomcat
+server:
+ port: 9202
+
+# 配置nacos的地址
+nacos:
+ server-addr: 60.204.221.52:8848
+
+# Spring
+spring:
+ rabbitmq:
+ host: 60.204.221.52
+ port: 5672
+ publisher-confirm-type: correlated #消息发送到交换机确认
+ publisher-returns: true #允许发送到消息队列的确认
+ username: user
+ password: Xxy041004
+ main:
+ allow-circular-references: true
+ jackson:
+ date-format: yyyy-MM-dd HH:mm:ss
+ time-zone: GMT+8
+ application:
+ # 应用名称
+ name: system-house
+ profiles:
+ # 环境配置
+ active: dev
+ cloud:
+ nacos:
+ discovery:
+ # 服务注册地址
+ server-addr: ${nacos.server-addr}
+ config:
+ # 配置中心地址
+ server-addr: ${nacos.server-addr}
+ # 配置文件格式
+ file-extension: yml
+ # 共享配置
+ shared-configs:
+ - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
+ # 程序Redis公共配置文件
+ - redis-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
+ # 程序MySQL公共配置文件
+ - mysql-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
+
+ - system-server-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
+
+fdfs:
+ so-timeout: 1500 # socket 连接时长
+ connect-timeout: 600 # 连接 tracker 服务器超时时长
+ # 这两个是你服务器的 IP 地址,注意 23000 端口也要打开,阿里云服务器记得配置安全组。tracker 要和 stroage 服务进行交流
+ tracker-list: 60.204.221.52:22122
+ web-server-url: 60.204.221.52:8888
+ pool:
+ jmx-enabled: false
+ # 生成缩略图
+ thumb-image:
+ height: 500
+ width: 500
diff --git a/modules/cloud-system/system-house/src/main/resources/mapper/AuditMapper.xml b/modules/cloud-system/system-house/src/main/resources/mapper/AuditMapper.xml
new file mode 100644
index 0000000..40e2237
--- /dev/null
+++ b/modules/cloud-system/system-house/src/main/resources/mapper/AuditMapper.xml
@@ -0,0 +1,42 @@
+
+
+
+
+ INSERT INTO `h6-zktwo630`.`t_audit` ( `id`, `audit_start_date`, `house_id`, `audit_actual_price`, `audit_discount_price`, `audit_desc`, `load_status`, `contract_id` )
+ VALUES
+ ( #{id}, now(), #{houseId}, #{auditActualPrice}, #{auditDiscountPrice}, #{auditDesc}, #{loadStatus}, #{contractId} )
+
+
+
+ UPDATE `h6-zktwo630`.`t_audit`
+ SET
+ `load_status` = #{loadStatus}
+ WHERE
+ `audit_id` = #{auditId}
+
+
+
+
+
+
+
+
diff --git a/modules/cloud-system/system-house/src/main/resources/mapper/ContractMapper.xml b/modules/cloud-system/system-house/src/main/resources/mapper/ContractMapper.xml
new file mode 100644
index 0000000..55ec01f
--- /dev/null
+++ b/modules/cloud-system/system-house/src/main/resources/mapper/ContractMapper.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
diff --git a/modules/cloud-system/system-house/src/main/resources/mapper/HouseMapper.xml b/modules/cloud-system/system-house/src/main/resources/mapper/HouseMapper.xml
new file mode 100644
index 0000000..4c51685
--- /dev/null
+++ b/modules/cloud-system/system-house/src/main/resources/mapper/HouseMapper.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
diff --git a/modules/cloud-system/system-house/src/main/resources/mapper/MethodMapper.xml b/modules/cloud-system/system-house/src/main/resources/mapper/MethodMapper.xml
new file mode 100644
index 0000000..a3d8643
--- /dev/null
+++ b/modules/cloud-system/system-house/src/main/resources/mapper/MethodMapper.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
diff --git a/modules/cloud-system/system-remote/pom.xml b/modules/cloud-system/system-remote/pom.xml
new file mode 100644
index 0000000..1c245a9
--- /dev/null
+++ b/modules/cloud-system/system-remote/pom.xml
@@ -0,0 +1,27 @@
+
+
+ 4.0.0
+
+ com.muyu
+ cloud-system
+ 1.0.0
+
+
+ system-remote
+
+
+ 8
+ 8
+ UTF-8
+
+
+
+
+
+ com.muyu
+ system-common
+
+
+
diff --git a/modules/cloud-system/system-remote/src/main/java/com/muyu/cloud/system/factory/UserInfoRemoteFactory.java b/modules/cloud-system/system-remote/src/main/java/com/muyu/cloud/system/factory/UserInfoRemoteFactory.java
new file mode 100644
index 0000000..1bbe7d8
--- /dev/null
+++ b/modules/cloud-system/system-remote/src/main/java/com/muyu/cloud/system/factory/UserInfoRemoteFactory.java
@@ -0,0 +1,36 @@
+package com.muyu.cloud.system.factory;
+
+import com.muyu.cloud.system.domain.UserInfo;
+import com.muyu.cloud.system.remote.RemoteUserInfoService;
+import com.muyu.common.constant.ServerNameConstants;
+import com.muyu.common.result.Result;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.cloud.openfeign.FallbackFactory;
+
+/**
+ * @Author: xiexyinyue
+ * @date: 2024/7/10
+ * @Description: 用户远程调用熔断机制
+ * @Version: 1.0
+ */
+@Log4j2
+public class UserInfoRemoteFactory implements FallbackFactory {
+ @Override
+ public RemoteUserInfoService create (Throwable cause) {
+ return new RemoteUserInfoService() {
+
+ /**
+ * 通过用户名称查询用户信息
+ *
+ * @param userTel 用户名称
+ *
+ * @return 用户信息
+ */
+ @Override
+ public Result login (String userTel) {
+ log.error("服务[{}]调用接口发生异常:[{}]", ServerNameConstants.SYSTEM_NAME, cause.getMessage(), cause);
+ return Result.error(cause.getMessage());
+ }
+ };
+ }
+}
diff --git a/modules/cloud-system/system-remote/src/main/java/com/muyu/cloud/system/remote/RemoteUserInfoService.java b/modules/cloud-system/system-remote/src/main/java/com/muyu/cloud/system/remote/RemoteUserInfoService.java
new file mode 100644
index 0000000..f694109
--- /dev/null
+++ b/modules/cloud-system/system-remote/src/main/java/com/muyu/cloud/system/remote/RemoteUserInfoService.java
@@ -0,0 +1,35 @@
+package com.muyu.cloud.system.remote;
+
+import com.muyu.cloud.system.domain.UserInfo;
+import com.muyu.cloud.system.factory.UserInfoRemoteFactory;
+import com.muyu.common.constant.ServerNameConstants;
+import com.muyu.common.result.Result;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+
+/**
+ * @Author: DongZeLiang
+ * @date: 2024/5/24
+ * @Description: 用户信息远程调用
+ * @Version: 1.0
+ */
+@FeignClient(
+ name = ServerNameConstants.SYSTEM_NAME,
+ // "/user-info" -> controller(requestMapping)
+ path = ServerNameConstants.SystemApi.USER_INFO_API,
+ contextId = "remoteUserInfoService",
+ fallbackFactory = UserInfoRemoteFactory.class
+)
+public interface RemoteUserInfoService {
+
+
+ /**
+ * 通过用户名称查询用户信息
+ * @param userTel 用户名称
+ * @return 用户信息
+ */
+ @PostMapping("/login/{userTel}")
+ Result login(@PathVariable("userTel") String userTel);
+}
diff --git a/modules/cloud-system/system-remote/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/modules/cloud-system/system-remote/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
new file mode 100644
index 0000000..9537641
--- /dev/null
+++ b/modules/cloud-system/system-remote/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
@@ -0,0 +1 @@
+com.muyu.cloud.system.factory.UserInfoRemoteFactory
diff --git a/modules/cloud-system/system-server/pom.xml b/modules/cloud-system/system-server/pom.xml
new file mode 100644
index 0000000..2b67d61
--- /dev/null
+++ b/modules/cloud-system/system-server/pom.xml
@@ -0,0 +1,32 @@
+
+
+ 4.0.0
+
+ com.muyu
+ cloud-system
+ 1.0.0
+
+
+ system-server
+
+
+ 8
+ 8
+ UTF-8
+
+
+
+
+
+ com.muyu
+ system-common
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
diff --git a/modules/cloud-system/system-server/src/main/java/com/muyu/cloud/system/CloudSystemApplication.java b/modules/cloud-system/system-server/src/main/java/com/muyu/cloud/system/CloudSystemApplication.java
new file mode 100644
index 0000000..42e1f75
--- /dev/null
+++ b/modules/cloud-system/system-server/src/main/java/com/muyu/cloud/system/CloudSystemApplication.java
@@ -0,0 +1,21 @@
+package com.muyu.cloud.system;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+import org.springframework.scheduling.annotation.EnableScheduling;
+
+/**
+ * @Author: xiexyinyue
+ * @date: 2024/7/10
+ * @Version: 1.0
+ */
+@SpringBootApplication
+@EnableFeignClients( basePackages = {"com.muyu.**"})
+@EnableScheduling
+public class CloudSystemApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(CloudSystemApplication.class, args);
+ }
+}
diff --git a/modules/cloud-system/system-server/src/main/java/com/muyu/cloud/system/controller/UserController.java b/modules/cloud-system/system-server/src/main/java/com/muyu/cloud/system/controller/UserController.java
new file mode 100644
index 0000000..df82e06
--- /dev/null
+++ b/modules/cloud-system/system-server/src/main/java/com/muyu/cloud/system/controller/UserController.java
@@ -0,0 +1,34 @@
+package com.muyu.cloud.system.controller;
+
+import com.muyu.cloud.system.domain.UserInfo;
+import com.muyu.cloud.system.service.UserService;
+import com.muyu.common.result.Result;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+
+/**
+ * @version 1.0
+ * @Author xiexyinyue
+ * @Date 2024/7/30
+ * @注释
+ */
+@RestController
+@RequestMapping("/user")
+@Log4j2
+public class UserController {
+ @Resource
+ private UserService userService;
+
+ @PostMapping("/login/{userTel}")
+ public Result login(@PathVariable("userTel") String userTel){
+ UserInfo login = userService.login(userTel);
+ log.info("查询的账户信息为[{}]",login);
+ return Result.success(login);
+ }
+
+}
diff --git a/modules/cloud-system/system-server/src/main/java/com/muyu/cloud/system/mapper/UserMapper.java b/modules/cloud-system/system-server/src/main/java/com/muyu/cloud/system/mapper/UserMapper.java
new file mode 100644
index 0000000..3fcf5c6
--- /dev/null
+++ b/modules/cloud-system/system-server/src/main/java/com/muyu/cloud/system/mapper/UserMapper.java
@@ -0,0 +1,18 @@
+package com.muyu.cloud.system.mapper;
+
+import com.muyu.cloud.system.domain.UserInfo;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * @version 1.0
+ * @Author xiexyinyue
+ * @Date 024/7/30
+ * @注释
+ */
+@Mapper
+public interface UserMapper {
+
+ UserInfo login(@Param("userTel") String userTel);
+
+}
diff --git a/modules/cloud-system/system-server/src/main/java/com/muyu/cloud/system/service/UserService.java b/modules/cloud-system/system-server/src/main/java/com/muyu/cloud/system/service/UserService.java
new file mode 100644
index 0000000..2f407ff
--- /dev/null
+++ b/modules/cloud-system/system-server/src/main/java/com/muyu/cloud/system/service/UserService.java
@@ -0,0 +1,14 @@
+package com.muyu.cloud.system.service;
+
+import com.muyu.cloud.system.domain.UserInfo;
+
+/**
+ * @version 1.0
+ * @Author xiexyinyue
+ * @Date 2024/7/30
+ * @注释
+ */
+public interface UserService {
+ UserInfo login(String userTel);
+
+}
diff --git a/modules/cloud-system/system-server/src/main/java/com/muyu/cloud/system/service/impl/UserServiceImpl.java b/modules/cloud-system/system-server/src/main/java/com/muyu/cloud/system/service/impl/UserServiceImpl.java
new file mode 100644
index 0000000..4d90ba2
--- /dev/null
+++ b/modules/cloud-system/system-server/src/main/java/com/muyu/cloud/system/service/impl/UserServiceImpl.java
@@ -0,0 +1,25 @@
+package com.muyu.cloud.system.service.impl;
+
+import com.muyu.cloud.system.domain.UserInfo;
+import com.muyu.cloud.system.mapper.UserMapper;
+import com.muyu.cloud.system.service.UserService;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+
+/**
+ * @version 1.0
+ * @Author xiexyinyue
+ * @Date 2024/7/30
+ * @注释
+ */
+@Service
+public class UserServiceImpl implements UserService {
+ @Resource
+ private UserMapper userMapper;
+
+ @Override
+ public UserInfo login(String userTel) {
+ return userMapper.login(userTel);
+ }
+}
diff --git a/modules/cloud-system/system-server/src/main/resources/bootstrap.yml b/modules/cloud-system/system-server/src/main/resources/bootstrap.yml
new file mode 100644
index 0000000..e230adb
--- /dev/null
+++ b/modules/cloud-system/system-server/src/main/resources/bootstrap.yml
@@ -0,0 +1,53 @@
+# Tomcat
+server:
+ port: 9201
+
+# 配置nacos的地址
+nacos:
+ server-addr: 60.204.221.52:8848
+
+# Spring
+spring:
+ main:
+ allow-circular-references: true
+ jackson:
+ date-format: yyyy-MM-dd HH:mm:ss
+ time-zone: GMT+8
+ application:
+ # 应用名称
+ name: system-server
+ profiles:
+ # 环境配置
+ active: dev
+ cloud:
+ nacos:
+ discovery:
+ # 服务注册地址
+ server-addr: ${nacos.server-addr}
+ config:
+ # 配置中心地址
+ server-addr: ${nacos.server-addr}
+ # 配置文件格式
+ file-extension: yml
+ # 共享配置
+ shared-configs:
+ - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
+ # 程序Redis公共配置文件
+ - redis-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
+ # 程序MySQL公共配置文件
+ - mysql-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
+
+ - system-server-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
+
+fdfs:
+ so-timeout: 1500 # socket 连接时长
+ connect-timeout: 600 # 连接 tracker 服务器超时时长
+ # 这两个是你服务器的 IP 地址,注意 23000 端口也要打开,阿里云服务器记得配置安全组。tracker 要和 stroage 服务进行交流
+ tracker-list: 60.204.221.52:22122
+ web-server-url: 60.204.221.52:8888
+ pool:
+ jmx-enabled: false
+ # 生成缩略图
+ thumb-image:
+ height: 500
+ width: 500
diff --git a/modules/cloud-system/system-server/src/main/resources/mapper/UserMapper.xml b/modules/cloud-system/system-server/src/main/resources/mapper/UserMapper.xml
new file mode 100644
index 0000000..7408544
--- /dev/null
+++ b/modules/cloud-system/system-server/src/main/resources/mapper/UserMapper.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
diff --git a/modules/pom.xml b/modules/pom.xml
new file mode 100644
index 0000000..6d05e66
--- /dev/null
+++ b/modules/pom.xml
@@ -0,0 +1,24 @@
+
+
+ 4.0.0
+
+ com.muyu
+ zg6-week2
+ 1.0.0
+
+
+ modules
+ pom
+
+ cloud-system
+
+
+
+ 8
+ 8
+ UTF-8
+
+
+
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..9fb380c
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,78 @@
+
+
+ 4.0.0
+
+ com.muyu
+ zg6-week2
+ 1.0.0
+pom
+
+ cloud-common
+ cloud-gateway
+ cloud-auth
+ modules
+
+
+ 17
+ 17
+ UTF-8
+
+
+
+
+
+ spring-boot-starter-parent
+ org.springframework.boot
+ 2.7.15
+
+
+
+
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-dependencies
+ 2021.0.8
+ pom
+ import
+
+
+
+ com.alibaba.cloud
+ spring-cloud-alibaba-dependencies
+ 2021.0.5.0
+ pom
+ import
+
+
+
+ com.alibaba.nacos
+ nacos-client
+ 2.0.4
+
+
+
+ com.muyu
+ cloud-common
+ 1.0.0
+
+
+
+
+ com.muyu
+ system-common
+ 1.0.0
+
+
+
+ com.muyu
+ system-remote
+ 1.0.0
+
+
+
+