mirror of https://github.com/halo-dev/halo
Create list teams api for photo.
parent
433f607634
commit
e6c6624680
|
@ -23,7 +23,7 @@ import static org.springframework.data.domain.Sort.Direction.DESC;
|
||||||
* Attachment controller.
|
* Attachment controller.
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
* @date 3/21/19
|
* @date 2019-03-21
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/admin/attachments")
|
@RequestMapping("/api/admin/attachments")
|
||||||
|
|
|
@ -22,7 +22,7 @@ import static org.springframework.data.domain.Sort.Direction.DESC;
|
||||||
* Photo controller
|
* Photo controller
|
||||||
*
|
*
|
||||||
* @author ryanwang
|
* @author ryanwang
|
||||||
* @date : 2019/3/21
|
* @date : 2019-3-21
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/admin/photos")
|
@RequestMapping("/api/admin/photos")
|
||||||
|
@ -92,4 +92,10 @@ public class PhotoController {
|
||||||
// Update menu in database
|
// Update menu in database
|
||||||
return new PhotoDTO().convertFrom(photoService.update(photo));
|
return new PhotoDTO().convertFrom(photoService.update(photo));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("teams")
|
||||||
|
@ApiOperation("Lists all of photo teams")
|
||||||
|
public List<String> listTeams() {
|
||||||
|
return photoService.listAllTeams();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ import java.util.List;
|
||||||
* Attachment repository
|
* Attachment repository
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
|
* @date 2019-04-03
|
||||||
*/
|
*/
|
||||||
public interface AttachmentRepository extends BaseRepository<Attachment, Integer>, JpaSpecificationExecutor<Attachment> {
|
public interface AttachmentRepository extends BaseRepository<Attachment, Integer>, JpaSpecificationExecutor<Attachment> {
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ package run.halo.app.repository;
|
||||||
|
|
||||||
import org.springframework.data.domain.Sort;
|
import org.springframework.data.domain.Sort;
|
||||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
import run.halo.app.model.entity.Photo;
|
import run.halo.app.model.entity.Photo;
|
||||||
import run.halo.app.repository.base.BaseRepository;
|
import run.halo.app.repository.base.BaseRepository;
|
||||||
|
|
||||||
|
@ -11,6 +12,8 @@ import java.util.List;
|
||||||
* Photo repository.
|
* Photo repository.
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
|
* @author ryanwang
|
||||||
|
* @date 2019-04-03
|
||||||
*/
|
*/
|
||||||
public interface PhotoRepository extends BaseRepository<Photo, Integer>, JpaSpecificationExecutor<Photo> {
|
public interface PhotoRepository extends BaseRepository<Photo, Integer>, JpaSpecificationExecutor<Photo> {
|
||||||
|
|
||||||
|
@ -22,4 +25,12 @@ public interface PhotoRepository extends BaseRepository<Photo, Integer>, JpaSpec
|
||||||
* @return list of photo
|
* @return list of photo
|
||||||
*/
|
*/
|
||||||
List<Photo> findByTeam(String team, Sort sort);
|
List<Photo> findByTeam(String team, Sort sort);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find all photo teams.
|
||||||
|
*
|
||||||
|
* @return list of teams.
|
||||||
|
*/
|
||||||
|
@Query(value = "select distinct p.team from Photo p")
|
||||||
|
List<String> findAllTeams();
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,4 +64,11 @@ public interface PhotoService extends CrudService<Photo, Integer> {
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
Photo createBy(@NonNull PhotoParam photoParam);
|
Photo createBy(@NonNull PhotoParam photoParam);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List all teams.
|
||||||
|
*
|
||||||
|
* @return list of teams
|
||||||
|
*/
|
||||||
|
List<String> listAllTeams();
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,9 +100,14 @@ public class PhotoServiceImpl extends AbstractCrudService<Photo, Integer> implem
|
||||||
return create(photoParam.convertTo());
|
return create(photoParam.convertTo());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> listAllTeams() {
|
||||||
|
return photoRepository.findAllTeams();
|
||||||
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private Specification<Photo> buildSpecByQuery(@NonNull PhotoQuery photoQuery) {
|
private Specification<Photo> buildSpecByQuery(@NonNull PhotoQuery photoQuery) {
|
||||||
Assert.notNull(photoQuery, "Attachment query must not be null");
|
Assert.notNull(photoQuery, "Photo query must not be null");
|
||||||
|
|
||||||
return (Specification<Photo>) (root, query, criteriaBuilder) -> {
|
return (Specification<Photo>) (root, query, criteriaBuilder) -> {
|
||||||
List<Predicate> predicates = new LinkedList<>();
|
List<Predicate> predicates = new LinkedList<>();
|
||||||
|
|
Loading…
Reference in New Issue