forked from p81075629/datagear
管理员账号不允许删除
This commit is contained in:
parent
93a5bc2340
commit
a8fb05bb53
|
@ -7,6 +7,7 @@
|
|||
|
||||
package org.datagear.management.domain;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
@ -221,4 +222,44 @@ public class User extends AbstractStringIdEntity implements CloneableEntity
|
|||
{
|
||||
return ADMIN_USER_ID.equals(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否包含管理员账号。
|
||||
*
|
||||
* @param userIds
|
||||
* @return
|
||||
*/
|
||||
public static boolean containsAdminUser(String[] userIds)
|
||||
{
|
||||
if (userIds == null)
|
||||
return false;
|
||||
|
||||
for (String userId : userIds)
|
||||
{
|
||||
if (ADMIN_USER_ID.equals(userId))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否包含管理员账号。
|
||||
*
|
||||
* @param userIds
|
||||
* @return
|
||||
*/
|
||||
public static boolean containsAdminUser(Collection<String> userIds)
|
||||
{
|
||||
if (userIds == null)
|
||||
return false;
|
||||
|
||||
for (String userId : userIds)
|
||||
{
|
||||
if (ADMIN_USER_ID.equals(userId))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -247,6 +247,10 @@ public class UserController extends AbstractController
|
|||
if (Arrays.asList(form.getIds()).contains(form.getMigrateToId()))
|
||||
throw new IllegalInputException();
|
||||
|
||||
if (User.containsAdminUser(form.getIds()))
|
||||
return buildOperationMessageFailResponseEntity(request, HttpStatus.BAD_REQUEST,
|
||||
buildMessageCode("deleteAdminUserDenied"));
|
||||
|
||||
User user = this.userService.getById(form.getMigrateToId());
|
||||
|
||||
if (user == null)
|
||||
|
|
Loading…
Reference in New Issue