记录sql
用于实体类里返回json形式
第一种 第二个集合字符串形式显示
< ? 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” >
<resultMap id="alarmCountDate" type="com.zx.erp.media.entity.MultimediaSelectEntity">
<id property="title" column="title" />
<id property="multimediaId" column="multimediaId" />
<id property="fileType" column="fileType" />
<id property="lecturer" column="lecturer" />
<id property="lecturerDesc" column="lecturerDesc" />
<id property="multimediaType" column="multimediaType" />
<id property="filePath" column="filePath" />
<id property="createTime" column="createTime" />
<id property="desc" column="desc" />
<id property="goodSkills" column="goodSkills" />
<collection property="tagIds" ofType="java.lang.String">
<constructor><arg column="tagId"/></constructor>
</collection>
</resultMap>
<select id="multimediaSelect" resultMap="alarmCountDate">
SELECT
mu.multimedia_title as title,
mu.multimedia_id as multimediaId,
mu.file_type as fileType,
le.lecturer as lecturer,
le.lecturer_desc as lecturerDesc,
mu.multimedia_type as multimediaType,
mu.file_path as filePath,
mtr.tag_id as tagId,
le.good_skills as goodSkills,
le.`desc` as `desc`,
mu.create_time as createTime
FROM
multimedia mu
LEFT JOIN lecturer le on le.multimedia_id= mu.multimedia_id
left join multimedia_tag_relation mtr on mtr.multimedia_id= le.multimedia_id
<where>
<if test="dto.title != null and dto.title !=''">
and mu.multimedia_title like concat('%',#{dto.title},'%')
</if>
<if test="dto.lecturer != null and dto.lecturer !=''">
and le.lecturer like concat('%',#{dto.lecturer},'%')
</if>
<if test="dto.type !=null and dto.type != ''">
and mu.multimedia_type= #{dto.type}
</if>
<if test="dto.createStartTime !=null">
and mu.create_time >= #{dto.createStartTime}
</if>
<if test="dto.createEndTime !=null">
and mu.create_time <= #{dto.createEndTime}
</if>
<if test="dto.unUpdateMessage == 1 and dto.unUpdateMessage!=null ">
and (le.lecturer_desc is not null and le.good_skills is not null and le.desc is not null)
</if>
<if test="dto.unUpdateMessage == 2 and dto.unUpdateMessage!=null ">
and (le.lecturer_desc is null and le.good_skills is null and le.desc is null)
</if>
<if test="dto.unChooseLabel ==1 and dto.unChooseLabel!=null ">
and mtr.tag_id is not null
</if>
<if test="dto.unChooseLabel ==2 and dto.unChooseLabel!=null ">
and mtr.tag_id is null
</if>
</where>
order by mu.create_time desc
</select>
记录sql
用于实体类里返回json形式
第二种 第二个集合封装对象形式显示
<
? 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.zx.erp.media.addvideo.mapper.MultimediaSelectMapper”>
<resultMap id="alarmCountDate" type="com.zx.erp.media.entity.MultimediaSelectEntity">
<id property="title" column="title" />
<id property="multimediaId" column="multimediaId" />
<id property="fileType" column="fileType" />
<id property="lecturer" column="lecturer" />
<id property="lecturerDesc" column="lecturerDesc" />
<id property="multimediaType" column="multimediaType" />
<id property="filePath" column="filePath" />
<id property="createTime" column="createTime" />
<id property="desc" column="desc" />
<id property="goodSkills" column="goodSkills" />
<collection property="tagIds" ofType="com.zx.erp.media.entity.TagIdsList">
<result property="tagId" column="tagId" />
</collection>
</resultMap>
<select id="multimediaSelect" resultMap="alarmCountDate">
SELECT
mu.multimedia_title as title,
mu.multimedia_id as multimediaId,
mu.file_type as fileType,
le.lecturer as lecturer,
le.lecturer_desc as lecturerDesc,
mu.multimedia_type as multimediaType,
mu.file_path as filePath,
mtr.tag_id as tagId,
le.good_skills as goodSkills,
le.`desc` as `desc`,
mu.create_time as createTime
FROM
multimedia mu
LEFT JOIN lecturer le on le.multimedia_id= mu.multimedia_id
left join multimedia_tag_relation mtr on mtr.multimedia_id= le.multimedia_id
<where>
<if test="dto.title != null and dto.title !=''">
and mu.multimedia_title like concat('%',#{dto.title},'%')
</if>
<if test="dto.lecturer != null and dto.lecturer !=''">
and le.lecturer like concat('%',#{dto.lecturer},'%')
</if>
<if test="dto.type !=null and dto.type != ''">
and mu.multimedia_type= #{dto.type}
</if>
<if test="dto.createStartTime !=null">
and mu.create_time >= #{dto.createStartTime}
</if>
<if test="dto.createEndTime !=null">
and mu.create_time <= #{dto.createEndTime}
</if>
<if test="dto.unUpdateMessage == 1 and dto.unUpdateMessage!=null ">
and (le.lecturer_desc is not null and le.good_skills is not null and le.desc is not null)
</if>
<if test="dto.unUpdateMessage == 2 and dto.unUpdateMessage!=null ">
and (le.lecturer_desc is null and le.good_skills is null and le.desc is null)
</if>
<if test="dto.unChooseLabel ==1 and dto.unChooseLabel!=null ">
and mtr.tag_id is not null
</if>
<if test="dto.unChooseLabel ==2 and dto.unChooseLabel!=null ">
and mtr.tag_id is null
</if>
</where>
</select>