package com.sandu.ximon.admin.controller; import com.sandu.common.domain.ResponseVO; import com.sandu.common.execption.BusinessException; import com.sandu.common.util.ResponseUtil; import com.sandu.ximon.admin.service.C3mChargingChargeService; import com.sandu.ximon.dao.domain.C3mChargingCharge; import lombok.AllArgsConstructor; import org.springframework.web.bind.annotation.*; import java.util.List; /** * @Author liuhaonan * @Date 2022/3/18 15:58 * @Version 1.0 * 充电桩费率相关 */ @RestController @AllArgsConstructor @RequestMapping("/v1/c3mChargingCharge") public class C3mChargingChargeController { private final C3mChargingChargeService chargeService; /** * 编辑充电桩费率 * * @param chargeEntities * @return */ @PostMapping("/updateC3mCharging") public ResponseVO updateC3mCharging(@RequestBody List chargeEntities) { if (chargeEntities.size() > 5) { throw new BusinessException("当前最高仅支持4组费率"); } if (chargeEntities.size() == 0) { throw new BusinessException("最少需要一条费率"); } return ResponseUtil.success(chargeService.updateCharge(chargeEntities)); } @GetMapping("/getChargeByC3Id/{c3mId}") public ResponseVO getChargeByC3Id(@PathVariable Integer c3mId) { return ResponseUtil.success(chargeService.getChargeByC3Id(c3mId)); } @GetMapping("/getChargeByPoleId/{PoleId}") public ResponseVO getChargeByPoleId(@PathVariable Long PoleId) { return ResponseUtil.success(chargeService.getChargeByPoleId(PoleId)); } /** * 根据充电桩mac获取当前时间段的费率 */ @GetMapping("/getChargeByMac/{mac}") public ResponseVO getChargeByMac(@PathVariable Long mac, Integer power) { return ResponseUtil.success(chargeService.getCostByC3id(mac, power)); } }