类org.springframework.web.bind.annotation.GetMapping源码实例Demo

下面列出了怎么用org.springframework.web.bind.annotation.GetMapping的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: spring-boot-study   文件: UserController.java
@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  "";
}
 
源代码2 项目: tutorials   文件: SleuthController.java
@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";
}
 
源代码3 项目: mall-learning   文件: HutoolController.java
@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, "操作成功");
}
 
源代码4 项目: foremast   文件: QueueController.java
@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";
}
 
@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));
}
 
源代码6 项目: scaffold-cloud   文件: SysMenuController.java
@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";
}
 
源代码7 项目: dhis2-core   文件: LocaleController.java
@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;
}
 
源代码8 项目: LuckyFrameWeb   文件: UserController.java
/**
 * 修改用户
 */
@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";
}
 
源代码9 项目: LuckyFrameWeb   文件: RoleController.java
/**
 * 新增数据权限
 */
@GetMapping("/rule/{roleId}")
public String rule(@PathVariable("roleId") Long roleId, ModelMap mmap)
{
    mmap.put("role", roleService.selectRoleById(roleId));
    return "system/role/rule";
}
 
源代码10 项目: apollo   文件: ConfigsExportController.java
@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);
  }
}
 
源代码11 项目: mall4j   文件: ProdController.java
@GetMapping("/moreBuyProdList")
@ApiOperation(value = "每日疯抢", notes = "获取销量最多的商品列表")
@ApiImplicitParams({})
public ResponseEntity<IPage<ProductDto>> moreBuyProdList(PageParam<ProductDto> page) {
    IPage<ProductDto> productDtoIPage = prodService.moreBuyProdList(page);
    return ResponseEntity.ok(productDtoIPage);
}
 
源代码12 项目: apollo   文件: CommitController.java
@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);
}
 
源代码13 项目: wingtips   文件: SampleController.java
@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;
}
 
/**
 * 获取设备组的压力概览
 *
 * @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);
}
 
源代码15 项目: soul   文件: OrderController.java
/**
 * 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;
}
 
@GetMapping
public String displayDiscountCodes(Model model) {
  
  Map<String, Integer> codes = discountProps.getCodes();
  model.addAttribute("codes", codes);
  
  return "discountList";
}
 
源代码17 项目: spring-guides   文件: FileUploadController.java
@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";
}
 
源代码18 项目: scoold   文件: AdminController.java
@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";
}
 
源代码19 项目: supplierShop   文件: SysJobController.java
@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";
}
 
源代码20 项目: springboot-plus   文件: FileSystemContorller.java
@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;
}
 
源代码21 项目: mayday   文件: CategoryController.java
/**
 * 跳转修改页面
 * 
 * @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";
}
 
源代码22 项目: mall   文件: AdminStatController.java
@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);
}
 
@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;
}
 
源代码24 项目: scoold   文件: PeopleController.java
@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";
}
 
@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;
}
 
源代码26 项目: retro-game   文件: AllianceController.java
@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";
}
 
@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());
}
 
源代码28 项目: api-boot   文件: BannerInfoController.java
/**
 * 查询全部轮播图
 *
 * @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();
}
 
源代码29 项目: springboot-plus   文件: CoreCodeGenController.java
@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;

}
 
@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());
    }
}
 
 类方法