mybatis dialectclass分页示例

本文详细介绍了如何使用MyBatis和Spring框架进行分页查询存入记录的操作,包括参数设置、SQL语句编写及异常处理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

mybatis:

<select id="queryDeposit" parameterType="com.coactsoft.cfp.entity.Deposit"
resultType="com.coactsoft.cfp.entity.Deposit">
select FID as id, FAPPLYTIME as applyTime, FCURRENCY as currency,
FAMOUNT as amount, FARRIVALAMOUNT as arrivalAmount, FSTATUS as status
from tdeposit
where 1
<if test="currency != '0'.toString()">
and FCURRENCY = #{currency}
</if>
<if test="status != '0'.toString()">
and FSTATUS = #{status}
</if>
</select>

Dao:

/**
* 分页查询存入记录
* @param deposit
* @param bounds
* @return
*/
PageList<Deposit> queryDeposit(Deposit deposit, PageBounds bounds);

logic:

@Path("/queryDeposit")
@POST
public ResponseData<List<Deposit>> queryDeposit(@FormParam("currency")String currency, @FormParam("status")String status, @FormParam("start")String start, @FormParam("count")String count) {
Deposit deposit = new Deposit();
deposit.setCurrency(Integer.parseInt(currency));
deposit.setStatus(Integer.parseInt(status));
SqlSession session = null;
try {
session = SessionFactory.get().openSession();
List<Deposit> pl = session.getMapper(FundsDao.class).queryDeposit(deposit,
new PageBounds(Integer.parseInt(start)/Integer.parseInt(count) + 1, Integer.parseInt(count)));
return ResponseData.ok(((PageList<Deposit>) pl).getPaginator().getTotalCount(), pl);
} catch (Exception e) {
LOGGER.error("查询存入记录出错", e);
} finally {
session.close();
}
return null;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值