<?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.hzya.frame.u9c.unit.dao.impl.VU9cUnitDaoImpl">

    <resultMap id="get-VU9cUnitEntity-result" type="com.hzya.frame.u9c.unit.entity.VU9cUnitEntity" >
        <result property="unitid" column="unitId" jdbcType="VARCHAR"/>
        <result property="unitcode" column="unitCode" jdbcType="VARCHAR"/>
        <result property="unitname" column="unitName" jdbcType="VARCHAR"/>
        <result property="status" column="status" jdbcType="VARCHAR"/>
        <result property="unitgroupcode" column="unitGroupCode" jdbcType="VARCHAR"/>
        <result property="unitgroupname" column="unitGroupName" jdbcType="VARCHAR"/>
        <result property="updateTime" column="update_time" jdbcType="VARCHAR"/>
    </resultMap>
    <!-- 查询的字段-->
    <sql id = "VU9cUnitEntity_Base_Column_List">
        unitId
       ,unitCode 
        ,unitName 
        ,status 
        ,unitGroupCode 
        ,unitGroupName 
        ,update_time 
     </sql>
 <!-- 查询 采用==查询 -->
 <select id="entity_list_base" resultMap="get-VU9cUnitEntity-result" parameterType = "com.hzya.frame.u9c.unit.entity.VU9cUnitEntity">
    select
    <include refid="VU9cUnitEntity_Base_Column_List" />
    from v_u9c_unit
    <trim prefix="where" prefixOverrides="and"> 
        <if test="unitid != null and unitid != ''"> and unitId = #{unitid} </if>
        <if test="unitcode != null and unitcode != ''"> and unitCode = #{unitcode} </if>
        <if test="unitname != null and unitname != ''"> and unitName = #{unitname} </if>
        <if test="status != null and status != ''"> and status = #{status} </if>
        <if test="unitgroupcode != null and unitgroupcode != ''"> and unitGroupCode = #{unitgroupcode} </if>
        <if test="unitgroupname != null and unitgroupname != ''"> and unitGroupName = #{unitgroupname} </if>
        <if test="updateTime != null and updateTime != ''"> and update_time >= #{updateTime} </if>

    </trim>

</select>


    <!-- 查询计量单位，睿本云专用 -->
    <select id="entity_list_base_reabam" resultMap="get-VU9cUnitEntity-result" parameterType = "com.hzya.frame.u9c.unit.entity.VU9cUnitEntity">
        select
        <include refid="VU9cUnitEntity_Base_Column_List" />
        from v_u9c_unit
        <trim prefix="where" prefixOverrides="and">
            <if test="unitid != null and unitid != ''"> and unitId = #{unitid} </if>
            <if test="unitcode != null and unitcode != ''"> and unitCode = #{unitcode} </if>
            <if test="unitname != null and unitname != ''"> and unitName = #{unitname} </if>
            <if test="status != null and status != ''"> and status = #{status} </if>
            <if test="unitgroupcode != null and unitgroupcode != ''"> and unitGroupCode = #{unitgroupcode} </if>
            <if test="unitgroupname != null and unitgroupname != ''"> and unitGroupName = #{unitgroupname} </if>
            <if test="updateTime != null and updateTime != ''"> and update_time >= #{updateTime} </if>

        </trim>

    </select>
    
<!-- 查询符合条件的数量 -->
<select id="entity_count" resultType="Integer" parameterType = "com.hzya.frame.u9c.unit.entity.VU9cUnitEntity">
        select  count(1)   from v_u9c_unit
    <trim prefix="where" prefixOverrides="and"> 
        <if test="unitid != null and unitid != ''"> and unitId = #{unitid} </if>
        <if test="unitcode != null and unitcode != ''"> and unitCode = #{unitcode} </if>
        <if test="unitname != null and unitname != ''"> and unitName = #{unitname} </if>
        <if test="status != null and status != ''"> and status = #{status} </if>
        <if test="unitgroupcode != null and unitgroupcode != ''"> and unitGroupCode = #{unitgroupcode} </if>
        <if test="unitgroupname != null and unitgroupname != ''"> and unitGroupName = #{unitgroupname} </if>
        <if test="updateTime != null and updateTime != ''"> and update_time = #{updateTime} </if>

    </trim>
    <if test=" sort ==''.toString() "> order by sorts asc</if>
	<if test=" sort !='' and sort!=null and order !='' and order!=null "> order by ${sort} ${order}</if>
    </select>

    <!-- 分页查询列表 采用like格式 -->
<select id="entity_list_like" resultMap="get-VU9cUnitEntity-result" parameterType = "com.hzya.frame.u9c.unit.entity.VU9cUnitEntity">
    select
    <include refid="VU9cUnitEntity_Base_Column_List" />
    from v_u9c_unit
    <trim prefix="where" prefixOverrides="and"> 
        <if test="unitid != null and unitid != ''"> and unitId like concat('%',#{unitid},'%') </if>
        <if test="unitcode != null and unitcode != ''"> and unitCode like concat('%',#{unitcode},'%') </if>
        <if test="unitname != null and unitname != ''"> and unitName like concat('%',#{unitname},'%') </if>
        <if test="status != null and status != ''"> and status like concat('%',#{status},'%') </if>
        <if test="unitgroupcode != null and unitgroupcode != ''"> and unitGroupCode like concat('%',#{unitgroupcode},'%') </if>
        <if test="unitgroupname != null and unitgroupname != ''"> and unitGroupName like concat('%',#{unitgroupname},'%') </if>
        <if test="updateTime != null and updateTime != ''"> and update_time like concat('%',#{updateTime},'%') </if>

    </trim>
    <if test=" sort == ''.toString() "> order by sorts asc</if>
    <if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
</select>

<!-- 查询列表 字段采用or格式 -->
<select id="VU9cUnitentity_list_or" resultMap="get-VU9cUnitEntity-result" parameterType = "com.hzya.frame.u9c.unit.entity.VU9cUnitEntity">
    select
    <include refid="VU9cUnitEntity_Base_Column_List" />
    from v_u9c_unit
    <trim prefix="where" prefixOverrides="and"> 
        <if test="unitid != null and unitid != ''"> or unitId = #{unitid} </if>
        <if test="unitcode != null and unitcode != ''"> or unitCode = #{unitcode} </if>
        <if test="unitname != null and unitname != ''"> or unitName = #{unitname} </if>
        <if test="status != null and status != ''"> or status = #{status} </if>
        <if test="unitgroupcode != null and unitgroupcode != ''"> or unitGroupCode = #{unitgroupcode} </if>
        <if test="unitgroupname != null and unitgroupname != ''"> or unitGroupName = #{unitgroupname} </if>
        <if test="updateTime != null and updateTime != ''"> or update_time = #{updateTime} </if>

    </trim>
    <if test=" sort == ''.toString() "> order by sorts asc</if>
    <if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
</select>

</mapper>

