Skip to content

Commit

Permalink
Revert "2-5-1 브랜드 추가"
Browse files Browse the repository at this point in the history
This reverts commit 165ca87.
  • Loading branch information
Taehoya committed Jul 19, 2023
1 parent 165ca87 commit 91155d3
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 131 deletions.
11 changes: 0 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
"license": "GNU",
"private": true,
"dependencies": {
"@babel/plugin-proposal-class-properties": "^7.16.7",
"@babel/preset-env": "^7.16.11",
"@babel/preset-typescript": "^7.16.7",
"@babel/plugin-proposal-decorators": "^7.22.3",
"@babel/plugin-proposal-class-properties": "^7.16.7",
"@babel/plugin-proposal-object-rest-spread": "^7.17.3",
"@babel/plugin-transform-runtime": "^7.17.0",
"@babel/preset-env": "^7.16.11",
"@babel/preset-typescript": "^7.16.7",
"@opensearch-project/opensearch": "^1.2.0",
"aws-sdk": "^2.1101.0",
"babel-plugin-module-resolver": "^4.1.0",
Expand All @@ -41,7 +41,6 @@
"discord-webhook-node": "^1.1.8",
"dotenv": "^16.0.0",
"express": "^4.17.3",
"hangul-js": "^0.2.6",
"ioredis": "^5.2.4",
"js-yaml": "^4.1.0",
"jsonwebtoken": "^9.0.0",
Expand Down
79 changes: 6 additions & 73 deletions src/controllers/Admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
import { ListAndCountDTO } from '@src/data/dto';
import IngredientCategoryService from '@src/service/IngredientCategoryService';
import { DuplicatedEntryError } from '@src/utils/errors/errors';
import * as Hangul from 'hangul-js';

let Admin: AdminService = new AdminService();
let Perfume: PerfumeService = new PerfumeService();
let Ingredient: IngredientService = new IngredientService();
Expand Down Expand Up @@ -487,22 +487,22 @@ export const createIngredientCategory: RequestHandler = async (
* type: object
* x-swagger-router-controll er: Admin
* definitions:
* Brand:
* Brand:
* type: object
* properties:
* properties:
* brandIdx:
* type: integer
* name:
* type: string
* Note:
* Note:
* type: object
* properties:
* perfumeIdx:
* type: integer
* ingredientIdx:
* type: integer
* type:
*
* type:
*
*/
export const createPerfume: RequestHandler = async (
req: Request,
Expand Down Expand Up @@ -604,70 +604,3 @@ export const getBrandAll: RequestHandler = async (
);
};

/**
* @swagger
* /admin/brand:
* post:
* tags:
* - admin
* summary: 브랜드 추가
* description: 브랜드 추가
* operationId: createBrand
* consumes:
* - application/json
* produces:
* - application/json
* parameters:
* - name: body
* in: body
* required: true
* schema:
* type: object
* properties:
* name:
* type: string
* englishName:
* type: string
* description:
* type: string
* responses:
* 200:
* description: success
* schema:
* type: object
* properties:
* message:
* type: string
* example: 성공
* 400:
* description: 요청 실패
* 409:
* description: 같은 이름의 브랜드가 존재할 때
* schema:
* type: object
* x-swagger-router-controller: Admin
*
*/
export const createBrand: RequestHandler = async (
req: Request,
res: Response
) => {
const { name, englishName, description } = req.body;
try {
const firstInitail = Hangul.disassemble(name)[0];
await Brand.create(name, englishName, description, firstInitail);
res.status(StatusCode.OK).json({
message: '성공',
});
} catch (e: any) {
if (e instanceof DuplicatedEntryError) {
res.status(StatusCode.CONFLICT).json(
new ResponseDTO(MSG_EXIST_DUPLICATE_ENTRY, false)
);
} else {
res.status(StatusCode.BAD_REQUEST).json(
new SimpleResponseDTO(e.message)
);
}
}
};
14 changes: 0 additions & 14 deletions src/dao/BrandDao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,6 @@ class BrandDao {
order: [['createdAt', 'desc']],
});
}

async create(
name: string,
englishName: string,
description: string,
firstInitial: string
) {
return Brand.create({
name,
englishName,
description,
firstInitial,
});
}
}

export default BrandDao;
1 change: 0 additions & 1 deletion src/models/tables/Brand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export class Brand extends Model {
@Column({
type: DataType.STRING,
allowNull: false,
defaultValue: '',
})
imageUrl: string;

Expand Down
28 changes: 0 additions & 28 deletions src/service/BrandService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ import {
BrandDTO,
PagingDTO,
} from '@dto/index';
import {
DuplicatedEntryError,
FailedToCreateError,
} from '@src/utils/errors/errors';

const LOG_TAG: string = '[Brand/Service]';

Expand Down Expand Up @@ -81,30 +77,6 @@ class BrandService {
const list = rows.map((brand) => BrandDTO.createByJson(brand));
return new ListAndCountDTO(count, list);
}

async create(
name: string,
englishName: string,
description: string,
firstInitial: string
) {
try {
return await this.brandDao.create(
name,
englishName,
description,
firstInitial
);
} catch (err: Error | any) {
if (
err.original.code === 'ER_DUP_ENTRY' ||
err.parent.errno === 1062
) {
throw new DuplicatedEntryError();
}
throw new FailedToCreateError();
}
}
}

export default BrandService;

0 comments on commit 91155d3

Please sign in to comment.