Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[type:fix]fix namespace delete error #5916

Merged
merged 2 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,13 @@ public interface AppAuthMapper extends ExistProvider {
* @return list
*/
List<AppAuthVO> selectByCondition(@Param("condition") AppAuthQuery condition);


/**
* Find by namespace id list.
*
* @param namespaceIds the namespaceIds
* @return the list
*/
List<AppAuthDO> findByNamespaceIds(List<String> namespaceIds);
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@
import org.apache.shenyu.admin.mapper.DiscoveryMapper;
import org.apache.shenyu.admin.mapper.MetaDataMapper;
import org.apache.shenyu.admin.mapper.NamespaceMapper;
import org.apache.shenyu.admin.mapper.AppAuthMapper;
import org.apache.shenyu.admin.mapper.NamespacePluginRelMapper;
import org.apache.shenyu.admin.mapper.RuleMapper;
import org.apache.shenyu.admin.mapper.SelectorMapper;
import org.apache.shenyu.admin.model.dto.NamespaceDTO;
import org.apache.shenyu.admin.model.entity.AuthPathDO;
import org.apache.shenyu.admin.model.entity.AppAuthDO;
import org.apache.shenyu.admin.model.entity.DiscoveryDO;
import org.apache.shenyu.admin.model.entity.MetaDataDO;
import org.apache.shenyu.admin.model.entity.NamespaceDO;
Expand Down Expand Up @@ -80,6 +81,8 @@ public class NamespaceServiceImpl implements NamespaceService {

private final NamespacePluginRelMapper namespacePluginRelMapper;

private final AppAuthMapper appAuthMapper;


public NamespaceServiceImpl(final NamespaceMapper namespaceMapper,
final NamespaceUserService namespaceUserService,
Expand All @@ -89,7 +92,7 @@ public NamespaceServiceImpl(final NamespaceMapper namespaceMapper,
final RuleMapper ruleMapper,
final AuthPathMapper authPathMapper,
final MetaDataMapper metaDataMapper,
final DiscoveryMapper discoveryMapper) {
final DiscoveryMapper discoveryMapper, final AppAuthMapper appAuthMapper) {
liyabing12138 marked this conversation as resolved.
Show resolved Hide resolved
this.namespaceMapper = namespaceMapper;
this.namespaceUserService = namespaceUserService;
this.namespaceEventPublisher = namespaceEventPublisher;
Expand All @@ -99,6 +102,7 @@ public NamespaceServiceImpl(final NamespaceMapper namespaceMapper,
this.authPathMapper = authPathMapper;
this.metaDataMapper = metaDataMapper;
this.discoveryMapper = discoveryMapper;
this.appAuthMapper = appAuthMapper;
}

@Override
Expand Down Expand Up @@ -152,9 +156,9 @@ public String delete(final List<String> ids) {
if (CollectionUtils.isNotEmpty(metaDataDOList)) {
throw new ShenyuAdminException("metaData exist under those namespace!");
}
List<AuthPathDO> authPathDOList = authPathMapper.findByNamespaceIds(namespaceIdList);
if (CollectionUtils.isNotEmpty(authPathDOList)) {
throw new ShenyuAdminException("authPath exist under those namespace!");
List<AppAuthDO> appPathDOList = appAuthMapper.findByNamespaceIds(namespaceIdList);
if (CollectionUtils.isNotEmpty(appPathDOList)) {
throw new ShenyuAdminException("appPath exist under those namespace!");
}
List<DiscoveryDO> discoveryDOList = discoveryMapper.selectAllByNamespaceIds(namespaceIdList);
if (CollectionUtils.isNotEmpty(discoveryDOList)) {
Expand Down
10 changes: 10 additions & 0 deletions shenyu-admin/src/main/resources/mappers/app-auth-sqlmap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@
WHERE app_key = #{appKey, jdbcType=VARCHAR}
</select>

<select id="findByNamespaceIds" parameterType="java.lang.String" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM app_auth
WHERE namespace_id IN
<foreach item="namespaceId" collection="namespaceIds" open="(" separator="," close=")">
#{namespaceId, jdbcType=VARCHAR}
</foreach>
</select>

<select id="selectByQuery" parameterType="org.apache.shenyu.admin.model.query.AppAuthQuery" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
Expand Down
Loading