Search in sources :

Example 66 with GetMapping

use of org.springframework.web.bind.annotation.GetMapping in project judge by zjnu-acm.

the class ModifyUserController method updatePage.

@GetMapping({ "/modifyuserpage", "/modifyuser" })
public String updatePage(Model model, Authentication authentication) {
    String userId = authentication != null ? authentication.getName() : null;
    User user = accountService.findOne(userId);
    model.addAttribute("user", user);
    return "users/edit";
}
Also used : User(cn.edu.zjnu.acm.judge.domain.User) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 67 with GetMapping

use of org.springframework.web.bind.annotation.GetMapping in project judge by zjnu-acm.

the class SearchUserController method searchuser.

@GetMapping("/searchuser")
public String searchuser(Model model, @RequestParam(value = "user_id", defaultValue = "") String keyword, @RequestParam(value = "position", required = false) String position, @PageableDefault(1000) Pageable pageable) {
    if (keyword.replace("%", "").length() < 2) {
        throw new BusinessException(BusinessCode.USER_SEARCH_KEYWORD_SHORT);
    }
    String like = keyword;
    if (position == null) {
        like = "%" + like + "%";
    } else if (position.equalsIgnoreCase("begin")) {
        like += "%";
    } else {
        like = "%" + like;
    }
    Pageable t = pageable;
    if (t.getSort() == null) {
        t = new PageRequest(pageable.getPageNumber(), pageable.getPageSize(), new Sort(new Sort.Order("solved").with(Sort.Direction.DESC), new Sort.Order("submit")));
    }
    Page<User> users = accountService.findAll(AccountForm.builder().disabled(Boolean.FALSE).query(like).build(), t);
    model.addAttribute("query", keyword);
    model.addAttribute("users", users);
    return "users/search";
}
Also used : BusinessException(cn.edu.zjnu.acm.judge.exception.BusinessException) PageRequest(org.springframework.data.domain.PageRequest) Pageable(org.springframework.data.domain.Pageable) User(cn.edu.zjnu.acm.judge.domain.User) Sort(org.springframework.data.domain.Sort) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 68 with GetMapping

use of org.springframework.web.bind.annotation.GetMapping in project incubator-servicecomb-java-chassis by apache.

the class GetMappingMethodAnnotationProcessor method process.

@Override
public void process(Object annotation, OperationGenerator operationGenerator) {
    GetMapping mappingAnnotation = (GetMapping) annotation;
    Operation operation = operationGenerator.getOperation();
    // path/value是等同的
    this.processPath(mappingAnnotation.path(), operationGenerator);
    this.processPath(mappingAnnotation.value(), operationGenerator);
    this.processMethod(RequestMethod.GET, operationGenerator);
    this.processConsumes(mappingAnnotation.consumes(), operation);
    this.processProduces(mappingAnnotation.produces(), operation);
    if (StringUtils.isEmpty(operationGenerator.getHttpMethod()) && StringUtils.isEmpty(operationGenerator.getSwaggerGenerator().getHttpMethod())) {
        throw new Error("HttpMethod must not both be empty in class and method");
    }
}
Also used : GetMapping(org.springframework.web.bind.annotation.GetMapping) Operation(io.swagger.models.Operation)

Example 69 with GetMapping

use of org.springframework.web.bind.annotation.GetMapping in project jhipster-registry by jhipster.

the class EurekaResource method lastn.

/**
 * GET  /eureka/lastn : get Eureka registrations
 */
@GetMapping("/eureka/lastn")
@Timed
public ResponseEntity<Map<String, Map<Long, String>>> lastn() {
    Map<String, Map<Long, String>> lastn = new HashMap<>();
    PeerAwareInstanceRegistryImpl registry = (PeerAwareInstanceRegistryImpl) getRegistry();
    Map<Long, String> canceledMap = new HashMap<>();
    registry.getLastNCanceledInstances().forEach(canceledInstance -> {
        canceledMap.put(canceledInstance.first(), canceledInstance.second());
    });
    lastn.put("canceled", canceledMap);
    Map<Long, String> registeredMap = new HashMap<>();
    registry.getLastNRegisteredInstances().forEach(registeredInstance -> {
        registeredMap.put(registeredInstance.first(), registeredInstance.second());
    });
    lastn.put("registered", registeredMap);
    return new ResponseEntity<>(lastn, HttpStatus.OK);
}
Also used : PeerAwareInstanceRegistryImpl(com.netflix.eureka.registry.PeerAwareInstanceRegistryImpl) ResponseEntity(org.springframework.http.ResponseEntity) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) GetMapping(org.springframework.web.bind.annotation.GetMapping) Timed(com.codahale.metrics.annotation.Timed)

Example 70 with GetMapping

use of org.springframework.web.bind.annotation.GetMapping in project jhipster-registry by jhipster.

the class EurekaResource method eureka.

/**
 * GET  /eureka/applications : get Eureka applications information
 */
@GetMapping("/eureka/applications")
@Timed
public ResponseEntity<EurekaVM> eureka() {
    EurekaVM eurekaVM = new EurekaVM();
    eurekaVM.setApplications(getApplications());
    return new ResponseEntity<>(eurekaVM, HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) EurekaVM(io.github.jhipster.registry.web.rest.vm.EurekaVM) GetMapping(org.springframework.web.bind.annotation.GetMapping) Timed(com.codahale.metrics.annotation.Timed)

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