修改一版
This commit is contained in:
@@ -17,55 +17,15 @@ namespace IRaCIS.Core.Application.Service
|
||||
public class ShortcutKeyService: BaseService
|
||||
{
|
||||
private readonly IRepository<Dictionary> _dictionaryRepository;
|
||||
private readonly IRepository<DefaultShortcutKey> _defaultShortcutKeyRepository;
|
||||
private readonly IRepository<ShortcutKey> _shortcutKeyRepository;
|
||||
|
||||
public ShortcutKeyService(
|
||||
IRepository<Dictionary> DictionaryRepository,
|
||||
IRepository<DefaultShortcutKey> defaultShortcutKeyRepository
|
||||
IRepository<ShortcutKey> shortcutKeyRepository
|
||||
)
|
||||
{
|
||||
_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")
|
||||
.WhereIf(inQuery.ShortcutKeyEnum!=null,x=>x.Code==inQuery.ShortcutKeyEnum.ToString()).ToListAsync();
|
||||
|
||||
|
||||
List<DefaultShortcutKeyView> result = new List<DefaultShortcutKeyView>();
|
||||
|
||||
shortcutKeydic.OrderBy(x => x.ShowOrder).ForEach(x =>
|
||||
{
|
||||
var key= defaultShortcutKey.Where(y => y.ShortcutKeyEnum == int.Parse(x.Code)).FirstOrDefault();
|
||||
|
||||
var isnull = key == null;
|
||||
|
||||
result.Add(new DefaultShortcutKeyView()
|
||||
{
|
||||
Id = x.Id,
|
||||
ImageToolType = inQuery.ImageToolType,
|
||||
ShortcutKeyEnum = int.Parse(x.Code),
|
||||
Keyboardkey = isnull ? string.Empty : key.Keyboardkey,
|
||||
AltKey = isnull ? false : key.AltKey,
|
||||
CtrlKey = isnull ? false : key.CtrlKey,
|
||||
MetaKey = isnull ? false : key.MetaKey,
|
||||
ShiftKey = isnull ? false : key.ShiftKey
|
||||
}) ;
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
return result;
|
||||
_shortcutKeyRepository = shortcutKeyRepository;
|
||||
}
|
||||
|
||||
|
||||
@@ -77,29 +37,130 @@ namespace IRaCIS.Core.Application.Service
|
||||
[HttpPost]
|
||||
public async Task<List<DefaultShortcutKeyView>> GetDoctorShortcutKey(DefaultShortcutKeyQuery inQuery)
|
||||
{
|
||||
return await this.GetDefaultShortcutKeyList(inQuery);
|
||||
var shortcutKeyList = await _shortcutKeyRepository.Where(x => x.ImageToolType == inQuery.ImageToolType)
|
||||
.Where(x=>x.UserId==_userInfo.Id)
|
||||
.ToListAsync();
|
||||
|
||||
var defaultshortcutKeyList = this.GetDefaultShortcutKey();
|
||||
|
||||
var shortcutKeydic = await _dictionaryRepository.Where(x => x.Parent.Code == "ShortcutKey")
|
||||
.WhereIf(inQuery.ShortcutKeyEnum != null, x => x.Code == inQuery.ShortcutKeyEnum.ToString()).ToListAsync();
|
||||
|
||||
|
||||
List<DefaultShortcutKeyView> result = new List<DefaultShortcutKeyView>();
|
||||
|
||||
shortcutKeydic.OrderBy(x => x.ShowOrder).ForEach(x =>
|
||||
{
|
||||
var key = shortcutKeyList.Where(y => y.ShortcutKeyEnum == int.Parse(x.Code)).FirstOrDefault();
|
||||
var defaultkey= defaultshortcutKeyList.Where(y => y.ShortcutKeyEnum == int.Parse(x.Code)).FirstOrDefault();
|
||||
var isnull = key == null;
|
||||
|
||||
result.Add(new DefaultShortcutKeyView()
|
||||
{
|
||||
Id = x.Id,
|
||||
ImageToolType = inQuery.ImageToolType,
|
||||
ShortcutKeyEnum = int.Parse(x.Code),
|
||||
Keyboardkey = isnull ? defaultkey.Keyboardkey : key.Keyboardkey,
|
||||
AltKey = isnull ? false : key.AltKey,
|
||||
CtrlKey = isnull ? false : key.CtrlKey,
|
||||
MetaKey = isnull ? false : key.MetaKey,
|
||||
ShiftKey = isnull ? false : key.ShiftKey,
|
||||
KeyboardShow = isnull ? defaultkey.KeyboardShow : key.KeyboardShow,
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取默认快捷键
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private List<ShortcutKey> GetDefaultShortcutKey()
|
||||
{
|
||||
List<ShortcutKey> shortcutKeys = new List<ShortcutKey>() {
|
||||
new ShortcutKey (){ ShortcutKeyEnum=1,Keyboardkey="right",KeyboardShow="right" },
|
||||
new ShortcutKey (){ ShortcutKeyEnum=2,Keyboardkey="left",KeyboardShow="left"},
|
||||
new ShortcutKey (){ ShortcutKeyEnum=3,Keyboardkey="PageUp",KeyboardShow="PageUp"},
|
||||
new ShortcutKey (){ ShortcutKeyEnum=4,Keyboardkey="pageDown",KeyboardShow="pageDown"},
|
||||
new ShortcutKey (){ ShortcutKeyEnum=5,Keyboardkey="Up",KeyboardShow="Up"},
|
||||
new ShortcutKey (){ ShortcutKeyEnum=6,Keyboardkey="Down",KeyboardShow="Down"},
|
||||
new ShortcutKey (){ ShortcutKeyEnum=7,Keyboardkey="L",KeyboardShow="L"},
|
||||
new ShortcutKey (){ ShortcutKeyEnum=8,Keyboardkey="R",KeyboardShow="R"},
|
||||
new ShortcutKey (){ ShortcutKeyEnum=9,Keyboardkey="H",KeyboardShow="H"},
|
||||
new ShortcutKey (){ ShortcutKeyEnum=10,Keyboardkey="V" ,KeyboardShow="V"},
|
||||
new ShortcutKey (){ ShortcutKeyEnum=11,Keyboardkey="+" ,KeyboardShow="+"},
|
||||
new ShortcutKey (){ ShortcutKeyEnum=12,Keyboardkey="-" ,KeyboardShow="-"},
|
||||
new ShortcutKey (){ ShortcutKeyEnum=13,Keyboardkey="=" ,KeyboardShow="="},
|
||||
new ShortcutKey (){ ShortcutKeyEnum=14,Keyboardkey="F" ,KeyboardShow="F"},
|
||||
new ShortcutKey (){ ShortcutKeyEnum=15,Keyboardkey="S" ,KeyboardShow="S"},
|
||||
new ShortcutKey (){ ShortcutKeyEnum=16,Keyboardkey="I" ,KeyboardShow="I"},
|
||||
new ShortcutKey (){ ShortcutKeyEnum=17,Keyboardkey="C" ,KeyboardShow="C"},
|
||||
new ShortcutKey (){ ShortcutKeyEnum=18,Keyboardkey="Space" ,KeyboardShow="Space"},
|
||||
};
|
||||
|
||||
return shortcutKeys;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置默认快捷键
|
||||
/// 重置为默认快捷键
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<bool> RestoreDefaultShortcutKey(RestoreDefaultShortcutKeyInDto inDto)
|
||||
{
|
||||
var shortcutKeys = GetDefaultShortcutKey();
|
||||
shortcutKeys.ForEach(x => {
|
||||
x.UserId = _userInfo.Id;
|
||||
});
|
||||
|
||||
await _shortcutKeyRepository.BatchDeleteNoTrackingAsync(x => x.ImageToolType == inDto.ImageToolType && x.UserId == _userInfo.Id);
|
||||
|
||||
await _shortcutKeyRepository.AddRangeAsync(shortcutKeys.Select(x => new ShortcutKey()
|
||||
{
|
||||
ImageToolType = inDto.ImageToolType,
|
||||
Keyboardkey = x.Keyboardkey,
|
||||
ShortcutKeyEnum = x.ShortcutKeyEnum,
|
||||
UserId = _userInfo.Id,
|
||||
AltKey = x.AltKey,
|
||||
CtrlKey = x.CtrlKey,
|
||||
MetaKey = x.MetaKey,
|
||||
ShiftKey = x.ShiftKey,
|
||||
KeyboardShow = x.KeyboardShow,
|
||||
}));
|
||||
|
||||
return await _shortcutKeyRepository.SaveChangesAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置快捷键
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<bool> SetDefaultShortcutKey(SetDefaultShortcutKey inDto)
|
||||
public async Task<bool> SetShortcutKey(SetDefaultShortcutKey inDto)
|
||||
{
|
||||
await _defaultShortcutKeyRepository.BatchDeleteNoTrackingAsync(x => x.ImageToolType == inDto.ImageToolType);
|
||||
await _shortcutKeyRepository.BatchDeleteNoTrackingAsync(x => x.ImageToolType == inDto.ImageToolType&&x.UserId==_userInfo.Id);
|
||||
|
||||
await _defaultShortcutKeyRepository.AddRangeAsync(inDto.ShortcutKeyList.Select(x => new DefaultShortcutKey()
|
||||
await _shortcutKeyRepository.AddRangeAsync(inDto.ShortcutKeyList.Select(x => new ShortcutKey()
|
||||
{
|
||||
ImageToolType = inDto.ImageToolType,
|
||||
Keyboardkey = x.Keyboardkey,
|
||||
ShortcutKeyEnum = x.ShortcutKeyEnum
|
||||
|
||||
ShortcutKeyEnum = x.ShortcutKeyEnum,
|
||||
UserId=_userInfo.Id,
|
||||
AltKey=x.AltKey,
|
||||
CtrlKey=x.CtrlKey,
|
||||
MetaKey=x.MetaKey,
|
||||
ShiftKey=x.ShiftKey,
|
||||
KeyboardShow=x.KeyboardShow,
|
||||
}));
|
||||
|
||||
return await _defaultShortcutKeyRepository.SaveChangesAsync();
|
||||
return await _shortcutKeyRepository.SaveChangesAsync();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user