From 919c10eb0b96bd0b63d767ad72e5979c758003cc Mon Sep 17 00:00:00 2001 From: mjkhan21 Date: Thu, 18 Apr 2024 14:17:07 +0900 Subject: [PATCH] =?UTF-8?q?sql=20mapper=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/sql/mapper/menu-mapper.xml | 94 +++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 src/main/resources/sql/mapper/menu-mapper.xml diff --git a/src/main/resources/sql/mapper/menu-mapper.xml b/src/main/resources/sql/mapper/menu-mapper.xml new file mode 100644 index 0000000..2856c0b --- /dev/null +++ b/src/main/resources/sql/mapper/menu-mapper.xml @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + +SELECT A.* + FROM TB_MENU A +WHERE MENU_NO = #{menuID} + ORDER BY PRNT_NO, SRT_ORD, MENU_NO + + + + + +/* 메뉴 등록(menuMapper.insertMenu) */ + +SELECT NEW_NO, NEW_ORD + FROM (SELECT IFNULL(MAX(MENU_NO) + 1, 0) NEW_NO FROM TB_MENU) A, + () B +INSERT INTO TB_MENU ( + MENU_NO + , MENU_NM + , PRNT_NO + , PGRM_FILE_NM + , ACTION + , DSCRP + , IMG_NM + , IMG_CNF + , SRT_ORD + , REG_DT + , RGTR +) VALUES ( + #{menu.id} + , #{menu.name} + , #{menu.parentID} + , #{menu.programFilename} + , #{menu.action} + , #{menu.description} + , #{menu.imageName} + , #{menu.imageConf} + , #{menu.sortOrder} + , + , #{currentUser.id} +) + +/* 메뉴 수정(menuMapper.updateMenu) */ +UPDATE TB_MENU SET + MENU_NM = #{menu.name} + , PGRM_FILE_NM = #{menu.programFilename} + , ACTION = #{menu.action} + , DSCRP = #{menu.description} + , IMG_NM = #{menu.imageName} + , IMG_CNF = #{menu.imageConf} +WHERE MENU_NO = #{menu.id} + +SELECT IFNULL(MAX(SRT_ORD) + 1, 0) NEW_ORD FROM TB_MENU WHERE PRNT_NO = IFNULL(#{parentID}, IFNULL(#{menu.parentID}, 0)) + +/* 메뉴 이동(menuMapper.moveMenus) */ +UPDATE TB_MENU SET + PRNT_NO = #{parentID} + , SRT_ORD = SRT_ORD + () + WHERE MENU_NO IN (#{menuID}) + + +/* 메뉴 순서 변경(menuMapper.reorderMenus) */ +UPDATE TB_MENU SET + SRT_ORD = CASE MENU_NO + WHEN #{menuID} THEN #{index} + + ELSE MENU_NO END + WHERE MENU_NO IN (#{menuID}) + +/* 메뉴 제거(menuMapper.removeMenus) */ +DELETE FROM TB_MENU + WHERE MENU_NO IN (#{menuID}) + + + \ No newline at end of file