常用的方法一般是在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; }
以这个例子为例,其他的方法也存在很多可以这样使用的。
例如以上。 只是部分例子。详细参考官方文档。
坚持! 慢慢的会更好。