CompanyContactDao.xml 2.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="platform.modules.build.dao.CompanyContactDao">
  4. <update id="deleteByCompanyId">
  5. update y_company_contact set del_flag=1 where company_id=#{companyId}
  6. </update>
  7. <insert id="insertInfo">
  8. INSERT INTO `service_platform`.`y_company_contact`
  9. ( `company_id`, `contact`, `phone`, `gender`, `birthday`, `tel`, `qq`, `wechat`, `email`, `position`, `work`, `create_time`, `create_by`, `create_name`, `update_by`, `update_name`, `update_time`, `del_flag`)
  10. VALUES ( #{company_id}, #{contact}, #{phone}, NULL, NULL, NULL, NULL, NULL, NULL, #{position}, NULL, #{create_time}, #{create_by}, #{create_name}, NULL, NULL, NULL, '0')
  11. </insert>
  12. <select id="findContactList" resultType="platform.modules.build.entity.CompanyContact">
  13. SELECT
  14. getFirstPinyin ( TRIM(c.company_name) ) AS letter,
  15. cc.company_id,
  16. c.company_name,
  17. cc.phone,
  18. cc.contact
  19. FROM
  20. y_company_contact cc
  21. LEFT JOIN y_company c ON c.id = cc.company_id
  22. WHERE c.del_flag = 0 AND cc.del_flag = 0
  23. <if test="searchName != null and searchName != ''">
  24. c.compnay_name LIKE CONCAT('%', #{seatchName}, '%')
  25. </if>
  26. ORDER BY letter
  27. </select>
  28. <resultMap id="companyContactList" type="platform.modules.carrier.dto.CompanyContacts">
  29. <result column="letter" jdbcType="VARCHAR" property="letter"/>
  30. <collection property="data" ofType="platform.modules.build.entity.Company">
  31. <id column="id" jdbcType="INTEGER" property="id"/>
  32. <result column="company_name" jdbcType="VARCHAR" property="company_name"/>
  33. <collection property="contactList" ofType="platform.modules.build.entity.CompanyContact">
  34. <id column="contact_id" jdbcType="INTEGER" property="id"/>
  35. <result column="phone" jdbcType="VARCHAR" property="phone"/>
  36. <result column="contact" jdbcType="VARCHAR" property="contact"/>
  37. </collection>
  38. </collection>
  39. </resultMap>
  40. <select id="findCompanyContactList" resultMap="companyContactList">
  41. SELECT
  42. *
  43. FROM
  44. (
  45. SELECT
  46. getFirstPinyin ( TRIM( c.company_name ) ) AS letter,
  47. c.id,
  48. c.company_name,
  49. cc.id AS contact_id,
  50. cc.phone,
  51. cc.contact
  52. FROM
  53. y_company c
  54. LEFT JOIN y_company_contact cc ON cc.company_id = c.id
  55. WHERE
  56. c.del_flag = 0 AND c.is_start = 1 AND c.is_register = 1
  57. AND cc.del_flag = 0
  58. <if test="streetId != null and streetId != ''">
  59. AND c.street_id = #{streetId}
  60. </if>
  61. <if test="parkId != null and parkId != ''">
  62. AND c.build_id = #{parkId}
  63. </if>
  64. ORDER BY
  65. letter
  66. ) a
  67. WHERE 1=1
  68. <if test="letter != null and letter != ''">
  69. and a.letter = #{letter}
  70. </if>
  71. <if test="companyName != null and companyName != ''">
  72. and a.company_name LIKE CONCAT('%', #{companyName}, '%')
  73. </if>
  74. </select>
  75. </mapper>