Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yafangsuo_dataServer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
node_server
yafangsuo_dataServer
Commits
1825e86e
Commit
1825e86e
authored
Aug 28, 2023
by
lixinming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
4236aaf6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
12 deletions
+15
-12
mysqlTableConfig.ts
src/config/mysqlTableConfig.ts
+6
-6
sqlModelBind.ts
src/model/sqlModelBind.ts
+9
-6
No files found.
src/config/mysqlTableConfig.ts
View file @
1825e86e
...
@@ -15,7 +15,7 @@ export const TablesConfig = [
...
@@ -15,7 +15,7 @@ export const TablesConfig = [
},
},
branchName
:
{
type
:
Sequelize
.
STRING
(
100
),
allowNull
:
false
},
//支部名称
branchName
:
{
type
:
Sequelize
.
STRING
(
100
),
allowNull
:
false
},
//支部名称
},
},
association
:
[
{}
]
association
:
[]
},
},
{
{
tableNameCn
:
'后台用户表'
,
tableNameCn
:
'后台用户表'
,
...
@@ -32,7 +32,7 @@ export const TablesConfig = [
...
@@ -32,7 +32,7 @@ export const TablesConfig = [
token
:{
type
:
Sequelize
.
STRING
(
100
),
allowNull
:
false
},
token
:{
type
:
Sequelize
.
STRING
(
100
),
allowNull
:
false
},
tokenMs
:{
type
:
Sequelize
.
DATE
,
allowNull
:
false
}
tokenMs
:{
type
:
Sequelize
.
DATE
,
allowNull
:
false
}
},
},
association
:
[
{}
]
association
:
[]
},
},
{
{
tableNameCn
:
'行政职务表'
,
tableNameCn
:
'行政职务表'
,
...
@@ -47,7 +47,7 @@ export const TablesConfig = [
...
@@ -47,7 +47,7 @@ export const TablesConfig = [
},
},
administrativePositionName
:
{
type
:
Sequelize
.
STRING
(
100
),
allowNull
:
false
}
administrativePositionName
:
{
type
:
Sequelize
.
STRING
(
100
),
allowNull
:
false
}
},
},
association
:
[
{}
]
association
:
[]
},
},
{
{
tableNameCn
:
'党内职务表'
,
tableNameCn
:
'党内职务表'
,
...
@@ -62,7 +62,7 @@ export const TablesConfig = [
...
@@ -62,7 +62,7 @@ export const TablesConfig = [
},
},
partyPositionsName
:
{
type
:
Sequelize
.
STRING
(
100
),
allowNull
:
false
}
partyPositionsName
:
{
type
:
Sequelize
.
STRING
(
100
),
allowNull
:
false
}
},
},
association
:
[
{}
]
association
:
[]
},
},
{
{
tableNameCn
:
'所属科室表'
,
tableNameCn
:
'所属科室表'
,
...
@@ -77,7 +77,7 @@ export const TablesConfig = [
...
@@ -77,7 +77,7 @@ export const TablesConfig = [
},
},
departmentName
:
{
type
:
Sequelize
.
STRING
(
100
),
allowNull
:
false
}
departmentName
:
{
type
:
Sequelize
.
STRING
(
100
),
allowNull
:
false
}
},
},
association
:
[
{}
]
association
:
[]
},
},
{
{
tableNameCn
:
'课程类型'
,
tableNameCn
:
'课程类型'
,
...
@@ -92,7 +92,7 @@ export const TablesConfig = [
...
@@ -92,7 +92,7 @@ export const TablesConfig = [
},
},
courseTypeName
:
{
type
:
Sequelize
.
STRING
(
100
),
allowNull
:
false
}
courseTypeName
:
{
type
:
Sequelize
.
STRING
(
100
),
allowNull
:
false
}
},
},
association
:
[
{}
]
association
:
[]
},
},
{
{
tableNameCn
:
'党员基础信息表'
,
tableNameCn
:
'党员基础信息表'
,
...
...
src/model/sqlModelBind.ts
View file @
1825e86e
...
@@ -9,18 +9,24 @@ let baseDB = {};
...
@@ -9,18 +9,24 @@ let baseDB = {};
export
async
function
initMysqlModel
()
{
export
async
function
initMysqlModel
()
{
/**初始化表 */
for
(
let
i
=
0
;
i
<
TablesConfig
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
TablesConfig
.
length
;
i
++
)
{
let
{
tableName
,
schema
,
association
,
tableNameCn
}
=
TablesConfig
[
i
];
let
{
tableName
,
schema
}
=
TablesConfig
[
i
];
let
schemaConf
=
{
let
schemaConf
=
{
freezeTableName
:
true
,
//true表示使用给定的表名,false表示模型名后加s作为表名
freezeTableName
:
true
,
//true表示使用给定的表名,false表示模型名后加s作为表名
timestamps
:
false
//true表示给模型加上时间戳属性(createAt、updateAt),false表示不带时间戳属性
timestamps
:
false
//true表示给模型加上时间戳属性(createAt、updateAt),false表示不带时间戳属性
};
};
let
model
=
mysqlDB
.
define
(
tableName
,
schema
,
schemaConf
);
let
model
=
mysqlDB
.
define
(
tableName
,
schema
,
schemaConf
);
baseDB
[
tableName
]
=
model
.
sync
({}).
then
();
baseDB
[
tableName
]
=
await
model
.
sync
({}).
then
();
}
/**初始化表关联 */
for
(
let
i
=
0
;
i
<
TablesConfig
.
length
;
i
++
)
{
let
{
tableName
,
association
}
=
TablesConfig
[
i
];
association
.
forEach
(
(
item
:
any
)
=>
{
association
.
forEach
(
(
item
:
any
)
=>
{
if
(
item
)
{
if
(
item
)
{
let
{
type
,
check
}
=
item
;
let
{
type
,
check
}
=
item
;
...
@@ -32,9 +38,6 @@ export async function initMysqlModel() {
...
@@ -32,9 +38,6 @@ export async function initMysqlModel() {
baseDB
[
tableName
].
belongsTo
(
baseDB
[
check
]);
baseDB
[
tableName
].
belongsTo
(
baseDB
[
check
]);
}
}
});
});
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment