记得上下班打卡 | git大法好,push需谨慎

Commit 50255531 authored by 胡佳晨's avatar 胡佳晨

修改 参数验证 config-dev的rabbitmq

parent 88f7224c
package com.liquidnet.service.kylin.dto.param;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
......@@ -9,6 +10,7 @@ import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.util.List;
@Api
@Data
public class PayOrderParam {
@ApiModelProperty(value = "演出id")
......
......@@ -39,6 +39,7 @@ public enum ErrorCode implements ServiceErrorCode {
REDIRECT("-1",""),
SUCCESS("0",""),
ERROR("1",""),
HTTP_PARAM_ERROR("2", "Param error"),
HTTP_SYSTEM_ERROR("50000", "System busy, please try again later"),
;
......
......@@ -16,6 +16,10 @@
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</dependency>
</dependencies>
......
......@@ -17,6 +17,8 @@ import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.WebRequest;
import javax.validation.ConstraintViolationException;
/**
* @author AnJiabin <jiabin.an@lightnet.io>
* @version V1.0
......@@ -34,6 +36,12 @@ public class RestControllerAdviceHandler {
@ResponseBody
public ResponseEntity serviceExceptionHandler(Exception rex, WebRequest request) {
logger.error("serviceExceptionHandler request:{},param:{}", request.getContextPath(), JSON.toJSONString(request.getParameterMap()));
if (rex instanceof ConstraintViolationException) {
ConstraintViolationException ygex = ((ConstraintViolationException) rex);
String message = ygex.getMessage().split("\\.")[1];
logger.error("LiquidnetServiceException errorCode:{} error : {}", ErrorCode.HTTP_PARAM_ERROR.getCode(), ygex.getMessage());
return new ResponseEntity<Error>(new Error(ErrorCode.HTTP_PARAM_ERROR.getCode(), message), HttpStatus.OK);
}
if (rex instanceof LiquidnetFeignException) {
LiquidnetFeignException ygex = ((LiquidnetFeignException) rex);
String errorCode = ygex.errorCode().getCode();
......
package com.liquidnet.common.exception;
import com.liquidnet.common.exception.entity.Error;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.BindException;
import org.springframework.validation.BindingResult;
import org.springframework.validation.ObjectError;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import java.util.List;
@RestControllerAdvice
public class ValidControllerAdviceHandler {
@ExceptionHandler(BindException.class)
@ResponseBody
public ResponseEntity<Error> handleBindException(Exception e) {
//打印校验住的所有的错误信息
StringBuilder sb = new StringBuilder("参数错误:[");
List<ObjectError> list = ((BindException) e).getAllErrors();
for (ObjectError item : list) {
sb.append(item.getDefaultMessage()).append(',');
}
sb.deleteCharAt(sb.length() - 1);
sb.append(']');
String msg = sb.toString();
return new ResponseEntity<Error>(new Error("400", msg), HttpStatus.OK);
}
}
......@@ -15,7 +15,7 @@ liquidnet:
username: testmall
password: zhengzai!mYT
rabbitmq:
host: 127.0.0.1
host: https://rabbitmq.zhengzai.tv/#/
port: 5672
username: admin
password: admin
......
......@@ -514,68 +514,6 @@ CREATE TABLE `kylin_order_ticket_entities`
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4 COMMENT '订单详情';
# -- 订单退款 <初步>
#
drop TABLE if exists `kylin_order_tickets_refund`;
#
CREATE TABLE `kylin_order_tickets_refund`
#
(
# `mid` int
(
10
) unsigned NOT NULL AUTO_INCREMENT,
# `order_tickets_refund_id` varchar
(
255
) NOT NULL DEFAULT '' COMMENT 'order_tickets_refund_id',
# `order_id` varchar
(
255
) NOT NULL DEFAULT '' COMMENT '订单id',
# `reason` varchar
(
255
) NOT NULL DEFAULT '' COMMENT '退款原因',
# `refund_type` varchar
(
10
) NOT NULL DEFAULT '' COMMENT '退款类型 票ticket,快递express',
# `order_ticket_entities_id` varchar
(
255
) NOT NULL DEFAULT '' COMMENT '入场人id',
# `refund_status` tinyint NOT NULL DEFAULT 0 COMMENT '1完成退款,2关闭或者取消退款,3正在退款,4已退款',
# `refund_price` decimal
(
8,
2
) NOT NULL DEFAULT '0.00' COMMENT '退款金额',
# `coupon_type` varchar
(
10
) NOT NULL DEFAULT '' COMMENT '优惠券类型',
# `coupon_id` varchar
(
255
) NOT NULL DEFAULT '' COMMENT '优惠券id',
# `comment` varchar
(
255
) NOT NULL DEFAULT '' COMMENT 'comment',
# `created_at` datetime NULL DEFAULT NULL COMMENT '创建时间',
# `updated_at` datetime NULL DEFAULT NULL COMMENT '修改时间',
# KEY `kylin_order_tickets_refund_uid_index`
(
`order_tickets_refund_id`
),
# PRIMARY KEY
(
`mid`
)
# ) ENGINE = InnoDB
# DEFAULT CHARSET = utf8mb4 COMMENT '订单退款';
-- 购票须知表
drop TABLE if exists `kylin_buy_notice`;
CREATE TABLE `kylin_buy_notice`
......
......@@ -14,6 +14,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
......@@ -33,6 +34,7 @@ import java.util.List;
@Api(tags = "前端-订单相关")
@RestController
@RequestMapping("order")
@Validated
public class KylinOrderTicketsController {
@Autowired
......@@ -62,15 +64,15 @@ public class KylinOrderTicketsController {
@GetMapping("list")
@ApiOperation("订单列表")
@ApiResponse(code = 200, message = "接口返回对象参数")
public ResponseDto<PageInfo<List<KylinOrderListVo>>> orderList(@RequestParam("page") @NotNull @Min(1) int page,
@RequestParam("size") @NotNull @Min(1) int size) {
public ResponseDto<PageInfo<List<KylinOrderListVo>>> orderList(@RequestParam("page") @NotNull @Min(1) int page,
@RequestParam("size") @NotNull @Min(1) int size) {
return ResponseDto.success(orderTicketsService.orderList(page,size));
}
@GetMapping("details")
@ApiOperation("订单详情")
@ApiResponse(code = 200, message = "接口返回对象参数")
public ResponseDto<OrderDetailsVo> orderDetails(@RequestParam("orderId") @NotNull String orderId) {
public ResponseDto<OrderDetailsVo> orderDetails(@RequestParam(value = "orderId",required = false) @NotNull(message = "订单id不能为空") String orderId) {
return ResponseDto.success(orderTicketsService.orderDetails(orderId));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment