Example #1
0
        public ActionResult <object> Post([FromBody] sys_userVM model)
        {
            sys_user_Entity entity = model.ConvertToT <sys_user_Entity>();

            this.SetCreateUserInfo(entity);
            return(this._repository.Insert(entity).ResponseSuccess());
        }
Example #2
0
        /// <summary>
        /// 修改
        /// <summary>
        public bool Update(sys_user_Entity model)
        {
            Dictionary <string, object> dic = new Dictionary <string, object>();

            dic["User_ID"] = model.User_ID;

            if (model.Password != null)
            {
                dic["Password"] = model.Password;
            }
            if (model.User_Name != null)
            {
                dic["User_Name"] = model.User_Name;
            }
            if (model.User_Status != null && model.User_Status.HasValue)
            {
                dic["User_Status"] = model.User_Status;
            }
            if (model.Update_UserId != null)
            {
                dic["Update_UserId"] = model.Update_UserId;
            }
            if (model.Update_User != null)
            {
                dic["Update_User"] = model.Update_User;
            }
            return(SQLHelperFactory.Instance.ExecuteNonQuery("Update_sys_user", dic) > 0);
        }
Example #3
0
        public ActionResult <object> GetList([FromBody] sys_userVM model, int pageindex, int pagesize)
        {
            sys_user_Entity entity = model.ConvertToT <sys_user_Entity>();

            var(list, total) = this._repository.GetList(entity, pageindex, pagesize);
            return(list.ResponseSuccess("", total));
        }
Example #4
0
        public ActionResult <object> Delete(int User_ID)
        {
            sys_user_Entity entity = new sys_user_Entity();

            this.SetUpdateUserInfo(entity);
            this._repository.Update(entity);
            return(this._repository.Delete(User_ID).ResponseSuccess());
        }
Example #5
0
        public ActionResult <object> UpdateUserPassword([FromBody] sys_userVM model)
        {
            sys_user_Entity entity = this.GetLoginUser();

            this.SetUpdateUserInfo(entity);
            entity.Password = model.Password;
            return(this._repository.Update(entity).ResponseSuccess());
        }
Example #6
0
        public ActionResult <object> Login([FromBody] LoginVM model)
        {
            LoginVM         login = new LoginVM();
            sys_user_Entity user  = this._repository.GetUserByAccount(model.User_Account);

            if (user == null || !model.Password.Equals(user.Password))
            {
                return(login.ResponseNotLogin("登录失败"));
            }
            user.Password = "";
            var key    = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(this._configuration["JWT:SecurityKey"]));
            var creds  = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);
            var claims = new[] { new Claim(ClaimTypes.Name, user.ToJson()) };

            var authTime  = DateTime.UtcNow;
            var expiresAt = authTime.AddDays(7);
            var token     = new JwtSecurityToken(issuer: "*", audience: "*", claims: claims, expires: expiresAt, signingCredentials: creds);

            login.token = Constant.JwtTokenPrefix + new JwtSecurityTokenHandler().WriteToken(token);
            //HttpContext.Session.SetString(login.token, user.ToJson());

            return(login.ResponseSuccess());
        }
Example #7
0
        /// <summary>
        /// 获取列表
        /// <summary>
        public (IEnumerable <sys_user_Entity>, int) GetList(sys_user_Entity model, int pageindex, int pagesize)
        {
            Dictionary <string, object> dic = new Dictionary <string, object>();

            if (model.User_ID != 0)
            {
                dic["User_ID"] = model.User_ID;
            }
            if (model.User_Account != null)
            {
                dic["User_Account"] = model.User_Account;
            }
            if (model.Password != null)
            {
                dic["Password"] = model.Password;
            }
            if (model.User_Name != null)
            {
                dic["User_Name"] = model.User_Name;
            }
            if (model.User_Status != null && model.User_Status.HasValue)
            {
                dic["User_Status"] = model.User_Status;
            }
            if (pageindex >= 0)
            {
                dic["StartIndex"] = pageindex <= 1 ? 0 : (pageindex - 1) * pagesize;
            }
            if (pagesize > 0)
            {
                dic["SelectCount"] = pagesize;
            }
            var list = SQLHelperFactory.Instance.QueryMultipleByPage <sys_user_Entity>("Select_sys_user_List", dic, out int total);

            return(list, total);
        }