mybatis

本文介绍了一个使用MyBatis实现的人力资源(HR)信息系统中的数据映射配置。该配置详细定义了数据库表HR_STAFF与Java对象HrStaff之间的映射关系,并通过SQL片段实现了灵活的数据查询条件组合。

<?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.bjscis.ims.persistence.expand.QueryHrHumanInfoMapper">


<resultMap id="HrStaffOneResultMap" type="com.bjscis.ims.domain.HrStaff" >
    <id column="HR_STAFF_ONE_ID" property="id" jdbcType="BIGINT" />
<result column="HR_STAFF_ONE_HR_HUMAN_ID" property="hrHumanId" jdbcType="BIGINT" />
<result column="HR_STAFF_ONE_SYS_RFID_CARD_ID" property="sysRfidCardId" jdbcType="BIGINT" />
<result column="HR_STAFF_ONE_STAFF_NO" property="staffNo" jdbcType="VARCHAR" />
<result column="HR_STAFF_ONE_STAFF_PASSWORD" property="staffPassword" jdbcType="VARCHAR" />
<result column="HR_STAFF_ONE_WORKER_TYPE" property="workerType" jdbcType="CHAR" />
<result column="HR_STAFF_ONE_CONTRACT_TYPE" property="contractType" jdbcType="CHAR" />
<result column="HR_STAFF_ONE_IS_VERIFIED" property="isVerified" jdbcType="CHAR" />
<result column="HR_STAFF_ONE_COMMENT" property="comment" jdbcType="VARCHAR" />
<result column="HR_STAFF_ONE_CREATE_TIME" property="createTime" jdbcType="TIMESTAMP" />
<result column="HR_STAFF_ONE_MODIFY_TIME" property="modifyTime" jdbcType="TIMESTAMP" />
<result column="HR_STAFF_ONE_SHOW_ID" property="showId" jdbcType="BIGINT" />
<result column="HR_STAFF_ONE_SHOW_SUB_ID" property="showSubId" jdbcType="BIGINT" />
<result column="HR_STAFF_ONE_IS_ENABLED" property="isEnabled" jdbcType="CHAR" />
<result column="HR_STAFF_ONE_IS_DELETED" property="isDeleted" jdbcType="CHAR" />
<result column="HR_STAFF_ONE_IN_ID" property="inId" jdbcType="BIGINT" />
<result column="HR_STAFF_ONE_MO_ID" property="moId" jdbcType="BIGINT" />
<result column="HR_STAFF_ONE_CONTACT_INFOMATION" property="contactInfomation" jdbcType="VARCHAR" />
<result column="HR_STAFF_ONE_WORK_ENTRY_STATE" property="workEntryState" jdbcType="CHAR" />
<result column="HR_STAFF_ONE_META_POSITION_ID" property="metaPositionId" jdbcType="BIGINT" />


  </resultMap>   
  <sql id="HrStaff_One_Column_List" >
    HR_STAFF_ONE.ID as HR_STAFF_ONE_ID,
HR_STAFF_ONE.HR_HUMAN_ID as HR_STAFF_ONE_HR_HUMAN_ID,
HR_STAFF_ONE.SYS_RFID_CARD_ID as HR_STAFF_ONE_SYS_RFID_CARD_ID,
HR_STAFF_ONE.STAFF_NO as HR_STAFF_ONE_STAFF_NO,
HR_STAFF_ONE.STAFF_PASSWORD as HR_STAFF_ONE_STAFF_PASSWORD,
HR_STAFF_ONE.WORKER_TYPE as HR_STAFF_ONE_WORKER_TYPE,
HR_STAFF_ONE.CONTRACT_TYPE as HR_STAFF_ONE_CONTRACT_TYPE,
HR_STAFF_ONE.IS_VERIFIED as HR_STAFF_ONE_IS_VERIFIED,
HR_STAFF_ONE.COMMENT as HR_STAFF_ONE_COMMENT,
HR_STAFF_ONE.CREATE_TIME as HR_STAFF_ONE_CREATE_TIME,
HR_STAFF_ONE.MODIFY_TIME as HR_STAFF_ONE_MODIFY_TIME,
HR_STAFF_ONE.SHOW_ID as HR_STAFF_ONE_SHOW_ID,
HR_STAFF_ONE.SHOW_SUB_ID as HR_STAFF_ONE_SHOW_SUB_ID,
HR_STAFF_ONE.IS_ENABLED as HR_STAFF_ONE_IS_ENABLED,
HR_STAFF_ONE.IS_DELETED as HR_STAFF_ONE_IS_DELETED,
HR_STAFF_ONE.IN_ID as HR_STAFF_ONE_IN_ID,
HR_STAFF_ONE.MO_ID as HR_STAFF_ONE_MO_ID,
HR_STAFF_ONE.CONTACT_INFOMATION as HR_STAFF_ONE_CONTACT_INFOMATION,
HR_STAFF_ONE.WORK_ENTRY_STATE as HR_STAFF_ONE_WORK_ENTRY_STATE,
HR_STAFF_ONE.META_POSITION_ID as HR_STAFF_ONE_META_POSITION_ID
  </sql>

<resultMap id="HrHumanQueryInfoExpandMap"
type="com.bjscis.ims.domain.expand.HrHumanQueryInfoExpand">
<id column="HR_STAFF_ONE_ID" property="id" jdbcType="BIGINT" />
<association property="hrStaff" column="HR_STAFF_ONE_ID" resultMap="HrStaffOneResultMap" />
<association property="hrHuman" column="HR_HUMAN_ONE_ID" resultMap="HrHumanOneResultMap" />


</resultMap>
<select id="selectHrHumanQueryInfoExpand" resultMap="HrHumanQueryInfoExpandMap">
SELECT


<include refid="HrStaff_One_Column_List" />,
<include refid="HrHuman_One_Column_List" />


FROM HR_STAFF HR_STAFF_ONE


LEFT JOIN HR_HUMAN HR_HUMAN_ONE ON HR_HUMAN_ONE.ID = HR_STAFF_ONE.HR_HUMAN_ID


<where>
HR_STAFF_ONE.IS_DELETED = 'N'




<if test=" liftAge != '' and liftAge != null and rightAge != '' and rightAge != null">
AND  UNIX_TIMESTAMP (`HR_HUMAN_ONE`.`HUMAN_BIRTHDAY`) BETWEEN UNIX_TIMESTAMP('${liftAge}')  AND  UNIX_TIMESTAMP('${rightAge}')  
</if>
<if test=" postId != '' and postId != null">
AND SYS_CORPORTION_STRUCTURE_ONE.ID = #{postId}
</if>
<if test=" staffNo != '' and staffNo != null">
AND HR_STAFF_ONE.STAFF_NO LIKE CONCAT('%',#{staffNo},'%') 
</if>
<if test=" workEntryState != '' and workEntryState != null">
AND HR_STAFF_ONE.WORK_ENTRY_STATE  IN ('${workEntryState}')
</if>
</where>
ORDER BY HR_STAFF_ONE.ID
</select>


</mapper>







转载于:https://my.oschina.net/u/264002/blog/123535

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值