Skip to content

Commit 8bb2c9e

Browse files
committed
✨ refactor code and add mssql support
1 parent f9e50b1 commit 8bb2c9e

16 files changed

+1889
-368
lines changed

.vscode/settings.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"cSpell.words": ["prec"]
3+
}

bin/code-gear.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#! /usr/bin/env node
22

33
const program = require('commander'),
4-
chalk = require('chalk'),
54
codeGear = require('../lib/index');
65

76
program

code-gear.mssql.js

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
module.exports = {
2+
type: 'mssql',
3+
database: {
4+
server: 'localhost',
5+
database: 'sampledb',
6+
user: 'sa',
7+
password: '123456',
8+
pool: {
9+
max: 10,
10+
min: 0,
11+
idleTimeoutMillis: 30000,
12+
},
13+
options: {
14+
encrypt: false, // true for azure
15+
trustServerCertificate: true, // change to true for local dev / self-signed certs
16+
},
17+
},
18+
template: {
19+
imports: './templates/imports_mssql.js',
20+
target: './.generate',
21+
templates: [
22+
{
23+
splitType: 1, // 1= table split每个table 一个文件 0 =所有的table 一个文件
24+
path: './templates/vulcanEntity.art', //相对的模板路劲
25+
targetFile: function (t) {
26+
var arrParts = t.tableName.split('_');
27+
var resArr = [];
28+
resArr.push('./');
29+
arrParts.forEach((a) => {
30+
if (!a) {
31+
return '';
32+
}
33+
var s = a.replace(
34+
/\b(\w)(\w*)/g,
35+
function ($0, $1, $2) {
36+
return $1.toUpperCase() + $2.toLowerCase();
37+
}
38+
);
39+
resArr.push(s);
40+
});
41+
resArr.push('.cs');
42+
return resArr.join('');
43+
},
44+
extend: {
45+
//额外的变量
46+
nameSpace: 'Sample.Impl.Model',
47+
baseModel: 'Sample.Impl.Model.BaseModel',
48+
},
49+
},
50+
],
51+
},
52+
};

code-gear.config.js code-gear.mysql.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
module.exports = {
2+
type: 'mysql',
23
database: {
34
host: '127.0.0.1',
45
port: 3306,
5-
database: 'sampleDb',
6+
database: 'sampledb',
67
user: 'root',
7-
password: '123333@',
8+
password: '123456',
89
},
910
template: {
1011
imports: './templates/imports.js',

lib/dbSchema.js

-126
This file was deleted.

0 commit comments

Comments
 (0)