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 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM