use of cn.edu.zjnu.acm.judge.domain.Mail in project judge by zjnu-acm.
the class MailController method delete.
@GetMapping("/deletemail")
public String delete(@RequestParam("mail_id") long mailId, Authentication authentication) {
Mail mail = mailMapper.findOne(mailId);
if (mail == null) {
throw new MessageException("No such mail", HttpStatus.NOT_FOUND);
}
if (!UserDetailsServiceImpl.isUser(authentication, mail.getTo())) {
throw new MessageException("Sorry, invalid access", HttpStatus.FORBIDDEN);
}
mailMapper.delete(mailId);
return "redirect:/mail";
}
use of cn.edu.zjnu.acm.judge.domain.Mail in project judge by zjnu-acm.
the class MailController method sendPage.
@GetMapping({ "sendpage", "send" })
@SuppressWarnings("AssignmentToMethodParameter")
public String sendPage(Model model, @RequestParam(value = "reply", defaultValue = "-1") long reply, @RequestParam(value = "to", defaultValue = "") String userId) {
String title = "";
String content = "";
if (reply != -1) {
Mail parent = mailMapper.findOne(reply);
if (parent == null) {
throw new BusinessException(BusinessCode.MAIL_NOT_FOUND);
}
String toUser = parent.getTo();
if (!UserDetailsServiceImpl.isUser(toUser)) {
throw new BusinessException(BusinessCode.MAIL_INVALID_ACCESS);
}
userId = parent.getFrom();
title = parent.getTitle();
content = parent.getContent();
if (!title.regionMatches(true, 0, "re:", 0, 3)) {
title = "Re:" + title;
}
mailMapper.setReply(reply);
}
model.addAttribute("to", userId);
model.addAttribute("title", title);
model.addAttribute("content", JudgeUtils.INSTANCE.getReplyString(content));
return "mails/sendpage";
}
use of cn.edu.zjnu.acm.judge.domain.Mail in project judge by zjnu-acm.
the class MailController method showMail.
@GetMapping("/showmail")
public String showMail(Model model, @RequestParam("mail_id") long mailId, Authentication authentication) {
Mail mail = mailMapper.findOne(mailId);
if (mail == null) {
throw new MessageException("No such mail", HttpStatus.NOT_FOUND);
}
if (!UserDetailsServiceImpl.isUser(authentication, mail.getTo())) {
throw new MessageException("Sorry, invalid access", HttpStatus.FORBIDDEN);
}
mailMapper.readed(mailId);
model.addAttribute("mail", mail);
return "mails/view";
}
use of cn.edu.zjnu.acm.judge.domain.Mail in project judge by zjnu-acm.
the class MailController method sendPage.
@GetMapping({ "/sendpage", "/send" })
@SuppressWarnings("AssignmentToMethodParameter")
public String sendPage(Model model, @RequestParam(value = "reply", defaultValue = "-1") long reply, @RequestParam(value = "to", defaultValue = "") String userId, Authentication authentication) {
String title = "";
String content = "";
if (reply != -1) {
Mail parent = mailMapper.findOne(reply);
if (parent == null) {
throw new MessageException("No such mail", HttpStatus.NOT_FOUND);
}
String toUser = parent.getTo();
if (!UserDetailsServiceImpl.isUser(authentication, toUser)) {
throw new MessageException("invalid access", HttpStatus.FORBIDDEN);
}
userId = parent.getFrom();
title = parent.getTitle();
content = parent.getContent();
if (!title.regionMatches(true, 0, "re:", 0, 3)) {
title = "Re:" + title;
}
mailMapper.setReply(reply);
}
model.addAttribute("to", userId);
model.addAttribute("title", title);
model.addAttribute("content", JudgeUtils.getReplyString(content));
return "mails/sendpage";
}
use of cn.edu.zjnu.acm.judge.domain.Mail in project judge by zjnu-acm.
the class MailController method showMail.
@GetMapping("showmail")
public String showMail(Model model, @RequestParam("mail_id") long mailId) {
Mail mail = access(mailId);
mailMapper.readed(mailId);
model.addAttribute("mail", mail);
return "mails/view";
}
Aggregations