Exemplo n.º 1
0
        /// <summary>
        /// 编辑功能
        /// </summary>
        /// <param name="input"></param>
        /// <param name="profile"></param>
        /// <returns></returns>
        public ActionResult EditFunc(Dictionary <string, string> input, sys_member profile)
        {
            sys_func f = JsonConvert.DeserializeObject <sys_func>(input["inputData"]);

            if (input["type"] == "save")
            {
                _db.Updateable(f).ExecuteCommand();
            }
            else if (input["type"] == "del")
            {
                if (!_db.Queryable <sys_func>().Where(_f => _f.pid == f.ID).Any())
                {
                    _db.Deleteable <sys_func>().Where(d => d.ID == f.ID).ExecuteCommand();
                }
                else
                {
                    return(new ActionResult(false, null, null, "请先删除子节点"));
                }
            }
            else
            {
                if (f.pid != null && f.pid == 0)
                {
                    f.pid = null;
                }
                if (input.ContainsKey("child") && input["child"] == "child")
                {
                    f.pid = f.ID;
                }
                _db.Insertable(f).ExecuteCommand();
            }
            return(new ActionResult(true));
        }
Exemplo n.º 2
0
        public bool SaveChange(SysMember entity)
        {
            var snapshot = GetById(entity.ID);
            var rlt      = _baseQueryRepository.Context.Ado.UseTran(() =>
            {
                var userTemp = new sys_member();
                userTemp.Mapp(entity);
                var success = _baseQueryRepository.Context.Updateable(userTemp)
                              .Where(it => it.ID == entity.ID)
                              .ExecuteCommand();//主表
                snapshot.Roles.Where(r => !entity.Roles.Exists(rr => rr.ID == r.ID)).ToList().ForEach(r =>
                {
                    _baseQueryRepository.Context.Ado.ExecuteCommand("delete from sys_member_roles_link where mid=@mid and rid=@rid;"
                                                                    , new { mid = entity.ID, rid = r.ID });
                });

                entity.Roles.Where(r => !snapshot.Roles.Exists(rr => rr.ID == r.ID)).ToList().ForEach(r =>
                {
                    var smrlink = new sys_member_roles_link()
                    {
                        ID  = IdWorker.NextId(),
                        mid = entity.ID,
                        rid = r.ID
                    };
                    _baseQueryRepository.Context.Insertable(smrlink).ExecuteCommand();
                });
            });

            return(true);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 保存用户角色
        /// </summary>
        /// <returns></returns>
        public ActionResult SaveSurRoles(Dictionary <string, string> input, sys_member profile)
        {
            sys_member usr = profile;

            if (usr != null)
            {
                List <sys_roles>      frl = JsonConvert.DeserializeObject <List <sys_roles> >(input["inputData"]);
                sys_member_roles_link mrl = new sys_member_roles_link();
                _db.Deleteable <sys_member_roles_link>().Where(l => l.mid == Convert.ToInt32(input["uid"])).ExecuteCommand();
                foreach (sys_roles r in frl)
                {
                    mrl     = new sys_member_roles_link();
                    mrl.mid = Convert.ToInt32(input["uid"]);
                    mrl.rid = Convert.ToInt32(r.ID);
                    _db.Insertable(mrl).ExecuteCommand();
                }
            }
            return(new ActionResult(true));
        }
Exemplo n.º 4
0
 public ActionResult PCenter()
 {
     if (Profile != null)
     {
         sys_member member = null;
         if (RequestContainsKey("type") && RequestContainsKey("id"))
         {
             member = DbInstance.Db.Queryable <sys_member>().Where(m => (m.ID == RequestInt64("id"))).First();
         }
         else
         {
             member = DbInstance.Db.Queryable <sys_member>().Where(m => (m.ID == Profile.ID)).First();
         }
         return(new ActionResult(true, member));
     }
     else
     {
         return(new ActionResult(false, null, null, "未授权的访问"));
     }
 }
Exemplo n.º 5
0
        public (bool success, string msg) AddMember(SysMember sysMember)
        {
            var rlt = _baseQueryRepository.Context.Ado.UseTran(() =>
            {
                var userTemp = new sys_member();
                userTemp.Mapp(sysMember);
                _baseQueryRepository.Context.Insertable(userTemp).ExecuteCommand();
                sysMember.Roles.ForEach(role =>
                {
                    var mrlink = new Model.sys_member_roles_link
                    {
                        ID  = IdWorker.NextId(),
                        mid = userTemp.ID,
                        rid = role.ID
                    };
                    _baseQueryRepository.Context.Insertable(mrlink).ExecuteCommand();
                });
            });

            return(rlt.IsSuccess, rlt.IsSuccess ? null : rlt.ErrorMessage);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 密码修改,启用停用、重置
        /// </summary>
        /// <returns></returns>
        public ActionResult ReSetpwd(Dictionary <string, string> input, sys_member profile)
        {
            sys_member usr = new sys_member();

            if (input.ContainsKey("pwd"))  //修改密码
            {
                if (input["pwd"].Length < 6)
                {
                    return(new ActionResult(false, null, null, "新密码至少6位"));
                }
                usr = profile;
                string pwd  = CryptoHelper.TripleDesEncrypting(input["opwd"]);
                string Npwd = CryptoHelper.TripleDesEncrypting(input["pwd"]);
                if (usr.pwd == pwd)
                {
                    usr.pwd = Npwd;
                    _db.Updateable(usr).ExecuteCommand();
                    return(new ActionResult(true));
                }
                else
                {
                    return(new ActionResult(false, null, null, "旧密码验证失败:管理员【微信:Anno6295】"));
                }
            }
            else if (input.ContainsKey("state"))  //启用停用
            {
                usr.ID    = Convert.ToInt32(input["uid"]);
                usr.state = Convert.ToInt16(input["state"]);
                _db.Updateable(usr).UpdateColumns(m => new { m.state }).ExecuteCommand();
            }
            else
            {  //重置密码
                usr.ID  = Convert.ToInt32(input["uid"]);
                usr.pwd = CryptoHelper.TripleDesEncrypting(Const.AppSettings.DefaultPwd);
                _db.Updateable(usr).UpdateColumns(m => new { m.pwd }).ExecuteCommand();
            }
            return(new ActionResult(true));
        }