一个teamId对应对个日期
Service层
public List<DayVo> selectTimeListByTeamId(Long teamId);
impl层
@Override
public List<DayVo> selectTimeListByTeamId(Long teamId) {
return rcmReportCompactMapper.selectTimeListByTeamId(teamId);
}
Mapper.xml层(时间戳的使用)(将数据库中的数字转化为日期格式)
<resultMap id="DayRcmReportCompactResult" type="DayVo">
<result property="day" column="t1"/>
</resultMap>
<select id="selectTimeListByTeamId" parameterType="long" resultMap="DayRcmReportCompactResult">
select FROM_UNIXTIME(t1,'%Y-%m-%d') t1
from report_compact
where teamid = #{teamId}
</select>
Controller层
@GetMapping("/select_by_teamId")
public AjaxResult selectTimeListByTeamId(Long teamId){
AjaxResult ajaxResult=AjaxResult.success();
List<DayVo> dayVos = rcmReportCompactService.selectTimeListByTeamId(teamId);
ajaxResult.put("dayList",dayVos.stream().map(DayVo::getDay).collect(Collectors.toList()));
return ajaxResult;
}
注:stream流为Java8的新特性(可以理解为是for循环)