diff --git a/ningda-generator/src/main/java/com/ningdatech/generator/config/GeneratorCodeConfig.java b/ningda-generator/src/main/java/com/ningdatech/generator/config/GeneratorCodeConfig.java
index 6a1f8f7..12e7db1 100644
--- a/ningda-generator/src/main/java/com/ningdatech/generator/config/GeneratorCodeConfig.java
+++ b/ningda-generator/src/main/java/com/ningdatech/generator/config/GeneratorCodeConfig.java
@@ -8,14 +8,14 @@ import java.util.Collections;
/**
* @description: 自动生成code代码
- * @author: liushuai
- * @date: 2022/3/25 14:20
+ * @author: liuxinxin
+ * @date: 2023/01/03 09:20
*/
public class GeneratorCodeConfig {
- private static final String PATH_LXX = "/Users/liuxinxin/IdeaProjects/car_rental/ningda-car-rental-api/src/main/java";
- private static final String PATH_YYD = "/Users/wendy/code project/java/car_rental/ningda-car-rental-api/src/main/java";
- private static final String PATH_LS = "/Users/qinxianyun/Documents/qin/ningdatech/car_rental/ningda-car-rental-api/src/main/java";
+ private static final String PATH_LXX = "";
+ private static final String PATH_YYD = "";
+ private static final String PATH_LS = "";
private static final String PATH_ZPF = "";
private static final String PATH_CMM = "";
@@ -41,11 +41,11 @@ public class GeneratorCodeConfig {
// 设置父包名
builder.parent("com.ningdatech")
// 设置父包模块名
- .moduleName("rentalcar." + packageName)
+ .moduleName("pmapi." + packageName)
// 设置mapperXml生成路径
.pathInfo(Collections.singletonMap(OutputFile.mapperXml,
//设置自己的生成路径
- path + "/com/ningdatech/rentalcar/" + packageName + "/mapper"));
+ path + "/com/ningdatech/pmapi/" + packageName + "/mapper"));
})
.strategyConfig(builder -> {
builder.addTablePrefix("nd");
@@ -58,7 +58,7 @@ public class GeneratorCodeConfig {
}
public static void main(String[] args) {
- generate("Liuxinxin", "order", PATH_YYD, "nd_order_status_change");
+ generate("Liuxinxin", "null", PATH_LXX, "null");
}
}
diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/constants/BizConst.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/constants/BizConst.java
new file mode 100644
index 0000000..a4eb44c
--- /dev/null
+++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/constants/BizConst.java
@@ -0,0 +1,98 @@
+package com.ningdatech.pmapi.common.constants;
+
+import com.ningdatech.basic.model.ApiResponse;
+
+import java.math.BigDecimal;
+
+/**
+ *
+ * 业务常量
+ *
+ *
+ * @author WendyYang
+ * @since 13:42 2022/12/1
+ */
+public interface BizConst {
+
+ /**
+ * SQL查询一条
+ */
+ String LIMIT_1 = "limit 1";
+
+ String COOKIE_KEY = "ND_CAR_RENTAL_JSESSION";
+
+ /**
+ * 一小时秒数
+ **/
+ BigDecimal SECONDS_BY_HOUR = new BigDecimal(60 * 60);
+
+ /**
+ * 十分钟的毫秒数
+ */
+ long MILLS_10_MIN = 1000L * 60 * 10;
+
+ /**
+ * 中国行政区划编码
+ */
+ long ROOT_REGION_CODE = 100000L;
+
+ /**
+ * 一级行政区划数量
+ */
+ int NUM_PROVINCE = 34;
+
+ /**
+ * 默认的父id
+ */
+ long PARENT_ID = 0L;
+
+ /**
+ * 默认树层级
+ */
+ int TREE_GRADE = 0;
+
+ /**
+ * 默认的排序
+ */
+ int SORT_VALUE = 0;
+
+ /**
+ * 浙江省的region_id
+ */
+ long ZJ_REGION_CODE = 330000L;
+
+ /**
+ * 省/直辖市 level
+ */
+ int GOV_L1 = 1;
+
+ /**
+ * 市 level
+ */
+ int GOV_L2 = 2;
+
+ /**
+ * 区/县 level
+ */
+ int GOV_L3 = 3;
+
+ /**
+ * 密码正则:长度8-20位且至少包含大写字母、小写字母、数字或特殊符号中的任意三种
+ */
+ String REGEX_PASS = "^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\\W_]+$)(?![a-z0-9]+$)(?![a-z\\W_]+$)(?![0-9\\W_]+$)[a-zA-Z0-9\\W_]{8,20}$";
+
+ /**
+ * 租车费率
+ */
+ BigDecimal RATE_CAR_RENTAL = new BigDecimal("1.13");
+
+ /**
+ * 服务费率
+ */
+ BigDecimal RATE_SERVICE = new BigDecimal("0.0442");
+
+ ApiResponse UNAUTHENTICATED = ApiResponse.of(401, "用户未登录", null);
+
+ int MAX_EXPORT_COUNT = 5000;
+
+}
diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/errorcode/AppErrorCode.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/errorcode/AppErrorCode.java
new file mode 100644
index 0000000..40a8f06
--- /dev/null
+++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/errorcode/AppErrorCode.java
@@ -0,0 +1,17 @@
+package com.ningdatech.pmapi.common.errorcode;
+
+public enum AppErrorCode {
+ USER(100),
+
+ AUTH(101);
+
+ private final Integer code;
+
+ AppErrorCode(Integer code) {
+ this.code = code;
+ }
+
+ public Integer getCode() {
+ return code;
+ }
+}
diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/handler/GlobalExceptionHandler.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/handler/GlobalExceptionHandler.java
new file mode 100644
index 0000000..7cee5f1
--- /dev/null
+++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/handler/GlobalExceptionHandler.java
@@ -0,0 +1,62 @@
+package com.ningdatech.pmapi.common.handler;
+
+import com.ningdatech.basic.enumeration.Status;
+import com.ningdatech.basic.model.ApiResponse;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.context.support.DefaultMessageSourceResolvable;
+import org.springframework.http.HttpStatus;
+import org.springframework.validation.BindException;
+import org.springframework.web.bind.MethodArgumentNotValidException;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.servlet.NoHandlerFoundException;
+
+import javax.validation.ConstraintViolation;
+import javax.validation.ConstraintViolationException;
+import java.util.stream.Collectors;
+
+/**
+ * @description: 统一错误处理
+ * @author: liuxinxin
+ * @date: 2023/01/03 11:39
+ */
+@Slf4j
+@ControllerAdvice
+@ResponseStatus(HttpStatus.BAD_REQUEST)
+public class GlobalExceptionHandler {
+
+ @ResponseBody
+ @ExceptionHandler(value = NoHandlerFoundException.class)
+ public ApiResponse noHandlerFoundException(NoHandlerFoundException e) {
+ log.error("【全局异常拦截】NoHandlerFoundException: 请求方法 {}, 请求路径 {}", e.getRequestURL(), e.getHttpMethod());
+ return ApiResponse.ofStatus(Status.REQUEST_NOT_FOUND);
+ }
+
+ @ResponseBody
+ @ExceptionHandler(value = {MethodArgumentNotValidException.class, BindException.class})
+ public ApiResponse bindException(BindException e) {
+ String msg = e.getAllErrors().stream()
+ .map(DefaultMessageSourceResolvable::getDefaultMessage)
+ .collect(Collectors.joining(","));
+ return ApiResponse.of(Status.BAD_REQUEST.getCode(), msg, null);
+ }
+
+ @ResponseBody
+ @ExceptionHandler(value = ConstraintViolationException.class)
+ public ApiResponse constraintViolationException(ConstraintViolationException e) {
+ String msg = e.getConstraintViolations().stream()
+ .map(ConstraintViolation::getMessage)
+ .collect(Collectors.joining(","));
+ return ApiResponse.of(Status.BAD_REQUEST.getCode(), msg, null);
+ }
+
+ @ResponseBody
+ @ExceptionHandler(value = Exception.class)
+ public ApiResponse handlerException(Exception e) {
+ log.error("【全局异常拦截】: 异常信息 {}: {} ", e.getClass().getSimpleName(), e);
+ return ApiResponse.of(Status.BAD_REQUEST.getCode(), e.getMessage(), null);
+ }
+
+}
diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/handler/GlobalResponseHandler.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/handler/GlobalResponseHandler.java
new file mode 100644
index 0000000..d361210
--- /dev/null
+++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/handler/GlobalResponseHandler.java
@@ -0,0 +1,56 @@
+package com.ningdatech.pmapi.common.handler;
+
+import cn.hutool.json.JSONUtil;
+import com.ningdatech.basic.model.ApiResponse;
+import org.springframework.core.MethodParameter;
+import org.springframework.http.MediaType;
+import org.springframework.http.converter.HttpMessageConverter;
+import org.springframework.http.server.ServerHttpRequest;
+import org.springframework.http.server.ServerHttpResponse;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.RestControllerAdvice;
+import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
+
+/**
+ * @Author liuxinxin
+ * @Date 2021/7/21 11:26
+ * @Version 1.0
+ **/
+@RestControllerAdvice(basePackages = {})
+public class GlobalResponseHandler implements ResponseBodyAdvice