BizSocialSecurityConfirmDetailMapper.xml 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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.ezhizao.project.business.socialSecurity.mapper.BizSocialSecurityConfirmDetailMapper">
  4. <!-- 基础的返回map 多表复杂的 自行组合 -->
  5. <resultMap id="BaseResultMap"
  6. type="cn.ezhizao.project.business.socialSecurity.domain.BizSocialSecurityConfirmDetail">
  7. <id column="id" jdbcType="BIGINT" property="id"/>
  8. <collection property="details" select="getEmployees" column="id" />
  9. </resultMap>
  10. <resultMap id="BaseResultMap2"
  11. type="cn.ezhizao.project.business.socialSecurity.domain.BizSocialSecurityConfirmDetail">
  12. <id column="id" jdbcType="BIGINT" property="id"/>
  13. </resultMap>
  14. <resultMap id="EmployeeResult" type="cn.ezhizao.project.business.socialSecurity.domain.BizSocialSecurityConfirmDetailEmployee">
  15. <id column="id" jdbcType="INTEGER" property="id"/>
  16. </resultMap>
  17. <select id="getEmployees" resultMap="EmployeeResult">
  18. select *
  19. from biz_social_security_confirm_detail_employee
  20. where social_security_confirm_detail_id = #{id} and deleted = 0
  21. </select>
  22. <!--带条件的List查询-->
  23. <select id="getList" resultMap="BaseResultMap">
  24. <include refid="getListSql"/>
  25. </select>
  26. <select id="getList2" resultMap="BaseResultMap2">
  27. <include refid="getListSql"/>
  28. </select>
  29. <!--带条件的List查询 数据总条数-->
  30. <select id="getTotal" resultType="java.lang.Integer">
  31. SELECT COUNT(1) FROM (<include refid="getListSql"/>) AS C
  32. </select>
  33. <sql id="getListSql">
  34. SELECT t1.*, t2.government_account_no, t2.name as company_name
  35. , t2.government_password, t2.social_security_account_no, t2.social_security_password
  36. , t2.employee_password, t2.is_first_social_security FROM biz_social_security_confirm_detail t1
  37. left join biz_company t2 on t2.id = t1.company_id
  38. <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
  39. t1.deleted = 0 AND
  40. <if test="id != null ">
  41. t1.id = #{id} AND
  42. </if>
  43. <if test="socialSecurityConfirmId != null ">
  44. t1.social_security_confirm_id = #{socialSecurityConfirmId} AND
  45. </if>
  46. <if test="companyId != null ">
  47. t1.company_id = #{companyId} AND
  48. </if>
  49. <if test="year != null and year != '' ">
  50. t1.year = #{year} AND
  51. </if>
  52. <if test="month != null and month != '' ">
  53. t1.month = #{month} AND
  54. </if>
  55. <if test="status != null ">
  56. t1.status = #{status} AND
  57. </if>
  58. <if test="content != null and content != '' ">
  59. t1.content = #{content} AND
  60. </if>
  61. <if test="verifyContent != null and verifyContent != '' ">
  62. t1.verify_content = #{verifyContent} AND
  63. </if>
  64. <if test="startMonth != null and endMonth != null">
  65. STR_TO_DATE(concat(t1.year, '-', t1.month, '-01'), '%Y-%m-%d') between #{startMonth} and #{endMonth} AND
  66. </if>
  67. </trim>
  68. </sql>
  69. </mapper>