public virtual IActionResult Get(long id) { try { var data = _baseRepo.Get(id); return(Ok(new { status = 0, message = "OK", data = data })); } catch (Exception ex) { return(Ok(new { status = -1, message = ex.Message })); } }
/// <summary> /// 获取用户主要岗位的ID。 /// </summary> /// <param name="id">用户ID。</param> /// <returns>用户对应的主要岗位的ID。</returns> public Guid GetMainStation(Guid id) { IBase usersRelation = Factory.GetBase("UsersRelation", "Sort"); Data.Model.UsersRelation model = usersRelation.Get <Data.Model.UsersRelation>( new KeyValuePair <string, object>("UserID", id), new KeyValuePair <string, object>("IsMain", 1)); return(model != null ? model.OrganizeID : Guid.Empty); }
public IActionResult Post([FromBody] Login model) { try { UsersHelper.VerifyAdminUser(this.dataRepositoryFactory); User user = users.Get(x => x.Where(u => u.Active == true && u.Email == model.Email && u.Password == MD5.Encrypt(model.Password, _appSettings.Value.TokenKey))); if (user == null) { return(Ok(new { status = -1, message = "Invalid credentials" })); } var claims = new[] { new Claim(JwtRegisteredClaimNames.UniqueName, user.Email), new Claim(JwtRegisteredClaimNames.Sid, user.Id.ToString()), //new Claim("miValor", "Lo que yo quiera"), new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()) }; var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_appSettings.Value.TokenKey)); var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256); var expiration = DateTime.UtcNow.AddHours(_appSettings.Value.TokenTimeHours); JwtSecurityToken token = new JwtSecurityToken( issuer: _appSettings.Value.Domain, audience: _appSettings.Value.Domain, claims: claims, expires: expiration, signingCredentials: creds ); string tokenString = new JwtSecurityTokenHandler().WriteToken(token); user.TokenKey = tokenString; _cache.Set <User>(tokenString, user, DateTimeOffset.Now.AddHours(_appSettings.Value.TokenTimeHours)); return(Ok(new { message = "OK", status = 1, token = tokenString, expiration = expiration, user = user })); } catch (Exception ex) { return(Ok(new { status = -1, message = ex.Message })); } }
public virtual bool Get <T>(out object resultData) where T : new() { return(_service.Get <T>(out resultData)); }
/// <summary> /// 查询单条记录 /// </summary> public RoadFlow.Data.Model.AppLibraryModel Get(Guid id, bool fromCache = false) { return(BaseDb.Get <RoadFlow.Data.Model.AppLibraryModel>(new KeyValuePair <string, object>("ID", id))); }
public RoadFlow.Data.Model.ArticleModel Get(string id) { return(baseDb.Get <RoadFlow.Data.Model.ArticleModel>(new KeyValuePair <string, object>("ID", id.Convert <Guid>()))); }
public RoadFlow.Data.Model.BuildingsModel Get(string id) { return(BaseDb.Get <RoadFlow.Data.Model.BuildingsModel>(new KeyValuePair <string, object>("ID", id))); }
public RoadFlow.Data.Model.BuildingsModel Get(Guid id) { return(baseDb.Get <RoadFlow.Data.Model.BuildingsModel>(new KeyValuePair <string, object>("ID", id), new KeyValuePair <string, object>("Status", RoadFlow.Data.Model.Status.Normal))); }
public RoadFlow.Data.Model.BuildingsAndBuildingMonthInfoModel Get(Guid id) { return(BaseDb.Get <RoadFlow.Data.Model.BuildingsAndBuildingMonthInfoModel>(new KeyValuePair <string, object>("ID", id))); }
/// <summary> /// 按名称获取流程 /// </summary> /// <param name="name">流程名称</param> public RoadFlow.Data.Model.WorkFlow GetByName(string name) { //报送流程ID return(baseDb.Get <RoadFlow.Data.Model.WorkFlow>(new KeyValuePair <string, object>("Name", name))); }
public DictionaryModel GetByID(Guid id) { return(BaseDb.Get <RoadFlow.Data.Model.DictionaryModel>(new KeyValuePair <string, object>("ID", id))); }
/// <summary> /// 获取组织机构 /// </summary> /// <returns></returns> public RoadFlow.Data.Model.OrganizeModel GetByID(Guid id) { return(baseDb.Get <RoadFlow.Data.Model.OrganizeModel>(new KeyValuePair <string, object>("ID", id))); }