diff --git a/pom.xml b/pom.xml
index 3649477..97e017e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -30,6 +30,7 @@
17
+
org.springframework.boot
spring-boot-starter-web
@@ -39,7 +40,7 @@
mybatis-spring-boot-starter
3.0.3
-
+
com.mysql
mysql-connector-j
@@ -55,12 +56,54 @@
spring-boot-starter-test
test
+
org.mybatis.spring.boot
mybatis-spring-boot-starter-test
3.0.3
test
+
+
+ com.github.wechatpay-apiv3
+ wechatpay-java
+ 0.2.12
+
+
+ com.github.wechatpay-apiv3
+ wechatpay-apache-httpclient
+ 0.4.9
+
+
+
+ com.github.binarywang
+ wx-java-miniapp-spring-boot-starter
+ 4.4.0
+
+
+
+ com.huaweicloud
+ esdk-obs-java
+ 3.21.8
+
+
+
+ com.github.xiaoymin
+ knife4j-openapi3-jakarta-spring-boot-starter
+ 4.4.0
+
+
+
+ junit
+ junit
+ 4.13.2
+
+
+
+ com.baomidou
+ mybatis-plus-spring-boot3-starter
+ 3.5.5
+
diff --git a/src/main/java/com/cultural/heritage/config/CorsConfig.java b/src/main/java/com/cultural/heritage/config/CorsConfig.java
new file mode 100644
index 0000000..354441a
--- /dev/null
+++ b/src/main/java/com/cultural/heritage/config/CorsConfig.java
@@ -0,0 +1,32 @@
+package com.cultural.heritage.config;
+
+import org.springframework.boot.web.servlet.FilterRegistrationBean;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.Ordered;
+import org.springframework.web.cors.CorsConfiguration;
+import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
+import org.springframework.web.filter.CorsFilter;
+
+/**
+ * 跨域配置
+ */
+@Configuration
+public class CorsConfig {
+
+ @Bean
+ public FilterRegistrationBean corsFilter() {
+ UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
+ CorsConfiguration config = new CorsConfiguration();
+ // 携带cookie
+ config.setAllowCredentials(true);
+ // 放行哪些域名(必须用 patterns,否则 * 会和 allowCredentials 冲突)
+ config.addAllowedOriginPattern("*");
+ config.addAllowedHeader("*");
+ config.addAllowedMethod("*");
+ source.registerCorsConfiguration("/**", config);
+ FilterRegistrationBean bean = new FilterRegistrationBean<>(new CorsFilter(source));
+ bean.setOrder(Ordered.HIGHEST_PRECEDENCE);
+ return bean;
+ }
+}
diff --git a/src/main/java/com/cultural/heritage/config/HweiOBSConfig.java b/src/main/java/com/cultural/heritage/config/HweiOBSConfig.java
new file mode 100644
index 0000000..ae4a740
--- /dev/null
+++ b/src/main/java/com/cultural/heritage/config/HweiOBSConfig.java
@@ -0,0 +1,70 @@
+package com.cultural.heritage.config;
+
+import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import lombok.Data;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Configuration;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+@Data
+@Configuration
+public class HweiOBSConfig {
+
+
+ /**
+ * 访问密钥AK
+ */
+ @Value("${hwyun.obs.accessKey}")
+ private String accessKey;
+
+ /**
+ * 访问密钥SK
+ */
+ @Value("${hwyun.obs.securityKey}")
+ private String securityKey;
+
+ /**
+ * 终端节点
+ */
+ @Value("${hwyun.obs.endPoint}")
+ private String endPoint;
+
+ /**
+ * 桶
+ */
+ @Value("${hwyun.obs.bucketName}")
+ private String bucketName;
+
+ /**
+ * @Description 获取OBS客户端实例
+ * @return: com.obs.services.ObsClient
+ */
+ public ObsClient getInstance() {
+ return new ObsClient(accessKey, securityKey, endPoint);
+ }
+
+ /**
+ * @Description 销毁OBS客户端实例
+ * @param: obsClient
+ */
+ public void destroy(ObsClient obsClient){
+ try {
+ obsClient.close();
+ } catch (ObsException e) {
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * @Description 微服务文件存放路径
+ * @return: java.lang.String
+ */
+ public static String getObjectKey() {
+ // 项目或者服务名称 + 日期存储方式
+ return "Hwei" + "/" + new SimpleDateFormat("yyyy-MM-dd").format(new Date() )+ "/";
+ }
+}
+
diff --git a/src/main/java/com/cultural/heritage/config/Knife4jConfig.java b/src/main/java/com/cultural/heritage/config/Knife4jConfig.java
new file mode 100644
index 0000000..1458092
--- /dev/null
+++ b/src/main/java/com/cultural/heritage/config/Knife4jConfig.java
@@ -0,0 +1,27 @@
+package com.cultural.heritage.config;
+
+import io.swagger.v3.oas.models.OpenAPI;
+import io.swagger.v3.oas.models.info.Info;
+import io.swagger.v3.oas.models.info.License;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * Knife4j 接口文档配置
+ * 官网地址
+ */
+@Configuration
+public class Knife4jConfig {
+
+ @Bean
+ public OpenAPI customOpenAPI() {
+ return new OpenAPI()
+ .info(new Info()
+ .title("碳索生活接口文档")
+ .version("1.0")
+ .description("碳索生活接口文档")
+ .termsOfService("http://doc.xiaominfo.com")
+ .license(new License().name("Apache 2.0")
+ .url("http://doc.xiaominfo.com")));
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/cultural/heritage/config/MyBatisPlusConfig.java b/src/main/java/com/cultural/heritage/config/MyBatisPlusConfig.java
new file mode 100644
index 0000000..f495c30
--- /dev/null
+++ b/src/main/java/com/cultural/heritage/config/MyBatisPlusConfig.java
@@ -0,0 +1,27 @@
+package com.cultural.heritage.config;
+
+import com.baomidou.mybatisplus.annotation.DbType;
+import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
+import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * MyBatis Plus 配置
+ */
+@Configuration
+@MapperScan("com.xuande.takeaway.mapper")
+public class MyBatisPlusConfig {
+
+ /**
+ * 拦截器配置
+ */
+ @Bean
+ public MybatisPlusInterceptor mybatisPlusInterceptor() {
+ MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
+ // 分页插件
+ interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
+ return interceptor;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/cultural/heritage/exception/BusinessException.java b/src/main/java/com/cultural/heritage/exception/BusinessException.java
new file mode 100644
index 0000000..7610f1c
--- /dev/null
+++ b/src/main/java/com/cultural/heritage/exception/BusinessException.java
@@ -0,0 +1,35 @@
+package com.cultural.heritage.exception;
+
+
+import com.cultural.heritage.common.ErrorCode;
+
+/**
+ * 自定义异常类
+ */
+@SuppressWarnings("all")
+public class BusinessException extends RuntimeException {
+
+ /**
+ * 错误码
+ */
+ private final int code;
+
+ public BusinessException(int code, String message) {
+ super(message);
+ this.code = code;
+ }
+
+ public BusinessException(ErrorCode errorCode) {
+ super(errorCode.getMessage());
+ this.code = errorCode.getCode();
+ }
+
+ public BusinessException(ErrorCode errorCode, String message) {
+ super(message);
+ this.code = errorCode.getCode();
+ }
+
+ public int getCode() {
+ return code;
+ }
+}
diff --git a/src/main/java/com/cultural/heritage/exception/GlobalExceptionHandler.java b/src/main/java/com/cultural/heritage/exception/GlobalExceptionHandler.java
new file mode 100644
index 0000000..60c77cc
--- /dev/null
+++ b/src/main/java/com/cultural/heritage/exception/GlobalExceptionHandler.java
@@ -0,0 +1,28 @@
+package com.cultural.heritage.exception;
+
+import com.cultural.heritage.common.BaseResponse;
+import com.cultural.heritage.common.ErrorCode;
+import com.cultural.heritage.common.ResultUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.RestControllerAdvice;
+
+/**
+ * 全局异常处理器
+ */
+@Slf4j
+@RestControllerAdvice
+public class GlobalExceptionHandler {
+
+ @ExceptionHandler(BusinessException.class)
+ public BaseResponse> businessExceptionHandler(BusinessException e) {
+ log.error("BusinessException", e);
+ return ResultUtils.error(e.getCode(), e.getMessage());
+ }
+
+ @ExceptionHandler(RuntimeException.class)
+ public BaseResponse> runtimeExceptionHandler(RuntimeException e) {
+ log.error("RuntimeException", e);
+ return ResultUtils.error(ErrorCode.SYSTEM_ERROR, "系统错误");
+ }
+}
diff --git a/src/main/java/com/cultural/heritage/exception/ThrowUtils.java b/src/main/java/com/cultural/heritage/exception/ThrowUtils.java
new file mode 100644
index 0000000..d2c24b8
--- /dev/null
+++ b/src/main/java/com/cultural/heritage/exception/ThrowUtils.java
@@ -0,0 +1,44 @@
+package com.cultural.heritage.exception;
+
+
+import com.cultural.heritage.common.ErrorCode;
+
+/**
+ * 抛异常工具类
+ */
+@SuppressWarnings("all")
+public class ThrowUtils {
+
+ /**
+ * 条件成立则抛异常
+ *
+ * @param condition 条件
+ * @param runtimeException 运行时异常
+ */
+ public static void throwIf(boolean condition, RuntimeException runtimeException) {
+ if (condition) {
+ throw runtimeException;
+ }
+ }
+
+ /**
+ * 条件成立则抛异常
+ *
+ * @param condition 条件
+ * @param errorCode 自定义异常
+ */
+ public static void throwIf(boolean condition, ErrorCode errorCode) {
+ throwIf(condition, new BusinessException(errorCode));
+ }
+
+ /**
+ * 条件成立则抛异常
+ *
+ * @param condition 条件
+ * @param errorCode 自定义异常
+ * @param message 报错信息
+ */
+ public static void throwIf(boolean condition, ErrorCode errorCode, String message) {
+ throwIf(condition, new BusinessException(errorCode, message));
+ }
+}