-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
โฆrUser [BE][Feat] #159 : ํ์๊ฐ์ api ๊ตฌํ, [BE][Refactor] swagger ๋ฌธ์ tag ์ถ๊ฐ, jsdoc ์ถ๊ฐ
- Loading branch information
Showing
9 changed files
with
210 additions
and
22 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
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
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 |
---|---|---|
@@ -1,6 +1,46 @@ | ||
import { pool } from '../db/db.js'; | ||
|
||
/** | ||
* @description ๋ฐ์ดํฐ๋ฒ ์ด์ค์ ์๋ก์ด ์ฌ์ฉ์ ์์ฑ | ||
* @param {string} id - ์ฌ์ฉ์ id | ||
* @returns {object} id๋ก ์ฐพ์ ์ฌ์ฉ์ ์ ๋ณด | ||
*/ | ||
export const findUserById = async id => { | ||
const result = await pool.query('SELECT * FROM "main"."user" WHERE id = $1', [id]); | ||
return result.rows[0]; | ||
}; | ||
|
||
/** | ||
* @description ์ฌ์ฉ์ ID ์ค๋ณต ์ฌ๋ถ ํ์ธ | ||
* @param {string} id - ์ฌ์ฉ์ ID | ||
* @returns {boolean} ์ค๋ณต ์ฌ๋ถ | ||
*/ | ||
export const isUserIdDuplicate = async id => { | ||
const query = ` | ||
SELECT 1 FROM "main"."user" | ||
WHERE id = $1; | ||
`; | ||
const result = await pool.query(query, [id]); | ||
|
||
return result.rows.length > 0; | ||
}; | ||
|
||
/** | ||
* @description ๋ฐ์ดํฐ๋ฒ ์ด์ค์ ์๋ก์ด ์ฌ์ฉ์ ์์ฑ | ||
* @param {string} id - ์ฌ์ฉ์ ID | ||
* @param {string} name - ์ฌ์ฉ์ ์ด๋ฆ | ||
* @param {string} password - ์ฌ์ฉ์ ๋น๋ฐ๋ฒํธ | ||
* @param {string} email - ์ฌ์ฉ์ ์ด๋ฉ์ผ | ||
* @returns {object} ์๋ก ์์ฑ๋ ์ฌ์ฉ์ ์ ๋ณด | ||
*/ | ||
export const createUserInDB = async (id, name, password, email) => { | ||
const query = ` | ||
INSERT INTO "main"."user" (id, name, password, email) | ||
VALUES ($1, $2, $3, $4) | ||
RETURNING id, name, email; | ||
`; | ||
const values = [id, name, password, email]; | ||
const result = await pool.query(query, values); | ||
|
||
return result.rows[0]; | ||
}; |
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
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
Oops, something went wrong.