package com.by4cloud.platformx.device.controller;
|
|
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.ArrayUtil;
|
import cn.hutool.core.collection.CollUtil;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.by4cloud.platformx.common.core.util.R;
|
import com.by4cloud.platformx.common.log.annotation.SysLog;
|
import com.by4cloud.platformx.device.entity.DeviceLeasingLedgerItem;
|
import com.by4cloud.platformx.device.service.DeviceLeasingLedgerItemService;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
import com.by4cloud.platformx.common.excel.annotation.ResponseExcel;
|
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
import org.springdoc.api.annotations.ParameterObject;
|
import org.springframework.http.HttpHeaders;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.Operation;
|
import lombok.RequiredArgsConstructor;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.util.List;
|
import java.util.Objects;
|
|
/**
|
* 设备租赁台账明细
|
*
|
* @author syt
|
* @date 2025-03-27 09:33:07
|
*/
|
@RestController
|
@RequiredArgsConstructor
|
@RequestMapping("/deviceLeasingLedgerItem" )
|
@Tag(description = "deviceLeasingLedgerItem" , name = "设备租赁台账明细管理" )
|
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
public class DeviceLeasingLedgerItemController {
|
|
private final DeviceLeasingLedgerItemService deviceLeasingLedgerItemService;
|
|
/**
|
* 分页查询
|
* @param page 分页对象
|
* @param deviceLeasingLedgerItem 设备租赁台账明细
|
* @return
|
*/
|
@Operation(summary = "分页查询" , description = "分页查询" )
|
@GetMapping("/page" )
|
@PreAuthorize("@pms.hasPermission('device_deviceLeasingLedgerItem_view')" )
|
public R getDeviceLeasingLedgerItemPage(@ParameterObject Page page, @ParameterObject DeviceLeasingLedgerItem deviceLeasingLedgerItem) {
|
LambdaQueryWrapper<DeviceLeasingLedgerItem> wrapper = Wrappers.lambdaQuery();
|
wrapper.eq(deviceLeasingLedgerItem.getLedgerId()!=null,DeviceLeasingLedgerItem::getLedgerId,deviceLeasingLedgerItem.getLedgerId());
|
wrapper.eq(StrUtil.isNotBlank(deviceLeasingLedgerItem.getDeviceCode()),DeviceLeasingLedgerItem::getDeviceCode,deviceLeasingLedgerItem.getDeviceCode());
|
return R.ok(deviceLeasingLedgerItemService.page(page, wrapper));
|
}
|
|
|
/**
|
* 通过id查询设备租赁台账明细
|
* @param id id
|
* @return R
|
*/
|
@Operation(summary = "通过id查询" , description = "通过id查询" )
|
@GetMapping("/{id}" )
|
@PreAuthorize("@pms.hasPermission('device_deviceLeasingLedgerItem_view')" )
|
public R getById(@PathVariable("id" ) Long id) {
|
return R.ok(deviceLeasingLedgerItemService.getById(id));
|
}
|
|
/**
|
* 新增设备租赁台账明细
|
* @param deviceLeasingLedgerItem 设备租赁台账明细
|
* @return R
|
*/
|
@Operation(summary = "新增设备租赁台账明细" , description = "新增设备租赁台账明细" )
|
@SysLog("新增设备租赁台账明细" )
|
@PostMapping
|
@PreAuthorize("@pms.hasPermission('device_deviceLeasingLedgerItem_add')" )
|
public R save(@RequestBody DeviceLeasingLedgerItem deviceLeasingLedgerItem) {
|
return R.ok(deviceLeasingLedgerItemService.save(deviceLeasingLedgerItem));
|
}
|
|
/**
|
* 修改设备租赁台账明细
|
* @param deviceLeasingLedgerItem 设备租赁台账明细
|
* @return R
|
*/
|
@Operation(summary = "修改设备租赁台账明细" , description = "修改设备租赁台账明细" )
|
@SysLog("修改设备租赁台账明细" )
|
@PutMapping
|
@PreAuthorize("@pms.hasPermission('device_deviceLeasingLedgerItem_edit')" )
|
public R updateById(@RequestBody DeviceLeasingLedgerItem deviceLeasingLedgerItem) {
|
return R.ok(deviceLeasingLedgerItemService.updateById(deviceLeasingLedgerItem));
|
}
|
|
/**
|
* 通过id删除设备租赁台账明细
|
* @param ids id列表
|
* @return R
|
*/
|
@Operation(summary = "通过id删除设备租赁台账明细" , description = "通过id删除设备租赁台账明细" )
|
@SysLog("通过id删除设备租赁台账明细" )
|
@DeleteMapping
|
@PreAuthorize("@pms.hasPermission('device_deviceLeasingLedgerItem_del')" )
|
public R removeById(@RequestBody Long[] ids) {
|
return R.ok(deviceLeasingLedgerItemService.removeBatchByIds(CollUtil.toList(ids)));
|
}
|
|
|
/**
|
* 导出excel 表格
|
* @param deviceLeasingLedgerItem 查询条件
|
* @param ids 导出指定ID
|
* @return excel 文件流
|
*/
|
@ResponseExcel
|
@GetMapping("/export")
|
@PreAuthorize("@pms.hasPermission('device_deviceLeasingLedgerItem_export')" )
|
public List<DeviceLeasingLedgerItem> export(DeviceLeasingLedgerItem deviceLeasingLedgerItem,Long[] ids) {
|
return deviceLeasingLedgerItemService.list(Wrappers.lambdaQuery(deviceLeasingLedgerItem).in(ArrayUtil.isNotEmpty(ids), DeviceLeasingLedgerItem::getId, ids));
|
}
|
}
|