fix 消息记录保存日志
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
using System.Text;
|
||||
using Dlhis.Message.Options;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
@@ -8,13 +10,15 @@ namespace Dlhis.Message.Services;
|
||||
public class JinkoApiService : IJinkoApiService
|
||||
{
|
||||
private readonly IHttpClientFactory _httpClientFactory;
|
||||
private readonly DingTalkOption _dingTalkOption;
|
||||
|
||||
public JinkoApiService(IHttpClientFactory httpClientFactory)
|
||||
public JinkoApiService(IHttpClientFactory httpClientFactory, IOptions<DingTalkOption> options)
|
||||
{
|
||||
_httpClientFactory = httpClientFactory;
|
||||
_dingTalkOption = options.Value;
|
||||
}
|
||||
|
||||
public async Task<string> GetTokenAsync()
|
||||
private async Task<string> GetTokenAsync()
|
||||
{
|
||||
var token = string.Empty;
|
||||
if (string.IsNullOrEmpty(token))
|
||||
@@ -23,11 +27,10 @@ public class JinkoApiService : IJinkoApiService
|
||||
|
||||
var form = new FormUrlEncodedContent(new Dictionary<string, string>
|
||||
{
|
||||
{ "appkey", "dingumelppews6rah7x9" },
|
||||
{ "appsecret", "nsWfJTVjYesHVzrLiP-t1TQqMQvC1L_kZNfXfnIyzcXK4pCTfKprkjZcxAbsDR_l" }
|
||||
{ "appkey", _dingTalkOption.AppKey },
|
||||
{ "appsecret", _dingTalkOption.AppSecret }
|
||||
});
|
||||
|
||||
//appkey=dingumelppews6rah7x9&appsecret=nsWfJTVjYesHVzrLiP-t1TQqMQvC1L_kZNfXfnIyzcXK4pCTfKprkjZcxAbsDR_l
|
||||
|
||||
var response = await httpClient.GetStringAsync($"/gettoken?{await form.ReadAsStringAsync()}");
|
||||
var jObj = JObject.Parse(response);
|
||||
(jObj.Value<string>("errcode") == "0").ThrowIfFalse(jObj.Value<string>("errmsg"));
|
||||
@@ -50,7 +53,7 @@ public class JinkoApiService : IJinkoApiService
|
||||
|
||||
var body = new
|
||||
{
|
||||
agent_id = "2768073678",
|
||||
agent_id = _dingTalkOption.AgentId,
|
||||
userid_list = userStringIds,
|
||||
msg = new
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user