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.DeviceManufacturer;
|
import com.by4cloud.platformx.device.service.DeviceManufacturerService;
|
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-26 08:46:59
|
*/
|
@RestController
|
@RequiredArgsConstructor
|
@RequestMapping("/deviceManufacturer" )
|
@Tag(description = "deviceManufacturer" , name = "设备厂商管理" )
|
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
public class DeviceManufacturerController {
|
|
private final DeviceManufacturerService deviceManufacturerService;
|
|
/**
|
* 分页查询
|
* @param page 分页对象
|
* @param deviceManufacturer 设备厂商
|
* @return
|
*/
|
@Operation(summary = "分页查询" , description = "分页查询" )
|
@GetMapping("/page" )
|
@PreAuthorize("@pms.hasPermission('device_deviceManufacturer_view')" )
|
public R getDeviceManufacturerPage(@ParameterObject Page page, @ParameterObject DeviceManufacturer deviceManufacturer) {
|
LambdaQueryWrapper<DeviceManufacturer> wrapper = Wrappers.lambdaQuery();
|
wrapper.like(StrUtil.isNotBlank(deviceManufacturer.getManufacturerCategory()),DeviceManufacturer::getManufacturerCategory,deviceManufacturer.getManufacturerCategory());
|
wrapper.like(StrUtil.isNotBlank(deviceManufacturer.getManufacturerName()),DeviceManufacturer::getManufacturerName,deviceManufacturer.getManufacturerName());
|
return R.ok(deviceManufacturerService.page(page, wrapper));
|
}
|
|
|
/**
|
* 通过id查询设备厂商
|
* @param id id
|
* @return R
|
*/
|
@Operation(summary = "通过id查询" , description = "通过id查询" )
|
@GetMapping("/{id}" )
|
@PreAuthorize("@pms.hasPermission('device_deviceManufacturer_view')" )
|
public R getById(@PathVariable("id" ) Long id) {
|
return R.ok(deviceManufacturerService.getById(id));
|
}
|
|
/**
|
* 新增设备厂商
|
* @param deviceManufacturer 设备厂商
|
* @return R
|
*/
|
@Operation(summary = "新增设备厂商" , description = "新增设备厂商" )
|
@SysLog("新增设备厂商" )
|
@PostMapping
|
@PreAuthorize("@pms.hasPermission('device_deviceManufacturer_add')" )
|
public R save(@RequestBody DeviceManufacturer deviceManufacturer) {
|
return R.ok(deviceManufacturerService.save(deviceManufacturer));
|
}
|
|
/**
|
* 修改设备厂商
|
* @param deviceManufacturer 设备厂商
|
* @return R
|
*/
|
@Operation(summary = "修改设备厂商" , description = "修改设备厂商" )
|
@SysLog("修改设备厂商" )
|
@PutMapping
|
@PreAuthorize("@pms.hasPermission('device_deviceManufacturer_edit')" )
|
public R updateById(@RequestBody DeviceManufacturer deviceManufacturer) {
|
return R.ok(deviceManufacturerService.updateById(deviceManufacturer));
|
}
|
|
/**
|
* 通过id删除设备厂商
|
* @param ids id列表
|
* @return R
|
*/
|
@Operation(summary = "通过id删除设备厂商" , description = "通过id删除设备厂商" )
|
@SysLog("通过id删除设备厂商" )
|
@DeleteMapping
|
@PreAuthorize("@pms.hasPermission('device_deviceManufacturer_del')" )
|
public R removeById(@RequestBody Long[] ids) {
|
return R.ok(deviceManufacturerService.removeBatchByIds(CollUtil.toList(ids)));
|
}
|
|
|
/**
|
* 导出excel 表格
|
* @param deviceManufacturer 查询条件
|
* @param ids 导出指定ID
|
* @return excel 文件流
|
*/
|
@ResponseExcel
|
@GetMapping("/export")
|
@PreAuthorize("@pms.hasPermission('device_deviceManufacturer_export')" )
|
public List<DeviceManufacturer> export(DeviceManufacturer deviceManufacturer,Long[] ids) {
|
return deviceManufacturerService.list(Wrappers.lambdaQuery(deviceManufacturer).in(ArrayUtil.isNotEmpty(ids), DeviceManufacturer::getId, ids));
|
}
|
}
|