Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nanMoMentorPlatform
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
nanMoMentorPlatform
Commits
24ca3f55
Commit
24ca3f55
authored
Jul 06, 2026
by
PC-20251223ZVQQ\Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增测评题库问题修复
parent
2ac1e3c4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
42 deletions
+30
-42
teacherSurvey.ts
src/biz/admin/teacherSurvey.ts
+16
-42
addData.ts
src/data/addData.ts
+14
-0
No files found.
src/biz/admin/teacherSurvey.ts
View file @
24ca3f55
...
...
@@ -2,7 +2,7 @@
import
{
selectDataListByParam
,
selectOneDataByParam
}
from
"../../data/findData"
;
import
{
updateManyData
}
from
"../../data/updateData"
;
import
{
addData
}
from
"../../data/addData"
;
import
{
addData
,
addOneResId
}
from
"../../data/addData"
;
import
{
delData
}
from
"../../data/delData"
;
import
{
TABLENAME
,
TABLEID
}
from
"../../config/dbEnum"
;
import
{
BizError
}
from
"../../util/bizError"
;
...
...
@@ -92,32 +92,15 @@ export async function createSurvey(param: {
/**获取当前学期 */
let
semester
=
await
getCurrentSemester
();
insertSurveyInfo
(
semester
.
id
,
surveyName
,
startTime
,
endTime
,
isOpen
,
description
,
1
,
null
);
/**查回自增ID */
let
newSurvey
=
await
selectOneDataByParam
(
TABLENAME
.
测评活动表
,
{
name
:
surveyName
,
semester_id
:
semester
.
id
,
is_temp
:
1
,
"%orderDesc%"
:
"id"
,
"%limit%"
:
1
});
let
surveyId
=
(
newSurvey
.
data
as
any
).
id
;
insertSurveyDetail
(
surveyId
,
questions
);
// 新增模板
let
insertTempData
=
await
insertSurveyInfo
(
semester
.
id
,
surveyName
,
startTime
,
endTime
,
isOpen
,
description
,
1
,
null
);
let
surveyId
=
(
insertTempData
as
any
).
data
.
id
;
await
insertSurveyDetail
(
surveyId
,
questions
);
// 新增试卷
insertSurveyInfo
(
semester
.
id
,
surveyName
,
startTime
,
endTime
,
isOpen
,
description
,
2
,
surveyId
);
/**查回自增ID */
let
surveyInfo
=
await
selectOneDataByParam
(
TABLENAME
.
测评活动表
,
{
name
:
surveyName
,
semester_id
:
semester
.
id
,
is_temp
:
2
,
"%orderDesc%"
:
"id"
,
"%limit%"
:
1
});
let
survey_id
=
(
surveyInfo
.
data
as
any
).
id
;
insertSurveyDetail
(
survey_id
,
questions
);
let
insertData
=
await
insertSurveyInfo
(
semester
.
id
,
surveyName
,
startTime
,
endTime
,
isOpen
,
description
,
2
,
surveyId
);
let
survey_id
=
(
insertData
as
any
).
data
.
id
;
await
insertSurveyDetail
(
survey_id
,
questions
);
return
{
isSuccess
:
true
};
}
...
...
@@ -169,7 +152,7 @@ export async function updateSurvey(param: {
if
(
!
hasData
(
survey
))
{
throw
new
BizError
(
ERRORENUM
.
未找到数据
,
'测评不存在'
);
}
updateSurveyInfo
(
surveyId
,
surveyName
,
startTime
,
endTime
,
isOpen
,
description
,
questions
);
await
updateSurveyInfo
(
surveyId
,
surveyName
,
startTime
,
endTime
,
isOpen
,
description
,
questions
);
// 若是没有更新开始时间,则同步更新试卷
if
(
survey
.
data
.
start_time
===
startTime
)
{
...
...
@@ -183,24 +166,15 @@ export async function updateSurvey(param: {
if
(
hasData
(
survey_template
))
{
let
survey_id
=
(
survey_template
.
data
as
any
).
id
;
// 更新试卷信息
updateSurveyInfo
(
survey_id
,
surveyName
,
startTime
,
endTime
,
isOpen
,
description
,
questions
);
await
updateSurveyInfo
(
survey_id
,
surveyName
,
startTime
,
endTime
,
isOpen
,
description
,
questions
);
}
}
else
{
let
semester
=
await
getCurrentSemester
();
// 若是更新开始时间,则通过模板创建试卷
let
tempId
=
survey
.
data
.
id
;
insertSurveyInfo
(
semester
.
id
,
surveyName
,
startTime
,
endTime
,
isOpen
,
description
,
2
,
tempId
);
/**查回自增ID */
let
newSurvey
=
await
selectOneDataByParam
(
TABLENAME
.
测评活动表
,
{
name
:
surveyName
,
semester_id
:
semester
.
id
,
"%orderDesc%"
:
"id"
,
"%limit%"
:
1
});
let
surveyId
=
(
newSurvey
.
data
as
any
).
id
;
insertSurveyDetail
(
surveyId
,
questions
);
let
insertData
=
await
insertSurveyInfo
(
semester
.
id
,
surveyName
,
startTime
,
endTime
,
isOpen
,
description
,
2
,
tempId
);
let
survey_id
=
(
insertData
as
any
).
data
.
id
;
await
insertSurveyDetail
(
survey_id
,
questions
);
}
return
{
isSuccess
:
true
};
...
...
@@ -246,7 +220,7 @@ export async function surveyInfo(surveyId: number) {
// 内联方法,用于插入测评信息
async
function
insertSurveyInfo
(
semesterId
:
number
,
surveyName
:
string
,
startTime
:
string
,
endTime
:
string
,
isOpen
:
number
,
description
:
string
,
is_temp
?:
number
,
temp
I
d
?:
number
){
endTime
:
string
,
isOpen
:
number
,
description
:
string
,
is_temp
?:
number
,
temp
_i
d
?:
number
){
/**插入 survey 表 */
let
surveyData
:
any
=
{
name
:
surveyName
,
...
...
@@ -256,9 +230,9 @@ async function insertSurveyInfo(semesterId: number, surveyName: string, startTim
is_open
:
isOpen
?
true
:
false
,
description
:
description
||
null
,
is_temp
:
is_temp
,
temp
Id
:
tempI
d
||
null
temp
_id
:
temp_i
d
||
null
};
await
addData
(
TABLENAME
.
测评活动表
,
surveyData
);
return
await
addOneResId
(
TABLENAME
.
测评活动表
,
surveyData
);
}
// 内联方法,用于插入测评题目列表
async
function
insertSurveyDetail
(
surveyId
:
number
,
questions
:
any
[]){
...
...
src/data/addData.ts
View file @
24ca3f55
...
...
@@ -16,4 +16,17 @@ export async function addData(tableName:string, data:any) {
await
tableModel
.
bulkCreate
(
dataArray
);
return
{
isSuccess
:
true
};
}
/**
* 插入单条数据并返回完整记录(含自增ID)
* 使用 create 替代 bulkCreate,确保返回值包含自增主键
* @param tableName 表名
* @param data 单条数据对象
* @returns { isSuccess, data: 插入后的完整记录 }
*/
export
async
function
addOneResId
(
tableName
:
string
,
data
:
any
)
{
let
tableModel
=
mysqlModelMap
[
tableName
];
const
result
=
await
tableModel
.
create
(
data
);
return
{
isSuccess
:
true
,
data
:
result
};
}
\ No newline at end of file
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