@TableField(exist = false) private StdElementCategory elementCategory;
2、xml中增加resultmap即相关信息
<resultMap type="stdElementCategory" id="StdElementCategoryResult"> <result property="id" column="id"/> <result property="name" column="category_name"/> <result property="descInfo" column="desc_info"/> </resultMap> <select id="selectPageElementList" resultMap="StdElementDataResult"> select u.id,u.category_id, u.name, u.inner_code, u.identifier, u.oid, u.definition, u.data_element_type, u.presentation_format, u.dataset_code, u.dataset_desc, u.version_code, u.version_status, u.effective_date, u.valuedomain_id, u.range_code, u.privacy,u.object_properties,u.expiration_date,u.data_status,u.create_time,u.update_time, u.create_by,u.update_by,u.del_flag, d.name as category_name from std_element_data u left join std_element_category d on u.category_id = d.id ${ew.getCustomSqlSegment} </select> <association property="elementCategory" column="category_id" javaType="StdElementCategory" resultMap="StdElementCategoryResult"/>
重点是字段有重名,给字段取别名。体现在
<result property="name" column="category_name"/>
3、mapper层,增加:
public interface StdElementDataMapper extends BaseMapperPlus<StdElementDataMapper, StdElementData, StdElementDataVo> { Page<StdElementDataVo> selectPageElementList(@Param("page") Page<StdElementDataVo> build, @Param(Constants.WRAPPER) LambdaQueryWrapper<StdElementData> lqw); }4、调整impl
//Page<StdElementDataVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw); Page<StdElementDataVo> result = baseMapper.selectPageElementList(pageQuery.build(), lqw);
------------正 文 已 结 束, 感 谢 您 的 阅 读 (折雨的天空)--------------------
转载请注明本文标题和链接:《ruoyi-vue-plus中,自定义SQL查询,关联查询的步骤》
发表评论