From 08a515946d6763b26746d593af76a8af9b1b4076 Mon Sep 17 00:00:00 2001
From: hwh <332078369@qq.com>
Date: 星期五, 28 六月 2024 16:05:44 +0800
Subject: [PATCH] 操作日志

---
 Wms/Wms/Controllers/BasisController.cs |  646 +++++++++++++---------------------------------------------
 1 files changed, 145 insertions(+), 501 deletions(-)

diff --git a/Wms/Wms/Controllers/BasisController.cs b/Wms/Wms/Controllers/BasisController.cs
index 41d72d9..fb0997a 100644
--- a/Wms/Wms/Controllers/BasisController.cs
+++ b/Wms/Wms/Controllers/BasisController.cs
@@ -20,6 +20,8 @@
 using System.Security.Cryptography;
 using System.Data;
 using Model.ModelDto.LogDto;
+using Utility;
+using Model.ModelVm.LogVm;
 
 namespace Wms.Controllers
 {
@@ -44,6 +46,7 @@
         private readonly IFunSettingServer _setting; //鍔熻兘璁惧畾
         private readonly IInterfaceServer _interface;//鎺ュ彛绠$悊
         private readonly IOperationSysServer _operation; //鎿嶄綔鏃ュ織
+        private readonly UserManager _userManager;
         /// <summary>
         /// 鏋勯�犲嚱鏁�
         /// </summary>
@@ -58,7 +61,7 @@
         /// <param name="department">閮ㄩ棬</param>
         /// <param name="setting">鍔熻兘璁惧畾</param>
         /// <param name="operation">鎿嶄綔鏃ュ織</param>
-        public BasisController(ICustomerServer customerSvc, ILogisticsInfoServer logisticsSvc, IUserInforServer userInforServer, IRolesServer rolesServer, IRoleRightServer roleRightServer, IRBACServer rBACServer, IUnitServer unitSvc, IPackagServer packagServer, IMaterialsServer mate, IDepartmentServer department, IFunSettingServer setting, IInterfaceServer interfaceS, IOperationSysServer operation)
+        public BasisController(ICustomerServer customerSvc, ILogisticsInfoServer logisticsSvc, IUserInforServer userInforServer, IRolesServer rolesServer, IRoleRightServer roleRightServer, IRBACServer rBACServer, IUnitServer unitSvc, IPackagServer packagServer, IMaterialsServer mate, IDepartmentServer department, IFunSettingServer setting, IInterfaceServer interfaceS, IOperationSysServer operation, UserManager userManager)
         {
             _customerSvc = customerSvc;//瀹㈡埛Svc
             _logisticsSvc = logisticsSvc;//鐗╂祦Svc
@@ -73,6 +76,7 @@
             _setting = setting; //鍔熻兘璁惧畾
             _interface = interfaceS;//鎺ュ彛绠$悊
             _operation = operation; //鎿嶄綔鏃ュ織
+            _userManager = userManager;
         }
         //鍩烘湰淇℃伅绠$悊
 
@@ -89,15 +93,10 @@
         /// <param name="Status">鐘舵��</param>
         /// <returns></returns>
         [HttpGet]
-        public IActionResult GetUserRoleList(string UserName, string DepartmentNo, string RoleNo, string Status)
+        [ServiceFilter(typeof(ApiResponseActionFilter))]
+        public async Task<List<UserInfoDto>> GetUserRoleList(string UserName, string DepartmentNo, string RoleNo, string Status)
         {
-            List<UserInfoDto> userdtolist = _userInforServer.GetUserRoleList(UserName, DepartmentNo, RoleNo, Status);
-            return Ok(new
-            {
-                data = userdtolist,
-                code = 0,
-                mes = "鎴愬姛"
-            });
+            return await _userInforServer.GetUserRoleList(UserName, DepartmentNo, RoleNo, Status);
         }
 
         /// <summary>
@@ -106,15 +105,10 @@
         /// <param name="id">鐢ㄦ埛id</param>
         /// <returns></returns>
         [HttpGet]
-        public IActionResult GetUserinfoListById(int id)
+        [ServiceFilter(typeof(ApiResponseActionFilter))]
+        public async Task<SysUserInfor> GetUserinfoListById(int id)
         {
-            SysUserInfor userinfo = _userInforServer.GetUserInfoById(id);
-            return Ok(new
-            {
-                data = userinfo,
-                code = 0,
-                msg = "鎴愬姛"
-            });
+            return await _userInforServer.GetUserInfoById(id);
         }
 
 
@@ -125,38 +119,19 @@
         /// <returns></returns>
         /// <exception cref="System.Exception">鎹曡幏寮傚父</exception>
         [HttpPost]
-        public async Task<IActionResult> InsertUserinfo(UserInfoDto UserInfoDto)
+        [ServiceFilter(typeof(ApiResponseActionFilter))]
+        [UnitOfWork]
+        public async Task InsertUserinfo(UserInfoDto UserInfoDto)
         {
-            //鎹曡幏寮傚父
-            try
+            await _userInforServer.InsertUserInfo(UserInfoDto);
+            await _operation.InsertOperation(new OperationInputVm()
             {
-                //鑾峰彇褰撳墠鎿嶄綔鐢ㄦ埛id
-                var claimsIdentity = this.User.Identity as ClaimsIdentity;
-                var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
-                int uid = Convert.ToInt32(userId);
-                UserInfoDto.CreateUser = uid;
-                int i = await _userInforServer.InsertUserInfo(UserInfoDto);
-
-                //鍒ゆ柇鏄惁鏂板鎴愬姛
-                if (i == 0)
-                {
-                    return Ok(new { data = i, code = 1, msg = "鏂板澶辫触" });
-                }
-                else if (i == 3)
-                {
-                    return Ok(new { data = i, code = 3, msg = "鐢ㄦ埛鍚嶆垨鐧诲綍鍚嶉噸澶�" });
-                }
-                else
-                {
-                    await _operation.InsertOperation("绯荤粺璁剧疆", "鐢ㄦ埛绠$悊", UserInfoDto.UserNo, "娣诲姞", "娣诲姞鐢ㄦ埛淇℃伅 鐢ㄦ埛鍙凤細" + UserInfoDto.UserNo, uid);
-                    return Ok(new { data = i, code = 0, msg = "鏂板鎴愬姛" });
-                }
-            }
-            catch (System.Exception ex)
-            {
-                //鎶涘嚭寮傚父
-                throw new System.Exception("鏂板鐢ㄦ埛寮傚父", ex);
-            }
+                ParentName = "绯荤粺璁剧疆",
+                MenuName = "鐢ㄦ埛绠$悊",
+                FkNo = UserInfoDto.UserNo,
+                TypeName = "娣诲姞",
+                Msg = "娣诲姞鐢ㄦ埛淇℃伅 鐢ㄦ埛鍙凤細" + UserInfoDto.UserNo
+            });
         }
 
 
@@ -167,34 +142,21 @@
         /// <returns></returns>
         /// <exception cref="System.Exception">寮傚父</exception>
         [HttpGet]
-        public async Task<IActionResult> DeleteUserInfo(int userids)
+        [ServiceFilter(typeof(ApiResponseActionFilter))]
+        [UnitOfWork]
+        public async Task DeleteUserInfo(int userids)
         {
-            //寮傚父
-            try
+            //鑾峰彇鐢ㄦ埛淇℃伅
+            SysUserInfor user = await _userInforServer.GetUserInfoById(userids);
+            await _userInforServer.DeleteUserinfo(user);
+            await _operation.InsertOperation(new OperationInputVm()
             {
-                //鑾峰彇鐢ㄦ埛淇℃伅
-                SysUserInfor user = _userInforServer.GetUserInfoById(userids);
-                //鑾峰彇褰撳墠鎿嶄綔鐢ㄦ埛id
-                var claimsIdentity = this.User.Identity as ClaimsIdentity;
-                var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
-                int uid = Convert.ToInt32(userId);
-                int i = await _userInforServer.DeleteUserinfo(user);
-                //鍒ゆ柇鏄惁鍒犻櫎鎴愬姛
-                if (i == 0)
-                {
-                    return Ok(new { data = i, code = 1, msg = "鍒犻櫎澶辫触" });
-                }
-                else
-                {
-                    await _operation.InsertOperation("绯荤粺璁剧疆", "鐢ㄦ埛绠$悊", user.UserNo, "鍒犻櫎", "鍒犻櫎鐢ㄦ埛淇℃伅 鐢ㄦ埛鍙凤細" + user.UserNo, uid);
-                    return Ok(new { data = i, code = 0, msg = "鍒犻櫎鎴愬姛" });
-                }
-            }
-            catch (System.Exception ex)
-            {
-                //鎶涘嚭寮傚父
-                throw new System.Exception("鍒犻櫎鐢ㄦ埛淇℃伅寮傚父", ex);
-            }
+                ParentName = "绯荤粺璁剧疆",
+                MenuName = "鐢ㄦ埛绠$悊",
+                FkNo = user.UserNo,
+                TypeName = "鍒犻櫎",
+                Msg = "鍒犻櫎鐢ㄦ埛淇℃伅 鐢ㄦ埛鍙凤細" + user.UserNo
+            });
         }
 
 
@@ -205,73 +167,25 @@
         /// <returns></returns>
         /// <exception cref="System.Exception">鎹曡幏寮傚父</exception>
         [HttpPost]
-        public async Task<IActionResult> UpdateUserinfo(UserInfoDto userdto)
+        [ServiceFilter(typeof(ApiResponseActionFilter))]
+        [UnitOfWork]
+        public async Task UpdateUserinfo(UserInfoDto userdto)
         {
-            //鎹曡幏寮傚父
-            try
+            await _userInforServer.UpdateUserinfo(userdto);
+            await _operation.InsertOperation(new OperationInputVm()
             {
-                //鑾峰彇褰撳墠鎿嶄綔鐢ㄦ埛id
-                var claimsIdentity = this.User.Identity as ClaimsIdentity;
-                var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
-                int uid = Convert.ToInt32(userId);
-                //userdto.UpdateUser = Convert.ToInt32(userId);
-                //鏇存敼浜�
-                userdto.UpdateUser = uid;
-
-                //缂栬緫鐢ㄦ埛淇℃伅
-                int i = await _userInforServer.UpdateUserinfo(userdto);
-                //鍒ゆ柇鏄惁缂栬緫鎴愬姛
-                if (i == 0)
-                {
-                    return Ok(new { data = i, code = 1, msg = "缂栬緫澶辫触" });
-                }
-                else if (i == 3)
-                {
-                    return Ok(new { data = i, code = 1, msg = "鐢ㄦ埛鍚嶆垨鐧诲綍鍚嶉噸澶�" });
-                }
-                else
-                {
-                    await _operation.InsertOperation("绯荤粺璁剧疆", "鐢ㄦ埛绠$悊", userdto.UserNo, "淇敼", "淇敼鐢ㄦ埛淇℃伅 鐢ㄦ埛鍙凤細" + userdto.UserNo, uid);
-                    return Ok(new { data = i, code = 0, msg = "缂栬緫鎴愬姛" });
-                }
-            }
-            catch (System.Exception ex)
-            {
-                //鎶涘嚭寮傚父
-                throw new System.Exception("缂栬緫鐢ㄦ埛淇℃伅寮傚父", ex);
-            }
+                ParentName = "绯荤粺璁剧疆",
+                MenuName = "鐢ㄦ埛绠$悊",
+                FkNo = userdto.UserNo,
+                TypeName = "缂栬緫",
+                Msg = "淇敼鐢ㄦ埛淇℃伅 鐢ㄦ埛鍙凤細" + userdto.UserNo
+            });
         }
 
 
         #endregion
 
         #region 淇敼瀵嗙爜
-
-        /// <summary>
-        /// 淇敼瀵嗙爜 鏍规嵁id鑾峰彇鐢ㄦ埛鍘熷瘑鐮�
-        /// </summary>
-        /// <param name="PassWord">鐢ㄦ埛鍘熷瘑鐮�</param>
-        /// <returns></returns>
-        [HttpGet]
-        public int GetUserUptPassById(string PassWord, int userId)
-        {
-            ////鑾峰彇褰撳墠鎿嶄綔鐢ㄦ埛id
-            //var claimsIdentity = this.User.Identity as ClaimsIdentity;
-            //var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
-            //int uid = Convert.ToInt32(userId);
-
-            //鏍规嵁鐢ㄦ埛id鑾峰彇鐢ㄦ埛瀵嗙爜
-            SysUserInfor user = _userInforServer.GetUserInfoById(userId);
-            //鍒ゆ柇鍘熷瘑鐮佹槸鍚︽纭�
-            if (user.PassWord == PassWord)
-            {
-                return 1;
-            }
-            else
-            {
-                return 0;
-            }
-        }
 
         ///// <param name="userId">鐢ㄦ埛id</param>
         /// <summary>
@@ -283,100 +197,32 @@
         /// <returns></returns>
         /// <exception cref="Exception">鎹曡幏寮傚父</exception>
         [HttpGet]
-        public async Task<IActionResult> UptUserPassWord(string pwdOld, string pwdNew, string pwdNewTwo/*, int userId*/)
+        [ServiceFilter(typeof(ApiResponseActionFilter))]
+        public async Task UptUserPassWord(string pwdOld, string pwdNew, string pwdNewTwo/*, int userId*/)
         {
-            //鎹曡幏寮傚父
-            try
-            {
-                pwdOld = Md5Tools.CalcMd5(pwdOld);
-                pwdNew = Md5Tools.CalcMd5(pwdNew);
-                pwdNewTwo = Md5Tools.CalcMd5(pwdNewTwo);
-                //鑾峰彇褰撳墠鎿嶄綔鐢ㄦ埛id
-                var claimsIdentity = this.User.Identity as ClaimsIdentity;
-                var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
-                int uid = Convert.ToInt32(userId);
-                //鍒ゆ柇鍘熷瘑鐮佹槸鍚︽纭�
-                int a = GetUserUptPassById(pwdOld, uid);
-                if (a == 1)
-                {
-                    //淇敼瀵嗙爜
-                    int i = await _userInforServer.UptUserPassWord(pwdOld, pwdNew, pwdNewTwo, uid);
-                    if (i == 0)
-                    {
-                        return Ok(new
-                        {
-                            data = i,
-                            code = 1,
-                            msg = "淇敼澶辫触"
-                        });
-                    }
-                    //鍒ゆ柇涓ゆ鏂板瘑鐮佹槸鍚︿竴鑷�
-                    else if (i == 3)
-                    {
-                        return Ok(new
-                        {
-                            data = i,
-                            code = 0,
-                            msg = "淇敼鎴愬姛 璇烽噸鏂扮櫥褰�"
-                        });
-                    }
-                    else
-                    {
-                        return Ok(new
-                        {
-                            data = i,
-                            code = 0,
-                            msg = "淇敼鎴愬姛 璇烽噸鏂扮櫥褰�"
-                        });
-                    }
-                }
-                else
-                {
-                    //閿欒
-                    return Ok(new
-                    {
-                        data = a,
-                        code = 1,
-                        msg = "鍘熷瘑鐮佷笉姝g‘"
-                    });
-                }
-
-            }
-            catch (Exception ex)
-            {
-                //鎶涘嚭寮傚父
-                throw new Exception("淇敼瀵嗙爜寮傚父", ex);
-            }
+            pwdOld = Md5Tools.CalcMd5(pwdOld);
+            pwdNew = Md5Tools.CalcMd5(pwdNew);
+            pwdNewTwo = Md5Tools.CalcMd5(pwdNewTwo);
+            //鑾峰彇褰撳墠鎿嶄綔鐢ㄦ埛id
+            SysUserInfor user = await _userInforServer.GetUserInfoById(_userManager.UserId);
+            if (user == null)
+                throw Oops.Bah("鎵句笉鍒扮敤鎴蜂俊鎭�");
+            if (user.PassWord != pwdOld)
+                throw Oops.Bah("鍘熷瘑鐮佷笉姝g‘");
+            //淇敼瀵嗙爜
+            int i = await _userInforServer.UptUserPassWord(pwdNew, _userManager.UserId);
+            if (i <= 0)
+                throw Oops.Bah("淇敼瀵嗙爜澶辫触");
         }
         /// <summary>
         /// x澶╁悗鎻愰啋鐢ㄦ埛淇敼瀵嗙爜
         /// </summary>
         /// <returns></returns>
         [HttpGet]
-        public IActionResult IsPassWordTime()
+        [ServiceFilter(typeof(ApiResponseActionFilter))]
+        public async Task<int> IsPassWordTime()
         {
-            //鎹曡幏寮傚父
-            try
-            {
-                //鑾峰彇褰撳墠鎿嶄綔鐢ㄦ埛id
-                var claimsIdentity = this.User.Identity as ClaimsIdentity;
-                var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
-                int uid = Convert.ToInt32(userId);
-                //鍒ゆ柇鍘熷瘑鐮佹槸鍚︽纭�
-                int a = _userInforServer.IsPassWordTime(uid);
-                return Ok(new
-                {
-                    data = a,
-                    code = 0,
-                    msg = "淇敼澶辫触"
-                });
-
-            }
-            catch (Exception ex)
-            {
-                //鎶涘嚭寮傚父
-                throw new Exception("淇敼瀵嗙爜寮傚父", ex);
-            }
+            return await _userInforServer.IsPassWordTime(_userManager.UserId);
         }
         #endregion
 
@@ -391,29 +237,10 @@
         /// <param name="RoleName">瑙掕壊鍚嶇О</param>
         /// <returns></returns>
         [HttpGet]
-        public IActionResult GetRolesList(string RoleNo, string RoleName)
+        [ServiceFilter(typeof(ApiResponseActionFilter))]
+        public async Task<List<RoleDto>> GetRolesList(string RoleNo, string RoleName)
         {
-            //鑾峰彇褰撳墠鎿嶄綔鐢ㄦ埛id
-            var claimsIdentity = this.User.Identity as ClaimsIdentity;
-            if (claimsIdentity == null)
-            {
-                throw new Exception("鏈幏鍙栧埌鐢ㄦ埛淇℃伅");
-            }
-            string UserId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
-            if (string.IsNullOrWhiteSpace(UserId))
-            {
-                throw new Exception("鏈幏鍙栧埌鐢ㄦ埛淇℃伅");
-            }
-
-            //鏌ヨ
-            List<RoleDto> roles = _rolesServer.GetRoleList(RoleNo, RoleName, UserId);
-            //杩斿洖鏁版嵁
-            return Ok(new
-            {
-                data = roles,
-                code = 0,
-                msg = "鑾峰彇鎴愬姛"
-            });
+            return await _rolesServer.GetRoleList(RoleNo, RoleName);
         }
 
         /// <summary>
@@ -422,15 +249,10 @@
         /// <param name="roleid">瑙掕壊id</param>
         /// <returns></returns>
         [HttpGet]
-        public IActionResult GetRolesListById(int roleid)
+        [ServiceFilter(typeof(ApiResponseActionFilter))]
+        public async Task<SysRoles> GetRolesListById(int roleid)
         {
-            SysRoles role = _rolesServer.GetRoleInfoById(roleid);
-            return Ok(new
-            {
-                data = role,
-                code = 0,
-                msg = "鑾峰彇鎴愬姛"
-            });
+            return await _rolesServer.GetRoleInfoById(roleid);
         }
 
         /// <summary>
@@ -440,52 +262,19 @@
         /// <returns></returns>
         /// <exception cref="System.Exception">鎹曡幏寮傚父</exception>
         [HttpPost]
-        public async Task<IActionResult> InsertRoleInfo(RoleDto roledto)
+        [ServiceFilter(typeof(ApiResponseActionFilter))]
+        [UnitOfWork]
+        public async Task InsertRoleInfo(RoleDto roledto)
         {
-            //鎹曡幏寮傚父
-            try
+            await _rolesServer.InsertRoleInfo(roledto);
+            await _operation.InsertOperation(new OperationInputVm()
             {
-                //鑾峰彇褰撳墠鎿嶄綔鐢ㄦ埛id
-                var claimsIdentity = this.User.Identity as ClaimsIdentity;
-                var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
-                int uid = Convert.ToInt32(userId);
-                //鍒涘缓浜�
-                roledto.CreateUser = uid;
-                int i = await _rolesServer.InsertRoleInfo(roledto);
-                if (i == 0)
-                {
-                    return Ok(new
-                    {
-                        data = i,
-                        code = 1,
-                        msg = "鏂板澶辫触"
-                    });
-                }
-                else if (i == 3)
-                {
-                    return Ok(new
-                    {
-                        data = i,
-                        code = 3,
-                        msg = "瑙掕壊鍙峰繀椤诲敮涓�"
-                    });
-                }
-                else
-                {
-                    await _operation.InsertOperation("绯荤粺璁剧疆", "瑙掕壊鏉冮檺", roledto.RoleNo, "娣诲姞", "娣诲姞瑙掕壊淇℃伅 瑙掕壊鍙凤細" + roledto.RoleNo, uid);
-                    return Ok(new
-                    {
-                        data = i,
-                        code = 0,
-                        msg = "鏂板鎴愬姛"
-                    });
-                }
-            }
-            catch (System.Exception ex)
-            {
-                //鎶涘嚭寮傚父
-                throw new System.Exception("瑙掕壊鏂板寮傚父", ex);
-            }
+                ParentName = "绯荤粺璁剧疆",
+                MenuName = "瑙掕壊鏉冮檺",
+                FkNo = roledto.RoleNo,
+                TypeName = "娣诲姞",
+                Msg = "娣诲姞瑙掕壊淇℃伅 瑙掕壊鍙凤細" + roledto.RoleNo
+            });
         }
 
         /// <summary>
@@ -495,45 +284,21 @@
         /// <returns></returns>
         /// <exception cref="System.Exception"></exception>
         [HttpGet]
-        public async Task<IActionResult> DeleteRoleInfo(int roleids)
+        [ServiceFilter(typeof(ApiResponseActionFilter))]
+        [UnitOfWork]
+        public async Task DeleteRoleInfo(int roleids)
         {
-            //鎹曡幏寮傚父
-            try
+            //鏍规嵁瑙掕壊id鑾峰彇瑙掕壊淇℃伅
+            SysRoles role = await _rolesServer.GetRoleInfoById(roleids);
+            await _rolesServer.DeleteRoleInfo(role);
+            await _operation.InsertOperation(new OperationInputVm()
             {
-                //鏍规嵁瑙掕壊id鑾峰彇瑙掕壊淇℃伅
-                SysRoles role = _rolesServer.GetRoleInfoById(roleids);
-                //鑾峰彇褰撳墠鎿嶄綔鐢ㄦ埛id
-                var claimsIdentity = this.User.Identity as ClaimsIdentity;
-                var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
-                int uid = Convert.ToInt32(userId);
-                role.UpdateUser = uid;
-                int i = await _rolesServer.DeleteRoleInfo(role);
-                //鍒ゆ柇鏄惁鍒犻櫎鎴愬姛
-                if (i == 0)
-                {
-                    return Ok(new
-                    {
-                        data = i,
-                        code = 1,
-                        msg = "鍒犻櫎澶辫触"
-                    });
-                }
-                else
-                {
-                    await _operation.InsertOperation("绯荤粺璁剧疆", "瑙掕壊鏉冮檺", role.RoleNo, "鍒犻櫎", "鍒犻櫎瑙掕壊淇℃伅 瑙掕壊鍙凤細" + role.RoleNo, uid);
-                    return Ok(new
-                    {
-                        data = i,
-                        code = 0,
-                        msg = "鍒犻櫎鎴愬姛"
-                    });
-                }
-            }
-            catch (System.Exception ex)
-            {
-                //鎶涘嚭寮傚父
-                throw new System.Exception("瑙掕壊鍒犻櫎寮傚父", ex);
-            }
+                ParentName = "绯荤粺璁剧疆",
+                MenuName = "瑙掕壊鏉冮檺",
+                FkNo = role.RoleNo,
+                TypeName = "鍒犻櫎",
+                Msg = "鍒犻櫎瑙掕壊淇℃伅 瑙掕壊鍙凤細" + role.RoleNo
+            });
         }
 
         /// <summary>
@@ -543,45 +308,19 @@
         /// <returns></returns>
         /// <exception cref="System.Exception">鎹曡幏寮傚父</exception>
         [HttpPost]
-        public async Task<IActionResult> UpdateRolesInfo(SysRoles role)
+        [ServiceFilter(typeof(ApiResponseActionFilter))]
+        [UnitOfWork]
+        public async Task UpdateRolesInfo(SysRoles role)
         {
-            //鎹曡幏寮傚父
-            try
+            await _rolesServer.UpdateRoleInfo(role);
+            await _operation.InsertOperation(new OperationInputVm()
             {
-                //鑾峰彇褰撳墠鎿嶄綔鐢ㄦ埛id
-                var claimsIdentity = this.User.Identity as ClaimsIdentity;
-                var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
-                int uid = Convert.ToInt32(userId);
-                //鏇存敼浜�
-                role.UpdateUser = uid;
-
-                int i = await _rolesServer.UpdateRoleInfo(role);
-                //鍒ゆ柇鏄惁缂栬緫鎴愬姛
-                if (i == 0)
-                {
-                    return Ok(new
-                    {
-                        data = i,
-                        code = 1,
-                        msg = "缂栬緫澶辫触"
-                    });
-                }
-                else
-                {
-                    await _operation.InsertOperation("绯荤粺璁剧疆", "瑙掕壊鏉冮檺", role.RoleNo, "淇敼", "淇敼瑙掕壊淇℃伅 瑙掕壊鍙凤細" + role.RoleNo, uid);
-                    return Ok(new
-                    {
-                        data = i,
-                        code = 0,
-                        msg = "缂栬緫鎴愬姛"
-                    });
-                }
-            }
-            catch (System.Exception ex)
-            {
-                //鎶涘嚭寮傚父
-                throw new System.Exception("缂栬緫瑙掕壊寮傚父", ex);
-            }
+                ParentName = "绯荤粺璁剧疆",
+                MenuName = "瑙掕壊鏉冮檺",
+                FkNo = role.RoleNo,
+                TypeName = "缂栬緫",
+                Msg = "淇敼瑙掕壊淇℃伅 瑙掕壊鍙凤細" + role.RoleNo
+            });
         }
 
         #endregion
@@ -593,16 +332,10 @@
         /// </summary>
         /// <returns></returns>
         [HttpGet]
-        public IActionResult GetRBACLists(int id)
+        [ServiceFilter(typeof(ApiResponseActionFilter))]
+        public async Task<List<FunctionMenuDto>> GetRBACLists(int id)
         {
-            //List<RoleRightDto> roleright = 
-            var obj = _rBACServer.GetMenuByroleIdNew(id);
-            return Ok(new
-            {
-                data = obj,
-                code = 0,
-                msg = "鎴愬姛"
-            });
+            return await _rBACServer.GetMenuByroleIdNew(id);
         }
 
 
@@ -611,27 +344,10 @@
         /// </summary>
         /// <returns></returns>
         [HttpGet]
-        public IActionResult GetRoleRightRBAC(int id, string MenuNo)
+        [ServiceFilter(typeof(ApiResponseActionFilter))]
+        public async Task<List<FunctionMenuDto>> GetRoleRightRBAC(int id, string MenuNo)
         {
-            //鑾峰彇褰撳墠鎿嶄綔鐢ㄦ埛id
-            var claimsIdentity = this.User.Identity as ClaimsIdentity;
-            if (claimsIdentity == null)
-            {
-                throw new Exception("鏈幏鍙栧埌鐢ㄦ埛淇℃伅");
-            }
-            string UserId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
-            if (string.IsNullOrWhiteSpace(UserId))
-            {
-                throw new Exception("鏈幏鍙栧埌鐢ㄦ埛淇℃伅");
-            }
-
-            List<FunctionMenuDto> menudto = _rBACServer.GetRoleRightRBAC(MenuNo, UserId);
-            return Ok(new
-            {
-                data = menudto,
-                code = 0,
-                msg = "鎴愬姛"
-            });
+            return await _rBACServer.GetRoleRightRBAC(MenuNo, UserId);
         }
 
         /// <summary>
@@ -639,15 +355,10 @@
         /// </summary>
         /// <returns></returns>
         [HttpGet]
-        public IActionResult GetRoleRightLists(int id)
+        [ServiceFilter(typeof(ApiResponseActionFilter))]
+        public async Task<List<RoleRightDto>> GetRoleRightLists(int id)
         {
-            List<RoleRightDto> roleRightDtos = _rBACServer.GetRoleRightList(id);
-            return Ok(new
-            {
-                data = roleRightDtos,
-                code = 0,
-                msg = "鎴愬姛"
-            });
+            return await _rBACServer.GetRoleRightList(id);
         }
 
         /// <summary>
@@ -656,33 +367,10 @@
         /// </summary>
         /// <returns></returns>
         [HttpGet]
-        public IActionResult GetRoleRightList()
+        [ServiceFilter(typeof(ApiResponseActionFilter))]
+        public async Task<List<RoleRightDto>> GetRoleRightList()
         {
-            try
-            {
-                //鑾峰彇褰撳墠鐧诲綍鐨勭敤鎴稩D
-                var claimsIdentity = this.User.Identity as ClaimsIdentity;
-                if (claimsIdentity == null)
-                {
-                    return Ok(new { code = 1, msg = "涓鸿幏鍙栧埌褰撳墠鎿嶄綔浜轰俊鎭�" });
-                }
-                var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
-                if (string.IsNullOrWhiteSpace(userId))
-                {
-                    return Ok(new { code = 1, msg = "涓鸿幏鍙栧埌褰撳墠鎿嶄綔浜轰俊鎭�" });
-                }
-                var roleRightDtos = _roleRightServer.GetRoleMenuList(int.Parse(userId));
-                return Ok(new
-                {
-                    data = roleRightDtos,
-                    msg = "鎴愬姛",
-                    code = 0
-                });
-            }
-            catch (Exception e)
-            {
-                return Ok(new { msg = e.Message, code = 0 });
-            }
+            return await _roleRightServer.GetRoleMenuList();
         }
 
         /// <summary>
@@ -691,15 +379,10 @@
         /// <param name="id">瑙掕壊鏉冮檺id</param>
         /// <returns></returns>
         [HttpGet]
-        public IActionResult GetRoleRightOneListById(int id)
+        [ServiceFilter(typeof(ApiResponseActionFilter))]
+        public async Task<List<SysRoleRight>> GetRoleRightOneListById(int id)
         {
-            List<SysRoleRight> roleRights = _roleRightServer.GetRoleRightOneListById(id);
-            return Ok(new
-            {
-                data = roleRights,
-                msg = "鎴愬姛",
-                core = 0
-            });
+            return await _roleRightServer.GetRoleRightOneListById(id);
         }
 
         /// <summary>
@@ -710,46 +393,22 @@
         /// <returns></returns>
         /// <exception cref="Exception">鎹曡幏寮傚父</exception>
         [HttpPost]
-        public async Task<IActionResult> InsertRoleRight(string MenuNo, int id)
+        [ServiceFilter(typeof(ApiResponseActionFilter))]
+        [UnitOfWork]
+        public async Task InsertRoleRight(string MenuNo, int id)
         {
-            //鎹曡幏寮傚父
-            try
+            //鏍规嵁Id鑾峰彇瑙掕壊鍙�
+            SysRoles roles = await _rolesServer.GetRoleInfoById(id);
+            //淇濆瓨瑙掕壊鏉冮檺淇℃伅
+            await _roleRightServer.InsertRoleRight(MenuNo, roles.RoleNo);
+            await _operation.InsertOperation(new OperationInputVm()
             {
-                //鑾峰彇褰撳墠鎿嶄綔鐢ㄦ埛id
-                var claimsIdentity = this.User.Identity as ClaimsIdentity;
-                var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
-
-                //鏍规嵁Id鑾峰彇瑙掕壊鍙�
-                SysRoles roles = _rolesServer.GetRoleInfoById(id);
-
-                //淇濆瓨瑙掕壊鏉冮檺淇℃伅
-                int i = await _roleRightServer.InsertRoleRight(MenuNo, roles.RoleNo, userId);
-                //鍒ゆ柇鏄惁鏂板鎴愬姛
-                if (i == 0)
-                {
-                    return Ok(new
-                    {
-                        data = i,
-                        msg = "鍒嗛厤澶辫触",
-                        code = 1
-                    });
-                }
-                else
-                {
-                    await _operation.InsertOperation("绯荤粺璁剧疆", "瑙掕壊鏉冮檺", roles.RoleNo, "淇敼", "鍒嗛厤瑙掕壊鏉冮檺 瑙掕壊鍙凤細" + roles.RoleNo, Convert.ToInt32(userId));
-                    return Ok(new
-                    {
-                        data = i,
-                        msg = "鍒嗛厤鎴愬姛",
-                        code = 0
-                    });
-                }
-            }
-            catch (Exception ex)
-            {
-                //鎶涘嚭寮傚父
-                throw new Exception("鏂板瑙掕壊鏉冮檺淇℃伅寮傚父", ex);
-            }
+                ParentName = "绯荤粺璁剧疆",
+                MenuName = "瑙掕壊鏉冮檺",
+                FkNo = roles.RoleNo,
+                TypeName = "缂栬緫",
+                Msg = "鍒嗛厤瑙掕壊鏉冮檺 瑙掕壊鍙凤細" + roles.RoleNo
+            });
         }
 
         #endregion
@@ -1283,7 +942,7 @@
                 matedto.CreateUser = uid;
                 //鏂板
                 int i = await _mate.AddMate(matedto);
-                
+
                 await _operation.InsertOperation("鍩虹淇℃伅", "鐗╂枡绠$悊", matedto.SkuNo, "娣诲姞", "娣诲姞鐗╂枡淇℃伅 鐗╂枡鍙凤細" + matedto.SkuNo, uid);
                 return Ok(new { data = i, code = 0, msg = "鎴愬姛" });
 
@@ -1291,7 +950,7 @@
             catch (Exception ex)
             {
                 //鎶涘嚭寮傚父 
-                return Ok(new { code = 1, msg = "鏂板鐗╂枡寮傚父"+ ex.Message });
+                return Ok(new { code = 1, msg = "鏂板鐗╂枡寮傚父" + ex.Message });
             }
         }
 
@@ -1385,7 +1044,7 @@
             catch (Exception ex)
             {
                 //鎶涘嚭寮�
-                return Ok(new { code = 1, msg = "缂栬緫鐗╂枡寮傚父"+ex.Message });
+                return Ok(new { code = 1, msg = "缂栬緫鐗╂枡寮傚父" + ex.Message });
             }
         }
 
@@ -1612,7 +1271,7 @@
         {
             try
             {
-                var bolls = _customerSvc.GetCustomerList(model.CustomerNo,model.CustomerName, model.Type, model.LinkMan, model.Phone, model.Page, model.Limit, out int count);
+                var bolls = _customerSvc.GetCustomerList(model.CustomerNo, model.CustomerName, model.Type, model.LinkMan, model.Phone, model.Page, model.Limit, out int count);
 
                 return Ok(new { code = 0, count, msg = "瀹㈡埛淇℃伅", data = bolls });
             }
@@ -2434,22 +2093,12 @@
         /// <summary>
         /// 鑾峰彇鎿嶄綔鏃ュ織淇℃伅鍒楄〃
         /// </summary>
-        /// <param name="menuName">鑿滃崟鍚嶇О</param>
-        /// <param name="type">鎿嶄綔绫诲瀷</param>
-        /// <param name="msg">鎿嶄綔鍐呭</param>
-        /// <param name="menuNo">鑿滃崟鍙�</param>
-        /// <param name="parentNo">妯″潡鍙�</param>
         /// <returns></returns>
-        [HttpGet]
-        public IActionResult GetSysOperationList(string menuName, string type, string msg, string menuNo, string parentNo)
+        [HttpPost]
+        [ServiceFilter(typeof(ApiResponseActionFilter))]
+        public async Task<SqlSugarPagedList<OperationDto>> GetSysOperationList(GetOperationVm model)
         {
-            List<OperationDto> operation = _operation.GetSysOperationList(menuName, type, msg, menuNo, parentNo);
-            return Ok(new
-            {
-                data = operation,
-                code = 0,
-                msg = "鎴愬姛"
-            });
+            return await _operation.GetSysOperationList(model);
         }
 
         /// <summary>
@@ -2458,15 +2107,10 @@
         /// <param name="dicName">瀛楀吀鍚嶇О</param>
         /// <returns></returns>
         [HttpGet]
-        public IActionResult GetDicTypeList(string dicName)
+        [ServiceFilter(typeof(ApiResponseActionFilter))]
+        public async Task<List<SysDictionary>> GetDicTypeList(string dicName)
         {
-            List<SysDictionary> diclist = _operation.GetDicTypeList(dicName);
-            return Ok(new
-            {
-                data = diclist,
-                code = 0,
-                msg = "鎴愬姛"
-            });
+            return await _operation.GetDicTypeList(dicName);
         }
 
         #endregion

--
Gitblit v1.8.0