物联设备配置
This commit is contained in:
parent
8ef633288a
commit
2e7480594d
|
|
@ -0,0 +1,155 @@
|
||||||
|
package com.nu.modules.config.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.nu.modules.config.entity.DeviceConfig;
|
||||||
|
import com.nu.modules.config.service.IDeviceInfoService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
|
import org.jeecg.common.api.vo.Result;
|
||||||
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||||
|
import org.jeecg.common.system.base.controller.JeecgController;
|
||||||
|
import org.jeecg.common.system.query.QueryGenerator;
|
||||||
|
import org.jeecg.common.system.query.QueryRuleEnum;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 设备配置
|
||||||
|
* @Author: jeecg-boot
|
||||||
|
* @Date: 2026-03-27
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/iot/device/config")
|
||||||
|
@Slf4j
|
||||||
|
public class DeviceConfigController extends JeecgController<DeviceConfig, IDeviceInfoService> {
|
||||||
|
@Autowired
|
||||||
|
private IDeviceInfoService service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页列表查询
|
||||||
|
*
|
||||||
|
* @param DeviceConfig
|
||||||
|
* @param pageNo
|
||||||
|
* @param pageSize
|
||||||
|
* @param req
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/list")
|
||||||
|
public Result<IPage<DeviceConfig>> queryPageList(DeviceConfig DeviceConfig,
|
||||||
|
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||||
|
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||||
|
HttpServletRequest req) {
|
||||||
|
QueryWrapper<DeviceConfig> queryWrapper = QueryGenerator.initQueryWrapper(DeviceConfig, req.getParameterMap());
|
||||||
|
Page<DeviceConfig> page = new Page<DeviceConfig>(pageNo, pageSize);
|
||||||
|
IPage<DeviceConfig> pageList = service.page(page, queryWrapper);
|
||||||
|
return Result.OK(pageList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加
|
||||||
|
*
|
||||||
|
* @param DeviceConfig
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/add")
|
||||||
|
public Result<String> add(@RequestBody DeviceConfig DeviceConfig) {
|
||||||
|
QueryWrapper<DeviceConfig> emQw = new QueryWrapper<>();
|
||||||
|
emQw.eq("device_type",DeviceConfig.getDeviceType());
|
||||||
|
emQw.eq("device_model",DeviceConfig.getDeviceModel());
|
||||||
|
emQw.eq("factory",DeviceConfig.getFactory());
|
||||||
|
emQw.eq("dimension",DeviceConfig.getDimension());
|
||||||
|
DeviceConfig entity = service.getOne(emQw);
|
||||||
|
if(entity!=null){
|
||||||
|
return Result.error("配置已存在!");
|
||||||
|
}
|
||||||
|
service.save(DeviceConfig);
|
||||||
|
return Result.OK("添加成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编辑
|
||||||
|
*
|
||||||
|
* @param DeviceConfig
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
||||||
|
public Result<String> edit(@RequestBody DeviceConfig DeviceConfig) {
|
||||||
|
service.updateById(DeviceConfig);
|
||||||
|
return Result.OK("编辑成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过id删除
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@DeleteMapping(value = "/delete")
|
||||||
|
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
|
||||||
|
service.removeById(id);
|
||||||
|
return Result.OK("删除成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除
|
||||||
|
*
|
||||||
|
* @param ids
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@DeleteMapping(value = "/deleteBatch")
|
||||||
|
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||||
|
this.service.removeByIds(Arrays.asList(ids.split(",")));
|
||||||
|
return Result.OK("批量删除成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过id查询
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/queryById")
|
||||||
|
public Result<DeviceConfig> queryById(@RequestParam(name="id",required=true) String id) {
|
||||||
|
DeviceConfig DeviceConfig = service.getById(id);
|
||||||
|
if(DeviceConfig==null) {
|
||||||
|
return Result.error("未找到对应数据");
|
||||||
|
}
|
||||||
|
return Result.OK(DeviceConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出excel
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
|
* @param DeviceConfig
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/exportXls")
|
||||||
|
public ModelAndView exportXls(HttpServletRequest request, DeviceConfig DeviceConfig) {
|
||||||
|
return super.exportXls(request, DeviceConfig, DeviceConfig.class, "物联设备配置");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过excel导入数据
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
|
* @param response
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||||
|
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||||
|
return super.importExcel(request, response, DeviceConfig.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.nu.modules.config.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.jeecg.common.aspect.annotation.Dict;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@TableName("nu_iot_device_config")
|
||||||
|
public class DeviceConfig implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**ID*/
|
||||||
|
@TableId(type = IdType.AUTO)
|
||||||
|
@ApiModelProperty(value = "ID")
|
||||||
|
private Integer id;
|
||||||
|
@Dict(dicCode = "tplink_device_type")
|
||||||
|
private String deviceType;
|
||||||
|
private String deviceModel;
|
||||||
|
private String factory;
|
||||||
|
private String dimension;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.nu.modules.config.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.nu.modules.config.entity.DeviceConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 设备配置
|
||||||
|
* @Author: jeecg-boot
|
||||||
|
* @Date: 2026-03-27
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
public interface DeviceConfigMapper extends BaseMapper<DeviceConfig> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.nu.modules.config.mapper.DeviceConfigMapper">
|
||||||
|
|
||||||
|
</mapper>
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
package com.nu.modules.config.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.nu.modules.config.entity.DeviceConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 设备配置
|
||||||
|
* @Author: jeecg-boot
|
||||||
|
* @Date: 2026-03-27
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
public interface IDeviceInfoService extends IService<DeviceConfig> {
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.nu.modules.config.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.nu.modules.config.entity.DeviceConfig;
|
||||||
|
import com.nu.modules.config.mapper.DeviceConfigMapper;
|
||||||
|
import com.nu.modules.config.service.IDeviceInfoService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 设备配置
|
||||||
|
* @Author: jeecg-boot
|
||||||
|
* @Date: 2026-03-27
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class DeviceConfigServiceImpl extends ServiceImpl<DeviceConfigMapper, DeviceConfig> implements IDeviceInfoService {
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue