PageResult多表查询

PageResult多表查询

Mapper

@Mapper
public interface OperateInfoMapper extends BaseDao<OperateInfo> {
@Select("SELECT\n" +
            "\tDATE_FORMAT( start_time, \"%Y-%m-%d\" ) AS date ,\n" +
            "\tsum( operated_oil ) AS totalOil,\n" +
            "\tcount( id ) AS totalNum,\n" +
            "\tsum( operated_mileage ) AS totalMileage,\n" +
            "\tsum( total_used_time )/3600 AS totalTime ,\n" +
            "\tsum( operated_area ) AS totalArea \n" +
            "FROM\n" +
            "\t`t_operate_info` where deleted = 0 and start_time>= #{startDate} and start_time <= #{endDate} \n" +
            "GROUP BY\n" +
            "\tDATE_FORMAT( start_time, \"%Y-%m-%d\" )\n" +
            "ORDER BY start_time desc")
    IPage<OperateDataGroupByDate> getTotalDataByDate(IPage<OperateDataGroupByDate> page,String startDate, String endDate);
    }

Service
接口

public interface IOperateInfoService extends IServiceDto<OperateInfo>, IService<OperateInfo> {
PagerResult<OperateDataGroupByDate> getTotalDataByDate(BasePageVo pageVo,String startDate, String endDate);
}

实现类:

@Slf4j
@Service("operateInfoService")
public class OperateInfoServiceImpl extends BaseService<OperateInfoMapper, OperateInfo, OperateInfo> implements IOperateInfoService {
@Override
    public PagerResult<OperateDataGroupByDate> getTotalDataByDate(BasePageVo pageVo,String startDate, String endDate) {
        IPage<OperateDataGroupByDate> page = new Page(pageVo.getPage(),pageVo.getLimit());
        IPage<OperateDataGroupByDate> pageResult = getBaseMapper().getTotalDataByDate(page, startDate, endDate);
        PagerResult<OperateDataGroupByDate> result =PagerResult.of(pageResult.getTotal()
                ,pageResult.getCurrent(),pageResult.getSize(),pageResult.getRecords());
        return result;
    }
}

OperateDataGroupByDate是要查询的列表,不对应数据库种的任何一张表,多表查询。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值