feat: ASW-46 新增 device 接口
This commit is contained in:
79
src/main/resources/db/mapper/device/DeviceMapper.xml
Normal file
79
src/main/resources/db/mapper/device/DeviceMapper.xml
Normal file
@@ -0,0 +1,79 @@
|
||||
<?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>
|
||||
@@ -456,3 +456,50 @@ CREATE TABLE `workspace_member` (
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
INSERT INTO `workspace_member` (`workspace_id`, `user_id`, `role_id`, `create_timestamp`, `create_user_id`) VALUES ('1', 'admin', 'admin', 1724291229000, 'admin');
|
||||
|
||||
|
||||
/**
|
||||
* 新增 device 表
|
||||
*/
|
||||
DROP TABLE IF EXISTS `device`;
|
||||
CREATE TABLE `device` (
|
||||
`id` varchar(64) NOT NULL COMMENT '主键',
|
||||
`name` varchar(256) NOT NULL DEFAULT '' COMMENT '名称',
|
||||
`location` varchar(256) NOT NULL DEFAULT '' COMMENT '位置',
|
||||
`platform` varchar(256) NOT NULL DEFAULT 'android' COMMENT '支持的平台,可选:android',
|
||||
`param` varchar(1024) NOT NULL DEFAULT '' COMMENT '连接参数',
|
||||
`description` text NOT NULL DEFAULT '' COMMENT '描述信息',
|
||||
`status` int(1) NOT NULL DEFAULT 0 COMMENT '状态,0:离线;1:在线',
|
||||
`last_health_check` bigint(20) NOT NULL DEFAULT -1 COMMENT '最后健康检查时间',
|
||||
`create_timestamp` bigint(20) NOT NULL COMMENT '创建时间戳',
|
||||
`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
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
|
||||
/**
|
||||
* 新增 device_log 表
|
||||
*/
|
||||
DROP TABLE IF EXISTS `device_log`;
|
||||
CREATE TABLE `device_log` (
|
||||
`id` varchar(64) NOT NULL COMMENT '主键',
|
||||
`device_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 '结束时间',
|
||||
`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',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
KEY `idx_status` (`status`) USING BTREE,
|
||||
KEY `idx_device_id` (`device_id`) USING BTREE,
|
||||
KEY `idx_user_id` (`user_id`) USING BTREE,
|
||||
KEY `idx_job_id` (`job_id`) USING BTREE,
|
||||
KEY `idx_workspace_id` (`workspace_id`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
Reference in New Issue
Block a user