Пример #1
0
  private void initCRMRole() {
    List<ResourceType> rts = session.createQuery("from ResourceType rt").list();

    Map<String, ResourceType> rtMap = new HashMap<String, ResourceType>();
    for (ResourceType rt : rts) {
      rtMap.put(rt.getName(), rt);
    }

    List<Menu> menus = session.createQuery("from Menu m where m.scope = 'crm'").list();
    Map<String, Menu> menuMap = new HashMap<String, Menu>();
    for (Menu menu : menus) {
      menuMap.put(menu.getPath(), menu);
    }

    //		Role admin = new Role();
    //		admin.setName("系统管理员");
    //		admin.setSysAdmin(true);
    //		admin.setCode(Role.ROLE_ADMIN);
    //		admin.setDescription("拥有系统管理的权限");
    //		admin.addMenu(menuMap.get("系统管理"));
    //		admin.addMenu(menuMap.get("系统管理/企业管理"));
    //		admin.addMenu(menuMap.get("系统管理/用户管理"));
    //		session.save(admin);

    SubSystemDefinition ssd =
        (SubSystemDefinition)
            session
                .createQuery("from SubSystemDefinition ssd where ssd.code = 'crm'")
                .uniqueResult();
    Role account = new Role();
    account.setName("账户管理");
    account.setCode(Role.ROLE_CODE_CRM_ACCOUNT);
    account.setDescription("拥有账户管理的权限");
    account.setSubSystem(ssd);
    account.addPermission(new Permission(rtMap.get(ResourceType.RES_TYPE_CRMACCOUNT), "*"));
    account.addMenu(menuMap.get("账户管理"));
    account.addMenu(menuMap.get("账户管理/用户管理"));
    account.addMenu(menuMap.get("账户管理/部门管理"));
    account.addMenu(menuMap.get("账户管理/数据字典管理"));
    account.addMenu(menuMap.get("账户管理/客户完整度管理"));
    account.setType("company|agency|provider");
    account.setResourceType(rtMap.get(ResourceType.RES_TYPE_ACCOUNT));
    session.save(account);

    Role sell = new Role();
    sell.setName("销售人员");
    sell.setCode(Role.ROLE_CODE_CRM_SELL);
    sell.setDescription("拥有销售机会管理的权限");
    sell.addPermission(new Permission(rtMap.get(ResourceType.RES_TYPE_CUSTOMER), "*"));
    sell.addPermission(new Permission(rtMap.get(ResourceType.RES_TYPE_SELL), "*"));
    //		sell.addMenu(menuMap.get("客户管理"));
    //		sell.addMenu(menuMap.get("客户管理/客户管理"));
    //		sell.addMenu(menuMap.get("客户管理/联系人管理"));
    //		sell.addMenu(menuMap.get("客户管理/客户关怀"));
    //		sell.addMenu(menuMap.get("客户管理/客户所有人查询"));
    //		sell.addMenu(menuMap.get("销售管理"));
    //		sell.addMenu(menuMap.get("销售管理/销售机会管理"));
    //		sell.addMenu(menuMap.get("销售管理/合同管理"));
    sell.setSubSystem(ssd);
    sell.setType("company|agency|provider");
    sell.setResourceType(rtMap.get(ResourceType.RES_TYPE_ACCOUNT));
    session.save(sell);

    Role customService = new Role();
    customService.setName("客户服务");
    customService.setCode(Role.ROLE_CODE_CRM_SERVICE);
    customService.setDescription("拥有客户服务管理的权限");
    customService.addPermission(new Permission(rtMap.get(ResourceType.RES_TYPE_CUSTOMER), "*"));
    //		customService.addMenu(menuMap.get("客户管理"));
    //		customService.addMenu(menuMap.get("客户管理/客户管理"));
    //		customService.addMenu(menuMap.get("客户管理/联系人管理"));
    //		customService.addMenu(menuMap.get("客户管理/客户关怀"));
    //		customService.addMenu(menuMap.get("客户管理/客户所有人查询"));
    //		customService.addMenu(menuMap.get("客服管理"));
    //		customService.addMenu(menuMap.get("客服管理/通话记录管理"));
    customService.setSubSystem(ssd);
    customService.setType("company|agency|provider");
    customService.setResourceType(rtMap.get(ResourceType.RES_TYPE_ACCOUNT));
    session.save(customService);

    //		Role resourceManager = new Role();
    //		resourceManager.setName("资源管理");
    //		resourceManager.setCode(Role.RESOURCE_MANAGER);
    //		resourceManager.setDescription("拥有资源审批的权限");
    //		resourceManager.addPermission(new Permission(rtMap.get(ResourceType.RES_TYPE_CUSTOMER),
    // "*"));
    //		resourceManager.addPermission(new Permission(rtMap.get(ResourceType.RES_TYPE_SELL), "*"));
    //		resourceManager.addMenu(menuMap.get("客户管理"));
    //		resourceManager.addMenu(menuMap.get("客户管理/客户管理"));
    //		resourceManager.addMenu(menuMap.get("客户管理/联系人管理"));
    //		resourceManager.addMenu(menuMap.get("客户管理/客户关怀"));
    //		resourceManager.addMenu(menuMap.get("客户管理/客户关怀"));
    //		resourceManager.addMenu(menuMap.get("客户管理/客户所有人查询"));
    //		resourceManager.addMenu(menuMap.get("客户管理/统计分析/客户类型分布"));
    //		resourceManager.addMenu(menuMap.get("客户管理/统计分析/客户来源分布"));
    //		resourceManager.addMenu(menuMap.get("客户管理/统计分析/客户行业分布"));
    //		resourceManager.addMenu(menuMap.get("客户管理/统计分析/客户规模分布"));
    //		resourceManager.addMenu(menuMap.get("客户管理/统计分析/销售进程分布"));
    //		resourceManager.addMenu(menuMap.get("客户管理/统计分析/销售机会所有人分布"));
    //		resourceManager.addMenu(menuMap.get("客户管理/统计分析/预计金额分布"));
    //		resourceManager.addMenu(menuMap.get("销售管理"));
    //		resourceManager.addMenu(menuMap.get("销售管理/销售机会管理"));
    //		resourceManager.addMenu(menuMap.get("销售管理/合同管理"));
    //		session.save(resourceManager);

    Role sellManager = new Role();
    sellManager.setName("销售管理");
    sellManager.setCode(Role.ROLE_CODE_CRM_MANAGER);
    sellManager.setDescription("拥有销售管理的权限");
    sellManager.addPermission(new Permission(rtMap.get(ResourceType.RES_TYPE_CUSTOMER), "*"));
    sellManager.addPermission(new Permission(rtMap.get(ResourceType.RES_TYPE_SELL), "*"));
    sellManager.addMenu(menuMap.get("客户管理"));
    sellManager.addMenu(menuMap.get("客户管理/客户管理"));
    sellManager.addMenu(menuMap.get("客户管理/联系人管理"));
    sellManager.addMenu(menuMap.get("客户管理/客户关怀"));
    sellManager.addMenu(menuMap.get("销售管理"));
    sellManager.addMenu(menuMap.get("销售管理/销售机会管理"));
    sellManager.addMenu(menuMap.get("销售管理/合同管理"));
    //		sellManager.addMenu(menuMap.get("销售管理/统计报表"));
    //		sellManager.addMenu(menuMap.get("销售管理/统计报表/呼叫统计"));
    //		sellManager.addMenu(menuMap.get("销售管理/统计报表/广告分析统计"));
    //		sellManager.addMenu(menuMap.get("销售管理/统计报表/销售分析统计"));
    //		sellManager.addMenu(menuMap.get("销售管理/统计报表/客户分析统计"));
    sellManager.addMenu(menuMap.get("客服管理"));
    sellManager.addMenu(menuMap.get("客服管理/通话记录管理"));
    sellManager.setSubSystem(ssd);
    sellManager.setType("company|agency|provider");
    sellManager.setResourceType(rtMap.get(ResourceType.RES_TYPE_ACCOUNT));
    session.save(sellManager);
  }
Пример #2
0
  private void initCRMResourceType() {
    ResourceType account = new ResourceType();
    account.setName(ResourceType.RES_TYPE_CRMACCOUNT);
    account.setSubsystemCode("crm");
    account.setDescription("账户管理");

    ResourceTypePermission editUser = new ResourceTypePermission();
    editUser.setAction("editUser");
    editUser.setDescription("修改用户");
    editUser.setMask(1);
    account.addPermission(editUser);

    ResourceTypePermission editDept = new ResourceTypePermission();
    editDept.setAction("editDept");
    editDept.setDescription("修改部门");
    editDept.setMask(2);
    account.addPermission(editDept);

    ResourceTypePermission editCustomField = new ResourceTypePermission();
    editCustomField.setAction("editCustomField");
    editCustomField.setDescription("修改自定义字段");
    editCustomField.setMask(4);
    account.addPermission(editCustomField);

    ResourceTypePermission editIndicate = new ResourceTypePermission();
    editIndicate.setAction("editIndicate");
    editIndicate.setDescription("修改客户评分指标");
    editIndicate.setMask(8);
    account.addPermission(editIndicate);

    session.save(account);

    // 客户
    ResourceType rtc = new ResourceType();
    rtc.setName(ResourceType.RES_TYPE_CUSTOMER);
    rtc.setSubsystemCode("crm");
    rtc.setDescription("客户");

    ResourceTypePermission cnew = new ResourceTypePermission();
    cnew.setAction("createCustomer");
    cnew.setDescription("新增客户");
    cnew.setMask(1);
    rtc.addPermission(cnew);

    ResourceTypePermission cview = new ResourceTypePermission();
    cview.setAction("viewCustomer");
    cview.setDescription("查看客户");
    cview.setMask(2);
    rtc.addPermission(cview);

    ResourceTypePermission cedit = new ResourceTypePermission();
    cedit.setAction("editCustomer");
    cedit.setDescription("修改/删除客户");
    cedit.setMask(4);
    rtc.addPermission(cedit);

    ResourceTypePermission ctrans = new ResourceTypePermission();
    ctrans.setAction("transferCustomer");
    ctrans.setDescription("转移客户");
    ctrans.setMask(8);
    rtc.addPermission(ctrans);

    session.save(rtc);

    ResourceType rtl = new ResourceType();
    rtl.setName(ResourceType.RES_TYPE_LINKMAN);
    rtl.setSubsystemCode("crm");
    rtl.setDescription("联系人");

    ResourceTypePermission lnew = new ResourceTypePermission();
    lnew.setAction("createLinkman");
    lnew.setDescription("新增联系人");
    lnew.setMask(1);
    rtl.addPermission(lnew);

    ResourceTypePermission lview = new ResourceTypePermission();
    lview.setAction("viewLinkman");
    lview.setDescription("查看联系人");
    lview.setMask(2);
    rtl.addPermission(lview);

    ResourceTypePermission ledit = new ResourceTypePermission();
    ledit.setAction("editLinkman");
    ledit.setDescription("修改/删除联系人");
    ledit.setMask(4);
    rtl.addPermission(ledit);

    session.save(rtl);

    ResourceType rts = new ResourceType();
    rts.setName(ResourceType.RES_TYPE_CONCERN);
    rts.setSubsystemCode("crm");
    rts.setDescription("客户关怀");

    ResourceTypePermission gnew = new ResourceTypePermission();
    gnew.setAction("createCustomerConcern");
    gnew.setDescription("新增客户关怀");
    gnew.setMask(1);
    rts.addPermission(gnew);

    ResourceTypePermission gview = new ResourceTypePermission();
    gview.setAction("viewCustomerConcern");
    gview.setDescription("查看客户关怀");
    gview.setMask(2);
    rts.addPermission(gview);

    ResourceTypePermission gedit = new ResourceTypePermission();
    gedit.setAction("editCustomerConcern");
    gedit.setDescription("修改/删除客户关怀");
    gedit.setMask(4);
    rts.addPermission(gedit);

    session.save(rts);

    // 销售
    ResourceType rss = new ResourceType();
    rss.setName(ResourceType.RES_TYPE_SELL);
    rss.setSubsystemCode("crm");
    rss.setDescription("销售机会");

    ResourceTypePermission snew = new ResourceTypePermission();
    snew.setAction("newSellOpportunity");
    snew.setDescription("新增销售机会");
    snew.setMask(1);
    rss.addPermission(snew);

    ResourceTypePermission sview = new ResourceTypePermission();
    sview.setAction("viewSellOpportunity");
    sview.setDescription("查看销售机会");
    sview.setMask(2);
    rss.addPermission(sview);

    ResourceTypePermission sedit = new ResourceTypePermission();
    sedit.setAction("editSellOpportunity");
    sedit.setDescription("修改/删除销售机会");
    sedit.setMask(4);
    rss.addPermission(sedit);

    session.save(rss);
  }