常用的方法一般是在mapper.xml中写一个
<select id="selectCountt" resultType="java.lang.Integer">
select count(user_code) from sys_law_case_project_user
where user_code =#{userCode}
</select>
写一个select块来调用查询。
在mybatis plus中有集成好的selectCount的方法。
Integer selectCount(@Param("ew") Wrapper<T> queryWrapper);
使用方式如下:
@Override
public int selectCount(String userCode) {
// int sCount =sysLawCaseProjectUserMapper.selectCountt(userCode);
QueryWrapper<SysLawCaseProjectUser> query = new QueryWrapper<>();
query.eq("user_code",userCode);
//直接通过以上的两句代码实现条件查询计数,之后调用集成好的selectCount就ok了。
int sCount = sysLawCaseProjectUserMapper.selectCount(query);
return sCount;
}
以这个例子为例,其他的方法也存在很多可以这样使用的。

例如以上。 只是部分例子。详细参考官方文档。
坚持! 慢慢的会更好。
这篇博客介绍了如何在MyBatisPlus中使用集成的`selectCount`方法进行条件查询计数,通过示例展示了如何创建查询wrapper并调用API简化代码。这种方法可以应用于多种查询场景,提高了代码的简洁性和效率。
966

被折叠的 条评论
为什么被折叠?



