NavbarMapper.xml 5.59 KB
<?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.diligrp.manage.dao.impl.NavbarDaoImpl">
    <resultMap id="NavbarRM" type="com.diligrp.manage.domain.Navbar">
            <id property="id" column="id"/>
            <result property="projectName" column="project_name"/>
            <result property="description" column="description"/>
            <result property="created" column="created"/>
            <result property="modified" column="modified"/>
            <result property="code" column="code"/>
    </resultMap>


	<select id="getById" parameterType="Long" resultMap="NavbarRM">
		<![CDATA[
		SELECT
		    id
		    ,project_name
		    ,description
		    ,created
		    ,modified
		    ,code
		FROM security_navbar

		WHERE id=#{pk}
		AND (yn is null or yn = 1)
		]]>
	</select>
	<select id="findByCode" parameterType="string" resultMap="NavbarRM">
		<![CDATA[
		SELECT
		    id
		    ,project_name
		    ,description
		    ,created
		    ,modified
		    ,code
		FROM security_navbar

		WHERE code=#{pk}
		AND (yn is null or yn = 1)
		]]>
	</select>

	<insert id="save" parameterType="com.diligrp.manage.domain.Navbar">
        <selectKey keyProperty="id" resultType="long" order="AFTER">
            SELECT LAST_INSERT_ID();
        </selectKey>
		<![CDATA[
		INSERT INTO security_navbar(
                    project_name
                    ,description
                    ,code
		) VALUES(
                    #{projectName}
                    ,#{description}
                    ,#{code}
		)
		]]>
	</insert>

    <update id="update" parameterType="com.diligrp.manage.domain.Navbar">
    <![CDATA[
            UPDATE security_navbar set
                        project_name=#{projectName}
                        ,description=#{description}
                        ,modified=#{modified}
                        ,code=#{code}

            where 1=1
            and id = #{id}
            ]]>
    </update>

	<select id="countByCondition" parameterType="Query" resultType="Integer">
		<![CDATA[
		SELECT count(1) FROM security_navbar where 1=1
		]]>
        <if test="param != null">
            <if test="param.id != null and param.id != ''">
            and id = #{param.id}
            </if>
            <if test="param.projectName != null and param.projectName != ''">
            and project_name = #{param.projectName}
            </if>
            <if test="param.description != null and param.description != ''">
            and description = #{param.description}
            </if>
            <if test="param.code != null and param.code != ''">
            and code = #{param.code}
            </if>
            <if test="param.created != null and param.created != ''">
            and DATE_FORMAT(created, '%Y-%m-%d') = #{param.created}
            </if>
            <if test="param.modified != null and param.modified != ''">
            and DATE_FORMAT(modified, '%Y-%m-%d') = #{param.modified}
            </if>
        </if>
        and (yn is null or yn = 1)
	</select>

	<select id="listByCondition" parameterType="Query" resultMap="NavbarRM">
		<![CDATA[
		SELECT
		    id
		    ,project_name
		    ,description
		    ,created
		    ,code
		    ,modified
		FROM security_navbar where 1=1
		]]>
        <if test="param != null">
            <if test="param.id != null and param.id != ''">
                and id = #{param.id}
            </if>
            <if test="param.code != null and param.code != ''">
                and code = #{param.code}
            </if>
            <if test="param.projectName != null and param.projectName != ''">
                and project_name = #{param.projectName}
            </if>
            <if test="param.description != null and param.description != ''">
                and description = #{param.description}
            </if>
            <if test="param.created != null and param.created != ''">
                and DATE_FORMAT(created, '%Y-%m-%d') = #{param.created}
            </if>
            <if test="param.modified != null and param.modified != ''">
                and DATE_FORMAT(modified, '%Y-%m-%d') = #{param.modified}
            </if>
        </if>
        and (yn is null or yn = 1)
        order by id desc
		<![CDATA[
		limit #{startRow},#{pageSize}
		]]>
	</select>

	<select id="findAll" parameterType="Query" resultMap="NavbarRM">
		<![CDATA[
		SELECT
		    id
		    ,project_name
		    ,description
		    ,created
		    ,modified
		    ,code
		FROM security_navbar where 1=1
		]]>
        <if test="param != null">
            <if test="param.id != null and param.id != ''">
                and id = #{param.id}
            </if>
            <if test="param.code != null and param.code != ''">
                and code = #{param.code}
            </if>
            <if test="param.projectName != null and param.projectName != ''">
                and project_name = #{param.projectName}
            </if>
            <if test="param.description != null and param.description != ''">
                and description = #{param.description}
            </if>
            <if test="param.created != null and param.created != ''">
                and created = #{param.created}
            </if>
            <if test="param.modified != null and param.modified != ''">
                and modified = #{param.modified}
            </if>
        </if>
        and (yn is null or yn = 1)
        order by id desc
	</select>


    <update id="deleteById" parameterType="Long">
    <![CDATA[
        update security_navbar set
        yn = 2
        where 1 = 1
        and id = #{id}
    ]]>
    </update>

</mapper>