package com.ruoyi.chargingPile.controller; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.ruoyi.chargingPile.api.model.TCarport; import com.ruoyi.chargingPile.api.model.TVehicleRamp; import com.ruoyi.chargingPile.api.vo.TCarportVO; import com.ruoyi.chargingPile.service.TCarportService; import com.ruoyi.chargingPile.service.TVehicleRampService; import com.ruoyi.common.core.web.domain.AjaxResult; import com.ruoyi.common.core.web.domain.BaseDelete; import com.ruoyi.common.log.annotation.Log; import com.ruoyi.common.log.enums.BusinessType; import com.ruoyi.common.log.enums.OperatorType; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.Arrays; import java.util.List; /** *

* 车库 前端控制器 *

* * @author xiaochen * @since 2024-08-06 */ @Api(tags = "车库") @RestController @RequestMapping("/t-carport") public class TCarportController { private final TCarportService carportService; private final TVehicleRampService vehicleRampService; @Autowired public TCarportController(TCarportService carportService, TVehicleRampService vehicleRampService) { this.carportService = carportService; this.vehicleRampService = vehicleRampService; } /** * 通过停车场id查询车库及车道信息 */ @ApiOperation(tags = {"后台-车库"},value = "通过停车场id查询车库及车道信息") @GetMapping(value = "/queryCarportByParkId") public AjaxResult> queryCarportByParkId(@RequestParam(value = "parkingLotId", required = true) Integer parkingLotId) { return AjaxResult.ok(carportService.queryCarportByParkId(parkingLotId)); } /** * 添加车库管理 */ @Log(title = "【车库】添加车库", businessType = BusinessType.INSERT) @ApiOperation(tags = {"后台-车库"},value = "添加车库") @PostMapping(value = "/add") public AjaxResult add(@RequestBody TCarport dto) { return AjaxResult.ok(carportService.save(dto)); } /** * 修改车库 */ @Log(title = "【车库】修改车库", businessType = BusinessType.UPDATE,operatorType = OperatorType.MANAGE) @ApiOperation(tags = {"后台-车库"},value = "修改车库") @PostMapping(value = "/update") public AjaxResult update(@RequestBody TCarport dto) { return AjaxResult.ok(carportService.updateById(dto)); } /** * 查看车库详情 */ @ApiOperation(tags = {"后台-车库"},value = "查看车库详情") @GetMapping(value = "/getDetailById") public AjaxResult getDetailById(@RequestParam("id") Integer id) { return AjaxResult.ok(carportService.getById(id)); } /** * 删除车库 */ @Log(title = "【车库】删除车库", businessType = BusinessType.DELETE,operatorType = OperatorType.MANAGE) @ApiOperation(tags = {"后台-车库"},value = "删除车库") @DeleteMapping(value = "/deleteById") public AjaxResult deleteById(@RequestParam("id") Integer id) { // 刪除车道信息 vehicleRampService.remove(Wrappers.lambdaQuery(TVehicleRamp.class) .eq(TVehicleRamp::getCarportId, id)); return AjaxResult.ok(carportService.removeById(id)); } /** * 批量删除车库 */ @Log(title = "【车库】批量删除车库", businessType = BusinessType.DELETE,operatorType = OperatorType.MANAGE) @ApiOperation(tags = {"后台-车库"},value = "批量删除车库") @DeleteMapping(value = "/deleteByIds") public AjaxResult deleteByIds(@RequestParam String ids) { String[] split = ids.split(","); // 刪除车道信息 vehicleRampService.remove(Wrappers.lambdaQuery(TVehicleRamp.class) .in(TVehicleRamp::getCarportId, Arrays.asList(split))); return AjaxResult.ok(carportService.removeByIds(Arrays.asList(split))); } }