mirror of
https://github.com/Such-Software/medusa-plugin-blog.git
synced 2026-10-23 06:28:32 +02:00
changes to search by tag endpoints
This commit is contained in:
+1
-1
@@ -67,7 +67,7 @@ export default (rootDirectory: string): Router | Router[] => {
|
||||
if (!req.query.tag) { return res.json([]) }
|
||||
const tag_ids = (typeof req.query.tag === "string")? [req.query.tag] : req.query.tag
|
||||
const blogService = req.scope.resolve("blogService")
|
||||
blogService.getBlogPostsByTags(tag_ids).then((blog_posts) => {
|
||||
blogService.getBlogPostsByTag(tag_ids).then((blog_posts) => {
|
||||
return res.json(blog_posts)
|
||||
})
|
||||
})
|
||||
|
||||
+1
-13
@@ -122,18 +122,6 @@ export default class BlogService extends TransactionBaseService {
|
||||
})
|
||||
}
|
||||
|
||||
async getBlogPostsByTag(tag_id) {
|
||||
/* @ts-ignore */
|
||||
const blogPostRepository = this.activeManager_.withRepository(this.blogPostRepository_)
|
||||
return await blogPostRepository.createQueryBuilder('blog_post')
|
||||
.leftJoinAndSelect('blog_post.tags', 'tags')
|
||||
.leftJoinAndSelect('blog_post.category', 'category')
|
||||
.leftJoinAndSelect('blog_post.products', 'products')
|
||||
.leftJoinAndSelect('blog_post.collections', 'collections')
|
||||
.where('tags.id = :tag_id)', { tag_id })
|
||||
.getMany()
|
||||
}
|
||||
|
||||
async getBlogPostsAllTags(tag_ids) {
|
||||
/* @ts-ignore */
|
||||
const blogPostRepository = this.activeManager_.withRepository(this.blogPostRepository_)
|
||||
@@ -152,7 +140,7 @@ export default class BlogService extends TransactionBaseService {
|
||||
// .getMany()
|
||||
}
|
||||
|
||||
async getBlogPostsByTags(tag_ids:number[]) {
|
||||
async getBlogPostsByTag(tag_ids:number[]) {
|
||||
/* @ts-ignore */
|
||||
const blogPostRepository = this.activeManager_.withRepository(this.blogPostRepository_)
|
||||
return await blogPostRepository.createQueryBuilder('blog_post')
|
||||
|
||||
Reference in New Issue
Block a user