a-tuoheng-airline/src/main/resources/mapper/airline/AirlineFileGroupMapper.xml

160 lines
6.3 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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.airline.mapper.AirlineFileGroupMapper">
<!-- 结果映射 -->
<resultMap id="AirlineFileGroupResult" type="com.ruoyi.airline.mapper.entity.AirlineFileGroupEntity">
<id property="groupId" column="group_id" />
<result property="groupName" column="group_name" />
<result property="userId" column="user_id" />
<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="delFlag" column="del_flag" />
<result property="deletedBy" column="deleted_by" />
<result property="deletedTime" column="deleted_time" />
</resultMap>
<!-- 结果映射 -->
<resultMap type="com.ruoyi.airline.mapper.entity.AirlineFileEntity" id="AirlineFileResult">
<id property="id" column="id" />
<result property="name" column="name" />
<result property="airVendor" column="air_vendor" />
<result property="airType" column="air_type" />
<result property="fileName" column="file_name" />
<result property="fileUrl" column="file_url" />
<result property="type" column="type" />
<result property="source" column="source" />
<result property="status" column="status" />
<result property="fileMd5" column="file_md5" />
<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" />
<result property="groupName" column="group_name" />
<result property="groupId" column="group_id" />
<result property="userId" column="user_id" />
<result property="userId" column="user_id" />
</resultMap>
<!-- 检查分组名称是否唯一 -->
<select id="checkgroupNameUnique" parameterType="com.ruoyi.airline.mapper.entity.AirlineFileGroupEntity" resultType="java.lang.Integer">
select count(1) from airline_file_group
where group_name = #{groupName}
and del_flag = 0
<if test="groupId != null">
and group_id != #{groupId}
</if>
<if test="userId != null">
and user_id = #{userId}
</if>
</select>
<!-- 删除分组(软删除) -->
<update id="deletegroup" parameterType="com.ruoyi.airline.mapper.entity.AirlineFileGroupEntity">
update airline_file_group
set del_flag = 1,
deleted_by = #{deletedBy},
deleted_time = now()
where group_id = #{groupId}
<if test="userId != null">
and user_id = #{userId}
</if>
</update>
<!-- 更新分组 -->
<update id="updateGroup" parameterType="com.ruoyi.airline.mapper.entity.AirlineFileGroupEntity">
update airline_file_group
set group_name = #{groupName},
update_by = #{updateBy},
update_time = now()
where group_id = #{groupId}
and del_flag = 0
<if test="userId != null">
and user_id = #{userId}
</if>
</update>
<!-- 插入分组 -->
<insert id="insertGroup" parameterType="com.ruoyi.airline.mapper.entity.AirlineFileGroupEntity">
insert into airline_file_group (group_name, user_id, create_by, create_time, update_by, update_time, del_flag)
values (#{groupName}, #{userId}, #{createBy}, now(), #{updateBy}, now(), 0)
</insert>
<!-- 查询分组列表 -->
<select id="selectGroupList" parameterType="com.ruoyi.airline.mapper.entity.AirlineFileGroupEntity" resultMap="AirlineFileGroupResult">
select group_id, group_name, user_id, create_by, create_time, update_by, update_time, del_flag, deleted_by, deleted_time
from airline_file_group
<where>
and del_flag = 0
<if test="groupName != null and groupName != ''">
and group_name like concat('%', #{groupName}, '%')
</if>
<if test="userId != null">
and user_id = #{userId}
</if>
</where>
order by create_time desc
</select>
<!-- 通过用户ID查询所有符合条件的航线包含分组信息 -->
<select id="selectAirlineListByUserId" parameterType="com.ruoyi.airline.mapper.entity.AirlineFileEntity" resultMap="AirlineFileResult">
select
af.id ,
af.name ,
af.file_name ,
af.air_vendor ,
af.air_type ,
af.file_url ,
af.type ,
af.source ,
af.status ,
af.file_md5 ,
af.create_by ,
af.create_time ,
af.update_by ,
af.update_time ,
af.remark ,
afg.group_id ,
afg.group_name ,
afg.user_id
from airline_file af
inner join airline_file_group_info afgi on af.id = afgi.airline_id
inner join airline_file_group afg on afgi.group_id = afg.group_id
<where>
afg.del_flag = 0
<if test="userId != null">
and afg.user_id = #{userId}
</if>
<if test="groupId != null">
and afg.group_id = #{groupId}
</if>
<if test="name != null and name != ''">
and af.name like concat('%', #{name}, '%')
</if>
<if test="type != null and type != ''">
and af.type = #{type}
</if>
<if test="status != null">
and af.status = #{status}
</if>
<if test="source != null and source != ''">
and af.source = #{source}
</if>
<if test="airVendor != null and airVendor != ''">
and af.air_vendor = #{airVendor}
</if>
<if test="airType != null and airType != ''">
and af.air_type = #{airType}
</if>
</where>
order by af.create_time desc
</select>
</mapper>