-
Notifications
You must be signed in to change notification settings - Fork 5
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
Showing
32 changed files
with
2,321 additions
and
450 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,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))); | ||
} |
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,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); | ||
} | ||
} |
Oops, something went wrong.