CompanyPostMapper.xml 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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.CompanyPostMapper">
  6. <resultMap type="CompanyPost" id="CompanyPostResult">
  7. <result property="postId" column="post_id" />
  8. <result property="companyId" column="company_id" />
  9. <result property="postCode" column="post_code" />
  10. <result property="postName" column="post_name" />
  11. <result property="postSort" column="post_sort" />
  12. <result property="status" column="status" />
  13. <result property="createBy" column="create_by" />
  14. <result property="createTime" column="create_time" />
  15. <result property="updateBy" column="update_by" />
  16. <result property="updateTime" column="update_time" />
  17. <result property="remark" column="remark" />
  18. </resultMap>
  19. <sql id="selectCompanyPostVo">
  20. select post_id, company_id, post_code, post_name, post_sort, status, create_by, create_time, update_by, update_time, remark from company_post
  21. </sql>
  22. <select id="selectCompanyPostList" parameterType="CompanyPost" resultMap="CompanyPostResult">
  23. <include refid="selectCompanyPostVo"/>
  24. <where>
  25. <if test="companyId != null "> and company_id = #{companyId}</if>
  26. <if test="postCode != null and postCode != ''"> and post_code = #{postCode}</if>
  27. <if test="postName != null and postName != ''"> and post_name like concat('%', #{postName}, '%')</if>
  28. <if test="postSort != null "> and post_sort = #{postSort}</if>
  29. <if test="status != null and status != ''"> and status = #{status}</if>
  30. </where>
  31. </select>
  32. <select id="selectCompanyPostById" parameterType="Long" resultMap="CompanyPostResult">
  33. <include refid="selectCompanyPostVo"/>
  34. where post_id = #{postId}
  35. </select>
  36. <insert id="insertCompanyPost" parameterType="CompanyPost" useGeneratedKeys="true" keyProperty="postId">
  37. insert into company_post
  38. <trim prefix="(" suffix=")" suffixOverrides=",">
  39. <if test="companyId != null">company_id,</if>
  40. <if test="postCode != null and postCode != ''">post_code,</if>
  41. <if test="postName != null and postName != ''">post_name,</if>
  42. <if test="postSort != null">post_sort,</if>
  43. <if test="status != null and status != ''">status,</if>
  44. <if test="createBy != null">create_by,</if>
  45. <if test="createTime != null">create_time,</if>
  46. <if test="updateBy != null">update_by,</if>
  47. <if test="updateTime != null">update_time,</if>
  48. <if test="remark != null">remark,</if>
  49. </trim>
  50. <trim prefix="values (" suffix=")" suffixOverrides=",">
  51. <if test="companyId != null">#{companyId},</if>
  52. <if test="postCode != null and postCode != ''">#{postCode},</if>
  53. <if test="postName != null and postName != ''">#{postName},</if>
  54. <if test="postSort != null">#{postSort},</if>
  55. <if test="status != null and status != ''">#{status},</if>
  56. <if test="createBy != null">#{createBy},</if>
  57. <if test="createTime != null">#{createTime},</if>
  58. <if test="updateBy != null">#{updateBy},</if>
  59. <if test="updateTime != null">#{updateTime},</if>
  60. <if test="remark != null">#{remark},</if>
  61. </trim>
  62. </insert>
  63. <update id="updateCompanyPost" parameterType="CompanyPost">
  64. update company_post
  65. <trim prefix="SET" suffixOverrides=",">
  66. <if test="companyId != null">company_id = #{companyId},</if>
  67. <if test="postCode != null and postCode != ''">post_code = #{postCode},</if>
  68. <if test="postName != null and postName != ''">post_name = #{postName},</if>
  69. <if test="postSort != null">post_sort = #{postSort},</if>
  70. <if test="status != null and status != ''">status = #{status},</if>
  71. <if test="createBy != null">create_by = #{createBy},</if>
  72. <if test="createTime != null">create_time = #{createTime},</if>
  73. <if test="updateBy != null">update_by = #{updateBy},</if>
  74. <if test="updateTime != null">update_time = #{updateTime},</if>
  75. <if test="remark != null">remark = #{remark},</if>
  76. </trim>
  77. where post_id = #{postId}
  78. </update>
  79. <delete id="deleteCompanyPostById" parameterType="Long">
  80. delete from company_post where post_id = #{postId}
  81. </delete>
  82. <delete id="deleteCompanyPostByIds" parameterType="String">
  83. delete from company_post where post_id in
  84. <foreach item="postId" collection="array" open="(" separator="," close=")">
  85. #{postId}
  86. </foreach>
  87. </delete>
  88. <select id="selectPostsByUserName" parameterType="String" resultMap="CompanyPostResult">
  89. select p.post_id, p.post_name, p.post_code
  90. from company_post p
  91. left join company_user_post up on up.post_id = p.post_id
  92. left join company_user u on u.user_id = up.user_id
  93. where u.user_name = #{userName}
  94. </select>
  95. <select id="selectPostListByUserId" parameterType="Long" resultType="Integer">
  96. select p.post_id
  97. from company_post p
  98. left join company_user_post up on up.post_id = p.post_id
  99. left join company_user u on u.user_id = up.user_id
  100. where u.user_id = #{userId}
  101. </select>
  102. <select id="selectPostsByUserId" resultMap="CompanyPostResult">
  103. select p.post_id, p.post_name, p.post_code
  104. from company_post p
  105. left join company_user_post up on up.post_id = p.post_id
  106. left join company_user u on u.user_id = up.user_id
  107. where u.user_id = #{user_id}
  108. </select>
  109. <select id="selectCompanyPostByIds" resultType="com.fs.company.domain.CompanyPost">
  110. <include refid="selectCompanyPostVo"/>
  111. <where>
  112. <if test="postIds != null">
  113. post_id in
  114. <foreach collection="postIds" item="id" open="(" close=")" separator=",">
  115. #{id}
  116. </foreach>
  117. </if>
  118. </where>
  119. </select>
  120. <select id="selectCompanyPostCode" resultType="com.fs.company.domain.CompanyPost">
  121. <include refid="selectCompanyPostVo"/>
  122. where post_code=#{postCode} AND company_id = #{companyId}
  123. </select>
  124. </mapper>