ars.module.people.service.AbstractRoleService Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ars-module-people Show documentation
Show all versions of ars-module-people Show documentation
Ars framework module people
package ars.module.people.service;
import ars.invoke.request.Requester;
import ars.module.people.model.User;
import ars.module.people.model.Role;
import ars.module.people.service.RoleService;
import ars.database.repository.Repositories;
import ars.database.service.StandardGeneralService;
import ars.database.repository.DataConstraintException;
/**
* 角色业务操作抽象实现
*
* @author yongqiangwu
*
* @param
* 数据模型
*/
public abstract class AbstractRoleService extends StandardGeneralService implements RoleService {
@Override
public void deleteObject(Requester requester, T object) {
if (object.getInnate() == Boolean.TRUE) {
throw new RuntimeException("Innate role is not deletable:" + object);
}
User user = Repositories.getRepository(User.class).query().in("roles.id", new Integer[] { object.getId() })
.paging(1, 1).single();
if (user != null) {
String message = new StringBuilder(requester.format(user.getClass().getName())).append('【')
.append(user.toString()).append('】').toString();
throw new DataConstraintException(message);
}
super.deleteObject(requester, object);
}
}