Jiaqi Xia

Merge branch 'hotfix/resubmit-issue' into 'master'

fix: disable methodAutoUnlock for RepeatSubmit on create order/diner/mealorder e…

…ndpoints to prevent resubmit issues

See merge request !9
......@@ -38,7 +38,8 @@ public class RepeatSubmitAspect {
final var lockKey = getLockKey(joinPoint);
final var lock = redissonClient.getLock(lockKey);
try {
if (lock.tryLock(requestLock.expire(), requestLock.timeUnit())) {
// 立即尝试获取锁,如果获取到则设置持有时间
if (lock.tryLock(0, requestLock.expire(), requestLock.timeUnit())) {
return joinPoint.proceed();
} else {
log.error("Failed to acquire lock for method: {}", method.getName());
......
......@@ -53,7 +53,7 @@ public class DinerController {
@ApiOperation(value = "添加就餐人")
@PutMapping("/mpaccount/diner")
@RepeatSubmit(prefix = "create.diner", isLockByLoginUser = false)
@RepeatSubmit(prefix = "create.diner", isLockByLoginUser = false, methodAutoUnlock = false)
@ResponseStatus(HttpStatus.CREATED)
public CreatedResult<DinerVO> createMpAccountDiner(@RequestBody @Valid final DinerDTO.CreateDinerDTO createDinerDTO) {
return dinerService.createMpAccountDiner(createDinerDTO);
......
......@@ -11,7 +11,6 @@ import com.infoloop.tianting.model.vo.MealOrderVO;
import com.infoloop.tianting.service.MealOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -22,7 +21,6 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
......@@ -50,7 +48,7 @@ public class MealOrderController {
@ApiOperation(value = "立即订餐")
@PutMapping("/mealorder")
@RepeatSubmit(prefix = "create.meal.order", isLockByLoginUser = false)
@RepeatSubmit(prefix = "create.meal.order", isLockByLoginUser = false, methodAutoUnlock = false)
@ResponseStatus(HttpStatus.CREATED)
public CreatedResult<MealOrderVO> createMealOrder(@RequestBody @Valid final MealOrderDTO.CreateMealOrderDTO createMealOrderDTO) {
return mealOrderService.createMealOrder(createMealOrderDTO);
......
......@@ -68,7 +68,7 @@ public class OrderController {
@ApiOperation(value = "小程序创建订单")
@PostMapping("/orders")
@ResponseStatus(HttpStatus.OK)
@RepeatSubmit(prefix = "createOrder", isLockByLoginUser = false)
@RepeatSubmit(prefix = "createOrder", isLockByLoginUser = false, methodAutoUnlock = false)
public CreateOrderResponse createOrder(@Valid @RequestBody CreateOrderDto createOrderDto) {
return orderService.createOrder(createOrderDto);
}
......@@ -76,7 +76,7 @@ public class OrderController {
@ApiOperation(value = "院区端创建订单")
@PostMapping("/operator/orders")
@ResponseStatus(HttpStatus.OK)
@RepeatSubmit(prefix = "createOrder", isLockByLoginUser = false)
@RepeatSubmit(prefix = "createOrder", isLockByLoginUser = false, methodAutoUnlock = false)
public CreateOrderResponse createOrderByOperator(@Valid @RequestBody OrderDbDTO.OperatorCreateOrderDto createOrderDto) {
return orderService.orderCreation(createOrderDto);
}
......