public ActionRes Update([FromBody] Update_Sys_Account_Input model)
        {
            //检查权限分组(防止别人乱来)
            var authorities = Cat.M.Public.Services.Constants.Authority.AllAuthority;

            if (model.Authority.Count > 0)
            {
                foreach (var item in model.Authority)
                {
                    if (!authorities.Contains(item))
                    {
                        throw new Exception($"不合法的权限分组[{item}]");
                    }
                }
            }
            //
            var instance = AllServices.SysAccountService.GetByKey(model.Id);

            if (instance == null)
            {
                throw new Exception($"没有找到指定的用户[{model.Id}]");
            }
            CheckPression(instance);

            var res = AllServices.SysAccountService.Update(model);

            return(ActionRes.Success(res));
        }
Exemple #2
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public Sys_Account Update(Update_Sys_Account_Input model)
        {
            if (model.Id.IsNullOrEmpty() || model.Authority.Count == 0 || model.NickName.IsNullOrEmpty())
            {
                throw new Exception("不能为空");
            }

            Sys_Account instance = GetByKey(model.Id);

            instance.Update_Time = DateTime.Now;

            instance.Authority = string.Join(',', model.Authority);
            instance.NickName  = model.NickName;
            //instance.Password = GetEncryptPwd(model.Password, instance.Password_Salt);
            instance.Avatar  = model.Avatar;
            instance.Disable = model.Disable;

            base.Update(instance);

            RemoveCache();

            return(instance);
        }