메뉴 권한 uri 수정
This commit is contained in:
@@ -9,5 +9,7 @@ import org.apache.ibatis.annotations.Param;
|
||||
@Mapper
|
||||
public interface URIMapper {
|
||||
URITopTier findTopTierByAppType(@Param("appType") AppType appType);
|
||||
URITopTier findTopTierByAppTypeByRoleId(@Param("appType") AppType appType,@Param("roleId") String roleId);
|
||||
List<URITopTier> findChildrenByParentId(@Param("parentId") String parentId);
|
||||
List<URITopTier> findChildrenByParentIdByRoleId(@Param("parentId") String parentId,@Param("roleId") String roleId);
|
||||
}
|
||||
|
||||
@@ -25,12 +25,33 @@ public class URITopTierDao implements URITopTierPortOut {
|
||||
|
||||
return recursiveMapping(top);
|
||||
}
|
||||
@Override
|
||||
@Transactional
|
||||
public URITopTier connectRoleId(AppType appType, String roleId) {
|
||||
URITopTier top = uriMapper.findTopTierByAppTypeByRoleId(appType,roleId);
|
||||
if (top == null) {
|
||||
throw new RuntimeException("There is no top tier item of " + appType);
|
||||
}
|
||||
|
||||
return recursiveMapping(top,roleId);
|
||||
}
|
||||
|
||||
private URITopTier recursiveMapping(URITopTier current) {
|
||||
List<URITopTier> children = uriMapper.findChildrenByParentId(current.getId());
|
||||
current.setChildren(children.stream()
|
||||
.map(this::recursiveMapping)
|
||||
.map(this::recursiveMapping)
|
||||
.collect(Collectors.toList()));
|
||||
return current;
|
||||
}
|
||||
|
||||
private URITopTier recursiveMapping(URITopTier current,String roleId) {
|
||||
List<URITopTier> children = uriMapper.findChildrenByParentIdByRoleId(current.getId(),roleId);
|
||||
current.setChildren(children.stream()
|
||||
.map(uri -> recursiveMapping(uri,roleId))
|
||||
.collect(Collectors.toList()));
|
||||
return current;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -5,4 +5,5 @@ import app.module.core.usecase.uri.toptier.ports.application.domain.URITopTier;
|
||||
|
||||
public interface URITopTierPortIn {
|
||||
URITopTier connect(AppType appType);
|
||||
URITopTier connectRoleId(AppType appType, String roleId);
|
||||
}
|
||||
|
||||
@@ -6,4 +6,5 @@ import app.module.core.usecase.uri.toptier.ports.application.domain.URITopTier;
|
||||
public interface URITopTierPortOut {
|
||||
|
||||
URITopTier connect(AppType appType);
|
||||
URITopTier connectRoleId(AppType appType,String roleId);
|
||||
}
|
||||
|
||||
@@ -19,4 +19,10 @@ public class URITopTierService implements URITopTierPortIn {
|
||||
public URITopTier connect(AppType appType) {
|
||||
return topTierPortOut.connect(appType);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public URITopTier connectRoleId(AppType appType, String roleId) {
|
||||
return topTierPortOut.connectRoleId(appType,roleId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,32 +2,65 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="app.module.core.usecase.uri.toptier.adapters.persistence.URIMapper">
|
||||
<select id="findTopTierByAppType" resultType="app.module.core.usecase.uri.toptier.ports.application.domain.URITopTier">
|
||||
SELECT
|
||||
u.id,
|
||||
u.app_type,
|
||||
u.text,
|
||||
u.uri,
|
||||
u.show_on_navi,
|
||||
u.order_no
|
||||
FROM uri u
|
||||
WHERE u.app_type = #{appType}
|
||||
AND u.parent_id IS NULL
|
||||
AND u.is_deleted = false
|
||||
</select>
|
||||
|
||||
<select id="findTopTierByAppType" resultType="app.module.core.usecase.uri.toptier.ports.application.domain.URITopTier">
|
||||
<select id="findChildrenByParentId" resultType="app.module.core.usecase.uri.toptier.ports.application.domain.URITopTier">
|
||||
SELECT
|
||||
u.id,
|
||||
u.app_type,
|
||||
u.text,
|
||||
u.uri,
|
||||
u.show_on_navi,
|
||||
u.order_no
|
||||
FROM uri u
|
||||
WHERE u.parent_id = #{parentId}
|
||||
AND u.is_deleted = false
|
||||
ORDER BY u.order_no ASC
|
||||
</select>
|
||||
|
||||
<select id="findTopTierByAppTypeByRoleId" resultType="app.module.core.usecase.uri.toptier.ports.application.domain.URITopTier">
|
||||
SELECT
|
||||
id,
|
||||
app_type,
|
||||
text,
|
||||
uri,
|
||||
show_on_navi,
|
||||
order_no
|
||||
FROM uri
|
||||
WHERE app_type = #{appType}
|
||||
AND parent_id IS NULL
|
||||
AND is_deleted = false
|
||||
u.id,
|
||||
u.app_type,
|
||||
u.text,
|
||||
u.uri,
|
||||
u.show_on_navi,
|
||||
u.order_no
|
||||
FROM uri u
|
||||
JOIN uri_has_role uhr ON u.id = uhr.uri_id and uhr.is_deleted = false
|
||||
WHERE u.app_type = #{appType}
|
||||
AND u.parent_id IS NULL
|
||||
AND u.is_deleted = false
|
||||
AND uhr.role_id = #{roleId}
|
||||
AND u.show_on_navi = true
|
||||
</select>
|
||||
|
||||
<select id="findChildrenByParentId" resultType="app.module.core.usecase.uri.toptier.ports.application.domain.URITopTier">
|
||||
<select id="findChildrenByParentIdByRoleId" resultType="app.module.core.usecase.uri.toptier.ports.application.domain.URITopTier">
|
||||
SELECT
|
||||
id,
|
||||
app_type,
|
||||
text,
|
||||
uri,
|
||||
show_on_navi,
|
||||
order_no
|
||||
FROM uri
|
||||
WHERE parent_id = #{parentId}
|
||||
AND is_deleted = false
|
||||
ORDER BY order_no ASC
|
||||
u.id,
|
||||
u.app_type,
|
||||
u.text,
|
||||
u.uri,
|
||||
u.show_on_navi,
|
||||
u.order_no
|
||||
FROM uri u
|
||||
JOIN uri_has_role uhr ON u.id = uhr.uri_id and uhr.is_deleted = false
|
||||
WHERE u.parent_id = #{parentId}
|
||||
AND u.is_deleted = false
|
||||
AND uhr.role_id = #{roleId}
|
||||
AND u.show_on_navi = true
|
||||
ORDER BY u.order_no ASC
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user