<?xml version="1.0" encoding="UTF-8"?>

<!--
  ~
  ~      Copyright (c) 2018-2025, lengleng All rights reserved.
  ~
  ~  Redistribution and use in source and binary forms, with or without
  ~  modification, are permitted provided that the following conditions are met:
  ~
  ~ Redistributions of source code must retain the above copyright notice,
  ~  this list of conditions and the following disclaimer.
  ~  Redistributions in binary form must reproduce the above copyright
  ~  notice, this list of conditions and the following disclaimer in the
  ~  documentation and/or other materials provided with the distribution.
  ~  Neither the name of the yifu4cloud.com developer nor the names of its
  ~  contributors may be used to endorse or promote products derived from
  ~  this software without specific prior written permission.
  ~  Author: lengleng (wangiegie@gmail.com)
  ~
  -->

<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.yifu.cloud.plus.v1.yifu.social.mapper.SysHouseHoldInfoMapper">

  <resultMap id="sysHouseHoldInfoMap" type="com.yifu.cloud.plus.v1.yifu.social.entity.SysHouseHoldInfo">
    <id property="id" column="ID"/>
    <result property="organId" column="ORGAN_ID"/>
    <result property="name" column="NAME"/>
    <result property="createTime" column="CREATE_TIME"/>
    <result property="delFlag" column="DEL_FLAG"/>
    <result property="type" column="TYPE"/>
    <result property="province" column="PROVINCE"/>
    <result property="city" column="CITY"/>
    <result property="town" column="TOWN"/>
    <result property="rmark" column="RMARK"/>
    <result property="organName" column="ORGAN_NAME"/>
    <result property="createBy" column="CREATE_BY"/>
    <result property="updateBy" column="UPDATE_BY"/>
    <result property="createName" column="CREATE_NAME"/>
    <result property="createTime" column="CREATE_TIME"/>
    <result property="updateTime" column="UPDATE_TIME"/>
  </resultMap>
    <sql id="Base_Column_List">
                a.ID,
                a.ORGAN_ID,
                a.NAME,
                a.CREATE_TIME,
                a.DEL_FLAG,
                a.TYPE,
                a.PROVINCE,
                a.CITY,
                a.TOWN,
                a.RMARK,
                a.ORGAN_NAME,
                a.CREATE_BY,
                a.UPDATE_BY,
                a.CREATE_NAME,
                a.UPDATE_TIME
    </sql>
    <sql id="sysHouseHoldInfo_where">
        <if test="sysHouseHoldInfo != null">
                    <if test="sysHouseHoldInfo.id != null and sysHouseHoldInfo.id.trim() != ''">
                        AND a.ID = #{sysHouseHoldInfo.id}
                    </if>
                    <if test="sysHouseHoldInfo.organId != null and sysHouseHoldInfo.organId.trim() != ''">
                        AND a.ORGAN_ID = #{sysHouseHoldInfo.organId}
                    </if>
                    <if test="sysHouseHoldInfo.name != null and sysHouseHoldInfo.name.trim() != ''">
						AND a.NAME like CONCAT('%',#{sysHouseHoldInfo.name},'%')
                    </if>
                    <if test="sysHouseHoldInfo.createTime != null">
                        AND a.CREATE_TIME = #{sysHouseHoldInfo.createTime}
                    </if>
                    <if test="sysHouseHoldInfo.delFlag != null and sysHouseHoldInfo.delFlag.trim() != ''">
                        AND a.DEL_FLAG = #{sysHouseHoldInfo.delFlag}
                    </if>
                    <if test="sysHouseHoldInfo.type != null and sysHouseHoldInfo.type.trim() != ''">
                        AND a.TYPE = #{sysHouseHoldInfo.type}
                    </if>
                    <if test="sysHouseHoldInfo.province != null and sysHouseHoldInfo.province.trim() != ''">
                        AND a.PROVINCE = #{sysHouseHoldInfo.province}
                    </if>
                    <if test="sysHouseHoldInfo.city != null and sysHouseHoldInfo.city.trim() != ''">
                        AND a.CITY = #{sysHouseHoldInfo.city}
                    </if>
                    <if test="sysHouseHoldInfo.town != null and sysHouseHoldInfo.town.trim() != ''">
                        AND a.TOWN = #{sysHouseHoldInfo.town}
                    </if>
                    <if test="sysHouseHoldInfo.rmark != null and sysHouseHoldInfo.rmark.trim() != ''">
                        AND a.RMARK = #{sysHouseHoldInfo.rmark}
                    </if>
                    <if test="sysHouseHoldInfo.organName != null and sysHouseHoldInfo.organName.trim() != ''">
                        AND a.ORGAN_NAME = #{sysHouseHoldInfo.organName}
                    </if>
                    <if test="sysHouseHoldInfo.createBy != null and sysHouseHoldInfo.createBy.trim() != ''">
                        AND a.CREATE_BY = #{sysHouseHoldInfo.createBy}
                    </if>
                    <if test="sysHouseHoldInfo.updateBy != null and sysHouseHoldInfo.updateBy.trim() != ''">
                        AND a.UPDATE_BY = #{sysHouseHoldInfo.updateBy}
                    </if>
                    <if test="sysHouseHoldInfo.createName != null and sysHouseHoldInfo.createName.trim() != ''">
                        AND a.CREATE_NAME = #{sysHouseHoldInfo.createName}
                    </if>
                    <if test="sysHouseHoldInfo.updateTime != null">
                        AND a.UPDATE_TIME = #{sysHouseHoldInfo.updateTime}
                    </if>
        </if>
    </sql>
    <!--sysHouseHoldInfo简单分页查询-->
    <select id="getSysHouseHoldInfoPage" resultMap="sysHouseHoldInfoMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM sys_house_hold_info a
        <where>
            1=1
            <include refid="sysHouseHoldInfo_where"/>
        </where>
		order by a.CREATE_TIME desc
    </select>
</mapper>
