mybatisPlus or 使用

/**
     * 查询是否有权限
     */
    @GetMapping(API_PREFIX+"/getPermissionLogCount")
    @Override
    public Integer getPermissionLogCount(String openId
        ,@RequestParam(value = "tournamentId",required = false,defaultValue = "") String tournamentId
        ,@RequestParam(value = "applicationType",required = false,defaultValue = "") String applicationType) {
        return permissionLogService.count(
            new LambdaQueryWrapper<PermissionLog>()
          //相当于 select count(id)
PermissionLog from where getApplicantOpenid = openId and ((getRoleType = "SYSTEM") or (getRoleType = "TOURNAMENT") or (getTournamentId = tournamentId and getApplicationType = applicationType and getIsApproved = “Y” ))
          .eq(org.springblade.competition.entity.PermissionLog::getApplicantOpenid, openId)
                .and(
wrapper1 -> wrapper1.eq(org.springblade.competition.entity.PermissionLog::getRoleType,"SYSTEM") // 赛事创建者 .or(wrapper -> wrapper.eq(org.springblade.competition.entity.PermissionLog::getRoleType,"TOURNAMENT") .eq(org.springblade.competition.entity.PermissionLog::getTournamentId,tournamentId) ) // TOURNAMENT/ACCOUNT/ALBUM .or(w->w.eq(org.springblade.competition.entity.PermissionLog::getTournamentId,tournamentId) .eq (org.springblade.competition.entity.PermissionLog::getApplicationType, applicationType) .eq(org.springblade.competition.entity.PermissionLog::getIsApproved,"Y") ) ) ); }

复杂一点的单表 最好还是写一条sql 

原文地址:https://www.cnblogs.com/-mzh/p/13084752.html