javacodeadmin/ruoyi-system/src/main/resources/mapper/system/ServiceCateMapper.xml

134 lines
5.7 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.ServiceCateMapper">
<resultMap type="ServiceCate" id="ServiceCateResult">
<result property="id" column="id" />
<result property="title" column="title" />
<result property="icon" column="icon" />
<result property="sort" column="sort" />
<result property="status" column="status" />
<result property="browse" column="browse" />
<result property="type" column="type" />
<result property="city" column="city" />
<result property="parentId" column="parent_id" />
<result property="createdAt" column="created_at" />
<result property="updatedAt" column="updated_at" />
<result property="deletedAt" column="deleted_at" />
</resultMap>
<sql id="selectServiceCateVo">
select id, title, icon, sort, status, city,browse, type, parent_id, created_at, updated_at, deleted_at from service_cate
</sql>
<select id="selectServiceCateList" parameterType="ServiceCate" resultMap="ServiceCateResult">
<include refid="selectServiceCateVo"/>
<where>
<if test="title != null and title != ''"> and title like concat('%',#{title},'%')</if>
<if test="status != null and status != ''"> and status=#{status}</if>
<if test="type != null and type != ''"> and type=#{type}</if>
<if test="parentId != null"> and parent_id=#{parentId}</if>
<if test="city != null and city != ''"> and JSON_CONTAINS(city, #{city})</if>
</where>
order by parent_id ASC, sort ASC
</select>
<select id="selectServiceCateCiKaList" resultMap="ServiceCateResult">
<include refid="selectServiceCateVo"/>
where id in (select card.type from user_secondary_card card where card.status='1' )
order by parent_id ASC, sort ASC
</select>
<select id="selectServiceCatepintuanList" resultMap="ServiceCateResult">
<include refid="selectServiceCateVo"/>
where id in (select card.first_cate_id from service_goods card where card.status='1' and card.type='1' and card.isgroup='1' )
order by parent_id ASC, sort ASC
</select>
<select id="selectServiceCateMiaoshaList" resultMap="ServiceCateResult">
<include refid="selectServiceCateVo"/>
where id in (select card.first_cate_id from service_goods card where card.status='1' and card.type='1' and card.isfixed='1' )
order by parent_id ASC, sort ASC
</select>
<select id="selectServiceCateBaojiaList" resultMap="ServiceCateResult">
<include refid="selectServiceCateVo"/>
where id in (select card.first_cate_id from service_goods card where card.status='1' and card.type='1' and card.servicetype='2' )
order by parent_id ASC, sort ASC
</select>
<select id="selectServiceCateById" parameterType="Long" resultMap="ServiceCateResult">
<include refid="selectServiceCateVo"/>
where id = #{id}
</select>
<insert id="insertServiceCate" parameterType="ServiceCate" useGeneratedKeys="true" keyProperty="id">
insert into service_cate
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="title != null and title != ''">title,</if>
<if test="icon != null">icon,</if>
<if test="sort != null">sort,</if>
<if test="status != null">status,</if>
<if test="browse != null">browse,</if>
<if test="type != null">type,</if>
<if test="city != null">city,</if>
<if test="parentId != null">parent_id,</if>
<if test="deletedAt != null">deleted_at,</if>
created_at,
updated_at
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="title != null and title != ''">#{title},</if>
<if test="icon != null">#{icon},</if>
<if test="sort != null">#{sort},</if>
<if test="status != null">#{status},</if>
<if test="browse != null">#{browse},</if>
<if test="type != null">#{type},</if>
<if test="city != null">#{city},</if>
<if test="parentId != null">#{parentId},</if>
<if test="deletedAt != null">#{deletedAt},</if>
NOW(),
NOW()
</trim>
</insert>
<update id="updateServiceCate" parameterType="ServiceCate">
update service_cate
<trim prefix="SET" suffixOverrides=",">
<if test="title != null and title != ''">title = #{title},</if>
<if test="icon != null">icon = #{icon},</if>
<if test="sort != null">sort = #{sort},</if>
<if test="status != null">status = #{status},</if>
<if test="browse != null">browse = #{browse},</if>
<if test="type != null">type = #{type},</if>
<if test="city != null">city = #{city},</if>
<if test="parentId != null">parent_id = #{parentId},</if>
<if test="deletedAt != null">deleted_at = #{deletedAt},</if>
updated_at = NOW()
</trim>
where id = #{id}
</update>
<delete id="deleteServiceCateById" parameterType="Long">
delete from service_cate where id = #{id}
</delete>
<delete id="deleteServiceCateByIds" parameterType="String">
delete from service_cate where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>