Skip to content

Commit 67d2fe3

Browse files
committed
添加文件
1 parent 60cb073 commit 67d2fe3

19 files changed

+414
-264
lines changed

src/Senparc.TouTiao/Senparc.TouTiao.csproj

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,7 @@
5454
</PropertyGroup>
5555

5656
<ItemGroup>
57-
<PackageReference Include="Senparc.NeuChar" Version="1.2.106" />
58-
</ItemGroup>
59-
60-
<ItemGroup>
61-
<Folder Include="Entities\JsonResult\" />
57+
<PackageReference Include="Senparc.NeuChar" Version="1.2.108" />
6258
</ItemGroup>
6359

6460

src/Senparc.Toutiao/Cache.Local/ContainerCacheStrategy/LocalContainerCacheStrategy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#region Apache License Version 2.0
22
/*----------------------------------------------------------------
33
4-
Copyright 2020 Jeffrey Su & Suzhou Senparc Network Technology Co.,Ltd.
4+
Copyright 2020 Suzhou Senparc Network Technology Co.,Ltd.
55
66
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
77
except in compliance with the License. You may obtain a copy of the License at

src/Senparc.Toutiao/Cache/ContainerCacheStrategy/BaseContainerCacheStrategy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#region Apache License Version 2.0
22
/*----------------------------------------------------------------
33
4-
Copyright 2020 Jeffrey Su & Suzhou Senparc Network Technology Co.,Ltd.
4+
Copyright 2020 Suzhou Senparc Network Technology Co.,Ltd.
55
66
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
77
except in compliance with the License. You may obtain a copy of the License at

src/Senparc.Toutiao/Cache/ContainerCacheStrategy/IContainerCacheStrategy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#region Apache License Version 2.0
22
/*----------------------------------------------------------------
33
4-
Copyright 2020 Jeffrey Su & Suzhou Senparc Network Technology Co.,Ltd.
4+
Copyright 2020 Suzhou Senparc Network Technology Co.,Ltd.
55
66
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
77
except in compliance with the License. You may obtain a copy of the License at

src/Senparc.Toutiao/Cache/ContainerCacheStrategyDomain.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static Nested()
4242

4343
#endregion
4444

45-
private const string IDENTITY_NAME= "6526BBC0-718A-4F47-9675-D6DF6E1CE125";//固定值,请勿修改
45+
private const string IDENTITY_NAME= "0EEBB862-276C-4546-9964-FF9733EBD36B";//固定值,请勿修改
4646
private const string DOMAIN_NAME = "ToutiaoContainer";//固定值,请勿修改。同时会作为缓存键命名空间的子级名称
4747

4848
public string IdentityName { get { return IDENTITY_NAME; } }

src/Senparc.Toutiao/Cache/ContainerCacheStrategyFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#region Apache License Version 2.0
22
/*----------------------------------------------------------------
33
4-
Copyright 2020 Jeffrey Su & Suzhou Senparc Network Technology Co.,Ltd.
4+
Copyright 2020 Suzhou Senparc Network Technology Co.,Ltd.
55
66
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
77
except in compliance with the License. You may obtain a copy of the License at

src/Senparc.Toutiao/Containers/BaseContainer.cs

Lines changed: 5 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#region Apache License Version 2.0
22
/*----------------------------------------------------------------
33
4-
Copyright 2020 Jeffrey Su & Suzhou Senparc Network Technology Co.,Ltd.
4+
Copyright 2020 Suzhou Senparc Network Technology Co.,Ltd.
55
66
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
77
except in compliance with the License. You may obtain a copy of the License at
@@ -122,58 +122,6 @@ public interface IBaseContainer
122122
}
123123
}
124124

125-
//2016.8.8注释掉
126-
/// <summary>
127-
/// 获取当前容器的数据项集合
128-
/// </summary>
129-
/// <returns></returns>
130-
//protected static IContainerItemCollection ItemCollection
131-
//{
132-
// get
133-
// {
134-
// var cacheKey = GetContainerCacheKey();
135-
// IContainerItemCollection itemCollection;
136-
// if (!Cache.CheckExisted(cacheKey))
137-
// {
138-
// itemCollection = new ContainerItemCollection();
139-
// //CollectionList[cacheKey] = newItemCollection;
140-
141-
// //直接执行
142-
// //{
143-
// //}
144-
// //var containerCacheStrategy = CacheStrategyFactory.GetContainerCacheStrategyInstance();
145-
// //containerCacheStrategy.InsertToCache(cacheKey, itemCollection);//插入到缓存
146-
147-
// //保存到缓存队列,等待执行
148-
// SenparcMessageQueue mq = new SenparcMessageQueue();
149-
// var mqKey = SenparcMessageQueue.GenerateKey("ContainerItemCollection", typeof(BaseContainer<TBag>), cacheKey, "InsertItemCollection");
150-
// mq.Add(mqKey, () =>
151-
// {
152-
// var containerCacheStrategy = CacheStrategyFactory.GetContainerCacheStrategyInstance();
153-
// containerCacheStrategy.InsertToCache(cacheKey, itemCollection);//插入到缓存
154-
// });
155-
// }
156-
// else
157-
// {
158-
// itemCollection = Cache.Get(cacheKey);
159-
// }
160-
161-
// return itemCollection;
162-
// }
163-
//}
164-
165-
166-
167-
///// <summary>
168-
///// 获取Container缓存Key
169-
///// </summary>
170-
///// <returns></returns>
171-
//public static string GetContainerCacheKey()
172-
//{
173-
// return ContainerHelper.GetCacheKey(typeof(TBag));
174-
//}
175-
176-
177125

178126
/// <summary>
179127
/// 进行注册过程的委托集合
@@ -228,7 +176,7 @@ public static string GetFirstOrDefaultAppId(PlatformType platformType)
228176
appId = Senparc.Toutiao.Config.SenparcToutiaoSetting.AppId;
229177
break;
230178
default:
231-
throw new ArgumentOutOfRangeException($"未知的 PlatformType {nameof(platformType)}{platformType.ToString(0}");
179+
throw new ArgumentOutOfRangeException($"未知的 PlatformType {nameof(platformType)}{platformType.ToString()}");
232180
}
233181

234182
if (appId == null)
@@ -423,21 +371,11 @@ public static async Task<string> GetFirstOrDefaultAppIdAsync(PlatformType platfo
423371
string appId = null;
424372
switch (platformType)
425373
{
426-
case PlatformType.MP:
427-
appId = Senparc.Toutiao.Config.SenparcWeixinSetting.WeixinAppId;
428-
break;
429-
case PlatformType.Open:
430-
appId = Senparc.Toutiao.Config.SenparcWeixinSetting.WeixinAppId;
431-
break;
432-
case PlatformType.WxOpen:
433-
appId = Senparc.Toutiao.Config.SenparcWeixinSetting.WxOpenAppId;
434-
break;
435-
case PlatformType.QY:
436-
break;
437-
case PlatformType.Work:
374+
case PlatformType.Apps:
375+
appId = Senparc.Toutiao.Config.SenparcToutiaoSetting.AppId;
438376
break;
439377
default:
440-
break;
378+
throw new ArgumentOutOfRangeException($"未知的 PlatformType {nameof(platformType)}{platformType.ToString()}");
441379
}
442380

443381
if (appId == null)

src/Senparc.Toutiao/Containers/BaseContainerBag.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#region Apache License Version 2.0
22
/*----------------------------------------------------------------
33
4-
Copyright 2020 Jeffrey Su & Suzhou Senparc Network Technology Co.,Ltd.
4+
Copyright 2020 Suzhou Senparc Network Technology Co.,Ltd.
55
66
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
77
except in compliance with the License. You may obtain a copy of the License at
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
#region Apache License Version 2.0
2+
/*----------------------------------------------------------------
3+
4+
Copyright 2020 Jeffrey Su & Suzhou Senparc Network Technology Co.,Ltd.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7+
except in compliance with the License. You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software distributed under the
12+
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13+
either express or implied. See the License for the specific language governing permissions
14+
and limitations under the License.
15+
16+
Detail: https://github.com/JeffreySu/WeiXinMPSDK/blob/master/license.md
17+
18+
----------------------------------------------------------------*/
19+
#endregion Apache License Version 2.0
20+
21+
/*----------------------------------------------------------------
22+
Copyright (C) 2020 Senparc
23+
24+
文件名:WxJsonResult.cs
25+
文件功能描述:同于公众号的JSON返回结果基类(用于菜单接口等)
26+
27+
28+
创建标识:Senparc - 20150211
29+
30+
修改标识:Senparc - 20150303
31+
修改描述:整理接口
32+
33+
修改标识:Senparc - 20150303
34+
修改描述:添加QyJsonResult(企业号JSON返回结果)
35+
36+
修改标识:Senparc - 20150706
37+
修改描述:调整位置,去除MP下的WxJsonResult
38+
39+
修改标识:Senparc - 20161108
40+
修改描述:重写ToString()方法,快捷输出结果
41+
42+
修改标识:Senparc - 20170702
43+
修改描述:将 IWxJsonResult 定义从 IJsonResult.cs 文件移入
44+
45+
修改标识:Senparc - 20170702
46+
修改描述:v4.13.0 添加 ErrorCodeValue 属性。使用 BaseJsonResult 基类。
47+
----------------------------------------------------------------*/
48+
49+
using Senparc.NeuChar.Entities;
50+
using System;
51+
52+
namespace Senparc.Toutiao.Entities
53+
{
54+
/// <summary>
55+
/// 包含 errorcode 的 Json 返回结果接口
56+
/// </summary>
57+
public interface IWxJsonResult : IJsonResult
58+
{
59+
/// <summary>
60+
/// 返回结果代码
61+
/// </summary>
62+
ReturnCode errcode { get; set; }
63+
}
64+
65+
/// <summary>
66+
/// 公众号 JSON 返回结果(用于菜单接口等),子类必须具有不带参数的构造函数
67+
/// </summary>
68+
[Serializable]
69+
public class TtJsonResult : BaseJsonResult
70+
{
71+
//会造成循环引用
72+
//public WxJsonResult BaseResult
73+
//{
74+
// get { return this; }
75+
//}
76+
77+
public ReturnCode errcode { get; set; }
78+
79+
/// <summary>
80+
/// 返回消息代码数字(同errcode枚举值)
81+
/// </summary>
82+
public override int ErrorCodeValue { get { return (int)errcode; } }
83+
84+
/// <summary>
85+
/// 无参数的构造函数
86+
/// </summary>
87+
public TtJsonResult() { }
88+
89+
90+
public override string ToString()
91+
{
92+
return string.Format("WxJsonResult:{{errcode:'{0}',errcode_name:'{1}',errmsg:'{2}'}}",
93+
(int)errcode, errcode.ToString(), errmsg);
94+
}
95+
96+
//public ReturnCode ReturnCode
97+
//{
98+
// get
99+
// {
100+
// try
101+
// {
102+
// return (ReturnCode) errorcode;
103+
// }
104+
// catch
105+
// {
106+
// return ReturnCode.系统繁忙;//如果有“其他错误”的话可以指向其他错误
107+
// }
108+
// }
109+
//}
110+
//public void SerializingCallback()
111+
//{
112+
//}
113+
114+
//public void SrializedCallback(string json)
115+
//{
116+
// throw new NotImplementedException();
117+
//}
118+
119+
//public void DeserializingCallback(string json)
120+
//{
121+
// throw new NotImplementedException();
122+
//}
123+
124+
//public void DeserializedCallback(string json)
125+
//{
126+
// throw new NotImplementedException();
127+
//}
128+
}
129+
}

src/Senparc.Toutiao/Enums.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,24 @@ public enum PlatformType
1414
/// </summary>
1515
Apps
1616
}
17+
18+
/// <summary>
19+
/// 公众号返回码(JSON)
20+
/// 应该更名为ReturnCode_MP,但为减少项目中的修改,此处依旧用ReturnCode命名
21+
/// </summary>
22+
public enum ReturnCode
23+
{
24+
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释
25+
SenparcWeixinSDK配置错误 = -99,
26+
27+
系统错误 = -1,
28+
请求成功 = 0,
29+
appid错误 = 40015,
30+
secret错误 = 40017,
31+
grant_type不是client_credential = 40020,
32+
33+
//获取access_token时AppSecret错误或者access_token无效 = 40001,
34+
35+
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释
36+
}
1737
}

0 commit comments

Comments
 (0)