Browse Source

권한 작업 - 승인관리 목록 조회 , 사용자관리 목록 조회

Test
qkr7828(박재우) 2 years ago
parent
commit
387891b631
  1. 64
      src/main/java/com/palnet/biz/jpa/repository/pty/PtyGroupQueryRepository.java

64
src/main/java/com/palnet/biz/jpa/repository/pty/PtyGroupQueryRepository.java

@ -1,6 +1,8 @@
package com.palnet.biz.jpa.repository.pty; package com.palnet.biz.jpa.repository.pty;
import com.palnet.biz.api.acnt.jwt.utils.JwtTokenUtil;
import com.palnet.biz.api.bas.group.model.*; import com.palnet.biz.api.bas.group.model.*;
import com.palnet.biz.jpa.entity.QPtyCstmrBas; import com.palnet.biz.jpa.entity.QPtyCstmrBas;
import com.palnet.biz.jpa.entity.QPtyCstmrDtl; import com.palnet.biz.jpa.entity.QPtyCstmrDtl;
@ -14,6 +16,7 @@ import com.querydsl.jpa.impl.JPAQueryFactory;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.ArrayList; import java.util.ArrayList;
@ -30,6 +33,10 @@ public class PtyGroupQueryRepository{
* @param rq * @param rq
* @return * @return
*/ */
@Autowired
private JwtTokenUtil jwtTokenUtil;
public List<BasGroupModel> list(BasGroupRqModel rq){ public List<BasGroupModel> list(BasGroupRqModel rq){
QPtyGroupBas bas = QPtyGroupBas.ptyGroupBas; QPtyGroupBas bas = QPtyGroupBas.ptyGroupBas;
@ -194,6 +201,8 @@ public class PtyGroupQueryRepository{
BooleanBuilder builder = new BooleanBuilder(); BooleanBuilder builder = new BooleanBuilder();
String appAuth = jwtTokenUtil.getUserAuthByToken();
if(!StringUtils.isEmpty(rq.getGroupNm())) { if(!StringUtils.isEmpty(rq.getGroupNm())) {
builder.and(bas.groupNm.like("%" + rq.getGroupNm() + "%")); builder.and(bas.groupNm.like("%" + rq.getGroupNm() + "%"));
} }
@ -203,7 +212,19 @@ public class PtyGroupQueryRepository{
// builder.and(cstmrDtl.memberName.eq(memberName)); // builder.and(cstmrDtl.memberName.eq(memberName));
// } // }
if(appAuth.equals("USER")) {
builder.and(bas.groupId.in(
JPAExpressions
.select(bas.groupId)
.from(bas)
.leftJoin(dtl)
.on(bas.groupId.eq(dtl.groupId))
.where(bas.useYn.eq("Y"))
.where(dtl.cstmrSno.eq(rq.getCstmrSno()))
.where(dtl.groupAuthCd.eq("MASTER").or(dtl.groupAuthCd.eq("LEADER")))
));
}
if(!StringUtils.isEmpty(rq.getAprvYn())) { if(!StringUtils.isEmpty(rq.getAprvYn())) {
builder.and(dtl.aprvlYn.eq(rq.getAprvYn())); builder.and(dtl.aprvlYn.eq(rq.getAprvYn()));
} }
@ -237,18 +258,6 @@ public class PtyGroupQueryRepository{
.on(cstmr.cstmrSno.eq(cstmrDtl.cstmrSno)) .on(cstmr.cstmrSno.eq(cstmrDtl.cstmrSno))
.where(builder) .where(builder)
.where(bas.groupId.in(
JPAExpressions
.select(bas.groupId)
.from(bas)
.leftJoin(dtl)
.on(bas.groupId.eq(dtl.groupId))
.where(bas.useYn.eq("Y"))
.where(dtl.cstmrSno.eq(rq.getCstmrSno()))
// .where(dtl.groupAuthCd.eq("CREATER").or(dtl.groupAuthCd.eq("ADMIN")))
.where(dtl.groupAuthCd.eq("MASTER").or(dtl.groupAuthCd.eq("LEADER")))
))
.where(dtl.cstmrSno.ne(rq.getCstmrSno())) .where(dtl.cstmrSno.ne(rq.getCstmrSno()))
// .where(dtl.groupAuthCd.ne("CREATER")) // .where(dtl.groupAuthCd.ne("CREATER"))
.where(dtl.groupAuthCd.ne("MASTER")) .where(dtl.groupAuthCd.ne("MASTER"))
@ -273,7 +282,7 @@ public class PtyGroupQueryRepository{
return result; return result;
} }
/** /**
* 참여 했는지 여부체크 * 참여 했는지 여부체크
* @param cstmrSno * @param cstmrSno
@ -322,12 +331,25 @@ public class PtyGroupQueryRepository{
QPtyCstmrDtl cstmrDtl = QPtyCstmrDtl.ptyCstmrDtl; QPtyCstmrDtl cstmrDtl = QPtyCstmrDtl.ptyCstmrDtl;
BooleanBuilder builder = new BooleanBuilder(); BooleanBuilder builder = new BooleanBuilder();
String appAuth = jwtTokenUtil.getUserAuthByToken();
builder.and(bas.useYn.eq("Y")); builder.and(bas.useYn.eq("Y"));
builder.and(dtl.joinYn.eq("Y")); builder.and(dtl.joinYn.eq("Y"));
builder.and(dtl.aprvlYn.eq("Y")); builder.and(dtl.aprvlYn.eq("Y"));
if(appAuth.equals("USER")) {
builder.and(bas.groupId.in(
JPAExpressions
.select(bas.groupId)
.from(bas)
.leftJoin(dtl)
.on(bas.groupId.eq(dtl.groupId))
.where(bas.useYn.eq("Y"))
.where(dtl.cstmrSno.eq(rq.getCstmrSno()))
.where(dtl.groupAuthCd.eq("MASTER").or(dtl.groupAuthCd.eq("LEADER")))
));
}
if(!StringUtils.isEmpty(rq.getGroupNm())) { if(!StringUtils.isEmpty(rq.getGroupNm())) {
builder.and(bas.groupNm.like("%" + rq.getGroupNm() + "%")); builder.and(bas.groupNm.like("%" + rq.getGroupNm() + "%"));
} }
@ -367,18 +389,6 @@ public class PtyGroupQueryRepository{
.leftJoin(cstmrDtl) .leftJoin(cstmrDtl)
.on(cstmr.cstmrSno.eq(cstmrDtl.cstmrSno)) .on(cstmr.cstmrSno.eq(cstmrDtl.cstmrSno))
.where(builder) .where(builder)
.where(bas.groupId.in(
JPAExpressions
.select(bas.groupId)
.from(bas)
.leftJoin(dtl)
.on(bas.groupId.eq(dtl.groupId))
.where(bas.useYn.eq("Y"))
.where(dtl.cstmrSno.eq(rq.getCstmrSno()))
// .where(dtl.groupAuthCd.eq("CREATER").or(dtl.groupAuthCd.eq("ADMIN")))
.where(dtl.groupAuthCd.eq("MASTER").or(dtl.groupAuthCd.eq("LEADER")))
))
.where(dtl.cstmrSno.ne(rq.getCstmrSno())) .where(dtl.cstmrSno.ne(rq.getCstmrSno()))
.orderBy(bas.createDt.desc()) .orderBy(bas.createDt.desc())

Loading…
Cancel
Save