Search in sources :

Example 96 with GetMapping

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;
}
Also used : Comment(cc.ryanc.halo.model.domain.Comment) Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) HashMap(java.util.HashMap) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 97 with GetMapping

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;
}
Also used : Timer(io.micrometer.core.instrument.Timer) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 98 with GetMapping

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;
}
Also used : ArrayList(java.util.ArrayList) WorkDay(com.gwc.workday.entity.WorkDay) EventVO(com.gwc.workday.vo.EventVO) GetMapping(org.springframework.web.bind.annotation.GetMapping) ApiOperation(io.swagger.annotations.ApiOperation) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 99 with GetMapping

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;
}
Also used : Car(de.spring.webservices.domain.Car) ArrayList(java.util.ArrayList) GetMapping(org.springframework.web.bind.annotation.GetMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus)

Example 100 with GetMapping

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";
}
Also used : Authentication(org.springframework.security.core.Authentication) CookieClearingLogoutHandler(org.springframework.security.web.authentication.logout.CookieClearingLogoutHandler) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

GetMapping (org.springframework.web.bind.annotation.GetMapping)756 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)114 ResponseEntity (org.springframework.http.ResponseEntity)80 ArrayList (java.util.ArrayList)52 List (java.util.List)49 ModelAndView (org.springframework.web.servlet.ModelAndView)48 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)45 HttpHeaders (org.springframework.http.HttpHeaders)41 Map (java.util.Map)40 HashMap (java.util.HashMap)38 lombok.val (lombok.val)38 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)36 Grid (org.hisp.dhis.common.Grid)35 IOException (java.io.IOException)34 RequestParam (org.springframework.web.bind.annotation.RequestParam)34 ApiOperation (io.swagger.annotations.ApiOperation)31 RootNode (org.hisp.dhis.node.types.RootNode)31 PathVariable (org.springframework.web.bind.annotation.PathVariable)31 HttpServletRequest (javax.servlet.http.HttpServletRequest)30 FieldFilterParams (org.hisp.dhis.fieldfilter.FieldFilterParams)28