org.springframework.web.bind.annotation.GetMapping Java Examples

The following examples show how to use org.springframework.web.bind.annotation.GetMapping. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: spring-boot-study   Author: fishpro   File: UserController.java    License: MIT License 6 votes vote down vote up
@GetMapping("/test")
public String testCache(){
    System.out.println("============以下第一次调用 ================");
    userService.list();
    userService.get(1);
    userService.save(new UserDO(1,"fishpro","123456",1));
    userService.update(new UserDO(1,"fishpro","123456434",1));

    System.out.println("============以下第二次调用 观察 list 和 get 方法 ================");

    userService.list();
    userService.get(1);
    userService.save(new UserDO(1,"fishpro","123456",1));
    userService.update(new UserDO(1,"fishpro","123456434",1));


    System.out.println("============以下第三次调用 先删除 观察 list 和 get 方法 ================");
    userService.delete(1);
    userService.list();
    userService.get(1);
    userService.save(new UserDO(1,"fishpro","123456",1));
    userService.update(new UserDO(1,"fishpro","123456434",1));
    return  "";
}
 
Example #2
Source Project: tutorials   Author: eugenp   File: SleuthController.java    License: MIT License 6 votes vote down vote up
@GetMapping("/new-thread")
public String helloSleuthNewThread() {
    logger.info("New Thread");
    Runnable runnable = () -> {
        try {
            Thread.sleep(1000L);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        logger.info("I'm inside the new thread - with a new span");
    };
    executor.execute(runnable);

    logger.info("I'm done - with the original span");
    return "success";
}
 
Example #3
Source Project: mall-learning   Author: macrozheng   File: HutoolController.java    License: Apache License 2.0 6 votes vote down vote up
@ApiOperation("CollUtil使用:集合工具类")
@GetMapping("/collUtil")
public CommonResult collUtil() {
    //数组转换为列表
    String[] array = new String[]{"a", "b", "c", "d", "e"};
    List<String> list = CollUtil.newArrayList(array);
    //join:数组转字符串时添加连接符号
    String joinStr = CollUtil.join(list, ",");
    LOGGER.info("collUtil join:{}", joinStr);
    //将以连接符号分隔的字符串再转换为列表
    List<String> splitList = StrUtil.split(joinStr, ',');
    LOGGER.info("collUtil split:{}", splitList);
    //创建新的Map、Set、List
    HashMap<Object, Object> newMap = CollUtil.newHashMap();
    HashSet<Object> newHashSet = CollUtil.newHashSet();
    ArrayList<Object> newList = CollUtil.newArrayList();
    //判断列表是否为空
    CollUtil.isEmpty(list);
    CollUtil.isNotEmpty(list);
    return CommonResult.success(null, "操作成功");
}
 
Example #4
Source Project: foremast   Author: intuit   File: QueueController.java    License: Apache License 2.0 6 votes vote down vote up
@GetMapping("/load")
public String load(@RequestParam("latency") float latency, @RequestParam("errorRate") float errorRate, HttpServletResponse response) throws IOException {
    float error = errorRate * 100;
    if (error > 0.1) {
        int r = random.nextInt(1000);
        if (r < error * 10) {
            response.sendError(501, "Internal error");
            return "Error";
        }
    }

    if (latency <= 0) {
        latency = 10;
    }
    try {
        Thread.sleep((int)latency);
    }
    catch(Exception ex) {
    }
    return "OK";
}
 
Example #5
Source Project: wingtips   Author: Nike-Inc   File: WingtipsSpringWebfluxComponentTest.java    License: Apache License 2.0 6 votes vote down vote up
@GetMapping(FLUX_ENDPOINT_PATH)
@ResponseBody
Flux<String> fluxEndpoint(ServerHttpRequest request) {
    HttpHeaders headers = request.getHeaders();

    if ("true".equals(headers.getFirst("throw-exception"))) {
        sleepThread(SLEEP_TIME_MILLIS);
        throw new RuntimeException("Error thrown in fluxEndpoint(), outside Flux");
    }

    if ("true".equals(headers.getFirst("return-exception-in-flux"))) {
        return Flux.just("foo")
                   .delayElements(Duration.ofMillis(SLEEP_TIME_MILLIS))
                   .map(d -> {
                       throw new RuntimeException("Error thrown in fluxEndpoint(), inside Flux");
                   });
    }

    long delayPerElementMillis = SLEEP_TIME_MILLIS / FLUX_ENDPOINT_PAYLOAD.size();
    return Flux.fromIterable(FLUX_ENDPOINT_PAYLOAD).delayElements(Duration.ofMillis(delayPerElementMillis));
}
 
Example #6
Source Project: scaffold-cloud   Author: Fatezhang   File: SysMenuController.java    License: MIT License 5 votes vote down vote up
@GetMapping("/sysMenuEdit")
public String SysMenuEdit(Model model, SysMenuAO sysMenu) {
    SysMenuResp sysMenuResp;
    if (null == sysMenu.getId()) {
        sysMenuResp = Builder.build(sysMenu, SysMenuResp.class);
    } else {
        ResponseModel<SysMenuBO> resp = sysMenuFeign.selectById(sysMenu.getId());
        sysMenuResp = Builder.build(resp.getData(), SysMenuResp.class);
    }
    model.addAttribute("sysMenu", sysMenuResp);
    return ftlPath + "sysMenuEdit";
}
 
Example #7
Source Project: dhis2-core   Author: dhis2   File: LocaleController.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@GetMapping( value = "/ui" )
public @ResponseBody List<WebLocale> getUiLocales( Model model )
{
    List<Locale> locales = localeManager.getAvailableLocales();
    List<WebLocale> webLocales = locales.stream().map( WebLocale::fromLocale ).collect( Collectors.toList() );

    return webLocales;
}
 
Example #8
Source Project: LuckyFrameWeb   Author: seagull1985   File: UserController.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * 修改用户
 */
@GetMapping("/edit/{userId}")
public String edit(@PathVariable("userId") Long userId, ModelMap mmap)
{
    mmap.put("user", userService.selectUserById(userId));
    mmap.put("roles", roleService.selectRolesByUserId(userId));
    mmap.put("posts", postService.selectPostsByUserId(userId));
    mmap.put("projects", projectService.selectProjectAll(0));
    return "system/user/edit";
}
 
Example #9
Source Project: LuckyFrameWeb   Author: seagull1985   File: RoleController.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * 新增数据权限
 */
@GetMapping("/rule/{roleId}")
public String rule(@PathVariable("roleId") Long roleId, ModelMap mmap)
{
    mmap.put("role", roleService.selectRoleById(roleId));
    return "system/role/rule";
}
 
Example #10
Source Project: apollo   Author: ctripcorp   File: ConfigsExportController.java    License: Apache License 2.0 5 votes vote down vote up
@GetMapping("/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/items/export")
public void exportItems(@PathVariable String appId, @PathVariable String env,
    @PathVariable String clusterName, @PathVariable String namespaceName,
    HttpServletResponse res) {
  List<String> fileNameSplit = Splitter.on(".").splitToList(namespaceName);

  String fileName = fileNameSplit.size() <= 1 ? Joiner.on(".")
      .join(namespaceName, ConfigFileFormat.Properties.getValue()) : namespaceName;
  NamespaceBO namespaceBO = namespaceService.loadNamespaceBO(appId, Env.fromString
      (env), clusterName, namespaceName);

  //generate a file.
  res.setHeader("Content-Disposition", "attachment;filename=" + fileName);

  List<String> fileItems = namespaceBO.getItems().stream().map(itemBO -> {
    String key = itemBO.getItem().getKey();
    String value = itemBO.getItem().getValue();
    if (ConfigConsts.CONFIG_FILE_CONTENT_KEY.equals(key)) {
      return value;
    }

    if ("".equals(key)) {
      return Joiner.on("").join(itemBO.getItem().getKey(), itemBO.getItem().getValue());
    }

    return Joiner.on(" = ").join(itemBO.getItem().getKey(), itemBO.getItem().getValue());
  }).collect(Collectors.toList());

  try {
    ConfigToFileUtils.itemsToFile(res.getOutputStream(), fileItems);
  } catch (Exception e) {
    throw new ServiceException("export items failed:{}", e);
  }
}
 
Example #11
Source Project: mall4j   Author: gz-yami   File: ProdController.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
@GetMapping("/moreBuyProdList")
@ApiOperation(value = "每日疯抢", notes = "获取销量最多的商品列表")
@ApiImplicitParams({})
public ResponseEntity<IPage<ProductDto>> moreBuyProdList(PageParam<ProductDto> page) {
    IPage<ProductDto> productDtoIPage = prodService.moreBuyProdList(page);
    return ResponseEntity.ok(productDtoIPage);
}
 
Example #12
Source Project: apollo   Author: ctripcorp   File: CommitController.java    License: Apache License 2.0 5 votes vote down vote up
@GetMapping("/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/commits")
public List<CommitDTO> find(@PathVariable String appId, @PathVariable String env,
                            @PathVariable String clusterName, @PathVariable String namespaceName,
                            @Valid @PositiveOrZero(message = "page should be positive or 0") @RequestParam(defaultValue = "0") int page,
                            @Valid @Positive(message = "size should be positive number") @RequestParam(defaultValue = "10") int size) {
  if (permissionValidator.shouldHideConfigToCurrentUser(appId, env, namespaceName)) {
    return Collections.emptyList();
  }

  return commitService.find(appId, Env.valueOf(env), clusterName, namespaceName, page, size);
}
 
Example #13
Source Project: wingtips   Author: Nike-Inc   File: SampleController.java    License: Apache License 2.0 5 votes vote down vote up
@GetMapping(path = ASYNC_ERROR_PATH)
@SuppressWarnings("unused")
public DeferredResult<String> getAsyncError() {
    logger.info("Async error endpoint hit");

    sleepThread(SLEEP_TIME_MILLIS);

    DeferredResult<String> deferredResult = new DeferredResult<>();
    deferredResult.setErrorResult(new RuntimeException("Intentional exception by asyncError endpoint"));

    return deferredResult;
}
 
Example #14
Source Project: ClusterDeviceControlPlatform   Author: bitkylin   File: DataProcessController.java    License: MIT License 5 votes vote down vote up
/**
 * 获取设备组的压力概览
 *
 * @return 返回消息对象
 */
@GetMapping("/pressure")
public ResMsg getDeviceGroupPressure() {
    logger.info("/server/dataprocess/devicegroup/pressure");
    GroupCacheItem item = null;
    item = GroupCacheItem.randomInstance();

    item.setAlarmLimit(100, 500);
    return new ResMsg(item);
}
 
Example #15
Source Project: soul   Author: Dromara   File: OrderController.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Find by id order dto.
 *
 * @param id the id
 * @return the order dto
 */
@GetMapping("/findById")
@SoulSpringCloudClient(path = "/findById")
public OrderDTO findById(@RequestParam("id") final String id) {
    OrderDTO orderDTO = new OrderDTO();
    orderDTO.setId(id);
    orderDTO.setName("hello world spring cloud findById");
    return orderDTO;
}
 
Example #16
Source Project: spring-in-action-5-samples   Author: habuma   File: DiscountController.java    License: Apache License 2.0 5 votes vote down vote up
@GetMapping
public String displayDiscountCodes(Model model) {
  
  Map<String, Integer> codes = discountProps.getCodes();
  model.addAttribute("codes", codes);
  
  return "discountList";
}
 
Example #17
Source Project: spring-guides   Author: Hanope   File: FileUploadController.java    License: Apache License 2.0 5 votes vote down vote up
@GetMapping("/")
public String listUploadedFiles(Model model) throws IOException {

    model.addAttribute("files", storageService.loadAll().map(
            path -> MvcUriComponentsBuilder.fromMethodName(FileUploadController.class,
                    "serveFile", path.getFileName().toString()).build().toString())
            .collect(Collectors.toList()));

    return "uploadForm";
}
 
Example #18
Source Project: scoold   Author: Erudika   File: AdminController.java    License: Apache License 2.0 5 votes vote down vote up
@GetMapping
public String get(HttpServletRequest req, Model model) {
	if (!utils.isAuthenticated(req) || !utils.isAdmin(utils.getAuthUser(req))) {
		return "redirect:" + ADMINLINK;
	}
	Map<String, Object> configMap = new LinkedHashMap<String, Object>();
	for (Map.Entry<String, ConfigValue> entry : Config.getConfig().entrySet()) {
		ConfigValue value = entry.getValue();
		configMap.put(entry.getKey(), value != null ? value.unwrapped() : "-");
	}
	configMap.putAll(System.getenv());

	Pager itemcount = utils.getPager("page", req);
	Pager itemcount1 = utils.getPager("page1", req);
	itemcount.setLimit(40);
	model.addAttribute("path", "admin.vm");
	model.addAttribute("title", utils.getLang(req).get("administration.title"));
	model.addAttribute("configMap", configMap);
	model.addAttribute("version", pc.getServerVersion());
	model.addAttribute("endpoint", pc.getEndpoint());
	model.addAttribute("paraapp", Config.getConfigParam("access_key", "x"));
	model.addAttribute("spaces", pc.findQuery("scooldspace", "*", itemcount));
	model.addAttribute("webhooks", pc.findQuery(Utils.type(Webhook.class), "*", itemcount1));
	model.addAttribute("scooldimports", pc.findQuery("scooldimport", "*", new Pager(7)));
	model.addAttribute("coreScooldTypes", utils.getCoreScooldTypes());
	model.addAttribute("customHookEvents", utils.getCustomHookEvents());
	model.addAttribute("apiKeys", utils.getApiKeys());
	model.addAttribute("apiKeysExpirations", utils.getApiKeysExpirations());
	model.addAttribute("itemcount", itemcount);
	model.addAttribute("itemcount1", itemcount1);
	model.addAttribute("isDefaultSpacePublic", utils.isDefaultSpacePublic());
	model.addAttribute("scooldVersion", Optional.ofNullable(scooldVersion).orElse("unknown"));
	Sysprop theme = utils.getCustomTheme();
	String themeCSS = (String) theme.getProperty("theme");
	model.addAttribute("selectedTheme", theme.getName());
	model.addAttribute("customTheme", StringUtils.isBlank(themeCSS) ? utils.getDefaultTheme() : themeCSS);
	return "base";
}
 
Example #19
Source Project: supplierShop   Author: guchengwuyue   File: SysJobController.java    License: MIT License 5 votes vote down vote up
@RequiresPermissions("monitor:job:detail")
@GetMapping("/detail/{jobId}")
public String detail(@PathVariable("jobId") Long jobId, ModelMap mmap)
{
    mmap.put("name", "job");
    mmap.put("job", jobService.selectJobById(jobId));
    return prefix + "/detail";
}
 
Example #20
Source Project: springboot-plus   Author: hdhong   File: FileSystemContorller.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@GetMapping(MODEL + "/download/{fileId}/{batchFileUUID}/{name}")
public ModelAndView download(HttpServletResponse response,@PathVariable Long fileId,@PathVariable  String batchFileUUID ) throws IOException {
    FileItem item = fileService.getFileItemById(fileId,batchFileUUID);
    response.setHeader("Content-Disposition", "attachment; filename="+item.getName());  
    item.copy(response.getOutputStream());
    return null;
}
 
Example #21
Source Project: mayday   Author: gujiniCY   File: CategoryController.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * 跳转修改页面
 * 
 * @param model
 * @param categoryId
 * @return
 */
@GetMapping(value = "/edit")
public String updateCategory(Model model, @RequestParam(value = "categoryId") int categoryId) {
	try {
		Category category = categoryService.findByCategoryId(categoryId);
		List<Category> categorys = categoryService.findCategory();
		model.addAttribute("Categorys", categorys);
		model.addAttribute("category", category);
	} catch (Exception e) {
		log.error(e.getMessage());
	}
	return "admin/admin_category";
}
 
Example #22
Source Project: mall   Author: bigspiders   File: AdminStatController.java    License: MIT License 5 votes vote down vote up
@RequiresPermissions("admin:stat:user")
@RequiresPermissionsDesc(menu={"统计管理" , "用户统计"}, button="查询")
@GetMapping("/user")
public Object statUser() {
    List<Map> rows = statService.statUser();
    String[] columns = new String[]{"day", "users"};
    StatVo statVo = new StatVo();
    statVo.setColumns(columns);
    statVo.setRows(rows);
    return ResponseUtil.ok(statVo);
}
 
Example #23
Source Project: Hands-On-RESTful-API-Design-Patterns-and-Best-Practices   Author: PacktPublishing   File: InvestorController.java    License: MIT License 5 votes vote down vote up
@GetMapping("/investors/{investorId}")
public Investor fetchInvestorById(@PathVariable String investorId) {
	Investor resultantInvestor = investorService.fetchInvestorById(investorId);
	if (resultantInvestor == null) {
		throw new InvestorNotFoundException("Investor Id-" + investorId);
	}
	return resultantInvestor;
}
 
Example #24
Source Project: scoold   Author: Erudika   File: PeopleController.java    License: Apache License 2.0 5 votes vote down vote up
@GetMapping
public String get(@RequestParam(required = false, defaultValue = Config._TIMESTAMP) String sortby,
		@RequestParam(required = false, defaultValue = "*") String q, HttpServletRequest req, Model model) {
	if (!utils.isDefaultSpacePublic() && !utils.isAuthenticated(req)) {
		return "redirect:" + SIGNINLINK + "?returnto=" + PEOPLELINK;
	}
	Profile authUser = utils.getAuthUser(req);
	Pager itemcount = utils.getPager("page", req);
	itemcount.setSortby(sortby);
	// [space query filter] + original query string
	String qs = utils.sanitizeQueryString(q, req);
	if (req.getParameter("bulkedit") != null && utils.isAdmin(authUser)) {
		qs = q;
	} else {
		qs = qs.replaceAll("properties\\.space:", "properties.spaces:");
	}

	List<Profile> userlist = utils.getParaClient().findQuery(Utils.type(Profile.class), qs, itemcount);
	model.addAttribute("path", "people.vm");
	model.addAttribute("title", utils.getLang(req).get("people.title"));
	model.addAttribute("peopleSelected", "navbtn-hover");
	model.addAttribute("itemcount", itemcount);
	model.addAttribute("userlist", userlist);
	if (req.getParameter("bulkedit") != null && utils.isAdmin(authUser)) {
		List<ParaObject> spaces = utils.getParaClient().findQuery("scooldspace", "*", new Pager(Config.DEFAULT_LIMIT));
		model.addAttribute("spaces", spaces);
	}
	return "base";
}
 
Example #25
Source Project: Hands-On-RESTful-API-Design-Patterns-and-Best-Practices   Author: PacktPublishing   File: InvestorController.java    License: MIT License 5 votes vote down vote up
@GetMapping("/investors/{investorId}")
public Investor fetchInvestorById(@PathVariable String investorId) {
	Investor resultantInvestor = investorService.fetchInvestorById(investorId);
	if (resultantInvestor == null) {
		throw new InvestorNotFoundException("Investor Id-" + investorId);
	}
	return resultantInvestor;
}
 
Example #26
Source Project: retro-game   Author: retro-game   File: AllianceController.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
@GetMapping("/alliance/manage/text")
@PreAuthorize("hasPermission(#bodyId, 'ACCESS')")
@Activity(bodies = "#bodyId")
public String manageText(@RequestParam(name = "body") long bodyId,
                         @RequestParam(name = "alliance") long allianceId,
                         @RequestParam @NotNull AllianceTextKindDto kind,
                         Model model) {
  model.addAttribute("bodyId", bodyId);
  model.addAttribute("allianceId", allianceId);
  model.addAttribute("kind", kind);
  String text = allianceService.getText(bodyId, allianceId, kind);
  model.addAttribute("text", text);
  return "alliance-manage-text";
}
 
Example #27
Source Project: metasfresh-webui-api-legacy   Author: metasfresh   File: LetterRestController.java    License: GNU General Public License v3.0 5 votes vote down vote up
@GetMapping("/templates")
@ApiOperation("Available Email templates")
public JSONLookupValuesList getTemplates()
{
	return MADBoilerPlate.getAll(Env.getCtx())
			.stream()
			.map(adBoilerPlate -> JSONLookupValue.of(adBoilerPlate.getAD_BoilerPlate_ID(), adBoilerPlate.getName()))
			.collect(JSONLookupValuesList.collect());
}
 
Example #28
Source Project: api-boot   Author: minbox-projects   File: BannerInfoController.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 查询全部轮播图
 *
 * @return
 * @throws KnowledgeException
 */
@GetMapping(value = "/")
@ApiOperation(value = "查询文章专题列表", response = ArticleTopicInfoDTO.class)
@ApiResponse(code = 200, message = "查询成功", response = ArticleTopicInfoDTO.class)
public ApiBootResult getAllBanner()
        throws KnowledgeException {
    return ApiBootResult.builder().data(bannerInfoService.selectAllBanner()).build();
}
 
Example #29
Source Project: springboot-plus   Author: hdhong   File: CoreCodeGenController.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@GetMapping(MODEL + "/tableDetail.do")
public ModelAndView tableDetail(String table) {
	ModelAndView view = new ModelAndView("/core/codeGen/edit.html");
	Entity entity = codeGenService.getEntityInfo(table);
	view.addObject("entity", entity);
	return view;

}
 
Example #30
Source Project: flowable-engine   Author: flowable   File: DecisionTableClientResource.java    License: Apache License 2.0 5 votes vote down vote up
@GetMapping(value = "/rest/admin/decision-tables/{decisionTableId}", produces = "application/json")
public JsonNode getDecisionTable(@PathVariable String decisionTableId) throws BadRequestException {

    ServerConfig serverConfig = retrieveServerConfig(EndpointType.DMN);
    try {
        return clientService.getDecisionTable(serverConfig, decisionTableId);
    } catch (FlowableServiceException e) {
        LOGGER.error("Error getting decision table {}", decisionTableId, e);
        throw new BadRequestException(e.getMessage());
    }
}