id,topic_code,name,description,level,update_time,update_user_id,create_time
INSERT INTO kpim_info_topic(id,topic_code,name,description,level,update_time,update_user_id,create_time)
VALUE(UUID(),#{topicCode},#{name},#{description},#{level},NOW(),#{updateUserId},NOW());
UPDATE kpim_info_topic
SET
name = #{name},
description = #{description},
update_time = NOW(),
update_user_id = #{updateUserId}
WHERE 1 = 1
and id = #{id}
and topic_code = #{topicCode}
DELETE FROM kpim_info_topic WHERE id = #{id}
DELETE FROM kpim_info_topic WHERE topic_code LIKE CONCAT(#{topicCode},'%')
SELECT
A.id,A.topic_code,
A.name,A.description,
A.level,A.update_time,A.create_time,
A.update_user_id,
/*B.topic_code as parentTopicCode,*/
IFNULL(B.topic_code,'0') AS parentTopicCode,
B.name as parentTopic,
SU.nickname as updateUserName
FROM kpim_info_topic A
LEFT JOIN kpim_info_topic B
ON LEFT(A.topic_code,LENGTH(A.topic_code)-3) = B.topic_code
LEFT JOIN dc_info_user SU
ON A.update_user_id = SU.id
WHERE A.id = #{id}
SELECT
A.id,A.topic_code,
A.name,A.description,
A.level,A.update_time,A.create_time,
A.update_user_id,
/*B.topic_code as parentTopicCode,*/
IFNULL(B.topic_code,'0') AS parentTopicCode,
B.name as parentTopic ,
SU.nickname as updateUserName
FROM kpim_info_topic A
LEFT JOIN kpim_info_topic B
ON LEFT(A.topic_code,LENGTH(A.topic_code)-3) = B.topic_code
LEFT JOIN dc_info_user SU
ON A.update_user_id = SU.id
WHERE A.topic_code = #{topicCode}
SELECT
A.id,A.topic_code,
A.name,A.description,
A.level,A.update_time,A.create_time,
A.update_user_id,
B.topic_code as parentTopicCode,
B.name as parentTopic ,
SU.nickname as updateUserName
FROM kpim_info_topic A
LEFT JOIN kpim_info_topic B
ON LEFT(A.topic_code,LENGTH(A.topic_code)-3) = B.topic_code
LEFT JOIN dc_info_user SU
ON A.update_user_id = SU.id
WHERE A.topic_code IN
#{item}
SELECT
A.id,A.topic_code,
A.name,A.description,
A.level,A.update_time,A.create_time,
A.update_user_id,
B.topic_code as parentTopicCode,
B.name as parentTopic ,
SU.nickname as updateUserName
FROM kpim_info_topic A
LEFT JOIN kpim_info_topic B
ON LEFT(A.topic_code,LENGTH(A.topic_code)-3) = B.topic_code
LEFT JOIN dc_info_user SU
ON A.update_user_id = SU.id
LEFT JOIN kpim_rel_kpi_topic D
ON A.id = D.topic_id
WHERE D.kpi_id = #{kpiId}
SELECT COUNT(1) FROM kpim_info_topic WHERE id = #{id}
SELECT COUNT(1) FROM kpim_info_topic WHERE topic_code = #{topicCode}
SELECT COUNT(1) FROM kpim_rel_kpi_topic WHERE topic_id = #{topicId}
SELECT COUNT(1) FROM kpim_rel_kpi_topic WHERE topic_id IN
#{item}
SELECT
A.id,A.topic_code,
A.name,A.description,
A.level,A.update_time,A.create_time,
A.update_user_id,
B.topic_code as parentTopicCode,
B.name as parentTopic ,
SU.nickname as updateUserName
FROM kpim_info_topic A
LEFT JOIN kpim_info_topic B
ON LEFT(A.topic_code,LENGTH(A.topic_code)-3) = B.topic_code
LEFT JOIN dc_info_user SU
ON A.update_user_id = SU.id
A.name LIKE CONCAT('%',#{name},'%')
SELECT
FROM kpim_info_topic
topic_code LIKE CONCAT(#{parentTopicCode},'%')
AND topic_code != #{parentTopicCode}
AND level = LENGTH(#{parentTopicCode})/3 + 1
level = 1
SELECT
FROM kpim_info_topic
WHERE topic_code LIKE CONCAT(#{parentTopicCode},'%') AND topic_code != #{parentTopicCode}
SELECT
A.id,
A.topic_code as code,
A.name as name,
/*B.topic_code as pcode*/
IFNULL(B.topic_code,'0') AS pcode
FROM kpim_info_topic A
LEFT JOIN kpim_info_topic B
ON LEFT(A.topic_code,LENGTH(A.topic_code)-3) = B.topic_code
A.name LIKE CONCAT('%',#{name},'%')
order by A.create_time asc