目录
简单的一种写法,代码阅读更方便
直接截图上代码截图:
返回的结果JSON:
代码:
<resultMap id="DetailResultMap" type="com.ruoyi.aftersale.api.vo.MyRcecordDetail">
<id column="id" property="id" />
<result column="order_num" property="orderNum" />
<result column="descs" property="content" />
<result column="create_time" property="createTime" />
<result column="status" property="status" />
<association column="id" property="pingjia" select="queryPingJia" />
<collection column="id" property="history" select="queryHistory" />
</resultMap>
<select id="detail" resultMap="DetailResultMap">
SELECT
a.id,a.order_num,a.descs,a.create_time,a.`status`
FROM
sh_record a
WHERE a.id= #{id}
</select>
<select id="queryHistory" resultType="com.ruoyi.aftersale.api.vo.HistoryVO">
SELECT
id hid,
descs content,
create_time htime
FROM
sh_record_history
WHERE
record_id = #{id}
</select>
<select id="queryPingJia" resultType="com.ruoyi.aftersale.api.vo.PingjiaVO">
SELECT
id pid,
score,
content,
deal_time timeLevel
FROM
sh_pingjia
WHERE
record_id = #{id}
</select>
@Data
@AllArgsConstructor
@NoArgsConstructor
public class MyRcecordDetail {
Integer id;
String orderNum;
String content;
String createTime;
Integer status;
RcordTypeEnum statusEnum ;
List<HistoryVO> history;
PingjiaVO pingjia;
private void setStatus(Integer status) {
this.status = status;
statusEnum = RcordTypeEnum.getEnum(status);
}
}
@AllArgsConstructor
@NoArgsConstructor
@Data
public class HistoryVO {
Integer hid;
String descs;
Date htime;
}
@Data
@AllArgsConstructor
@NoArgsConstructor
public class PingjiaVO {
Integer pId;
Long recordId;
Long score;
String content;
String timeLevel;
}