/// <summary> /// 用户登录实现 /// </summary> /// <param name="parm"></param> /// <returns></returns> public async Task <ApiResult <SysAdmin> > LoginAsync(SysAdminLogin parm) { var res = new ApiResult <SysAdmin>(); try { parm.password = DES3Encrypt.EncryptString(parm.password); var model = Db.Queryable <SysAdmin>() .Where(m => m.LoginName == parm.loginname).First(); if (model != null) { if (model.LoginPwd.Equals(parm.password)) { //修改登录时间 model.LoginDate = DateTime.Now; model.UpLoginDate = model.LoginDate; SysAdminDb.Update(model); #region 保存操作日志 var logModel = new SysLog() { Guid = Guid.NewGuid().ToString(), LoginName = model.LoginName, DepartName = model.DepartmentName, OptionTable = "SysAdmin", Summary = "登录操作", IP = Utils.GetIp(), LogType = (int)LogEnum.Login, Urls = Utils.GetUrl(), AddTime = DateTime.Now }; SysLogDb.Insert(logModel); #endregion res.success = true; res.message = "获取成功!"; res.data = model; } else { res.success = false; res.statusCode = (int)ApiEnum.Error; res.message = "密码错误~"; } } else { res.success = false; res.statusCode = (int)ApiEnum.Error; res.message = "账号错误~"; } } catch (Exception ex) { res.message = ApiEnum.Error.GetEnumText() + ex.Message; res.statusCode = (int)ApiEnum.Error; } return(await Task.Run(() => res)); }
/// <summary> /// 删除一条或多条数据 /// </summary> /// <param name="parm"></param> /// <returns></returns> public async Task <ApiResult <string> > DeleteAsync(string parm) { var res = new ApiResult <string>() { data = "ok", statusCode = 200 }; try { var list = Utils.StrToListString(parm); var isok = SysLogDb.Delete(m => list.Contains(m.Guid)); } catch (Exception ex) { res.statusCode = (int)ApiEnum.Error; res.message = ApiEnum.Error.GetEnumText() + ex.Message; } return(await Task.Run(() => res)); }