Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create notice board post, getAll apis #74

Merged
merged 40 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
0aba6f0
feat/#66: create notice-boards module
hobiJeong Nov 29, 2023
9543658
modify/#66: modifying entities related to the notice-board
hobiJeong Nov 29, 2023
cf1ab64
modify/#66: modifying entity related to the notice-board
hobiJeong Nov 29, 2023
37e1837
feat/#66: create dto, constant
hobiJeong Nov 29, 2023
7d80f29
feat/#66: feat post api, modify dto
hobiJeong Nov 29, 2023
7a21900
feat/#66: create swagger api docs and set response
hobiJeong Nov 30, 2023
c54f62e
feat/#66: feat findAll and notice-board-history migrate
hobiJeong Nov 30, 2023
2ab2ad7
conflict/#66: conflict
hobiJeong Dec 3, 2023
3865fec
feat/#66: create dto, add and modify entities
hobiJeong Dec 3, 2023
9683159
modify/#66: modify entity
hobiJeong Dec 3, 2023
0d324e1
feat/#66: create api for post, getAll
hobiJeong Dec 3, 2023
4d5f325
feat/#66: create test code
hobiJeong Dec 3, 2023
b600416
refactor/#66: delete console.log
hobiJeong Dec 3, 2023
941b402
refactor/#66: modify string
hobiJeong Dec 3, 2023
782865b
modify/#66: modify Order type
hobiJeong Dec 3, 2023
b3a035f
modify/#66: modify Order type
hobiJeong Dec 3, 2023
62b4bd3
refactor/#66: modify NoticeBoard Create's key for swaggerBuilder
hobiJeong Dec 3, 2023
ebd5e47
feat/#66: add ApiBearerAuth
hobiJeong Dec 4, 2023
d266d56
modify/#66: modify string
hobiJeong Dec 4, 2023
8eae727
modify/#66: remove test code
hobiJeong Dec 4, 2023
75cf9e7
modify/#66: modify notice-board.constants
hobiJeong Dec 4, 2023
66da11a
modify/#66: modify entity
hobiJeong Dec 4, 2023
bbd65bf
modify/#66: modify migration file
hobiJeong Dec 4, 2023
10915d0
modify/#66: modify entities and migration
hobiJeong Dec 4, 2023
1fe7fd1
modify/#66: modify entities
hobiJeong Dec 4, 2023
9a7b052
refactor/#66: modify typo
hobiJeong Dec 4, 2023
8a206fe
modify/#66: modify dtos
hobiJeong Dec 4, 2023
0114f89
modify/#66: modify dtos
hobiJeong Dec 4, 2023
a293353
Update src/apis/notice-boards/services/notice-boards.service.ts
hobiJeong Dec 4, 2023
d4139d4
refactor/#66: use snake case
hobiJeong Dec 4, 2023
4b10111
refactor/#66: modify entity comment
hobiJeong Dec 4, 2023
be43d1e
Merge branch 'develop' into feat/#66/notice_board_crud
hobiJeong Dec 4, 2023
6da5f59
modify/#66: modify column name and dtos
hobiJeong Dec 4, 2023
cc35718
feat/#66: notice_board , notice_board_history migration
hobiJeong Dec 4, 2023
db84c46
modify/#66: 주석처리
hobiJeong Dec 4, 2023
39c7ba2
feat/#66: reflect #81 PR
hobiJeong Dec 4, 2023
4c58c85
feat/#66: add default value
hobiJeong Dec 5, 2023
6fba066
modify/#66: set default value
hobiJeong Dec 5, 2023
11403a3
modify/#66: delete ApiProperty
hobiJeong Dec 5, 2023
be27db6
Merge branch 'develop' into feat/#66/notice_board_crud
hobiJeong Dec 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions migrations/1700634679995-notice-board.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class NoticeBoard1700634679995 implements MigrationInterface {
comment: '조회수',
},
{
name: 'allow_comment',
name: 'is_allow_comment',
type: 'tinyint',
length: '1',
unsigned: true,
Expand Down Expand Up @@ -190,7 +190,7 @@ export class NoticeBoard1700634679995 implements MigrationInterface {
comment: '댓글 본문',
},
{
name: 'isAnonymous',
name: 'is_anonymous',
type: 'tinyint',
length: '1',
default: 0,
Expand Down Expand Up @@ -316,7 +316,7 @@ export class NoticeBoard1700634679995 implements MigrationInterface {
comment: '대댓글 본문',
},
{
name: 'isAnonymous',
name: 'is_anonymous',
type: 'tinyint',
length: '1',
default: 0,
Expand Down
241 changes: 241 additions & 0 deletions migrations/1701328900610-notice-board-history.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,241 @@
import {
MigrationInterface,
QueryRunner,
Table,
TableColumnOptions,
} from 'typeorm';

const generatePrimaryColumn = (
comment: string = '고유 ID',
): TableColumnOptions => {
return {
name: 'id',
type: 'int',
unsigned: true,
isPrimary: true,
isNullable: false,
isGenerated: true,
generationStrategy: 'increment',
comment,
};
};

const generateCreatedAtColumn = (
comment: string = '생성 일자',
): TableColumnOptions => {
return {
name: 'created_at',
type: 'timestamp',
isNullable: false,
default: 'CURRENT_TIMESTAMP',
comment,
};
};

export class NoticeBoardHistory1701328900610 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
// 공지게시글 히스토리
await queryRunner.createTable(
new Table({
name: 'notice_board_history',
columns: [
generatePrimaryColumn('공지 게시글 히스토리 고유 ID'),
{
name: 'notice_board_id',
type: 'int',
unsigned: true,
isNullable: false,
comment: '공지 게시글 고유 ID',
},
{
name: 'user_id',
type: 'int',
unsigned: true,
isNullable: false,
comment: '게시글 작성 유저 고유 ID',
},
{
name: 'title',
type: 'varchar',
length: '255',
isNullable: false,
comment: '공지게시글 제목',
},
{
name: 'description',
type: 'text',
isNullable: false,
comment: '공지게시글 내용',
},
{
name: 'is_allow_comment',
type: 'boolean',
default: 1,
isNullable: false,
comment: '댓글 허용 여부 (0: 비활성화, 1: 허용)',
},
generateCreatedAtColumn(),
],
foreignKeys: [
{
referencedTableName: 'notice_board',
referencedColumnNames: ['id'],
columnNames: ['notice_board_id'],
onDelete: 'NO ACTION',
onUpdate: 'NO ACTION',
},
{
referencedTableName: 'user',
referencedColumnNames: ['id'],
columnNames: ['user_id'],
onDelete: 'NO ACTION',
onUpdate: 'NO ACTION',
},
],
}),
);
await queryRunner.query(
'ALTER TABLE notice_board_history COMMENT = "공지 게시판 수정이력"',
);

// 공지게시글 댓글 수정이력
await queryRunner.createTable(
new Table({
name: 'notice_board_comment_history',
columns: [
generatePrimaryColumn('공지게시글 댓글 수정이력 고유 ID'),
{
name: 'user_id',
type: 'int',
unsigned: true,
isNullable: false,
comment: '댓글 작성 유저 고유 ID',
},
{
name: 'notice_board_history_id',
type: 'int',
unsigned: true,
isNullable: false,
comment: '게시글 고유 ID',
},
{
name: 'description',
type: 'varchar',
length: '255',
isNullable: false,
comment: '댓글 본문',
},
{
name: 'is_anonymous',
type: 'boolean',
default: 0,
isNullable: false,
comment: '작성자 익명 여부 (0: 실명, 1: 익명)',
},
generateCreatedAtColumn(),
],
foreignKeys: [
{
referencedTableName: 'user',
referencedColumnNames: ['id'],
columnNames: ['user_id'],
onDelete: 'NO ACTION',
onUpdate: 'NO ACTION',
},
{
referencedTableName: 'notice_board_history',
referencedColumnNames: ['id'],
columnNames: ['notice_board_history_id'],
onDelete: 'NO ACTION',
onUpdate: 'NO ACTION',
},
],
}),
);
await queryRunner.query(
'ALTER TABLE notice_board_comment_history COMMENT = "공지 게시글 댓글 수정이력"',
);

// 공지 게시글 대댓글 수정이력
await queryRunner.createTable(
new Table({
name: 'notice_board_reply_comment_history',
columns: [
generatePrimaryColumn('공지 게시글 대댓글 수정이력 고유 ID'),
{
name: 'notice_board_history_id',
type: 'int',
unsigned: true,
isNullable: false,
comment: '게시글 고유 ID',
},
{
name: 'notice_board_comment_history_id',
type: 'int',
unsigned: true,
isNullable: false,
comment: '공지 게시글 댓글 고유 ID',
},
{
name: 'user_id',
type: 'int',
unsigned: true,
isNullable: false,
comment: '대댓글 작성 유저 고유 ID',
},
{
name: 'description',
type: 'varchar',
length: '255',
isNullable: false,
comment: '대댓글 본문',
},
{
name: 'is_anonymous',
type: 'boolean',
default: 0,
isNullable: false,
comment: '작성자 익명 여부 (0: 실명, 1: 익명)',
},
generateCreatedAtColumn(),
],
foreignKeys: [
{
referencedTableName: 'user',
referencedColumnNames: ['id'],
columnNames: ['user_id'],
onDelete: 'NO ACTION',
onUpdate: 'NO ACTION',
},
{
referencedTableName: 'notice_board_history',
referencedColumnNames: ['id'],
columnNames: ['notice_board_history_id'],
onDelete: 'NO ACTION',
onUpdate: 'NO ACTION',
},
{
referencedTableName: 'notice_board_comment_history',
referencedColumnNames: ['id'],
columnNames: ['notice_board_comment_history_id'],
onDelete: 'NO ACTION',
onUpdate: 'NO ACTION',
},
],
}),
);
await queryRunner.query(
'ALTER TABLE notice_board_reply_comment_history COMMENT = "공지 게시판 대댓글 수정이력"',
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.dropTable(
new Table({ name: 'notice_board_reply_comment_history' }),
);
await queryRunner.dropTable(
new Table({ name: 'notice_board_comment_history' }),
);
await queryRunner.dropTable(new Table({ name: 'notice_board_history' }));
}
}
123 changes: 123 additions & 0 deletions migrations/1701696068699-notice-board-change-column-name.ts
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

얜 칼럼명 변경하면서 사용한 마이그레이션데 삭제해야 할 것 같으면 지우겠습니다.

Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
// import { MigrationInterface, QueryRunner, TableColumn } from 'typeorm';

// export class NoticeBoardChangeColumnName1701696068699
// implements MigrationInterface
// {
// public async up(queryRunner: QueryRunner): Promise<void> {
// await queryRunner.changeColumn(
// 'notice_board',
// 'allow_comment',
// new TableColumn({
// name: 'is_allow_comment',
// type: 'boolean',
// default: true,
// isNullable: false,
// comment: '댓글 허용 여부 (0: 비활성화, 1: 허용)',
// }),
// );

// await queryRunner.changeColumn(
// 'notice_board_comment',
// 'isAnonymous',
// new TableColumn({
// name: 'is_anonymous',
// type: 'tinyint',
// }),
// );

// await queryRunner.changeColumn(
// 'notice_board_reply_comment',
// 'isAnonymous',
// new TableColumn({
// name: 'is_anonymous',
// type: 'tinyint',
// }),
// );

// await queryRunner.changeColumn(
// 'notice_board_history',
// 'allow_comment',
// new TableColumn({
// name: 'is_allow_comment',
// type: 'boolean',
// default: true,
// isNullable: false,
// comment: '댓글 허용 여부 (0: 비활성화, 1: 허용)',
// }),
// );

// await queryRunner.changeColumn(
// 'notice_board_comment_history',
// 'isAnonymous',
// new TableColumn({
// name: 'is_anonymous',
// type: 'tinyint',
// }),
// );

// await queryRunner.changeColumn(
// 'notice_board_reply_comment_history',
// 'isAnonymous',
// new TableColumn({
// name: 'is_anonymous',
// type: 'tinyint',
// }),
// );
// }

// public async down(queryRunner: QueryRunner): Promise<void> {
// await queryRunner.changeColumn(
// 'notice_board',
// 'is_allow_comment',
// new TableColumn({
// name: 'allow_comment',
// type: 'boolean',
// }),
// );

// await queryRunner.changeColumn(
// 'notice_board_comment',
// 'is_anonymous',
// new TableColumn({
// name: 'isAnonymous',
// type: 'tinyint',
// }),
// );

// await queryRunner.changeColumn(
// 'notice_board_reply_comment',
// 'is_anonymous',
// new TableColumn({
// name: 'isAnonymous',
// type: 'tinyint',
// }),
// );

// await queryRunner.changeColumn(
// 'notice_board_history',
// 'is_allow_comment',
// new TableColumn({
// name: 'allow_comment',
// type: 'boolean',
// }),
// );

// await queryRunner.changeColumn(
// 'notice_board_comment_history',
// 'is_anonymous',
// new TableColumn({
// name: 'isAnonymous',
// type: 'tinyint',
// }),
// );

// await queryRunner.changeColumn(
// 'notice_board_reply_comment_history',
// 'is_anonymous',
// new TableColumn({
// name: 'isAnonymous',
// type: 'tinyint',
// }),
// );
// }
// }
Loading