LiftCertificateMapper.xml 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  3. <mapper namespace="cn.com.ty.lift.enterprise.oa.mapper.LiftCertificateMapper" >
  4. <resultMap id="BaseResultMap" type="cn.com.ty.lift.enterprise.oa.dto.LiftCertificateResponse" >
  5. <id column="id" property="id" jdbcType="BIGINT" />
  6. <result column="mt_company_id" property="mtCompanyId" jdbcType="BIGINT" />
  7. <result column="owner_id" property="ownerId" jdbcType="BIGINT" />
  8. <result column="code" property="code" jdbcType="CHAR" />
  9. <result column="issuance_agency" property="issuanceAgency" jdbcType="VARCHAR" />
  10. <result column="expiration_date" property="expirationDate" jdbcType="TIMESTAMP" />
  11. <result column="certificate_type" property="certificateType" jdbcType="VARCHAR" />
  12. <result column="status" property="status" jdbcType="TINYINT" />
  13. <result column="first_img_url" property="firstImgUrl" jdbcType="LONGVARCHAR" />
  14. <result column="second_img_url" property="secondImgUrl" jdbcType="LONGVARCHAR" />
  15. <result column="creator_id" property="creatorId" jdbcType="BIGINT" />
  16. <result column="create_date" property="createDate" jdbcType="TIMESTAMP" />
  17. <result column="update_id" property="updateId" jdbcType="BIGINT" />
  18. <result column="update_date" property="updateDate" jdbcType="TIMESTAMP" />
  19. <result column="username" property="username" jdbcType="VARCHAR" />
  20. </resultMap>
  21. <!--根据条件分页查询-->
  22. <select id="pageByCondition" resultMap="BaseResultMap" parameterType="cn.com.ty.lift.enterprise.oa.dto.LiftCertificateRequest">
  23. SELECT
  24. lc.*,
  25. ui.`name` AS username
  26. FROM
  27. `lift_certificate` lc
  28. LEFT JOIN user_info ui ON ui.user_id = lc.owner_id
  29. LEFT JOIN mt_company_user mcu ON mcu.user_id = lc.owner_id AND mcu.mt_company_id = lc.mt_company_id
  30. <where>
  31. <if test="cond.mtCompanyId != null and cond.mtCompanyId > 0">
  32. AND lc.mt_company_id = #{cond.mtCompanyId}
  33. </if>
  34. <if test="cond.status != null">
  35. AND lc.`status` = #{cond.status}
  36. </if>
  37. <if test="cond.certificateType == 1">
  38. AND mcu.user_role IN (12,13)
  39. </if>
  40. <if test="cond.certificateType == 2">
  41. AND mcu.user_role NOT IN (12,13)
  42. </if>
  43. <if test="cond.username != null and cond.username !=''">
  44. AND ui.`name` LIKE concat('%',#{cond.username},'%')
  45. </if>
  46. </where>
  47. </select>
  48. <select id="countByCondition" resultType="java.lang.Long" parameterType="cn.com.ty.lift.enterprise.oa.dto.LiftCertificateRequest">
  49. SELECT
  50. count(*)
  51. FROM
  52. `lift_certificate` lc
  53. LEFT JOIN mt_company_user mcu ON mcu.user_id = lc.owner_id AND mcu.mt_company_id = lc.mt_company_id
  54. <where>
  55. <if test="cond.mtCompanyId != null and cond.mtCompanyId > 0">
  56. AND lc.mt_company_id = #{cond.mtCompanyId}
  57. </if>
  58. <if test="cond.mtCompanyId != null and cond.certificateType == 1">
  59. AND mcu.user_role IN (12,13)
  60. </if>
  61. <if test="cond.mtCompanyId != null and cond.certificateType == 2">
  62. AND mcu.user_role NOT IN (12,13)
  63. </if>
  64. </where>
  65. </select>
  66. <select id="infoById" resultMap="BaseResultMap" parameterType="cn.com.ty.lift.enterprise.oa.dto.LiftCertificateRequest">
  67. SELECT
  68. lc.*,
  69. ui.`name` AS username
  70. FROM
  71. `lift_certificate` lc
  72. LEFT JOIN user_info ui ON ui.user_id = lc.owner_id
  73. <where>
  74. <if test="cond.id != null and cond.id > 0">
  75. AND lc.id = #{cond.id}
  76. </if>
  77. </where>
  78. </select>
  79. </mapper>