fix: issues
This commit is contained in:
@@ -3,6 +3,7 @@ package admin
|
||||
import (
|
||||
"quyun/v2/app/requests"
|
||||
"quyun/v2/app/services"
|
||||
"quyun/v2/database"
|
||||
"quyun/v2/database/models"
|
||||
"quyun/v2/pkg/fields"
|
||||
|
||||
@@ -27,12 +28,13 @@ type posts struct{}
|
||||
// @Param pagination query requests.Pagination false "分页参数"
|
||||
// @Param query query ListQuery false "筛选条件"
|
||||
// @Success 200 {object} requests.Pager{items=PostItem} "成功"
|
||||
// @Router /admin/posts [get]
|
||||
// @Router /admin/v1/posts [get]
|
||||
// @Bind pagination query
|
||||
// @Bind query query
|
||||
func (ctl *posts) List(ctx fiber.Ctx, pagination *requests.Pagination, query *ListQuery) (*requests.Pager, error) {
|
||||
conds := []gen.Condition{
|
||||
models.PostQuery.Title.Like(*query.Keyword),
|
||||
conds := []gen.Condition{}
|
||||
if query.Keyword != nil && *query.Keyword != "" {
|
||||
conds = append(conds, models.PostQuery.Title.Like(database.WrapLike(*query.Keyword)))
|
||||
}
|
||||
pager, err := services.Posts.List(ctx, pagination, conds...)
|
||||
if err != nil {
|
||||
@@ -81,7 +83,7 @@ type PostForm struct {
|
||||
// @Produce json
|
||||
// @Param form body PostForm true "请求体"
|
||||
// @Success 200 {object} any "成功"
|
||||
// @Router /admin/posts [post]
|
||||
// @Router /admin/v1/posts [post]
|
||||
// @Bind form body
|
||||
func (ctl *posts) Create(ctx fiber.Ctx, form *PostForm) error {
|
||||
post := models.Post{
|
||||
@@ -126,7 +128,7 @@ func (ctl *posts) Create(ctx fiber.Ctx, form *PostForm) error {
|
||||
// @Param id path int64 true "作品 ID"
|
||||
// @Param form body PostForm true "请求体"
|
||||
// @Success 200 {object} any "成功"
|
||||
// @Router /admin/posts/:id [put]
|
||||
// @Router /admin/v1/posts/:id [put]
|
||||
// @Bind post path key(id) model(id)
|
||||
// @Bind form body
|
||||
func (ctl *posts) Update(ctx fiber.Ctx, post *models.Post, form *PostForm) error {
|
||||
@@ -167,7 +169,7 @@ func (ctl *posts) Update(ctx fiber.Ctx, post *models.Post, form *PostForm) error
|
||||
// @Produce json
|
||||
// @Param id path int64 true "作品 ID"
|
||||
// @Success 204 {object} any "成功"
|
||||
// @Router /admin/posts/:id [delete]
|
||||
// @Router /admin/v1/posts/:id [delete]
|
||||
// @Bind post path key(id) model(id)
|
||||
func (ctl *posts) Delete(ctx fiber.Ctx, post *models.Post) error {
|
||||
if _, err := post.ForceDelete(ctx); err != nil {
|
||||
@@ -189,7 +191,7 @@ type PostItem struct {
|
||||
// @Produce json
|
||||
// @Param id path int64 true "作品 ID"
|
||||
// @Success 200 {object} PostItem "成功"
|
||||
// @Router /admin/posts/:id [get]
|
||||
// @Router /admin/v1/posts/:id [get]
|
||||
// @Bind post path key(id) model(id)
|
||||
func (ctl *posts) Show(ctx fiber.Ctx, post *models.Post) (*PostItem, error) {
|
||||
medias, err := services.Media.GetByIds(ctx, lo.Map(post.Assets.Data(), func(asset fields.MediaAsset, _ int) int64 {
|
||||
@@ -212,7 +214,7 @@ func (ctl *posts) Show(ctx fiber.Ctx, post *models.Post) (*PostItem, error) {
|
||||
// @Param id path int64 true "作品 ID"
|
||||
// @Param userId path int64 true "用户 ID"
|
||||
// @Success 200 {object} any "成功"
|
||||
// @Router /admin/posts/:id/send-to/:userId [post]
|
||||
// @Router /admin/v1/posts/:id/send-to/:userId [post]
|
||||
// @Bind post path key(id) model(id)
|
||||
// @Bind user path key(userId) model(id)
|
||||
func (ctl *posts) SendTo(ctx fiber.Ctx, post *models.Post, user *models.User) error {
|
||||
|
||||
Reference in New Issue
Block a user