<?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.ruoyi.project.business.mapper.TcFollowMapper">
    <select id="getNewFollowNo" resultType="String">
        SELECT
            CONCAT(
                    "GJ",
                    DATE_FORMAT( NOW(), "%Y%m%d" ),
                    LPAD( IFNULL( max( SUBSTR( follow_no FROM 11 FOR 4 )), 0 ) + 1, 4, '0' )) AS new_follow_no
        FROM
            tc_follow
        WHERE
            follow_no LIKE CONCAT( "GJ", DATE_FORMAT( CURDATE(), "%Y%m%d" ), '%' )
    </select>
</mapper>