mirror of https://github.com/halo-dev/halo
feat: create get attahcment types api.
parent
6941cd4c32
commit
19862b0f79
|
@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.*;
|
|||
import org.springframework.web.multipart.MultipartFile;
|
||||
import run.halo.app.model.dto.AttachmentDTO;
|
||||
import run.halo.app.model.entity.Attachment;
|
||||
import run.halo.app.model.enums.AttachmentType;
|
||||
import run.halo.app.model.params.AttachmentParam;
|
||||
import run.halo.app.model.params.AttachmentQuery;
|
||||
import run.halo.app.service.AttachmentService;
|
||||
|
@ -112,4 +113,10 @@ public class AttachmentController {
|
|||
public List<String> listMediaTypes() {
|
||||
return attachmentService.listAllMediaType();
|
||||
}
|
||||
|
||||
@GetMapping("types")
|
||||
@ApiOperation("Lists all of types.")
|
||||
public List<AttachmentType> listTypes() {
|
||||
return attachmentService.listAllType();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
|||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.lang.NonNull;
|
||||
import run.halo.app.model.entity.Attachment;
|
||||
import run.halo.app.model.enums.AttachmentType;
|
||||
import run.halo.app.repository.base.BaseRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -12,6 +13,7 @@ import java.util.List;
|
|||
* Attachment repository
|
||||
*
|
||||
* @author johnniang
|
||||
* @author ryanwang
|
||||
* @date 2019-04-03
|
||||
*/
|
||||
public interface AttachmentRepository extends BaseRepository<Attachment, Integer>, JpaSpecificationExecutor<Attachment> {
|
||||
|
@ -24,6 +26,14 @@ public interface AttachmentRepository extends BaseRepository<Attachment, Integer
|
|||
@Query(value = "select distinct a.mediaType from Attachment a")
|
||||
List<String> findAllMediaType();
|
||||
|
||||
/**
|
||||
* Find all attachment type.
|
||||
*
|
||||
* @return list of type.
|
||||
*/
|
||||
@Query(value = "select distinct a.type from Attachment a")
|
||||
List<AttachmentType> findAllType();
|
||||
|
||||
/**
|
||||
* Counts by attachment path.
|
||||
*
|
||||
|
|
|
@ -7,6 +7,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|||
import run.halo.app.exception.FileOperationException;
|
||||
import run.halo.app.model.dto.AttachmentDTO;
|
||||
import run.halo.app.model.entity.Attachment;
|
||||
import run.halo.app.model.enums.AttachmentType;
|
||||
import run.halo.app.model.params.AttachmentQuery;
|
||||
import run.halo.app.service.base.CrudService;
|
||||
|
||||
|
@ -74,4 +75,11 @@ public interface AttachmentService extends CrudService<Attachment, Integer> {
|
|||
* @return list of media type
|
||||
*/
|
||||
List<String> listAllMediaType();
|
||||
|
||||
/**
|
||||
* List all type.
|
||||
*
|
||||
* @return list of type.
|
||||
*/
|
||||
List<AttachmentType> listAllType();
|
||||
}
|
||||
|
|
|
@ -178,6 +178,11 @@ public class AttachmentServiceImpl extends AbstractCrudService<Attachment, Integ
|
|||
return attachmentRepository.findAllMediaType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AttachmentType> listAllType() {
|
||||
return attachmentRepository.findAllType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Attachment create(Attachment attachment) {
|
||||
Assert.notNull(attachment, "Attachment must not be null");
|
||||
|
|
Loading…
Reference in New Issue