| | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.shardingsphere.transaction.annotation.ShardingSphereTransactionType; |
| | | import org.apache.shardingsphere.transaction.core.TransactionType; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.validation.annotation.Validated; |
| | |
| | | /** |
| | | * 新增点位 |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @PostMapping("/addPoint") |
| | | @ResponseBody |
| | | @Transactional |
| | | @ShardingSphereTransactionType(TransactionType.BASE) |
| | | @ApiOperation(value = "新增点位") |
| | | public R add(@Validated @RequestBody PointAddDto pointAddDto) { |
| | | XpPoint xpPoint = new XpPoint(); |
| | |
| | | @GetMapping("/deletePoint") |
| | | @ResponseBody |
| | | @ApiOperation(value = "删除点位") |
| | | @Transactional |
| | | @ShardingSphereTransactionType(TransactionType.BASE) |
| | | public R deletePoint(@RequestParam("ids") String ids) { |
| | | xpPointService.removeBatchByIds(Arrays.stream(ids.split(",")).map(Long::parseLong).collect(Collectors.toList())); |
| | | return R.ok(); |
| | |
| | | */ |
| | | @PostMapping("/editPoint") |
| | | @ApiOperation(value = "编辑点位") |
| | | @Transactional |
| | | @ShardingSphereTransactionType(TransactionType.BASE) |
| | | public R edit(@Validated@RequestBody PointUpdateDto pointAddDto) { |
| | | XpPoint xpPoint = new XpPoint(); |
| | | BeanUtils.copyProperties(pointAddDto, xpPoint); |
| | |
| | | */ |
| | | @PostMapping("/enableDisablePoint") |
| | | @ApiOperation(value = "启用/禁用") |
| | | @Transactional |
| | | @ShardingSphereTransactionType(TransactionType.BASE) |
| | | public R enableDisable(@RequestBody XpPointEnableDisableDto dto) { |
| | | XpPoint xpPoint = xpPointService.getById(dto.getId()); |
| | | xpPoint.setOperationStatus(dto.getOperationStatus()); |
| | |
| | | * 设置特殊点位 |
| | | */ |
| | | @PostMapping("/setSpecialPoint") |
| | | @ApiOperation(value = "设置特殊点位") |
| | | @ApiOperation(value = "设置特殊点位",tags = "后台管理-特殊点位") |
| | | public R setSpecialPoint(@RequestBody XpPointSpecialDto dto) { |
| | | xpPointService.update(new LambdaUpdateWrapper<XpPoint>().set(XpPoint::getChargePoint, 0).set(XpPoint::getParkingPoint,0)); |
| | | xpPointService.update(new LambdaUpdateWrapper<XpPoint>().in(XpPoint::getId,dto.getChargePoints()).set(XpPoint::getChargePoint,1)); |