mirror of https://github.com/halo-dev/halo
Create gallery save api for gallery.
parent
cf3301d15a
commit
f893294076
|
@ -8,9 +8,12 @@ import org.springframework.data.web.PageableDefault;
|
|||
import org.springframework.data.web.SortDefault;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import run.halo.app.model.dto.GalleryDTO;
|
||||
import run.halo.app.model.entity.Gallery;
|
||||
import run.halo.app.model.params.GalleryParam;
|
||||
import run.halo.app.model.params.GalleryQuery;
|
||||
import run.halo.app.service.GalleryService;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
import static org.springframework.data.domain.Sort.Direction.DESC;
|
||||
|
@ -70,4 +73,9 @@ public class GalleryController {
|
|||
public void deletePermanently(@PathVariable("galleryId") Integer galleryId) {
|
||||
galleryService.removeById(galleryId);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public Gallery createBy(@Valid @RequestBody GalleryParam galleryParam) {
|
||||
return galleryService.createBy(galleryParam);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package run.halo.app.controller.admin.api;
|
||||
|
||||
import run.halo.app.model.dto.LogDTO;
|
||||
import run.halo.app.service.LogService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import run.halo.app.model.dto.LogDTO;
|
||||
import run.halo.app.service.LogService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package run.halo.app.controller.admin.api;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import run.halo.app.model.dto.OptionDTO;
|
||||
import run.halo.app.model.params.OptionParam;
|
||||
import run.halo.app.service.OptionService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
|
|
@ -8,7 +8,6 @@ import org.springframework.web.bind.annotation.*;
|
|||
import run.halo.app.model.dto.post.PostMinimalDTO;
|
||||
import run.halo.app.model.dto.post.PostSimpleDTO;
|
||||
import run.halo.app.model.entity.Post;
|
||||
import run.halo.app.model.entity.Sheet;
|
||||
import run.halo.app.model.enums.PostStatus;
|
||||
import run.halo.app.model.params.PostParam;
|
||||
import run.halo.app.model.params.PostQuery;
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
package run.halo.app.controller.admin.api;
|
||||
|
||||
import run.halo.app.model.dto.TagDTO;
|
||||
import run.halo.app.model.entity.Tag;
|
||||
import run.halo.app.model.params.TagParam;
|
||||
import run.halo.app.service.PostTagService;
|
||||
import run.halo.app.service.TagService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.web.SortDefault;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import run.halo.app.model.dto.TagDTO;
|
||||
import run.halo.app.model.entity.Tag;
|
||||
import run.halo.app.model.params.TagParam;
|
||||
import run.halo.app.service.PostTagService;
|
||||
import run.halo.app.service.TagService;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package run.halo.app.controller.admin.api;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import run.halo.app.model.dto.UserDTO;
|
||||
import run.halo.app.model.entity.User;
|
||||
import run.halo.app.model.params.PasswordParam;
|
||||
import run.halo.app.model.params.UserParam;
|
||||
import run.halo.app.service.UserService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
package run.halo.app.model.params;
|
||||
|
||||
import lombok.Data;
|
||||
import run.halo.app.model.dto.base.InputConverter;
|
||||
import run.halo.app.model.entity.Gallery;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Post param.
|
||||
*
|
||||
* @author RYAN0UP
|
||||
* @date 2019/04/25
|
||||
*/
|
||||
@Data
|
||||
public class GalleryParam implements InputConverter<Gallery> {
|
||||
|
||||
@NotBlank(message = "Gallery name must not be blank")
|
||||
private String name;
|
||||
|
||||
private String description;
|
||||
|
||||
private Date takeTime;
|
||||
|
||||
private String location;
|
||||
|
||||
@NotBlank(message = "Gallery thumbnail must not be blank")
|
||||
private String thumbnail;
|
||||
|
||||
@NotBlank(message = "Gallery url must not be blank")
|
||||
private String url;
|
||||
|
||||
private String team;
|
||||
}
|
|
@ -6,6 +6,7 @@ import org.springframework.data.domain.Sort;
|
|||
import org.springframework.lang.NonNull;
|
||||
import run.halo.app.model.dto.GalleryDTO;
|
||||
import run.halo.app.model.entity.Gallery;
|
||||
import run.halo.app.model.params.GalleryParam;
|
||||
import run.halo.app.model.params.GalleryQuery;
|
||||
import run.halo.app.model.vo.GalleryTeamVO;
|
||||
import run.halo.app.service.base.CrudService;
|
||||
|
@ -53,4 +54,13 @@ public interface GalleryService extends CrudService<Gallery, Integer> {
|
|||
*/
|
||||
@NonNull
|
||||
Page<GalleryDTO> pageDtosBy(@NonNull Pageable pageable, GalleryQuery galleryQuery);
|
||||
|
||||
/**
|
||||
* Creates gallery by gallery param.
|
||||
*
|
||||
* @param galleryParam must not be null
|
||||
* @return create gallery
|
||||
*/
|
||||
@NonNull
|
||||
Gallery createBy(@NonNull GalleryParam galleryParam);
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.util.Assert;
|
||||
import run.halo.app.model.dto.GalleryDTO;
|
||||
import run.halo.app.model.entity.Gallery;
|
||||
import run.halo.app.model.params.GalleryParam;
|
||||
import run.halo.app.model.params.GalleryQuery;
|
||||
import run.halo.app.model.vo.GalleryTeamVO;
|
||||
import run.halo.app.repository.GalleryRepository;
|
||||
|
@ -111,6 +112,13 @@ public class GalleryServiceImpl extends AbstractCrudService<Gallery, Integer> im
|
|||
return galleryPage.map(gallery -> new GalleryDTO().convertFrom(gallery));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Gallery createBy(GalleryParam galleryParam) {
|
||||
Assert.notNull(galleryParam, "Gallery param must not be null");
|
||||
|
||||
return create(galleryParam.convertTo());
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private Specification<Gallery> buildSpecByQuery(@NonNull GalleryQuery galleryQuery) {
|
||||
Assert.notNull(galleryQuery, "Attachment query must not be null");
|
||||
|
|
Loading…
Reference in New Issue