using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.DotNet.PlatformAbstractions;
using Microsoft.Extensions.DependencyModel;
using Shentun.Peis.Models;
using Shentun.Peis.RegisterCheckSummarys;
using System;
using System.CodeDom;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Identity;
namespace Shentun.Peis.RegisterCheckSuggestions
{
///
/// 建议
///
[ApiExplorerSettings(GroupName = "Work")]
[Authorize]
public class RegisterCheckSuggestionAppService : ApplicationService
{
private readonly IRepository _registerCheckSuggestionRepository;
private readonly IRepository _userRepository;
private readonly RegisterCheckSuggestionManager _registerCheckSuggestionManager;
public RegisterCheckSuggestionAppService(
IRepository registerCheckSuggestionRepository,
IRepository userRepository,
RegisterCheckSuggestionManager registerCheckSuggestionManager
)
{
this._registerCheckSuggestionRepository = registerCheckSuggestionRepository;
this._userRepository = userRepository;
this._registerCheckSuggestionManager = registerCheckSuggestionManager;
}
///
/// 批量生成建议 先删除全部,然后批量创建,前台调用直接传所有的建议就行
///
///
///
[HttpPost("api/app/registerchecksuggestion/createregisterchecksuggestionmany")]
public async Task CreateRegisterCheckSuggestionManyAsync(CreateRegisterCheckSuggestionDto input)
{
throw new Exception("禁止");
List dtolist = ObjectMapper.Map, List>(input.Details);
// await _registerCheckSuggestionRepository.DeleteAsync(m => m.RegisterCheckId == input[0].RegisterCheckId, true);
await _registerCheckSuggestionManager.CheckAndDeleteAsync(input.RegisterCheckId);
await _registerCheckSuggestionManager.CreateRegisterCheckSuggestionManyAsync(dtolist);
}
///
/// 根据RegisterCheckId获取检查建议数据
///
/// RegisterCheck表ID
///
[HttpGet("api/app/registerchecksuggestion/getregisterchecksuggestionlist")]
public async Task> GetRegisterCheckSuggestionListAsync(Guid RegisterCheckId)
{
var entlist = (await _registerCheckSuggestionRepository.GetListAsync(m => m.RegisterCheckId == RegisterCheckId)).OrderBy(o => o.DisplayOrder).ToList();
var userList = await _userRepository.GetListAsync();
var entlistdto = entlist.Select(s => new RegisterCheckSuggestionDto
{
CreationTime = s.CreationTime,
DisplayOrder = s.DisplayOrder,
CreatorId = s.CreatorId,
Id = s.Id,
LastModificationTime = s.LastModificationTime,
LastModifierId = s.LastModifierId,
RegisterCheckId = s.RegisterCheckId,
Suggestion = s.Suggestion,
CreatorName = EntityHelper.GetUserNameNoSql(userList, s.CreatorId),
LastModifierName = EntityHelper.GetUserNameNoSql(userList, s.LastModifierId)
}).ToList();
return entlistdto;
}
}
}