mapper查询主子表结构

映射:

<resultMap type="com.qc.hms.api.manage.knowledgeBase.domain.vo.HmsKbTopicVo" id="topicResult">
        <result property="id" column="id"/>
        <result property="code" column="code"/>
        <result property="temId" column="tem_id"/>
        <result property="described" column="described"/>
        <result property="topic" column="topic"/>
        <result property="isRequired" column="is_required"/>
        <result property="classify" column="classify"/>
        <result property="optionType" column="option_type"/>
        <result property="serialNumber" column="serial_number"/>
        <!--获取三级指标来源列表-->
        <collection property="issueList" ofType="com.qc.hms.api.manage.knowledgeBase.domain.HmsKbIssue"
                    select="getIssueList" column="{code=code,temId=tem_id}">
        </collection>
    </resultMap>

主表语句

<!--    查询模板问题标题列表 -->
    <select id="queryList" parameterType="com.qc.hms.api.manage.knowledgeBase.domain.bo.HmsKbTopicTemplateBo" resultMap="topicResult">
        SELECT
            *
        FROM
            hms_kb_topic a
        <where>
            a.del_flag = '0'
            AND a.tem_id = #{temId}
            <if test="described!='' and described!=null">
                and (a.described=#{described} or a.described is null)
            </if>
        </where>

        ORDER BY
            a.serial_number
    </select>

子表语句 getIssueList

    <!--    查询问题选项集合 -->
    <select id="getIssueList" parameterType="com.qc.hms.api.manage.knowledgeBase.domain.bo.HmsKbTopicTemplateBo" resultMap="issueResult">
        SELECT
            *
        FROM
            hms_kb_issue a
        WHERE
            a.del_flag = '0'
            AND a.topic_code = #{code}
            AND a.tem_id = #{temId}
        ORDER BY
            a.serial_number
    </select>

column=“{code=code,temId=tem_id}” 为条件对应语句

然后在主表实体类中加入子表集合

/**
 * 问卷问题标题视图对象 hms_kb_topic
 *
 * @author 
 * @date 2023-01-09
 */
@Data
@ApiModel("问卷问题标题视图对象")
@ExcelIgnoreUnannotated
public class HmsKbTopicVo {

    private static final long serialVersionUID = 1L;

    /**
     * id
     */
    @ExcelProperty(value = "id")
    @ApiModelProperty("id")
    private String id;

    /**
     * 问题编码
     */
    @ExcelProperty(value = "问题编码")
    @ApiModelProperty("问题编码")
    private String code;

    /**
     * 问卷id
     */
    @ExcelProperty(value = "问卷id")
    @ApiModelProperty("问卷id")
    private String temId;

    /**
     * 描述
     */
    @ExcelProperty(value = "描述")
    @ApiModelProperty("描述")
    private String described;

    /**
     * 问题标题
     */
    @ExcelProperty(value = "问题标题")
    @ApiModelProperty("问题标题")
    private String topic;

    /**
     * 是否必填 1必填
     */
    @ExcelProperty(value = "是否必填 1必填")
    @ApiModelProperty("是否必填 1必填")
    private String isRequired;

    /**
     * 分类
     */
    @ExcelProperty(value = "分类")
    @ApiModelProperty("分类")
    private String classify;

    /**
     * 题目类型 1单选 2多选3数字4单文本 5多行文本 6时间7日期8时间日期
     */
    @ExcelProperty(value = "题目类型 1单选 2多选3数字4单文本 5多行文本 6时间7日期8时间日期")
    @ApiModelProperty("题目类型 1单选 2多选3数字4单文本 5多行文本 6时间7日期8时间日期")
    private String optionType;

    /**
     * 序号
     */
    @ExcelProperty(value = "序号")
    @ApiModelProperty("序号")
    private Integer serialNumber;

    /**
     * 问题选项集合
     */
    private List<HmsKbIssue> issueList;

    private List<HmsKbTopicBo> topicList;
}

这样的话调用主表的查询方法就能返回主表包含子表的数据结构

    /**
     * 查询问题标题列表
     * @param bo
     * @return
     */
    List<HmsKbTopicVo> queryList(HmsKbTopicBo bo);
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值