wenlvApp/ruoyi-system/src/main/resources/mapper/system/UserWorkMapper.xml

187 lines
10 KiB
XML

<?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.ruoyi.system.mapper.UserWorkMapper">
<resultMap type="UserWork" id="UserWorkResult">
<result property="workId" column="work_id" />
<result property="userId" column="user_id" />
<result property="workName" column="work_name" />
<result property="workAddress" column="work_address" />
<result property="coordinate" column="coordinate" />
<result property="createTime" column="create_time" />
<result property="postTime" column="post_time" />
<result property="workStatus" column="work_status" />
<result property="auditOpinion" column="audit_opinion" />
<result property="sourceId" column="source_id" />
<result property="price" column="price" />
<result property="receiveRockets" column="receive_rockets" />
<result property="detail" column="detail" />
<result property="deleteFlag" column="delete_flag" />
<result property="scenic" column="scenic" />
<result property="part" column="part" />
<result property="city" column="city" />
</resultMap>
<resultMap id="UserWorkReviewDtoResult" type="UserWorkReviewDto">
<result property="workId" column="work_id" />
<result property="workName" column="work_name" />
<result property="workAddress" column="work_address" />
<result property="createTime" column="create_time" />
<result property="auditOpinion" column="audit_opinion" />
<result property="sourceId" column="source_id" />
<result property="detail" column="detail" />
<result property="workStatus" column="work_status" />
<result property="nickName" column="nick_name" />
<result property="scenic" column="scenic" />
<result property="part" column="part" />
<result property="city" column="city" />
</resultMap>
<sql id="selectUserWorkVo">
select work_id, user_id, work_name, work_address, coordinate, create_time, post_time, work_status, audit_opinion, source_id, price, receive_rockets, detail, delete_flag, scenic, part, city from user_work
</sql>
<select id="selectUserWorkList" parameterType="UserWork" resultMap="UserWorkResult">
<include refid="selectUserWorkVo"/>
<where>
<if test="userId != null "> and user_id = #{userId}</if>
<if test="workName != null and workName != ''"> and work_name like concat('%', #{workName}, '%')</if>
<if test="workAddress != null and workAddress != ''"> and work_address = #{workAddress}</if>
<if test="coordinate != null and coordinate != ''"> and coordinate = #{coordinate}</if>
<if test="postTime != null "> and post_time = #{postTime}</if>
<if test="workStatus != null and workStatus != ''"> and work_status = #{workStatus}</if>
<if test="auditOpinion != null and auditOpinion != ''"> and audit_opinion = #{auditOpinion}</if>
<if test="sourceId != null and sourceId != ''"> and source_id = #{sourceId}</if>
<if test="price != null "> and price = #{price}</if>
<if test="receiveRockets != null "> and receive_rockets = #{receiveRockets}</if>
<if test="detail != null and detail != ''"> and detail = #{detail}</if>
<if test="deleteFlag != null and deleteFlag != ''"> and delete_flag = #{deleteFlag}</if>
<if test="scenic != null and scenic != ''"> and scenic = #{scenic}</if>
<if test="part != null and part != ''"> and part = #{part}</if>
<if test="city != null and city != ''"> and city = #{city}</if>
</where>
</select>
<select id="selectUserWorkByWorkId" parameterType="Long" resultMap="UserWorkResult">
<include refid="selectUserWorkVo"/>
where work_id = #{workId}
</select>
<insert id="insertUserWork" parameterType="UserWork" useGeneratedKeys="true" keyProperty="workId">
insert into user_work
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="userId != null">user_id,</if>
<if test="workName != null">work_name,</if>
<if test="workAddress != null">work_address,</if>
<if test="coordinate != null and coordinate != ''">coordinate,</if>
<if test="createTime != null">create_time,</if>
<if test="postTime != null">post_time,</if>
<if test="workStatus != null">work_status,</if>
<if test="auditOpinion != null">audit_opinion,</if>
<if test="sourceId != null">source_id,</if>
<if test="price != null">price,</if>
<if test="receiveRockets != null">receive_rockets,</if>
<if test="detail != null">detail,</if>
<if test="deleteFlag != null">delete_flag,</if>
<if test="scenic != null">scenic,</if>
<if test="part != null">part,</if>
<if test="city != null">city,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="userId != null">#{userId},</if>
<if test="workName != null">#{workName},</if>
<if test="workAddress != null">#{workAddress},</if>
<if test="coordinate != null and coordinate != ''">#{coordinate},</if>
<if test="createTime != null">#{createTime},</if>
<if test="postTime != null">#{postTime},</if>
<if test="workStatus != null">#{workStatus},</if>
<if test="auditOpinion != null">#{auditOpinion},</if>
<if test="sourceId != null">#{sourceId},</if>
<if test="price != null">#{price},</if>
<if test="receiveRockets != null">#{receiveRockets},</if>
<if test="detail != null">#{detail},</if>
<if test="deleteFlag != null">#{deleteFlag},</if>
<if test="scenic != null">#{scenic},</if>
<if test="part != null">#{part},</if>
<if test="city != null">#{city},</if>
</trim>
</insert>
<update id="updateUserWork" parameterType="UserWork">
update user_work
<trim prefix="SET" suffixOverrides=",">
<if test="userId != null">user_id = #{userId},</if>
<if test="workName != null">work_name = #{workName},</if>
<if test="workAddress != null">work_address = #{workAddress},</if>
<if test="coordinate != null and coordinate != ''">coordinate = #{coordinate},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="postTime != null">post_time = #{postTime},</if>
<if test="workStatus != null">work_status = #{workStatus},</if>
<if test="auditOpinion != null">audit_opinion = #{auditOpinion},</if>
<if test="sourceId != null">source_id = #{sourceId},</if>
<if test="price != null">price = #{price},</if>
<if test="receiveRockets != null">receive_rockets = #{receiveRockets},</if>
<if test="detail != null">detail = #{detail},</if>
<if test="deleteFlag != null">delete_flag = #{deleteFlag},</if>
<if test="scenic != null">scenic = #{scenic},</if>
<if test="part != null">part = #{part},</if>
<if test="city != null">city = #{city},</if>
</trim>
where work_id = #{workId}
</update>
<delete id="deleteUserWorkByWorkId" parameterType="Long">
delete from user_work where work_id = #{workId}
</delete>
<delete id="deleteUserWorkByWorkIds" parameterType="String">
delete from user_work where work_id in
<foreach item="workId" collection="array" open="(" separator="," close=")">
#{workId}
</foreach>
</delete>
<select id="getUserWorkCount" resultType="Long">
select count(*) from user_work
<where>
<if test="workStatus != null and workStatus != ''"> and work_status = #{workStatus}</if>
</where>
</select>
<select id="getAllUserWork" resultMap="UserWorkReviewDtoResult">
select w.work_id, w.work_name, w.work_address, w.create_time, w.work_status, w.audit_opinion, w.source_id, w.city, w.scenic, w.part ,w.detail, u.nick_name
from user_work w
left join sys_user u
on w.user_id = u.user_id
<where>
<if test="userId != null "> and w.user_id = #{userId}</if>
<if test="workName != null and workName != ''"> and work_name like concat('%', #{workName}, '%')</if>
<if test="workAddress != null and workAddress != ''"> and work_address = #{workAddress}</if>
<if test="coordinate != null and coordinate != ''"> and coordinate = #{coordinate}</if>
<if test="postTime != null "> and post_time = #{postTime}</if>
<if test="workStatus != null and workStatus != ''"> and work_status = #{workStatus}</if>
<if test="auditOpinion != null and auditOpinion != ''"> and audit_opinion = #{auditOpinion}</if>
<if test="sourceId != null and sourceId != ''"> and source_id = #{sourceId}</if>
<!--&#45;&#45; <if test="price != null "> and price = #{price}</if>-->
<if test="receiveRockets != null "> and receive_rockets = #{receiveRockets}</if>
<if test="detail != null and detail != ''"> and detail = #{detail}</if>
<if test="deleteFlag != null and deleteFlag != ''"> and delete_flag = #{deleteFlag}</if>
<if test="scenic != null and scenic != ''"> and scenic = #{scenic}</if>
<if test="part != null and part != ''"> and part = #{part}</if>
<if test="city != null and city != ''"> and city = #{city}</if>
and work_status in ('2','3', '4', '5')
</where>
</select>
<select id="selectUserPublishWorkList" resultMap="UserWorkResult" parameterType="Long">
select *
from user_work
where work_status != "0" and user_id = #{userId}
</select>
</mapper>