@PostMapping("/detail")
public AjaxResult detail(Long id,HttpServletRequest request) {
String url = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath();
SgChildcare sgConvenientService = sgChildcareService.selectSgChildcareApiById(id,url);
return AjaxResult.success(sgConvenientService);
}
@Override
public SgChildcare selectSgChildcareApiById(Long id, String url)
{
return sgChildcareMapper.selectSgChildcareApiById(id,url,"sg_childcare");
}
public SgChildcare selectSgChildcareApiById(@Param("id") Long id,@Param("url") String url, @Param("tablename") String tablename);
<resultMap type="SgChildcare" id="SgChildcareApiResult">
<result property="id" column="id" />
<result property="createTime" column="create_time" />
<result property="createBy" column="create_by" />
<result property="updateTime" column="update_time" />
<result property="updateBy" column="update_by" />
<result property="delFlag" column="del_flag" />
<result property="name" column="name" />
<result property="childcareTime" column="childcare_time" />
<result property="address" column="address" />
<result property="phone" column="phone"/>
<result property="des" column="des" />
<result property="sort" column="sort" />
<collection property="attachmentIdList" select="getAttachemntUrl" column="{id=id,url=url,tablename=tablename}" ofType="string" javaType="list" >
<result column="attachment_url"/>
</collection>
</resultMap>
<select id="getAttachemntUrl" resultType="string">
SELECT concat(#{url},attachment_url) attachment_url
FROM sys_attachment
where attachment_category = #{tablename}
and business_id = #{id}
and is_delete_opt = 0
</select>
<select id="selectSgChildcareApiList" resultMap="SgChildcareApiResult">
select a.id, a.create_time, a.create_by, a.update_time, a.update_by, a.del_flag, a.name, a.childcare_time, a.address, a.des, a.sort,a.phone,#{url} url,#{tablename} tablename from sg_childcare a
<if test="deptId != null and deptId != ''">
LEFT JOIN SYS_USER su on a.CREATE_BY = su.USER_ID inner JOIN (
select
DEPT_ID
from
SYS_DEPT where DEPT_ID in (100,#{deptId})
) c on c.DEPT_ID = su.DEPT_ID
</if>
<where>
<if test="sgChildcare.name != null and sgChildcare.name != ''"> and a.name like concat('%', #{sgChildcare.name}, '%')</if>
and a.del_flag = '0'
</where>
order by a.sort=0, a.sort asc, a.create_time desc
</select>
<select id="selectSgChildcareApiById" resultMap="SgChildcareApiResult">
select id, create_time, create_by, update_time, update_by, del_flag, name, childcare_time, address, des, sort,#{url} url,#{tablename} tablename,phone from sg_childcare
where id = #{id}
and del_flag = '0'
</select>
domin实体类添加冗余数组
private List<String> attachmentIdList;