コード例 #1
0
            public async Task <IEnumerable <ResUdv> > ListUdv(UdfTargetType targetType, string targetId, CancellationToken cancellationToken = default)
            {
                var param = new UdvParam(targetType, targetId);
                var res   = await client.Request <UdvResponse>(param.CreateRequest(), cancellationToken);

                return(AuthingUtils.ConvertUdv(res.Result));
            }
コード例 #2
0
            /// <summary>
            /// 获取自定义字段列表
            /// </summary>
            /// <param name="type">自定义字段目标类型, USER 表示用户、ROLE 表示角色。</param>
            /// <param name="cancellationToken"></param>
            /// <returns></returns>
            public async Task <IEnumerable <UserDefinedField> > List(
                UdfTargetType type,
                CancellationToken cancellationToken = default)
            {
                var param = new UdfParam(type);

                var res = await client.Request <UdfResponse>(param.CreateRequest(), cancellationToken);

                return(res.Result);
            }
コード例 #3
0
            /// <summary>
            /// 删除自定义字段
            /// </summary>
            /// <param name="type">自定义字段目标类型, USER 表示用户、ROLE 表示角色。</param>
            /// <param name="key">字段 key</param>
            /// <param name="cancellationToken"></param>
            /// <returns></returns>
            public async Task <CommonMessage> Remove(
                UdfTargetType type,
                string key,
                CancellationToken cancellationToken = default)
            {
                var param = new RemoveUdfParam(type, key);

                var res = await client.Request <RemoveUdfResponse>(param.CreateRequest(), cancellationToken);

                return(res.Result);
            }
コード例 #4
0
            /// <summary>
            /// 设置自定义字段元数据,如果字段不存在则会创建,存在会更新
            /// </summary>
            /// <param name="type">自定义字段目标类型, USER 表示用户、ROLE 表示角色。</param>
            /// <param name="key">字段 key</param>
            /// <param name="dataType">数据类型,目前共支持五种数据类型。STRING 为字符串、NUMBER 为数字、DATETIME 为日期、BOOLEAN 为 boolean 值、OBJECT 为对象。</param>
            /// <param name="label">字段 Label,一般是一个 Human Readable 字符串。</param>
            /// <param name="cancellationToken"></param>
            /// <returns></returns>
            public async Task <UserDefinedField> Set(
                UdfTargetType type,
                string key,
                UdfDataType dataType,
                string label,
                CancellationToken cancellationToken = default)
            {
                var param = new SetUdfParam(type, key, dataType, label);

                var res = await client.Request <SetUdfResponse>(param.CreateRequest(), cancellationToken);

                return(res.Result);
            }
コード例 #5
0
            public async Task <IEnumerable <ResUdv> > SetUdvBatch(UdfTargetType udfTargetType, string targetId, KeyValueDictionary udvList, CancellationToken cancellationToken = default)
            {
                var _udvList = new List <UserDefinedDataInput>();

                udvList.ToList().ForEach(udv => _udvList.Add(new UserDefinedDataInput(udv.Key)
                {
                    Value = udv.Value
                }));
                var param = new SetUdvBatchParam(udfTargetType, targetId)
                {
                    UdvList = _udvList
                };
                var res = await client.Request <SetUdvBatchResponse>(param.CreateRequest(), cancellationToken);

                return(AuthingUtils.ConvertUdv(res.Result));
            }