feat: 新增已发布的问卷再次修改状态会变成修改中 (#20)
This commit is contained in:
parent
a891ad3351
commit
e2fa7db310
@ -82,13 +82,25 @@ class SurveyService {
|
|||||||
const surveyMetaUpdateRes = await surveyMeta.updateOne({
|
const surveyMetaUpdateRes = await surveyMeta.updateOne({
|
||||||
_id,
|
_id,
|
||||||
owner: surveyParams.userData.username,
|
owner: surveyParams.userData.username,
|
||||||
}, {
|
}, [{
|
||||||
$set: {
|
$set: {
|
||||||
remark: surveyParams.remark,
|
remark: surveyParams.remark,
|
||||||
title: surveyParams.title,
|
title: surveyParams.title,
|
||||||
updateDate: Date.now(),
|
updateDate: Date.now(),
|
||||||
}
|
}
|
||||||
})
|
}, {
|
||||||
|
$set: {
|
||||||
|
"curStatus": {
|
||||||
|
$cond: {
|
||||||
|
if: {
|
||||||
|
$eq: ["$curStatus.status", "new"]
|
||||||
|
},
|
||||||
|
then: "$curStatus",
|
||||||
|
else: getStatusObject({ status: SURVEY_STATUS.editing })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}])
|
||||||
if (surveyMetaUpdateRes.matchedCount < 1) {
|
if (surveyMetaUpdateRes.matchedCount < 1) {
|
||||||
throw new CommonError("更新问卷信息失败,问卷不存在或您不是该问卷所有者")
|
throw new CommonError("更新问卷信息失败,问卷不存在或您不是该问卷所有者")
|
||||||
}
|
}
|
||||||
@ -255,13 +267,30 @@ class SurveyService {
|
|||||||
|
|
||||||
async saveConf(surveyData: { surveyId: string, configData: any }) {
|
async saveConf(surveyData: { surveyId: string, configData: any }) {
|
||||||
const surveyConf = await mongo.getCollection({ collectionName: 'surveyConf' });
|
const surveyConf = await mongo.getCollection({ collectionName: 'surveyConf' });
|
||||||
|
const surveyMeta = await mongo.getCollection({ collectionName: 'surveyMeta' });
|
||||||
const saveRes = await surveyConf.updateOne({
|
const saveRes = await surveyConf.updateOne({
|
||||||
pageId: surveyData.surveyId
|
pageId: surveyData.surveyId
|
||||||
}, {
|
}, {
|
||||||
$set: {
|
$set: {
|
||||||
code: surveyData.configData
|
code: surveyData.configData,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
const _id = mongo.getObjectIdByStr(surveyData.surveyId)
|
||||||
|
surveyMeta.updateOne({
|
||||||
|
_id,
|
||||||
|
}, [{
|
||||||
|
$set: {
|
||||||
|
"curStatus": {
|
||||||
|
$cond: {
|
||||||
|
if: {
|
||||||
|
$eq: ["$curStatus.status", "new"]
|
||||||
|
},
|
||||||
|
then: "$curStatus",
|
||||||
|
else: getStatusObject({ status: SURVEY_STATUS.editing })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}])
|
||||||
return saveRes
|
return saveRes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user