22 changed files with 1053 additions and 16 deletions
			
			
		- 
					19src/Shentun.WebPeis.Application.Contracts/QuestionTypes/CreateQuestionTypeDto.cs
 - 
					23src/Shentun.WebPeis.Application.Contracts/QuestionTypes/QuestionTypeDto.cs
 - 
					11src/Shentun.WebPeis.Application.Contracts/QuestionTypes/QuestionTypeIdInputDto.cs
 - 
					19src/Shentun.WebPeis.Application.Contracts/QuestionTypes/UpdateQuestionTypeDto.cs
 - 
					48src/Shentun.WebPeis.Application.Contracts/Questions/CreateQuestionDto.cs
 - 
					55src/Shentun.WebPeis.Application.Contracts/Questions/QuestionDto.cs
 - 
					11src/Shentun.WebPeis.Application.Contracts/Questions/QuestionIdInputDto.cs
 - 
					58src/Shentun.WebPeis.Application.Contracts/Questions/QuestionTreeListDto.cs
 - 
					47src/Shentun.WebPeis.Application.Contracts/Questions/UpdateQuestionDto.cs
 - 
					135src/Shentun.WebPeis.Application/QuestionTypes/QuestionTypeAppService.cs
 - 
					208src/Shentun.WebPeis.Application/Questions/QuestionAppService.cs
 - 
					4src/Shentun.WebPeis.Domain/AppointScheduleTemplates/AppointScheduleTemplateManager.cs
 - 
					4src/Shentun.WebPeis.Domain/EntityHelper.cs
 - 
					16src/Shentun.WebPeis.Domain/Models/Question.cs
 - 
					2src/Shentun.WebPeis.Domain/Models/QuestionType.cs
 - 
					137src/Shentun.WebPeis.Domain/QuestionTypes/QuestionTypeManager.cs
 - 
					17src/Shentun.WebPeis.Domain/QuestionTypes/UpdateQuestionTypeSortDragDto.cs
 - 
					16src/Shentun.WebPeis.Domain/QuestionTypes/UpdateQuestionTypeSortTopOrBottomInputDto.cs
 - 
					197src/Shentun.WebPeis.Domain/Questions/QuestionManager.cs
 - 
					20src/Shentun.WebPeis.Domain/Questions/UpdateQuestionSortDragDto.cs
 - 
					18src/Shentun.WebPeis.Domain/Questions/UpdateQuestionSortTopOrBottomInputDto.cs
 - 
					2src/Shentun.WebPeis.HttpApi.Host/Shentun.WebPeis.HttpApi.Host.csproj
 
@ -0,0 +1,19 @@ | 
				
			|||
using System; | 
				
			|||
using System.Collections.Generic; | 
				
			|||
using System.Text; | 
				
			|||
 | 
				
			|||
namespace Shentun.WebPeis.QuestionTypes | 
				
			|||
{ | 
				
			|||
    public class CreateQuestionTypeDto | 
				
			|||
    { | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 主键
 | 
				
			|||
        /// </summary>
 | 
				
			|||
        public string QuestionTypeId { get; set; } | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 名称
 | 
				
			|||
        /// </summary>
 | 
				
			|||
 | 
				
			|||
        public string QuestionTypeName { get; set; }  | 
				
			|||
    } | 
				
			|||
} | 
				
			|||
@ -0,0 +1,23 @@ | 
				
			|||
using System; | 
				
			|||
using System.Collections.Generic; | 
				
			|||
using System.Text; | 
				
			|||
 | 
				
			|||
namespace Shentun.WebPeis.QuestionTypes | 
				
			|||
{ | 
				
			|||
    public class QuestionTypeDto:AuditedEntityDtoName | 
				
			|||
    { | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 主键
 | 
				
			|||
        /// </summary>
 | 
				
			|||
        public string QuestionTypeId { get; set; } | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 名称
 | 
				
			|||
        /// </summary>
 | 
				
			|||
 | 
				
			|||
        public string QuestionTypeName { get; set; }  | 
				
			|||
 | 
				
			|||
        public string SimpleCode { get; set; }  | 
				
			|||
 | 
				
			|||
        public int DisplayOrder { get; set; } | 
				
			|||
    } | 
				
			|||
} | 
				
			|||
@ -0,0 +1,11 @@ | 
				
			|||
using System; | 
				
			|||
using System.Collections.Generic; | 
				
			|||
using System.Text; | 
				
			|||
 | 
				
			|||
namespace Shentun.WebPeis.QuestionTypes | 
				
			|||
{ | 
				
			|||
    public class QuestionTypeIdInputDto | 
				
			|||
    { | 
				
			|||
        public string QuestionTypeId { get; set; } | 
				
			|||
    } | 
				
			|||
} | 
				
			|||
@ -0,0 +1,19 @@ | 
				
			|||
using System; | 
				
			|||
using System.Collections.Generic; | 
				
			|||
using System.Text; | 
				
			|||
 | 
				
			|||
namespace Shentun.WebPeis.QuestionTypes | 
				
			|||
{ | 
				
			|||
    public class UpdateQuestionTypeDto | 
				
			|||
    { | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 主键
 | 
				
			|||
        /// </summary>
 | 
				
			|||
        public string QuestionTypeId { get; set; } | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 名称
 | 
				
			|||
        /// </summary>
 | 
				
			|||
 | 
				
			|||
        public string QuestionTypeName { get; set; } | 
				
			|||
    } | 
				
			|||
} | 
				
			|||
@ -0,0 +1,48 @@ | 
				
			|||
using System; | 
				
			|||
using System.Collections.Generic; | 
				
			|||
using System.Text; | 
				
			|||
 | 
				
			|||
namespace Shentun.WebPeis.Questions | 
				
			|||
{ | 
				
			|||
    public class CreateQuestionDto | 
				
			|||
    { | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 主键
 | 
				
			|||
        /// </summary>
 | 
				
			|||
        public Guid QuestionId { get; set; } | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 题目
 | 
				
			|||
        /// </summary>
 | 
				
			|||
 | 
				
			|||
        public string QuestionName { get; set; } = null!; | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 问卷类别ID
 | 
				
			|||
        /// </summary>
 | 
				
			|||
 | 
				
			|||
        public string QuestionTypeId { get; set; } | 
				
			|||
 | 
				
			|||
 | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 答案类别 0-单选  1-多选
 | 
				
			|||
        /// </summary>
 | 
				
			|||
 | 
				
			|||
        public char? AnswerType { get; set; } | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 问卷题目类别 01-生育 ,02-不适症状,03-危险因素,04-所患疾病
 | 
				
			|||
        /// </summary>
 | 
				
			|||
 | 
				
			|||
        public string QuestionSubjectTypeId { get; set; } | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 启用
 | 
				
			|||
        /// </summary>
 | 
				
			|||
 | 
				
			|||
        public char? IsActive { get; set; } | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 父问卷ID
 | 
				
			|||
        /// </summary>
 | 
				
			|||
 | 
				
			|||
        public Guid? ParentId { get; set; } | 
				
			|||
         | 
				
			|||
  | 
				
			|||
    } | 
				
			|||
} | 
				
			|||
@ -0,0 +1,55 @@ | 
				
			|||
using System; | 
				
			|||
using System.Collections.Generic; | 
				
			|||
using System.Text; | 
				
			|||
 | 
				
			|||
namespace Shentun.WebPeis.Questions | 
				
			|||
{ | 
				
			|||
    public class QuestionDto: AuditedEntityDtoName | 
				
			|||
    { | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 主键
 | 
				
			|||
        /// </summary>
 | 
				
			|||
        public Guid QuestionId { get; set; } | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 题目
 | 
				
			|||
        /// </summary>
 | 
				
			|||
 | 
				
			|||
        public string QuestionName { get; set; } = null!; | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 问卷类别ID
 | 
				
			|||
        /// </summary>
 | 
				
			|||
 | 
				
			|||
        public string QuestionTypeId { get; set; } | 
				
			|||
 | 
				
			|||
 | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 答案类别 0-单选  1-多选
 | 
				
			|||
        /// </summary>
 | 
				
			|||
 | 
				
			|||
        public char? AnswerType { get; set; } | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 问卷题目类别 01-生育 ,02-不适症状,03-危险因素,04-所患疾病
 | 
				
			|||
        /// </summary>
 | 
				
			|||
 | 
				
			|||
        public string QuestionSubjectTypeId { get; set; } | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 启用
 | 
				
			|||
        /// </summary>
 | 
				
			|||
 | 
				
			|||
        public char? IsActive { get; set; } | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 父问卷ID
 | 
				
			|||
        /// </summary>
 | 
				
			|||
 | 
				
			|||
        public Guid? ParentId { get; set; } | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 编码路径
 | 
				
			|||
        /// </summary>
 | 
				
			|||
 | 
				
			|||
        public string? PathCode { get; set; } | 
				
			|||
 | 
				
			|||
        public string SimpleCode { get; set; } = null!; | 
				
			|||
 | 
				
			|||
        public int DisplayOrder { get; set; } | 
				
			|||
    } | 
				
			|||
} | 
				
			|||
@ -0,0 +1,11 @@ | 
				
			|||
using System; | 
				
			|||
using System.Collections.Generic; | 
				
			|||
using System.Text; | 
				
			|||
 | 
				
			|||
namespace Shentun.WebPeis.Questions | 
				
			|||
{ | 
				
			|||
    public class QuestionIdInputDto | 
				
			|||
    { | 
				
			|||
        public Guid QuestionId { get; set; } | 
				
			|||
    } | 
				
			|||
} | 
				
			|||
@ -0,0 +1,58 @@ | 
				
			|||
using System; | 
				
			|||
using System.Collections.Generic; | 
				
			|||
using System.Text; | 
				
			|||
 | 
				
			|||
namespace Shentun.WebPeis.Questions | 
				
			|||
{ | 
				
			|||
    public class QuestionTreeListDto : AuditedEntityDtoName | 
				
			|||
    { | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 主键
 | 
				
			|||
        /// </summary>
 | 
				
			|||
        public Guid QuestionId { get; set; } | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 题目
 | 
				
			|||
        /// </summary>
 | 
				
			|||
 | 
				
			|||
        public string QuestionName { get; set; } = null!; | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 问卷类别ID
 | 
				
			|||
        /// </summary>
 | 
				
			|||
 | 
				
			|||
        public string QuestionTypeId { get; set; } | 
				
			|||
 | 
				
			|||
 | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 答案类别 0-单选  1-多选
 | 
				
			|||
        /// </summary>
 | 
				
			|||
 | 
				
			|||
        public char? AnswerType { get; set; } | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 问卷题目类别 01-生育 ,02-不适症状,03-危险因素,04-所患疾病
 | 
				
			|||
        /// </summary>
 | 
				
			|||
 | 
				
			|||
        public string QuestionSubjectTypeId { get; set; } | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 启用
 | 
				
			|||
        /// </summary>
 | 
				
			|||
 | 
				
			|||
        public char? IsActive { get; set; } | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 父问卷ID
 | 
				
			|||
        /// </summary>
 | 
				
			|||
 | 
				
			|||
        public Guid? ParentId { get; set; } | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 编码路径
 | 
				
			|||
        /// </summary>
 | 
				
			|||
 | 
				
			|||
        public string? PathCode { get; set; } | 
				
			|||
 | 
				
			|||
        public string SimpleCode { get; set; } = null!; | 
				
			|||
 | 
				
			|||
        public int DisplayOrder { get; set; } | 
				
			|||
 | 
				
			|||
        public List<QuestionTreeListDto> TreeChildren { get; set; } | 
				
			|||
 | 
				
			|||
    } | 
				
			|||
} | 
				
			|||
@ -0,0 +1,47 @@ | 
				
			|||
using System; | 
				
			|||
using System.Collections.Generic; | 
				
			|||
using System.Text; | 
				
			|||
 | 
				
			|||
namespace Shentun.WebPeis.Questions | 
				
			|||
{ | 
				
			|||
    public class UpdateQuestionDto | 
				
			|||
    { | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 主键
 | 
				
			|||
        /// </summary>
 | 
				
			|||
        public Guid QuestionId { get; set; } | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 题目
 | 
				
			|||
        /// </summary>
 | 
				
			|||
 | 
				
			|||
        public string QuestionName { get; set; } = null!; | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 问卷类别ID
 | 
				
			|||
        /// </summary>
 | 
				
			|||
 | 
				
			|||
        public string QuestionTypeId { get; set; } | 
				
			|||
 | 
				
			|||
 | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 答案类别 0-单选  1-多选
 | 
				
			|||
        /// </summary>
 | 
				
			|||
 | 
				
			|||
        public char? AnswerType { get; set; } | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 问卷题目类别 01-生育 ,02-不适症状,03-危险因素,04-所患疾病
 | 
				
			|||
        /// </summary>
 | 
				
			|||
 | 
				
			|||
        public string QuestionSubjectTypeId { get; set; } | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 启用
 | 
				
			|||
        /// </summary>
 | 
				
			|||
 | 
				
			|||
        public char? IsActive { get; set; } | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 父问卷ID
 | 
				
			|||
        /// </summary>
 | 
				
			|||
 | 
				
			|||
        public Guid? ParentId { get; set; } | 
				
			|||
      | 
				
			|||
    } | 
				
			|||
} | 
				
			|||
@ -0,0 +1,135 @@ | 
				
			|||
using Microsoft.AspNetCore.Authorization; | 
				
			|||
using Microsoft.AspNetCore.Mvc; | 
				
			|||
using Shentun.WebPeis.AppointScheduleTemplates; | 
				
			|||
using Shentun.WebPeis.Models; | 
				
			|||
using System; | 
				
			|||
using System.Collections.Generic; | 
				
			|||
using System.Linq; | 
				
			|||
using System.Text; | 
				
			|||
using System.Threading.Tasks; | 
				
			|||
using Volo.Abp.Application.Services; | 
				
			|||
using Volo.Abp.Domain.Repositories; | 
				
			|||
 | 
				
			|||
namespace Shentun.WebPeis.QuestionTypes | 
				
			|||
{ | 
				
			|||
    /// <summary>
 | 
				
			|||
    /// 问卷类型
 | 
				
			|||
    /// </summary>
 | 
				
			|||
    [ApiExplorerSettings(GroupName = "Work")] | 
				
			|||
    [Authorize] | 
				
			|||
    public class QuestionTypeAppService : ApplicationService | 
				
			|||
    { | 
				
			|||
 | 
				
			|||
        private readonly IRepository<QuestionType> _questionTypeRepository; | 
				
			|||
        private readonly QuestionTypeManager _questionTypeManager; | 
				
			|||
        private readonly CacheService _cacheService; | 
				
			|||
 | 
				
			|||
        public QuestionTypeAppService( | 
				
			|||
            IRepository<QuestionType> questionTypeRepository, | 
				
			|||
            QuestionTypeManager questionTypeManager, | 
				
			|||
            CacheService cacheService) | 
				
			|||
        { | 
				
			|||
            _questionTypeRepository = questionTypeRepository; | 
				
			|||
            _questionTypeManager = questionTypeManager; | 
				
			|||
            _cacheService = cacheService; | 
				
			|||
        } | 
				
			|||
 | 
				
			|||
 | 
				
			|||
 | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 获取列表
 | 
				
			|||
        /// </summary>
 | 
				
			|||
        /// <returns></returns>
 | 
				
			|||
        [HttpPost("api/app/QuestionType/GetList")] | 
				
			|||
        public async Task<List<QuestionTypeDto>> GetListAsync() | 
				
			|||
        { | 
				
			|||
            var entlist = await _questionTypeRepository.GetQueryableAsync(); | 
				
			|||
 | 
				
			|||
            var entdto = entlist.Select(s => new QuestionTypeDto | 
				
			|||
            { | 
				
			|||
                CreationTime = s.CreationTime, | 
				
			|||
                CreatorId = s.CreatorId, | 
				
			|||
                DisplayOrder = s.DisplayOrder, | 
				
			|||
                LastModificationTime = s.LastModificationTime, | 
				
			|||
                LastModifierId = s.LastModifierId, | 
				
			|||
                SimpleCode = s.SimpleCode, | 
				
			|||
                QuestionTypeId = s.QuestionTypeId, | 
				
			|||
                QuestionTypeName = s.QuestionTypeName, | 
				
			|||
                CreatorName = _cacheService.GetSurnameAsync(s.CreatorId).Result, | 
				
			|||
                LastModifierName = _cacheService.GetSurnameAsync(s.LastModifierId).Result | 
				
			|||
            }).OrderBy(o => o.DisplayOrder).ToList(); | 
				
			|||
 | 
				
			|||
            return entdto; | 
				
			|||
 | 
				
			|||
 | 
				
			|||
        } | 
				
			|||
 | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 创建
 | 
				
			|||
        /// </summary>
 | 
				
			|||
        /// <returns></returns>
 | 
				
			|||
        [HttpPost("api/app/QuestionType/Create")] | 
				
			|||
        public async Task<QuestionTypeDto> CreateAsync(CreateQuestionTypeDto input) | 
				
			|||
        { | 
				
			|||
            var createEntity = ObjectMapper.Map<CreateQuestionTypeDto, QuestionType>(input); | 
				
			|||
            var entity = await _questionTypeManager.CreateAsync(createEntity); | 
				
			|||
            entity = await _questionTypeRepository.InsertAsync(entity); | 
				
			|||
            var dto = ObjectMapper.Map<QuestionType, QuestionTypeDto>(entity); | 
				
			|||
            dto.CreatorName = await _cacheService.GetSurnameAsync(dto.CreatorId); | 
				
			|||
            dto.LastModifierName = await _cacheService.GetSurnameAsync(dto.LastModifierId); | 
				
			|||
            return dto; | 
				
			|||
        } | 
				
			|||
 | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 更新
 | 
				
			|||
        /// </summary>
 | 
				
			|||
        /// <param name="input"></param>
 | 
				
			|||
        /// <returns></returns>
 | 
				
			|||
        [HttpPost("api/app/QuestionType/Update")] | 
				
			|||
        public async Task<QuestionTypeDto> UpdateAsync(UpdateQuestionTypeDto input) | 
				
			|||
        { | 
				
			|||
            var entity = await _questionTypeRepository.GetAsync(f => f.QuestionTypeId == input.QuestionTypeId); | 
				
			|||
            var sourceEntity = ObjectMapper.Map<UpdateQuestionTypeDto, QuestionType>(input); | 
				
			|||
            await _questionTypeManager.UpdateAsync(sourceEntity, entity); | 
				
			|||
            entity = await _questionTypeRepository.UpdateAsync(entity); | 
				
			|||
            var dto = ObjectMapper.Map<QuestionType, QuestionTypeDto>(entity); | 
				
			|||
            dto.CreatorName = await _cacheService.GetSurnameAsync(dto.CreatorId); | 
				
			|||
            dto.LastModifierName = await _cacheService.GetSurnameAsync(dto.LastModifierId); | 
				
			|||
            return dto; | 
				
			|||
        } | 
				
			|||
 | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 删除
 | 
				
			|||
        /// </summary>
 | 
				
			|||
        /// <param name="input"></param>
 | 
				
			|||
        /// <returns></returns>
 | 
				
			|||
        [HttpPost("api/app/QuestionType/Delete")] | 
				
			|||
        public async Task DeleteAsync(QuestionTypeIdInputDto input) | 
				
			|||
        { | 
				
			|||
            await _questionTypeManager.CheckAndDeleteAsync(input.QuestionTypeId); | 
				
			|||
        } | 
				
			|||
 | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 修改排序  置顶,置底
 | 
				
			|||
        /// </summary>
 | 
				
			|||
        /// <param name="input"></param>
 | 
				
			|||
        /// <returns></returns>
 | 
				
			|||
        [HttpPost("api/app/QuestionType/UpdateSortTopOrBottom")] | 
				
			|||
        public async Task UpdateSortTopOrBottomAsync(UpdateQuestionTypeSortTopOrBottomInputDto input) | 
				
			|||
        { | 
				
			|||
            await _questionTypeManager.UpdateSortTopOrBottomAsync(input.QuestionTypeId, input.SortType); | 
				
			|||
        } | 
				
			|||
 | 
				
			|||
        /// <summary>
 | 
				
			|||
        ///  修改排序  拖拽
 | 
				
			|||
        /// </summary>
 | 
				
			|||
        /// <param name="input"></param>
 | 
				
			|||
        /// <returns></returns>
 | 
				
			|||
        [HttpPost("api/app/QuestionType/UpdateSortDragAsync")] | 
				
			|||
        public async Task UpdateSortDragAsync(UpdateQuestionTypeSortDragDto input) | 
				
			|||
        { | 
				
			|||
            await _questionTypeManager.UpdateSortDragAsync(input); | 
				
			|||
        } | 
				
			|||
 | 
				
			|||
    } | 
				
			|||
} | 
				
			|||
@ -0,0 +1,208 @@ | 
				
			|||
using Microsoft.AspNetCore.Authorization; | 
				
			|||
using Microsoft.AspNetCore.Mvc; | 
				
			|||
using Shentun.WebPeis.Models; | 
				
			|||
using Shentun.WebPeis.QuestionTypes; | 
				
			|||
using System; | 
				
			|||
using System.Collections.Generic; | 
				
			|||
using System.Linq; | 
				
			|||
using System.Text; | 
				
			|||
using System.Threading.Tasks; | 
				
			|||
using Volo.Abp.Application.Services; | 
				
			|||
using Volo.Abp.Domain.Repositories; | 
				
			|||
 | 
				
			|||
namespace Shentun.WebPeis.Questions | 
				
			|||
{ | 
				
			|||
    /// <summary>
 | 
				
			|||
    /// 问卷
 | 
				
			|||
    /// </summary>
 | 
				
			|||
    [ApiExplorerSettings(GroupName = "Work")] | 
				
			|||
    [Authorize] | 
				
			|||
    public class QuestionAppService : ApplicationService | 
				
			|||
    { | 
				
			|||
 | 
				
			|||
        private readonly IRepository<Question> _questionRepository; | 
				
			|||
        private readonly QuestionManager _questionManager; | 
				
			|||
        private readonly CacheService _cacheService; | 
				
			|||
 | 
				
			|||
        public QuestionAppService( | 
				
			|||
            IRepository<Question> questionRepository, | 
				
			|||
            QuestionManager questionManager, | 
				
			|||
            CacheService cacheService) | 
				
			|||
        { | 
				
			|||
            _questionRepository = questionRepository; | 
				
			|||
            _questionManager = questionManager; | 
				
			|||
            _cacheService = cacheService; | 
				
			|||
        } | 
				
			|||
 | 
				
			|||
        ///// <summary>
 | 
				
			|||
        ///// 获取列表
 | 
				
			|||
        ///// </summary>
 | 
				
			|||
        ///// <returns></returns>
 | 
				
			|||
        //[HttpPost("api/app/Question/GetList")]
 | 
				
			|||
        //public async Task<List<QuestionDto>> GetListAsync()
 | 
				
			|||
        //{
 | 
				
			|||
        //    var entlist = await _questionRepository.GetQueryableAsync();
 | 
				
			|||
 | 
				
			|||
        //    var entdto = entlist.Select(s => new QuestionDto
 | 
				
			|||
        //    {
 | 
				
			|||
        //        CreationTime = s.CreationTime,
 | 
				
			|||
        //        CreatorId = s.CreatorId,
 | 
				
			|||
        //        DisplayOrder = s.DisplayOrder,
 | 
				
			|||
        //        LastModificationTime = s.LastModificationTime,
 | 
				
			|||
        //        LastModifierId = s.LastModifierId,
 | 
				
			|||
        //        SimpleCode = s.SimpleCode,
 | 
				
			|||
        //        QuestionTypeId = s.QuestionTypeId,
 | 
				
			|||
        //        QuestionSubjectTypeId = s.QuestionSubjectTypeId,
 | 
				
			|||
        //        QuestionName = s.QuestionName,
 | 
				
			|||
        //        QuestionId = s.QuestionId,
 | 
				
			|||
        //        PathCode = s.PathCode,
 | 
				
			|||
        //        ParentId = s.ParentId,
 | 
				
			|||
        //        IsActive = s.IsActive,
 | 
				
			|||
        //        AnswerType = s.AnswerType,
 | 
				
			|||
        //        CreatorName = _cacheService.GetSurnameAsync(s.CreatorId).Result,
 | 
				
			|||
        //        LastModifierName = _cacheService.GetSurnameAsync(s.LastModifierId).Result
 | 
				
			|||
        //    }).OrderBy(o => o.DisplayOrder).ToList();
 | 
				
			|||
 | 
				
			|||
        //    return entdto;
 | 
				
			|||
 | 
				
			|||
 | 
				
			|||
        //}
 | 
				
			|||
 | 
				
			|||
 | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 获取问卷树型列表
 | 
				
			|||
        /// </summary>
 | 
				
			|||
        /// <returns></returns>
 | 
				
			|||
        [HttpPost("api/app/Question/GetQuestionTreeList")] | 
				
			|||
        public async Task<List<QuestionTreeListDto>> GetQuestionTreeListAsync() | 
				
			|||
        { | 
				
			|||
            var dataList = await _questionRepository.GetListAsync(); | 
				
			|||
            var items = from p in dataList.OrderBy(o => o.DisplayOrder) | 
				
			|||
                        select new QuestionTreeListDto() | 
				
			|||
                        { | 
				
			|||
                            ParentId = p.ParentId, | 
				
			|||
                            AnswerType = p.AnswerType, | 
				
			|||
                            QuestionId = p.QuestionId, | 
				
			|||
                            CreationTime = p.CreationTime, | 
				
			|||
                            CreatorId = p.CreatorId, | 
				
			|||
                            CreatorName = _cacheService.GetSurnameAsync(p.CreatorId).Result, | 
				
			|||
                            IsActive = p.IsActive, | 
				
			|||
                            LastModificationTime = p.LastModificationTime, | 
				
			|||
                            LastModifierId = p.LastModifierId, | 
				
			|||
                            LastModifierName = _cacheService.GetSurnameAsync(p.LastModifierId).Result, | 
				
			|||
                            PathCode = p.PathCode, | 
				
			|||
                            QuestionName = p.QuestionName, | 
				
			|||
                            QuestionSubjectTypeId = p.QuestionSubjectTypeId, | 
				
			|||
                            QuestionTypeId = p.QuestionTypeId, | 
				
			|||
                            SimpleCode = p.SimpleCode, | 
				
			|||
                            DisplayOrder = p.DisplayOrder | 
				
			|||
                        }; | 
				
			|||
            return GetTree(items.ToList(), 0, ""); | 
				
			|||
        } | 
				
			|||
 | 
				
			|||
       | 
				
			|||
 | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 创建
 | 
				
			|||
        /// </summary>
 | 
				
			|||
        /// <returns></returns>
 | 
				
			|||
        [HttpPost("api/app/Question/Create")] | 
				
			|||
        public async Task<QuestionDto> CreateAsync(CreateQuestionDto input) | 
				
			|||
        { | 
				
			|||
            var createEntity = ObjectMapper.Map<CreateQuestionDto, Question>(input); | 
				
			|||
            var entity = await _questionManager.CreateAsync(createEntity); | 
				
			|||
            entity = await _questionRepository.InsertAsync(entity); | 
				
			|||
            var dto = ObjectMapper.Map<Question, QuestionDto>(entity); | 
				
			|||
            dto.CreatorName = await _cacheService.GetSurnameAsync(dto.CreatorId); | 
				
			|||
            dto.LastModifierName = await _cacheService.GetSurnameAsync(dto.LastModifierId); | 
				
			|||
            return dto; | 
				
			|||
        } | 
				
			|||
 | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 更新
 | 
				
			|||
        /// </summary>
 | 
				
			|||
        /// <param name="input"></param>
 | 
				
			|||
        /// <returns></returns>
 | 
				
			|||
        [HttpPost("api/app/Question/Update")] | 
				
			|||
        public async Task<QuestionDto> UpdateAsync(UpdateQuestionDto input) | 
				
			|||
        { | 
				
			|||
            var entity = await _questionRepository.GetAsync(f => f.QuestionTypeId == input.QuestionTypeId); | 
				
			|||
            var sourceEntity = ObjectMapper.Map<UpdateQuestionDto, Question>(input); | 
				
			|||
            _questionManager.UpdateAsync(sourceEntity, entity); | 
				
			|||
            entity = await _questionRepository.UpdateAsync(entity); | 
				
			|||
            var dto = ObjectMapper.Map<Question, QuestionDto>(entity); | 
				
			|||
            dto.CreatorName = await _cacheService.GetSurnameAsync(dto.CreatorId); | 
				
			|||
            dto.LastModifierName = await _cacheService.GetSurnameAsync(dto.LastModifierId); | 
				
			|||
            return dto; | 
				
			|||
        } | 
				
			|||
 | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 删除
 | 
				
			|||
        /// </summary>
 | 
				
			|||
        /// <param name="input"></param>
 | 
				
			|||
        /// <returns></returns>
 | 
				
			|||
        [HttpPost("api/app/Question/Delete")] | 
				
			|||
        public async Task DeleteAsync(QuestionIdInputDto input) | 
				
			|||
        { | 
				
			|||
            await _questionManager.CheckAndDeleteAsync(input.QuestionId); | 
				
			|||
        } | 
				
			|||
 | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 修改排序  置顶,置底
 | 
				
			|||
        /// </summary>
 | 
				
			|||
        /// <param name="input"></param>
 | 
				
			|||
        /// <returns></returns>
 | 
				
			|||
        [HttpPost("api/app/Question/UpdateSortTopOrBottom")] | 
				
			|||
        public async Task UpdateSortTopOrBottomAsync(UpdateQuestionSortTopOrBottomInputDto input) | 
				
			|||
        { | 
				
			|||
            await _questionManager.UpdateSortTopOrBottomAsync(input.QuestionId, input.SortType); | 
				
			|||
        } | 
				
			|||
 | 
				
			|||
        /// <summary>
 | 
				
			|||
        ///  修改排序  拖拽
 | 
				
			|||
        /// </summary>
 | 
				
			|||
        /// <param name="input"></param>
 | 
				
			|||
        /// <returns></returns>
 | 
				
			|||
        [HttpPost("api/app/Question/UpdateSortDragAsync")] | 
				
			|||
        public async Task UpdateSortDragAsync(UpdateQuestionSortDragDto input) | 
				
			|||
        { | 
				
			|||
            await _questionManager.UpdateSortDragAsync(input); | 
				
			|||
        } | 
				
			|||
 | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 使用Code进行递归
 | 
				
			|||
        /// </summary>
 | 
				
			|||
        /// <param name="items"></param>
 | 
				
			|||
        /// <param name="deep"></param>
 | 
				
			|||
        /// <param name="prefix"></param>
 | 
				
			|||
        /// <returns></returns>
 | 
				
			|||
        private List<QuestionTreeListDto> GetTree(List<QuestionTreeListDto> items, int deep, string prefix) | 
				
			|||
        { | 
				
			|||
            return (from p in items | 
				
			|||
                    where p.PathCode.StartsWith(prefix) && p.PathCode.Count(a => a == '.') == deep | 
				
			|||
                    orderby p.DisplayOrder ascending | 
				
			|||
                    let subs = GetTree(items, deep + 1, p.PathCode) | 
				
			|||
                    select new QuestionTreeListDto() | 
				
			|||
                    { | 
				
			|||
                        ParentId = p.ParentId, | 
				
			|||
                        AnswerType = p.AnswerType, | 
				
			|||
                        QuestionId = p.QuestionId, | 
				
			|||
                        CreationTime = p.CreationTime, | 
				
			|||
                        CreatorId = p.CreatorId, | 
				
			|||
                        CreatorName = _cacheService.GetSurnameAsync(p.CreatorId).Result, | 
				
			|||
                        IsActive = p.IsActive, | 
				
			|||
                        LastModificationTime = p.LastModificationTime, | 
				
			|||
                        LastModifierId = p.LastModifierId, | 
				
			|||
                        LastModifierName = _cacheService.GetSurnameAsync(p.LastModifierId).Result, | 
				
			|||
                        PathCode = p.PathCode, | 
				
			|||
                        QuestionName = p.QuestionName, | 
				
			|||
                        QuestionSubjectTypeId = p.QuestionSubjectTypeId, | 
				
			|||
                        QuestionTypeId = p.QuestionTypeId, | 
				
			|||
                        SimpleCode = p.SimpleCode, | 
				
			|||
                        DisplayOrder = p.DisplayOrder, | 
				
			|||
                        TreeChildren = subs.ToList() | 
				
			|||
                    } | 
				
			|||
                    ).ToList(); | 
				
			|||
        } | 
				
			|||
    } | 
				
			|||
} | 
				
			|||
@ -0,0 +1,137 @@ | 
				
			|||
using NPOI.SS.Formula.Functions; | 
				
			|||
using Shentun.Utilities; | 
				
			|||
using Shentun.WebPeis.Models; | 
				
			|||
using System; | 
				
			|||
using System.Collections.Generic; | 
				
			|||
using System.Linq; | 
				
			|||
using System.Text; | 
				
			|||
using System.Threading.Tasks; | 
				
			|||
using Volo.Abp; | 
				
			|||
using Volo.Abp.Domain.Entities; | 
				
			|||
using Volo.Abp.Domain.Repositories; | 
				
			|||
using Volo.Abp.Domain.Services; | 
				
			|||
 | 
				
			|||
namespace Shentun.WebPeis.QuestionTypes | 
				
			|||
{ | 
				
			|||
    public class QuestionTypeManager : DomainService | 
				
			|||
    { | 
				
			|||
        private readonly IRepository<QuestionType> _questionTypeRepository; | 
				
			|||
        private readonly IRepository<Question> _questionRepository; | 
				
			|||
 | 
				
			|||
        public QuestionTypeManager( | 
				
			|||
            IRepository<QuestionType> questionTypeRepository, | 
				
			|||
            IRepository<Question> questionRepository) | 
				
			|||
        { | 
				
			|||
            _questionTypeRepository = questionTypeRepository; | 
				
			|||
            _questionRepository = questionRepository; | 
				
			|||
        } | 
				
			|||
 | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 创建
 | 
				
			|||
        /// </summary>
 | 
				
			|||
        /// <returns></returns>
 | 
				
			|||
        public async Task<QuestionType> CreateAsync(QuestionType entity) | 
				
			|||
        { | 
				
			|||
            DataHelper.CheckEntityIsNull(entity); | 
				
			|||
            DataHelper.CheckStringIsNull(entity.QuestionTypeName, "名称"); | 
				
			|||
 | 
				
			|||
            var isQuestionType = await _questionTypeRepository.FirstOrDefaultAsync(f => f.QuestionTypeName == entity.QuestionTypeName); | 
				
			|||
            if (isQuestionType != null) | 
				
			|||
                throw new UserFriendlyException($"问卷类别{entity.QuestionTypeName}已存在"); | 
				
			|||
            return new QuestionType | 
				
			|||
            { | 
				
			|||
                QuestionTypeName = entity.QuestionTypeName, | 
				
			|||
                SimpleCode = LanguageConverter.GetPYSimpleCode(entity.QuestionTypeName), | 
				
			|||
                DisplayOrder = await EntityHelper.CreateMaxDisplayOrder<QuestionType>(_questionTypeRepository), | 
				
			|||
                QuestionTypeId = entity.QuestionTypeId | 
				
			|||
            }; | 
				
			|||
        } | 
				
			|||
 | 
				
			|||
 | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 更新
 | 
				
			|||
        /// </summary>
 | 
				
			|||
        /// <param name="sourceEntity"></param>
 | 
				
			|||
        /// <param name="targetEntity"></param>
 | 
				
			|||
        /// <returns></returns>
 | 
				
			|||
        public async Task UpdateAsync( | 
				
			|||
           QuestionType sourceEntity, | 
				
			|||
           QuestionType targetEntity | 
				
			|||
          ) | 
				
			|||
        { | 
				
			|||
            DataHelper.CheckEntityIsNull(sourceEntity); | 
				
			|||
            DataHelper.CheckEntityIsNull(targetEntity); | 
				
			|||
            DataHelper.CheckStringIsNull(sourceEntity.QuestionTypeName, "名称"); | 
				
			|||
            if (sourceEntity.QuestionTypeName != targetEntity.QuestionTypeName) | 
				
			|||
            { | 
				
			|||
                var isQuestionType = await _questionTypeRepository.FirstOrDefaultAsync(f => f.QuestionTypeId != sourceEntity.QuestionTypeId | 
				
			|||
                && f.QuestionTypeName == sourceEntity.QuestionTypeName); | 
				
			|||
                if (isQuestionType != null) | 
				
			|||
                    throw new UserFriendlyException($"问卷类别{sourceEntity.QuestionTypeName}已存在"); | 
				
			|||
                targetEntity.QuestionTypeName = sourceEntity.QuestionTypeName; | 
				
			|||
                targetEntity.SimpleCode = LanguageConverter.GetPYSimpleCode(targetEntity.QuestionTypeName); | 
				
			|||
 | 
				
			|||
            } | 
				
			|||
 | 
				
			|||
        } | 
				
			|||
 | 
				
			|||
 | 
				
			|||
 | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 删除
 | 
				
			|||
        /// </summary>
 | 
				
			|||
        /// <param name="QuestionTypeId"></param>
 | 
				
			|||
        /// <returns></returns>
 | 
				
			|||
        /// <exception cref="UserFriendlyException"></exception>
 | 
				
			|||
        public async Task CheckAndDeleteAsync(string QuestionTypeId) | 
				
			|||
        { | 
				
			|||
 | 
				
			|||
            var questionEnt = await _questionRepository.FirstOrDefaultAsync(m => m.QuestionTypeId == QuestionTypeId); | 
				
			|||
            if (questionEnt != null) | 
				
			|||
            { | 
				
			|||
                throw new UserFriendlyException($"问卷类别已被使用,不能删除"); | 
				
			|||
            } | 
				
			|||
 | 
				
			|||
            await _questionTypeRepository.DeleteAsync(d => d.QuestionTypeId == QuestionTypeId); | 
				
			|||
 | 
				
			|||
        } | 
				
			|||
 | 
				
			|||
 | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 修改排序  置顶,置底
 | 
				
			|||
        /// </summary>
 | 
				
			|||
        /// <param name="id">需要修改的ID</param>
 | 
				
			|||
        /// <param name="SortType">修改方式:1 置顶   2 置底</param>
 | 
				
			|||
        /// <returns></returns>
 | 
				
			|||
        public async Task UpdateSortTopOrBottomAsync(string QuestionTypeId, int SortType) | 
				
			|||
        { | 
				
			|||
            var entity = await _questionTypeRepository.GetAsync(f => f.QuestionTypeId == QuestionTypeId); | 
				
			|||
            await EntityHelper.UpdateSortTopOrBottomAsync(_questionTypeRepository, entity, SortType); | 
				
			|||
        } | 
				
			|||
 | 
				
			|||
 | 
				
			|||
 | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 修改排序  拖拽
 | 
				
			|||
        /// </summary>
 | 
				
			|||
        /// <typeparam name="TEntity"></typeparam>
 | 
				
			|||
        /// <param name="repository"></param>
 | 
				
			|||
        /// <param name="input"></param>
 | 
				
			|||
        /// <returns></returns>
 | 
				
			|||
        public async Task UpdateSortDragAsync(UpdateQuestionTypeSortDragDto input) | 
				
			|||
        { | 
				
			|||
            var entitylist = await _questionTypeRepository.GetListAsync(o => input.ItemList.Select(s => s.QuestionTypeId).Contains(o.QuestionTypeId)); | 
				
			|||
 | 
				
			|||
            foreach (var entity in entitylist) | 
				
			|||
            { | 
				
			|||
                foreach (var item in input.ItemList) | 
				
			|||
                { | 
				
			|||
                    if (item.QuestionTypeId == entity.QuestionTypeId) | 
				
			|||
                        entity.DisplayOrder = item.DisplayOrder; | 
				
			|||
                } | 
				
			|||
            } | 
				
			|||
 | 
				
			|||
            await _questionTypeRepository.UpdateManyAsync(entitylist); | 
				
			|||
        } | 
				
			|||
    } | 
				
			|||
} | 
				
			|||
@ -0,0 +1,17 @@ | 
				
			|||
using System; | 
				
			|||
using System.Collections.Generic; | 
				
			|||
using System.Text; | 
				
			|||
 | 
				
			|||
namespace Shentun.WebPeis.QuestionTypes | 
				
			|||
{ | 
				
			|||
    public class UpdateQuestionTypeSortDragDto | 
				
			|||
    { | 
				
			|||
        public List<UpdateQuestionTypeSortDragDetail> ItemList { get; set; } | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    public class UpdateQuestionTypeSortDragDetail | 
				
			|||
    { | 
				
			|||
        public string QuestionTypeId { get; set; } | 
				
			|||
        public int DisplayOrder { get; set; } | 
				
			|||
    } | 
				
			|||
} | 
				
			|||
@ -0,0 +1,16 @@ | 
				
			|||
using System; | 
				
			|||
using System.Collections.Generic; | 
				
			|||
using System.Text; | 
				
			|||
 | 
				
			|||
namespace Shentun.WebPeis.QuestionTypes | 
				
			|||
{ | 
				
			|||
    public class UpdateQuestionTypeSortTopOrBottomInputDto | 
				
			|||
    { | 
				
			|||
        public string QuestionTypeId { get; set; } | 
				
			|||
 | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 修改方式:1 置顶   2 置底
 | 
				
			|||
        /// </summary>
 | 
				
			|||
        public int SortType { get; set; } | 
				
			|||
    } | 
				
			|||
} | 
				
			|||
@ -0,0 +1,197 @@ | 
				
			|||
using NPOI.POIFS.Properties; | 
				
			|||
using Shentun.Utilities; | 
				
			|||
using Shentun.WebPeis.Models; | 
				
			|||
using Shentun.WebPeis.QuestionTypes; | 
				
			|||
using System; | 
				
			|||
using System.Collections.Generic; | 
				
			|||
using System.Linq; | 
				
			|||
using System.Text; | 
				
			|||
using System.Threading.Tasks; | 
				
			|||
using Volo.Abp; | 
				
			|||
using Volo.Abp.Domain.Entities; | 
				
			|||
using Volo.Abp.Domain.Repositories; | 
				
			|||
using Volo.Abp.Domain.Services; | 
				
			|||
 | 
				
			|||
namespace Shentun.WebPeis.Questions | 
				
			|||
{ | 
				
			|||
    public class QuestionManager : DomainService | 
				
			|||
    { | 
				
			|||
 | 
				
			|||
        private readonly IRepository<Question> _questionRepository; | 
				
			|||
 | 
				
			|||
        public QuestionManager( | 
				
			|||
            IRepository<Question> questionRepository | 
				
			|||
            ) | 
				
			|||
        { | 
				
			|||
            _questionRepository = questionRepository; | 
				
			|||
        } | 
				
			|||
 | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 创建
 | 
				
			|||
        /// </summary>
 | 
				
			|||
        /// <returns></returns>
 | 
				
			|||
        public async Task<Question> CreateAsync(Question entity) | 
				
			|||
        { | 
				
			|||
            DataHelper.CheckEntityIsNull(entity); | 
				
			|||
            //DataHelper.CheckStringIsNull(entity.QuestionTypeName, "名称");
 | 
				
			|||
 | 
				
			|||
            return new Question | 
				
			|||
            { | 
				
			|||
                AnswerType = entity.AnswerType, | 
				
			|||
                IsActive = entity.IsActive, | 
				
			|||
                ParentId = entity.ParentId, | 
				
			|||
                PathCode = await CreatePathCode(entity.ParentId), | 
				
			|||
                QuestionId = entity.QuestionId, | 
				
			|||
                QuestionName = entity.QuestionName, | 
				
			|||
                QuestionSubjectTypeId = entity.QuestionSubjectTypeId, | 
				
			|||
                SimpleCode = LanguageConverter.GetPYSimpleCode(entity.QuestionName), | 
				
			|||
                DisplayOrder = await EntityHelper.CreateMaxDisplayOrder<Question>(_questionRepository), | 
				
			|||
                QuestionTypeId = entity.QuestionTypeId | 
				
			|||
            }; | 
				
			|||
        } | 
				
			|||
 | 
				
			|||
 | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 更新
 | 
				
			|||
        /// </summary>
 | 
				
			|||
        /// <param name="sourceEntity"></param>
 | 
				
			|||
        /// <param name="targetEntity"></param>
 | 
				
			|||
        /// <returns></returns>
 | 
				
			|||
        public void UpdateAsync( | 
				
			|||
           Question sourceEntity, | 
				
			|||
           Question targetEntity | 
				
			|||
          ) | 
				
			|||
        { | 
				
			|||
            DataHelper.CheckEntityIsNull(sourceEntity); | 
				
			|||
            DataHelper.CheckEntityIsNull(targetEntity); | 
				
			|||
            //DataHelper.CheckStringIsNull(sourceEntity.QuestionTypeName, "名称");
 | 
				
			|||
 | 
				
			|||
 | 
				
			|||
            targetEntity.AnswerType = sourceEntity.AnswerType; | 
				
			|||
            targetEntity.IsActive = sourceEntity.IsActive; | 
				
			|||
            targetEntity.ParentId = sourceEntity.ParentId; | 
				
			|||
            targetEntity.QuestionName = sourceEntity.QuestionName; | 
				
			|||
            targetEntity.QuestionSubjectTypeId = sourceEntity.QuestionSubjectTypeId; | 
				
			|||
            targetEntity.SimpleCode = LanguageConverter.GetPYSimpleCode(sourceEntity.QuestionName); | 
				
			|||
            targetEntity.QuestionTypeId = sourceEntity.QuestionTypeId; | 
				
			|||
 | 
				
			|||
        } | 
				
			|||
 | 
				
			|||
 | 
				
			|||
 | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 删除
 | 
				
			|||
        /// </summary>
 | 
				
			|||
        /// <param name="QuestionId"></param>
 | 
				
			|||
        /// <returns></returns>
 | 
				
			|||
        /// <exception cref="UserFriendlyException"></exception>
 | 
				
			|||
        public async Task CheckAndDeleteAsync(Guid QuestionId) | 
				
			|||
        { | 
				
			|||
 | 
				
			|||
            //var questionEnt = await _questionRepository.FirstOrDefaultAsync(m => m.QuestionTypeId == QuestionTypeId);
 | 
				
			|||
            //if (questionEnt != null)
 | 
				
			|||
            //{
 | 
				
			|||
            //    throw new UserFriendlyException($"问卷类别已被使用,不能删除");
 | 
				
			|||
            //}
 | 
				
			|||
 | 
				
			|||
            await _questionRepository.DeleteAsync(d => d.QuestionId == QuestionId); | 
				
			|||
 | 
				
			|||
        } | 
				
			|||
 | 
				
			|||
 | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 修改排序  置顶,置底
 | 
				
			|||
        /// </summary>
 | 
				
			|||
        /// <param name="id">需要修改的ID</param>
 | 
				
			|||
        /// <param name="SortType">修改方式:1 置顶   2 置底</param>
 | 
				
			|||
        /// <returns></returns>
 | 
				
			|||
        public async Task UpdateSortTopOrBottomAsync(Guid QuestionId, int SortType) | 
				
			|||
        { | 
				
			|||
            var entity = await _questionRepository.GetAsync(f => f.QuestionId == QuestionId); | 
				
			|||
            await EntityHelper.UpdateSortTopOrBottomAsync(_questionRepository, entity, SortType); | 
				
			|||
        } | 
				
			|||
 | 
				
			|||
 | 
				
			|||
 | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 修改排序  拖拽
 | 
				
			|||
        /// </summary>
 | 
				
			|||
        /// <typeparam name="TEntity"></typeparam>
 | 
				
			|||
        /// <param name="repository"></param>
 | 
				
			|||
        /// <param name="input"></param>
 | 
				
			|||
        /// <returns></returns>
 | 
				
			|||
        public async Task UpdateSortDragAsync(UpdateQuestionSortDragDto input) | 
				
			|||
        { | 
				
			|||
            var entitylist = await _questionRepository.GetListAsync(o => input.ItemList.Select(s => s.QuestionId).Contains(o.QuestionId)); | 
				
			|||
 | 
				
			|||
            foreach (var entity in entitylist) | 
				
			|||
            { | 
				
			|||
                foreach (var item in input.ItemList) | 
				
			|||
                { | 
				
			|||
                    if (item.QuestionId == entity.QuestionId) | 
				
			|||
                        entity.DisplayOrder = item.DisplayOrder; | 
				
			|||
                } | 
				
			|||
            } | 
				
			|||
 | 
				
			|||
            await _questionRepository.UpdateManyAsync(entitylist); | 
				
			|||
        } | 
				
			|||
 | 
				
			|||
 | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 自动生成pathcode
 | 
				
			|||
        /// </summary>
 | 
				
			|||
        /// <param name="parentId"></param>
 | 
				
			|||
        /// <returns></returns>
 | 
				
			|||
        public async Task<string> CreatePathCode(Guid? parentId) | 
				
			|||
        { | 
				
			|||
            string PathCode = "00001"; | 
				
			|||
            //一级
 | 
				
			|||
            if (parentId == null || parentId == Guid.Empty) | 
				
			|||
            { | 
				
			|||
                //最大pathcode
 | 
				
			|||
                var LastPathCode = (await _questionRepository.GetListAsync(o => o.ParentId == Guid.Empty || o.ParentId == null)) | 
				
			|||
                        .OrderByDescending(o => | 
				
			|||
                        { | 
				
			|||
                            var sortCode = o.PathCode.Replace(".", ""); | 
				
			|||
                            return Convert.ToInt32(sortCode); | 
				
			|||
                        }).FirstOrDefault(); | 
				
			|||
                if (LastPathCode != null) | 
				
			|||
                { | 
				
			|||
                    PathCode = (Convert.ToInt32(LastPathCode.PathCode) + 1).ToString().PadLeft(5, '0'); | 
				
			|||
                } | 
				
			|||
                else | 
				
			|||
                { | 
				
			|||
                    PathCode = "00001"; | 
				
			|||
                } | 
				
			|||
            } | 
				
			|||
            else | 
				
			|||
            { | 
				
			|||
                //二级以及以上
 | 
				
			|||
 | 
				
			|||
 | 
				
			|||
                //上级pathcode
 | 
				
			|||
                var ParentPathCode = (await _questionRepository.GetListAsync(o => o.QuestionId == parentId)).FirstOrDefault().PathCode; | 
				
			|||
 | 
				
			|||
                //最大pathcode
 | 
				
			|||
                var LastPathCode = (await _questionRepository.GetListAsync(o => o.ParentId == parentId)) | 
				
			|||
                     .OrderByDescending(o => | 
				
			|||
                     { | 
				
			|||
                         var sortCode = o.PathCode.Replace(".", ""); | 
				
			|||
                         return Convert.ToInt32(sortCode); | 
				
			|||
                     }).Select(s => s.PathCode).FirstOrDefault(); | 
				
			|||
 | 
				
			|||
                if (!string.IsNullOrEmpty(LastPathCode)) | 
				
			|||
                { | 
				
			|||
                    var MaxCode = LastPathCode.Split('.').Last(); | 
				
			|||
                    PathCode = ParentPathCode + "." + (Convert.ToInt32(MaxCode) + 1).ToString().PadLeft(5, '0'); | 
				
			|||
                } | 
				
			|||
                else | 
				
			|||
                { | 
				
			|||
                    PathCode = ParentPathCode + ".00001"; | 
				
			|||
                } | 
				
			|||
            } | 
				
			|||
 | 
				
			|||
            return PathCode; | 
				
			|||
        } | 
				
			|||
    } | 
				
			|||
} | 
				
			|||
@ -0,0 +1,20 @@ | 
				
			|||
using System; | 
				
			|||
using System.Collections.Generic; | 
				
			|||
using System.Linq; | 
				
			|||
using System.Text; | 
				
			|||
using System.Threading.Tasks; | 
				
			|||
 | 
				
			|||
namespace Shentun.WebPeis.Questions | 
				
			|||
{ | 
				
			|||
    public class UpdateQuestionSortDragDto | 
				
			|||
    { | 
				
			|||
        public List<UpdateQuestionSortDragDetail> ItemList { get; set; } | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
 | 
				
			|||
    public class UpdateQuestionSortDragDetail | 
				
			|||
    { | 
				
			|||
        public Guid QuestionId { get; set; } | 
				
			|||
        public int DisplayOrder { get; set; } | 
				
			|||
    } | 
				
			|||
} | 
				
			|||
@ -0,0 +1,18 @@ | 
				
			|||
using System; | 
				
			|||
using System.Collections.Generic; | 
				
			|||
using System.Linq; | 
				
			|||
using System.Text; | 
				
			|||
using System.Threading.Tasks; | 
				
			|||
 | 
				
			|||
namespace Shentun.WebPeis.Questions | 
				
			|||
{ | 
				
			|||
    public class UpdateQuestionSortTopOrBottomInputDto | 
				
			|||
    { | 
				
			|||
        public Guid QuestionId { get; set; } | 
				
			|||
 | 
				
			|||
        /// <summary>
 | 
				
			|||
        /// 修改方式:1 置顶   2 置底
 | 
				
			|||
        /// </summary>
 | 
				
			|||
        public int SortType { get; set; } | 
				
			|||
    } | 
				
			|||
} | 
				
			|||
						Write
						Preview
					
					
					Loading…
					
					Cancel
						Save
					
		Reference in new issue