feat:ASW-56 device 我的设备 接口开发
1.调整 device 接口 path 2.调整 device 替换成 environment
This commit is contained in:
@@ -1,79 +0,0 @@
|
||||
<?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="net.geedge.asw.module.device.dao.DeviceDao">
|
||||
<resultMap id="deviceResult" type="net.geedge.asw.module.device.entity.DeviceEntity">
|
||||
<result property="id" column="id"/>
|
||||
<result property="name" column="name"/>
|
||||
<result property="platform" column="platform"/>
|
||||
<result property="param" column="param"/>
|
||||
<result property="description" column="description"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="lastHealthCheck" column="last_health_check"/>
|
||||
<result property="createTimestamp" column="create_timestamp"/>
|
||||
<result property="updateTimestamp" column="update_timestamp"/>
|
||||
<result property="createUserId" column="create_user_id"/>
|
||||
<result property="updateUserId" column="update_user_id"/>
|
||||
<result property="workspaceId" column="workspace_id"/>
|
||||
|
||||
<association property="createUser" columnPrefix="cu_" javaType="net.geedge.asw.module.sys.entity.SysUserEntity">
|
||||
<id property="id" column="id"/>
|
||||
<result property="name" column="name"/>
|
||||
</association>
|
||||
|
||||
<association property="updateUser" columnPrefix="uu_" javaType="net.geedge.asw.module.sys.entity.SysUserEntity">
|
||||
<id property="id" column="id"/>
|
||||
<result property="name" column="name"/>
|
||||
</association>
|
||||
|
||||
<association property="useUser" columnPrefix="u_" javaType="cn.hutool.json.JSONObject">
|
||||
<result property="id" column="id"/>
|
||||
<result property="name" column="name"/>
|
||||
<result property="startTimestamp" column="start_timestamp"/>
|
||||
<result property="endTimestamp" column="end_timestamp"/>
|
||||
</association>
|
||||
</resultMap>
|
||||
|
||||
<select id="queryList" resultMap="deviceResult">
|
||||
SELECT
|
||||
d.*,
|
||||
|
||||
cu.id AS cu_id,
|
||||
cu.name AS cu_name,
|
||||
|
||||
uu.id AS uu_id,
|
||||
uu.name AS uu_name,
|
||||
|
||||
log.user_id AS u_id,
|
||||
u.name AS u_name,
|
||||
log.start_timestamp AS u_start_timestamp,
|
||||
log.end_timestamp AS u_end_timestamp
|
||||
FROM device d
|
||||
LEFT JOIN sys_user cu ON d.create_user_id = cu.id
|
||||
LEFT JOIN sys_user uu ON d.update_user_id = uu.id
|
||||
LEFT JOIN device_log log ON d.id = log.device_id
|
||||
LEFT JOIN sys_user u ON log.user_id = u.id
|
||||
|
||||
<where>
|
||||
<if test="params.ids != null and params.ids != ''">
|
||||
d.id in
|
||||
<foreach item="id" collection="params.ids.split(',')" separator="," open="(" close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
|
||||
<if test="params.q != null and params.q != ''">
|
||||
AND ( locate(#{params.q}, d.name) OR locate(#{params.q}, d.description) )
|
||||
</if>
|
||||
|
||||
<if test="params.workspaceId != null and params.workspaceId != ''">
|
||||
AND d.workspace_id = #{params.workspaceId}
|
||||
</if>
|
||||
</where>
|
||||
|
||||
<if test="params.orderBy == null or params.orderBy == ''">
|
||||
ORDER BY d.create_timestamp
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
129
src/main/resources/db/mapper/device/EnvironmentMapper.xml
Normal file
129
src/main/resources/db/mapper/device/EnvironmentMapper.xml
Normal file
@@ -0,0 +1,129 @@
|
||||
<?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="net.geedge.asw.module.environment.dao.EnvironmentDao">
|
||||
<resultMap id="deviceResult" type="net.geedge.asw.module.environment.entity.EnvironmentEntity">
|
||||
<result property="id" column="id"/>
|
||||
<result property="name" column="name"/>
|
||||
<result property="location" column="location"/>
|
||||
<result property="platform" column="platform"/>
|
||||
<result property="param" column="param"/>
|
||||
<result property="description" column="description"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="lastHealthCheck" column="last_health_check"/>
|
||||
<result property="createTimestamp" column="create_timestamp"/>
|
||||
<result property="updateTimestamp" column="update_timestamp"/>
|
||||
<result property="createUserId" column="create_user_id"/>
|
||||
<result property="updateUserId" column="update_user_id"/>
|
||||
|
||||
<association property="createUser" columnPrefix="cu_" javaType="net.geedge.asw.module.sys.entity.SysUserEntity">
|
||||
<id property="id" column="id"/>
|
||||
<result property="name" column="name"/>
|
||||
</association>
|
||||
|
||||
<association property="updateUser" columnPrefix="uu_" javaType="net.geedge.asw.module.sys.entity.SysUserEntity">
|
||||
<id property="id" column="id"/>
|
||||
<result property="name" column="name"/>
|
||||
</association>
|
||||
|
||||
<association property="useUser" columnPrefix="u_" javaType="cn.hutool.json.JSONObject">
|
||||
<result property="id" column="id"/>
|
||||
<result property="name" column="name"/>
|
||||
<result property="startTimestamp" column="start_timestamp"/>
|
||||
<result property="endTimestamp" column="end_timestamp"/>
|
||||
</association>
|
||||
</resultMap>
|
||||
|
||||
<select id="queryList" resultMap="deviceResult">
|
||||
SELECT
|
||||
e.*,
|
||||
|
||||
cu.id AS cu_id,
|
||||
cu.name AS cu_name,
|
||||
|
||||
uu.id AS uu_id,
|
||||
uu.name AS uu_name,
|
||||
|
||||
es.user_id AS u_id,
|
||||
u.name AS u_name,
|
||||
es.start_timestamp AS u_start_timestamp,
|
||||
es.end_timestamp AS u_end_timestamp
|
||||
FROM environment e
|
||||
LEFT JOIN sys_user cu ON e.create_user_id = cu.id
|
||||
LEFT JOIN sys_user uu ON e.update_user_id = uu.id
|
||||
LEFT JOIN environment_session es ON e.id = es.env_id
|
||||
LEFT JOIN environment_workspace ew ON e.id = ew.env_id
|
||||
LEFT JOIN sys_user u ON es.user_id = u.id
|
||||
|
||||
<where>
|
||||
<if test="params.ids != null and params.ids != ''">
|
||||
e.id in
|
||||
<foreach item="id" collection="params.ids.split(',')" separator="," open="(" close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
|
||||
<if test="params.q != null and params.q != ''">
|
||||
AND ( locate(#{params.q}, e.name) OR locate(#{params.q}, e.description) )
|
||||
</if>
|
||||
|
||||
<if test="params.workspaceId != null and params.workspaceId != ''">
|
||||
AND ew.workspace_id = #{params.workspaceId}
|
||||
</if>
|
||||
</where>
|
||||
|
||||
<if test="params.orderBy == null or params.orderBy == ''">
|
||||
ORDER BY e.create_timestamp
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="mySession" resultMap="deviceResult">
|
||||
SELECT
|
||||
e.*,
|
||||
|
||||
cu.id AS cu_id,
|
||||
cu.name AS cu_name,
|
||||
|
||||
uu.id AS uu_id,
|
||||
uu.name AS uu_name,
|
||||
|
||||
es.user_id AS u_id,
|
||||
u.name AS u_name,
|
||||
es.start_timestamp AS u_start_timestamp,
|
||||
es.end_timestamp AS u_end_timestamp
|
||||
FROM environment e
|
||||
LEFT JOIN sys_user cu ON e.create_user_id = cu.id
|
||||
LEFT JOIN sys_user uu ON e.update_user_id = uu.id
|
||||
LEFT JOIN environment_workspace ew ON e.id = ew.env_id
|
||||
LEFT JOIN environment_session es ON e.id = es.env_id
|
||||
LEFT JOIN sys_user u ON es.user_id = u.id
|
||||
|
||||
<where>
|
||||
|
||||
es.status = 1
|
||||
|
||||
<if test="params.ids != null and params.ids != ''">
|
||||
AND e.id in
|
||||
<foreach item="id" collection="params.ids.split(',')" separator="," open="(" close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
|
||||
<if test="params.q != null and params.q != ''">
|
||||
AND ( locate(#{params.q}, e.name) OR locate(#{params.q}, e.description) )
|
||||
</if>
|
||||
|
||||
<if test="params.workspaceId != null and params.workspaceId != ''">
|
||||
AND ew.workspace_id = #{params.workspaceId}
|
||||
</if>
|
||||
|
||||
<if test="params.currentUserId != null and params.currentUserId != ''">
|
||||
AND es.user_id = #{params.currentUserId}
|
||||
</if>
|
||||
</where>
|
||||
|
||||
<if test="params.orderBy == null or params.orderBy == ''">
|
||||
ORDER BY e.create_timestamp
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -121,5 +121,9 @@ INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (199, '100017', 'SYS_ROLE_BUILT_IN', '内置权限不能删除或修改', 'zh', '', 'admin', 1724030366000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (201, '100018', 'SYS_ROLE_NOT_DELETE', 'Used role cannot be delete', 'en', '', 'admin', 1724030366000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (203, '100018', 'SYS_ROLE_NOT_DELETE', '已使用权限不能删除', 'zh', '', 'admin', 1724030366000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (205, '601001', 'ENVIRONMENT_SESSION_NOT_EXIST', 'environment session does not exist', 'en', '', 'admin', 1724030366000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (207, '601001', 'ENVIRONMENT_SESSION_NOT_EXIST', '会话不存在', 'zh', '', 'admin', 1724030366000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (209, '601002', 'ENVIRONMENT_NOT_EXIST', 'environment does not exist', 'en', '', 'admin', 1724030366000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (211, '601002', 'ENVIRONMENT_NOT_EXIST', '环境不存在', 'zh', '', 'admin', 1724030366000);
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
|
||||
@@ -462,10 +462,10 @@ INSERT INTO `workspace_member` (`workspace_id`, `user_id`, `role_id`, `create_ti
|
||||
|
||||
|
||||
/**
|
||||
* 新增 device 表
|
||||
* 新增 environment 表
|
||||
*/
|
||||
DROP TABLE IF EXISTS `device`;
|
||||
CREATE TABLE `device` (
|
||||
DROP TABLE IF EXISTS `environment`;
|
||||
CREATE TABLE `environment` (
|
||||
`id` varchar(64) NOT NULL COMMENT '主键',
|
||||
`name` varchar(256) NOT NULL DEFAULT '' COMMENT '名称',
|
||||
`location` varchar(256) NOT NULL DEFAULT '' COMMENT '位置',
|
||||
@@ -478,24 +478,37 @@ CREATE TABLE `device` (
|
||||
`update_timestamp` bigint(20) NOT NULL COMMENT '更新时间戳',
|
||||
`create_user_id` varchar(64) NOT NULL COMMENT '创建人',
|
||||
`update_user_id` varchar(64) NOT NULL COMMENT '更新人',
|
||||
`workspace_id` varchar(64) NOT NULL DEFAULT '' COMMENT '工作空间ID',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
KEY `idx_name` (`name`) USING BTREE,
|
||||
KEY `idx_status` (`status`) USING BTREE,
|
||||
KEY `idx_workspace_id` (`workspace_id`) USING BTREE
|
||||
KEY `idx_status` (`status`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
|
||||
/**
|
||||
* 新增 device_log 表
|
||||
* 新增 environment_workspace 表
|
||||
*/
|
||||
DROP TABLE IF EXISTS `device_log`;
|
||||
CREATE TABLE `device_log` (
|
||||
DROP TABLE IF EXISTS `environment_workspace`;
|
||||
CREATE TABLE `environment_workspace` (
|
||||
`id` varchar(64) NOT NULL COMMENT '主键',
|
||||
`env_id` varchar(64) NOT NULL DEFAULT '' COMMENT '名称',
|
||||
`workspace_id` varchar(64) NOT NULL DEFAULT '' COMMENT '位置',
|
||||
`create_timestamp` bigint(20) NOT NULL COMMENT '创建时间戳',
|
||||
`create_user_id` varchar(64) NOT NULL COMMENT '创建人',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
KEY `idx_workspace_id` (`workspace_id`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
|
||||
/**
|
||||
* 新增 environment_session 表
|
||||
*/
|
||||
DROP TABLE IF EXISTS `environment_session`;
|
||||
CREATE TABLE `environment_session` (
|
||||
`id` varchar(64) NOT NULL COMMENT '主键',
|
||||
`device_id` varchar(64) NOT NULL DEFAULT '' COMMENT '设备id',
|
||||
`env_id` varchar(64) NOT NULL DEFAULT '' COMMENT '设备id',
|
||||
`user_id` varchar(64) NOT NULL DEFAULT '' COMMENT '用户id',
|
||||
`start_timestamp` bigint(20) NOT NULL COMMENT '开始时间',
|
||||
`end_timestamp` bigint(20) NOT NULL COMMENT '结束时间',
|
||||
`end_timestamp` bigint(20) NOT NULL DEFAULT -1 COMMENT '结束时间',
|
||||
`status` int(1) NOT NULL DEFAULT 1 COMMENT '状态,1:使用中;2:已结束',
|
||||
`job_id` varchar(64) NOT NULL DEFAULT '' COMMENT '任务id',
|
||||
`workspace_id` varchar(64) NOT NULL DEFAULT '' COMMENT '工作空间ID',
|
||||
|
||||
Reference in New Issue
Block a user