fix: 修复处理组织checkowner时出现的问题
This commit is contained in:
parent
bbb217e2c5
commit
95aad7082f
|
@ -8,4 +8,6 @@ public interface ExtCheckOwnerMapper {
|
||||||
boolean checkoutOwner(@Param("table") String resourceType, @Param("userId") String userId, @Param("ids") List<String> ids);
|
boolean checkoutOwner(@Param("table") String resourceType, @Param("userId") String userId, @Param("ids") List<String> ids);
|
||||||
|
|
||||||
boolean checkoutOrganizationOwner(@Param("table") String resourceType, @Param("userId") String userId, @Param("ids") List<String> ids);
|
boolean checkoutOrganizationOwner(@Param("table") String resourceType, @Param("userId") String userId, @Param("ids") List<String> ids);
|
||||||
|
|
||||||
|
boolean checkoutOrganization(@Param("userId") String userId, @Param("ids") List<String> ids);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,4 +24,17 @@
|
||||||
</foreach>)
|
</foreach>)
|
||||||
AND user_id = #{userId}
|
AND user_id = #{userId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="checkoutOrganization" resultType="boolean">
|
||||||
|
SELECT count(1) > 0
|
||||||
|
FROM user_role_relation
|
||||||
|
WHERE source_id IN (SELECT id
|
||||||
|
FROM organization
|
||||||
|
WHERE organization.enable = TRUE
|
||||||
|
AND organization.id IN
|
||||||
|
<foreach collection="ids" item="id" separator="," open="(" close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>)
|
||||||
|
AND user_id = #{userId}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
|
@ -71,11 +71,26 @@ public class CheckOwnerAspect {
|
||||||
Object v = titleExp.getValue(context, Object.class);
|
Object v = titleExp.getValue(context, Object.class);
|
||||||
if (orgResources.contains(resourceType)) {
|
if (orgResources.contains(resourceType)) {
|
||||||
handleOrganizationResource(v, resourceType);
|
handleOrganizationResource(v, resourceType);
|
||||||
|
} else if (StringUtils.equals(resourceType, "organization")) {
|
||||||
|
handleOrganization(v);
|
||||||
} else {
|
} else {
|
||||||
handleProjectResource(v, resourceType);
|
handleProjectResource(v, resourceType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void handleOrganization(Object v) {
|
||||||
|
if (v instanceof String id) {
|
||||||
|
if (!extCheckOwnerMapper.checkoutOrganization(SessionUtils.getUserId(), List.of(id))) {
|
||||||
|
throw new MSException(Translator.get("check_owner_case"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (v instanceof List ids) {
|
||||||
|
if (!extCheckOwnerMapper.checkoutOrganization(SessionUtils.getUserId(), ids)) {
|
||||||
|
throw new MSException(Translator.get("check_owner_case"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void handleProjectResource(Object v, String resourceType) {
|
private void handleProjectResource(Object v, String resourceType) {
|
||||||
if (v instanceof String id) {
|
if (v instanceof String id) {
|
||||||
if (!extCheckOwnerMapper.checkoutOwner(resourceType, SessionUtils.getUserId(), List.of(id))) {
|
if (!extCheckOwnerMapper.checkoutOwner(resourceType, SessionUtils.getUserId(), List.of(id))) {
|
||||||
|
|
Loading…
Reference in New Issue