마이바티스 채번 처리 SQL 추가
parent
47b9957ed6
commit
61d383af4c
@ -0,0 +1,33 @@
|
|||||||
|
<?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="numbering">
|
||||||
|
|
||||||
|
<sql id="key">
|
||||||
|
SELECT
|
||||||
|
LPAD(CAST(IFNULL(MAX(${TABLE_KEY}) + 1, 1) AS INT), ${pad}, '0')
|
||||||
|
AS NEW_ID
|
||||||
|
FROM ${TABLE_NAME}
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<sql id="keyByYear">
|
||||||
|
SELECT
|
||||||
|
CONCAT(
|
||||||
|
<include refid="utility.currentYear" />
|
||||||
|
, LPAD(CAST(IFNULL(MAX(SUBSTRING(${TABLE_KEY}, 4+1)) + 1, 1) AS INT), ${pad}-4, '0')
|
||||||
|
) AS NEW_ID
|
||||||
|
FROM ${TABLE_NAME}
|
||||||
|
WHERE ${TABLE_KEY} LIKE CONCAT(<include refid="utility.currentYear" />, '%')
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<sql id="keyBySggAndYear">
|
||||||
|
SELECT
|
||||||
|
CONCAT(
|
||||||
|
#{sggCd}
|
||||||
|
, <include refid="utility.currentYear" />
|
||||||
|
, LPAD(CAST(IFNULL(MAX(SUBSTRING(${TABLE_KEY}, 9+1)) + 1, 1) AS INT), ${pad}-9, '0')
|
||||||
|
) AS NEW_ID
|
||||||
|
FROM ${TABLE_NAME}
|
||||||
|
WHERE ${TABLE_KEY} LIKE CONCAT(#{sggCd}, <include refid="utility.currentYear" />, '%')
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
</mapper>
|
Loading…
Reference in New Issue