gpt4 book ai didi

io.kaif.service.ZoneService类的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 10:56:01 33 4
gpt4 key购买 nike

本文整理了Java中io.kaif.service.ZoneService类的一些代码示例,展示了ZoneService类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZoneService类的具体详情如下:
包路径:io.kaif.service.ZoneService
类名称:ZoneService

ZoneService介绍

暂无

代码示例

代码示例来源:origin: kaif-open/kaif

@RequestMapping(value = "/can-create", method = RequestMethod.GET)
public SingleWrapper<Boolean> canCreateZone(AccountAccessToken token) {
 return SingleWrapper.of(zoneService.canCreateZone(token));
}

代码示例来源:origin: kaif-open/kaif

@RequestMapping(value = "/", method = RequestMethod.PUT, consumes = {
  MediaType.APPLICATION_JSON_VALUE })
public void create(AccountAccessToken token, @Valid @RequestBody CreateZone request) {
 zoneService.createByUser(request.zone, request.aliasName, token);
}

代码示例来源:origin: kaif-open/kaif

@RequestMapping(value = "/zone-available")
public SingleWrapper<Boolean> isZoneAvailable(@RequestParam("zone") String zone) {
 return SingleWrapper.of(zoneService.isZoneAvailable(zone));
}

代码示例来源:origin: kaif-open/kaif

@RequestMapping("/{zone}/debates/{articleId}")
public Object articleDebates(@PathVariable("zone") String rawZone,
  @PathVariable("articleId") FlakeId articleFlakeId,
  HttpServletRequest request) throws IOException {
 return resolveZone(request, rawZone, zoneInfo -> {
  return new ModelAndView("article/debates")//
    .addObject("zoneInfo", zoneInfo)
    .addObject("recommendZones", zoneService.listRecommendZones())
    .addObject("article", articleService.loadArticle(articleFlakeId))
    .addObject("zoneAdmins",
      zoneService.listAdministratorsWithCache(zoneInfo.getZone())
        .stream()
        .collect(Collectors.joining(",")))
    .addObject("debateTree", articleService.listBestDebates(articleFlakeId, null));
 });
}

代码示例来源:origin: kaif-open/kaif

@Test
public void listCitizenZones() throws Exception {
 ZoneInfo about = service.createDefault("about", "about-alias");
 ZoneInfo abc = service.createDefault("abc", "abc-alias");
 service.createKaif("kaif-java", "java-alias");
 ZoneInfo groovy = service.createDefault("groovy", "groovy-alias");
 assertEquals(asList(abc, about, groovy), service.listCitizenZones());
}

代码示例来源:origin: kaif-open/kaif

@Test
public void listRecommendZones() throws Exception {
 ZoneInfo z1 = service.createDefault("zone1", "Zone 1");
 ZoneInfo z2 = service.createDefault("zone2", "Zone 2");
 ZoneInfo z3 = service.createDefault("zone3", "No article zone");
 ZoneInfo z4 = service.createDefault("zone4", "Zone 4");
 Account account = savedAccountCitizen("foobar");
 IntStream.rangeClosed(1, 10).forEach(i -> {
  savedArticle(z1, account, i + " z1 - title");
  savedArticle(z2, account, i + " z2 - title");
  savedArticle(z4, account, i + " z4 - title");
 });
 assertTrue(service.listRecommendZones().containsAll(asList(z1, z2, z3, z4)));
}

代码示例来源:origin: kaif-open/kaif

private Object resolveZone(HttpServletRequest request,
  String decodedRawZone,
  Function<ZoneInfo, ModelAndView> onZoneInfo) {
 // note that decodedRawZone already do http url decode, and PathVariable already trim()
 // space of value
 return Zone.tryFallback(decodedRawZone).map(zone -> {
  if (!zone.value().equals(decodedRawZone)) {
   String orgUrl = request.getRequestURL().toString();
   // replace pattern is combine of fallback pattern and valid pattern
   // TODO refactor replace rule to Zone
   String location = orgUrl.replaceFirst("/z/[a-zA-Z0-9_\\-]+", "/z/" + zone);
   //check if fallback success, this prevent infinite redirect loop
   if (!location.equals(orgUrl)) {
    RedirectView redirectView = new RedirectView(location);
    redirectView.setPropagateQueryParams(true);
    redirectView.setExpandUriTemplateVariables(false);
    redirectView.setExposeModelAttributes(false);
    redirectView.setExposeContextBeansAsAttributes(false);
    redirectView.setExposePathVariables(false);
    redirectView.setContextRelative(true);
    redirectView.setStatusCode(HttpStatus.PERMANENT_REDIRECT);
    return redirectView;
   }
  }
  return onZoneInfo.apply(zoneService.loadZone(zone));
 }).orElseThrow(() -> new EmptyResultDataAccessException("no such zone: " + decodedRawZone, 1));
}

代码示例来源:origin: kaif-open/kaif

@Test
public void hotArticlesWithPaging() throws Exception {
 Zone z = zoneInfo.getZone();
 when(zoneService.loadZone(z)).thenReturn(zoneInfo);
 Article article1 = article(z, "javascript discussion");
 Article article2 = article(z, FlakeId.fromString("phpone"), "php-lang discussion");
 when(articleService.listHotZoneArticles(z, FlakeId.fromString("123456"))).thenReturn(//
   asList(article1, article2));
 when(zoneService.listAdministratorsWithCache(z)).thenReturn(asList("admin1", "admin2"));
 mockMvc.perform(get("/z/programming?start=123456"))
   .andExpect(content().string(containsString("/css/z-theme-default.css")))
   .andExpect(content().string(containsString("programming-alias")))
   .andExpect(content().string(containsString("php-lang")))
   .andExpect(content().string(containsString("admin1")))
   .andExpect(content().string(containsString("href=\"/z/programming?start=phpone\"")));
}

代码示例来源:origin: kaif-open/kaif

@Test
public void updateTheme() throws Exception {
 service.createDefault("twfaq", "TW FAQ");
 service.loadZone(Zone.valueOf("twfaq"));//populate cache
 service.updateTheme(Zone.valueOf("twfaq"), ZoneInfo.THEME_KAIF);
 assertEquals(ZoneInfo.THEME_KAIF, service.loadZone(Zone.valueOf("twfaq")).getTheme());
}

代码示例来源:origin: kaif-open/kaif

@Test
public void listAdministerZones() {
 assertTrue(service.listAdministerZones(citizen.getUsername()).isEmpty());
 accountDao.changeTotalVotedDebate(citizen.getAccountId(), 30, 0);
 ZoneInfo bZone = service.createByUser("bbb1", "this is aaa1", citizen);
 ZoneInfo aZone = service.createByUser("aaa2", "this is aaa2", citizen);
 List<ZoneInfo> administerZones = service.listAdministerZones(citizen.getUsername());
 assertEquals(2, administerZones.size());
 assertEquals(aZone, administerZones.get(0));
 assertEquals(bZone, administerZones.get(1));
}

代码示例来源:origin: kaif-open/kaif

@Test
 public void listAdministrators() {
  Zone zone = Zone.valueOf("foo");
  assertTrue(service.listAdministratorsWithCache(zone).isEmpty());
  accountDao.changeTotalVotedDebate(citizen.getAccountId(), 30, 0);
  service.createByUser("foo", "this is aaa2", citizen);
  List<String> administerNames = service.listAdministratorsWithCache(zone);
  assertEquals(asList(citizen.getUsername()), administerNames);
 }
}

代码示例来源:origin: kaif-open/kaif

@Test
public void createSpeak() throws Exception {
 when(zoneService.loadZone(Zone.valueOf("programming"))).thenReturn(zoneInfo);
 ZoneInfo another = zoneDefault("another");
 when(zoneService.listCitizenZones()).thenReturn(asList(zoneInfo, another));
 mockMvc.perform(get("/z/programming/article/create-speak"))
   .andExpect(view().name("article/create"))
   .andExpect(model().attribute("candidateZoneInfos", hasItem(another)))
   .andExpect(model().attribute("candidateZoneInfos", not(hasItem(zoneInfo))))
   .andExpect(content().string(containsString("id=\"contentInput\"")));
}

代码示例来源:origin: kaif-open/kaif

@ApiOperation(value = "[public] List all zones", notes = "List all available zones.")
@RequiredScope(PUBLIC)
@RequestMapping(value = "/all", method = RequestMethod.GET)
public List<V1ZoneDto> all(ClientAppUserAccessToken token) {
 return zoneService.listCitizenZones().stream().map(ZoneInfo::toV1Dto).collect(toList());
}

代码示例来源:origin: kaif-open/kaif

@Test
public void getZone_cached() throws Exception {
 service.createDefault("def", "dddd");
 ZoneInfo cached = service.loadZone(Zone.valueOf("def"));
 assertSame(cached, service.loadZone(Zone.valueOf("def")));
}

代码示例来源:origin: kaif-open/kaif

@Test
public void listZoneAtoZ() throws Exception {
 ZoneInfo about = service.createDefault("about", "about-alias");
 ZoneInfo abc = service.createDefault("abc", "abc-alias");
 ZoneInfo java = service.createDefault("java", "java-alias");
 ZoneInfo groovy = service.createDefault("groovy", "groovy-alias");
 Map<String, List<ZoneInfo>> aToZ = service.listZoneAtoZ();
 //key iteration must ordered
 Iterator<String> cat = aToZ.keySet().iterator();
 assertEquals("A", cat.next());
 assertEquals(asList(abc, about), aToZ.get("A"));
 assertEquals("G", cat.next());
 assertEquals(asList(groovy), aToZ.get("G"));
 assertEquals("J", cat.next());
 assertEquals(asList(java), aToZ.get("J"));
}

代码示例来源:origin: kaif-open/kaif

public IndexModelAndView(ZoneService zoneService) {
  super("index");
  addObject("recommendZones", zoneService.listRecommendZones());
 }
}

代码示例来源:origin: kaif-open/kaif

@ApiOperation(value = "[public] List administrators of the zone", notes = "List username of administrators of the zone")
 @RequiredScope(PUBLIC)
 @RequestMapping(value = "/{zone}/administrator/username", method = RequestMethod.GET)
 public List<String> listAdministrators(ClientAppUserAccessToken token,
   @PathVariable("zone") String zone) {
  return zoneService.listAdministratorsWithCache(Zone.valueOf(zone));
 }
}

代码示例来源:origin: kaif-open/kaif

@RequestMapping("/zone/a-z")
public ModelAndView zoneAtoZ() {
 return new ModelAndView("zone/zone-a-z").addObject("zoneAtoZ", zoneService.listZoneAtoZ());
}

代码示例来源:origin: kaif-open/kaif

@RequestMapping("/u/{username}")
public Object userProfile(@PathVariable("username") String username) {
 Account account = accountService.loadAccount(username);
 if (!account.getUsername().equals(username)) {
  RedirectView redirectView = new RedirectView("/u/" + account.getUsername());
  redirectView.setStatusCode(HttpStatus.MOVED_PERMANENTLY);
  return redirectView;
 }
 AccountStats accountStats = accountService.loadAccountStats(account.getUsername());
 List<ZoneInfo> zones = zoneService.listAdministerZones(account.getUsername());
 return new ModelAndView("account/user-profile")//
   .addObject("account", account)
   .addObject("accountStats", accountStats)
   .addObject("administerZones", zones);
}

代码示例来源:origin: kaif-open/kaif

@Test
public void createDefault_not_allow_reserve_word() throws Exception {
 try {
  service.createDefault("kaif", "ABC");
  fail("IllegalArgumentException expected");
 } catch (IllegalArgumentException expected) {
 }
 try {
  service.createDefault("kaif-abc", "ABC");
  fail("IllegalArgumentException expected");
 } catch (IllegalArgumentException expected) {
 }
 try {
  service.createDefault("abckaifabc", "ABC");
  fail("IllegalArgumentException expected");
 } catch (IllegalArgumentException expected) {
 }
}

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com