PlatformCityFeePlanController.java
2.92 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
71
72
package com.diligrp.rider.controller;
import com.diligrp.rider.common.result.Result;
import com.diligrp.rider.dto.DeliveryFeePlanPreviewDTO;
import com.diligrp.rider.dto.DeliveryFeePlanSaveDTO;
import com.diligrp.rider.service.DeliveryFeePlanService;
import com.diligrp.rider.vo.DeliveryFeePlanDetailVO;
import com.diligrp.rider.vo.DeliveryFeePlanVO;
import com.diligrp.rider.vo.DeliveryFeeResultVO;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/api/platform/city")
@RequiredArgsConstructor
public class PlatformCityFeePlanController {
private final DeliveryFeePlanService deliveryFeePlanService;
@GetMapping("/{cityId}/fee-plans")
public Result<List<DeliveryFeePlanVO>> listPlans(@PathVariable Long cityId) {
return Result.success(deliveryFeePlanService.listPlans(cityId));
}
@GetMapping("/{cityId}/fee-plans/{planId}")
public Result<DeliveryFeePlanDetailVO> getPlanDetail(@PathVariable Long cityId, @PathVariable Long planId) {
return Result.success(deliveryFeePlanService.getPlanDetail(cityId, planId));
}
@PostMapping("/{cityId}/fee-plans")
public Result<Long> createPlan(@PathVariable Long cityId, @RequestBody DeliveryFeePlanSaveDTO dto) {
return Result.success(deliveryFeePlanService.createPlan(cityId, dto));
}
@PostMapping("/{cityId}/fee-plans/init-default")
public Result<Long> initializeDefaultPlan(@PathVariable Long cityId) {
return Result.success(deliveryFeePlanService.initializeDefaultPlan(cityId));
}
@PutMapping("/{cityId}/fee-plans/{planId}")
public Result<Void> updatePlan(@PathVariable Long cityId,
@PathVariable Long planId,
@RequestBody DeliveryFeePlanSaveDTO dto) {
deliveryFeePlanService.updatePlan(cityId, planId, dto);
return Result.success();
}
@PostMapping("/{cityId}/fee-plans/{planId}/copy")
public Result<Long> copyPlan(@PathVariable Long cityId, @PathVariable Long planId) {
return Result.success(deliveryFeePlanService.copyPlan(cityId, planId));
}
@PostMapping("/{cityId}/fee-plans/{planId}/default")
public Result<Void> setDefaultPlan(@PathVariable Long cityId, @PathVariable Long planId) {
deliveryFeePlanService.setDefaultPlan(cityId, planId);
return Result.success();
}
@DeleteMapping("/{cityId}/fee-plans/{planId}")
public Result<Void> deletePlan(@PathVariable Long cityId, @PathVariable Long planId) {
deliveryFeePlanService.deletePlan(cityId, planId);
return Result.success();
}
@PostMapping("/{cityId}/fee-plans/preview")
public Result<DeliveryFeeResultVO> preview(@PathVariable Long cityId,
@RequestBody DeliveryFeePlanPreviewDTO dto) {
return Result.success(deliveryFeePlanService.preview(cityId, dto));
}
}