Merge branch 'master' of http://192.168.1.2:8033/IRaCIS_Core_Api
						commit
						2175755cd6
					
				| 
						 | 
				
			
			@ -10,164 +10,347 @@ using IRaCIS.Core.Application.Interfaces;
 | 
			
		|||
using IRaCIS.Core.Application.ViewModel;
 | 
			
		||||
namespace IRaCIS.Core.Application.Service
 | 
			
		||||
{
 | 
			
		||||
	/// <summary>
 | 
			
		||||
	/// 快捷键服务
 | 
			
		||||
	/// </summary>	
 | 
			
		||||
	[ApiExplorerSettings(GroupName = "Reading")]
 | 
			
		||||
	public class ShortcutKeyService: BaseService
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 快捷键服务
 | 
			
		||||
    /// </summary>	
 | 
			
		||||
    [ApiExplorerSettings(GroupName = "Reading")]
 | 
			
		||||
    public class ShortcutKeyService : BaseService
 | 
			
		||||
    {
 | 
			
		||||
        private readonly IRepository<Dictionary> _dictionaryRepository;
 | 
			
		||||
        private readonly IRepository<ShortcutKey> _shortcutKeyRepository;
 | 
			
		||||
 | 
			
		||||
		public ShortcutKeyService(
 | 
			
		||||
			IRepository<Dictionary> DictionaryRepository,
 | 
			
		||||
			IRepository<ShortcutKey> shortcutKeyRepository
 | 
			
		||||
			)
 | 
			
		||||
		{
 | 
			
		||||
        public ShortcutKeyService(
 | 
			
		||||
            IRepository<Dictionary> DictionaryRepository,
 | 
			
		||||
            IRepository<ShortcutKey> shortcutKeyRepository
 | 
			
		||||
            )
 | 
			
		||||
        {
 | 
			
		||||
            _dictionaryRepository = DictionaryRepository;
 | 
			
		||||
            _shortcutKeyRepository = shortcutKeyRepository;
 | 
			
		||||
		}
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		/// <summary>
 | 
			
		||||
		/// 获取医生快捷键
 | 
			
		||||
		/// </summary>
 | 
			
		||||
		/// <param name="inQuery"></param>
 | 
			
		||||
		/// <returns></returns>
 | 
			
		||||
		[HttpPost]
 | 
			
		||||
		public async Task<List<DefaultShortcutKeyView>> GetDoctorShortcutKey(DefaultShortcutKeyQuery 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,
 | 
			
		||||
					Text = isnull ? defaultkey.Text : key.Text,
 | 
			
		||||
					Code = isnull ? defaultkey.Code : key.Code,
 | 
			
		||||
				});
 | 
			
		||||
 | 
			
		||||
			});
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
			return result;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		/// <summary>
 | 
			
		||||
		/// 获取默认快捷键
 | 
			
		||||
		/// </summary>
 | 
			
		||||
		/// <returns></returns>
 | 
			
		||||
		private List<ShortcutKey> GetDefaultShortcutKey()
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 获取医生快捷键
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="inQuery"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        [HttpPost]
 | 
			
		||||
        public async Task<List<DefaultShortcutKeyView>> GetDoctorShortcutKey(DefaultShortcutKeyQuery inQuery)
 | 
			
		||||
        {
 | 
			
		||||
			List<ShortcutKey> shortcutKeys = new List<ShortcutKey>() {
 | 
			
		||||
			new ShortcutKey (){ ShortcutKeyEnum=1,Keyboardkey="right",Text="right" },
 | 
			
		||||
			new ShortcutKey (){ ShortcutKeyEnum=2,Keyboardkey="left",Text="left"},
 | 
			
		||||
			new ShortcutKey (){ ShortcutKeyEnum=3,Keyboardkey="PageUp",Text="PageUp"},
 | 
			
		||||
			new ShortcutKey (){ ShortcutKeyEnum=4,Keyboardkey="pageDown",Text="pageDown"},
 | 
			
		||||
			new ShortcutKey (){ ShortcutKeyEnum=5,Keyboardkey="Up",Text="Up"},
 | 
			
		||||
			new ShortcutKey (){ ShortcutKeyEnum=6,Keyboardkey="Down",Text="Down"},
 | 
			
		||||
			new ShortcutKey (){ ShortcutKeyEnum=7,Keyboardkey="L",Text="L"},
 | 
			
		||||
			new ShortcutKey (){ ShortcutKeyEnum=8,Keyboardkey="R",Text="R"},
 | 
			
		||||
			new ShortcutKey (){ ShortcutKeyEnum=9,Keyboardkey="H",Text="H"},
 | 
			
		||||
			new ShortcutKey (){ ShortcutKeyEnum=10,Keyboardkey="V" ,Text="V"},
 | 
			
		||||
			new ShortcutKey (){ ShortcutKeyEnum=11,Keyboardkey="+" ,Text="+"},
 | 
			
		||||
			new ShortcutKey (){ ShortcutKeyEnum=12,Keyboardkey="-" ,Text="-"},
 | 
			
		||||
			new ShortcutKey (){ ShortcutKeyEnum=13,Keyboardkey="=" ,Text="="},
 | 
			
		||||
			new ShortcutKey (){ ShortcutKeyEnum=14,Keyboardkey="F" ,Text="F"},
 | 
			
		||||
			new ShortcutKey (){ ShortcutKeyEnum=15,Keyboardkey="S" ,Text="S"},
 | 
			
		||||
			new ShortcutKey (){ ShortcutKeyEnum=16,Keyboardkey="I" ,Text="I"},
 | 
			
		||||
			new ShortcutKey (){ ShortcutKeyEnum=17,Keyboardkey="C" ,Text="C"},
 | 
			
		||||
			new ShortcutKey (){ ShortcutKeyEnum=18,Keyboardkey="Space" ,Text="Space"},
 | 
			
		||||
			};
 | 
			
		||||
            var shortcutKeyList = await _shortcutKeyRepository.Where(x => x.ImageToolType == inQuery.ImageToolType)
 | 
			
		||||
                .Where(x => x.UserId == _userInfo.Id)
 | 
			
		||||
                .ToListAsync();
 | 
			
		||||
 | 
			
		||||
			return shortcutKeys;
 | 
			
		||||
            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>();
 | 
			
		||||
 | 
			
		||||
		/// <summary>
 | 
			
		||||
		/// 重置为默认快捷键
 | 
			
		||||
		/// </summary>
 | 
			
		||||
		/// <returns></returns>
 | 
			
		||||
		[HttpPost]
 | 
			
		||||
		public async Task<bool> RestoreDefaultShortcutKey(RestoreDefaultShortcutKeyInDto inDto)
 | 
			
		||||
		{
 | 
			
		||||
		    var shortcutKeys = GetDefaultShortcutKey();
 | 
			
		||||
			shortcutKeys.ForEach(x => {
 | 
			
		||||
				x.UserId = _userInfo.Id;
 | 
			
		||||
			});
 | 
			
		||||
            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;
 | 
			
		||||
 | 
			
		||||
			await _shortcutKeyRepository.BatchDeleteNoTrackingAsync(x => x.ImageToolType == inDto.ImageToolType && x.UserId == _userInfo.Id);
 | 
			
		||||
                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,
 | 
			
		||||
                    Text = isnull ? defaultkey.Text : key.Text,
 | 
			
		||||
                    Code = isnull ? defaultkey.Code : key.Code,
 | 
			
		||||
                });
 | 
			
		||||
 | 
			
		||||
			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,
 | 
			
		||||
				Text = x.Text,
 | 
			
		||||
				Code=x.Code,
 | 
			
		||||
			}));
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
			return await _shortcutKeyRepository.SaveChangesAsync();
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		/// <summary>
 | 
			
		||||
		/// 设置快捷键
 | 
			
		||||
		/// </summary>
 | 
			
		||||
		/// <param name="inDto"></param>
 | 
			
		||||
		/// <returns></returns>
 | 
			
		||||
		[HttpPost]
 | 
			
		||||
		public async Task<bool> SetShortcutKey(SetDefaultShortcutKey inDto)
 | 
			
		||||
		{
 | 
			
		||||
			await _shortcutKeyRepository.BatchDeleteNoTrackingAsync(x => x.ImageToolType == inDto.ImageToolType&&x.UserId==_userInfo.Id);
 | 
			
		||||
 | 
			
		||||
			await _shortcutKeyRepository.AddRangeAsync(inDto.ShortcutKeyList.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,
 | 
			
		||||
				Text=x.Text,
 | 
			
		||||
				Code=x.Code,
 | 
			
		||||
			}));
 | 
			
		||||
            return result;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		   return	await _shortcutKeyRepository.SaveChangesAsync();
 | 
			
		||||
		}
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 获取默认快捷键
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        private List<ShortcutKey> GetDefaultShortcutKey()
 | 
			
		||||
        {
 | 
			
		||||
            List<ShortcutKey> shortcutKeys = new List<ShortcutKey>() {
 | 
			
		||||
            new ShortcutKey (){
 | 
			
		||||
 | 
			
		||||
        Keyboardkey= "ArrowLeft",
 | 
			
		||||
        ShortcutKeyEnum = 1,
 | 
			
		||||
        ImageToolType= 0,
 | 
			
		||||
        AltKey = false,
 | 
			
		||||
        CtrlKey = false,
 | 
			
		||||
        ShiftKey = false,
 | 
			
		||||
        MetaKey = false,
 | 
			
		||||
        Text= "←",
 | 
			
		||||
        Code= "ArrowLeft"
 | 
			
		||||
    }, new ShortcutKey (){
 | 
			
		||||
 | 
			
		||||
        Keyboardkey= "ArrowRight",
 | 
			
		||||
        ShortcutKeyEnum = 2,
 | 
			
		||||
        ImageToolType= 0,
 | 
			
		||||
        AltKey = false,
 | 
			
		||||
        CtrlKey = false,
 | 
			
		||||
        ShiftKey = false,
 | 
			
		||||
        MetaKey = false,
 | 
			
		||||
        Text= "→",
 | 
			
		||||
        Code= "ArrowRight"
 | 
			
		||||
         }, new ShortcutKey (){
 | 
			
		||||
 | 
			
		||||
        Keyboardkey= "PageUp",
 | 
			
		||||
        ShortcutKeyEnum = 3,
 | 
			
		||||
        ImageToolType= 0,
 | 
			
		||||
        AltKey = false,
 | 
			
		||||
        CtrlKey = false,
 | 
			
		||||
        ShiftKey = false,
 | 
			
		||||
        MetaKey = false,
 | 
			
		||||
        Text= "PageUp",
 | 
			
		||||
        Code= "PageUp"
 | 
			
		||||
         }, new ShortcutKey (){
 | 
			
		||||
 | 
			
		||||
        Keyboardkey= "PageDown",
 | 
			
		||||
        ShortcutKeyEnum = 4,
 | 
			
		||||
        ImageToolType= 0,
 | 
			
		||||
        AltKey = false,
 | 
			
		||||
        CtrlKey = false,
 | 
			
		||||
        ShiftKey = false,
 | 
			
		||||
        MetaKey = false,
 | 
			
		||||
        Text= "PageDown",
 | 
			
		||||
        Code= "PageDown"
 | 
			
		||||
         }, new ShortcutKey (){
 | 
			
		||||
 | 
			
		||||
        Keyboardkey= "ArrowUp",
 | 
			
		||||
        ShortcutKeyEnum = 5,
 | 
			
		||||
        ImageToolType= 0,
 | 
			
		||||
        AltKey = false,
 | 
			
		||||
        CtrlKey = false,
 | 
			
		||||
        ShiftKey = false,
 | 
			
		||||
        MetaKey = false,
 | 
			
		||||
        Text= "↑",
 | 
			
		||||
        Code= "ArrowUp"
 | 
			
		||||
         }, new ShortcutKey (){
 | 
			
		||||
 | 
			
		||||
        Keyboardkey= "ArrowDown",
 | 
			
		||||
        ShortcutKeyEnum = 6,
 | 
			
		||||
        ImageToolType= 0,
 | 
			
		||||
        AltKey = false,
 | 
			
		||||
        CtrlKey = false,
 | 
			
		||||
        ShiftKey = false,
 | 
			
		||||
        MetaKey = false,
 | 
			
		||||
        Text= "↓",
 | 
			
		||||
        Code= "ArrowDown"
 | 
			
		||||
         }, new ShortcutKey (){
 | 
			
		||||
 | 
			
		||||
        Keyboardkey= "l",
 | 
			
		||||
        ShortcutKeyEnum = 7,
 | 
			
		||||
        ImageToolType= 0,
 | 
			
		||||
        AltKey = false,
 | 
			
		||||
        CtrlKey = false,
 | 
			
		||||
        ShiftKey = false,
 | 
			
		||||
        MetaKey = false,
 | 
			
		||||
        Text= "L",
 | 
			
		||||
        Code= "KeyL"
 | 
			
		||||
         }, new ShortcutKey (){
 | 
			
		||||
 | 
			
		||||
        Keyboardkey= "r",
 | 
			
		||||
        ShortcutKeyEnum = 8,
 | 
			
		||||
        ImageToolType= 0,
 | 
			
		||||
        AltKey = false,
 | 
			
		||||
        CtrlKey = false,
 | 
			
		||||
        ShiftKey = false,
 | 
			
		||||
        MetaKey = false,
 | 
			
		||||
        Text= "R",
 | 
			
		||||
        Code= "KeyR"
 | 
			
		||||
         }, new ShortcutKey (){
 | 
			
		||||
 | 
			
		||||
        Keyboardkey= "h",
 | 
			
		||||
        ShortcutKeyEnum = 9,
 | 
			
		||||
        ImageToolType= 0,
 | 
			
		||||
        AltKey = false,
 | 
			
		||||
        CtrlKey = false,
 | 
			
		||||
        ShiftKey = false,
 | 
			
		||||
        MetaKey = false,
 | 
			
		||||
        Text= "H",
 | 
			
		||||
        Code= "KeyH"
 | 
			
		||||
         }, new ShortcutKey (){
 | 
			
		||||
 | 
			
		||||
        Keyboardkey= "v",
 | 
			
		||||
        ShortcutKeyEnum = 10,
 | 
			
		||||
        ImageToolType= 0,
 | 
			
		||||
        AltKey = false,
 | 
			
		||||
        CtrlKey = false,
 | 
			
		||||
        ShiftKey = false,
 | 
			
		||||
        MetaKey = false,
 | 
			
		||||
        Text= "V",
 | 
			
		||||
        Code= "KeyV"
 | 
			
		||||
         }, new ShortcutKey (){
 | 
			
		||||
 | 
			
		||||
        Keyboardkey= "+",
 | 
			
		||||
        ShortcutKeyEnum = 11,
 | 
			
		||||
        ImageToolType= 0,
 | 
			
		||||
        AltKey = false,
 | 
			
		||||
        CtrlKey = false,
 | 
			
		||||
        ShiftKey = true,
 | 
			
		||||
        MetaKey = false,
 | 
			
		||||
        Text= "+",
 | 
			
		||||
        Code= "Equal"
 | 
			
		||||
         }, new ShortcutKey (){
 | 
			
		||||
 | 
			
		||||
        Keyboardkey= "-",
 | 
			
		||||
        ShortcutKeyEnum = 12,
 | 
			
		||||
        ImageToolType= 0,
 | 
			
		||||
        AltKey = false,
 | 
			
		||||
        CtrlKey = false,
 | 
			
		||||
        ShiftKey = false,
 | 
			
		||||
        MetaKey = false,
 | 
			
		||||
        Text= "-",
 | 
			
		||||
        Code= "Minus"
 | 
			
		||||
         }, new ShortcutKey (){
 | 
			
		||||
 | 
			
		||||
        Keyboardkey= "=",
 | 
			
		||||
        ShortcutKeyEnum = 13,
 | 
			
		||||
        ImageToolType= 0,
 | 
			
		||||
        AltKey = false,
 | 
			
		||||
        CtrlKey = false,
 | 
			
		||||
        ShiftKey = false,
 | 
			
		||||
        MetaKey = false,
 | 
			
		||||
        Text= "=",
 | 
			
		||||
        Code= "Equal"
 | 
			
		||||
         }, new ShortcutKey (){
 | 
			
		||||
 | 
			
		||||
        Keyboardkey= "f",
 | 
			
		||||
        ShortcutKeyEnum = 14,
 | 
			
		||||
        ImageToolType= 0,
 | 
			
		||||
        AltKey = false,
 | 
			
		||||
        CtrlKey = false,
 | 
			
		||||
        ShiftKey = false,
 | 
			
		||||
        MetaKey = false,
 | 
			
		||||
        Text= "F",
 | 
			
		||||
        Code= "KeyF"
 | 
			
		||||
         }, new ShortcutKey (){
 | 
			
		||||
 | 
			
		||||
        Keyboardkey= "s",
 | 
			
		||||
        ShortcutKeyEnum = 15,
 | 
			
		||||
        ImageToolType= 0,
 | 
			
		||||
        AltKey = false,
 | 
			
		||||
        CtrlKey = false,
 | 
			
		||||
        ShiftKey = false,
 | 
			
		||||
        MetaKey = false,
 | 
			
		||||
        Text= "S",
 | 
			
		||||
        Code= "KeyS"
 | 
			
		||||
         }, new ShortcutKey (){
 | 
			
		||||
 | 
			
		||||
        Keyboardkey= "i",
 | 
			
		||||
        ShortcutKeyEnum = 16,
 | 
			
		||||
        ImageToolType= 0,
 | 
			
		||||
        AltKey = false,
 | 
			
		||||
        CtrlKey = false,
 | 
			
		||||
        ShiftKey = false,
 | 
			
		||||
        MetaKey = false,
 | 
			
		||||
        Text= "I",
 | 
			
		||||
        Code= "KeyI"
 | 
			
		||||
         }, new ShortcutKey (){
 | 
			
		||||
 | 
			
		||||
        Keyboardkey= "c",
 | 
			
		||||
        ShortcutKeyEnum = 17,
 | 
			
		||||
        ImageToolType= 0,
 | 
			
		||||
        AltKey = false,
 | 
			
		||||
        CtrlKey = false,
 | 
			
		||||
        ShiftKey = false,
 | 
			
		||||
        MetaKey = false,
 | 
			
		||||
        Text= "C",
 | 
			
		||||
        Code= "KeyC"
 | 
			
		||||
         }, new ShortcutKey (){
 | 
			
		||||
 | 
			
		||||
        Keyboardkey= "",
 | 
			
		||||
        ShortcutKeyEnum = 18,
 | 
			
		||||
        ImageToolType= 0,
 | 
			
		||||
        AltKey = false,
 | 
			
		||||
        CtrlKey = false,
 | 
			
		||||
        ShiftKey = false,
 | 
			
		||||
        MetaKey = false,
 | 
			
		||||
        Text= "Space",
 | 
			
		||||
        Code= "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,
 | 
			
		||||
                Text = x.Text,
 | 
			
		||||
                Code = x.Code,
 | 
			
		||||
            }));
 | 
			
		||||
 | 
			
		||||
            return await _shortcutKeyRepository.SaveChangesAsync();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 设置快捷键
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="inDto"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        [HttpPost]
 | 
			
		||||
        public async Task<bool> SetShortcutKey(SetDefaultShortcutKey inDto)
 | 
			
		||||
        {
 | 
			
		||||
            await _shortcutKeyRepository.BatchDeleteNoTrackingAsync(x => x.ImageToolType == inDto.ImageToolType && x.UserId == _userInfo.Id);
 | 
			
		||||
 | 
			
		||||
            await _shortcutKeyRepository.AddRangeAsync(inDto.ShortcutKeyList.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,
 | 
			
		||||
                Text = x.Text,
 | 
			
		||||
                Code = x.Code,
 | 
			
		||||
            }));
 | 
			
		||||
 | 
			
		||||
            return await _shortcutKeyRepository.SaveChangesAsync();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue