Esempio n. 1
0
        public async Task <IActionResult> GetQuestionListWhileCanDependAsync(GetQuestionListCanDependRequestDto requestDto)
        {
            var details = await new QuestionnaireQuestionBiz().GetQuestionListCanDependAsync(requestDto);
            //以问题分组
            var group = details.GroupBy(a => new
            {
                a.QuestionGuid,
                a.QuestionName,
                a.QuestionSort
            });
            var result = group.Select(g => new GetQuestionListCanDependResponseDto
            {
                QuestionGuid = g.Key.QuestionGuid,
                QuestionName = g.Key.QuestionName,
                Sort         = g.Key.QuestionSort,
                Answers      = g.Select(gd => new GetQuestionListCanDependResponseDto.Answer
                {
                    AnswerGuid  = gd.AnswerGuid,
                    AnswerLabel = gd.AnswerLabel,
                    Sort        = gd.AnswerSort
                }).OrderBy(answer => answer.Sort).ToList()
            }).OrderBy(q => q.Sort);

            return(Success(result));
        }
Esempio n. 2
0
        /// <summary>
        /// 获取当前问题可依赖的问题列表
        /// </summary>
        /// <param name="requestDto"></param>
        /// <returns></returns>
        public async Task <List <GetQuestionListCanDependItemDto> > GetQuestionListCanDependAsync(GetQuestionListCanDependRequestDto requestDto)
        {
            var sql = @"SELECT
	                        a.question_guid,
	                        a.question_name,
	                        a.sort AS question_sort,
	                        b.answer_guid,
	                        b.answer_label,
	                        b.sort AS answer_sort 
                        FROM
	                        t_questionnaire_question a
	                        INNER JOIN t_questionnaire_answer b ON a.question_guid = b.question_guid and a.`enable`=b.`enable`
                        WHERE
	                        a.questionnaire_guid = @QuestionnaireGuid and a.`enable`=1
	                        AND a.sort < @Sort 
                            AND a.question_type in ('Enum','Bool')";

            using (var conn = MySqlHelper.GetConnection())
            {
                var result = await conn.QueryAsync <GetQuestionListCanDependItemDto>(sql, requestDto);

                return(result.ToList());
            }
        }