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();
}
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";
}
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;
}
}
Aggregations