MealOrderController.java
2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package com.infoloop.tianting.controller;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.infoloop.tianting.annotation.RepeatSubmit;
import com.infoloop.tianting.mealorderservice.SingleMealOrderRpcResponse;
import com.infoloop.tianting.model.common.CreatedResult;
import com.infoloop.tianting.model.dto.MealOrderDTO;
import com.infoloop.tianting.model.vo.DeliveryRuleVO;
import com.infoloop.tianting.model.vo.MealOrderVO;
import com.infoloop.tianting.service.MealOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
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.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import java.util.List;
import static com.infoloop.tianting.constant.PathVariableResourceConstants.INJECTED_MEAL_ORDER;
@Api(tags = "订餐")
@ApiSupport(order = -1)
@Slf4j
@Validated
@RestController
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class MealOrderController {
private final MealOrderService mealOrderService;
@ApiOperation(value = "订餐记录")
@PostMapping("/mealorders")
@ResponseStatus(HttpStatus.OK)
public List<MealOrderVO> queryMealOrders(@RequestBody @Valid final MealOrderDTO.QueryMealOrderDTO queryMealOrderDTO) {
return mealOrderService.queryMealOrders(queryMealOrderDTO);
}
@ApiOperation(value = "立即订餐")
@PutMapping("/mealorder")
@RepeatSubmit(prefix = "create.meal.order", isLockByLoginUser = false)
@ResponseStatus(HttpStatus.CREATED)
public CreatedResult<MealOrderVO> createMealOrder(@RequestBody @Valid final MealOrderDTO.CreateMealOrderDTO createMealOrderDTO) {
return mealOrderService.createMealOrder(createMealOrderDTO);
}
@ApiOperation(value = "订餐记录详情")
@GetMapping("/mealorder/{mealOrderId}")
@ResponseStatus(HttpStatus.OK)
public MealOrderVO getMealOrderById(@RequestAttribute(INJECTED_MEAL_ORDER) final SingleMealOrderRpcResponse mealOrder) {
return mealOrderService.getMealOrderById(mealOrder);
}
@ApiOperation(value = "订餐规则")
@GetMapping("/deliveryrule")
@ResponseStatus(HttpStatus.OK)
public DeliveryRuleVO getDeliveryRule() {
return mealOrderService.getDeliveryRule();
}
}