fix: 修改更新问卷基础信息的接口允许remark字段为空 (#84)
This commit is contained in:
parent
15a41f1ba7
commit
d23924347e
@ -8,14 +8,15 @@ import {
|
||||
UseGuards,
|
||||
Request,
|
||||
} from '@nestjs/common';
|
||||
|
||||
import { SurveyMetaService } from '../services/surveyMeta.service';
|
||||
|
||||
import * as Joi from 'joi';
|
||||
import { Authtication } from 'src/guards/authtication';
|
||||
import moment from 'moment';
|
||||
|
||||
import { getFilter, getOrder } from 'src/utils/surveyUtil';
|
||||
import { HttpException } from 'src/exceptions/httpException';
|
||||
import { EXCEPTION_CODE } from 'src/enums/exceptionCode';
|
||||
import { Authtication } from 'src/guards/authtication';
|
||||
|
||||
import { SurveyMetaService } from '../services/surveyMeta.service';
|
||||
|
||||
@Controller('/api/survey')
|
||||
export class SurveyMetaController {
|
||||
@ -25,11 +26,17 @@ export class SurveyMetaController {
|
||||
@Post('/updateMeta')
|
||||
@HttpCode(200)
|
||||
async updateMeta(@Body() reqBody, @Request() req) {
|
||||
const validationResult = await Joi.object({
|
||||
remark: Joi.string().allow(null).default(''),
|
||||
title: Joi.string().required(),
|
||||
surveyId: Joi.string().required(),
|
||||
}).validateAsync(reqBody, { allowUnknown: true });
|
||||
let validationResult;
|
||||
try {
|
||||
validationResult = await Joi.object({
|
||||
title: Joi.string().required(),
|
||||
remark: Joi.string().allow(null, '').default(''),
|
||||
surveyId: Joi.string().required(),
|
||||
}).validateAsync(reqBody, { allowUnknown: true });
|
||||
} catch (error) {
|
||||
throw new HttpException('参数错误', EXCEPTION_CODE.PARAMETER_ERROR);
|
||||
}
|
||||
|
||||
const username = req.user.username;
|
||||
const surveyId = validationResult.surveyId;
|
||||
const survey = await this.surveyMetaService.checkSurveyAccess({
|
||||
|
Loading…
Reference in New Issue
Block a user