修改
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
//--------------------------------------------------------------------
|
||||
// 此代码由T4模板自动生成 byzhouhang 20210918
|
||||
// 生成时间 2023-02-13 10:33:22
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using IRaCIS.Core.Application.Interfaces;
|
||||
using IRaCIS.Core.Application.ViewModel;
|
||||
namespace IRaCIS.Core.Application.Service
|
||||
{
|
||||
/// <summary>
|
||||
/// 快捷键服务
|
||||
/// </summary>
|
||||
[ApiExplorerSettings(GroupName = "Reading")]
|
||||
public class ShortcutKeyService: BaseService
|
||||
{
|
||||
private readonly IRepository<Dictionary> _dictionaryRepository;
|
||||
private readonly IRepository<DefaultShortcutKey> _defaultShortcutKeyRepository;
|
||||
|
||||
public ShortcutKeyService(
|
||||
IRepository<Dictionary> DictionaryRepository,
|
||||
IRepository<DefaultShortcutKey> defaultShortcutKeyRepository
|
||||
)
|
||||
{
|
||||
_dictionaryRepository = DictionaryRepository;
|
||||
_defaultShortcutKeyRepository = defaultShortcutKeyRepository;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取默认快捷键
|
||||
/// </summary>
|
||||
/// <param name="inQuery"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<List<DefaultShortcutKeyView>> GetDefaultShortcutKeyList(DefaultShortcutKeyQuery inQuery)
|
||||
{
|
||||
var defaultShortcutKey = await _defaultShortcutKeyRepository.Where(x => x.ImageToolType == inQuery.ImageToolType).ToListAsync();
|
||||
var shortcutKeydic = await _dictionaryRepository.Where(x => x.Parent.Code == "ShortcutKey").ToListAsync();
|
||||
var result = shortcutKeydic.OrderBy(x=>x.ShowOrder).Select(x => new DefaultShortcutKeyView()
|
||||
{
|
||||
|
||||
Id = x.Id,
|
||||
ImageToolType = inQuery.ImageToolType,
|
||||
ShortcutKeyEnum = int.Parse(x.Code),
|
||||
Keyboardkey = defaultShortcutKey.Where(y => y.ShortcutKeyEnum == int.Parse(x.Code)).Select(y => y.Keyboardkey).FirstOrDefault() ?? string.Empty,
|
||||
}).ToList();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取医生快捷键
|
||||
/// </summary>
|
||||
/// <param name="inQuery"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<List<DefaultShortcutKeyView>> GetDoctorShortcutKey(DefaultShortcutKeyQuery inQuery)
|
||||
{
|
||||
var defaultShortcutKey = await _defaultShortcutKeyRepository.Where(x => x.ImageToolType == inQuery.ImageToolType).ToListAsync();
|
||||
var shortcutKeydic = await _dictionaryRepository.Where(x => x.Parent.Code == "ShortcutKey").ToListAsync();
|
||||
var result = shortcutKeydic.OrderBy(x => x.ShowOrder).Select(x => new DefaultShortcutKeyView()
|
||||
{
|
||||
|
||||
Id = x.Id,
|
||||
ImageToolType = inQuery.ImageToolType,
|
||||
ShortcutKeyEnum = int.Parse(x.Code),
|
||||
Keyboardkey = defaultShortcutKey.Where(y => y.ShortcutKeyEnum == int.Parse(x.Code)).Select(y => y.Keyboardkey).FirstOrDefault() ?? string.Empty,
|
||||
}).ToList();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 设置默认快捷键
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<bool> SetDefaultShortcutKey(SetDefaultShortcutKey inDto)
|
||||
{
|
||||
await _defaultShortcutKeyRepository.BatchDeleteNoTrackingAsync(x => x.ImageToolType == inDto.ImageToolType);
|
||||
|
||||
await _defaultShortcutKeyRepository.AddRangeAsync(inDto.ShortcutKeyList.Select(x => new DefaultShortcutKey()
|
||||
{
|
||||
ImageToolType = inDto.ImageToolType,
|
||||
Keyboardkey = x.Keyboardkey,
|
||||
ShortcutKeyEnum = x.ShortcutKeyEnum
|
||||
|
||||
}));
|
||||
|
||||
return await _defaultShortcutKeyRepository.SaveChangesAsync();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user