| <?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="doumeemes.dao.ext.DepartmentExtMapper"> | 
|   | 
|   <!-- 管理页面查询 --> | 
|   <resultMap id="DepartmentExtListVO" type="doumeemes.dao.ext.vo.DepartmentExtListVO" autoMapping="true"> | 
|     <id column="ID" jdbcType="INTEGER" property="id"/> | 
|     <association property="pmodel" javaType="doumeemes.dao.business.model.Department"> | 
|       <id column="PMODEL_ID" jdbcType="INTEGER" property="id"/> | 
|       <result column="PMODEL_DELETED" jdbcType="TINYINT" property="deleted"/> | 
|       <result column="PMODEL_CREATE_USER" jdbcType="INTEGER" property="createUser"/> | 
|       <result column="PMODEL_CREATE_TIME" jdbcType="TIMESTAMP" property="createTime"/> | 
|       <result column="PMODEL_UPDATE_USER" jdbcType="INTEGER" property="updateUser"/> | 
|       <result column="PMODEL_UPDATE_TIME" jdbcType="TIMESTAMP" property="updateTime"/> | 
|       <result column="PMODEL_NAME" jdbcType="VARCHAR" property="name"/> | 
|       <result column="PMODEL_REMARK" jdbcType="VARCHAR" property="remark"/> | 
|       <result column="PMODEL_ROOT_ID" jdbcType="INTEGER" property="rootId"/> | 
|       <result column="PMODEL_PARENT_ID" jdbcType="INTEGER" property="parentId"/> | 
|       <result column="PMODEL_COMPANY_ID" jdbcType="INTEGER" property="companyId"/> | 
|       <result column="PMODEL_TYPE" jdbcType="TINYINT" property="type"/> | 
|       <result column="PMODEL_ERP_ID" jdbcType="VARCHAR" property="erpId"/> | 
|       <result column="PMODEL_STATUS" jdbcType="INTEGER" property="status"/> | 
|       <result column="PMODEL_VALID_TIME" jdbcType="TIMESTAMP" property="validTime"/> | 
|       <result column="PMODEL_INVALID_TIME" jdbcType="TIMESTAMP" property="invalidTime"/> | 
|     </association> | 
|     <association property="rmodel" javaType="doumeemes.dao.business.model.Department"> | 
|       <id column="RMODEL_ID" jdbcType="INTEGER" property="id"/> | 
|       <result column="RMODEL_DELETED" jdbcType="TINYINT" property="deleted"/> | 
|       <result column="RMODEL_CREATE_USER" jdbcType="INTEGER" property="createUser"/> | 
|       <result column="RMODEL_CREATE_TIME" jdbcType="TIMESTAMP" property="createTime"/> | 
|       <result column="RMODEL_UPDATE_USER" jdbcType="INTEGER" property="updateUser"/> | 
|       <result column="RMODEL_UPDATE_TIME" jdbcType="TIMESTAMP" property="updateTime"/> | 
|       <result column="RMODEL_NAME" jdbcType="VARCHAR" property="name"/> | 
|       <result column="RMODEL_REMARK" jdbcType="VARCHAR" property="remark"/> | 
|       <result column="RMODEL_ROOT_ID" jdbcType="INTEGER" property="rootId"/> | 
|       <result column="RMODEL_PARENT_ID" jdbcType="INTEGER" property="parentId"/> | 
|       <result column="RMODEL_COMPANY_ID" jdbcType="INTEGER" property="companyId"/> | 
|       <result column="RMODEL_TYPE" jdbcType="TINYINT" property="type"/> | 
|       <result column="RMODEL_ERP_ID" jdbcType="VARCHAR" property="erpId"/> | 
|       <result column="RMODEL_STATUS" jdbcType="INTEGER" property="status"/> | 
|       <result column="RMODEL_VALID_TIME" jdbcType="TIMESTAMP" property="validTime"/> | 
|       <result column="RMODEL_INVALID_TIME" jdbcType="TIMESTAMP" property="invalidTime"/> | 
|     </association> | 
|   </resultMap> | 
|   <select id="selectList" parameterType="doumeemes.dao.ext.dto.QueryDepartmentExtDTO" resultMap="DepartmentExtListVO"> | 
|     SELECT | 
|       `a`.*, | 
|       `pmodel`.`ID` AS PMODEL_ID, | 
|       `pmodel`.`DELETED` AS PMODEL_DELETED, | 
|       `pmodel`.`CREATE_USER` AS PMODEL_CREATE_USER, | 
|       `pmodel`.`CREATE_TIME` AS PMODEL_CREATE_TIME, | 
|       `pmodel`.`UPDATE_USER` AS PMODEL_UPDATE_USER, | 
|       `pmodel`.`UPDATE_TIME` AS PMODEL_UPDATE_TIME, | 
|       `pmodel`.`NAME` AS PMODEL_NAME, | 
|       `pmodel`.`REMARK` AS PMODEL_REMARK, | 
|       `pmodel`.`ROOT_ID` AS PMODEL_ROOT_ID, | 
|       `pmodel`.`PARENT_ID` AS PMODEL_PARENT_ID, | 
|       `pmodel`.`COMPANY_ID` AS PMODEL_COMPANY_ID, | 
|       `pmodel`.`TYPE` AS PMODEL_TYPE, | 
|       `pmodel`.`ERP_ID` AS PMODEL_ERP_ID, | 
|       `pmodel`.`STATUS` AS PMODEL_STATUS, | 
|       `pmodel`.`VALID_TIME` AS PMODEL_VALID_TIME, | 
|       `pmodel`.`INVALID_TIME` AS PMODEL_INVALID_TIME, | 
|       `rmodel`.`ID` AS RMODEL_ID, | 
|       `rmodel`.`DELETED` AS RMODEL_DELETED, | 
|       `rmodel`.`CREATE_USER` AS RMODEL_CREATE_USER, | 
|       `rmodel`.`CREATE_TIME` AS RMODEL_CREATE_TIME, | 
|       `rmodel`.`UPDATE_USER` AS RMODEL_UPDATE_USER, | 
|       `rmodel`.`UPDATE_TIME` AS RMODEL_UPDATE_TIME, | 
|       `rmodel`.`NAME` AS RMODEL_NAME, | 
|       `rmodel`.`REMARK` AS RMODEL_REMARK, | 
|       `rmodel`.`ROOT_ID` AS RMODEL_ROOT_ID, | 
|       `rmodel`.`PARENT_ID` AS RMODEL_PARENT_ID, | 
|       `rmodel`.`COMPANY_ID` AS RMODEL_COMPANY_ID, | 
|       `rmodel`.`TYPE` AS RMODEL_TYPE, | 
|       `rmodel`.`ERP_ID` AS RMODEL_ERP_ID, | 
|       `rmodel`.`STATUS` AS RMODEL_STATUS, | 
|       `rmodel`.`VALID_TIME` AS RMODEL_VALID_TIME, | 
|       `rmodel`.`INVALID_TIME` AS RMODEL_INVALID_TIME, | 
|            cu.realname as creatorUsername, | 
|            uu.realname as updateUsername | 
|     FROM `department` `a` | 
|     LEFT JOIN `department` `pmodel` ON a.PARENT_ID=pmodel.ID | 
|     LEFT JOIN `department` `rmodel` ON a.ROOT_ID=rmodel.ID | 
|     LEFT JOIN `system_user` cu ON a.`CREATE_USER`=cu.ID | 
|     LEFT JOIN `system_user` uu ON a.`UPDATE_USER`=uu.ID | 
|     <where> | 
|       <if test="id != null"> | 
|         AND `a`.`ID` = #{id} | 
|       </if> | 
|       <if test="deleted != null"> | 
|         AND `a`.`DELETED` = #{deleted} | 
|       </if> | 
|       <if test="createUser != null"> | 
|         AND `a`.`CREATE_USER` = #{createUser} | 
|       </if> | 
|       <if test="createTime != null"> | 
|         AND `a`.`CREATE_TIME` = #{createTime} | 
|       </if> | 
|       <if test="updateUser != null"> | 
|         AND `a`.`UPDATE_USER` = #{updateUser} | 
|       </if> | 
|       <if test="updateTime != null"> | 
|         AND `a`.`UPDATE_TIME` = #{updateTime} | 
|       </if> | 
|       <if test="name != null and name != ''"> | 
|         AND `a`.`NAME` = #{name} | 
|       </if> | 
|       <if test="remark != null and remark != ''"> | 
|         AND `a`.`REMARK` = #{remark} | 
|       </if> | 
|       <if test="rootId != null"> | 
|         AND `a`.`ROOT_ID` = #{rootId} | 
|       </if> | 
|       <if test="parentId != null"> | 
|         AND `a`.`PARENT_ID` = #{parentId} | 
|       </if> | 
|       <if test="companyId != null"> | 
|         AND `a`.`COMPANY_ID` = #{companyId} | 
|       </if> | 
|       <if test="type != null"> | 
|         AND `a`.`TYPE` = #{type} | 
|       </if> | 
|       <if test="erpId != null and erpId != ''"> | 
|         AND `a`.`ERP_ID` = #{erpId} | 
|       </if> | 
|       <if test="status != null"> | 
|         AND `a`.`STATUS` = #{status} | 
|       </if> | 
|       <if test="validTime != null"> | 
|         AND `a`.`VALID_TIME` = #{validTime} | 
|       </if> | 
|       <if test="invalidTime != null"> | 
|         AND `a`.`INVALID_TIME` = #{invalidTime} | 
|       </if> | 
|       <if test="pmodelId != null"> | 
|         AND `pmodel`.`ID` = #{pmodelId} | 
|       </if> | 
|       <if test="pmodelDeleted != null"> | 
|         AND `pmodel`.`DELETED` = #{pmodelDeleted} | 
|       </if> | 
|       <if test="pmodelCreateUser != null"> | 
|         AND `pmodel`.`CREATE_USER` = #{pmodelCreateUser} | 
|       </if> | 
|       <if test="pmodelCreateTime != null"> | 
|         AND `pmodel`.`CREATE_TIME` = #{pmodelCreateTime} | 
|       </if> | 
|       <if test="pmodelUpdateUser != null"> | 
|         AND `pmodel`.`UPDATE_USER` = #{pmodelUpdateUser} | 
|       </if> | 
|       <if test="pmodelUpdateTime != null"> | 
|         AND `pmodel`.`UPDATE_TIME` = #{pmodelUpdateTime} | 
|       </if> | 
|       <if test="pmodelName != null and pmodelName != ''"> | 
|         AND `pmodel`.`NAME` = #{pmodelName} | 
|       </if> | 
|       <if test="pmodelRemark != null and pmodelRemark != ''"> | 
|         AND `pmodel`.`REMARK` = #{pmodelRemark} | 
|       </if> | 
|       <if test="pmodelRootId != null"> | 
|         AND `pmodel`.`ROOT_ID` = #{pmodelRootId} | 
|       </if> | 
|       <if test="pmodelParentId != null"> | 
|         AND `pmodel`.`PARENT_ID` = #{pmodelParentId} | 
|       </if> | 
|       <if test="pmodelCompanyId != null"> | 
|         AND `pmodel`.`COMPANY_ID` = #{pmodelCompanyId} | 
|       </if> | 
|       <if test="pmodelType != null"> | 
|         AND `pmodel`.`TYPE` = #{pmodelType} | 
|       </if> | 
|       <if test="pmodelErpId != null and pmodelErpId != ''"> | 
|         AND `pmodel`.`ERP_ID` = #{pmodelErpId} | 
|       </if> | 
|       <if test="pmodelStatus != null"> | 
|         AND `pmodel`.`STATUS` = #{pmodelStatus} | 
|       </if> | 
|       <if test="pmodelValidTime != null"> | 
|         AND `pmodel`.`VALID_TIME` = #{pmodelValidTime} | 
|       </if> | 
|       <if test="pmodelInvalidTime != null"> | 
|         AND `pmodel`.`INVALID_TIME` = #{pmodelInvalidTime} | 
|       </if> | 
|       <if test="rmodelId != null"> | 
|         AND `rmodel`.`ID` = #{rmodelId} | 
|       </if> | 
|       <if test="rmodelDeleted != null"> | 
|         AND `rmodel`.`DELETED` = #{rmodelDeleted} | 
|       </if> | 
|       <if test="rmodelCreateUser != null"> | 
|         AND `rmodel`.`CREATE_USER` = #{rmodelCreateUser} | 
|       </if> | 
|       <if test="rmodelCreateTime != null"> | 
|         AND `rmodel`.`CREATE_TIME` = #{rmodelCreateTime} | 
|       </if> | 
|       <if test="rmodelUpdateUser != null"> | 
|         AND `rmodel`.`UPDATE_USER` = #{rmodelUpdateUser} | 
|       </if> | 
|       <if test="rmodelUpdateTime != null"> | 
|         AND `rmodel`.`UPDATE_TIME` = #{rmodelUpdateTime} | 
|       </if> | 
|       <if test="rmodelName != null and rmodelName != ''"> | 
|         AND `rmodel`.`NAME` = #{rmodelName} | 
|       </if> | 
|       <if test="rmodelRemark != null and rmodelRemark != ''"> | 
|         AND `rmodel`.`REMARK` = #{rmodelRemark} | 
|       </if> | 
|       <if test="rmodelRootId != null"> | 
|         AND `rmodel`.`ROOT_ID` = #{rmodelRootId} | 
|       </if> | 
|       <if test="rmodelParentId != null"> | 
|         AND `rmodel`.`PARENT_ID` = #{rmodelParentId} | 
|       </if> | 
|       <if test="rmodelCompanyId != null"> | 
|         AND `rmodel`.`COMPANY_ID` = #{rmodelCompanyId} | 
|       </if> | 
|       <if test="rmodelType != null"> | 
|         AND `rmodel`.`TYPE` = #{rmodelType} | 
|       </if> | 
|       <if test="rmodelErpId != null and rmodelErpId != ''"> | 
|         AND `rmodel`.`ERP_ID` = #{rmodelErpId} | 
|       </if> | 
|       <if test="rmodelStatus != null"> | 
|         AND `rmodel`.`STATUS` = #{rmodelStatus} | 
|       </if> | 
|       <if test="rmodelValidTime != null"> | 
|         AND `rmodel`.`VALID_TIME` = #{rmodelValidTime} | 
|       </if> | 
|       <if test="rmodelInvalidTime != null"> | 
|         AND `rmodel`.`INVALID_TIME` = #{rmodelInvalidTime} | 
|       </if> | 
|     </where> | 
|   </select> | 
| </mapper> |