-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5f9ec6e
Showing
38 changed files
with
6,770 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module.exports = { | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
project: 'tsconfig.json', | ||
tsconfigRootDir: __dirname, | ||
sourceType: 'module', | ||
}, | ||
plugins: ['@typescript-eslint/eslint-plugin'], | ||
extends: [ | ||
'plugin:@typescript-eslint/recommended', | ||
'plugin:prettier/recommended', | ||
], | ||
root: true, | ||
env: { | ||
node: true, | ||
jest: true, | ||
}, | ||
ignorePatterns: ['.eslintrc.js'], | ||
rules: { | ||
'@typescript-eslint/interface-name-prefix': 'off', | ||
'@typescript-eslint/explicit-function-return-type': 'off', | ||
'@typescript-eslint/explicit-module-boundary-types': 'off', | ||
'@typescript-eslint/no-explicit-any': 'off', | ||
'@typescript-eslint/ban-ts-comment': 'off' | ||
}, | ||
}; |
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,35 @@ | ||
# compiled output | ||
/dist | ||
/node_modules | ||
|
||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
pnpm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
|
||
# OS | ||
.DS_Store | ||
|
||
# Tests | ||
/coverage | ||
/.nyc_output | ||
|
||
# IDEs and editors | ||
/.idea | ||
.project | ||
.classpath | ||
.c9/ | ||
*.launch | ||
.settings/ | ||
*.sublime-workspace | ||
|
||
# IDE - VSCode | ||
.vscode/* | ||
!.vscode/settings.json | ||
!.vscode/tasks.json | ||
!.vscode/launch.json | ||
!.vscode/extensions.json |
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,8 @@ | ||
MAINDB_HOST="127.0.0.1" | ||
MAINDB_PORT="3306" | ||
MAINDB_DATABASE="main_test" | ||
MAINDB_USERNAME="root" | ||
MAINDB_PASSWORD="test1234" | ||
MAINDB_DIALECT="mariadb" | ||
|
||
API_PORT=5001 |
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,8 @@ | ||
{ | ||
"tabWidth": 2, | ||
"semi": false, | ||
"singleQuote": true, | ||
"jsxSingleQuote": true, | ||
"endOfLine": "lf", | ||
"printWidth": 90 | ||
} |
97 changes: 97 additions & 0 deletions
97
api/src/app/OpEmailTemplate/OpEmailTemplate.controller.e2e-spec.ts
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,97 @@ | ||
import { Test, TestingModule } from '@nestjs/testing' | ||
import { OpEmailTemplateController } from './OpEmailTemplate.controller' | ||
import { OpEmailTemplateService } from './OpEmailTemplate.service' | ||
import { TypeOrmModule } from '@nestjs/typeorm' | ||
import { OpEmailTemplateEntity } from './OpEmailTemplate.entity' | ||
import { ConfigModule, ConfigService } from '@nestjs/config' | ||
import { validate } from '#helpers/ConfigValidator' | ||
import { OpEmailTemplateData } from './OpEmailTemplate.interface' | ||
|
||
describe('OpEmailTemplate (e2e)', () => { | ||
const opEmailTemplateSampleData = { | ||
idx: 0, | ||
name: 'test', | ||
serviceKey: `serviceKey${new Date().getTime()}`, | ||
titleEn: 'title', | ||
titleKo: '제목', | ||
contentEn: 'content', | ||
contentKo: '내용', | ||
} as OpEmailTemplateData | ||
let opEmailTemplateController: OpEmailTemplateController | ||
beforeEach(async () => { | ||
const moduleFixture: TestingModule = await Test.createTestingModule({ | ||
imports: [ | ||
ConfigModule.forRoot({ | ||
isGlobal: true, | ||
envFilePath: `.${process.env.NODE_ENV}.env`, | ||
validate: validate, | ||
}), | ||
TypeOrmModule.forRootAsync({ | ||
imports: [ConfigModule], | ||
inject: [ConfigService], | ||
useFactory: (config: ConfigService) => { | ||
console.log | ||
return { | ||
autoLoadEntities: true, | ||
host: config.get('MAINDB_HOST'), | ||
port: config.get('MAINDB_PORT'), | ||
database: config.get('MAINDB_DATABASE') as string, | ||
username: config.get('MAINDB_USERNAME'), | ||
password: config.get('MAINDB_PASSWORD'), | ||
type: config.get('MAINDB_DIALECT') as any, | ||
logging: false, | ||
synchronize: true, | ||
} | ||
}, | ||
}), | ||
TypeOrmModule.forFeature([OpEmailTemplateEntity]), | ||
], | ||
controllers: [OpEmailTemplateController], | ||
providers: [OpEmailTemplateService], | ||
}).compile() | ||
opEmailTemplateController = moduleFixture.get<OpEmailTemplateController>( | ||
OpEmailTemplateController | ||
) | ||
}) | ||
describe('이메일 템플릿 생성', () => { | ||
it('/email (PUT) - create', async () => { | ||
const { idx, ...opEmailTemplateInfoOnly } = opEmailTemplateSampleData | ||
const result = await opEmailTemplateController.createEmailTemplate( | ||
opEmailTemplateInfoOnly | ||
) | ||
opEmailTemplateSampleData.idx = result.data?.idx || 0 | ||
expect(result.data).toBeInstanceOf(OpEmailTemplateEntity) | ||
}) | ||
}) | ||
describe('이메일 템플릿 활동', () => { | ||
it('/email/list (GET)', async () => { | ||
const result = await opEmailTemplateController.getEmailTemplateList({ | ||
pageSize: 10, | ||
pageNumber: 1, | ||
}) | ||
expect(result.data).toBeInstanceOf(Array<OpEmailTemplateEntity>) | ||
}) | ||
it(`/email/{idx} (GET)`, async () => { | ||
const result = await opEmailTemplateController.getEmailTemplateByIdx( | ||
opEmailTemplateSampleData.idx || 0 | ||
) | ||
expect(result.data).toBeInstanceOf(OpEmailTemplateEntity) | ||
}) | ||
it(`/email/{idx} (POST)`, async () => { | ||
opEmailTemplateSampleData.contentEn = 'testtest' | ||
const result = await opEmailTemplateController.updateEmailTemplateByIdx( | ||
opEmailTemplateSampleData.idx || 0, | ||
opEmailTemplateSampleData | ||
) | ||
expect(result.data).toBeInstanceOf(OpEmailTemplateEntity) | ||
}) | ||
}) | ||
describe('이메일 템플릿 제거', () => { | ||
it(`/email/{idx} (DELETE)`, async () => { | ||
const result = await opEmailTemplateController.deleteEmailTemplateByIdx( | ||
opEmailTemplateSampleData.idx || 0 | ||
) | ||
expect(result.code).toBe(200) | ||
}) | ||
}) | ||
}) |
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,47 @@ | ||
import { Controller, Get, Query, Body, Post, Put, Param, Delete } from '@nestjs/common' | ||
import { OpEmailTemplateService } from './OpEmailTemplate.service' | ||
import { ApiTags } from '@nestjs/swagger' | ||
import { Response } from '#helpers/ResponseHelper' | ||
import { | ||
OpEmailTemplateData, | ||
OpEmailTemplatePagingData, | ||
} from './OpEmailTemplate.interface' | ||
|
||
@ApiTags('OpEmailTemplate') | ||
@Controller('/email') | ||
export class OpEmailTemplateController { | ||
constructor(private readonly opEmailTemplateService: OpEmailTemplateService) {} | ||
@Get('list') | ||
async getEmailTemplateList(@Query() pagingData: OpEmailTemplatePagingData) { | ||
const result = await this.opEmailTemplateService.getEmailTemplateList( | ||
pagingData.pageSize, | ||
pagingData.pageNumber, | ||
pagingData.startAt, | ||
pagingData.finishAt | ||
) | ||
return Response.success(result) | ||
} | ||
@Put() | ||
async createEmailTemplate(@Body() body: OpEmailTemplateData) { | ||
const result = await this.opEmailTemplateService.createEmailTemplate(body) | ||
return Response.success(result) | ||
} | ||
@Get(':idx') | ||
async getEmailTemplateByIdx(@Param('idx') idx: number) { | ||
const result = await this.opEmailTemplateService.getEmailTemplateByIdx(idx) | ||
return Response.success(result) | ||
} | ||
@Post(':idx') | ||
async updateEmailTemplateByIdx( | ||
@Param('idx') idx: number, | ||
@Body() body: OpEmailTemplateData | ||
) { | ||
const result = await this.opEmailTemplateService.updateEmailTemplateByIdx(idx, body) | ||
return Response.success(result) | ||
} | ||
@Delete(':idx') | ||
async deleteEmailTemplateByIdx(@Param('idx') idx: number) { | ||
const result = await this.opEmailTemplateService.deleteEmailTemplateByIdx(idx) | ||
return Response.success(result) | ||
} | ||
} |
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,76 @@ | ||
import { DateHelpers } from '#helpers/DateHelpers' | ||
import { BeforeInsert, Column, Entity, Index, PrimaryGeneratedColumn } from 'typeorm' | ||
|
||
@Index('key_UNIQUE', ['serviceKey'], { unique: true }) | ||
@Entity('op_email_template') | ||
export class OpEmailTemplateEntity { | ||
@PrimaryGeneratedColumn({ type: 'int', name: 'idx', unsigned: true }) | ||
idx: number | ||
|
||
@Column('varchar', { | ||
name: 'name', | ||
nullable: true, | ||
comment: '목적', | ||
length: 45, | ||
}) | ||
name?: string | ||
|
||
@Column('varchar', { | ||
name: 'service_key', | ||
nullable: true, | ||
unique: true, | ||
comment: '서비스 연동 키', | ||
length: 45, | ||
}) | ||
serviceKey?: string | ||
|
||
@Column('varchar', { | ||
name: 'title_ko', | ||
nullable: true, | ||
comment: '메일 제목', | ||
length: 255, | ||
}) | ||
titleKo?: string | ||
|
||
@Column('text', { name: 'content_ko', nullable: true, comment: '메일 내용' }) | ||
contentKo?: string | ||
|
||
@Column('varchar', { | ||
name: 'title_en', | ||
nullable: true, | ||
comment: '메일 제목', | ||
length: 255, | ||
}) | ||
titleEn?: string | ||
|
||
@Column('text', { name: 'content_en', nullable: true, comment: '메일 내용' }) | ||
contentEn?: string | ||
|
||
@Column('int', { | ||
name: 'use_flag', | ||
comment: '1 : 정상 | 9 : 삭제', | ||
default: () => "'1'", | ||
}) | ||
useFlag: number | ||
|
||
@Column('varchar', { | ||
name: 'set_date', | ||
comment: '생성일시 한국시간 datetime', | ||
length: 45, | ||
}) | ||
setDate: string | ||
|
||
@Column('int', { | ||
name: 'created_at', | ||
comment: '생성일시 UTC timestamp', | ||
default: () => "'0'", | ||
}) | ||
createdAt: number | ||
|
||
@BeforeInsert() | ||
initDate() { | ||
this.setDate = DateHelpers.getCurrentUTCDateTime() | ||
this.createdAt = DateHelpers.getCurrentUCTimestamp() | ||
this.useFlag = 1 | ||
} | ||
} |
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,24 @@ | ||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger' | ||
|
||
export class OpEmailTemplateData { | ||
idx?: number | ||
name?: string | ||
serviceKey?: string | ||
titleKo?: string | ||
contentKo?: string | ||
titleEn?: string | ||
contentEn?: string | ||
useFlag?: number | ||
setDate?: string | ||
createdAt?: number | ||
} | ||
export class OpEmailTemplatePagingData { | ||
@ApiProperty() | ||
pageSize: number | ||
@ApiProperty() | ||
pageNumber: number | ||
@ApiPropertyOptional() | ||
startAt?: string | ||
@ApiPropertyOptional() | ||
finishAt?: string | ||
} |
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,24 @@ | ||
import { MiddlewareConsumer } from '@nestjs/common' | ||
import { Module } from '@nestjs/common' | ||
import { NestModule } from '@nestjs/common' | ||
import { TypeOrmModule } from '@nestjs/typeorm' | ||
import { OpEmailTemplateController } from './OpEmailTemplate.controller' | ||
import { OpEmailTemplateEntity } from './OpEmailTemplate.entity' | ||
import { OpEmailTemplateService } from './OpEmailTemplate.service' | ||
|
||
@Module({ | ||
imports: [TypeOrmModule.forFeature([OpEmailTemplateEntity])], | ||
providers: [OpEmailTemplateService], | ||
controllers: [OpEmailTemplateController], | ||
exports: [OpEmailTemplateService], | ||
}) | ||
export class OpEmailTemplateModule implements NestModule { | ||
public configure(consumer: MiddlewareConsumer) { | ||
// consumer | ||
// .apply(AuthMiddleware) | ||
// .forRoutes( | ||
// { path: 'user', method: RequestMethod.GET }, | ||
// { path: 'user', method: RequestMethod.PUT } | ||
// ) | ||
} | ||
} |
Oops, something went wrong.