Search in sources :

Example 6 with Project

use of com.itrus.portal.db.Project in project portal by ixinportal.

the class UserInfoController method detail.

/**
 * 查看用户详情
 *
 * @param id
 *            用户id
 * @param item
 *            用户关联的项(0企业、1证书、2订单、3认证)
 * @param page
 * @param size
 * @param uiModel
 * @return
 */
@RequestMapping("/detail")
public String detail(@RequestParam(value = "id", required = true) Long id, @RequestParam(value = "item", required = false) Integer item, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, Model uiModel) {
    UserInfo userInfo = sqlSession.selectOne("com.itrus.portal.db.UserInfoMapper.selectByPrimaryKey", id);
    // 判断查询的用户是否属于当前管理员所管理的范围
    Long[] manageProjectIds = getProjectLongIdsOfAdmin();
    // 默认不属于当前管理员管理范围
    boolean flag = false;
    for (Long projectId : manageProjectIds) {
        if (userInfo.getProject() == projectId) {
            flag = true;
        }
    }
    if (!flag) {
        // 没有管理权限
        return "status403";
    }
    // 根据省市区code值获取省市区最新名称
    String regionCodes = userInfo.getRegionCodes();
    String userAdds = userInfo.getUserAdds();
    if (StringUtils.isNotBlank(regionCodes) && regionCodes.indexOf("@") >= 0) {
        String[] codes = regionCodes.split("@");
        String regionName = sysRegionService.getAllName(codes[1], codes[2], codes[3]);
        userAdds = regionName + userAdds;
        userInfo.setUserAdds(userAdds);
    }
    uiModel.addAttribute("userInfo", userInfo);
    if (page == null || page < 1) {
        page = 1;
    }
    if (size == null || size < 1) {
        size = 10;
    }
    // 总记录数
    Integer count = 0;
    // 当前页记录数
    Integer itemcount = 0;
    // null、0关联企业,1证书信息,2订单列表
    if (null == item || 0 == item) {
        item = 0;
        // 关联企业
        List<Enterprise> enterprises = new ArrayList<Enterprise>();
        List<Long> enterpriseIds = userInfoEnterpriseService.getEnterpriseByUserInfo(userInfo.getId());
        if (null != enterpriseIds && !enterpriseIds.isEmpty()) {
            count = enterpriseIds.size();
            EnterpriseExample enterpriseExample = new EnterpriseExample();
            EnterpriseExample.Criteria criteria = enterpriseExample.or();
            criteria.andIdIn(enterpriseIds);
            if (page > 1 && size * (page - 1) >= count) {
                page = (count + size - 1) / size;
            }
            Integer offset = size * (page - 1);
            enterpriseExample.setOffset(offset);
            enterpriseExample.setLimit(size);
            enterpriseExample.setOrderByClause("create_time desc");
            enterprises = sqlSession.selectList("com.itrus.portal.db.EnterpriseMapper.selectByExample", enterpriseExample);
        }
        itemcount = enterprises.size();
        uiModel.addAttribute("enterprises", enterprises);
    } else if (1 == item) {
        item = 1;
        // TODO 证书信息
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("id", userInfo.getId());
        count = sqlSession.selectOne("com.itrus.portal.db.UserCertMapper.countByUserInfoID", userInfo.getId());
        if (page > 1 && size * (page - 1) >= count) {
            page = (count + size - 1) / size;
        }
        Integer offset = size * (page - 1);
        map.put("offset", offset);
        map.put("limit", size);
        List<UserCert> userCertList = sqlSession.selectList("com.itrus.portal.db.UserCertMapper.selectByUserInfoID", map);
        itemcount = userCertList.size();
        uiModel.addAttribute("userCertList", userCertList);
    } else if (2 == item) {
        item = 2;
        // 订单列表
        BillExample billExample = new BillExample();
        BillExample.Criteria criteria = billExample.or();
        criteria.andUniqueIdEqualTo(userInfo.getId());
        // criteria.andIsDeleteEqualTo(false);
        count = sqlSession.selectOne("com.itrus.portal.db.BillMapper.countByExample", billExample);
        if (page > 1 && size * (page - 1) >= count) {
            page = (count + size - 1) / size;
        }
        Integer offset = size * (page - 1);
        billExample.setOffset(offset);
        billExample.setLimit(size);
        billExample.setOrderByClause("create_time desc");
        List<Bill> billList = sqlSession.selectList("com.itrus.portal.db.BillMapper.selectByExample", billExample);
        itemcount = billList.size();
        uiModel.addAttribute("billList", billList);
        Map<Long, Project> projectMap = billService.getProjectMapByUserInfoId(userInfo.getId());
        uiModel.addAttribute("projectMap", projectMap);
        Map<Long, Product> productMap = billService.getProductMapByUserInfoId(userInfo.getId());
        uiModel.addAttribute("productMap", productMap);
        Map<Long, Enterprise> enterpriseMap = billService.getEnterpriseMapByUserInfoId(userInfo.getId());
        uiModel.addAttribute("enterpriseMap", enterpriseMap);
    } else if (3 == item) {
        item = 3;
        Agent agent = sqlSession.selectOne("com.itrus.portal.db.AgentMapper.selectNewAgentByUserId", id);
        uiModel.addAttribute("agent", agent);
    }
    uiModel.addAttribute("count", count);
    uiModel.addAttribute("pages", (count + size - 1) / size);
    uiModel.addAttribute("page", page);
    uiModel.addAttribute("size", size);
    uiModel.addAttribute("itemcount", itemcount);
    uiModel.addAttribute("item", item);
    return "userInfo/detail";
}
Also used : ArrayList(java.util.ArrayList) Product(com.itrus.portal.db.Product) UserInfo(com.itrus.portal.db.UserInfo) BillExample(com.itrus.portal.db.BillExample) ArrayList(java.util.ArrayList) List(java.util.List) Agent(com.itrus.portal.db.Agent) Project(com.itrus.portal.db.Project) EnterpriseExample(com.itrus.portal.db.EnterpriseExample) Enterprise(com.itrus.portal.db.Enterprise) Bill(com.itrus.portal.db.Bill) HashMap(java.util.HashMap) Map(java.util.Map) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 7 with Project

use of com.itrus.portal.db.Project in project portal by ixinportal.

the class CustomerServerClientController method onLine.

/**
 * 用户登录后的客服在线
 * @param certSn
 * @param keySn
 * @param enterpriseName
 * @param session
 * @param uiModel
 * @return
 */
@RequestMapping("/online")
public String onLine(@RequestParam(value = "certSn", required = false) String certSn, @RequestParam(value = "keySn", required = false) String keySn, @RequestParam(value = "enterpriseName", required = false) String enterpriseName, HttpSession session, Model uiModel) {
    // TODO
    Boolean verifyCodeStatus = (Boolean) session.getAttribute(ComNames.WEB_VERIFY_CODE_STATUS);
    Enterprise enterprise = (Enterprise) session.getAttribute(ComNames.WEB_ENTERPRISE);
    UserInfo userInfo = (UserInfo) session.getAttribute(ComNames.WEB_USER_INFO);
    if (null == verifyCodeStatus || !verifyCodeStatus || null == userInfo) {
        // 登录状态失效,跳转到登录页面
        return ComNames.DENG_LU_CLIENT;
    }
    // 先根据key序列号取项目,若没有,则根据用户所属项目取项目信息
    Project project = null;
    if (StringUtils.isNotBlank(keySn)) {
        ProjectKeyInfo projectKeyInfo = cacheCustomer.findProjectByKey(keySn);
        if (null == projectKeyInfo) {
            uiModel.addAttribute("errorMsg", "无法识别的key序列号:" + keySn + ", 请联系系统管理员进行配置");
            return ComNames.CLIENTFW_ERRORPAGE;
        }
        project = projectService.selectByPrimaryKey(projectKeyInfo.getProject());
    }
    // 若项目为Null,而certsn不为null,则尝试从数据库获取keysn,查找项目
    if (null == project && StringUtils.isNotBlank(certSn)) {
        UserCert userCert = userCertService.getUserCertByCertSn(certSn);
        if (null != userCert && StringUtils.isNotBlank(userCert.getKeySn())) {
            ProjectKeyInfo projectKeyInfo = cacheCustomer.findProjectByKey(userCert.getKeySn());
            if (null != projectKeyInfo) {
                project = projectService.selectByPrimaryKey(projectKeyInfo.getProject());
            }
        }
    }
    if (null == project) {
        project = projectService.selectByPrimaryKey(userInfo.getProject());
    }
    Map<String, String> map = questionService.auth(project.getId());
    if (map != null && !map.isEmpty()) {
        uiModel.addAttribute("qq", map.get("qq"));
        uiModel.addAttribute("phone", map.get("phone"));
        uiModel.addAttribute("questionUrl", map.get("questionUrl"));
        uiModel.addAttribute("downloadUrl", map.get("downloadUrl"));
    }
    return "clientFW/kefuzaixian";
}
Also used : Project(com.itrus.portal.db.Project) ProjectKeyInfo(com.itrus.portal.db.ProjectKeyInfo) Enterprise(com.itrus.portal.db.Enterprise) UserInfo(com.itrus.portal.db.UserInfo) UserCert(com.itrus.portal.db.UserCert) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 8 with Project

use of com.itrus.portal.db.Project in project portal by ixinportal.

the class ProjectController method updateForm.

// 返回修改页面
@RequestMapping(value = "/{id}", params = "form", produces = "text/html")
public String updateForm(@PathVariable("id") Long id, Model uiModel) {
    List raaccountall = sqlSession.selectList("com.itrus.portal.db.RaAccountMapper.selectByExample");
    uiModel.addAttribute("raaccounts", raaccountall);
    Project project = sqlSession.selectOne("com.itrus.portal.db.ProjectMapper.selectByPrimaryKey", id);
    uiModel.addAttribute("project", project);
    // orgCode
    uiModel.addAttribute("orgCode", project.getOrgCode());
    return "projects/update";
}
Also used : Project(com.itrus.portal.db.Project) ArrayList(java.util.ArrayList) List(java.util.List) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 9 with Project

use of com.itrus.portal.db.Project in project portal by ixinportal.

the class ProjectController method delete.

// 删除
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE, produces = "text/html")
public String delete(@PathVariable("id") Long id, HttpServletRequest request, Model uiModel) {
    Project project = sqlSession.selectOne("com.itrus.portal.db.ProjectMapper.selectByPrimaryKey", id);
    if (project == null) {
        uiModel.addAttribute("message", "未找到要删除项目");
    } else {
        try {
            sqlSession.delete("com.itrus.portal.db.ProjectMapper.deleteByPrimaryKey", id);
            String oper = "删除项目";
            String info = "项目名称: " + project.getName();
            LogUtil.adminlog(sqlSession, oper, info);
            cacheCustomer.initProjectMap();
        } catch (Exception e) {
            uiModel.addAttribute("message", "要删除项目【" + project.getName() + "】存在关联,无法删除");
        }
    }
    return getReferer(request, "redirect:/projects", true);
}
Also used : Project(com.itrus.portal.db.Project) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 10 with Project

use of com.itrus.portal.db.Project in project portal by ixinportal.

the class ProjectKeyInfoController method create.

// 新建处理
@RequestMapping(method = RequestMethod.POST, produces = "text/html")
public String create(@Valid ProjectKeyInfo projectkeyinfo, @RequestParam(value = "retpath", required = false) String retpath, BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest) throws Exception {
    if (bindingResult.hasErrors()) {
        return "projectkeyinfos/create";
    }
    // 检查是否有权限操作
    Long[] projects = getProjectLongIdsOfAdmin();
    List<Long> list = Arrays.asList(projects);
    if (list != null && !list.contains(projectkeyinfo.getProject())) {
        return "status403";
    }
    projectkeyinfo.setCreateTime(new Date());
    projectkeyinfo.setId(null);
    // 加密adminPinValue信息
    if (projectkeyinfo.getAdminPinValue() != null && !projectkeyinfo.getAdminPinValue().equals("")) {
        String unlockCipher = "AES";
        SecretKeySpec skeySpec = new SecretKeySpec(this.adminPinEncKey.substring(0, 16).getBytes(), unlockCipher);
        IvParameterSpec ivSpec = new IvParameterSpec(this.adminPinEncKey.substring(16, 32).getBytes());
        Cipher cipher = Cipher.getInstance(unlockCipher + "/CBC/PKCS5Padding");
        cipher.init(Cipher.ENCRYPT_MODE, skeySpec, ivSpec, null);
        byte[] encadminpin = cipher.doFinal(projectkeyinfo.getAdminPinValue().getBytes());
        String sencadminpin = new String(Base64.encode(encadminpin));
        projectkeyinfo.setAdminPinValue(sencadminpin);
    }
    if (projectkeyinfo.getAdminPinValue2() != null && !projectkeyinfo.getAdminPinValue2().equals("")) {
        String unlockCipher = "AES";
        SecretKeySpec skeySpec = new SecretKeySpec(this.adminPinEncKey.substring(0, 16).getBytes(), unlockCipher);
        IvParameterSpec ivSpec = new IvParameterSpec(this.adminPinEncKey.substring(16, 32).getBytes());
        Cipher cipher = Cipher.getInstance(unlockCipher + "/CBC/PKCS5Padding");
        cipher.init(Cipher.ENCRYPT_MODE, skeySpec, ivSpec, null);
        byte[] encadminpin = cipher.doFinal(projectkeyinfo.getAdminPinValue2().getBytes());
        String sencadminpin = new String(Base64.encode(encadminpin));
        projectkeyinfo.setAdminPinValue2(sencadminpin);
    }
    sqlSession.insert("com.itrus.portal.db.ProjectKeyInfoMapper.insert", projectkeyinfo);
    Project project = sqlSession.selectOne("com.itrus.portal.db.ProjectMapper.selectByPrimaryKey", projectkeyinfo.getProject());
    String oper = "添加序列号";
    String info = "项目名称: " + project.getName() + ", 序列号1: " + projectkeyinfo.getSn1() + ", 序列号2: " + projectkeyinfo.getSn2();
    LogUtil.adminlog(sqlSession, oper, info);
    cacheCustomer.initProjectKeyInfos();
    if (retpath != null && retpath.length() > 0)
        return retpath;
    else
        return "redirect:/projectkeyinfos";
}
Also used : Project(com.itrus.portal.db.Project) SecretKeySpec(javax.crypto.spec.SecretKeySpec) IvParameterSpec(javax.crypto.spec.IvParameterSpec) Cipher(javax.crypto.Cipher) Date(java.util.Date) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

Project (com.itrus.portal.db.Project)77 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)59 HashMap (java.util.HashMap)32 UserInfo (com.itrus.portal.db.UserInfo)24 Enterprise (com.itrus.portal.db.Enterprise)20 ExtraProduct (com.itrus.portal.db.ExtraProduct)17 ProjectExample (com.itrus.portal.db.ProjectExample)16 ArrayList (java.util.ArrayList)15 ProjectKeyInfo (com.itrus.portal.db.ProjectKeyInfo)12 UserInfoServiceException (com.itrus.portal.exception.UserInfoServiceException)12 Product (com.itrus.portal.db.Product)10 Date (java.util.Date)10 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)9 BusinessLicense (com.itrus.portal.db.BusinessLicense)8 IdentityCard (com.itrus.portal.db.IdentityCard)8 OrgCode (com.itrus.portal.db.OrgCode)8 TaxRegisterCert (com.itrus.portal.db.TaxRegisterCert)8 UserinfoEnterprise (com.itrus.portal.db.UserinfoEnterprise)8 List (java.util.List)8 Map (java.util.Map)8