-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into 706-서클-별-도서-추천-기능-구현
- Loading branch information
Showing
29 changed files
with
596 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { | ||
Column, Entity, Index, JoinColumn, OneToOne, PrimaryGeneratedColumn, | ||
} from 'typeorm'; | ||
import { BookInfo } from './BookInfo'; | ||
|
||
@Index('bookInfoId', ['bookInfoId'], {}) | ||
@Entity('book_info_search_keywords') | ||
export class BookInfoSearchKeywords { | ||
@PrimaryGeneratedColumn({ type: 'int', name: 'id' }) | ||
id?: number; | ||
|
||
@Column('varchar', { name: 'disassembled_title', length: 255 }) | ||
disassembledTitle?: string; | ||
|
||
@Column('varchar', { name: 'disassembled_author', length: 255 }) | ||
disassembledAuthor?: string; | ||
|
||
@Column('varchar', { name: 'disassembled_publisher', length: 255 }) | ||
disassembledPublisher?: string; | ||
|
||
@Column('varchar', { name: 'title_initials', length: 255 }) | ||
titleInitials?: string; | ||
|
||
@Column('varchar', { name: 'author_initials', length: 255 }) | ||
authorInitials?: string; | ||
|
||
@Column('varchar', { name: 'publisher_initials', length: 255 }) | ||
publisherInitials?: string; | ||
|
||
@Column('int', { name: 'book_info_id' }) | ||
bookInfoId?: number; | ||
|
||
@OneToOne(() => BookInfo, (bookInfo) => bookInfo.id) | ||
@JoinColumn([{ name: 'book_info_id', referencedColumnName: 'id' }]) | ||
bookInfo?: BookInfo; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { SelectQueryBuilder } from 'kysely'; | ||
|
||
type Paginated<O> = { | ||
items: O[], | ||
meta: { | ||
totalItems: number; | ||
totalPages: number; | ||
}; | ||
} | ||
|
||
export const metaPaginated = async <DB, TB extends keyof DB, O>( | ||
qb: SelectQueryBuilder<DB, TB, O>, | ||
{ page, perPage }: { page: number; perPage: number }, | ||
): Promise<Paginated<O>> => { | ||
const { totalItems } = await qb | ||
.clearSelect() | ||
.select(({ fn }) => fn.countAll<number>().as('totalItems')) | ||
.executeTakeFirstOrThrow(); | ||
|
||
const items = await qb | ||
.offset((page - 1) * perPage) | ||
.limit(perPage) | ||
.execute(); | ||
|
||
const totalPages = Math.ceil(totalItems / perPage); | ||
|
||
return { items, meta: { totalItems, totalPages } }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { Router } from 'express'; | ||
import { getPopularSearchKeywords } from '../search-keywords/searchKeywords.controller'; | ||
|
||
export const path = '/search-keywords'; | ||
export const router = Router(); | ||
|
||
router | ||
/** | ||
* @openapi | ||
* /api/search-keywords/popular: | ||
* get: | ||
* description: 인기 검색어 순위를 10위까지 가져온다. 동순위가 있는 경우 가장 최근에 검색된 검색어 순으로 보여준다. | ||
* tags: | ||
* - search-keywords | ||
* responses: | ||
* '200': | ||
* description: 인기 검색어 10위. | ||
* rankingChange는 순위가 올랐으면 양수, 떨어졌으면 음수, 그대로면 0 이며, 새롭게 진입한 검색어는 null이다. | ||
* content: | ||
* application/json: | ||
* schema: | ||
* type: object | ||
* properties: | ||
* items: | ||
* type: array | ||
* example: [ | ||
* { "searchKeyword": 'aws', "rankingChange": 2 }, | ||
* { "searchKeyword": '파이썬', "rankingChange": 0 }, | ||
* { "searchKeyword": '도커', "rankingChange": -2 }, | ||
* { "searchKeyword": 'tcp', "rankingChange": 0 }, | ||
* { "searchKeyword": '스위프트', "rankingChange": 0 }, | ||
* { "searchKeyword": '자바', "rankingChange": 0 }, | ||
* { "searchKeyword": '검색', "rankingChange": 0 }, | ||
* { "searchKeyword": 'http', "rankingChange": null }, | ||
* { "searchKeyword": '리액트', "rankingChange": -1 }, | ||
* { "searchKeyword": 'java', "rankingChange": -1 } | ||
* ] | ||
* items: | ||
* type: object | ||
* properties: | ||
* searchKeyword: | ||
* description: 검색어 | ||
* type: string | ||
* rankingChange: | ||
* description: 순위 등락 | ||
* type: integer | ||
*/ | ||
.get('/popular', getPopularSearchKeywords); |
Oops, something went wrong.