Commit 3371d19a authored by 李欣峰's avatar 李欣峰

<dev>

1.新增删除api接口时,如果该api存在设置的权限,提示不可删除,请删除权限后再删除
parent 23a76368
......@@ -315,9 +315,17 @@ public class ApiServiceApplicationImpl implements ApiApplication {
InvokeResult invokeResult;
api.setId(id);
try {
//删除接口分组,查询该id的分组是否存在parentId,如果没有可以删除,如果存在不能删除
//查看API表是否存在id,非空判断 count>0,说明存在
Integer count = apiRepository.selectCountFromId(id);
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);
} else {
log.error("删除Api接口失败!");
......
......@@ -63,5 +63,15 @@ public interface ApiAuthRepository extends JpaRepository<ApiAuth, Integer>, JpaS
* @return
*/
@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