⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 groupmanagerimpl.java

📁 基于java的组号查询模块
💻 JAVA
字号:
/**
 * 
 */
package com.lily.dap.service.organize.impl;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

import com.lily.dap.model.organize.Group;
import com.lily.dap.service.core.BaseManager;
import com.lily.dap.service.core.VerifyUtil;
import com.lily.dap.service.core.exception.NotSupportOperationException;
import com.lily.dap.service.organize.GroupManager;
import com.lily.dap.service.right.RightHoldManager;

/**
 * @author zouxuemo
 *
 */
public class GroupManagerImpl extends BaseManager implements GroupManager, ApplicationContextAware {
	private RightHoldManager rightHoldManager;
	
	private ApplicationContext ctx;
	
	/**
	 * @param rightHoldManager 要设置的 rightHoldManager
	 */
	public void setRightHoldManager(RightHoldManager rightHoldManager) {
		this.rightHoldManager = rightHoldManager;
	}

	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		ctx = applicationContext;
	}

	/* (非 Javadoc)
	 * @see com.lily.dap.service.core.BaseManager#onBeforeAdd(java.lang.Object)
	 */
	protected Object onBeforeAdd(Object entity) {
		if (!(entity instanceof Group))
			throw new NotSupportOperationException("接口只支持对Group的add(...)方法!");
		
		entity = super.onBeforeAdd(entity);
		
		Group g = (Group)entity;
		
		VerifyUtil verifyUtil = new VerifyUtil(dao);
		verifyUtil.assertDataNotRepeat(Group.class, "name", g.getName(), "指定的群组名称重复,请重新指定新的群组名称");
		
		rightHoldManager.providerHoldsRole(g);
		
		return g;
	}

	/* (非 Javadoc)
	 * @see com.lily.dap.service.core.BaseManager#onAfterAdd(java.lang.Object)
	 */
	protected void onAfterAdd(Object entity) {
		super.onAfterAdd(entity);
		
		ctx.publishEvent(new OrganizeNotifyEvent(OrganizeNotifyEvent.EVENT_CLASS_GROUP, OrganizeNotifyEvent.EVENT_ADD_GROUP, entity));
	}

	/* (非 Javadoc)
	 * @see com.lily.dap.service.core.BaseManager#onBeforeModify(java.lang.Object)
	 */
	protected Object onBeforeModify(Object entity) {
		if (!(entity instanceof Group))
			throw new NotSupportOperationException("接口只支持对Group的modify(...)方法!");
		entity = super.onBeforeModify(entity);
		
		Group g = (Group)entity;
		
		VerifyUtil verifyUtil = new VerifyUtil(dao);
		verifyUtil.assertDataNotRepeat(Group.class, "name", g.getName(), "id", new Long(g.getId()), "指定的群组名称重复,请重新指定新的群组名称");
		
		Group group = (Group)get(Group.class, g.getId());
		group.setName(g.getName());
		group.setDes(g.getDes());
		group.setGroupMember(g.getGroupMember());
		
		return group;
	}

	/* (非 Javadoc)
	 * @see com.lily.dap.service.core.BaseManager#onAfterModify(java.lang.Object)
	 */
	protected void onAfterModify(Object entity) {
		super.onAfterModify(entity);
		
		ctx.publishEvent(new OrganizeNotifyEvent(OrganizeNotifyEvent.EVENT_CLASS_GROUP, OrganizeNotifyEvent.EVENT_MODIFY_GROUP, entity));
	}

	/* (非 Javadoc)
	 * @see com.lily.dap.service.core.BaseManager#onBeforeRemove(java.lang.Object)
	 */
	protected void onBeforeRemove(Object entity) {
		if (!(entity instanceof Group))
			throw new NotSupportOperationException("接口只支持对Group的remove(...)方法!");
		
		super.onBeforeRemove(entity);

		Group g = (Group)entity;
		
		rightHoldManager.removeHoldsRoles(g);
	}

	/* (非 Javadoc)
	 * @see com.lily.dap.service.core.BaseManager#onAfterRemove(java.lang.Object)
	 */
	protected void onAfterRemove(Object entity) {
		super.onAfterRemove(entity);
		
		ctx.publishEvent(new OrganizeNotifyEvent(OrganizeNotifyEvent.EVENT_CLASS_GROUP, OrganizeNotifyEvent.EVENT_REMOVE_GROUP, entity));
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -