ServiceImpl.java:
List<TestDoA> resultList = testMapper.selectTestList();
Mapper.java
public interface TestMapper extends BaseMapper<testDbTableDO> {
List<TestDoA> selectTestList();
}
Mapper.xml
<select id="selectTestList" resultMap="BaseResultMap">
SELECT property_no1,property_no2,property_no3,test_max,test_min
FROM test_db_table
</select>
<resultMap id="BaseResultMap" type="com.summer.domain.dbo.entity.TestDoA">
<result column="property_no1" property="propertyNo1" />
<result column="property_no2" property="propertyNo2" />
<collection property="dataList" ofType="com.summer.domain.dbo.entity.TestDoB">
<result column="property_no3" property="propertyNo3" />
<result column="test_max" property="max" />
<result column="test_min" property="min" />
</collection>
</resultMap>
TestDoA.java
@Data
@ApiModel(value = "TestDoA 对象", description = "数据库查询返回类")
public class TestDoA {
@ApiModelProperty("属性1")
private String propertyNo1;
@ApiModelProperty("属性2")
private String propertyNo2;
@ApiModelProperty(value = "dataList")
private List<TestDoB> dataList =new ArrayList<>();
}
TestDoB.java
@Data
public class TestDoB {
private String propertyNo3;
@JsonFormat(shape = JsonFormat.Shape.STRING)
private BigDecimal max;
@JsonFormat(shape = JsonFormat.Shape.STRING)
private BigDecimal min;
}