/// <summary> /// 创建实体 /// </summary> /// <param name="input"></param> /// <returns></returns> protected virtual async Task CreateRoleAsync(CreateOrUpdateRoleInput input) { var role = input.Role.MapTo<AuthorityRoleInfo>(); role.CreatorUserId = YLSession.UserId; role.CreatorUserName = ""; role.CreationTime = Clock.Now; await _roleRepository.InsertAsync(role); cacheHandler.Remove(CacheCategoryRole, "GetRoleList"); }
/// <summary> /// 修改实体 /// </summary> /// <param name="input"></param> /// <returns></returns> protected virtual async Task UpdateRoleAsync(CreateOrUpdateRoleInput input) { Debug.Assert(input.Role.Id != null, "input.Role.Id should be set."); var role = await _roleRepository.GetAsync(input.Role.Id); role = input.Role.MapTo<AuthorityRoleInfo>(); role.LastModifierUserId = YLSession.UserId; role.LastModifierUserName = ""; role.LastModificationTime = Clock.Now; await _roleRepository.UpdateAsync(role); cacheHandler.Remove(CacheCategoryRole, "GetRoleList"); }
/// <summary> /// 添加修改实体 /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task CreateOrUpdateRole(CreateOrUpdateRoleInput input) { if (input.Role.Id != null && input.Role.Id != Guid.Empty) { await UpdateRoleAsync(input); } else { await CreateRoleAsync(input); } }