@ninebone/mcp 0.1.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.kr.md +71 -0
- package/README.md +72 -0
- package/bak/generate-query.md +28 -0
- package/bak/generator-source-mapper.md +123 -0
- package/bak/mcp-server.js +498 -0
- package/bak/nomenu-navigator.md +16 -0
- package/bak/system-brain.md +62 -0
- package/bak/table-filter.md +21 -0
- package/package.json +33 -0
- package/prompts/menu/generate-menu.md +89 -0
- package/prompts/source/generate-source-controller.md +120 -0
- package/prompts/source/generate-source-mapper.mysql.md +97 -0
- package/prompts/source/generate-source-mapper.oracle.md +90 -0
- package/prompts/source/generate-source-mapper.postgre.md +89 -0
- package/prompts/source/generate-source-service.md +116 -0
- package/prompts/source/generate-source-ui-react.md +174 -0
- package/prompts/system/generate-source-brain.md +57 -0
- package/prompts/system/modify-source-brain.md +50 -0
- package/prompts/system/system-brain.md +88 -0
- package/src/ai/AIProcessor.js +85 -0
- package/src/ai/AIService.js +24 -0
- package/src/core/init.js +116 -0
- package/src/database/config/database.js +42 -0
- package/src/database/core/DatabaseManager.js +115 -0
- package/src/database/core/Dialects.js +66 -0
- package/src/database/core/PoolManager.js +92 -0
- package/src/drivers/mysql.js +0 -0
- package/src/index.js +38 -0
- package/src/mcp/loaders/promptLoader.js +62 -0
- package/src/mcp/mcp-server.js +129 -0
- package/src/mcp/tools/generateSourceBrainTool.js +179 -0
- package/src/mcp/tools/modifySourceBrainTool.js +283 -0
- package/src/mcp/tools/staticTools.js +29 -0
- package/src/mcp/tools/systemBrain.js +182 -0
- package/src/mcp/utils/mcp-utils.js +30 -0
- package/src/mcp-handler.js +131 -0
- package/src/services/NoMenuService.js +43 -0
- package/src/services/QueryService.js +26 -0
- package/src/services/SourceService.js +32 -0
- package/src/utils/CustomWsTransport.js +52 -0
- package/src/utils/asyncHandler.js +13 -0
package/README.kr.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
cat <<EOF > README.kr.md
|
|
2
|
+
# @nine-lab/nine-mcp ๐
|
|
3
|
+
|
|
4
|
+
[ํ๊ตญ์ด ๋ฌธ์(Korean)](./README.kr.md) | [English Document](./README.md)
|
|
5
|
+
|
|
6
|
+
์์ฐ์ด ๊ธฐ๋ฐ SQL ์์ฑ ์์ง(NineChat)๊ณผ ๋ฐ์ดํฐ๋ฒ ์ด์ค ์ฌ์ด๋ฅผ ์ฐ๊ฒฐํ๋ **AI ์ ์ฉ DB ์ปค๋ฅํฐ ์๋น์ค**์
๋๋ค.
|
|
7
|
+
|
|
8
|
+
๋ฐ์ดํฐ๋ฒ ์ด์ค์ ๊ตฌ์กฐ(Schema)๋ฅผ ๋ถ์ํ์ฌ AI๊ฐ ์ต์ ์ ์ฟผ๋ฆฌ๋ฅผ ์์ฑํ ์ ์๋๋ก ๋ธ๋ฆฟ์ง ์ญํ ์ ์ํํ๋ฉฐ, ๋ณด์์ด ๊ฒ์ฆ๋ ํ๊ฒฝ์์ ๋ฐ์ดํฐ๋ฅผ ์์ ํ๊ฒ ๋ฐํํฉ๋๋ค.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## ๐ ์ฃผ์ ๊ธฐ๋ฅ
|
|
13
|
+
|
|
14
|
+
* **์๋ ์ด๊ธฐํ**: \`nine-mcp init\` ๋ช
๋ น์ผ๋ก \`.env\` ์ค์ ๊ณผ AI ํ๋กฌํํธ ํ
ํ๋ฆฟ์ ์ฆ์ ๊ตฌ์ถํฉ๋๋ค.
|
|
15
|
+
* **Multi-DB ์ง์**: MySQL, PostgreSQL, MariaDB, Oracle ๋ฑ ๋ค์ํ ์ํฐํ๋ผ์ด์ฆ DB ํ๊ฒฝ์ ๋์ํฉ๋๋ค.
|
|
16
|
+
* **๋น์ฆ๋์ค ๋ก์ง ์ต์ ํ**: ํ๋กฌํํธ ํ์ผ ์์ ์ ํตํด ํน์ ํ
์ด๋ธ ์กฐํ ๊ธ์ง, ํํฐ๋ง ์กฐ๊ฑด ๊ฐ์ ๋ฑ ๊ณ ๊ฐ์ฌ๋ณ ๋ง์ถค ๊ท์น์ ์ ์ฉํ ์ ์์ต๋๋ค.
|
|
17
|
+
* **๋ณด์ ๊ฐ๋**: ๋ด๋ถ์ ์ผ๋ก ์ค์ง \`SELECT\` ์ฟผ๋ฆฌ๋ง ํ์ฉํ์ฌ ๋ฐ์ดํฐ ๋ณ์กฐ ๋ฐ ์ ์ถ์ ์์ฒ ์ฐจ๋จํฉ๋๋ค.
|
|
18
|
+
* **์ด์ ์์ ์ฑ**: BigInt ์ง๋ ฌํ ๋ฐ DB๋ณ ๊ฒฐ๊ณผ ํฌ๋งท ์ ๊ทํ๋ฅผ ํตํด ๋ฐ์ดํฐ ์ผ๊ด์ฑ์ ๋ณด์ฅํฉ๋๋ค.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## ๐ ์ค์น ๋ฐ ์ฌ์ฉ ๋ฐฉ๋ฒ
|
|
23
|
+
|
|
24
|
+
### 1. ํจํค์ง ์ค์น
|
|
25
|
+
\`\`\`bash
|
|
26
|
+
npm install -g @nine-lab/nine-mcp
|
|
27
|
+
\`\`\`
|
|
28
|
+
|
|
29
|
+
### 2. ํ๋ก์ ํธ ์ด๊ธฐํ (์ต์ด 1ํ)
|
|
30
|
+
์๋ฒ ์คํ ์ DB ์ ์ ์ ๋ณด ๋ฐ ํ๋กฌํํธ ํ๊ฒฝ ๊ตฌ์ฑ์ ์ํด ์คํํฉ๋๋ค.
|
|
31
|
+
\`\`\`bash
|
|
32
|
+
nine-mcp init
|
|
33
|
+
\`\`\`
|
|
34
|
+
|
|
35
|
+
### 3. ์๋ฒ ์คํ ๋ฐ ๊ด๋ฆฌ (PM2 ๊ถ์ฅ)
|
|
36
|
+
์๋ฒ์ ์์ ์ ์ธ ๊ธฐ๋๊ณผ ๋ก๊ทธ ๊ด๋ฆฌ๋ฅผ ์ํด ํ๋ก์ธ์ค ์ด๋ฆ์ ํจํค์ง๋ช
๊ณผ ๋์ผํ **nine-mcp**๋ก ๊ด๋ฆฌํ๋ ๊ฒ์ ๊ถ์ฅํฉ๋๋ค.
|
|
37
|
+
|
|
38
|
+
* **์๋ฒ ์์**:
|
|
39
|
+
\`\`\`bash
|
|
40
|
+
pm2 start nine-mcp --name "nine-mcp"
|
|
41
|
+
\`\`\`
|
|
42
|
+
* **์ํ ํ์ธ**:
|
|
43
|
+
\`\`\`bash
|
|
44
|
+
pm2 status
|
|
45
|
+
\`\`\`
|
|
46
|
+
* **๋ก๊ทธ ํ์ธ**:
|
|
47
|
+
\`\`\`bash
|
|
48
|
+
pm2 logs nine-mcp
|
|
49
|
+
\`\`\`
|
|
50
|
+
* **์๋ฒ ์ค์ง/์ฌ์์**:
|
|
51
|
+
\`\`\`bash
|
|
52
|
+
pm2 stop nine-mcp
|
|
53
|
+
pm2 restart nine-mcp
|
|
54
|
+
\`\`\`
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## ๐ ํ๋ก์ ํธ ๊ตฌ์กฐ ๋ฐ ์ปค์คํฐ๋ง์ด์ง
|
|
59
|
+
|
|
60
|
+
๊ธฐ๋ณธ์ ์ผ๋ก \`nine-query\` ์ปดํฌ๋ํธ์ ์ฐ๋๋์ด ๋์ํ๋ฉฐ, ์๋ ํ์ผ๋ค์ ํตํด ์ธ๋ถ ๋์์ ์ ์ดํ ์ ์์ต๋๋ค.
|
|
61
|
+
|
|
62
|
+
* **.env**: DB ์ ์ ์ ๋ณด ๋ฐ AI ๋ชจ๋ธ(Gemini) ์ค์ ๊ฐ
|
|
63
|
+
* **prompts/table-filter.md**: ์ง๋ฌธ์ ์ ํฉํ ํ
์ด๋ธ์ ์ฐพ์๋ด๋ AI์ ํ๋จ ๋ก์ง
|
|
64
|
+
* **prompts/query-generator.md**: ์ค์ SQL์ ์์ฑํ๋ AI์ ํ๋ฅด์๋ ๋ฐ ๊ท์น
|
|
65
|
+
* **๐ก Tip**: ์ด ํ์ผ์ \`[๊ณ ๊ฐ์ฌ ์ ์ฉ ๋น์ฆ๋์ค ๋ก์ง ๋ฐ ๋ณด์ ๊ท์น]\` ์น์
์ "ํน์ ๋ฏผ๊ฐ ํ
์ด๋ธ ์กฐํ ๊ธ์ง"๋ "๊ธฐ๋ณธ ์ ๋ ฌ/ํํฐ๋ง ๊ธฐ์ค"์ ๋ช
์ํ์ฌ AI์ ๋ต๋ณ์ ํต์ ํ ์ ์์ต๋๋ค.
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## ๐ ๋ผ์ด์ ์ค
|
|
70
|
+
MIT ยฉ **nine-lab**
|
|
71
|
+
EOF
|
package/README.md
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
cat <<EOF > README.md
|
|
2
|
+
# @nine-lab/nine-mcp ๐
|
|
3
|
+
|
|
4
|
+
[ํ๊ตญ์ด ๋ฌธ์(Korean)](./README.kr.md) | [English Document](./README.md)
|
|
5
|
+
|
|
6
|
+
**NineConnector** is an AI-specialized database connector service that bridges the gap between natural language SQL generation engines (**NineChat**) and your database.
|
|
7
|
+
|
|
8
|
+
It analyzes database schemas to provide AI models with the necessary metadata for optimal query generation and ensures secure data retrieval within a verified environment.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## ๐ Key Features
|
|
13
|
+
|
|
14
|
+
* **Auto-Initialization**: Instantly set up your environment with \`.env\` configurations and AI prompt templates using the \`nine-mcp init\` command.
|
|
15
|
+
* **Multi-DB Support**: Out-of-the-box compatibility with enterprise database environments including **MySQL, PostgreSQL, MariaDB, and Oracle**.
|
|
16
|
+
* **Business Logic Optimization**: Fine-tune AI behavior by customizing prompt files to enforce rules such as table access restrictions or mandatory filtering logic.
|
|
17
|
+
* **Security Guardrail**: Strictly restricts execution to \`SELECT\` queries to prevent unauthorized data modification or leakage.
|
|
18
|
+
* **Operational Stability**: Ensures data consistency through **BigInt serialization** and standardized result formatting across different DB dialects.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## ๐ Installation & Quick Start
|
|
23
|
+
|
|
24
|
+
### 1. Install Package
|
|
25
|
+
Install the package globally to access the CLI commands from anywhere.
|
|
26
|
+
\`\`\`bash
|
|
27
|
+
npm install -g @nine-lab/nine-mcp
|
|
28
|
+
\`\`\`
|
|
29
|
+
|
|
30
|
+
### 2. Initialize Project (First-time setup)
|
|
31
|
+
Run the initialization command to configure DB connection settings and generate prompt templates.
|
|
32
|
+
\`\`\`bash
|
|
33
|
+
nine-mcp init
|
|
34
|
+
\`\`\`
|
|
35
|
+
|
|
36
|
+
### 3. Server Execution & Management (PM2 Recommended)
|
|
37
|
+
For production environments, we highly recommend using **PM2** to ensure high availability and efficient log management.
|
|
38
|
+
|
|
39
|
+
* **Start Server**:
|
|
40
|
+
\`\`\`bash
|
|
41
|
+
pm2 start nine-mcp --name "nine-mcp"
|
|
42
|
+
\`\`\`
|
|
43
|
+
* **Check Status**:
|
|
44
|
+
\`\`\`bash
|
|
45
|
+
pm2 status
|
|
46
|
+
\`\`\`
|
|
47
|
+
* **View Logs**:
|
|
48
|
+
\`\`\`bash
|
|
49
|
+
pm2 logs nine-mcp
|
|
50
|
+
\`\`\`
|
|
51
|
+
* **Stop / Restart**:
|
|
52
|
+
\`\`\`bash
|
|
53
|
+
pm2 stop nine-mcp
|
|
54
|
+
pm2 restart nine-mcp
|
|
55
|
+
\`\`\`
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## ๐ Project Structure & Customization
|
|
60
|
+
|
|
61
|
+
Designed to work seamlessly with the \`nine-query\` component, you can control the AI's behavior via the following files:
|
|
62
|
+
|
|
63
|
+
* **.env**: Database credentials and AI model (e.g., Gemini) configurations.
|
|
64
|
+
* **prompts/table-filter.md**: AI logic for identifying relevant tables based on user intent.
|
|
65
|
+
* **prompts/query-generator.md**: Persona and rules for the SQL generation AI.
|
|
66
|
+
* **๐ก Tip**: Use the \`[Custom Business Logic & Security Rules]\` section in this file to enforce specific constraints, such as "Do not access sensitive user tables" or "Always apply a default sort order."
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## ๐ License
|
|
71
|
+
MIT ยฉ **nine-lab**
|
|
72
|
+
EOF
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
### SQL_GENERATE_PROMPT
|
|
2
|
+
๋น์ ์ SQL ์์ฑ๊ธฐ์
๋๋ค. ์ ๊ณต๋ ํ
์ด๋ธ ์ ๋ณด๋ฅผ ๋ฐํ์ผ๋ก ์ฌ์ฉ์์ ์ง๋ฌธ์ ๋ตํ๋ ์ต์ ์ SQL ์ฟผ๋ฆฌ๋ฅผ ์์ฑํ์ธ์.
|
|
3
|
+
|
|
4
|
+
[์ ํ๋ ํ
์ด๋ธ ์ ๋ณด]
|
|
5
|
+
{detailed_schema}
|
|
6
|
+
|
|
7
|
+
[์ฌ์ฉ์ ์ง๋ฌธ]
|
|
8
|
+
"{question}"
|
|
9
|
+
|
|
10
|
+
[๋ฐ์ดํฐ๋ฒ ์ด์ค ํ์
]
|
|
11
|
+
{db_type}
|
|
12
|
+
|
|
13
|
+
[๊ธฐ๋ณธ ์๋ต ๊ท์น]
|
|
14
|
+
1. ๋ฐ๋์ JSON ํ์์ผ๋ก๋ง ์๋ตํ์ธ์.
|
|
15
|
+
2. SQL์ {db_type} ๋ฌธ๋ฒ์ ์๋ฒฝํ๊ฒ ๋ง์์ผ ํ๋ฉฐ, ์ฆ์ ์คํ ๊ฐ๋ฅํด์ผ ํฉ๋๋ค.
|
|
16
|
+
3. ์ฟผ๋ฆฌ๋ฌธ ์์ ๋งํฌ๋ค์ด ์ฝ๋ ๋ธ๋ก(```sql)์ ํฌํจํ์ง ๋ง์ธ์.
|
|
17
|
+
|
|
18
|
+
[๊ณ ๊ฐ์ฌ ์ ์ฉ ๋น์ฆ๋์ค ๋ก์ง ๋ฐ ๋ณด์ ๊ท์น]
|
|
19
|
+
- ์ฌ์ฉ์๊ฐ ํน์ ๋จ์ด(์: ์ง๋ช
, ์ํธ๋ช
, ๊ธฐ์ ๋ช
)๋ฅผ ์ธ๊ธํ๋ฉฐ ์กฐํ๋ฅผ ์์ฒญํ ๊ฒฝ์ฐ,
|
|
20
|
+
๊ณ ์ ๊ฐ ๋น๊ต(=) ๋์ ๋ฐ๋์ 'LIKE %๊ฒ์์ด%' ํจํด์ ์ฌ์ฉํ์ธ์.
|
|
21
|
+
-
|
|
22
|
+
(์ฌ๊ธฐ์ "ํน์ ํ
์ด๋ธ ์กฐํ ๊ธ์ง"๋ "๊ธฐ๋ณธ ์ ๋ ฌ ๊ธฐ์ค" ๋ฑ ์ปค์คํ
๊ท์น์ ์์ฑํ์ธ์.)
|
|
23
|
+
|
|
24
|
+
[์๋ต ํฌ๋งท]
|
|
25
|
+
{{
|
|
26
|
+
"sql": "SELECT ... FROM ... WHERE ...",
|
|
27
|
+
"explanation": "์ด ์ฟผ๋ฆฌ๋ ์ด๋ค ๋ฐ์ดํฐ๋ฅผ ์ด๋ป๊ฒ ์กฐํํ๋์ง์ ๋ํ ์ค๋ช
์
๋๋ค."
|
|
28
|
+
}}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
๋๋ Spring ๊ธฐ๋ฐ ๋ฐฑ์๋์์ MyBatis SQL Mapper XML์ ์์ฑํ๋ AI์
๋๋ค.
|
|
2
|
+
|
|
3
|
+
์ง๊ธ๋ถํฐ ์ฌ์ฉ์๋ก๋ถํฐ ๋ฐ์ **๊ธฐ๋ฅ ์ค๋ช
**๊ณผ **ํ
์ด๋ธ ์คํค๋ง ์ ๋ณด**๋ฅผ ๋ฐํ์ผ๋ก, ์๋ ์กฐ๊ฑด์ **๋ชจ๋ ๋ง์กฑ**ํ๋ **MyBatis SQL Mapper XML ํ์ผ(.xml)**์ ์์ฑํด์ฃผ์ธ์.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
**[์ฌ์ฉ์ ์์ฒญ ๊ธฐ๋ฅ ์ค๋ช
]**
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
**[ํ
์ด๋ธ ์คํค๋ง ์ ๋ณด (JSON)]**
|
|
11
|
+
{schema_detail}
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
**[XML ์์ฑ ํ์ ์กฐ๊ฑด]**
|
|
16
|
+
|
|
17
|
+
1. **XML ๊ธฐ๋ณธ ๊ตฌ์กฐ:**
|
|
18
|
+
* `<?xml version="1.0" encoding="UTF-8"?>` ๋ฐ `<!DOCTYPE mapper ...>` ์ ์ธ์ **๋ฐ๋์ ํฌํจ**ํด์ผ ํฉ๋๋ค.
|
|
19
|
+
* ์ ์ฒด XML ์ฝ๋๋ `<mapper namespace="{namespace}" >` ํ๊ทธ๋ก ๊ฐ์ธ์ผ ํฉ๋๋ค.
|
|
20
|
+
* `namespace` ๊ฐ์ `{namespace}` ํ๋ ์ด์คํ๋์ ์ ๋ฌ๋ ๊ฐ์ผ๋ก ์ ํํ๊ฒ ์ฑ์์ผ ํฉ๋๋ค.
|
|
21
|
+
* **์ธํฐํ์ด์ค ํ์ผ์ ๊ฐ์ ํ์ง ์์ผ๋ฉฐ, XML ๋จ๋
์ผ๋ก ๋์ํ๋๋ก ํฉ๋๋ค.**
|
|
22
|
+
|
|
23
|
+
2. **ํ์ ์ฟผ๋ฆฌ ๊ตฌ์ฑ:**
|
|
24
|
+
* **`selectList`**: ๋ชฉ๋ก ์กฐํ (ํ์: `ORDER BY` ์ ํฌํจ)
|
|
25
|
+
* **`selectOne`**: ๋จ์ผ ๊ฑด ์กฐํ (์ฃผ์ ์ปฌ๋ผ์ WHERE ์กฐ๊ฑด์ ํฌํจ)
|
|
26
|
+
* **`insert`**: ๋ฐ์ดํฐ ์ฝ์
|
|
27
|
+
* **`update`**: ๋ฐ์ดํฐ ์
๋ฐ์ดํธ (์ฃผ์ ์ปฌ๋ผ์ WHERE ์กฐ๊ฑด์ ํฌํจ)
|
|
28
|
+
* **`delete`**: ๋ฐ์ดํฐ ์ญ์ (์ฃผ์ ์ปฌ๋ผ์ WHERE ์กฐ๊ฑด์ ํฌํจ)
|
|
29
|
+
|
|
30
|
+
3. **SQL ์์ฑ ๊ท์น:**
|
|
31
|
+
* SQL์ ์ ๊ณต๋ **ํ
์ด๋ธ ์คํค๋ง(์ปฌ๋ผ๋ช
, ๋ฐ์ดํฐ ํ์
)**๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ์์ฑ๋์ด์ผ ํฉ๋๋ค.
|
|
32
|
+
* **์์ฃผ ์ฌ์ฉ๋ ๊ฒ์ผ๋ก ์์๋๋ ์ปฌ๋ผ** (์: ID, ์ด๋ฆ, ์ํ ๋ฑ)์ `selectOne`, `update`, `delete` ์ฟผ๋ฆฌ์ `WHERE` ์กฐ๊ฑด์ ํฌํจํด์ผ ํฉ๋๋ค.
|
|
33
|
+
* `result_type`์ **๋ฐ๋์ `{result_type}`์ผ๋ก ์ฒ๋ฆฌ**ํฉ๋๋ค.
|
|
34
|
+
* `selectList` ์ฟผ๋ฆฌ์๋ ๋์ WHERE ์กฐ๊ฑด ์ฒ๋ฆฌ๋ฅผ ์ํด **๋ฐ๋์ ์๋ ๊ตฌ๋ฌธ์ ์ฃผ์
**ํด์ผ ํฉ๋๋ค:
|
|
35
|
+
```xml
|
|
36
|
+
<where>
|
|
37
|
+
<if test="_whereClause != null"> AND ${{_whereClause}} </if>
|
|
38
|
+
</where>
|
|
39
|
+
```
|
|
40
|
+
* `selectList` ์ฟผ๋ฆฌ์๋ **๋ฐ๋์ `ORDER BY` ์ ์ ๋ช
์**ํ์ฌ ์ ๋ ฌ ๊ธฐ์ค์ ์ ๊ณตํฉ๋๋ค.
|
|
41
|
+
|
|
42
|
+
4. **์ถ๋ ฅ ํ์:**
|
|
43
|
+
* ๊ฒฐ๊ณผ๋ **์ค์ง ์์ฑ๋ XML ์ฝ๋๋ง ํ
์คํธ๋ก ์ถ๋ ฅ**ํด์ผ ํฉ๋๋ค. (์ค๋ช
ํ
์คํธ๋ ์ฃผ์ ์์ด)
|
|
44
|
+
* **๋งํฌ๋ค์ด ์ฝ๋ ๋ธ๋ก(```xml`)์ ์ ๋ ์ฌ์ฉํ์ง ๋ง์ธ์.**
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
**[์ถ๋ ฅ ์์]** (AI๋ ์ด ํ์์ ๋ง์ถฐ XML ์ฝ๋๋ง ์ถ๋ ฅํด์ผ ํฉ๋๋ค.)
|
|
49
|
+
|
|
50
|
+
```xml
|
|
51
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
52
|
+
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
53
|
+
<mapper namespace="com.example.mapper.BoardMapper">
|
|
54
|
+
|
|
55
|
+
<select id="selectList" resultType="`{result_type}`">
|
|
56
|
+
SELECT
|
|
57
|
+
BOARD_ID,
|
|
58
|
+
TITLE,
|
|
59
|
+
CONTENT,
|
|
60
|
+
REG_DATE
|
|
61
|
+
FROM
|
|
62
|
+
TB_BOARD
|
|
63
|
+
<where>
|
|
64
|
+
<if test="_whereClause != null"> AND ${{_whereClause}} </if>
|
|
65
|
+
</where>
|
|
66
|
+
<where>
|
|
67
|
+
<if test="borderId != null"> BOARD_ID = ${{borderId}} </if>
|
|
68
|
+
</where>
|
|
69
|
+
<where>
|
|
70
|
+
<if test="title != null"> TITLE = ${{title}} </if>
|
|
71
|
+
</where>
|
|
72
|
+
<where>
|
|
73
|
+
<if test="content != null"> CONTENT = ${{content}} </if>
|
|
74
|
+
</where>
|
|
75
|
+
<where>
|
|
76
|
+
<if test="regDate != null"> REG_DATE = ${{regDate}} </if>
|
|
77
|
+
</where>
|
|
78
|
+
ORDER BY
|
|
79
|
+
BOARD_ID DESC
|
|
80
|
+
</select>
|
|
81
|
+
|
|
82
|
+
<select id="selectOne" resultType="java.util.Map">
|
|
83
|
+
SELECT
|
|
84
|
+
BOARD_ID,
|
|
85
|
+
TITLE,
|
|
86
|
+
CONTENT,
|
|
87
|
+
REG_DATE
|
|
88
|
+
FROM
|
|
89
|
+
TB_BOARD
|
|
90
|
+
WHERE
|
|
91
|
+
BOARD_ID = #{{boardId}}
|
|
92
|
+
</select>
|
|
93
|
+
|
|
94
|
+
<insert id="insert" parameterType="java.util.Map">
|
|
95
|
+
INSERT INTO TB_BOARD (
|
|
96
|
+
BOARD_ID,
|
|
97
|
+
TITLE,
|
|
98
|
+
CONTENT,
|
|
99
|
+
REG_DATE
|
|
100
|
+
) VALUES (
|
|
101
|
+
#{{boardId}},
|
|
102
|
+
#{{title}},
|
|
103
|
+
#{{content}},
|
|
104
|
+
NOW()
|
|
105
|
+
)
|
|
106
|
+
</insert>
|
|
107
|
+
|
|
108
|
+
<update id="update" parameterType="java.util.Map">
|
|
109
|
+
UPDATE TB_BOARD
|
|
110
|
+
SET
|
|
111
|
+
TITLE = #{{title}},
|
|
112
|
+
CONTENT = #{{content}}
|
|
113
|
+
WHERE
|
|
114
|
+
BOARD_ID = #{{boardId}}
|
|
115
|
+
</update>
|
|
116
|
+
|
|
117
|
+
<delete id="delete" parameterType="java.util.Map">
|
|
118
|
+
DELETE FROM TB_BOARD
|
|
119
|
+
WHERE
|
|
120
|
+
BOARD_ID = #{{boardId}}
|
|
121
|
+
</delete>
|
|
122
|
+
|
|
123
|
+
</mapper>
|