Skip to content

Commit

Permalink
fix: refreshToken dev 머지시 충돌에러 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
cchoiGeon committed Aug 12, 2024
2 parents 000c5d2 + aa5e7b0 commit 83b8a26
Show file tree
Hide file tree
Showing 32 changed files with 2,321 additions and 450 deletions.
192 changes: 176 additions & 16 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
"license": "ISC",
"devDependencies": {
"@babel/cli": "^7.24.8",
"@babel/core": "^7.24.8",
"@babel/core": "^7.24.9",
"@babel/node": "^7.24.8",
"@babel/preset-env": "^7.24.8",
"eslint": "^9.6.0",
"eslint": "^9.7.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-prettier": "^5.2.1",
"nodemon": "^3.1.4",
"prettier": "^3.3.2",
"prettier": "^3.3.3",
"swagger-cli": "^4.0.4",
"swagger-jsdoc": "^6.2.8",
"swagger-ui-express": "^5.0.1"
Expand All @@ -38,8 +38,10 @@
"express-async-handler": "^1.2.0",
"http-status-codes": "^2.3.0",
"jsonwebtoken": "^9.0.2",
"multer": "1.4.5-lts.1",
"mysql2": "^3.10.3",
"sequelize": "^6.37.3",
"swagger-ui-dist": "^5.17.14",
"yamljs": "^0.3.0"
}
}
1,288 changes: 896 additions & 392 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

Binary file added private/uploads/1723180160809-무신사1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added private/uploads/1723180165246-무신사1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added private/uploads/1723180185135-무신사1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added private/uploads/1723180197525-무신사1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added private/uploads/1723180198725-무신사1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added private/uploads/1723180200048-무신사1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added private/uploads/1723180490374-무신사1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added private/uploads/1723180632184-무신사1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added private/uploads/1723181125376-무신사1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 15 additions & 1 deletion src/config/db.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Import the dotenv module to load environment variables from the .env file
import dotenv from 'dotenv';
import mysql from 'mysql2/promise';


// Configure dotenv to load variables
dotenv.config();
Expand Down Expand Up @@ -27,4 +29,16 @@ export const config = {
host: process.env.DB_HOST,
dialect: process.env.DB_DIALECT
}
};
};



export const pool = mysql.createPool({
host: process.env.DB_HOST,
user: process.env.DB_USERNAME,
database: process.env.DB_DATABASE,
password: process.env.DB_PASSWORD,
waitForConnections: true,
connectionLimit: 10,
queueLimit: 0
});
23 changes: 23 additions & 0 deletions src/domains/search/search.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { response } from "../../config/response.js";
import { status } from "../../config/response.status.js";
import { getSearch, getCloth, getSearchResult, getSearchBrand } from "./search.provider.js";

export const searchPreview = async (req, res, next) => {
console.log("검색 메인화면을 조회합니다");
res.send(response(status.SUCCESS, await getSearch(req.query)));
}

export const clothView = async (req, res, next) => {
console.log("아이템 상세정보를 조회합니다");
res.send(response(status.SUCCESS, await getCloth(req.params.clothId)));
}

export const searchView = async (req, res, next) => {
console.log("검색 결과를 조회합니다");
res.send(response(status.SUCCESS, await getSearchResult(req.query)));
}

export const brandView = async (req, res, next) => {
console.log("브랜드 검색 결과를 조회합니다");
res.send(response(status.SUCCESS, await getSearchBrand(req.params.brandId, req.query)));
}
199 changes: 199 additions & 0 deletions src/domains/search/search.dao.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
import { query } from "express";
import { pool } from "../../config/db.config.js";
import { BaseError } from "../../config/error.js";
import { status } from "../../config/response.status.js";
import { UserNicknameToClothIdAtFirst, UserNicknameToClothId, UserCategoryToClothIdAtFirst, UserCategoryToClothId,
getClothByClothId, getUserIdToClothId, getUser, getFitToUserId, getStyleToUserId,
UserNicknameToClothNameAtFirst, UserNicknameToClothName, UserCategoryToClothNameAtFirst, UserCategoryToClothName,
brandToBrandName, userIdToNickname, userToNickname, getBrandToBrandId, UserNicknameToBrand } from "./search.sql.js";

// nickname+cloth 반환
export const getNicknameToClothId = async (category, size, cursorId) => {
try {
const conn = await pool.getConnection();

console.log("카테고리 : ", category);
console.log("옷 id : ", cursorId);
if(category == "undefined" || typeof category == "undefined" || category == null){
if(cursorId == "undefined" || typeof cursorId == "undefined" || cursorId == null){
const [data] = await pool.query(UserNicknameToClothIdAtFirst, [size]);
conn.release();
console.log("dao1", data);
return data;
}else{
const [data] = await pool.query(UserNicknameToClothId, [cursorId, size]);
conn.release();
console.log("dao2", data);
return data;
}
}else{
if(cursorId == "undefined" || typeof cursorId == "undefined" || cursorId == null){
const [data] = await pool.query(UserCategoryToClothIdAtFirst, [category, size]);
conn.release();
console.log("dao1", data);
return data;
}else{
const [data] = await pool.query(UserCategoryToClothId, [category, cursorId, size]);
conn.release();
console.log("dao2", data);
return data;
}
}
} catch (err) {
throw new BaseError(status.PARAMETER_IS_WRONG);
}
}

export const getPreviewCloth = async (clothId) => {
try {
console.log("dao getPreviewCloth");
const conn = await pool.getConnection();
const cloth = await pool.query(getClothByClothId, clothId);

conn.release();

return cloth;
} catch (err) {
throw new BaseError(status.PARAMETER_IS_WRONG);
}
}

// user 정보 반환
export const getUserToClothId = async (clothId) => {
try {
console.log("dao getUserToClothId");
const conn = await pool.getConnection();
const userData =await pool.query(getUserIdToClothId, clothId);

const userId = userData[0][0].uuid;
const user = await pool.query(getUser, userId);
const fit = await pool.query(getFitToUserId, userId);
const style = await pool.query(getStyleToUserId, userId);

if(user.length == 0){
return -1;
}

conn.release();
return [ user, fit, style ];

} catch (err) {
throw new BaseError(status.PARAMETER_IS_WRONG);
}
}


// nickname+cloth 반환
export const getNicknameToClothName = async (clothName, category, size, cursorId) => {
try {
const conn = await pool.getConnection();

if(typeof category == "undefined" || category == null){
if(typeof cursorId == "undefined" || cursorId == null){
const [data] = await pool.query(UserNicknameToClothNameAtFirst, [clothName, size]);
conn.release();
return data;
}else{
const [data] = await pool.query(UserNicknameToClothName, [clothName, cursorId, size]);
conn.release();
return data;
}
}else{
if(typeof cursorId == "undefined" || cursorId == null){
const [data] = await pool.query(UserCategoryToClothNameAtFirst, [clothName, category, size]);
conn.release();
return data;
}else{
const [data] = await pool.query(UserCategoryToClothName, [clothName, category, cursorId, size]);
conn.release();
return data;
}
}
} catch (err) {
throw new BaseError(status.PARAMETER_IS_WRONG);
}
}

// 통합검색 brand 조회
export const getPreviewBrand = async (brandName) => {
try {
const conn = await pool.getConnection();
console.log("\ndao brand", brandName);
const [data] = await pool.query(brandToBrandName, brandName);
console.log(data);
conn.release();
return data;
} catch (err) {
throw new BaseError(status.PARAMETER_IS_WRONG);
}
}

// 통합검색 user 조회
export const getPreviewUser = async (userName) => {
try {
const conn = await pool.getConnection();
const [userData] = await pool.query(userIdToNickname, userName);
console.log("\nuser :", userData);

const result = [];
for (let i = 0; i < userData.length; i++) {
const userId = userData[i].uuid;
console.log("userId ", userId);
const [user] = await pool.query(userToNickname, userId);
const [fit] = await pool.query(getFitToUserId, userId);
const [style] = await pool.query(getStyleToUserId, userId);
console.log(user, fit, style);
result.push({user, fit, style});
}
conn.release();
return result;
} catch (err) {
throw new BaseError(status.PARAMETER_IS_WRONG);
}
}


// brand 상세 조회
export const getBrand = async (brandId) => {
try {
const conn = await pool.getConnection();
const [brand] = await pool.query(getBrandToBrandId, brandId);

conn.release();
return brand;
} catch (err) {
throw new BaseError(status.PARAMETER_IS_WRONG);
}
}

// brand cloth 조회
export const getNicknameToBrand = async (brandId, clothName, category, size) => {
try {
const conn = await pool.getConnection();
let query = UserNicknameToBrand;

if(typeof clothName == "undefined" && typeof category == "undefined"){
query += "ORDER BY c.id DESC LIMIT ? ;";
const [data] = await pool.query(query, [brandId, size]);
conn.release();
return data;
}else if(typeof clothName == "undefined"){
query += "WHERE c.category_id = ? ORDER BY c.id DESC LIMIT ? ;"
const [data] = await pool.query(query, [brandId, category, size]);
conn.release();
return data;
}else if(typeof category == "undefined"){
query += "WHERE c.name REGEXP ? ORDER BY c.id DESC LIMIT ? ;"
const [data] = await pool.query(query, [brandId, clothName, size]);
conn.release();
return data;
}else{
query += "WHERE c.name REGEXP ? AND c.category_id = ? ORDER BY c.id DESC LIMIT ? ;"
const [data] = await pool.query(query, [brandId, clothName, category, size]);
conn.release();
return data;
}
} catch (err) {
throw new BaseError(status.PARAMETER_IS_WRONG);
}
}
Loading

0 comments on commit 83b8a26

Please sign in to comment.