log 파일 추가, 권한별 메뉴 기능 추가
This commit is contained in:
@@ -26,4 +26,13 @@ public class MenuCoreService {
|
||||
public List<MenuDto.Basic> getFindByRole(String role) {
|
||||
return menuRepository.getFindByRole(role).stream().map(MenuEntity::toDto).toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 메뉴별 권한 조회
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<MenuDto.MenuWithRolesDto> getMenuWithRoles() {
|
||||
return menuRepository.getFindByMenuWithRoles();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,5 +21,4 @@ public class YearEntity {
|
||||
@Size(max = 20)
|
||||
@Column(name = "status", length = 20)
|
||||
private String status;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.kamco.cd.kamcoback.postgres.repository.menu;
|
||||
|
||||
import com.kamco.cd.kamcoback.menu.dto.MenuDto.MenuWithRolesDto;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MenuEntity;
|
||||
import java.util.List;
|
||||
|
||||
@@ -14,4 +15,11 @@ public interface MenuRepositoryCustom {
|
||||
* @return
|
||||
*/
|
||||
List<MenuEntity> getFindByRole(String role);
|
||||
|
||||
/**
|
||||
* 메뉴별 권한 조회
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<MenuWithRolesDto> getFindByMenuWithRoles();
|
||||
}
|
||||
|
||||
@@ -3,10 +3,13 @@ package com.kamco.cd.kamcoback.postgres.repository.menu;
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QMenuEntity.menuEntity;
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QMenuMappEntity.menuMappEntity;
|
||||
|
||||
import com.kamco.cd.kamcoback.menu.dto.MenuDto.MenuWithRolesDto;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MenuEntity;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.QMenuEntity;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.QMenuMappEntity;
|
||||
import com.querydsl.core.types.Expression;
|
||||
import com.querydsl.core.types.Projections;
|
||||
import com.querydsl.core.types.dsl.Expressions;
|
||||
import com.querydsl.core.types.dsl.StringExpression;
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -17,7 +20,6 @@ import org.springframework.stereotype.Repository;
|
||||
public class MenuRepositoryImpl implements MenuRepositoryCustom {
|
||||
|
||||
private final JPAQueryFactory queryFactory;
|
||||
private final StringExpression NULL_STRING = Expressions.stringTemplate("cast(null as text)");
|
||||
|
||||
@Override
|
||||
public List<MenuEntity> getFindAll() {
|
||||
@@ -57,4 +59,31 @@ public class MenuRepositoryImpl implements MenuRepositoryCustom {
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MenuWithRolesDto> getFindByMenuWithRoles() {
|
||||
QMenuEntity tm = menuEntity;
|
||||
QMenuMappEntity tmm = menuMappEntity;
|
||||
|
||||
Expression<String> roleAgg =
|
||||
Expressions.stringTemplate("string_agg({0}, {1})", tmm.roleCode, Expressions.constant(","));
|
||||
|
||||
List<MenuWithRolesDto> content =
|
||||
queryFactory
|
||||
.select(
|
||||
Projections.constructor(
|
||||
MenuWithRolesDto.class,
|
||||
tm.menuUid,
|
||||
tm.menuNm,
|
||||
tm.menuUrl,
|
||||
tm.menuApiUri,
|
||||
roleAgg))
|
||||
.from(tm)
|
||||
.leftJoin(tmm)
|
||||
.on(tmm.menuUid.eq(tm).and(tmm.deleted.isFalse()))
|
||||
.where(tm.deleted.isFalse())
|
||||
.groupBy(tm.menuUid, tm.menuNm, tm.menuUrl, tm.menuApiUri)
|
||||
.fetch();
|
||||
return content;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user