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