mirror of https://github.com/halo-dev/halo
Create list team api for menu/link.
parent
1c38fc6471
commit
eb7ff715c2
|
@ -90,7 +90,7 @@ public class WebMvcAutoConfiguration implements WebMvcConfigurer {
|
||||||
.addResourceLocations(workDir + "upload/");
|
.addResourceLocations(workDir + "upload/");
|
||||||
registry.addResourceHandler("/backup/**")
|
registry.addResourceHandler("/backup/**")
|
||||||
.addResourceLocations(workDir + "backup/");
|
.addResourceLocations(workDir + "backup/");
|
||||||
registry.addResourceHandler("/admin/**")
|
registry.addResourceHandler(haloProperties.getAdminPath() + "/**")
|
||||||
.addResourceLocations(workDir + HALO_ADMIN_RELATIVE_PATH)
|
.addResourceLocations(workDir + HALO_ADMIN_RELATIVE_PATH)
|
||||||
.addResourceLocations("classpath:/admin/");
|
.addResourceLocations("classpath:/admin/");
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,11 @@ public class HaloProperties {
|
||||||
*/
|
*/
|
||||||
private boolean authEnabled = true;
|
private boolean authEnabled = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Admin path.
|
||||||
|
*/
|
||||||
|
private String adminPath = "/admin";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Work directory.
|
* Work directory.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -76,4 +76,10 @@ public class LinkController {
|
||||||
public void deletePermanently(@PathVariable("id") Integer id) {
|
public void deletePermanently(@PathVariable("id") Integer id) {
|
||||||
linkService.removeById(id);
|
linkService.removeById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("teams")
|
||||||
|
@ApiOperation(("List all link teams"))
|
||||||
|
public List<String> teams() {
|
||||||
|
return linkService.listAllTeams();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,8 @@ import static org.springframework.data.domain.Sort.Direction.DESC;
|
||||||
* Menu controller.
|
* Menu controller.
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
* @date 4/3/19
|
* @author ryanwang
|
||||||
|
* @date 2019-04-03
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/admin/menus")
|
@RequestMapping("/api/admin/menus")
|
||||||
|
@ -88,4 +89,10 @@ public class MenuController {
|
||||||
}
|
}
|
||||||
return new MenuDTO().convertFrom(menuService.removeById(menuId));
|
return new MenuDTO().convertFrom(menuService.removeById(menuId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("teams")
|
||||||
|
@ApiOperation(("List all menu teams"))
|
||||||
|
public List<String> teams() {
|
||||||
|
return menuService.listAllTeams();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,9 @@ package run.halo.app.controller.content;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
import run.halo.app.config.properties.HaloProperties;
|
||||||
import run.halo.app.exception.ServiceException;
|
import run.halo.app.exception.ServiceException;
|
||||||
import run.halo.app.model.entity.User;
|
import run.halo.app.model.entity.User;
|
||||||
import run.halo.app.model.properties.BlogProperties;
|
import run.halo.app.model.properties.BlogProperties;
|
||||||
|
@ -27,19 +29,22 @@ public class MainController {
|
||||||
|
|
||||||
private final OptionService optionService;
|
private final OptionService optionService;
|
||||||
|
|
||||||
public MainController(UserService userService, OptionService optionService) {
|
private final HaloProperties haloProperties;
|
||||||
|
|
||||||
|
public MainController(UserService userService, OptionService optionService, HaloProperties haloProperties) {
|
||||||
this.userService = userService;
|
this.userService = userService;
|
||||||
this.optionService = optionService;
|
this.optionService = optionService;
|
||||||
|
this.haloProperties = haloProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/admin")
|
@GetMapping("/{permlink}")
|
||||||
public String admin() {
|
public String admin(@PathVariable(name = "permlink") String permlink) {
|
||||||
return "redirect:/admin/index.html";
|
return "redirect:/" + permlink + "/index.html";
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/install")
|
@GetMapping("/install")
|
||||||
public String installation() {
|
public String installation() {
|
||||||
return "redirect:/admin/index.html#install";
|
return "redirect:" + haloProperties.getAdminPath() + "/index.html#install";
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/version")
|
@GetMapping("/version")
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class StartedListener implements ApplicationListener<ApplicationStartedEv
|
||||||
String blogUrl = optionService.getBlogBaseUrl();
|
String blogUrl = optionService.getBlogBaseUrl();
|
||||||
|
|
||||||
log.info("Halo started at {}", blogUrl);
|
log.info("Halo started at {}", blogUrl);
|
||||||
log.info("Halo admin started at {}/admin", blogUrl);
|
log.info("Halo admin started at {}{}", blogUrl, haloProperties.getAdminPath());
|
||||||
if (!haloProperties.isDocDisabled()) {
|
if (!haloProperties.isDocDisabled()) {
|
||||||
log.debug("Halo doc was enable at {}/swagger-ui.html", blogUrl);
|
log.debug("Halo doc was enable at {}/swagger-ui.html", blogUrl);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,23 @@
|
||||||
package run.halo.app.repository;
|
package run.halo.app.repository;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
import run.halo.app.model.entity.Link;
|
import run.halo.app.model.entity.Link;
|
||||||
import run.halo.app.repository.base.BaseRepository;
|
import run.halo.app.repository.base.BaseRepository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Link repository.
|
* Link repository.
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
*/
|
*/
|
||||||
public interface LinkRepository extends BaseRepository<Link, Integer> {
|
public interface LinkRepository extends BaseRepository<Link, Integer> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find all link teams.
|
||||||
|
*
|
||||||
|
* @return a list of teams
|
||||||
|
*/
|
||||||
|
@Query(value = "select distinct a.team from Link a")
|
||||||
|
List<String> findAllTeams();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package run.halo.app.repository;
|
package run.halo.app.repository;
|
||||||
|
|
||||||
import org.springframework.data.domain.Sort;
|
import org.springframework.data.domain.Sort;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
import org.springframework.lang.NonNull;
|
import org.springframework.lang.NonNull;
|
||||||
import run.halo.app.model.entity.Menu;
|
import run.halo.app.model.entity.Menu;
|
||||||
import run.halo.app.repository.base.BaseRepository;
|
import run.halo.app.repository.base.BaseRepository;
|
||||||
|
@ -23,4 +24,12 @@ public interface MenuRepository extends BaseRepository<Menu, Integer> {
|
||||||
List<Menu> findByParentId(@NonNull Integer id);
|
List<Menu> findByParentId(@NonNull Integer id);
|
||||||
|
|
||||||
List<Menu> findByTeam(String team, Sort sort);
|
List<Menu> findByTeam(String team, Sort sort);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find all menu teams.
|
||||||
|
*
|
||||||
|
* @return a list of teams
|
||||||
|
*/
|
||||||
|
@Query(value = "select distinct a.team from Menu a")
|
||||||
|
List<String> findAllTeams();
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ import java.util.List;
|
||||||
* Link service interface.
|
* Link service interface.
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
|
* @author ryanwang
|
||||||
* @date 2019-03-14
|
* @date 2019-03-14
|
||||||
*/
|
*/
|
||||||
public interface LinkService extends CrudService<Link, Integer> {
|
public interface LinkService extends CrudService<Link, Integer> {
|
||||||
|
@ -52,4 +53,11 @@ public interface LinkService extends CrudService<Link, Integer> {
|
||||||
* @return true if exists; false otherwise
|
* @return true if exists; false otherwise
|
||||||
*/
|
*/
|
||||||
boolean existByName(String name);
|
boolean existByName(String name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List all link teams.
|
||||||
|
*
|
||||||
|
* @return a list of teams.
|
||||||
|
*/
|
||||||
|
List<String> listAllTeams();
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,4 +71,11 @@ public interface MenuService extends CrudService<Menu, Integer> {
|
||||||
* @return a list of menu
|
* @return a list of menu
|
||||||
*/
|
*/
|
||||||
List<Menu> listByParentId(@NonNull Integer id);
|
List<Menu> listByParentId(@NonNull Integer id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List all menu teams.
|
||||||
|
*
|
||||||
|
* @return a list of teams.
|
||||||
|
*/
|
||||||
|
List<String> listAllTeams();
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,6 +95,11 @@ public class LinkServiceImpl extends AbstractCrudService<Link, Integer> implemen
|
||||||
return linkRepository.exists(Example.of(link));
|
return linkRepository.exists(Example.of(link));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> listAllTeams() {
|
||||||
|
return linkRepository.findAllTeams();
|
||||||
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private List<LinkDTO> convertTo(@Nullable List<Link> links) {
|
private List<LinkDTO> convertTo(@Nullable List<Link> links) {
|
||||||
if (CollectionUtils.isEmpty(links)) {
|
if (CollectionUtils.isEmpty(links)) {
|
||||||
|
|
|
@ -112,6 +112,11 @@ public class MenuServiceImpl extends AbstractCrudService<Menu, Integer> implemen
|
||||||
return menuRepository.findByParentId(id);
|
return menuRepository.findByParentId(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> listAllTeams() {
|
||||||
|
return menuRepository.findAllTeams();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Menu create(Menu menu) {
|
public Menu create(Menu menu) {
|
||||||
nameMustNotExist(menu);
|
nameMustNotExist(menu);
|
||||||
|
|
Loading…
Reference in New Issue