use of org.springframework.web.bind.annotation.GetMapping in project halo by ruibaby.
the class CommentController method moveToPublish.
/**
* 将评论改变为发布状态
*
* @param commentId commentId
* @param status status
* @return string
*/
@GetMapping("/revert")
public String moveToPublish(@PathParam("commentId") Long commentId, @PathParam("status") Integer status, HttpSession session) {
Comment comment = commentService.updateCommentStatus(commentId, 0);
// 判断评论者的邮箱是否符合规则
Pattern patternEmail = Pattern.compile("\\w[-\\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\\.)+[A-Za-z]{2,14}");
Matcher matcher = patternEmail.matcher(comment.getCommentAuthorEmail());
// 判断是否启用邮件服务
if ("true".equals(HaloConst.OPTIONS.get("smtp_email_enable")) && "true".equals(HaloConst.OPTIONS.get("comment_pass_notice"))) {
try {
if (status == 1 && matcher.find()) {
Map<String, Object> map = new HashMap<>();
map.put("pageUrl", comment.getPost().getPostUrl());
map.put("pageName", comment.getPost().getPostTitle());
map.put("commentContent", comment.getCommentContent());
map.put("siteUrl", HaloConst.OPTIONS.get("site_url"));
map.put("siteTitle", HaloConst.OPTIONS.get("site_title"));
map.put("author", userService.findUser().getUserDisplayName());
mailService.sendTemplateMail(comment.getCommentAuthorEmail(), "您在" + HaloConst.OPTIONS.get("site_title") + "的评论已审核通过!", map, "common/mail/mail_passed.ftl");
}
} catch (Exception e) {
log.error("邮件服务器未配置:" + e.getMessage());
}
}
this.getNewComments(session);
return "redirect:/admin/comments?status=" + status;
}
use of org.springframework.web.bind.annotation.GetMapping in project micrometer by micrometer-metrics.
the class PersonController method stats.
@GetMapping("/api/stats")
public Map<String, Number> stats() {
Timer t = registry.find("http.server.requests").tags("uri", "/api/people").timer();
Map<String, Number> result = null;
if (t != null) {
result = new HashMap<>();
result.put("count", t.count());
result.put("max", t.max(TimeUnit.MILLISECONDS));
result.put("mean", t.mean(TimeUnit.MILLISECONDS));
}
return result;
}
use of org.springframework.web.bind.annotation.GetMapping in project workday by peer44.
the class HolidayController method init.
@ApiOperation(value = "加载节假日")
@GetMapping(value = "holiday/init")
@ResponseBody
public List<EventVO> init() {
List<WorkDay> workDays = workDayService.findAllHolidays();
List<EventVO> events = new ArrayList<>();
if (!CollectionUtils.isEmpty(workDays)) {
workDays.forEach(workDay -> {
EventVO event = new EventVO(workDay.getDate());
events.add(event);
});
}
return events;
}
use of org.springframework.web.bind.annotation.GetMapping in project JavaForFun by gumartinm.
the class CarController method cars.
@GetMapping(produces = { MediaType.APPLICATION_JSON_UTF8_VALUE })
@ResponseStatus(HttpStatus.OK)
public List<Car> cars() {
final List<Car> cars = new ArrayList<>();
cars.add(new Car(counter.incrementAndGet(), String.format(TEMPLATE, 1)));
cars.add(new Car(counter.incrementAndGet(), String.format(TEMPLATE, 2)));
cars.add(new Car(counter.incrementAndGet(), String.format(TEMPLATE, 3)));
return cars;
}
use of org.springframework.web.bind.annotation.GetMapping in project tutorials by eugenp.
the class AuthController method logout.
@GetMapping("/logout")
public String logout(HttpServletRequest request, HttpServletResponse response, SecurityContextLogoutHandler logoutHandler) {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
logoutHandler.logout(request, response, auth);
new CookieClearingLogoutHandler(AbstractRememberMeServices.SPRING_SECURITY_REMEMBER_ME_COOKIE_KEY).logout(request, response, auth);
return "auth/logout";
}
Aggregations