Mapper.XML
<resultMap type="LmbBirdCollect" id="LmbBirdCollectResult2">
<id property="collectId" column="collect_id" />
<result property="pointId" column="point_id" />
<result property="collectTime" column="collect_time" />
<result property="status" column="status" />
<result property="delFlag" column="del_flag" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<association property="birdPoint" column="point_id" javaType="LmbBirdPoint" >
<id property="pointId" column="point_id" />
<result property="itemId" column="item_id" />
<result property="pointName" column="point_name" />
<result property="longitude" column="longitude" />
<result property="latitude" column="latitude" />
<result property="altitude" column="altitude" />
<result property="remarks" column="remarks" />
<result property="status" column="status" />
</association>
<collection property="birdCollects" column="collect_id" ofType="LmbBirdCollects">
<id property="collecstId" column="collects_id" />
<result property="collectId" column="collect_id" />
<result property="birdId" column="bird_id" />
<result property="quantity" column="quantity" />
</collection>
</resultMap>
<select id="selectLmbBirdCollectByCollectId" parameterType="Long" resultMap="LmbBirdCollectResult2">
SELECT c.collect_id, c.point_id, c.collect_time, c.status, c.del_flag, c.create_by,
c.create_time, c.update_by, c.update_time, c.remark ,p.point_name,s.bird_id,s.quantity
FROM lmb_bird_collect c
LEFT JOIN lmb_bird_point p ON c.point_id=p.point_id
LEFT JOIN lmb_bird_collects s ON c.collect_id=s.collect_id
where c.collect_id = #{collectId}
</select>
实体类:
public class LmbBirdCollect extends BaseEntity
{
private static final long serialVersionUID = 1L;
private Long collectId;
@Excel(name = "所属点")
private Long pointId;
@Excel(name = "调查时间", width = 30, dateFormat = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd")
private Date collectTime;
@Excel(name = "状态")
private String status;
private LmbBirdPoint birdPoint;
private List<LmbBirdCollects> birdCollects;
public List<LmbBirdCollects> getBirdCollects() {
if(birdCollects == null){
List<LmbBirdCollects> birdCollects = new ArrayList<>();
}
return birdCollects;
}
public void setBirdCollects(List<LmbBirdCollects> birdCollects) {
this.birdCollects = birdCollects;
}
public LmbBirdPoint getBirdPoint() {
if(birdPoint == null){
birdPoint = new LmbBirdPoint();
}
return birdPoint;
}
public void setBirdPoint(LmbBirdPoint birdPoint) {
this.birdPoint = birdPoint;
}
private String delFlag;
public String getDelFlag() {
return delFlag;
}
public void setDelFlag(String delFlag) {
this.delFlag = delFlag;
}
public Long getCollectId() {
return collectId;
}
public void setCollectId(Long collectId) {
this.collectId = collectId;
}
public Long getPointId() {
return pointId;
}
public void setPointId(Long pointId) {
this.pointId = pointId;
}
public Date getCollectTime() {
return collectTime;
}
public void setCollectTime(Date collectTime) {
this.collectTime = collectTime;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
@Override
public String toString() {
return "LmbBirdCollect{" +
"collectId=" + collectId +
", pointId=" + pointId +
", collectTime=" + collectTime +
", status='" + status + '\'' +
", birdPoint=" + birdPoint +
", birdCollects=" + birdCollects +
", delFlag='" + delFlag + '\'' +
'}';
}
}
|