feat:升级功能、密码卡框架、主密钥接口
This commit is contained in:
@@ -167,9 +167,64 @@ tms:
|
||||
memory-total-default: ${TMS_DEVICE_PROFILE_MEMORY_TOTAL_DEFAULT:16GB}
|
||||
# 磁盘总量默认展示值;命令读取失败或为空时回退。
|
||||
disk-total-default: ${TMS_DEVICE_PROFILE_DISK_TOTAL_DEFAULT:256G}
|
||||
web:
|
||||
cors:
|
||||
# 是否启用浏览器跨域访问控制。
|
||||
enabled: ${TMS_WEB_CORS_ENABLED:true}
|
||||
# 允许的前端来源;默认放开本机联调端口,部署时请改成明确前端域名/IP。
|
||||
allowed-origin-patterns:
|
||||
- ${TMS_WEB_CORS_ALLOWED_ORIGIN_PATTERN_1:http://localhost:*}
|
||||
- ${TMS_WEB_CORS_ALLOWED_ORIGIN_PATTERN_2:http://127.0.0.1:*}
|
||||
# 允许浏览器预检和业务请求使用的方法。
|
||||
allowed-methods:
|
||||
- GET
|
||||
- POST
|
||||
- PUT
|
||||
- DELETE
|
||||
- OPTIONS
|
||||
# 允许前端发送的请求头;覆盖内部 token、OpenAPI 签名头和 traceId。
|
||||
allowed-headers:
|
||||
- Authorization
|
||||
- Content-Type
|
||||
- X-Requested-With
|
||||
- X-Internal-Token
|
||||
- X-App-Id
|
||||
- X-Timestamp
|
||||
- X-Nonce
|
||||
- X-Signature
|
||||
- X-Trace-Id
|
||||
# 允许前端读取的响应头。
|
||||
exposed-headers:
|
||||
- X-Trace-Id
|
||||
# 是否允许跨域携带 cookie / 凭据。
|
||||
allow-credentials: ${TMS_WEB_CORS_ALLOW_CREDENTIALS:true}
|
||||
# 浏览器预检缓存时间(秒)。
|
||||
max-age-seconds: ${TMS_WEB_CORS_MAX_AGE_SECONDS:3600}
|
||||
upgrade:
|
||||
# 升级包解压和脚本执行暂存目录。
|
||||
staging-root-dir: ${TMS_UPGRADE_STAGING_ROOT_DIR:/home/tmp/tms-upgrade-staging}
|
||||
# 升级任务统一日志目录。
|
||||
log-dir: ${TMS_UPGRADE_LOG_DIR:/home/tms/tmp/tms-upgrade-logs}
|
||||
# 升级包验签使用的“固件完整性密钥”公钥 blob(Base64 编码);为空时升级预检会拒绝通过。
|
||||
signature-public-key-base64: ${TMS_UPGRADE_SIGNATURE_PUBLIC_KEY_BASE64:}
|
||||
mk:
|
||||
init-identify:
|
||||
# SDFE_InitIdentify 旧 PIN(Base64 编码);主密钥初始化接口会读取该值。
|
||||
old-pin-base64: ${TMS_MK_INIT_IDENTIFY_OLD_PIN_BASE64:NjY2NjY2}
|
||||
# SDFE_InitIdentify 新 PIN(Base64 编码);主密钥初始化接口会读取该值。
|
||||
new-pin-base64: ${TMS_MK_INIT_IDENTIFY_NEW_PIN_BASE64:NjY2NjY2}
|
||||
security:
|
||||
# 内部接口鉴权 token(前后端内部调用需一致)。
|
||||
internal-token: ${TMS_INTERNAL_TOKEN:change-me-internal-token}
|
||||
internal-auth:
|
||||
# 是否启用 /api/** 的内部登录鉴权;开发联调时可临时关闭。
|
||||
enabled: ${TMS_SECURITY_INTERNAL_AUTH_ENABLED:false}
|
||||
# 关闭内部鉴权后,注入请求上下文的调试角色。
|
||||
debug-role-code: ${TMS_SECURITY_INTERNAL_AUTH_DEBUG_ROLE_CODE:KEY_ADMIN}
|
||||
# 关闭内部鉴权后,注入请求上下文的调试认证等级。
|
||||
debug-auth-level: ${TMS_SECURITY_INTERNAL_AUTH_DEBUG_AUTH_LEVEL:FULL}
|
||||
# 关闭内部鉴权后,注入请求上下文的调试 session token。
|
||||
debug-session-token: ${TMS_SECURITY_INTERNAL_AUTH_DEBUG_SESSION_TOKEN:DEBUG-BYPASS}
|
||||
openapi:
|
||||
# 外部签名服务接口允许的时间戳偏差(秒),防重放。
|
||||
timestamp-skew-seconds: 300
|
||||
@@ -182,8 +237,8 @@ tms:
|
||||
# 密码卡模式:MOCK(模拟)/JNA(动态库调用)等。
|
||||
mode: ${TMS_CRYPTO_CARD_MODE:JNA}
|
||||
# 动态库目录(.so 所在目录)。
|
||||
vendor-lib-path: ${TMS_CRYPTO_VENDOR_LIB_PATH:/home/tms/lib/libsdf_syd1408-x64.so.1.0.0}
|
||||
vendor-lib-path: ${TMS_CRYPTO_VENDOR_LIB_PATH:/home/tms/libs/libsdf_ukey_syd1408-x64.so.1.0.0}
|
||||
# 动态库名(不含前缀/后缀或按加载器约定)。
|
||||
vendor-lib-name: ${TMS_CRYPTO_VENDOR_LIB_NAME:syd1408}
|
||||
vendor-lib-name: ${TMS_CRYPTO_VENDOR_LIB_NAME:sdf_ukey_syd1408}
|
||||
# 是否严格校验算法标识(与 0018/厂商补充定义一致性校验)。
|
||||
strict-alg-id-validation: ${TMS_CRYPTO_STRICT_ALG_ID_VALIDATION:true}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
CREATE TABLE IF NOT EXISTS t_upgrade_task (
|
||||
id BIGINT PRIMARY KEY,
|
||||
task_id VARCHAR(64) NOT NULL,
|
||||
upgrade_mode VARCHAR(16) NOT NULL,
|
||||
target_component VARCHAR(32) NOT NULL,
|
||||
package_file_id VARCHAR(64) NOT NULL,
|
||||
package_name VARCHAR(255) NOT NULL,
|
||||
package_hash VARCHAR(128) NOT NULL,
|
||||
current_version VARCHAR(64) NOT NULL,
|
||||
target_version VARCHAR(64) NOT NULL,
|
||||
status VARCHAR(32) NOT NULL,
|
||||
verify_passed TINYINT(1) NOT NULL DEFAULT 0,
|
||||
verify_message VARCHAR(1024) NULL,
|
||||
manifest_json TEXT NULL,
|
||||
detail_log_path VARCHAR(1024) NULL,
|
||||
error_message VARCHAR(1024) NULL,
|
||||
operator VARCHAR(64) NULL,
|
||||
started_at DATETIME(3) NULL,
|
||||
finished_at DATETIME(3) NULL,
|
||||
create_time DATETIME(3) NOT NULL,
|
||||
update_time DATETIME(3) NOT NULL,
|
||||
UNIQUE KEY uk_t_upgrade_task_task_id (task_id),
|
||||
KEY idx_t_upgrade_task_status (status),
|
||||
KEY idx_t_upgrade_task_component (target_component),
|
||||
KEY idx_t_upgrade_task_create_time (create_time)
|
||||
);
|
||||
@@ -0,0 +1,157 @@
|
||||
CREATE TABLE IF NOT EXISTS tms_role_account (
|
||||
id BIGINT PRIMARY KEY,
|
||||
role_code VARCHAR(64) NOT NULL,
|
||||
display_name VARCHAR(128) NOT NULL,
|
||||
required_ukey_count INT NOT NULL,
|
||||
password_hash VARCHAR(256) NOT NULL,
|
||||
password_salt VARCHAR(128) NOT NULL,
|
||||
status VARCHAR(32) NOT NULL,
|
||||
need_change_password TINYINT(1) NOT NULL DEFAULT 1,
|
||||
failed_count INT NOT NULL DEFAULT 0,
|
||||
locked_until DATETIME(3) NULL,
|
||||
last_login_at DATETIME(3) NULL,
|
||||
last_active_at DATETIME(3) NULL,
|
||||
create_time DATETIME(3) NOT NULL,
|
||||
update_time DATETIME(3) NOT NULL,
|
||||
UNIQUE KEY uk_tms_role_account_role_code (role_code)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS tms_role_ukey_binding (
|
||||
id BIGINT PRIMARY KEY,
|
||||
role_code VARCHAR(64) NOT NULL,
|
||||
slot_no INT NOT NULL,
|
||||
ukey_serial VARCHAR(128) NOT NULL,
|
||||
ukey_pubkey TEXT NOT NULL,
|
||||
issuer_sign TEXT NULL,
|
||||
status VARCHAR(32) NOT NULL,
|
||||
bound_at DATETIME(3) NOT NULL,
|
||||
unbound_at DATETIME(3) NULL,
|
||||
create_time DATETIME(3) NOT NULL,
|
||||
update_time DATETIME(3) NOT NULL,
|
||||
UNIQUE KEY uk_tms_role_ukey_binding_role_slot (role_code, slot_no),
|
||||
KEY idx_tms_role_ukey_binding_role_status (role_code, status)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS tms_auth_session (
|
||||
id BIGINT PRIMARY KEY,
|
||||
session_token VARCHAR(128) NOT NULL,
|
||||
role_code VARCHAR(64) NOT NULL,
|
||||
auth_level VARCHAR(32) NOT NULL,
|
||||
issued_at DATETIME(3) NOT NULL,
|
||||
last_active_at DATETIME(3) NOT NULL,
|
||||
expires_at DATETIME(3) NOT NULL,
|
||||
logout_at DATETIME(3) NULL,
|
||||
create_time DATETIME(3) NOT NULL,
|
||||
update_time DATETIME(3) NOT NULL,
|
||||
UNIQUE KEY uk_tms_auth_session_token (session_token),
|
||||
KEY idx_tms_auth_session_role_code (role_code)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS tms_auth_challenge (
|
||||
id BIGINT PRIMARY KEY,
|
||||
challenge_id VARCHAR(128) NOT NULL,
|
||||
role_code VARCHAR(64) NOT NULL,
|
||||
purpose VARCHAR(32) NOT NULL,
|
||||
nonce VARCHAR(256) NOT NULL,
|
||||
expires_at DATETIME(3) NOT NULL,
|
||||
used TINYINT(1) NOT NULL DEFAULT 0,
|
||||
create_time DATETIME(3) NOT NULL,
|
||||
update_time DATETIME(3) NOT NULL,
|
||||
UNIQUE KEY uk_tms_auth_challenge_challenge_id (challenge_id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS tms_auth_audit_log (
|
||||
id BIGINT PRIMARY KEY,
|
||||
event_type VARCHAR(64) NOT NULL,
|
||||
role_code VARCHAR(64) NULL,
|
||||
operator_role_code VARCHAR(64) NULL,
|
||||
result VARCHAR(32) NOT NULL,
|
||||
detail_json JSON NULL,
|
||||
remote_ip VARCHAR(64) NULL,
|
||||
create_time DATETIME(3) NOT NULL,
|
||||
update_time DATETIME(3) NOT NULL,
|
||||
KEY idx_tms_auth_audit_log_event_type (event_type),
|
||||
KEY idx_tms_auth_audit_log_role_code (role_code)
|
||||
);
|
||||
|
||||
INSERT IGNORE INTO tms_role_account (
|
||||
id,
|
||||
role_code,
|
||||
display_name,
|
||||
required_ukey_count,
|
||||
password_hash,
|
||||
password_salt,
|
||||
status,
|
||||
need_change_password,
|
||||
failed_count,
|
||||
locked_until,
|
||||
last_login_at,
|
||||
last_active_at,
|
||||
create_time,
|
||||
update_time
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
11001,
|
||||
'SUPER_ADMIN',
|
||||
'超级管理员',
|
||||
3,
|
||||
'Viuew8WE+qziUZwGGU0x25cUpzsTF+QvQFU0uhb+yVA=',
|
||||
'init-super-admin-salt-20260325',
|
||||
'UNENABLED',
|
||||
1,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
CURRENT_TIMESTAMP(3),
|
||||
CURRENT_TIMESTAMP(3)
|
||||
),
|
||||
(
|
||||
11002,
|
||||
'KEY_ADMIN',
|
||||
'密钥管理员',
|
||||
2,
|
||||
'/xqmDy3A/q9X5p7XWznIPSBabQ6bxTLAPgtHQ6Be33c=',
|
||||
'init-key-admin-salt-20260325',
|
||||
'ACTIVE',
|
||||
1,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
CURRENT_TIMESTAMP(3),
|
||||
CURRENT_TIMESTAMP(3)
|
||||
),
|
||||
(
|
||||
11003,
|
||||
'AUDIT_ADMIN',
|
||||
'审计管理员',
|
||||
1,
|
||||
'j/J1LKyUOzVEJfbbHe2dwKBKNdabRk502olk/LWIwhg=',
|
||||
'init-audit-admin-salt-20260325',
|
||||
'UNENABLED',
|
||||
1,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
CURRENT_TIMESTAMP(3),
|
||||
CURRENT_TIMESTAMP(3)
|
||||
),
|
||||
(
|
||||
11004,
|
||||
'OPS_ADMIN',
|
||||
'运维管理员',
|
||||
1,
|
||||
'2e9F4aCgsDb+AuD1LrBEqEg8yjy3ODo27UHtx06vj/A=',
|
||||
'init-ops-admin-salt-20260325',
|
||||
'UNENABLED',
|
||||
1,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
CURRENT_TIMESTAMP(3),
|
||||
CURRENT_TIMESTAMP(3)
|
||||
);
|
||||
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE tms_init_task
|
||||
ADD COLUMN task_type VARCHAR(32) NOT NULL DEFAULT 'INIT' COMMENT '任务类型:INIT/RESET' AFTER task_id;
|
||||
@@ -0,0 +1,12 @@
|
||||
CREATE TABLE IF NOT EXISTS sys_device_software_version (
|
||||
id BIGINT PRIMARY KEY,
|
||||
component_code VARCHAR(64) NOT NULL,
|
||||
component_name VARCHAR(128) NOT NULL,
|
||||
current_version VARCHAR(128) NOT NULL,
|
||||
source_type VARCHAR(32) NOT NULL,
|
||||
detected_at DATETIME NULL,
|
||||
remarks VARCHAR(255) NULL,
|
||||
create_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
update_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
UNIQUE KEY uk_sys_device_software_version_component_code (component_code)
|
||||
);
|
||||
@@ -0,0 +1 @@
|
||||
RENAME TABLE sys_device_software_version TO tms_device_software_version;
|
||||
@@ -0,0 +1,15 @@
|
||||
INSERT INTO tms_device_software_version
|
||||
(id, component_code, component_name, current_version, source_type, detected_at, remarks)
|
||||
VALUES
|
||||
(1001, 'RABBITMQ', '消息队列', 'RabbitMQ V3.8.21', 'MANUAL', NOW(), '出厂预置'),
|
||||
(1002, 'TLQ', '消息队列', 'tonglink/Q V8.1.11', 'MANUAL', NOW(), '出厂预置'),
|
||||
(1003, 'TIDB', '数据库', 'TiDB V8.1.0', 'MANUAL', NOW(), '出厂预置'),
|
||||
(1004, 'NGINX', 'Nginx', 'Nginx V1.20', 'MANUAL', NOW(), '出厂预置'),
|
||||
(1005, 'APP', '标准收发器企业版', '标准收发器企业版 V1.3.2', 'MANUAL', NOW(), '出厂预置')
|
||||
ON DUPLICATE KEY UPDATE
|
||||
component_name = VALUES(component_name),
|
||||
current_version = VALUES(current_version),
|
||||
source_type = VALUES(source_type),
|
||||
detected_at = VALUES(detected_at),
|
||||
remarks = VALUES(remarks),
|
||||
update_time = CURRENT_TIMESTAMP;
|
||||
@@ -0,0 +1,35 @@
|
||||
<?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.cisd.tms.modules.auth.mapper.AuthSessionMapper">
|
||||
|
||||
<resultMap id="AuthSessionResultMap" type="com.cisd.tms.modules.auth.entity.AuthSessionEntity">
|
||||
<id property="id" column="id"/>
|
||||
<result property="sessionToken" column="session_token"/>
|
||||
<result property="roleCode" column="role_code"/>
|
||||
<result property="authLevel" column="auth_level"/>
|
||||
<result property="issuedAt" column="issued_at"/>
|
||||
<result property="lastActiveAt" column="last_active_at"/>
|
||||
<result property="expiresAt" column="expires_at"/>
|
||||
<result property="logoutAt" column="logout_at"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectBySessionToken" parameterType="string" resultMap="AuthSessionResultMap">
|
||||
SELECT id,
|
||||
session_token,
|
||||
role_code,
|
||||
auth_level,
|
||||
issued_at,
|
||||
last_active_at,
|
||||
expires_at,
|
||||
logout_at,
|
||||
create_time,
|
||||
update_time
|
||||
FROM tms_auth_session
|
||||
WHERE session_token = #{sessionToken}
|
||||
LIMIT 1
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,43 @@
|
||||
<?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.cisd.tms.modules.auth.mapper.RoleAccountMapper">
|
||||
|
||||
<resultMap id="RoleAccountResultMap" type="com.cisd.tms.modules.auth.entity.RoleAccountEntity">
|
||||
<id property="id" column="id"/>
|
||||
<result property="roleCode" column="role_code"/>
|
||||
<result property="displayName" column="display_name"/>
|
||||
<result property="requiredUkeyCount" column="required_ukey_count"/>
|
||||
<result property="passwordHash" column="password_hash"/>
|
||||
<result property="passwordSalt" column="password_salt"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="needChangePassword" column="need_change_password"/>
|
||||
<result property="failedCount" column="failed_count"/>
|
||||
<result property="lockedUntil" column="locked_until"/>
|
||||
<result property="lastLoginAt" column="last_login_at"/>
|
||||
<result property="lastActiveAt" column="last_active_at"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectByRoleCode" parameterType="string" resultMap="RoleAccountResultMap">
|
||||
SELECT id,
|
||||
role_code,
|
||||
display_name,
|
||||
required_ukey_count,
|
||||
password_hash,
|
||||
password_salt,
|
||||
status,
|
||||
need_change_password,
|
||||
failed_count,
|
||||
locked_until,
|
||||
last_login_at,
|
||||
last_active_at,
|
||||
create_time,
|
||||
update_time
|
||||
FROM tms_role_account
|
||||
WHERE role_code = #{roleCode}
|
||||
LIMIT 1
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,57 @@
|
||||
<?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.cisd.tms.modules.auth.mapper.RoleUkeyBindingMapper">
|
||||
|
||||
<resultMap id="RoleUkeyBindingResultMap" type="com.cisd.tms.modules.auth.entity.RoleUkeyBindingEntity">
|
||||
<id property="id" column="id"/>
|
||||
<result property="roleCode" column="role_code"/>
|
||||
<result property="slotNo" column="slot_no"/>
|
||||
<result property="ukeySerial" column="ukey_serial"/>
|
||||
<result property="ukeyPubkey" column="ukey_pubkey"/>
|
||||
<result property="issuerSign" column="issuer_sign"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="boundAt" column="bound_at"/>
|
||||
<result property="unboundAt" column="unbound_at"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectActiveByRoleCodeAndSlotNo" resultMap="RoleUkeyBindingResultMap">
|
||||
SELECT id,
|
||||
role_code,
|
||||
slot_no,
|
||||
ukey_serial,
|
||||
ukey_pubkey,
|
||||
issuer_sign,
|
||||
status,
|
||||
bound_at,
|
||||
unbound_at,
|
||||
create_time,
|
||||
update_time
|
||||
FROM tms_role_ukey_binding
|
||||
WHERE role_code = #{roleCode}
|
||||
AND slot_no = #{slotNo}
|
||||
AND status = 'ACTIVE'
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<select id="selectActiveByRoleCode" parameterType="string" resultMap="RoleUkeyBindingResultMap">
|
||||
SELECT id,
|
||||
role_code,
|
||||
slot_no,
|
||||
ukey_serial,
|
||||
ukey_pubkey,
|
||||
issuer_sign,
|
||||
status,
|
||||
bound_at,
|
||||
unbound_at,
|
||||
create_time,
|
||||
update_time
|
||||
FROM tms_role_ukey_binding
|
||||
WHERE role_code = #{roleCode}
|
||||
AND status = 'ACTIVE'
|
||||
ORDER BY slot_no ASC
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,37 @@
|
||||
<?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.cisd.tms.modules.device.mapper.DeviceSoftwareVersionMapper">
|
||||
|
||||
<resultMap id="DeviceSoftwareVersionResultMap" type="com.cisd.tms.modules.device.entity.DeviceSoftwareVersionEntity">
|
||||
<id property="id" column="id"/>
|
||||
<result property="componentCode" column="component_code"/>
|
||||
<result property="componentName" column="component_name"/>
|
||||
<result property="currentVersion" column="current_version"/>
|
||||
<result property="sourceType" column="source_type"/>
|
||||
<result property="detectedAt" column="detected_at"/>
|
||||
<result property="remarks" column="remarks"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectByComponentCode" parameterType="string" resultMap="DeviceSoftwareVersionResultMap">
|
||||
SELECT id, component_code, component_name, current_version, source_type, detected_at, remarks, create_time, update_time
|
||||
FROM tms_device_software_version
|
||||
WHERE component_code = #{componentCode}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<update id="updateByComponentCode" parameterType="com.cisd.tms.modules.device.entity.DeviceSoftwareVersionEntity">
|
||||
UPDATE tms_device_software_version
|
||||
SET component_name = #{componentName},
|
||||
current_version = #{currentVersion},
|
||||
source_type = #{sourceType},
|
||||
detected_at = #{detectedAt},
|
||||
remarks = #{remarks},
|
||||
update_time = NOW()
|
||||
WHERE component_code = #{componentCode}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,90 @@
|
||||
<?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.cisd.tms.modules.upgrade.mapper.UpgradeTaskMapper">
|
||||
|
||||
<resultMap id="UpgradeTaskResultMap" type="com.cisd.tms.modules.upgrade.entity.UpgradeTaskEntity">
|
||||
<id property="id" column="id"/>
|
||||
<result property="taskId" column="task_id"/>
|
||||
<result property="upgradeMode" column="upgrade_mode"/>
|
||||
<result property="targetComponent" column="target_component"/>
|
||||
<result property="packageFileId" column="package_file_id"/>
|
||||
<result property="packageName" column="package_name"/>
|
||||
<result property="packageHash" column="package_hash"/>
|
||||
<result property="currentVersion" column="current_version"/>
|
||||
<result property="targetVersion" column="target_version"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="verifyPassed" column="verify_passed"/>
|
||||
<result property="verifyMessage" column="verify_message"/>
|
||||
<result property="manifestJson" column="manifest_json"/>
|
||||
<result property="detailLogPath" column="detail_log_path"/>
|
||||
<result property="errorMessage" column="error_message"/>
|
||||
<result property="operator" column="operator"/>
|
||||
<result property="startedAt" column="started_at"/>
|
||||
<result property="finishedAt" column="finished_at"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="UpgradeTaskColumns">
|
||||
id, task_id, upgrade_mode, target_component, package_file_id, package_name, package_hash,
|
||||
current_version, target_version, status, verify_passed, verify_message, manifest_json,
|
||||
detail_log_path, error_message, operator, started_at, finished_at, create_time, update_time
|
||||
</sql>
|
||||
|
||||
<select id="selectByTaskId" parameterType="string" resultMap="UpgradeTaskResultMap">
|
||||
SELECT <include refid="UpgradeTaskColumns"/>
|
||||
FROM t_upgrade_task
|
||||
WHERE task_id = #{taskId}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<select id="selectRunningTask" resultMap="UpgradeTaskResultMap">
|
||||
SELECT <include refid="UpgradeTaskColumns"/>
|
||||
FROM t_upgrade_task
|
||||
WHERE status = 'RUNNING'
|
||||
ORDER BY create_time DESC, id DESC
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<select id="selectPage" resultMap="UpgradeTaskResultMap">
|
||||
SELECT <include refid="UpgradeTaskColumns"/>
|
||||
FROM t_upgrade_task
|
||||
<where>
|
||||
<if test="targetComponent != null and targetComponent != ''">
|
||||
AND target_component = #{targetComponent}
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY create_time DESC, id DESC
|
||||
LIMIT #{limit} OFFSET #{offset}
|
||||
</select>
|
||||
|
||||
<select id="countPage" resultType="long">
|
||||
SELECT COUNT(1)
|
||||
FROM t_upgrade_task
|
||||
<where>
|
||||
<if test="targetComponent != null and targetComponent != ''">
|
||||
AND target_component = #{targetComponent}
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<update id="updateStatusByTaskId">
|
||||
UPDATE t_upgrade_task
|
||||
SET status = #{status},
|
||||
error_message = #{errorMessage},
|
||||
detail_log_path = #{detailLogPath},
|
||||
started_at = #{startedAt},
|
||||
finished_at = #{finishedAt},
|
||||
update_time = NOW()
|
||||
WHERE task_id = #{taskId}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user