/* SynonymManageMapper.deleteSynonym */
UPDATE TB_SYNONYM_MASTER SET
USE_YN='N'
WHERE SEQ=#{seq}
/* SynonymManageMapper.insertSynonymMaster */
INSERT INTO TB_SYNONYM_MASTER
(OPR_MNG_CODE, IDIV_WORD, REP_WORD, IF_MAPPING_ID, USE_YN, REGIST_ID, REGIST_DATE, UPDATE_ID, UPDATE_DATE)
VALUES
(#{serviceCode}, #{idivWord}, #{repWord}, #{mappingId},'Y', #{userId}, NOW(), #{userId}, NOW())
UPDATE TB_SYNONYM_MASTER
SET
IDIV_WORD=#{idivWord},
REP_WORD=#{repWord},
USE_YN = 'Y',
UPDATE_ID=#{userId},
UPDATE_DATE=NOW()
WHERE
SEQ=#{seq}
/* SynonymManageMapper.insertSynonymWord */
INSERT INTO TB_SYNONYM_WORD
(MASTER_SEQ, OPR_MNG_CODE, SYNONYM_WORD, USE_YN, REGIST_ID, REGIST_DATE, UPDATE_ID, UPDATE_DATE)
SELECT
a.SEQ, #{serviceCode}, #{synonymWord}, 'Y',#{userId}, NOW() ,#{userId}, NOW()
FROM
TB_SYNONYM_MASTER a
WHERE
a.IDIV_WORD=#{idivWord}
AND a.OPR_MNG_CODE=#{serviceCode}
/* SynonymManageMapper.updateSynonymWord */
UPDATE TB_SYNONYM_WORD a,
(SELECT SEQ FROM TB_SYNONYM_MASTER WHERE IDIV_WORD=#{idivWord} AND OPR_MNG_CODE = #{serviceCode} AND USE_YN = 'Y') b
SET
a.MASTER_SEQ=b.SEQ,
a.USE_YN='Y',
a.UPDATE_ID=#{userId},
a.UPDATE_DATE=NOW()
WHERE SYNONYM_WORD = #{synonymWord}
AND OPR_MNG_CODE = #{serviceCode}
/* SynonymManageMapper.saveSynonymList */
UPDATE TB_SYNONYM_MASTER a,
TB_SYNONYM_WORD b
SET
a.IDIV_WORD = #{idivWord},
a.REP_WORD = #{repWord},
a.UPDATE_ID = #{userId},
a.UPDATE_DATE = NOW()
, b.USE_YN = IF(b.SYNONYM_WORD IN(
#{item}
), 'Y', 'N')
WHERE
a.IDIV_WORD = #{idivWord}
AND b.MASTER_SEQ = a.SEQ
AND a.USE_YN = 'Y'
AND b.OPR_MNG_CODE = #{serviceCode};
/* SynonymManageMapper.deleteSynonymWord */
UPDATE TB_SYNONYM_WORD SET
USE_YN='N'
WHERE MASTER_SEQ=#{seq}