89 lines
3.2 KiB
Java
89 lines
3.2 KiB
Java
package com.whdc.zhdbaqapi.controller;
|
|
|
|
import cn.afterturn.easypoi.excel.ExcelImportUtil;
|
|
import cn.afterturn.easypoi.excel.entity.ImportParams;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.whdc.zhdbaqapi.model.dto.FindDeviceDto;
|
|
import com.whdc.zhdbaqapi.model.dto.IntegerIdDto;
|
|
import com.whdc.zhdbaqapi.model.dto.StationCodeDto;
|
|
import com.whdc.zhdbaqapi.model.entity.DeviceInfo;
|
|
import com.whdc.zhdbaqapi.model.vo.DeviceInfoImpVo;
|
|
import com.whdc.zhdbaqapi.service.IDeviceInfoService;
|
|
import com.whdc.zhdbaqapi.utils.ResultJson;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
import java.util.List;
|
|
|
|
/**
|
|
* @author 李赛
|
|
* @date 2022-07-21 23:58
|
|
*/
|
|
@Api(tags = "设备信息 - Controller")
|
|
@RestController
|
|
@RequestMapping("/v1/deviceInfo")
|
|
@Slf4j
|
|
public class DeviceInfoController {
|
|
|
|
@Autowired
|
|
private IDeviceInfoService iDeviceInfoService;
|
|
|
|
@ApiOperation(value = "获取单个对象")
|
|
@PostMapping("/get")
|
|
public ResultJson<DeviceInfo> get(@RequestBody @Validated IntegerIdDto idDto) {
|
|
return ResultJson.ok(iDeviceInfoService.get(idDto.getId()));
|
|
}
|
|
|
|
@ApiOperation(value = "新增")
|
|
@PostMapping("/save")
|
|
public ResultJson<Boolean> save(@RequestBody @Validated DeviceInfo bean) {
|
|
return ResultJson.ok(iDeviceInfoService.save(bean));
|
|
}
|
|
|
|
@ApiOperation(value = "删除")
|
|
@PostMapping("/del")
|
|
public ResultJson<Boolean> del(@RequestBody @Validated IntegerIdDto bean) {
|
|
return ResultJson.ok(iDeviceInfoService.removeById(bean.getId()));
|
|
}
|
|
|
|
@ApiOperation(value = "修改")
|
|
@PostMapping("/edit")
|
|
public ResultJson<Boolean> edit(@RequestBody @Validated DeviceInfo bean) {
|
|
return ResultJson.ok(iDeviceInfoService.updateById(bean));
|
|
}
|
|
|
|
@ApiOperation(value = "恢复")
|
|
@PostMapping("/restore")
|
|
public ResultJson<Boolean> edit(@RequestBody @Validated IntegerIdDto bean) {
|
|
return ResultJson.ok(iDeviceInfoService.restore(bean.getId()));
|
|
}
|
|
|
|
@ApiOperation(value = "列表查询")
|
|
@PostMapping(value = "/list")
|
|
public ResultJson<List<DeviceInfo>> list(@RequestBody StationCodeDto dto) {
|
|
return ResultJson.ok(iDeviceInfoService.list(dto.getStationCode()));
|
|
}
|
|
|
|
@ApiOperation(value = "分页查询")
|
|
@PostMapping(value = "/page")
|
|
public ResultJson<IPage<DeviceInfo>> page(@RequestBody FindDeviceDto findDto) {
|
|
return ResultJson.ok(iDeviceInfoService.page(findDto));
|
|
}
|
|
|
|
@ApiOperation(value = "Excel数据导入")
|
|
@PostMapping("/imp")
|
|
public ResultJson<DeviceInfoImpVo> imp(@RequestParam(value = "file") @RequestPart MultipartFile file) throws Exception {
|
|
if(file == null){
|
|
return ResultJson.error("无效文件");
|
|
}
|
|
|
|
return ResultJson.ok(iDeviceInfoService.imp(file.getInputStream()));
|
|
}
|
|
}
|