CompanyDomainMapper.xml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.fs.company.mapper.CompanyDomainMapper">
  6. <resultMap type="CompanyDomain" id="CompanyDomainResult">
  7. <result property="id" column="id"/>
  8. <result property="domain" column="domain"/>
  9. <result property="remark" column="remark"/>
  10. <result property="createTime" column="create_time"/>
  11. <result property="updateTime" column="update_time"/>
  12. <result property="status" column="status"/>
  13. <result property="createBy" column="create_by"/>
  14. <result property="updateBy" column="update_by"/>
  15. </resultMap>
  16. <sql id="selectCompanyDomainVo">
  17. select id, domain, remark, create_time, update_time, status, create_by, update_by
  18. from company_domain
  19. </sql>
  20. <select id="selectCompanyDomainList" parameterType="CompanyDomain" resultMap="CompanyDomainResult">
  21. <include refid="selectCompanyDomainVo"/>
  22. <where>
  23. <if test="domain != null and domain != ''">and domain LIKE CONCAT('%',#{domain},'%')</if>
  24. <if test="status != null ">and status = #{status}</if>
  25. </where>
  26. </select>
  27. <select id="selectCompanyDomainById" parameterType="Long" resultMap="CompanyDomainResult">
  28. <include refid="selectCompanyDomainVo"/>
  29. where id = #{id}
  30. </select>
  31. <insert id="insertCompanyDomain" parameterType="CompanyDomain" useGeneratedKeys="true" keyProperty="id">
  32. insert into company_domain
  33. <trim prefix="(" suffix=")" suffixOverrides=",">
  34. <if test="domain != null and domain != ''">domain,</if>
  35. <if test="remark != null">remark,</if>
  36. <if test="createTime != null">create_time,</if>
  37. <if test="updateTime != null">update_time,</if>
  38. <if test="status != null">status,</if>
  39. <if test="createBy != null">create_by,</if>
  40. <if test="updateBy != null">update_by,</if>
  41. </trim>
  42. <trim prefix="values (" suffix=")" suffixOverrides=",">
  43. <if test="domain != null and domain != ''">#{domain},</if>
  44. <if test="remark != null">#{remark},</if>
  45. <if test="createTime != null">#{createTime},</if>
  46. <if test="updateTime != null">#{updateTime},</if>
  47. <if test="status != null">#{status},</if>
  48. <if test="createBy != null">#{createBy},</if>
  49. <if test="updateBy != null">#{updateBy},</if>
  50. </trim>
  51. </insert>
  52. <update id="updateCompanyDomain" parameterType="CompanyDomain">
  53. update company_domain
  54. <trim prefix="SET" suffixOverrides=",">
  55. <if test="domain != null and domain != ''">domain = #{domain},</if>
  56. <if test="remark != null">remark = #{remark},</if>
  57. <if test="createTime != null">create_time = #{createTime},</if>
  58. <if test="updateTime != null">update_time = #{updateTime},</if>
  59. <if test="status != null">status = #{status},</if>
  60. <if test="createBy != null">create_by = #{createBy},</if>
  61. <if test="updateBy != null">update_by = #{updateBy},</if>
  62. </trim>
  63. where id = #{id}
  64. </update>
  65. <delete id="deleteCompanyDomainById" parameterType="Long">
  66. delete
  67. from company_domain
  68. where id = #{id}
  69. </delete>
  70. <delete id="deleteCompanyDomainByIds" parameterType="String">
  71. delete from company_domain where id in
  72. <foreach item="id" collection="array" open="(" separator="," close=")">
  73. #{id}
  74. </foreach>
  75. </delete>
  76. <select id="selectCompanyDomainJoinInfo" resultType="com.fs.company.vo.CompanyDomainVo">
  77. SELECT cd.*,
  78. COUNT(cdb.domain_id) bindNum
  79. FROM company_domain cd
  80. LEFT JOIN company_domain_bind cdb ON cd.id = cdb.domain_id
  81. <where>
  82. <if test="domain != null and domain != ''">and cd.domain LIKE CONCAT('%',#{domain},'%')</if>
  83. <if test="status != null ">and cd.status = #{status}</if>
  84. <if test="ids != null ">and cd.id IN
  85. <foreach collection="ids" item="item" index="index" open="(" separator="," close=")">#{item}</foreach>
  86. </if>
  87. </where>
  88. GROUP BY
  89. cd.id
  90. ORDER BY cd.create_time DESC
  91. </select>
  92. <insert id="batchDomainInfo">
  93. insert into company_domain (
  94. domain,
  95. remark,
  96. create_time,
  97. update_time,
  98. status,
  99. create_by,
  100. update_by
  101. )
  102. values
  103. <foreach collection="list" item="item" separator=",">
  104. (
  105. #{item.domain},
  106. #{item.remark},
  107. #{item.createTime},
  108. #{item.updateTime},
  109. #{item.status},
  110. #{item.createBy},
  111. #{item.updateBy}
  112. )
  113. </foreach>
  114. </insert>
  115. </mapper>