195 lines
6.0 KiB
Java
195 lines
6.0 KiB
Java
package com.jero.modules.controller;
|
|
|
|
import java.util.Arrays;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import com.jero.common.api.vo.Results;
|
|
import com.jero.modules.entity.KhDevice;
|
|
import com.jero.modules.service.IKhDeviceService;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.jero.modules.vo.DeviceStatisticsVO;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import com.jero.common.system.base.controller.JeroController;
|
|
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.servlet.ModelAndView;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import com.jero.common.aspect.annotation.AutoLog;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.poi.ss.formula.functions.T;
|
|
|
|
|
|
/**
|
|
* @Description: 设备
|
|
* @Author: jero-boot
|
|
* @Date: 2024-04-01
|
|
* @Version: V1.0
|
|
*/
|
|
|
|
@Slf4j
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@RestController
|
|
@Api(tags = "设备管理")
|
|
@RequestMapping("/device")
|
|
public class KhDeviceController extends JeroController<KhDevice, IKhDeviceService> {
|
|
@Autowired
|
|
private IKhDeviceService khDeviceService;
|
|
|
|
/**
|
|
* 分页列表查询
|
|
*
|
|
* @param khDevice
|
|
* @param pageNo
|
|
* @param pageSize
|
|
* @param req
|
|
* @return
|
|
*/
|
|
@AutoLog(value = "设备-分页列表查询")
|
|
@ApiOperation(value = "设备-分页列表查询", notes = "设备-分页列表查询")
|
|
@GetMapping(value = "/page")
|
|
public Results<IPage<KhDevice>> queryPageList(KhDevice khDevice,
|
|
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
|
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
|
HttpServletRequest req) {
|
|
IPage<KhDevice> pageList = khDeviceService.queryPage(khDevice, pageNo, pageSize, req);
|
|
return Results.OK(pageList);
|
|
}
|
|
|
|
/**
|
|
* 系统设备概况
|
|
*
|
|
* @return
|
|
*/
|
|
@AutoLog(value = "设备-系统设备概况")
|
|
@ApiOperation(value = "设备-系统设备概况", notes = "设备-系统设备概况")
|
|
@GetMapping(value = "/statistics")
|
|
public Results<DeviceStatisticsVO> statistics() {
|
|
return Results.OK(khDeviceService.statistics());
|
|
}
|
|
|
|
/**
|
|
* 列表查询
|
|
*
|
|
* @param khDevice
|
|
* @param req
|
|
* @return
|
|
*/
|
|
@AutoLog(value = "设备-列表查询")
|
|
@ApiOperation(value = "设备-列表查询", notes = "设备-列表查询")
|
|
@GetMapping(value = "/list")
|
|
public Results<List<KhDevice>> queryList(KhDevice khDevice, HttpServletRequest req) {
|
|
List<KhDevice> list = khDeviceService.queryList(khDevice, req);
|
|
return Results.OK(list);
|
|
}
|
|
|
|
/**
|
|
* 添加
|
|
*
|
|
* @param khDevice
|
|
* @return
|
|
*/
|
|
@AutoLog(value = "设备-添加")
|
|
@ApiOperation(value = "设备-添加", notes = "设备-添加")
|
|
@PostMapping(value = "/add")
|
|
public Results<T> add(@Validated @RequestBody KhDevice khDevice) {
|
|
khDeviceService.add(khDevice);
|
|
return Results.OK("操作成功!");
|
|
}
|
|
|
|
/**
|
|
* 编辑
|
|
*
|
|
* @param khDevice
|
|
* @return
|
|
*/
|
|
@AutoLog(value = "设备-编辑")
|
|
@ApiOperation(value = "设备-编辑", notes = "设备-编辑")
|
|
@PostMapping(value = "/edit")
|
|
public Results<T> edit(@Validated @RequestBody KhDevice khDevice) {
|
|
khDeviceService.editById(khDevice);
|
|
return Results.OK("操作成功!");
|
|
}
|
|
|
|
/**
|
|
* 通过id删除
|
|
*
|
|
* @param map
|
|
* @return
|
|
*/
|
|
@AutoLog(value = "设备-通过id删除")
|
|
@ApiOperation(value = "设备-通过id删除", notes = "设备-通过id删除")
|
|
@PostMapping(value = "/delete")
|
|
public Results<T> delete(@RequestBody Map<String, String> map) {
|
|
if (!map.containsKey("id") || StringUtils.isEmpty(map.get("id"))) {
|
|
return Results.error("请选择数据!");
|
|
}
|
|
khDeviceService.deleteById(map.get("id"));
|
|
return Results.OK("删除成功!");
|
|
}
|
|
|
|
/**
|
|
* 批量删除
|
|
*
|
|
* @param map
|
|
* @return
|
|
*/
|
|
@AutoLog(value = "设备-批量删除")
|
|
@ApiOperation(value = "设备-批量删除", notes = "设备-批量删除")
|
|
@PostMapping(value = "/deleteBatch")
|
|
public Results<T> deleteBatch(@RequestBody Map<String, String> map) {
|
|
if (!map.containsKey("ids") || StringUtils.isEmpty(map.get("ids"))) {
|
|
return Results.error("请选择数据!");
|
|
}
|
|
this.khDeviceService.deleteByIds(Arrays.asList(map.get("ids").split(",")));
|
|
return Results.OK("批量删除成功!");
|
|
}
|
|
|
|
/**
|
|
* 通过id查询
|
|
*
|
|
* @param id
|
|
* @return
|
|
*/
|
|
@AutoLog(value = "设备-通过id查询")
|
|
@ApiOperation(value = "设备-通过id查询", notes = "设备-通过id查询")
|
|
@GetMapping(value = "/queryById")
|
|
public Results<KhDevice> queryById(@RequestParam(name = "id", required = true) String id) {
|
|
KhDevice khDevice = khDeviceService.queryById(id);
|
|
if (khDevice == null) {
|
|
return Results.error("未找到对应数据");
|
|
}
|
|
return Results.OK(khDevice);
|
|
}
|
|
|
|
/**
|
|
* 导出excel
|
|
*
|
|
* @param request
|
|
* @param khDevice
|
|
*/
|
|
@RequestMapping(value = "/exportXls")
|
|
public ModelAndView exportXls(HttpServletRequest request, KhDevice khDevice) {
|
|
return super.exportXls(request, khDevice, KhDevice.class, "设备");
|
|
}
|
|
|
|
/**
|
|
* 通过excel导入数据
|
|
*
|
|
* @param request
|
|
* @param response
|
|
* @return
|
|
*/
|
|
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
|
public Results<KhDevice> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
|
return super.importExcel(request, response, KhDevice.class);
|
|
}
|
|
|
|
}
|
|
|
|
|