select
sum(JOIN_COUNT) as 'joinNum',sum(WIN_COUNT) as 'winNum',sum(DEFRAY_COUNT) as 'writeOffNum'
from mkplat_activity_point
where
activity_id = #{activityId}
and
point_id >= #{start}
and
point_id <![CDATA[<]]> #{end}
请问这种 sql 在 mp 里面除了 xml 还有啥办法吗,selectMaps 有点麻烦,返回值还要把 map 转为对应的对象,能不能直接通过 mybatis plus 返回一个 StatisticsCount 出来
@Override
public StatisticsCount count(String activityId, String start, String end) {
QueryWrapper<ActivityPointDO> wrapper = Wrappers.query();
wrapper.select("sum(JOIN_COUNT) as 'joinNum'","sum(WIN_COUNT) as 'winNum'","sum(DEFRAY_COUNT) as
'writeOffNum'").
eq("activity_id",activityId).
ge("point_id",start).
lt("point_id",end);
List<Map<String, Object>> maps = this.getBaseMapper().selectMaps(wrapper);
}
1
hcen1997 2021-08-12 11:18:27 +08:00
在 mybatis 中, 如果 select 的列结果名和 class 的结果名对应上, 是可以直接转换的
<select> select a,b,c from tt where a = #{paramA} </select> class CC { String a; String b; String c} List<CC> getByParamA(@Param("paramA")String paramA); 上面这种 sql 和 class 对应的关系, 接口返回类型可以直接写类名, 自动转换了 mybatis 甚至可以自动转换驼峰和下划线 |