| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper
- PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.fs.company.mapper.CompanyPostMapper">
- <resultMap type="CompanyPost" id="CompanyPostResult">
- <result property="postId" column="post_id" />
- <result property="companyId" column="company_id" />
- <result property="postCode" column="post_code" />
- <result property="postName" column="post_name" />
- <result property="postSort" column="post_sort" />
- <result property="status" column="status" />
- <result property="createBy" column="create_by" />
- <result property="createTime" column="create_time" />
- <result property="updateBy" column="update_by" />
- <result property="updateTime" column="update_time" />
- <result property="remark" column="remark" />
- </resultMap>
- <sql id="selectCompanyPostVo">
- select post_id, company_id, post_code, post_name, post_sort, status, create_by, create_time, update_by, update_time, remark from company_post
- </sql>
- <select id="selectCompanyPostList" parameterType="CompanyPost" resultMap="CompanyPostResult">
- <include refid="selectCompanyPostVo"/>
- <where>
- <if test="companyId != null "> and company_id = #{companyId}</if>
- <if test="postCode != null and postCode != ''"> and post_code = #{postCode}</if>
- <if test="postName != null and postName != ''"> and post_name like concat('%', #{postName}, '%')</if>
- <if test="postSort != null "> and post_sort = #{postSort}</if>
- <if test="status != null and status != ''"> and status = #{status}</if>
- </where>
- </select>
- <select id="selectCompanyPostById" parameterType="Long" resultMap="CompanyPostResult">
- <include refid="selectCompanyPostVo"/>
- where post_id = #{postId}
- </select>
- <insert id="insertCompanyPost" parameterType="CompanyPost" useGeneratedKeys="true" keyProperty="postId">
- insert into company_post
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="companyId != null">company_id,</if>
- <if test="postCode != null and postCode != ''">post_code,</if>
- <if test="postName != null and postName != ''">post_name,</if>
- <if test="postSort != null">post_sort,</if>
- <if test="status != null and status != ''">status,</if>
- <if test="createBy != null">create_by,</if>
- <if test="createTime != null">create_time,</if>
- <if test="updateBy != null">update_by,</if>
- <if test="updateTime != null">update_time,</if>
- <if test="remark != null">remark,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="companyId != null">#{companyId},</if>
- <if test="postCode != null and postCode != ''">#{postCode},</if>
- <if test="postName != null and postName != ''">#{postName},</if>
- <if test="postSort != null">#{postSort},</if>
- <if test="status != null and status != ''">#{status},</if>
- <if test="createBy != null">#{createBy},</if>
- <if test="createTime != null">#{createTime},</if>
- <if test="updateBy != null">#{updateBy},</if>
- <if test="updateTime != null">#{updateTime},</if>
- <if test="remark != null">#{remark},</if>
- </trim>
- </insert>
- <update id="updateCompanyPost" parameterType="CompanyPost">
- update company_post
- <trim prefix="SET" suffixOverrides=",">
- <if test="companyId != null">company_id = #{companyId},</if>
- <if test="postCode != null and postCode != ''">post_code = #{postCode},</if>
- <if test="postName != null and postName != ''">post_name = #{postName},</if>
- <if test="postSort != null">post_sort = #{postSort},</if>
- <if test="status != null and status != ''">status = #{status},</if>
- <if test="createBy != null">create_by = #{createBy},</if>
- <if test="createTime != null">create_time = #{createTime},</if>
- <if test="updateBy != null">update_by = #{updateBy},</if>
- <if test="updateTime != null">update_time = #{updateTime},</if>
- <if test="remark != null">remark = #{remark},</if>
- </trim>
- where post_id = #{postId}
- </update>
- <delete id="deleteCompanyPostById" parameterType="Long">
- delete from company_post where post_id = #{postId}
- </delete>
- <delete id="deleteCompanyPostByIds" parameterType="String">
- delete from company_post where post_id in
- <foreach item="postId" collection="array" open="(" separator="," close=")">
- #{postId}
- </foreach>
- </delete>
- <select id="selectPostsByUserName" parameterType="String" resultMap="CompanyPostResult">
- select p.post_id, p.post_name, p.post_code
- from company_post p
- left join company_user_post up on up.post_id = p.post_id
- left join company_user u on u.user_id = up.user_id
- where u.user_name = #{userName}
- </select>
- <select id="selectPostListByUserId" parameterType="Long" resultType="Integer">
- select p.post_id
- from company_post p
- left join company_user_post up on up.post_id = p.post_id
- left join company_user u on u.user_id = up.user_id
- where u.user_id = #{userId}
- </select>
- <select id="selectPostsByUserId" resultMap="CompanyPostResult">
- select p.post_id, p.post_name, p.post_code
- from company_post p
- left join company_user_post up on up.post_id = p.post_id
- left join company_user u on u.user_id = up.user_id
- where u.user_id = #{user_id}
- </select>
- <select id="selectCompanyPostByIds" resultType="com.fs.company.domain.CompanyPost">
- <include refid="selectCompanyPostVo"/>
- <where>
- <if test="postIds != null">
- post_id in
- <foreach collection="postIds" item="id" open="(" close=")" separator=",">
- #{id}
- </foreach>
- </if>
- </where>
- </select>
- <select id="selectCompanyPostCode" resultType="com.fs.company.domain.CompanyPost">
- <include refid="selectCompanyPostVo"/>
- where post_code=#{postCode} AND company_id = #{companyId}
- </select>
- </mapper>
|