Search in sources :

Example 46 with Project

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

the class ProjectController method update.

// 修改处理
@RequestMapping(method = RequestMethod.PUT, produces = "text/html")
public String update(@Valid Project project, BindingResult bindingResult, @RequestParam(value = "photoCodeImg", required = false) String photoCodeImg, Model uiModel, HttpServletRequest httpServletRequest) throws Exception {
    if (bindingResult.hasErrors()) {
        uiModel.addAttribute("project", project);
        return "projects/update";
    }
    Project project0 = sqlSession.selectOne("com.itrus.portal.db.ProjectMapper.selectByPrimaryKey", project.getId());
    project.setCreateTime(project0.getCreateTime());
    // 当企业代码为""或者null时,统一设置为null
    if (StringUtils.isBlank(project.getOrgCode()))
        project.setOrgCode(null);
    else if (isExistProject(project.getId(), project.getOrgCode())) {
        uiModel.addAttribute("message", "企业代码【" + project.getOrgCode() + "】已存在");
        uiModel.addAttribute("project", project);
        return "projects/update";
    }
    File imgDir = filePathUtils.getLogoDir(project.getName());
    if (StringUtils.isNotEmpty(photoCodeImg)) {
        if (!photoCodeImg.contains(".jpg")) {
            File pic = filePathUtils.saveImg(imgDir, null, photoCodeImg, IMG_DEFAULT_TYPE, IMG_NAME_PJ);
            if (pic != null && pic.isFile()) {
                project.setLogo(pic.getName());
            // sq.setPic1Hash(HMACSHA1.genSha1HashOfFile(pic1));
            }
        } else {
            project.setLogo(project0.getLogo());
        }
    }
    sqlSession.update("com.itrus.portal.db.ProjectMapper.updateByPrimaryKey", project);
    String oper = "修改项目";
    String info = "项目名称: " + project.getName();
    LogUtil.adminlog(sqlSession, oper, info);
    cacheCustomer.initProjectMap();
    return "redirect:/projects/" + project.getId();
}
Also used : Project(com.itrus.portal.db.Project) File(java.io.File) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 47 with Project

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

the class ProjectKeyInfoController method update.

// 修改处理
@RequestMapping(method = RequestMethod.PUT, produces = "text/html")
public String update(@Valid ProjectKeyInfo projectkeyinfo, BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest) throws Exception {
    if (bindingResult.hasErrors()) {
        uiModel.addAttribute("projectkeyinfo", projectkeyinfo);
        return "projectkeyinfos/update";
    }
    ProjectKeyInfo projectkeyinfo0 = sqlSession.selectOne("com.itrus.portal.db.ProjectKeyInfoMapper.selectByPrimaryKey", projectkeyinfo.getId());
    // 检查是否有权限操作
    Long[] projects = getProjectLongIdsOfAdmin();
    List<Long> list = Arrays.asList(projects);
    if (list != null && !list.contains(projectkeyinfo.getProject())) {
        return "status403";
    }
    // 加密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);
    }
    // 加密adminPinValue信息
    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);
    }
    projectkeyinfo.setCreateTime(projectkeyinfo0.getCreateTime());
    sqlSession.update("com.itrus.portal.db.ProjectKeyInfoMapper.updateByPrimaryKey", 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();
    return "redirect:/projectkeyinfos";
}
Also used : Project(com.itrus.portal.db.Project) ProjectKeyInfo(com.itrus.portal.db.ProjectKeyInfo) SecretKeySpec(javax.crypto.spec.SecretKeySpec) IvParameterSpec(javax.crypto.spec.IvParameterSpec) Cipher(javax.crypto.Cipher) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 48 with Project

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

the class ProjectKeyInfoController method list.

// 列表所有信息
@RequestMapping(produces = "text/html")
public String list(@Valid ProjectKeyInfo projectkeyinfo, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, Model uiModel) {
    uiModel.addAttribute("project", projectkeyinfo.getProject());
    uiModel.addAttribute("sn1", projectkeyinfo.getSn1());
    // page,size
    if (page == null || page < 1)
        page = 1;
    if (size == null || size < 1)
        size = 10;
    ProjectKeyInfoExample projectkeyinfoex = new ProjectKeyInfoExample();
    ProjectKeyInfoExample.Criteria criteria = projectkeyinfoex.or();
    if (projectkeyinfo.getProject() != null && projectkeyinfo.getProject() > 0L)
        criteria.andProjectEqualTo(projectkeyinfo.getProject());
    if (projectkeyinfo.getSn1() != null && projectkeyinfo.getSn1().length() > 0)
        criteria.andSn1Like("%" + projectkeyinfo.getSn1() + "%");
    // 检查是否有权限操作
    Long[] projects = getProjectLongIdsOfAdmin();
    List<Long> list = Arrays.asList(projects);
    if (list != null) {
        criteria.andProjectIn(list);
    }
    // count,pages
    Integer count = sqlSession.selectOne("com.itrus.portal.db.ProjectKeyInfoMapper.countByExample", projectkeyinfoex);
    uiModel.addAttribute("count", count);
    uiModel.addAttribute("pages", (count + size - 1) / size);
    // page, size
    if (page > 1 && size * (page - 1) >= count) {
        page = (count + size - 1) / size;
    }
    uiModel.addAttribute("page", page);
    uiModel.addAttribute("size", size);
    // query data
    Integer offset = size * (page - 1);
    RowBounds rowBounds = new RowBounds(offset, size);
    List<ProjectKeyInfo> projectkeyinfoall = sqlSession.selectList("com.itrus.portal.db.ProjectKeyInfoMapper.selectByExample", projectkeyinfoex, rowBounds);
    uiModel.addAttribute("projectkeyinfos", projectkeyinfoall);
    // itemcount
    uiModel.addAttribute("itemcount", projectkeyinfoall.size());
    Map<Long, ProjectKeyInfo> projectkeyinfomap = sqlSession.selectMap("com.itrus.portal.db.ProjectKeyInfoMapper.selectByExample", projectkeyinfoex, "id");
    uiModel.addAttribute("projectkeyinfomap", projectkeyinfomap);
    Map<Long, Project> projectmap = getProjectMapOfAdmin();
    uiModel.addAttribute("projectmap", projectmap);
    uiModel.addAttribute("projects", projectmap.values());
    return "projectkeyinfos/list";
}
Also used : Project(com.itrus.portal.db.Project) ProjectKeyInfo(com.itrus.portal.db.ProjectKeyInfo) RowBounds(org.apache.ibatis.session.RowBounds) ProjectKeyInfoExample(com.itrus.portal.db.ProjectKeyInfoExample) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 49 with Project

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

the class CustomerServerClientController method onLineByJieSuoYiChang.

/**
 * 解锁异常的的客服在线
 * @param certSn
 * @param keySn
 * @param enterpriseName
 * @param session
 * @param uiModel
 * @return
 */
@RequestMapping("/onLineByJieSuoYiChang")
public String onLineByJieSuoYiChang(@RequestParam(value = "certSn", required = true) String certSn, @RequestParam(value = "keySn", required = true) String keySn, HttpSession session, Model uiModel) {
    UserCert userCert = userCertService.getUserCertByCertSn(certSn);
    if (null == userCert || null == userCert.getUserinfo()) {
        return ComNames.DENG_LU_CLIENT;
    }
    UserInfo userInfo = userInfoService.getUserInfoById(userCert.getUserinfo());
    // 先根据key序列号取项目,若没有,则根据用户所属项目取项目信息
    Project project = null;
    if (StringUtils.isNotBlank(keySn) && StringUtils.isNotBlank(certSn)) {
        ProjectKeyInfo projectKeyInfo = cacheCustomer.findProjectByKey(keySn);
        if (null == projectKeyInfo) {
            uiModel.addAttribute("errorMsg", "无法识别的key序列号:" + keySn + ", 请联系系统管理员进行配置");
            return ComNames.CLIENTFW_ERRORPAGE;
        }
        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) UserInfo(com.itrus.portal.db.UserInfo) UserCert(com.itrus.portal.db.UserCert) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 50 with Project

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

the class DoUnlockKeyController method sendCodeByZSJS.

/**
 * 发送解锁授权码
 * @param mphone
 * @return
 */
@RequestMapping("/sendCodeByZSJS")
@ResponseBody
public Map<String, Object> sendCodeByZSJS(@RequestParam("mPhone") String mPhone, @RequestParam("certSn") String certSn, @RequestParam("keySn") String keySn) {
    Map<String, Object> retMap = new HashMap<String, Object>();
    retMap.put("retCode", 0);
    Project project = null;
    try {
        // 根据key序列号,获取证书
        ProjectKeyInfo projectKeyInfo = cacheCustomer.findProjectByKey(keySn);
        if (null == projectKeyInfo) {
            retMap.put("retMsg", "无法识别该序列号:" + keySn + ", 请联系系统管理进行配置");
            return retMap;
        }
        project = projectService.selectByPrimaryKey(projectKeyInfo.getProject());
        UserInfo userInfo = userInfoService.getUserInfoByMphone(mPhone);
        if (null == userInfo) {
            retMap.put("retMsg", "手机号对应的用户不存在,请检查手机号是否正确:" + mPhone);
            return retMap;
        }
        // ZSJS表示短信模版类型为‘证书解锁’。
        if (dynamicCodeService.sendCodeZSJS(mPhone, project.getId(), "ZSJS")) {
            retMap.put("retCode", 1);
            return retMap;
        }
    } catch (UserInfoServiceException e) {
        retMap.put("retMsg", e.getMessage());
        return retMap;
    } catch (Exception e) {
        retMap.put("retMsg", "发送证书解锁短信出现异常,请联系系统管理员");
        UserLog userLog = new UserLog();
        userLog.setCreateTime(new Date());
        userLog.setHostId("未知");
        userLog.setInfo(e.getMessage());
        userLog.setIp("未知");
        userLog.setProject(project.getId());
        userLog.setSn(null);
        userLog.setType("发送证书解锁短信");
        return retMap;
    }
    retMap.put("retMsg", "发送证书解锁短信失败,请联系系统管理员");
    return retMap;
}
Also used : Project(com.itrus.portal.db.Project) HashMap(java.util.HashMap) ProjectKeyInfo(com.itrus.portal.db.ProjectKeyInfo) UserInfo(com.itrus.portal.db.UserInfo) UserLog(com.itrus.portal.db.UserLog) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) Date(java.util.Date) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

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