Skip to content

Commit

Permalink
Merge pull request #881 from colinin/Integrated-WeCom
Browse files Browse the repository at this point in the history
WeCom integration
  • Loading branch information
colinin committed Sep 23, 2023
2 parents 2a7ddb7 + 7877e95 commit 2f1d515
Show file tree
Hide file tree
Showing 102 changed files with 2,366 additions and 333 deletions.
5 changes: 5 additions & 0 deletions apps/vue/src/api/auditing/model/auditLogModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,8 @@ export interface EntityChangeGetWithUsernameInput {
entityId?: string;
entityTypeFullName?: string;
}

export interface RestoreEntityInput {
entityId: string;
entityChangeId?: string;
}
2 changes: 1 addition & 1 deletion apps/vue/src/store/modules/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const useSettingManagementStore = defineStore({
initlize(settingKey: string, api: (...args) => Promise<ListResultDto<SettingGroup>>) {
this.settingKey = settingKey;
if (this.settings.length === 0) {
ls.get(this.settingKey) || this.refreshSettings(api);
this.settings = ls.get(this.settingKey) || this.refreshSettings(api);
}
},
refreshSettings(api: (...args) => Promise<ListResultDto<SettingGroup>>) {
Expand Down
2 changes: 1 addition & 1 deletion apps/vue/src/views/feature/src/FeatureModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@ok="handleSubmit"
@cancel="onGroupChange(0)"
>
<Form ref="formRel" :model="featureGroup" :label-col="{ span: 6 }" :wrapper-col="{ span: 18 }">
<Form ref="formRel" :model="featureGroup">
<Tabs tabPosition="left" v-model:activeKey="featureGroupKey" @change="onGroupChange">
<TabPane v-for="(group, gi) in featureGroup.groups" :key="gi" :tab="group.displayName">
<div v-for="(feature, fi) in group.features" :key="feature.name">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
type="primary"
@click="handleAddNew"
>
{{ L('Language:AddNew') }}
{{ L('Resource:AddNew') }}
</Button>
</template>
<template #bodyCell="{ column, record }">
Expand Down Expand Up @@ -47,7 +47,6 @@
import { getList, GetAsyncByName, DeleteAsyncByName } from '/@/api/localization/resources';
import { Resource } from '/@/api/localization/model/resourcesModel';
import { getDataColumns } from './TableData';
import { reactive } from 'vue';
import ResourceModal from './ResourceModal.vue';
Expand Down
6 changes: 3 additions & 3 deletions apps/vue/src/views/localization/texts/components/ModalData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function getSearchFormSchemas(submitFunc?: () => Promise<void>): Partial<
colProps: { span: 6 },
required: true,
componentProps: {
api: () => getLanguages(),
api: getLanguages,
resultField: 'items',
labelField: 'displayName',
valueField: 'cultureName',
Expand All @@ -30,7 +30,7 @@ export function getSearchFormSchemas(submitFunc?: () => Promise<void>): Partial<
colProps: { span: 6 },
required: true,
componentProps: {
api: () => getLanguages(),
api: getLanguages,
resultField: 'items',
labelField: 'displayName',
valueField: 'cultureName',
Expand All @@ -42,7 +42,7 @@ export function getSearchFormSchemas(submitFunc?: () => Promise<void>): Partial<
label: L('DisplayName:ResourceName'),
colProps: { span: 6 },
componentProps: {
api: () => getResources(),
api: getResources,
resultField: 'items',
labelField: 'displayName',
valueField: 'name',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
colProps: { span: 24 },
required: true,
componentProps: {
api: () => getLanguages(),
api: getLanguages,
resultField: 'items',
labelField: 'uiCultureName',
valueField: 'cultureName',
Expand Down Expand Up @@ -80,7 +80,7 @@
colProps: { span: 24 },
required: true,
componentProps: {
api: () => getResources(),
api: getResources,
resultField: 'items',
labelField: 'displayName',
valueField: 'name',
Expand Down
3 changes: 2 additions & 1 deletion aspnet-core/LINGYUN.MicroService.All.sln
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
common.props = common.props
configureawait.props = configureawait.props
Directory.Build.props = Directory.Build.props
NuGet.Config = NuGet.Config
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Tencent.SettingManagement", "modules\cloud-tencent\LINGYUN.Abp.Tencent.SettingManagement\LINGYUN.Abp.Tencent.SettingManagement.csproj", "{C7CF4193-6397-4450-AF42-3BACD7CF292E}"
Expand Down Expand Up @@ -1793,7 +1794,7 @@ Global
{5D0ED1FC-3A7C-4531-9512-832E73AD9555} = {0439B173-F41E-4CE0-A44A-CCB70328F272}
{2BF7FB73-0C62-4ECF-99F0-0583855D2777} = {52B5D4F7-237B-4E0A-A167-68442164F70A}
{6FE7E243-2D99-4567-8786-6C9283D608EF} = {52B5D4F7-237B-4E0A-A167-68442164F70A}
{685188AC-A145-4A27-BF5F-9C970A59AA9C} = {672E1170-7B18-474B-85C7-1961BF2A48AE}
{685188AC-A145-4A27-BF5F-9C970A59AA9C} = {E2408063-FB1F-4513-B4A7-1FE50667C6E8}
{6AA0785D-9B6C-4EAE-AB83-0C4CF2B6B473} = {8AC72641-30D3-4ACF-89FA-808FADC55C2E}
{65DE28D5-DFEA-43E5-B820-BAF09A1FC4ED} = {8AC72641-30D3-4ACF-89FA-808FADC55C2E}
{D3E65610-4167-4235-9C9D-1E1FAD4C0CE6} = {8AC72641-30D3-4ACF-89FA-808FADC55C2E}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,6 @@ protected async virtual Task RestoreEntityByAuditLogAsync(RestoreEntityInput inp
}

var currentValue = propertyChange.OriginalValue;
if (input.EntityChangeId.HasValue)
{
currentValue = propertyChange.NewValue;
}
if (currentValue.IsNullOrWhiteSpace() || string.Equals("null", currentValue, StringComparison.InvariantCultureIgnoreCase))
{
if (isNullableType)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using Volo.Abp.MultiTenancy;

namespace LINGYUN.Abp.OssManagement;
Expand All @@ -13,6 +14,10 @@ public abstract class GetFileMultiTenancyInput
{
if (!TenantId.IsNullOrWhiteSpace())
{
if ("g".Equals(TenantId, StringComparison.InvariantCultureIgnoreCase))
{
return null;
}
if ("global".Equals(TenantId, StringComparison.InvariantCultureIgnoreCase))
{
return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using LINGYUN.Abp.WeChat.Work.Settings;
using System;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using Volo.Abp;
using Volo.Abp.Application.Services;
using Volo.Abp.Security.Encryption;
Expand All @@ -27,7 +25,7 @@ public async virtual Task<string> GenerateOAuth2AuthorizeAsync(string agentid, s
{
var state = _encryptionService.Encrypt($"agentid={agentid}&redirectUri={redirectUri}&responseType={responseType}&scope={scope}&random={Guid.NewGuid():D}").ToMd5();

return await _authorizeGenerator.GenerateOAuth2AuthorizeAsync(agentid, HttpUtility.UrlEncode(redirectUri, Encoding.UTF8), state, responseType, scope);
return await _authorizeGenerator.GenerateOAuth2AuthorizeAsync(agentid, redirectUri, state, responseType, scope);
}

public async virtual Task<string> GenerateOAuth2LoginAsync(string redirectUri, string loginType = "ServiceApp", string agentid = "")
Expand All @@ -38,6 +36,6 @@ public async virtual Task<string> GenerateOAuth2LoginAsync(string redirectUri, s

Check.NotNullOrEmpty(corpId, nameof(corpId));

return await _authorizeGenerator.GenerateOAuth2LoginAsync(corpId, HttpUtility.UrlEncode(redirectUri, Encoding.UTF8), state, loginType, agentid);
return await _authorizeGenerator.GenerateOAuth2LoginAsync(corpId, redirectUri, state, loginType, agentid);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using LINGYUN.Abp.WeChat.Work.Security;
using LINGYUN.Abp.WeChat.Work.Security.Models;
using LINGYUN.Abp.WeChat.Work.Settings;
using Microsoft.Extensions.Options;
using System.Threading.Tasks;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@ public WeChatWorkAuthorizeController(IWeChatWorkAuthorizeAppService service)
return _service.GenerateOAuth2AuthorizeAsync(agentid, redirectUri, responseType, scope);
}

[HttpGet]
[Route("oauth2/authorize")]
public async virtual Task<IActionResult> OAuth2AuthorizeAsync(
[FromQuery(Name = "agent_id")] string agentid,
[FromQuery(Name = "redirect_uri")] string redirectUri,
[FromQuery(Name = "response_type")] string responseType = "code",
[FromQuery] string scope = "snsapi_base")
{
var url = await _service.GenerateOAuth2AuthorizeAsync(agentid, redirectUri, responseType, scope);

return Redirect(url);
}

[HttpGet]
[Route("oauth2/login")]
public virtual Task<string> GenerateOAuth2LoginAsync(
Expand All @@ -40,4 +53,16 @@ public WeChatWorkAuthorizeController(IWeChatWorkAuthorizeAppService service)
{
return _service.GenerateOAuth2LoginAsync(redirectUri, loginType, agentid);
}

[HttpGet]
[Route("oauth2/login/sso")]
public async virtual Task<IActionResult> OAuth2LoginAsync(
[FromQuery(Name = "redirect_uri")] string redirectUri,
[FromQuery(Name = "login_type")] string loginType = "ServiceApp",
[FromQuery(Name = "agent_id")] string agentid = "")
{
var url = await _service.GenerateOAuth2LoginAsync(redirectUri, loginType, agentid);

return Redirect(url);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Volo.Abp.ExceptionHandling" Version="$(VoloAbpPackageVersion)" />
<PackageReference Include="Volo.Abp.Features" Version="$(VoloAbpPackageVersion)" />
<PackageReference Include="Volo.Abp.Caching" Version="$(VoloAbpPackageVersion)" />
<PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Microsoft.Extensions.DependencyInjection;
using System;
using Volo.Abp.Caching;
using Volo.Abp.ExceptionHandling;
using Volo.Abp.Localization;
using Volo.Abp.Localization.ExceptionHandling;
using Volo.Abp.Modularity;
Expand All @@ -13,6 +14,7 @@ namespace LINGYUN.Abp.WeChat.Work;

[DependsOn(
typeof(AbpCachingModule),
typeof(AbpExceptionHandlingModule),
typeof(AbpFeaturesLimitValidationModule),
typeof(AbpSettingsModule))]
public class AbpWeChatWorkModule : AbpModule
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
using LINGYUN.Abp.WeChat.Work.Settings;
using LINGYUN.Abp.WeChat.Work.Features;
using LINGYUN.Abp.WeChat.Work.Settings;
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using Volo.Abp;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Features;
using Volo.Abp.Settings;

namespace LINGYUN.Abp.WeChat.Work.Authorize;

[RequiresFeature(WeChatWorkFeatureNames.Enable)]
public class WeChatWorkAuthorizeGenerator : IWeChatWorkAuthorizeGenerator, ISingletonDependency
{
protected ISettingProvider SettingProvider { get; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
using LINGYUN.Abp.WeChat.Work.Authorize.Models;
using LINGYUN.Abp.WeChat.Work.Authorize.Request;
using LINGYUN.Abp.WeChat.Work.Authorize.Response;
using LINGYUN.Abp.WeChat.Work.Features;
using LINGYUN.Abp.WeChat.Work.Token;
using Newtonsoft.Json;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Features;

namespace LINGYUN.Abp.WeChat.Work.Authorize;

[RequiresFeature(WeChatWorkFeatureNames.Enable)]
public class WeChatWorkUserFinder : IWeChatWorkUserFinder, ISingletonDependency
{
protected IHttpClientFactory HttpClientFactory { get; }
Expand All @@ -31,8 +34,7 @@ public class WeChatWorkUserFinder : IWeChatWorkUserFinder, ISingletonDependency
var client = HttpClientFactory.CreateClient(AbpWeChatWorkGlobalConsts.ApiClient);

using var response = await client.GetUserInfoAsync(token.AccessToken, code, cancellationToken);
var responseContent = await response.Content.ReadAsStringAsync();
var userInfoResponse = JsonConvert.DeserializeObject<WeChatWorkUserInfoResponse>(responseContent);
var userInfoResponse = await response.DeserializeObjectAsync<WeChatWorkUserInfoResponse>();

return userInfoResponse.ToUserInfo();
}
Expand All @@ -47,8 +49,7 @@ public class WeChatWorkUserFinder : IWeChatWorkUserFinder, ISingletonDependency

var request = new WeChatWorkUserDetailRequest(userTicket);
using var response = await client.GetUserDetailAsync(token.AccessToken, request, cancellationToken);
var responseContent = await response.Content.ReadAsStringAsync();
var userDetailResponse = JsonConvert.DeserializeObject<WeChatWorkUserDetailResponse>(responseContent);
var userDetailResponse = await response.DeserializeObjectAsync<WeChatWorkUserDetailResponse>();

return userDetailResponse.ToUserDetail();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using LINGYUN.Abp.WeChat.Work.Chat.Request;
using LINGYUN.Abp.WeChat.Work.Chat.Response;
using System.Threading;
using System.Threading.Tasks;

namespace LINGYUN.Abp.WeChat.Work.Chat;
/// <summary>
/// 群聊操作接口
/// </summary>
/// <remarks>
/// 参考:https://developer.work.weixin.qq.com/document/path/90244
/// </remarks>
public interface IWeChatWorkAppChatManager
{
/// <summary>
/// 创建群聊会话
/// </summary>
/// <remarks>
/// 参考:https://developer.work.weixin.qq.com/document/path/90245
/// </remarks>
Task<WeChatWorkAppChatCreateResponse> CreateAsync(
WeChatWorkAppChatCreateRequest request,
CancellationToken cancellationToken = default);
/// <summary>
/// 修改群聊会话
/// </summary>
/// <remarks>
/// 参考:https://developer.work.weixin.qq.com/document/path/98913
/// </remarks>
Task<WeChatWorkResponse> UpdateAsync(
WeChatWorkAppChatUpdateRequest request,
CancellationToken cancellationToken = default);
/// <summary>
/// 获取群聊会话
/// </summary>
/// <remarks>
/// 参考:https://developer.work.weixin.qq.com/document/path/98914
/// </remarks>
Task<WeChatWorkAppChatInfoResponse> GetAsync(
string agentId,
string chatId,
CancellationToken cancellationToken = default);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace LINGYUN.Abp.WeChat.Work.Chat.Models;
public class WeChatWorkAppChatInfo
{
/// <summary>
/// 群聊名
/// </summary>
[JsonProperty("name")]
[JsonPropertyName("name")]
public virtual string Name { get; set; }
/// <summary>
/// 群主id
/// </summary>
[JsonProperty("owner")]
[JsonPropertyName("owner")]
public virtual string Owner { get; set; }
/// <summary>
/// 群成员id列表
/// </summary>
[JsonProperty("userlist")]
[JsonPropertyName("userlist")]
public virtual List<string> Users { get; set; }
/// <summary>
/// 群聊唯一标志
/// </summary>
[JsonProperty("chatid")]
[JsonPropertyName("chatid")]
public virtual string ChatId { get; set; }
}
Loading

0 comments on commit 2f1d515

Please sign in to comment.