Package com.sm.web.rbac.model

Source Code of com.sm.web.rbac.model.AccountRoleModel

package com.sm.web.rbac.model;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Service;

import com.sm.framework.base.BaseModel;
import com.sm.framework.util.queryModel.QueryModel;
import com.sm.web.rbac.pojo.AccountRole;

/**
* ��Ŀ��schoolMedia��Ŀ
*
* �������ʺźͽ�ɫModel��
*
* ����ʱ�䣺2012-12-9 ����11:02:22 �����ˣ���С�� �汾��version 0.10
*
* �޸�ʱ�䣺2012-12-9 ����11:02:22 �޸��ˣ���С�� �޶��汾��version 0.10
*/
@Service
public class AccountRoleModel extends BaseModel<AccountRole> {
  /**
   * ����������accountId���ҽ�ɫId
   *
   * @param accountId
   * @return 2012-12-10 ����12:03:54 ��С��
   */
  public List<Integer> queryRoleIdList(Integer accountId) {
    QueryModel queryModel = new QueryModel();
    if (null != accountId) {
      queryModel.combEquals("accountId", accountId);
      List<AccountRole> accountRoleList = super.queryByModel(queryModel);
      if (null != accountRoleList && accountRoleList.size() > 0) {
        List<Integer> resultList = new ArrayList<Integer>();
        for (AccountRole accountRole : accountRoleList) {
          resultList.add(accountRole.getRoleId());
        }
        return resultList;
      }
    }
    return null;
  }

  /**
   * �����������ʺ�-��ɫ�Ĺ�ϵ
   *
   * @param accountId
   * @param roleIdList
   *            2012-12-11 ����8:52:27 ��С��
   */
  public void addAccountRoles(Integer accountId, List<Integer> roleIdList) {
    for (Integer roleId : roleIdList) {
      super.save(new AccountRole(accountId, roleId));
    }
  }

  /**
   * ������ɾ���˻���Ӧ������ �˻�-��ɫ��Ŀ
   *
   * @param accountId
   *            2012-12-11 ����9:03:05 ��С��
   */
  public void deleteByAccountId(Integer accountId) {
    if (null != accountId) {
      QueryModel queryModel = new QueryModel();
      queryModel.combEquals("accountId", accountId);
      super.deleteByModel(queryModel);
    }
  }

  /**
   * ������ɾ����Ӧ��ɫ���� �˻�-��ɫ��Ŀ
   *
   * @param roleId
   *            2012-12-11 ����9:07:32 ��С��
   */
  public void deleteByRoleId(Integer roleId) {
    if (null != roleId) {
      QueryModel queryModel = new QueryModel();
      queryModel.combEquals("roleId", roleId);
      super.deleteByModel(queryModel);
    }
  }
}
TOP

Related Classes of com.sm.web.rbac.model.AccountRoleModel

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.