Search in sources :

Example 6 with MailTemplate

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

the class MailTemplateController method update.

// 处理修改消息模版
@RequestMapping(method = RequestMethod.PUT, produces = "text/html")
public String update(@Valid MailTemplate mailTemplate, BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest) {
    if (bindingResult.hasErrors()) {
        uiModel.addAttribute("projectmap", getProjectMapOfAdmin());
        uiModel.addAttribute("mailTemplate", mailTemplate);
        return "mailtemplate/update";
    }
    MailTemplate mailTemplate0 = sqlSession.selectOne("com.itrus.portal.db.MailTemplateMapper.selectByPrimaryKey", mailTemplate.getId());
    mailTemplate.setCreateTime(mailTemplate0.getCreateTime());
    // 一个项目下只能创建一个模版类型的消息模版
    MailTemplateExample mte = new MailTemplateExample();
    MailTemplateExample.Criteria mtCriteria = mte.or();
    mtCriteria.andProjectNameEqualTo(mailTemplate.getProjectName());
    mtCriteria.andTypeEqualTo(mailTemplate.getType());
    Integer count = sqlSession.selectOne("com.itrus.portal.db.MailTemplateMapper.countByExample", mte);
    if ((mailTemplate0.getProjectName() == mailTemplate.getProjectName()) && count >= 2) {
        uiModel.addAttribute("projectMap", getProjectMapOfAdmin());
        uiModel.addAttribute("mailTemplate", mailTemplate);
        uiModel.addAttribute("message", "该项目下已经存在同样类型的模版消息");
        return "mailtemplate/update";
    }
    if ((mailTemplate0.getProjectName() != mailTemplate.getProjectName()) && count != 0) {
        uiModel.addAttribute("projectMap", getProjectMapOfAdmin());
        uiModel.addAttribute("mailTemplate", mailTemplate);
        uiModel.addAttribute("message", "该项目下已经存在同样类型的模版消息");
        return "mailtemplate/update";
    }
    // String adminProject = getRoleProjects();
    // if (adminProject != null
    // && (!adminProject.equals(msgTemplate0.getProject()) || !adminProject
    // .equals(msgTemplate.getProject()))) {
    // return "status403";
    // }
    sqlSession.update("com.itrus.portal.db.MailTemplateMapper.updateByPrimaryKey", mailTemplate);
    String oper = "修改消息模版";
    String info = "消息模板内容: " + mailTemplate.getContent();
    LogUtil.adminlog(sqlSession, oper, info);
    return "redirect:/mailtemplate/" + mailTemplate.getId();
}
Also used : MailTemplate(com.itrus.portal.db.MailTemplate) MailTemplateExample(com.itrus.portal.db.MailTemplateExample) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 7 with MailTemplate

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

the class MailTemplateController method updateForm.

// 修改消息模版页面
@RequestMapping(value = "/{id}", params = "form", produces = "text/html")
public String updateForm(@PathVariable("id") Long id, Model uiModel) {
    MailTemplate mailTemplate = sqlSession.selectOne("com.itrus.portal.db.MailTemplateMapper.selectByPrimaryKey", id);
    if (mailTemplate == null) {
        return "status403";
    }
    String adminProject = getRoleProjects();
    if (adminProject != null && adminProject.equals(mailTemplate.getProjectName())) {
        return "status403";
    }
    uiModel.addAttribute("projectMap", getProjectMapOfAdmin());
    uiModel.addAttribute("mailTemplate", mailTemplate);
    return "mailtemplate/update";
}
Also used : MailTemplate(com.itrus.portal.db.MailTemplate) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 8 with MailTemplate

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

the class MailTemplateServiceImpl method getMailTemplatesByProjectIdAndType.

public MailTemplate getMailTemplatesByProjectIdAndType(Long projectId, String type) {
    List<MailTemplate> mailTemplates = new ArrayList<>();
    MailTemplateExample mailTemplateExample = new MailTemplateExample();
    MailTemplateExample.Criteria criteria = mailTemplateExample.or();
    // 如果projectid =0 则表示模版通用所有的项目
    List<Long> list = new ArrayList<>();
    list.add(0L);
    if (null != projectId) {
        list.add(projectId);
    }
    criteria.andProjectNameIn(list);
    criteria.andTypeEqualTo(type);
    mailTemplates = sqlsession.selectList("com.itrus.portal.db.MailTemplateMapper.selectByExample", mailTemplateExample);
    if (null != mailTemplates && !mailTemplates.isEmpty()) {
        return mailTemplates.get(0);
    } else {
        return null;
    }
}
Also used : MailTemplate(com.itrus.portal.db.MailTemplate) ArrayList(java.util.ArrayList) MailTemplateExample(com.itrus.portal.db.MailTemplateExample)

Aggregations

MailTemplate (com.itrus.portal.db.MailTemplate)8 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 MailTemplateExample (com.itrus.portal.db.MailTemplateExample)4 Project (com.itrus.portal.db.Project)2 ArrayList (java.util.ArrayList)2 Bwdjrecord (com.itrus.portal.db.Bwdjrecord)1 Enterprise (com.itrus.portal.db.Enterprise)1 ExtraProduct (com.itrus.portal.db.ExtraProduct)1 UserInfo (com.itrus.portal.db.UserInfo)1 File (java.io.File)1 HashMap (java.util.HashMap)1