All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ars.module.people.service.AbstractRoleService Maven / Gradle / Ivy

There is a newer version: 2.0.0
Show newest version
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);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy