后端返给前端的两种json形式,字符串数组形式和对象数组形式

记录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 &lt;= #{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 &lt;= #{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>
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值