Commit 735b5728 authored by 朱允伟's avatar 朱允伟
parents 1ff9c9e3 3371d19a
...@@ -315,9 +315,17 @@ public class ApiServiceApplicationImpl implements ApiApplication { ...@@ -315,9 +315,17 @@ public class ApiServiceApplicationImpl implements ApiApplication {
InvokeResult invokeResult; InvokeResult invokeResult;
api.setId(id); api.setId(id);
try { try {
//删除接口分组,查询该id的分组是否存在parentId,如果没有可以删除,如果存在不能删除 //查看API表是否存在id,非空判断 count>0,说明存在
Integer count = apiRepository.selectCountFromId(id); Integer count = apiRepository.selectCountFromId(id);
if (count > 0) { if (count > 0) {
//判断该api是否设置了权限,如果设置了权限,不能删除
Integer count2 = apiAuthRepository.findAuthApiIdById(id);
if (count2 > 0) {
log.error("该Api存在权限,请删除权限后再删除!");
invokeResult = InvokeResult.fail();
invokeResult.setMessage("该Api存在权限,请删除权限后再删除!");
return invokeResult;
}
apiRepository.delete(api); apiRepository.delete(api);
} else { } else {
log.error("删除Api接口失败!"); log.error("删除Api接口失败!");
......
...@@ -63,5 +63,15 @@ public interface ApiAuthRepository extends JpaRepository<ApiAuth, Integer>, JpaS ...@@ -63,5 +63,15 @@ public interface ApiAuthRepository extends JpaRepository<ApiAuth, Integer>, JpaS
* @return * @return
*/ */
@Query(value = "select start_time , end_time from api_auth where api_id= ?1 and user_id = ?2", nativeQuery = true) @Query(value = "select start_time , end_time from api_auth where api_id= ?1 and user_id = ?2", nativeQuery = true)
Map<Date, Date> findApiAuthByApiId(Integer apiId , Integer userid); Map<Date, Date> findApiAuthByApiId(Integer apiId, Integer userid);
/**
* 根据apiid查询ApiAuth里是否存在权限
*
* @param id
* @return
*/
@Query(value = "select count(*) from api_auth where api_id= ?1", nativeQuery = true)
Integer findAuthApiIdById(Integer id);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment