public ResultData Login([FromBody] UserInfo data) { if (data == null) { return(ResultData.CreateResult("-1", "用户名或密码不正确", null)); } KeyValuePair <bool, string> keyValue = ApiUtils.CheckFuncParams(data, "UserName", "Password"); if (!keyValue.Key) { return(ResultData.CreateResult("-1", $"验证失败,字段{keyValue.Value}不能为空", null)); } string pa = ApiUtils.MD5Encode(data.Password, "32"); UserInfo userInfo = _dbContext.Queryable <UserInfo>().Where(x => x.UserName.ToLower() == data.UserName.ToLower() && x.Password == ApiUtils.MD5Encode(data.Password, "32")).Single(); if (userInfo != null) { HttpContext.Session.SetData("user", userInfo); return(ResultData.CreateSuccessResult()); } else { return(ResultData.CreateResult("-1", "用户名或密码不正确", null)); } }
public async Task <ResultData> AddConfigInfo([FromBody] ConfigInfo info) { KeyValuePair <bool, string> keyValue = ApiUtils.CheckFuncParams(info, "ConfigName", "ConfigPath", "LocalPath", "CategoryType"); if (!keyValue.Key) { return(ResultData.CreateResult("-1", $"验证失败,字段{keyValue.Value}不能为空", null)); } info.CreateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); info.IsSystem = "0"; return(await ApiUtils.InsertData(_dbContext, info)); }