查询设备分组列表
This commit is contained in:
119
aa.conf
Normal file
119
aa.conf
Normal file
@ -0,0 +1,119 @@
|
||||
|
||||
#user nobody;
|
||||
worker_processes 1;
|
||||
|
||||
#error_log logs/error.log;
|
||||
#error_log logs/error.log notice;
|
||||
#error_log logs/error.log info;
|
||||
|
||||
#pid logs/nginx.pid;
|
||||
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
|
||||
http {
|
||||
include mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
# '$status $body_bytes_sent "$http_referer" '
|
||||
# '"$http_user_agent" "$http_x_forwarded_for"';
|
||||
|
||||
#access_log logs/access.log main;
|
||||
|
||||
sendfile on;
|
||||
#tcp_nopush on;
|
||||
|
||||
#keepalive_timeout 0;
|
||||
keepalive_timeout 65;
|
||||
|
||||
#gzip on;
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name cnxhyc.com;
|
||||
|
||||
#charset koi8-r;
|
||||
|
||||
#access_log logs/host.access.log main;
|
||||
|
||||
location / {
|
||||
root html;
|
||||
index index.html index.htm;
|
||||
}
|
||||
|
||||
#error_page 404 /404.html;
|
||||
|
||||
# redirect server error pages to the static page /50x.html
|
||||
#
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root html;
|
||||
}
|
||||
|
||||
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
|
||||
#
|
||||
#location ~ \.php$ {
|
||||
# proxy_pass http://127.0.0.1;
|
||||
#}
|
||||
|
||||
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
|
||||
#
|
||||
#location ~ \.php$ {
|
||||
# root html;
|
||||
# fastcgi_pass 127.0.0.1:9000;
|
||||
# fastcgi_index index.php;
|
||||
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
|
||||
# include fastcgi_params;
|
||||
#}
|
||||
|
||||
# deny access to .htaccess files, if Apache's document root
|
||||
# concurs with nginx's one
|
||||
#
|
||||
#location ~ /\.ht {
|
||||
# deny all;
|
||||
#}
|
||||
}
|
||||
|
||||
|
||||
# another virtual host using mix of IP-, name-, and port-based configuration
|
||||
#
|
||||
#server {
|
||||
# listen 8000;
|
||||
# listen somename:8080;
|
||||
# server_name somename alias another.alias;
|
||||
|
||||
# location / {
|
||||
# root html;
|
||||
# index index.html index.htm;
|
||||
# }
|
||||
#}
|
||||
|
||||
|
||||
# HTTPS server
|
||||
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
server_name cnxhyc.com;
|
||||
|
||||
ssl_certificate /cert/cnxhyc.com.pem;
|
||||
ssl_certificate_key /cert/cnxhyc.com.key;
|
||||
|
||||
# 使用更现代的 SSL 配置
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_ciphers TLS_AES_256_GCM_SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
|
||||
ssl_prefer_server_ciphers off;
|
||||
|
||||
ssl_session_cache shared:SSL:10m;
|
||||
ssl_session_timeout 10m;
|
||||
|
||||
location / {
|
||||
root html;
|
||||
index index.html index.htm;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -2,6 +2,7 @@ package com.fuyuanshen.web.controller.device;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.*;
|
||||
@ -45,6 +46,7 @@ public class DeviceGroupController extends BaseController {
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导出设备分组列表
|
||||
*/
|
||||
@ -56,6 +58,7 @@ public class DeviceGroupController extends BaseController {
|
||||
ExcelUtil.exportExcel(list, "设备分组", DeviceGroupVo.class, response);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取设备分组详细信息
|
||||
*
|
||||
@ -63,8 +66,7 @@ public class DeviceGroupController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("fys-equipment:group:query")
|
||||
@GetMapping("/{id}")
|
||||
public R<DeviceGroupVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long id) {
|
||||
public R<DeviceGroupVo> getInfo(@NotNull(message = "主键不能为空") @PathVariable Long id) {
|
||||
return R.ok(deviceGroupService.queryById(id));
|
||||
}
|
||||
|
||||
|
@ -39,8 +39,8 @@ public class EncryptUtilsTest {
|
||||
loginBody.setClientId("e5cd7e4891bf95d1d19206ce24a7b32e");
|
||||
loginBody.setGrantType("password");
|
||||
loginBody.setTenantId("894078");
|
||||
loginBody.setCode("0");
|
||||
loginBody.setUuid("1c285b27f516486f9535face77023aeb");
|
||||
loginBody.setCode("9");
|
||||
loginBody.setUuid("d5be31eac1244cee851a9903f358bc6a");
|
||||
// loginBody.setUsername("admin");
|
||||
// loginBody.setPassword("admin123");
|
||||
loginBody.setUsername("dyf");
|
||||
|
@ -24,7 +24,7 @@ public class DeviceGroup extends TenantEntity {
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId(value = "id")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
|
@ -5,6 +5,7 @@ import com.fuyuanshen.common.core.validate.EditGroup;
|
||||
import com.fuyuanshen.equipment.domain.DeviceGroup;
|
||||
import com.fuyuanshen.common.mybatis.core.domain.BaseEntity;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import jakarta.validation.constraints.*;
|
||||
@ -55,4 +56,10 @@ public class DeviceGroupBo extends BaseEntity {
|
||||
private Long isDeleted;
|
||||
|
||||
|
||||
@Schema(name = "页码", example = "1")
|
||||
private Integer pageNum = 1;
|
||||
|
||||
@Schema(name = "每页数据量", example = "10")
|
||||
private Integer pageSize = 10;
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.fuyuanshen.equipment.domain.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.fuyuanshen.equipment.domain.DeviceGroup;
|
||||
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
@ -44,7 +46,7 @@ public class DeviceGroupVo implements Serializable {
|
||||
* 状态:0-禁用,1-正常
|
||||
*/
|
||||
@ExcelProperty(value = "状态:0-禁用,1-正常")
|
||||
private Long status;
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 父分组ID
|
||||
@ -69,4 +71,9 @@ public class DeviceGroupVo implements Serializable {
|
||||
*/
|
||||
private List<DeviceGroupVo> children;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private String createTime;
|
||||
|
||||
}
|
||||
|
@ -1,8 +1,15 @@
|
||||
package com.fuyuanshen.equipment.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fuyuanshen.equipment.domain.Device;
|
||||
import com.fuyuanshen.equipment.domain.DeviceGroup;
|
||||
import com.fuyuanshen.equipment.domain.bo.DeviceGroupBo;
|
||||
import com.fuyuanshen.equipment.domain.vo.DeviceGroupVo;
|
||||
import com.fuyuanshen.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 设备分组Mapper接口
|
||||
@ -12,4 +19,20 @@ import com.fuyuanshen.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
*/
|
||||
public interface DeviceGroupMapper extends BaseMapperPlus<DeviceGroup, DeviceGroupVo> {
|
||||
|
||||
/**
|
||||
* 查询设备分组列表
|
||||
*
|
||||
* @param bo 设备分组
|
||||
* @return 设备分组
|
||||
*/
|
||||
IPage<DeviceGroup> selectRootGroups(@Param("bo") DeviceGroupBo bo, Page<Device> page);
|
||||
|
||||
/**
|
||||
* 查询子分组
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
List<DeviceGroup> selectByParentId(Long id);
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.fuyuanshen.equipment.service;
|
||||
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
import com.fuyuanshen.equipment.domain.vo.DeviceGroupVo;
|
||||
import com.fuyuanshen.equipment.domain.bo.DeviceGroupBo;
|
||||
|
||||
|
@ -1,10 +1,16 @@
|
||||
package com.fuyuanshen.equipment.service.impl;
|
||||
|
||||
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.fuyuanshen.common.core.domain.R;
|
||||
import com.fuyuanshen.common.core.utils.MapstructUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
import com.fuyuanshen.common.satoken.utils.LoginHelper;
|
||||
import com.fuyuanshen.equipment.domain.Device;
|
||||
import com.fuyuanshen.equipment.domain.DeviceTypeGrants;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -15,9 +21,11 @@ import com.fuyuanshen.equipment.domain.DeviceGroup;
|
||||
import com.fuyuanshen.equipment.mapper.DeviceGroupMapper;
|
||||
import com.fuyuanshen.equipment.service.IDeviceGroupService;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 设备分组Service业务层处理
|
||||
@ -32,6 +40,7 @@ public class DeviceGroupServiceImpl implements IDeviceGroupService {
|
||||
|
||||
private final DeviceGroupMapper baseMapper;
|
||||
|
||||
|
||||
/**
|
||||
* 查询设备分组
|
||||
*
|
||||
@ -52,8 +61,34 @@ public class DeviceGroupServiceImpl implements IDeviceGroupService {
|
||||
*/
|
||||
@Override
|
||||
public List<DeviceGroupVo> queryList(DeviceGroupBo bo) {
|
||||
LambdaQueryWrapper<DeviceGroup> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
Page<Device> page = new Page<>(bo.getPageNum(), bo.getPageSize());
|
||||
// 1. 查询顶级分组(parent_id为null)
|
||||
IPage<DeviceGroup> rootGroups = baseMapper.selectRootGroups(bo, page);
|
||||
List<DeviceGroup> records = rootGroups.getRecords();
|
||||
|
||||
// 2. 递归构建树形结构
|
||||
return records.stream()
|
||||
.map(this::buildGroupTree)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private DeviceGroupVo buildGroupTree(DeviceGroup group) {
|
||||
DeviceGroupVo vo = convertToVO(group);
|
||||
// 递归查询子分组
|
||||
List<DeviceGroup> children = baseMapper.selectByParentId(group.getId());
|
||||
vo.setChildren(children.stream()
|
||||
.map(this::buildGroupTree)
|
||||
.collect(Collectors.toList()));
|
||||
return vo;
|
||||
}
|
||||
|
||||
private DeviceGroupVo convertToVO(DeviceGroup group) {
|
||||
DeviceGroupVo vo = new DeviceGroupVo();
|
||||
vo.setId(group.getId());
|
||||
vo.setGroupName(group.getGroupName());
|
||||
vo.setStatus(group.getStatus() == 1 ? "正常" : "禁用");
|
||||
vo.setCreateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(group.getCreateTime()));
|
||||
return vo;
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<DeviceGroup> buildQueryWrapper(DeviceGroupBo bo) {
|
||||
@ -81,13 +116,13 @@ public class DeviceGroupServiceImpl implements IDeviceGroupService {
|
||||
// 验证分组名称唯一性
|
||||
DeviceGroup deviceGroup = baseMapper.selectOne(new QueryWrapper<DeviceGroup>().eq("group_name", bo.getGroupName()));
|
||||
if (deviceGroup != null) {
|
||||
throw new RuntimeException("分组名称已存在,请勿重复添加");
|
||||
throw new RuntimeException("分组名称已存在,请勿重复添加!!!");
|
||||
}
|
||||
|
||||
// 验证父分组是否存在(如果提供了parentId)
|
||||
DeviceGroup pDeviceGroup = baseMapper.selectById(bo.getParentId());
|
||||
if (bo.getParentId() != null && pDeviceGroup == null) {
|
||||
throw new RuntimeException("父分组不存在");
|
||||
throw new RuntimeException("父分组不存在!!!");
|
||||
}
|
||||
|
||||
DeviceGroup add = MapstructUtils.convert(bo, DeviceGroup.class);
|
||||
|
@ -1,7 +1,28 @@
|
||||
<?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">
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.fuyuanshen.equipment.mapper.DeviceGroupMapper">
|
||||
|
||||
<!-- 查询顶级分组 -->
|
||||
<select id="selectRootGroups" resultType="DeviceGroup">
|
||||
SELECT * FROM device_group
|
||||
WHERE parent_id IS NULL
|
||||
<if test="bo.groupName != null and bo.groupName != ''">
|
||||
AND group_name LIKE CONCAT('%', #{bo.groupName}, '%')
|
||||
</if>
|
||||
<if test="bo.status != null">
|
||||
AND status = #{bo.status}
|
||||
</if>
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 根据父ID查询子分组 -->
|
||||
<select id="selectByParentId" resultType="DeviceGroup">
|
||||
SELECT *
|
||||
FROM device_group
|
||||
WHERE parent_id = #{parentId}
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
Reference in New Issue
Block a user