116 changed files with 3851 additions and 752 deletions
@ -0,0 +1,46 @@ |
|||
import { defAbpHttp } from '/@/utils/http/abp'; |
|||
import { |
|||
TextTemplateContentDto, |
|||
TextTemplateContentGetInput, |
|||
TextTemplateRestoreInput, |
|||
TextTemplateContentUpdateDto |
|||
} from './model'; |
|||
|
|||
const remoteServiceName = 'AbpTextTemplating'; |
|||
const controllerName = 'TextTemplate'; |
|||
|
|||
export const GetAsyncByInput = (input: TextTemplateContentGetInput) => { |
|||
return defAbpHttp.request<TextTemplateContentDto>({ |
|||
service: remoteServiceName, |
|||
controller: controllerName, |
|||
action: 'GetAsync', |
|||
uniqueName: 'GetAsyncByInput', |
|||
params: input, |
|||
}); |
|||
}; |
|||
|
|||
export const RestoreToDefaultAsyncByNameAndInput = (name: string, input: TextTemplateRestoreInput) => { |
|||
return defAbpHttp.request<void>({ |
|||
service: remoteServiceName, |
|||
controller: controllerName, |
|||
action: 'RestoreToDefaultAsync', |
|||
uniqueName: 'RestoreToDefaultAsyncByNameAndInput', |
|||
params: { |
|||
name: name, |
|||
}, |
|||
data: input, |
|||
}); |
|||
}; |
|||
|
|||
export const UpdateAsyncByNameAndInput = (name: string, input: TextTemplateContentUpdateDto) => { |
|||
return defAbpHttp.request<TextTemplateContentDto>({ |
|||
service: remoteServiceName, |
|||
controller: controllerName, |
|||
action: 'UpdateAsync', |
|||
uniqueName: 'UpdateAsyncByNameAndInput', |
|||
params: { |
|||
name: name, |
|||
}, |
|||
data: input, |
|||
}); |
|||
}; |
|||
@ -0,0 +1,19 @@ |
|||
export interface TextTemplateContentDto { |
|||
name: string; |
|||
content?: string; |
|||
culture?: string; |
|||
} |
|||
|
|||
export interface TextTemplateContentGetInput { |
|||
name: string; |
|||
culture?: string; |
|||
} |
|||
|
|||
export interface TextTemplateRestoreInput { |
|||
culture?: string; |
|||
} |
|||
|
|||
export interface TextTemplateContentUpdateDto { |
|||
culture?: string; |
|||
content: string; |
|||
} |
|||
@ -0,0 +1,67 @@ |
|||
import { defAbpHttp } from '/@/utils/http/abp'; |
|||
import { |
|||
TextTemplateDefinitionDto, |
|||
TextTemplateDefinitionCreateDto, |
|||
TextTemplateDefinitionUpdateDto, |
|||
TextTemplateDefinitionGetListInput |
|||
} from './model'; |
|||
|
|||
const remoteServiceName = 'AbpTextTemplating'; |
|||
const controllerName = 'TextTemplateDefinition'; |
|||
|
|||
export const CreateAsyncByInput = (input: TextTemplateDefinitionCreateDto) => { |
|||
return defAbpHttp.request<TextTemplateDefinitionDto>({ |
|||
service: remoteServiceName, |
|||
controller: controllerName, |
|||
action: 'CreateAsync', |
|||
uniqueName: 'CreateAsyncByInput', |
|||
params: input, |
|||
}); |
|||
}; |
|||
|
|||
export const DeleteAsyncByName = (name: string) => { |
|||
return defAbpHttp.request<void>({ |
|||
service: remoteServiceName, |
|||
controller: controllerName, |
|||
action: 'DeleteAsync', |
|||
uniqueName: 'DeleteAsyncByName', |
|||
params: { |
|||
name: name, |
|||
}, |
|||
}); |
|||
}; |
|||
|
|||
export const GetByNameAsyncByName = (name: string) => { |
|||
return defAbpHttp.request<TextTemplateDefinitionDto>({ |
|||
service: remoteServiceName, |
|||
controller: controllerName, |
|||
action: 'GetByNameAsync', |
|||
uniqueName: 'GetByNameAsyncByName', |
|||
params: { |
|||
name: name, |
|||
}, |
|||
}); |
|||
}; |
|||
|
|||
export const GetListAsyncByInput = (input: TextTemplateDefinitionGetListInput) => { |
|||
return defAbpHttp.request<PagedResultDto<TextTemplateDefinitionDto>>({ |
|||
service: remoteServiceName, |
|||
controller: controllerName, |
|||
action: 'GetListAsync', |
|||
uniqueName: 'GetListAsyncByInput', |
|||
params: input, |
|||
}); |
|||
}; |
|||
|
|||
export const UpdateAsyncByNameAndInput = (name: string, input: TextTemplateDefinitionUpdateDto) => { |
|||
return defAbpHttp.request<TextTemplateDefinitionDto>({ |
|||
service: remoteServiceName, |
|||
controller: controllerName, |
|||
action: 'UpdateAsync', |
|||
uniqueName: 'UpdateAsyncByNameAndInput', |
|||
params: { |
|||
name: name, |
|||
}, |
|||
data: input, |
|||
}); |
|||
}; |
|||
@ -0,0 +1,30 @@ |
|||
export interface TextTemplateDefinitionDto { |
|||
name: string; |
|||
displayName: string; |
|||
defaultCultureName?: string; |
|||
isInlineLocalized: boolean; |
|||
isLayout: boolean; |
|||
layout: string; |
|||
isStatic: boolean; |
|||
renderEngine?: string; |
|||
} |
|||
|
|||
interface TextTemplateDefinitionCreateOrUpdateDto { |
|||
displayName: string; |
|||
defaultCultureName?: string; |
|||
isInlineLocalized: boolean; |
|||
isLayout: boolean; |
|||
layout: string; |
|||
isStatic: boolean; |
|||
renderEngine?: string; |
|||
} |
|||
|
|||
export interface TextTemplateDefinitionCreateDto extends TextTemplateDefinitionCreateOrUpdateDto { |
|||
name: string; |
|||
} |
|||
|
|||
export interface TextTemplateDefinitionUpdateDto extends TextTemplateDefinitionCreateOrUpdateDto, IHasConcurrencyStamp { } |
|||
|
|||
export interface TextTemplateDefinitionGetListInput extends PagedAndSortedResultRequestDto { |
|||
filter?: string; |
|||
} |
|||
@ -1,63 +0,0 @@ |
|||
import { defAbpHttp } from '/@/utils/http/abp'; |
|||
import { |
|||
TextTemplateDefinition, |
|||
TextTemplateContent, |
|||
TextTemplateContentGetInput, |
|||
TextTemplateUpdateInput, |
|||
TextTemplateRestoreInput, |
|||
TextTemplateDefinitionGetListInput, |
|||
} from './model'; |
|||
|
|||
const remoteServiceName = 'AbpTextTemplating'; |
|||
const controllerName = 'TextTemplate'; |
|||
|
|||
export const get = (name: string) => { |
|||
return defAbpHttp.request<TextTemplateDefinition>({ |
|||
service: remoteServiceName, |
|||
controller: controllerName, |
|||
action: 'GetAsync', |
|||
params: { |
|||
name: name, |
|||
}, |
|||
}); |
|||
}; |
|||
|
|||
export const getContent = (input: TextTemplateContentGetInput) => { |
|||
return defAbpHttp.request<TextTemplateContent>({ |
|||
service: remoteServiceName, |
|||
controller: controllerName, |
|||
action: 'GetContentAsync', |
|||
params: { |
|||
input: input, |
|||
}, |
|||
}); |
|||
} |
|||
|
|||
export const getList = (input: TextTemplateDefinitionGetListInput) => { |
|||
return defAbpHttp.request<PagedResultDto<TextTemplateDefinition>>({ |
|||
service: remoteServiceName, |
|||
controller: controllerName, |
|||
action: 'GetListAsync', |
|||
params: { |
|||
input: input, |
|||
}, |
|||
}); |
|||
}; |
|||
|
|||
export const restoreToDefault = (input: TextTemplateRestoreInput) => { |
|||
return defAbpHttp.request<void>({ |
|||
service: remoteServiceName, |
|||
controller: controllerName, |
|||
action: 'RestoreToDefaultAsync', |
|||
data: input, |
|||
}); |
|||
}; |
|||
|
|||
export const update = (input: TextTemplateUpdateInput) => { |
|||
return defAbpHttp.request<TextTemplateDefinition>({ |
|||
service: remoteServiceName, |
|||
controller: controllerName, |
|||
action: 'UpdateAsync', |
|||
data: input, |
|||
}); |
|||
}; |
|||
@ -1,34 +0,0 @@ |
|||
export interface TextTemplateDefinition { |
|||
name: string; |
|||
displayName: string; |
|||
defaultCultureName?: string; |
|||
isInlineLocalized: boolean; |
|||
isLayout: boolean; |
|||
layout?: string; |
|||
} |
|||
|
|||
export interface TextTemplateContent { |
|||
name: string; |
|||
content?: string; |
|||
culture?: string; |
|||
} |
|||
|
|||
export interface TextTemplateContentGetInput { |
|||
name: string; |
|||
culture?: string; |
|||
} |
|||
|
|||
export interface TextTemplateRestoreInput { |
|||
name: string; |
|||
culture?: string; |
|||
} |
|||
|
|||
export interface TextTemplateUpdateInput { |
|||
name: string; |
|||
culture?: string; |
|||
content: string; |
|||
} |
|||
|
|||
export interface TextTemplateDefinitionGetListInput extends PagedAndSortedResultRequestDto { |
|||
filter?: string; |
|||
} |
|||
@ -0,0 +1,111 @@ |
|||
<template> |
|||
<div> |
|||
<BasicTable @register="registerTable"> |
|||
<template #bodyCell="{ column, record }"> |
|||
<template v-if="column.key === 'isStatic'"> |
|||
<CheckOutlined v-if="record.isStatic" class="enable" /> |
|||
<CloseOutlined v-else class="disable" /> |
|||
</template> |
|||
<template v-else-if="column.key === 'isInlineLocalized'"> |
|||
<CheckOutlined v-if="record.isInlineLocalized" class="enable" /> |
|||
<CloseOutlined v-else class="disable" /> |
|||
</template> |
|||
<template v-else-if="column.key === 'isLayout'"> |
|||
<CheckOutlined v-if="record.isLayout" class="enable" /> |
|||
<CloseOutlined v-else class="disable" /> |
|||
</template> |
|||
<template v-else-if="column.key === 'action'"> |
|||
<TableAction |
|||
v-auth="['AbpTextTemplating.TextTemplateDefinitions', 'AbpTextTemplating.TextTemplateDefinitions.Delete']" |
|||
:stop-button-propagation="true" |
|||
:actions="[ |
|||
{ |
|||
auth: 'AbpTextTemplating.TextTemplateDefinitions.Update', |
|||
label: L('Update'), |
|||
icon: 'ant-design:edit-outlined', |
|||
onClick: handleEdit.bind(null, record), |
|||
}, |
|||
{ |
|||
auth: 'AbpTextTemplating.TextTemplateDefinitions.Delete', |
|||
label: L('Delete'), |
|||
color: 'error', |
|||
icon: 'ant-design:delete-outlined', |
|||
onClick: handleDelete.bind(null, record), |
|||
}, |
|||
]" |
|||
:dropDownActions="[ |
|||
{ |
|||
auth: 'AbpTextTemplating.TextTemplateContent.Update', |
|||
label: L('EditContents'), |
|||
icon: 'ant-design:edit-outlined', |
|||
onClick: handleEditContent.bind(null, record), |
|||
}, |
|||
]" |
|||
/> |
|||
</template> |
|||
</template> |
|||
</BasicTable> |
|||
<TemplateContentModal @register="registerModal" /> |
|||
</div> |
|||
</template> |
|||
|
|||
<script lang="ts" setup> |
|||
import { CheckOutlined, CloseOutlined } from '@ant-design/icons-vue'; |
|||
import { useModal } from '/@/components/Modal'; |
|||
import { BasicTable, TableAction, useTable } from '/@/components/Table'; |
|||
import { getDataColumns } from '../datas/TableData'; |
|||
import { getSearchFormSchemas } from '../datas/ModalData'; |
|||
import { useMessage } from '/@/hooks/web/useMessage'; |
|||
import { useLocalization } from '/@/hooks/abp/useLocalization'; |
|||
import { GetListAsyncByInput, DeleteAsyncByName } from '/@/api/text-templating/definitions'; |
|||
import { TextTemplateDefinitionDto } from '/@/api/text-templating/definitions/model'; |
|||
import { formatPagedRequest } from '/@/utils/http/abp/helper'; |
|||
import TemplateContentModal from './TemplateContentModal.vue'; |
|||
|
|||
const { L } = useLocalization(['AbpTextTemplating', 'AbpUi']); |
|||
const { createConfirm, createMessage } = useMessage(); |
|||
const [registerModal, { openModal }] = useModal(); |
|||
const [registerTable, { reload }] = useTable({ |
|||
rowKey: 'name', |
|||
title: L('TextTemplates'), |
|||
columns: getDataColumns(), |
|||
api: GetListAsyncByInput, |
|||
beforeFetch: formatPagedRequest, |
|||
pagination: true, |
|||
striped: false, |
|||
useSearchForm: true, |
|||
formConfig: getSearchFormSchemas(), |
|||
showIndexColumn: false, |
|||
showTableSetting: true, |
|||
bordered: true, |
|||
canResize: true, |
|||
immediate: true, |
|||
actionColumn: { |
|||
width: 150, |
|||
title: L('Actions'), |
|||
dataIndex: 'action', |
|||
}, |
|||
}); |
|||
|
|||
function handleEdit(record: TextTemplateDefinitionDto) { |
|||
console.log('This method is not implemented', record); |
|||
} |
|||
|
|||
function handleEditContent(record: TextTemplateDefinitionDto) { |
|||
openModal(true, record); |
|||
} |
|||
|
|||
function handleDelete(record: TextTemplateDefinitionDto) { |
|||
createConfirm({ |
|||
iconType: 'warning', |
|||
title: L('AreYouSure'), |
|||
content: record.isStatic ? L('RestoreTemplateToDefaultMessage') : L('ItemWillBeDeletedMessage'), |
|||
onOk: () => { |
|||
return DeleteAsyncByName(record.name).then(() => { |
|||
createMessage.success(record.isStatic ? L('TemplateUpdated') : L('SuccessfullyDeleted')); |
|||
reload(); |
|||
}); |
|||
}, |
|||
}); |
|||
} |
|||
</script> |
|||
@ -1,71 +0,0 @@ |
|||
<template> |
|||
<div> |
|||
<BasicTable @register="registerTable"> |
|||
<template #bodyCell="{ column, record }"> |
|||
<template v-if="column.key === 'isInlineLocalized'"> |
|||
<!-- <Switch readonly :checked="record.isInlineLocalized" /> --> |
|||
<CheckOutlined v-if="record.isInlineLocalized" class="enable" /> |
|||
<CloseOutlined v-else class="disable" /> |
|||
</template> |
|||
<template v-else-if="column.key === 'isLayout'"> |
|||
<!-- <Switch readonly :checked="record.isLayout" /> --> |
|||
<CheckOutlined v-if="record.isLayout" class="enable" /> |
|||
<CloseOutlined v-else class="disable" /> |
|||
</template> |
|||
<template v-else-if="column.key === 'action'"> |
|||
<TableAction |
|||
:stop-button-propagation="true" |
|||
:actions="[ |
|||
{ |
|||
label: L('EditContents'), |
|||
icon: 'ant-design:edit-outlined', |
|||
onClick: handleEditContent.bind(null, record), |
|||
}, |
|||
]" |
|||
/> |
|||
</template> |
|||
</template> |
|||
</BasicTable> |
|||
<TemplateContentModal @register="registerModal" /> |
|||
</div> |
|||
</template> |
|||
|
|||
<script lang="ts" setup> |
|||
import { CheckOutlined, CloseOutlined } from '@ant-design/icons-vue'; |
|||
import { useModal } from '/@/components/Modal'; |
|||
import { BasicTable, TableAction, useTable } from '/@/components/Table'; |
|||
import { getDataColumns } from '../datas/TableData'; |
|||
import { useLocalization } from '/@/hooks/abp/useLocalization'; |
|||
import { getList } from '/@/api/text-templating/templates'; |
|||
import { TextTemplateDefinition } from '/@/api/text-templating/templates/model'; |
|||
import { formatPagedRequest } from '/@/utils/http/abp/helper'; |
|||
import TemplateContentModal from './TemplateContentModal.vue'; |
|||
|
|||
const { L } = useLocalization('AbpTextTemplating'); |
|||
|
|||
const [registerModal, { openModal }] = useModal(); |
|||
const [registerTable] = useTable({ |
|||
rowKey: 'id', |
|||
title: L('TextTemplates'), |
|||
columns: getDataColumns(), |
|||
api: getList, |
|||
beforeFetch: formatPagedRequest, |
|||
pagination: true, |
|||
striped: false, |
|||
useSearchForm: false, |
|||
showIndexColumn: false, |
|||
showTableSetting: true, |
|||
bordered: true, |
|||
canResize: true, |
|||
immediate: true, |
|||
actionColumn: { |
|||
width: 150, |
|||
title: L('Actions'), |
|||
dataIndex: 'action', |
|||
}, |
|||
}); |
|||
|
|||
function handleEditContent(record: TextTemplateDefinition) { |
|||
openModal(true, record); |
|||
} |
|||
</script> |
|||
@ -1,32 +1,30 @@ |
|||
import { useLocalization } from '/@/hooks/abp/useLocalization'; |
|||
import { FormProps } from '/@/components/Form'; |
|||
import { NotificationReadState } from '/@/api/messages/model/notificationsModel'; |
|||
import { FormProps, FormSchema } from '/@/components/Form'; |
|||
|
|||
const { L } = useLocalization(['AbpMessageService', 'AbpUi']); |
|||
const { L } = useLocalization(['AbpTextTemplating', 'AbpUi']); |
|||
|
|||
export function getSearchFormSchemas(): Partial<FormProps> { |
|||
return { |
|||
labelWidth: 100, |
|||
schemas: [ |
|||
{ |
|||
field: 'readState', |
|||
component: 'Select', |
|||
label: L('Notifications:State'), |
|||
colProps: { span: 8 }, |
|||
defaultValue: NotificationReadState.UnRead, |
|||
componentProps: { |
|||
options: [ |
|||
{ label: L('Read'), value: NotificationReadState.Read, }, |
|||
{ label: L('UnRead'), value: NotificationReadState.UnRead, }, |
|||
], |
|||
}, |
|||
}, |
|||
{ |
|||
field: 'filter', |
|||
component: 'Input', |
|||
label: L('Search'), |
|||
colProps: { span: 16 }, |
|||
colProps: { span: 24 }, |
|||
}, |
|||
], |
|||
}; |
|||
} |
|||
|
|||
export function getModalFormSchemas(): FormSchema[] { |
|||
return [ |
|||
{ |
|||
field: 'name', |
|||
component: 'Input', |
|||
label: L('DisplayName:Name'), |
|||
colProps: { span: 24 }, |
|||
required: true, |
|||
}, |
|||
]; |
|||
} |
|||
|
|||
@ -1,13 +1,13 @@ |
|||
<template> |
|||
<TemplateTable /> |
|||
<TemplateDefinitionTable /> |
|||
</template> |
|||
|
|||
<script lang="ts"> |
|||
import { defineComponent } from 'vue'; |
|||
import TemplateTable from './components/TemplateTable.vue'; |
|||
import TemplateDefinitionTable from './components/TemplateDefinitionTable.vue'; |
|||
|
|||
export default defineComponent({ |
|||
name: 'Templates', |
|||
components: { TemplateTable }, |
|||
name: 'TemplateDefinitions', |
|||
components: { TemplateDefinitionTable }, |
|||
}); |
|||
</script> |
|||
|
|||
@ -0,0 +1,578 @@ |
|||
// <auto-generated />
|
|||
using System; |
|||
using LY.MicroService.BackendAdmin.EntityFrameworkCore; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.EntityFrameworkCore.Infrastructure; |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
|
|||
#nullable disable |
|||
|
|||
namespace LY.MicroService.BackendAdmin.EntityFrameworkCore.Migrations |
|||
{ |
|||
[DbContext(typeof(BackendAdminMigrationsDbContext))] |
|||
[Migration("20230304062910_Add-Text-Template-Definition")] |
|||
partial class AddTextTemplateDefinition |
|||
{ |
|||
/// <inheritdoc />
|
|||
protected override void BuildTargetModel(ModelBuilder modelBuilder) |
|||
{ |
|||
#pragma warning disable 612, 618
|
|||
modelBuilder |
|||
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) |
|||
.HasAnnotation("ProductVersion", "7.0.2") |
|||
.HasAnnotation("Relational:MaxIdentifierLength", 64); |
|||
|
|||
modelBuilder.Entity("LINGYUN.Abp.Saas.Editions.Edition", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("ConcurrencyStamp") |
|||
.IsConcurrencyToken() |
|||
.HasMaxLength(40) |
|||
.HasColumnType("varchar(40)") |
|||
.HasColumnName("ConcurrencyStamp"); |
|||
|
|||
b.Property<DateTime>("CreationTime") |
|||
.HasColumnType("datetime(6)") |
|||
.HasColumnName("CreationTime"); |
|||
|
|||
b.Property<Guid?>("CreatorId") |
|||
.HasColumnType("char(36)") |
|||
.HasColumnName("CreatorId"); |
|||
|
|||
b.Property<Guid?>("DeleterId") |
|||
.HasColumnType("char(36)") |
|||
.HasColumnName("DeleterId"); |
|||
|
|||
b.Property<DateTime?>("DeletionTime") |
|||
.HasColumnType("datetime(6)") |
|||
.HasColumnName("DeletionTime"); |
|||
|
|||
b.Property<string>("DisplayName") |
|||
.IsRequired() |
|||
.HasMaxLength(64) |
|||
.HasColumnType("varchar(64)"); |
|||
|
|||
b.Property<string>("ExtraProperties") |
|||
.HasColumnType("longtext") |
|||
.HasColumnName("ExtraProperties"); |
|||
|
|||
b.Property<bool>("IsDeleted") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("tinyint(1)") |
|||
.HasDefaultValue(false) |
|||
.HasColumnName("IsDeleted"); |
|||
|
|||
b.Property<DateTime?>("LastModificationTime") |
|||
.HasColumnType("datetime(6)") |
|||
.HasColumnName("LastModificationTime"); |
|||
|
|||
b.Property<Guid?>("LastModifierId") |
|||
.HasColumnType("char(36)") |
|||
.HasColumnName("LastModifierId"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("DisplayName"); |
|||
|
|||
b.ToTable("AbpEditions", (string)null); |
|||
}); |
|||
|
|||
modelBuilder.Entity("LINGYUN.Abp.Saas.Tenants.Tenant", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("ConcurrencyStamp") |
|||
.IsConcurrencyToken() |
|||
.HasMaxLength(40) |
|||
.HasColumnType("varchar(40)") |
|||
.HasColumnName("ConcurrencyStamp"); |
|||
|
|||
b.Property<DateTime>("CreationTime") |
|||
.HasColumnType("datetime(6)") |
|||
.HasColumnName("CreationTime"); |
|||
|
|||
b.Property<Guid?>("CreatorId") |
|||
.HasColumnType("char(36)") |
|||
.HasColumnName("CreatorId"); |
|||
|
|||
b.Property<Guid?>("DeleterId") |
|||
.HasColumnType("char(36)") |
|||
.HasColumnName("DeleterId"); |
|||
|
|||
b.Property<DateTime?>("DeletionTime") |
|||
.HasColumnType("datetime(6)") |
|||
.HasColumnName("DeletionTime"); |
|||
|
|||
b.Property<DateTime?>("DisableTime") |
|||
.HasColumnType("datetime(6)"); |
|||
|
|||
b.Property<Guid?>("EditionId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<DateTime?>("EnableTime") |
|||
.HasColumnType("datetime(6)"); |
|||
|
|||
b.Property<string>("ExtraProperties") |
|||
.HasColumnType("longtext") |
|||
.HasColumnName("ExtraProperties"); |
|||
|
|||
b.Property<bool>("IsActive") |
|||
.HasColumnType("tinyint(1)"); |
|||
|
|||
b.Property<bool>("IsDeleted") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("tinyint(1)") |
|||
.HasDefaultValue(false) |
|||
.HasColumnName("IsDeleted"); |
|||
|
|||
b.Property<DateTime?>("LastModificationTime") |
|||
.HasColumnType("datetime(6)") |
|||
.HasColumnName("LastModificationTime"); |
|||
|
|||
b.Property<Guid?>("LastModifierId") |
|||
.HasColumnType("char(36)") |
|||
.HasColumnName("LastModifierId"); |
|||
|
|||
b.Property<string>("Name") |
|||
.IsRequired() |
|||
.HasMaxLength(64) |
|||
.HasColumnType("varchar(64)"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("EditionId"); |
|||
|
|||
b.HasIndex("Name"); |
|||
|
|||
b.ToTable("AbpTenants", (string)null); |
|||
}); |
|||
|
|||
modelBuilder.Entity("LINGYUN.Abp.Saas.Tenants.TenantConnectionString", b => |
|||
{ |
|||
b.Property<Guid>("TenantId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("Name") |
|||
.HasMaxLength(64) |
|||
.HasColumnType("varchar(64)"); |
|||
|
|||
b.Property<string>("Value") |
|||
.IsRequired() |
|||
.HasMaxLength(1024) |
|||
.HasColumnType("varchar(1024)"); |
|||
|
|||
b.HasKey("TenantId", "Name"); |
|||
|
|||
b.ToTable("AbpTenantConnectionStrings", (string)null); |
|||
}); |
|||
|
|||
modelBuilder.Entity("LINGYUN.Abp.TextTemplating.TextTemplate", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("Content") |
|||
.HasMaxLength(1048576) |
|||
.HasColumnType("longtext") |
|||
.HasColumnName("Content"); |
|||
|
|||
b.Property<DateTime>("CreationTime") |
|||
.HasColumnType("datetime(6)") |
|||
.HasColumnName("CreationTime"); |
|||
|
|||
b.Property<Guid?>("CreatorId") |
|||
.HasColumnType("char(36)") |
|||
.HasColumnName("CreatorId"); |
|||
|
|||
b.Property<string>("Culture") |
|||
.HasMaxLength(30) |
|||
.HasColumnType("varchar(30)") |
|||
.HasColumnName("Culture"); |
|||
|
|||
b.Property<string>("DisplayName") |
|||
.IsRequired() |
|||
.HasMaxLength(100) |
|||
.HasColumnType("varchar(100)") |
|||
.HasColumnName("DisplayName"); |
|||
|
|||
b.Property<DateTime?>("LastModificationTime") |
|||
.HasColumnType("datetime(6)") |
|||
.HasColumnName("LastModificationTime"); |
|||
|
|||
b.Property<Guid?>("LastModifierId") |
|||
.HasColumnType("char(36)") |
|||
.HasColumnName("LastModifierId"); |
|||
|
|||
b.Property<string>("Name") |
|||
.IsRequired() |
|||
.HasMaxLength(100) |
|||
.HasColumnType("varchar(100)") |
|||
.HasColumnName("Name"); |
|||
|
|||
b.Property<Guid?>("TenantId") |
|||
.HasColumnType("char(36)") |
|||
.HasColumnName("TenantId"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("TenantId", "Name") |
|||
.HasDatabaseName("IX_Tenant_Text_Template_Name"); |
|||
|
|||
b.ToTable("AbpTextTemplates", (string)null); |
|||
}); |
|||
|
|||
modelBuilder.Entity("LINGYUN.Abp.TextTemplating.TextTemplateDefinition", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("ConcurrencyStamp") |
|||
.IsConcurrencyToken() |
|||
.HasMaxLength(40) |
|||
.HasColumnType("varchar(40)") |
|||
.HasColumnName("ConcurrencyStamp"); |
|||
|
|||
b.Property<string>("DefaultCultureName") |
|||
.HasMaxLength(30) |
|||
.HasColumnType("varchar(30)") |
|||
.HasColumnName("DefaultCultureName"); |
|||
|
|||
b.Property<string>("DisplayName") |
|||
.IsRequired() |
|||
.HasMaxLength(512) |
|||
.HasColumnType("varchar(512)") |
|||
.HasColumnName("DisplayName"); |
|||
|
|||
b.Property<string>("ExtraProperties") |
|||
.HasColumnType("longtext") |
|||
.HasColumnName("ExtraProperties"); |
|||
|
|||
b.Property<bool>("IsInlineLocalized") |
|||
.HasColumnType("tinyint(1)"); |
|||
|
|||
b.Property<bool>("IsLayout") |
|||
.HasColumnType("tinyint(1)"); |
|||
|
|||
b.Property<string>("Layout") |
|||
.HasMaxLength(60) |
|||
.HasColumnType("varchar(60)") |
|||
.HasColumnName("Layout"); |
|||
|
|||
b.Property<string>("Name") |
|||
.IsRequired() |
|||
.HasMaxLength(128) |
|||
.HasColumnType("varchar(128)") |
|||
.HasColumnName("Name"); |
|||
|
|||
b.Property<string>("RenderEngine") |
|||
.HasMaxLength(30) |
|||
.HasColumnType("varchar(30)") |
|||
.HasColumnName("RenderEngine"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.ToTable("AbpTextTemplateDefinitions", (string)null); |
|||
}); |
|||
|
|||
modelBuilder.Entity("Volo.Abp.FeatureManagement.FeatureDefinitionRecord", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("AllowedProviders") |
|||
.HasMaxLength(256) |
|||
.HasColumnType("varchar(256)"); |
|||
|
|||
b.Property<string>("DefaultValue") |
|||
.HasMaxLength(256) |
|||
.HasColumnType("varchar(256)"); |
|||
|
|||
b.Property<string>("Description") |
|||
.HasMaxLength(256) |
|||
.HasColumnType("varchar(256)"); |
|||
|
|||
b.Property<string>("DisplayName") |
|||
.IsRequired() |
|||
.HasMaxLength(256) |
|||
.HasColumnType("varchar(256)"); |
|||
|
|||
b.Property<string>("ExtraProperties") |
|||
.HasColumnType("longtext") |
|||
.HasColumnName("ExtraProperties"); |
|||
|
|||
b.Property<string>("GroupName") |
|||
.IsRequired() |
|||
.HasMaxLength(128) |
|||
.HasColumnType("varchar(128)"); |
|||
|
|||
b.Property<bool>("IsAvailableToHost") |
|||
.HasColumnType("tinyint(1)"); |
|||
|
|||
b.Property<bool>("IsVisibleToClients") |
|||
.HasColumnType("tinyint(1)"); |
|||
|
|||
b.Property<string>("Name") |
|||
.IsRequired() |
|||
.HasMaxLength(128) |
|||
.HasColumnType("varchar(128)"); |
|||
|
|||
b.Property<string>("ParentName") |
|||
.HasMaxLength(128) |
|||
.HasColumnType("varchar(128)"); |
|||
|
|||
b.Property<string>("ValueType") |
|||
.HasMaxLength(2048) |
|||
.HasColumnType("varchar(2048)"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("GroupName"); |
|||
|
|||
b.HasIndex("Name") |
|||
.IsUnique(); |
|||
|
|||
b.ToTable("AbpFeatures", (string)null); |
|||
}); |
|||
|
|||
modelBuilder.Entity("Volo.Abp.FeatureManagement.FeatureGroupDefinitionRecord", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("DisplayName") |
|||
.IsRequired() |
|||
.HasMaxLength(256) |
|||
.HasColumnType("varchar(256)"); |
|||
|
|||
b.Property<string>("ExtraProperties") |
|||
.HasColumnType("longtext") |
|||
.HasColumnName("ExtraProperties"); |
|||
|
|||
b.Property<string>("Name") |
|||
.IsRequired() |
|||
.HasMaxLength(128) |
|||
.HasColumnType("varchar(128)"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("Name") |
|||
.IsUnique(); |
|||
|
|||
b.ToTable("AbpFeatureGroups", (string)null); |
|||
}); |
|||
|
|||
modelBuilder.Entity("Volo.Abp.FeatureManagement.FeatureValue", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("Name") |
|||
.IsRequired() |
|||
.HasMaxLength(128) |
|||
.HasColumnType("varchar(128)"); |
|||
|
|||
b.Property<string>("ProviderKey") |
|||
.HasMaxLength(64) |
|||
.HasColumnType("varchar(64)"); |
|||
|
|||
b.Property<string>("ProviderName") |
|||
.HasMaxLength(64) |
|||
.HasColumnType("varchar(64)"); |
|||
|
|||
b.Property<string>("Value") |
|||
.IsRequired() |
|||
.HasMaxLength(128) |
|||
.HasColumnType("varchar(128)"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("Name", "ProviderName", "ProviderKey") |
|||
.IsUnique(); |
|||
|
|||
b.ToTable("AbpFeatureValues", (string)null); |
|||
}); |
|||
|
|||
modelBuilder.Entity("Volo.Abp.PermissionManagement.PermissionDefinitionRecord", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("DisplayName") |
|||
.IsRequired() |
|||
.HasMaxLength(256) |
|||
.HasColumnType("varchar(256)"); |
|||
|
|||
b.Property<string>("ExtraProperties") |
|||
.HasColumnType("longtext") |
|||
.HasColumnName("ExtraProperties"); |
|||
|
|||
b.Property<string>("GroupName") |
|||
.IsRequired() |
|||
.HasMaxLength(128) |
|||
.HasColumnType("varchar(128)"); |
|||
|
|||
b.Property<bool>("IsEnabled") |
|||
.HasColumnType("tinyint(1)"); |
|||
|
|||
b.Property<byte>("MultiTenancySide") |
|||
.HasColumnType("tinyint unsigned"); |
|||
|
|||
b.Property<string>("Name") |
|||
.IsRequired() |
|||
.HasMaxLength(128) |
|||
.HasColumnType("varchar(128)"); |
|||
|
|||
b.Property<string>("ParentName") |
|||
.HasMaxLength(128) |
|||
.HasColumnType("varchar(128)"); |
|||
|
|||
b.Property<string>("Providers") |
|||
.HasMaxLength(128) |
|||
.HasColumnType("varchar(128)"); |
|||
|
|||
b.Property<string>("StateCheckers") |
|||
.HasMaxLength(256) |
|||
.HasColumnType("varchar(256)"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("GroupName"); |
|||
|
|||
b.HasIndex("Name") |
|||
.IsUnique(); |
|||
|
|||
b.ToTable("AbpPermissions", (string)null); |
|||
}); |
|||
|
|||
modelBuilder.Entity("Volo.Abp.PermissionManagement.PermissionGrant", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("Name") |
|||
.IsRequired() |
|||
.HasMaxLength(128) |
|||
.HasColumnType("varchar(128)"); |
|||
|
|||
b.Property<string>("ProviderKey") |
|||
.IsRequired() |
|||
.HasMaxLength(64) |
|||
.HasColumnType("varchar(64)"); |
|||
|
|||
b.Property<string>("ProviderName") |
|||
.IsRequired() |
|||
.HasMaxLength(64) |
|||
.HasColumnType("varchar(64)"); |
|||
|
|||
b.Property<Guid?>("TenantId") |
|||
.HasColumnType("char(36)") |
|||
.HasColumnName("TenantId"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("TenantId", "Name", "ProviderName", "ProviderKey") |
|||
.IsUnique(); |
|||
|
|||
b.ToTable("AbpPermissionGrants", (string)null); |
|||
}); |
|||
|
|||
modelBuilder.Entity("Volo.Abp.PermissionManagement.PermissionGroupDefinitionRecord", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("DisplayName") |
|||
.IsRequired() |
|||
.HasMaxLength(256) |
|||
.HasColumnType("varchar(256)"); |
|||
|
|||
b.Property<string>("ExtraProperties") |
|||
.HasColumnType("longtext") |
|||
.HasColumnName("ExtraProperties"); |
|||
|
|||
b.Property<string>("Name") |
|||
.IsRequired() |
|||
.HasMaxLength(128) |
|||
.HasColumnType("varchar(128)"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("Name") |
|||
.IsUnique(); |
|||
|
|||
b.ToTable("AbpPermissionGroups", (string)null); |
|||
}); |
|||
|
|||
modelBuilder.Entity("Volo.Abp.SettingManagement.Setting", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("Name") |
|||
.IsRequired() |
|||
.HasMaxLength(128) |
|||
.HasColumnType("varchar(128)"); |
|||
|
|||
b.Property<string>("ProviderKey") |
|||
.HasMaxLength(64) |
|||
.HasColumnType("varchar(64)"); |
|||
|
|||
b.Property<string>("ProviderName") |
|||
.HasMaxLength(64) |
|||
.HasColumnType("varchar(64)"); |
|||
|
|||
b.Property<string>("Value") |
|||
.IsRequired() |
|||
.HasMaxLength(2048) |
|||
.HasColumnType("varchar(2048)"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("Name", "ProviderName", "ProviderKey") |
|||
.IsUnique(); |
|||
|
|||
b.ToTable("AbpSettings", (string)null); |
|||
}); |
|||
|
|||
modelBuilder.Entity("LINGYUN.Abp.Saas.Tenants.Tenant", b => |
|||
{ |
|||
b.HasOne("LINGYUN.Abp.Saas.Editions.Edition", "Edition") |
|||
.WithMany() |
|||
.HasForeignKey("EditionId"); |
|||
|
|||
b.Navigation("Edition"); |
|||
}); |
|||
|
|||
modelBuilder.Entity("LINGYUN.Abp.Saas.Tenants.TenantConnectionString", b => |
|||
{ |
|||
b.HasOne("LINGYUN.Abp.Saas.Tenants.Tenant", null) |
|||
.WithMany("ConnectionStrings") |
|||
.HasForeignKey("TenantId") |
|||
.OnDelete(DeleteBehavior.Cascade) |
|||
.IsRequired(); |
|||
}); |
|||
|
|||
modelBuilder.Entity("LINGYUN.Abp.Saas.Tenants.Tenant", b => |
|||
{ |
|||
b.Navigation("ConnectionStrings"); |
|||
}); |
|||
#pragma warning restore 612, 618
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,50 @@ |
|||
using System; |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
|
|||
#nullable disable |
|||
|
|||
namespace LY.MicroService.BackendAdmin.EntityFrameworkCore.Migrations |
|||
{ |
|||
/// <inheritdoc />
|
|||
public partial class AddTextTemplateDefinition : Migration |
|||
{ |
|||
/// <inheritdoc />
|
|||
protected override void Up(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.CreateTable( |
|||
name: "AbpTextTemplateDefinitions", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
|||
Name = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false) |
|||
.Annotation("MySql:CharSet", "utf8mb4"), |
|||
DisplayName = table.Column<string>(type: "varchar(512)", maxLength: 512, nullable: false) |
|||
.Annotation("MySql:CharSet", "utf8mb4"), |
|||
IsLayout = table.Column<bool>(type: "tinyint(1)", nullable: false), |
|||
Layout = table.Column<string>(type: "varchar(60)", maxLength: 60, nullable: true) |
|||
.Annotation("MySql:CharSet", "utf8mb4"), |
|||
IsInlineLocalized = table.Column<bool>(type: "tinyint(1)", nullable: false), |
|||
DefaultCultureName = table.Column<string>(type: "varchar(30)", maxLength: 30, nullable: true) |
|||
.Annotation("MySql:CharSet", "utf8mb4"), |
|||
RenderEngine = table.Column<string>(type: "varchar(30)", maxLength: 30, nullable: true) |
|||
.Annotation("MySql:CharSet", "utf8mb4"), |
|||
ExtraProperties = table.Column<string>(type: "longtext", nullable: true) |
|||
.Annotation("MySql:CharSet", "utf8mb4"), |
|||
ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: true) |
|||
.Annotation("MySql:CharSet", "utf8mb4") |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AbpTextTemplateDefinitions", x => x.Id); |
|||
}) |
|||
.Annotation("MySql:CharSet", "utf8mb4"); |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
protected override void Down(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.DropTable( |
|||
name: "AbpTextTemplateDefinitions"); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,581 @@ |
|||
// <auto-generated />
|
|||
using System; |
|||
using LY.MicroService.BackendAdmin.EntityFrameworkCore; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.EntityFrameworkCore.Infrastructure; |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
|
|||
#nullable disable |
|||
|
|||
namespace LY.MicroService.BackendAdmin.EntityFrameworkCore.Migrations |
|||
{ |
|||
[DbContext(typeof(BackendAdminMigrationsDbContext))] |
|||
[Migration("20230304083526_Add-IsStatic-Field")] |
|||
partial class AddIsStaticField |
|||
{ |
|||
/// <inheritdoc />
|
|||
protected override void BuildTargetModel(ModelBuilder modelBuilder) |
|||
{ |
|||
#pragma warning disable 612, 618
|
|||
modelBuilder |
|||
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) |
|||
.HasAnnotation("ProductVersion", "7.0.2") |
|||
.HasAnnotation("Relational:MaxIdentifierLength", 64); |
|||
|
|||
modelBuilder.Entity("LINGYUN.Abp.Saas.Editions.Edition", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("ConcurrencyStamp") |
|||
.IsConcurrencyToken() |
|||
.HasMaxLength(40) |
|||
.HasColumnType("varchar(40)") |
|||
.HasColumnName("ConcurrencyStamp"); |
|||
|
|||
b.Property<DateTime>("CreationTime") |
|||
.HasColumnType("datetime(6)") |
|||
.HasColumnName("CreationTime"); |
|||
|
|||
b.Property<Guid?>("CreatorId") |
|||
.HasColumnType("char(36)") |
|||
.HasColumnName("CreatorId"); |
|||
|
|||
b.Property<Guid?>("DeleterId") |
|||
.HasColumnType("char(36)") |
|||
.HasColumnName("DeleterId"); |
|||
|
|||
b.Property<DateTime?>("DeletionTime") |
|||
.HasColumnType("datetime(6)") |
|||
.HasColumnName("DeletionTime"); |
|||
|
|||
b.Property<string>("DisplayName") |
|||
.IsRequired() |
|||
.HasMaxLength(64) |
|||
.HasColumnType("varchar(64)"); |
|||
|
|||
b.Property<string>("ExtraProperties") |
|||
.HasColumnType("longtext") |
|||
.HasColumnName("ExtraProperties"); |
|||
|
|||
b.Property<bool>("IsDeleted") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("tinyint(1)") |
|||
.HasDefaultValue(false) |
|||
.HasColumnName("IsDeleted"); |
|||
|
|||
b.Property<DateTime?>("LastModificationTime") |
|||
.HasColumnType("datetime(6)") |
|||
.HasColumnName("LastModificationTime"); |
|||
|
|||
b.Property<Guid?>("LastModifierId") |
|||
.HasColumnType("char(36)") |
|||
.HasColumnName("LastModifierId"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("DisplayName"); |
|||
|
|||
b.ToTable("AbpEditions", (string)null); |
|||
}); |
|||
|
|||
modelBuilder.Entity("LINGYUN.Abp.Saas.Tenants.Tenant", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("ConcurrencyStamp") |
|||
.IsConcurrencyToken() |
|||
.HasMaxLength(40) |
|||
.HasColumnType("varchar(40)") |
|||
.HasColumnName("ConcurrencyStamp"); |
|||
|
|||
b.Property<DateTime>("CreationTime") |
|||
.HasColumnType("datetime(6)") |
|||
.HasColumnName("CreationTime"); |
|||
|
|||
b.Property<Guid?>("CreatorId") |
|||
.HasColumnType("char(36)") |
|||
.HasColumnName("CreatorId"); |
|||
|
|||
b.Property<Guid?>("DeleterId") |
|||
.HasColumnType("char(36)") |
|||
.HasColumnName("DeleterId"); |
|||
|
|||
b.Property<DateTime?>("DeletionTime") |
|||
.HasColumnType("datetime(6)") |
|||
.HasColumnName("DeletionTime"); |
|||
|
|||
b.Property<DateTime?>("DisableTime") |
|||
.HasColumnType("datetime(6)"); |
|||
|
|||
b.Property<Guid?>("EditionId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<DateTime?>("EnableTime") |
|||
.HasColumnType("datetime(6)"); |
|||
|
|||
b.Property<string>("ExtraProperties") |
|||
.HasColumnType("longtext") |
|||
.HasColumnName("ExtraProperties"); |
|||
|
|||
b.Property<bool>("IsActive") |
|||
.HasColumnType("tinyint(1)"); |
|||
|
|||
b.Property<bool>("IsDeleted") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("tinyint(1)") |
|||
.HasDefaultValue(false) |
|||
.HasColumnName("IsDeleted"); |
|||
|
|||
b.Property<DateTime?>("LastModificationTime") |
|||
.HasColumnType("datetime(6)") |
|||
.HasColumnName("LastModificationTime"); |
|||
|
|||
b.Property<Guid?>("LastModifierId") |
|||
.HasColumnType("char(36)") |
|||
.HasColumnName("LastModifierId"); |
|||
|
|||
b.Property<string>("Name") |
|||
.IsRequired() |
|||
.HasMaxLength(64) |
|||
.HasColumnType("varchar(64)"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("EditionId"); |
|||
|
|||
b.HasIndex("Name"); |
|||
|
|||
b.ToTable("AbpTenants", (string)null); |
|||
}); |
|||
|
|||
modelBuilder.Entity("LINGYUN.Abp.Saas.Tenants.TenantConnectionString", b => |
|||
{ |
|||
b.Property<Guid>("TenantId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("Name") |
|||
.HasMaxLength(64) |
|||
.HasColumnType("varchar(64)"); |
|||
|
|||
b.Property<string>("Value") |
|||
.IsRequired() |
|||
.HasMaxLength(1024) |
|||
.HasColumnType("varchar(1024)"); |
|||
|
|||
b.HasKey("TenantId", "Name"); |
|||
|
|||
b.ToTable("AbpTenantConnectionStrings", (string)null); |
|||
}); |
|||
|
|||
modelBuilder.Entity("LINGYUN.Abp.TextTemplating.TextTemplate", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("Content") |
|||
.HasMaxLength(1048576) |
|||
.HasColumnType("longtext") |
|||
.HasColumnName("Content"); |
|||
|
|||
b.Property<DateTime>("CreationTime") |
|||
.HasColumnType("datetime(6)") |
|||
.HasColumnName("CreationTime"); |
|||
|
|||
b.Property<Guid?>("CreatorId") |
|||
.HasColumnType("char(36)") |
|||
.HasColumnName("CreatorId"); |
|||
|
|||
b.Property<string>("Culture") |
|||
.HasMaxLength(30) |
|||
.HasColumnType("varchar(30)") |
|||
.HasColumnName("Culture"); |
|||
|
|||
b.Property<string>("DisplayName") |
|||
.IsRequired() |
|||
.HasMaxLength(100) |
|||
.HasColumnType("varchar(100)") |
|||
.HasColumnName("DisplayName"); |
|||
|
|||
b.Property<DateTime?>("LastModificationTime") |
|||
.HasColumnType("datetime(6)") |
|||
.HasColumnName("LastModificationTime"); |
|||
|
|||
b.Property<Guid?>("LastModifierId") |
|||
.HasColumnType("char(36)") |
|||
.HasColumnName("LastModifierId"); |
|||
|
|||
b.Property<string>("Name") |
|||
.IsRequired() |
|||
.HasMaxLength(100) |
|||
.HasColumnType("varchar(100)") |
|||
.HasColumnName("Name"); |
|||
|
|||
b.Property<Guid?>("TenantId") |
|||
.HasColumnType("char(36)") |
|||
.HasColumnName("TenantId"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("TenantId", "Name") |
|||
.HasDatabaseName("IX_Tenant_Text_Template_Name"); |
|||
|
|||
b.ToTable("AbpTextTemplates", (string)null); |
|||
}); |
|||
|
|||
modelBuilder.Entity("LINGYUN.Abp.TextTemplating.TextTemplateDefinition", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("ConcurrencyStamp") |
|||
.IsConcurrencyToken() |
|||
.HasMaxLength(40) |
|||
.HasColumnType("varchar(40)") |
|||
.HasColumnName("ConcurrencyStamp"); |
|||
|
|||
b.Property<string>("DefaultCultureName") |
|||
.HasMaxLength(30) |
|||
.HasColumnType("varchar(30)") |
|||
.HasColumnName("DefaultCultureName"); |
|||
|
|||
b.Property<string>("DisplayName") |
|||
.IsRequired() |
|||
.HasMaxLength(512) |
|||
.HasColumnType("varchar(512)") |
|||
.HasColumnName("DisplayName"); |
|||
|
|||
b.Property<string>("ExtraProperties") |
|||
.HasColumnType("longtext") |
|||
.HasColumnName("ExtraProperties"); |
|||
|
|||
b.Property<bool>("IsInlineLocalized") |
|||
.HasColumnType("tinyint(1)"); |
|||
|
|||
b.Property<bool>("IsLayout") |
|||
.HasColumnType("tinyint(1)"); |
|||
|
|||
b.Property<bool>("IsStatic") |
|||
.HasColumnType("tinyint(1)"); |
|||
|
|||
b.Property<string>("Layout") |
|||
.HasMaxLength(60) |
|||
.HasColumnType("varchar(60)") |
|||
.HasColumnName("Layout"); |
|||
|
|||
b.Property<string>("Name") |
|||
.IsRequired() |
|||
.HasMaxLength(128) |
|||
.HasColumnType("varchar(128)") |
|||
.HasColumnName("Name"); |
|||
|
|||
b.Property<string>("RenderEngine") |
|||
.HasMaxLength(30) |
|||
.HasColumnType("varchar(30)") |
|||
.HasColumnName("RenderEngine"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.ToTable("AbpTextTemplateDefinitions", (string)null); |
|||
}); |
|||
|
|||
modelBuilder.Entity("Volo.Abp.FeatureManagement.FeatureDefinitionRecord", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("AllowedProviders") |
|||
.HasMaxLength(256) |
|||
.HasColumnType("varchar(256)"); |
|||
|
|||
b.Property<string>("DefaultValue") |
|||
.HasMaxLength(256) |
|||
.HasColumnType("varchar(256)"); |
|||
|
|||
b.Property<string>("Description") |
|||
.HasMaxLength(256) |
|||
.HasColumnType("varchar(256)"); |
|||
|
|||
b.Property<string>("DisplayName") |
|||
.IsRequired() |
|||
.HasMaxLength(256) |
|||
.HasColumnType("varchar(256)"); |
|||
|
|||
b.Property<string>("ExtraProperties") |
|||
.HasColumnType("longtext") |
|||
.HasColumnName("ExtraProperties"); |
|||
|
|||
b.Property<string>("GroupName") |
|||
.IsRequired() |
|||
.HasMaxLength(128) |
|||
.HasColumnType("varchar(128)"); |
|||
|
|||
b.Property<bool>("IsAvailableToHost") |
|||
.HasColumnType("tinyint(1)"); |
|||
|
|||
b.Property<bool>("IsVisibleToClients") |
|||
.HasColumnType("tinyint(1)"); |
|||
|
|||
b.Property<string>("Name") |
|||
.IsRequired() |
|||
.HasMaxLength(128) |
|||
.HasColumnType("varchar(128)"); |
|||
|
|||
b.Property<string>("ParentName") |
|||
.HasMaxLength(128) |
|||
.HasColumnType("varchar(128)"); |
|||
|
|||
b.Property<string>("ValueType") |
|||
.HasMaxLength(2048) |
|||
.HasColumnType("varchar(2048)"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("GroupName"); |
|||
|
|||
b.HasIndex("Name") |
|||
.IsUnique(); |
|||
|
|||
b.ToTable("AbpFeatures", (string)null); |
|||
}); |
|||
|
|||
modelBuilder.Entity("Volo.Abp.FeatureManagement.FeatureGroupDefinitionRecord", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("DisplayName") |
|||
.IsRequired() |
|||
.HasMaxLength(256) |
|||
.HasColumnType("varchar(256)"); |
|||
|
|||
b.Property<string>("ExtraProperties") |
|||
.HasColumnType("longtext") |
|||
.HasColumnName("ExtraProperties"); |
|||
|
|||
b.Property<string>("Name") |
|||
.IsRequired() |
|||
.HasMaxLength(128) |
|||
.HasColumnType("varchar(128)"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("Name") |
|||
.IsUnique(); |
|||
|
|||
b.ToTable("AbpFeatureGroups", (string)null); |
|||
}); |
|||
|
|||
modelBuilder.Entity("Volo.Abp.FeatureManagement.FeatureValue", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("Name") |
|||
.IsRequired() |
|||
.HasMaxLength(128) |
|||
.HasColumnType("varchar(128)"); |
|||
|
|||
b.Property<string>("ProviderKey") |
|||
.HasMaxLength(64) |
|||
.HasColumnType("varchar(64)"); |
|||
|
|||
b.Property<string>("ProviderName") |
|||
.HasMaxLength(64) |
|||
.HasColumnType("varchar(64)"); |
|||
|
|||
b.Property<string>("Value") |
|||
.IsRequired() |
|||
.HasMaxLength(128) |
|||
.HasColumnType("varchar(128)"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("Name", "ProviderName", "ProviderKey") |
|||
.IsUnique(); |
|||
|
|||
b.ToTable("AbpFeatureValues", (string)null); |
|||
}); |
|||
|
|||
modelBuilder.Entity("Volo.Abp.PermissionManagement.PermissionDefinitionRecord", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("DisplayName") |
|||
.IsRequired() |
|||
.HasMaxLength(256) |
|||
.HasColumnType("varchar(256)"); |
|||
|
|||
b.Property<string>("ExtraProperties") |
|||
.HasColumnType("longtext") |
|||
.HasColumnName("ExtraProperties"); |
|||
|
|||
b.Property<string>("GroupName") |
|||
.IsRequired() |
|||
.HasMaxLength(128) |
|||
.HasColumnType("varchar(128)"); |
|||
|
|||
b.Property<bool>("IsEnabled") |
|||
.HasColumnType("tinyint(1)"); |
|||
|
|||
b.Property<byte>("MultiTenancySide") |
|||
.HasColumnType("tinyint unsigned"); |
|||
|
|||
b.Property<string>("Name") |
|||
.IsRequired() |
|||
.HasMaxLength(128) |
|||
.HasColumnType("varchar(128)"); |
|||
|
|||
b.Property<string>("ParentName") |
|||
.HasMaxLength(128) |
|||
.HasColumnType("varchar(128)"); |
|||
|
|||
b.Property<string>("Providers") |
|||
.HasMaxLength(128) |
|||
.HasColumnType("varchar(128)"); |
|||
|
|||
b.Property<string>("StateCheckers") |
|||
.HasMaxLength(256) |
|||
.HasColumnType("varchar(256)"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("GroupName"); |
|||
|
|||
b.HasIndex("Name") |
|||
.IsUnique(); |
|||
|
|||
b.ToTable("AbpPermissions", (string)null); |
|||
}); |
|||
|
|||
modelBuilder.Entity("Volo.Abp.PermissionManagement.PermissionGrant", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("Name") |
|||
.IsRequired() |
|||
.HasMaxLength(128) |
|||
.HasColumnType("varchar(128)"); |
|||
|
|||
b.Property<string>("ProviderKey") |
|||
.IsRequired() |
|||
.HasMaxLength(64) |
|||
.HasColumnType("varchar(64)"); |
|||
|
|||
b.Property<string>("ProviderName") |
|||
.IsRequired() |
|||
.HasMaxLength(64) |
|||
.HasColumnType("varchar(64)"); |
|||
|
|||
b.Property<Guid?>("TenantId") |
|||
.HasColumnType("char(36)") |
|||
.HasColumnName("TenantId"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("TenantId", "Name", "ProviderName", "ProviderKey") |
|||
.IsUnique(); |
|||
|
|||
b.ToTable("AbpPermissionGrants", (string)null); |
|||
}); |
|||
|
|||
modelBuilder.Entity("Volo.Abp.PermissionManagement.PermissionGroupDefinitionRecord", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("DisplayName") |
|||
.IsRequired() |
|||
.HasMaxLength(256) |
|||
.HasColumnType("varchar(256)"); |
|||
|
|||
b.Property<string>("ExtraProperties") |
|||
.HasColumnType("longtext") |
|||
.HasColumnName("ExtraProperties"); |
|||
|
|||
b.Property<string>("Name") |
|||
.IsRequired() |
|||
.HasMaxLength(128) |
|||
.HasColumnType("varchar(128)"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("Name") |
|||
.IsUnique(); |
|||
|
|||
b.ToTable("AbpPermissionGroups", (string)null); |
|||
}); |
|||
|
|||
modelBuilder.Entity("Volo.Abp.SettingManagement.Setting", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("Name") |
|||
.IsRequired() |
|||
.HasMaxLength(128) |
|||
.HasColumnType("varchar(128)"); |
|||
|
|||
b.Property<string>("ProviderKey") |
|||
.HasMaxLength(64) |
|||
.HasColumnType("varchar(64)"); |
|||
|
|||
b.Property<string>("ProviderName") |
|||
.HasMaxLength(64) |
|||
.HasColumnType("varchar(64)"); |
|||
|
|||
b.Property<string>("Value") |
|||
.IsRequired() |
|||
.HasMaxLength(2048) |
|||
.HasColumnType("varchar(2048)"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("Name", "ProviderName", "ProviderKey") |
|||
.IsUnique(); |
|||
|
|||
b.ToTable("AbpSettings", (string)null); |
|||
}); |
|||
|
|||
modelBuilder.Entity("LINGYUN.Abp.Saas.Tenants.Tenant", b => |
|||
{ |
|||
b.HasOne("LINGYUN.Abp.Saas.Editions.Edition", "Edition") |
|||
.WithMany() |
|||
.HasForeignKey("EditionId"); |
|||
|
|||
b.Navigation("Edition"); |
|||
}); |
|||
|
|||
modelBuilder.Entity("LINGYUN.Abp.Saas.Tenants.TenantConnectionString", b => |
|||
{ |
|||
b.HasOne("LINGYUN.Abp.Saas.Tenants.Tenant", null) |
|||
.WithMany("ConnectionStrings") |
|||
.HasForeignKey("TenantId") |
|||
.OnDelete(DeleteBehavior.Cascade) |
|||
.IsRequired(); |
|||
}); |
|||
|
|||
modelBuilder.Entity("LINGYUN.Abp.Saas.Tenants.Tenant", b => |
|||
{ |
|||
b.Navigation("ConnectionStrings"); |
|||
}); |
|||
#pragma warning restore 612, 618
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
|
|||
#nullable disable |
|||
|
|||
namespace LY.MicroService.BackendAdmin.EntityFrameworkCore.Migrations |
|||
{ |
|||
/// <inheritdoc />
|
|||
public partial class AddIsStaticField : Migration |
|||
{ |
|||
/// <inheritdoc />
|
|||
protected override void Up(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.AddColumn<bool>( |
|||
name: "IsStatic", |
|||
table: "AbpTextTemplateDefinitions", |
|||
type: "tinyint(1)", |
|||
nullable: false, |
|||
defaultValue: false); |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
protected override void Down(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.DropColumn( |
|||
name: "IsStatic", |
|||
table: "AbpTextTemplateDefinitions"); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,30 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
|||
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> |
|||
<xs:element name="Weavers"> |
|||
<xs:complexType> |
|||
<xs:all> |
|||
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1"> |
|||
<xs:complexType> |
|||
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" /> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:all> |
|||
<xs:attribute name="VerifyAssembly" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="VerifyIgnoreCodes" type="xs:string"> |
|||
<xs:annotation> |
|||
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="GenerateXsd" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:schema> |
|||
@ -0,0 +1,30 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
|||
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> |
|||
<xs:element name="Weavers"> |
|||
<xs:complexType> |
|||
<xs:all> |
|||
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1"> |
|||
<xs:complexType> |
|||
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" /> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:all> |
|||
<xs:attribute name="VerifyAssembly" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="VerifyIgnoreCodes" type="xs:string"> |
|||
<xs:annotation> |
|||
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="GenerateXsd" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:schema> |
|||
@ -0,0 +1,30 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
|||
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> |
|||
<xs:element name="Weavers"> |
|||
<xs:complexType> |
|||
<xs:all> |
|||
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1"> |
|||
<xs:complexType> |
|||
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" /> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:all> |
|||
<xs:attribute name="VerifyAssembly" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="VerifyIgnoreCodes" type="xs:string"> |
|||
<xs:annotation> |
|||
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="GenerateXsd" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:schema> |
|||
@ -0,0 +1,93 @@ |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Hosting; |
|||
using Microsoft.Extensions.Logging; |
|||
using Microsoft.Extensions.Options; |
|||
using System; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Threading; |
|||
using Volo.Abp.Uow; |
|||
|
|||
namespace LINGYUN.Abp.Notifications; |
|||
public class NotificationDefinitionInitializer : ITransientDependency |
|||
{ |
|||
protected IRootServiceProvider RootServiceProvider { get; } |
|||
protected ICancellationTokenProvider CancellationTokenProvider { get; } |
|||
protected AbpNotificationsManagementOptions NotificationsManagementOptions { get; } |
|||
public NotificationDefinitionInitializer( |
|||
IRootServiceProvider rootServiceProvider, |
|||
ICancellationTokenProvider cancellationTokenProvider, |
|||
IOptions<AbpNotificationsManagementOptions> notificationsManagementOptions) |
|||
{ |
|||
RootServiceProvider = rootServiceProvider; |
|||
CancellationTokenProvider = cancellationTokenProvider; |
|||
NotificationsManagementOptions = notificationsManagementOptions.Value; |
|||
} |
|||
|
|||
[UnitOfWork] |
|||
public async virtual Task InitializeDynamicNotifications(CancellationToken cancellationToken) |
|||
{ |
|||
if (!NotificationsManagementOptions.SaveStaticNotificationsToDatabase && !NotificationsManagementOptions.IsDynamicNotificationsStoreEnabled) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
using var scope = RootServiceProvider.CreateScope(); |
|||
var applicationLifetime = scope.ServiceProvider.GetService<IHostApplicationLifetime>(); |
|||
var token = applicationLifetime?.ApplicationStopping ?? cancellationToken; |
|||
try |
|||
{ |
|||
using (CancellationTokenProvider.Use(cancellationToken)) |
|||
{ |
|||
if (CancellationTokenProvider.Token.IsCancellationRequested) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
await SaveStaticNotificationsToDatabaseAsync(scope); |
|||
|
|||
if (CancellationTokenProvider.Token.IsCancellationRequested) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
await PreCacheDynamicNotificationsAsync(scope); |
|||
} |
|||
} |
|||
catch (OperationCanceledException) |
|||
{ |
|||
// ignore
|
|||
} |
|||
catch(Exception ex) |
|||
{ |
|||
scope.ServiceProvider |
|||
.GetService<ILogger<NotificationDefinitionInitializer>>()? |
|||
.LogException(ex); |
|||
} |
|||
} |
|||
|
|||
private async Task SaveStaticNotificationsToDatabaseAsync(IServiceScope serviceScope) |
|||
{ |
|||
if (!NotificationsManagementOptions.SaveStaticNotificationsToDatabase) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
var saver = serviceScope.ServiceProvider.GetRequiredService<IStaticNotificationSaver>(); |
|||
|
|||
await saver.SaveAsync(); |
|||
} |
|||
|
|||
private async Task PreCacheDynamicNotificationsAsync(IServiceScope serviceScope) |
|||
{ |
|||
if (!NotificationsManagementOptions.IsDynamicNotificationsStoreEnabled) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
var store = serviceScope.ServiceProvider.GetRequiredService<IDynamicNotificationDefinitionStore>(); |
|||
|
|||
await store.GetGroupsAsync(); |
|||
} |
|||
} |
|||
@ -1,39 +0,0 @@ |
|||
using AutoMapper; |
|||
using System; |
|||
using Volo.Abp; |
|||
using Volo.Abp.DependencyInjection; |
|||
|
|||
namespace LINGYUN.Abp.Notifications |
|||
{ |
|||
public class NotificationTypeConverter : ITypeConverter<Notification, NotificationInfo>, ISingletonDependency |
|||
{ |
|||
public NotificationInfo Convert(Notification source, NotificationInfo destination, ResolutionContext context) |
|||
{ |
|||
destination = new NotificationInfo |
|||
{ |
|||
Name = source.NotificationName, |
|||
Type = source.Type, |
|||
ContentType = source.ContentType, |
|||
Severity = source.Severity, |
|||
CreationTime = source.CreationTime, |
|||
TenantId = source.TenantId |
|||
}; |
|||
destination.SetId(source.NotificationId); |
|||
|
|||
var dataType = Type.GetType(source.NotificationTypeName); |
|||
Check.NotNull(dataType, source.NotificationTypeName); |
|||
var data = Activator.CreateInstance(dataType); |
|||
if (data != null && data is NotificationData notificationData) |
|||
{ |
|||
notificationData.ExtraProperties = source.ExtraProperties; |
|||
destination.Data = NotificationDataConverter.Convert(notificationData); |
|||
} |
|||
else |
|||
{ |
|||
destination.Data = new NotificationData(); |
|||
destination.Data.ExtraProperties = source.ExtraProperties; |
|||
} |
|||
return destination; |
|||
} |
|||
} |
|||
} |
|||
@ -1,18 +0,0 @@ |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Application.Services; |
|||
|
|||
namespace LINGYUN.Abp.TextTemplating; |
|||
|
|||
public interface ITextTemplateAppService : IApplicationService |
|||
{ |
|||
Task<TextTemplateDefinitionDto> GetAsync(string name); |
|||
|
|||
Task<TextTemplateContentDto> GetContentAsync(TextTemplateContentGetInput input); |
|||
|
|||
Task RestoreToDefaultAsync(TextTemplateRestoreInput input); |
|||
|
|||
Task<TextTemplateDefinitionDto> UpdateAsync(TextTemplateUpdateInput input); |
|||
|
|||
Task<PagedResultDto<TextTemplateDefinitionDto>> GetListAsync(TextTemplateDefinitionGetListInput input); |
|||
} |
|||
@ -0,0 +1,13 @@ |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Application.Services; |
|||
|
|||
namespace LINGYUN.Abp.TextTemplating; |
|||
|
|||
public interface ITextTemplateContentAppService : IApplicationService |
|||
{ |
|||
Task<TextTemplateContentDto> GetAsync(TextTemplateContentGetInput input); |
|||
|
|||
Task RestoreToDefaultAsync(string name, TextTemplateRestoreInput input); |
|||
|
|||
Task<TextTemplateContentDto> UpdateAsync(string name, TextTemplateContentUpdateDto input); |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Application.Services; |
|||
|
|||
namespace LINGYUN.Abp.TextTemplating; |
|||
|
|||
public interface ITextTemplateDefinitionAppService : IApplicationService |
|||
{ |
|||
Task<TextTemplateDefinitionDto> GetByNameAsync(string name); |
|||
|
|||
Task<TextTemplateDefinitionDto> CreateAsync(TextTemplateDefinitionCreateDto input); |
|||
|
|||
Task<TextTemplateDefinitionDto> UpdateAsync(string name, TextTemplateDefinitionUpdateDto input); |
|||
|
|||
Task DeleteAsync(string name); |
|||
|
|||
Task<PagedResultDto<TextTemplateDefinitionDto>> GetListAsync(TextTemplateDefinitionGetListInput input); |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Volo.Abp.Validation; |
|||
|
|||
namespace LINGYUN.Abp.TextTemplating; |
|||
|
|||
public class TextTemplateDefinitionCreateDto : TextTemplateDefinitionCreateOrUpdateDto |
|||
{ |
|||
[Required] |
|||
[DynamicStringLength(typeof(TextTemplateDefinitionConsts), nameof(TextTemplateDefinitionConsts.MaxNameLength))] |
|||
public string Name { get; set; } |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Volo.Abp.Validation; |
|||
|
|||
namespace LINGYUN.Abp.TextTemplating; |
|||
|
|||
public abstract class TextTemplateDefinitionCreateOrUpdateDto |
|||
{ |
|||
[Required] |
|||
[DynamicStringLength(typeof(TextTemplateDefinitionConsts), nameof(TextTemplateDefinitionConsts.MaxDisplayNameLength))] |
|||
public string DisplayName { get; set; } |
|||
|
|||
[DynamicStringLength(typeof(TextTemplateDefinitionConsts), nameof(TextTemplateDefinitionConsts.MaxDefaultCultureNameLength))] |
|||
public string DefaultCultureName { get; set; } |
|||
|
|||
public bool IsInlineLocalized { get; set; } |
|||
|
|||
public bool IsLayout { get; set; } |
|||
|
|||
[DynamicStringLength(typeof(TextTemplateDefinitionConsts), nameof(TextTemplateDefinitionConsts.MaxLayoutLength))] |
|||
public string Layout { get; set; } |
|||
|
|||
[DynamicStringLength(typeof(TextTemplateDefinitionConsts), nameof(TextTemplateDefinitionConsts.MaxRenderEngineLength))] |
|||
public string RenderEngine { get; set; } |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
using Volo.Abp.Domain.Entities; |
|||
|
|||
namespace LINGYUN.Abp.TextTemplating; |
|||
public class TextTemplateDefinitionUpdateDto : TextTemplateDefinitionCreateOrUpdateDto, IHasConcurrencyStamp |
|||
{ |
|||
public string ConcurrencyStamp { get; set; } |
|||
} |
|||
@ -1,14 +1,9 @@ |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Volo.Abp.Validation; |
|||
using Volo.Abp.Validation; |
|||
|
|||
namespace LINGYUN.Abp.TextTemplating; |
|||
|
|||
public class TextTemplateRestoreInput |
|||
{ |
|||
[Required] |
|||
[DynamicStringLength(typeof(TextTemplateConsts), nameof(TextTemplateConsts.MaxNameLength))] |
|||
public string Name { get; set; } |
|||
|
|||
[DynamicStringLength(typeof(TextTemplateConsts), nameof(TextTemplateConsts.MaxCultureLength))] |
|||
public string Culture { get; set; } |
|||
} |
|||
|
|||
@ -1,174 +0,0 @@ |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Globalization; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Localization; |
|||
using Volo.Abp.TextTemplating; |
|||
|
|||
namespace LINGYUN.Abp.TextTemplating; |
|||
|
|||
[Authorize(AbpTextTemplatingPermissions.TextTemplate.Default)] |
|||
public class TextTemplateAppService : AbpTextTemplatingAppServiceBase, ITextTemplateAppService |
|||
{ |
|||
protected ITextTemplateRepository TextTemplateRepository { get; } |
|||
protected ITemplateContentProvider TemplateContentProvider { get; } |
|||
protected ITemplateDefinitionManager TemplateDefinitionManager { get; } |
|||
|
|||
public TextTemplateAppService( |
|||
ITextTemplateRepository textTemplateRepository, |
|||
ITemplateContentProvider templateContentProvider, |
|||
ITemplateDefinitionManager templateDefinitionManager) |
|||
{ |
|||
TextTemplateRepository = textTemplateRepository; |
|||
TemplateContentProvider = templateContentProvider; |
|||
TemplateDefinitionManager = templateDefinitionManager; |
|||
} |
|||
|
|||
public virtual Task<TextTemplateDefinitionDto> GetAsync(string name) |
|||
{ |
|||
var templateDefinition = GetTemplateDefinition(name); |
|||
|
|||
var layout = templateDefinition.Layout; |
|||
if (!layout.IsNullOrWhiteSpace()) |
|||
{ |
|||
var layoutDefinition = GetTemplateDefinition(templateDefinition.Layout); |
|||
layout = layoutDefinition.DisplayName.Localize(StringLocalizerFactory); |
|||
} |
|||
|
|||
var result = new TextTemplateDefinitionDto |
|||
{ |
|||
DefaultCultureName = templateDefinition.DefaultCultureName, |
|||
IsInlineLocalized = templateDefinition.IsInlineLocalized, |
|||
IsLayout = templateDefinition.IsLayout, |
|||
Layout = layout, |
|||
Name = templateDefinition.Name, |
|||
DisplayName = templateDefinition.DisplayName.Localize(StringLocalizerFactory), |
|||
}; |
|||
|
|||
return Task.FromResult(result); |
|||
} |
|||
|
|||
public async virtual Task<TextTemplateContentDto> GetContentAsync(TextTemplateContentGetInput input) |
|||
{ |
|||
var templateDefinition = GetTemplateDefinition(input.Name); |
|||
|
|||
var content = await TemplateContentProvider.GetContentOrNullAsync(templateDefinition.Name, input.Culture); |
|||
|
|||
return new TextTemplateContentDto |
|||
{ |
|||
Name = templateDefinition.Name, |
|||
Culture = input.Culture, |
|||
Content = content, |
|||
}; |
|||
} |
|||
|
|||
public virtual Task<PagedResultDto<TextTemplateDefinitionDto>> GetListAsync(TextTemplateDefinitionGetListInput input) |
|||
{ |
|||
var templates = new List<TextTemplateDefinitionDto>(); |
|||
var templateDefinitions = TemplateDefinitionManager.GetAll(); |
|||
var filterTemplates = templateDefinitions |
|||
.WhereIf(!input.Filter.IsNullOrWhiteSpace(), x => |
|||
x.Name.Contains(input.Filter) || x.Layout.Contains(input.Filter)) |
|||
.Skip(input.SkipCount) |
|||
.Take(input.MaxResultCount); |
|||
|
|||
foreach (var templateDefinition in filterTemplates) |
|||
{ |
|||
var layout = templateDefinition.Layout; |
|||
if (!layout.IsNullOrWhiteSpace()) |
|||
{ |
|||
var layoutDefinition = GetTemplateDefinition(templateDefinition.Layout); |
|||
layout = layoutDefinition.DisplayName.Localize(StringLocalizerFactory); |
|||
} |
|||
|
|||
var result = new TextTemplateDefinitionDto |
|||
{ |
|||
DefaultCultureName = templateDefinition.DefaultCultureName, |
|||
IsInlineLocalized = templateDefinition.IsInlineLocalized, |
|||
IsLayout = templateDefinition.IsLayout, |
|||
Layout = layout, |
|||
Name = templateDefinition.Name, |
|||
DisplayName = templateDefinition.DisplayName.Localize(StringLocalizerFactory), |
|||
}; |
|||
|
|||
templates.Add(result); |
|||
} |
|||
|
|||
return Task.FromResult(new PagedResultDto<TextTemplateDefinitionDto>(templateDefinitions.Count, templates)); |
|||
} |
|||
|
|||
[Authorize(AbpTextTemplatingPermissions.TextTemplate.Delete)] |
|||
public async virtual Task RestoreToDefaultAsync(TextTemplateRestoreInput input) |
|||
{ |
|||
var templateDefinition = GetTemplateDefinition(input.Name); |
|||
|
|||
var templates = await TextTemplateRepository |
|||
.GetListAsync(x => x.Name.Equals(templateDefinition.Name) && x.Culture.Equals(input.Culture)); |
|||
|
|||
await TextTemplateRepository.DeleteManyAsync(templates); |
|||
|
|||
await CurrentUnitOfWork.SaveChangesAsync(); |
|||
} |
|||
|
|||
[Authorize(AbpTextTemplatingPermissions.TextTemplate.Update)] |
|||
public async virtual Task<TextTemplateDefinitionDto> UpdateAsync(TextTemplateUpdateInput input) |
|||
{ |
|||
var templateDefinition = GetTemplateDefinition(input.Name); |
|||
|
|||
var template = await TextTemplateRepository.FindByNameAsync(input.Name, input.Culture); |
|||
if (template == null) |
|||
{ |
|||
template = new TextTemplate( |
|||
GuidGenerator.Create(), |
|||
templateDefinition.Name, |
|||
templateDefinition.DisplayName.Localize(StringLocalizerFactory), |
|||
input.Content, |
|||
input.Culture); |
|||
|
|||
await TextTemplateRepository.InsertAsync(template); |
|||
} |
|||
else |
|||
{ |
|||
template.SetContent(input.Content); |
|||
|
|||
await TextTemplateRepository.UpdateAsync(template); |
|||
} |
|||
|
|||
await CurrentUnitOfWork.SaveChangesAsync(); |
|||
|
|||
var layout = templateDefinition.Layout; |
|||
if (!layout.IsNullOrWhiteSpace()) |
|||
{ |
|||
var layoutDefinition = GetTemplateDefinition(templateDefinition.Layout); |
|||
layout = layoutDefinition.DisplayName.Localize(StringLocalizerFactory); |
|||
} |
|||
|
|||
return new TextTemplateDefinitionDto |
|||
{ |
|||
DefaultCultureName = templateDefinition.DefaultCultureName, |
|||
IsInlineLocalized = templateDefinition.IsInlineLocalized, |
|||
IsLayout = templateDefinition.IsLayout, |
|||
Layout = layout, |
|||
Name = templateDefinition.Name, |
|||
DisplayName = templateDefinition.DisplayName.Localize(StringLocalizerFactory), |
|||
}; |
|||
} |
|||
|
|||
protected virtual TemplateDefinition GetTemplateDefinition(string name) |
|||
{ |
|||
var template = TemplateDefinitionManager.GetOrNull(name); |
|||
if (template == null) |
|||
{ |
|||
throw new BusinessException( |
|||
AbpTextTemplatingErrorCodes.TemplateNotFound, |
|||
$"The text template {name} does not exist!") |
|||
.WithData("Name", name); |
|||
} |
|||
|
|||
return template; |
|||
} |
|||
} |
|||
@ -0,0 +1,127 @@ |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp; |
|||
using Volo.Abp.TextTemplating; |
|||
|
|||
namespace LINGYUN.Abp.TextTemplating; |
|||
|
|||
[Authorize(AbpTextTemplatingPermissions.TextTemplateContent.Default)] |
|||
public class TextTemplateContentAppService : AbpTextTemplatingAppServiceBase, ITextTemplateContentAppService |
|||
{ |
|||
protected ITextTemplateRepository TextTemplateRepository { get; } |
|||
protected ITemplateContentProvider TemplateContentProvider { get; } |
|||
protected ITemplateDefinitionStore TemplateDefinitionStore { get; } |
|||
|
|||
public TextTemplateContentAppService( |
|||
ITextTemplateRepository textTemplateRepository, |
|||
ITemplateContentProvider templateContentProvider, |
|||
ITemplateDefinitionStore templateDefinitionStore) |
|||
{ |
|||
TextTemplateRepository = textTemplateRepository; |
|||
TemplateContentProvider = templateContentProvider; |
|||
TemplateDefinitionStore = templateDefinitionStore; |
|||
} |
|||
|
|||
public async virtual Task<TextTemplateContentDto> GetAsync(TextTemplateContentGetInput input) |
|||
{ |
|||
var templateDefinition = await GetTemplateDefinition(input.Name); |
|||
|
|||
var content = await TemplateContentProvider.GetContentOrNullAsync(templateDefinition.Name, input.Culture); |
|||
|
|||
return new TextTemplateContentDto |
|||
{ |
|||
Name = templateDefinition.Name, |
|||
Culture = input.Culture, |
|||
Content = content, |
|||
}; |
|||
} |
|||
|
|||
//public virtual Task<PagedResultDto<TextTemplateDefinitionDto>> GetListAsync(TextTemplateDefinitionGetListInput input)
|
|||
//{
|
|||
// var templates = new List<TextTemplateDefinitionDto>();
|
|||
// var templateDefinitions = TemplateDefinitionManager.GetAll();
|
|||
// var filterTemplates = templateDefinitions
|
|||
// .WhereIf(!input.Filter.IsNullOrWhiteSpace(), x =>
|
|||
// x.Name.Contains(input.Filter) || x.Layout.Contains(input.Filter))
|
|||
// .Skip(input.SkipCount)
|
|||
// .Take(input.MaxResultCount);
|
|||
|
|||
// foreach (var templateDefinition in filterTemplates)
|
|||
// {
|
|||
// var layout = templateDefinition.Layout;
|
|||
// if (!layout.IsNullOrWhiteSpace())
|
|||
// {
|
|||
// var layoutDefinition = GetTemplateDefinition(templateDefinition.Layout);
|
|||
// layout = layoutDefinition.DisplayName.Localize(StringLocalizerFactory);
|
|||
// }
|
|||
|
|||
// var result = new TextTemplateDefinitionDto
|
|||
// {
|
|||
// DefaultCultureName = templateDefinition.DefaultCultureName,
|
|||
// IsInlineLocalized = templateDefinition.IsInlineLocalized,
|
|||
// IsLayout = templateDefinition.IsLayout,
|
|||
// Layout = layout,
|
|||
// Name = templateDefinition.Name,
|
|||
// DisplayName = templateDefinition.DisplayName.Localize(StringLocalizerFactory),
|
|||
// };
|
|||
|
|||
// templates.Add(result);
|
|||
// }
|
|||
|
|||
// return Task.FromResult(new PagedResultDto<TextTemplateDefinitionDto>(templateDefinitions.Count, templates));
|
|||
//}
|
|||
|
|||
[Authorize(AbpTextTemplatingPermissions.TextTemplateContent.Delete)] |
|||
public async virtual Task RestoreToDefaultAsync(string name, TextTemplateRestoreInput input) |
|||
{ |
|||
var templateDefinition = await GetTemplateDefinition(name); |
|||
|
|||
var templates = await TextTemplateRepository |
|||
.GetListAsync(x => x.Name.Equals(templateDefinition.Name) && x.Culture.Equals(input.Culture)); |
|||
|
|||
await TextTemplateRepository.DeleteManyAsync(templates); |
|||
|
|||
await CurrentUnitOfWork.SaveChangesAsync(); |
|||
} |
|||
|
|||
[Authorize(AbpTextTemplatingPermissions.TextTemplateContent.Update)] |
|||
public async virtual Task<TextTemplateContentDto> UpdateAsync(string name, TextTemplateContentUpdateDto input) |
|||
{ |
|||
var templateDefinition = await GetTemplateDefinition(name); |
|||
|
|||
var template = await TextTemplateRepository.FindByNameAsync(name, input.Culture); |
|||
if (template == null) |
|||
{ |
|||
template = new TextTemplate( |
|||
GuidGenerator.Create(), |
|||
templateDefinition.Name, |
|||
templateDefinition.DisplayName.Localize(StringLocalizerFactory), |
|||
input.Content, |
|||
input.Culture); |
|||
|
|||
await TextTemplateRepository.InsertAsync(template); |
|||
} |
|||
else |
|||
{ |
|||
template.SetContent(input.Content); |
|||
|
|||
await TextTemplateRepository.UpdateAsync(template); |
|||
} |
|||
|
|||
await CurrentUnitOfWork.SaveChangesAsync(); |
|||
|
|||
return new TextTemplateContentDto |
|||
{ |
|||
Name = templateDefinition.Name, |
|||
Culture = input.Culture, |
|||
Content = template.Content, |
|||
}; |
|||
} |
|||
|
|||
protected async virtual Task<TemplateDefinition> GetTemplateDefinition(string name) |
|||
{ |
|||
return await TemplateDefinitionStore.GetOrNullAsync(name) |
|||
?? throw new BusinessException(AbpTextTemplatingErrorCodes.TextTemplateDefinition.TemplateNotFound) |
|||
.WithData(nameof(TextTemplateDefinition.Name), name); |
|||
} |
|||
} |
|||
@ -0,0 +1,257 @@ |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Linq.Dynamic.Core; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Localization; |
|||
using Volo.Abp.TextTemplating; |
|||
|
|||
namespace LINGYUN.Abp.TextTemplating; |
|||
|
|||
[Authorize(AbpTextTemplatingPermissions.TextTemplateDefinition.Default)] |
|||
public class TextTemplateDefinitionAppService : AbpTextTemplatingAppServiceBase, ITextTemplateDefinitionAppService |
|||
{ |
|||
private readonly ITemplateDefinitionStore _store; |
|||
private readonly ITextTemplateDefinitionRepository _repository; |
|||
private readonly ILocalizableStringSerializer _localizableStringSerializer; |
|||
|
|||
public TextTemplateDefinitionAppService( |
|||
ITemplateDefinitionStore store, |
|||
ITextTemplateDefinitionRepository repository, |
|||
ILocalizableStringSerializer localizableStringSerializer) |
|||
{ |
|||
_store = store; |
|||
_repository = repository; |
|||
_localizableStringSerializer = localizableStringSerializer; |
|||
} |
|||
|
|||
[Authorize(AbpTextTemplatingPermissions.TextTemplateDefinition.Create)] |
|||
public async virtual Task<TextTemplateDefinitionDto> CreateAsync(TextTemplateDefinitionCreateDto input) |
|||
{ |
|||
var template = await _store.GetOrNullAsync(input.Name); |
|||
if (template != null) |
|||
{ |
|||
throw new BusinessException(AbpTextTemplatingErrorCodes.TextTemplateDefinition.NameAlreadyExists) |
|||
.WithData(nameof(TextTemplateDefinition.Name), input.Name); |
|||
} |
|||
|
|||
var layout = input.Layout; |
|||
if (!layout.IsNullOrWhiteSpace()) |
|||
{ |
|||
var layoutDefinition = await _store.GetAsync(layout); |
|||
layout = await layoutDefinition.DisplayName.LocalizeAsync(StringLocalizerFactory); |
|||
} |
|||
|
|||
var formatDisplayName = input.DisplayName; |
|||
if (!formatDisplayName.IsNullOrWhiteSpace()) |
|||
{ |
|||
var displayName = _localizableStringSerializer.Deserialize(formatDisplayName); |
|||
formatDisplayName = await displayName.LocalizeAsync(StringLocalizerFactory); |
|||
} |
|||
|
|||
var templateDefinition = new TextTemplateDefinition( |
|||
GuidGenerator.Create(), |
|||
input.Name, |
|||
input.DisplayName, |
|||
input.IsLayout, |
|||
input.Layout, |
|||
input.IsInlineLocalized, |
|||
input.DefaultCultureName, |
|||
input.RenderEngine); |
|||
|
|||
await _store.CreateAsync(templateDefinition); |
|||
|
|||
await CurrentUnitOfWork.SaveChangesAsync(); |
|||
|
|||
var result = new TextTemplateDefinitionDto |
|||
{ |
|||
DefaultCultureName = templateDefinition.DefaultCultureName, |
|||
IsInlineLocalized = templateDefinition.IsInlineLocalized, |
|||
IsLayout = templateDefinition.IsLayout, |
|||
Layout = layout, |
|||
Name = templateDefinition.Name, |
|||
DisplayName = formatDisplayName, |
|||
IsStatic = templateDefinition.IsStatic, |
|||
ConcurrencyStamp = templateDefinition.ConcurrencyStamp, |
|||
}; |
|||
|
|||
return result; |
|||
} |
|||
|
|||
[Authorize(AbpTextTemplatingPermissions.TextTemplateDefinition.Delete)] |
|||
public async virtual Task DeleteAsync(string name) |
|||
{ |
|||
await _store.DeleteAsync(name); |
|||
} |
|||
|
|||
public async virtual Task<TextTemplateDefinitionDto> GetByNameAsync(string name) |
|||
{ |
|||
var template = await _store.GetAsync(name); |
|||
|
|||
var layout = template.Layout; |
|||
if (!layout.IsNullOrWhiteSpace()) |
|||
{ |
|||
var layoutDefinition = await _store.GetAsync(template.Layout); |
|||
layout = await layoutDefinition.DisplayName.LocalizeAsync(StringLocalizerFactory); |
|||
} |
|||
|
|||
var result = new TextTemplateDefinitionDto |
|||
{ |
|||
DefaultCultureName = template.DefaultCultureName, |
|||
IsInlineLocalized = template.IsInlineLocalized, |
|||
IsLayout = template.IsLayout, |
|||
Layout = layout, |
|||
Name = template.Name, |
|||
DisplayName = await template.DisplayName.LocalizeAsync(StringLocalizerFactory), |
|||
}; |
|||
|
|||
var staticState = template.Properties.GetOrDefault(nameof(TextTemplateDefinition.IsStatic)); |
|||
if (staticState != null && staticState is bool isStatic) |
|||
{ |
|||
result.IsStatic = isStatic; |
|||
} |
|||
|
|||
return result; |
|||
} |
|||
|
|||
public async virtual Task<PagedResultDto<TextTemplateDefinitionDto>> GetListAsync(TextTemplateDefinitionGetListInput input) |
|||
{ |
|||
var templates = new List<TextTemplateDefinitionDto>(); |
|||
|
|||
var templateDefinitions = await _store.GetAllAsync(); |
|||
|
|||
var sorting = input.Sorting; |
|||
if (sorting.IsNullOrWhiteSpace()) |
|||
{ |
|||
sorting = nameof(TextTemplateDefinition.Name); |
|||
} |
|||
var filterTemplates = templateDefinitions.AsQueryable() |
|||
.WhereIf(!input.Filter.IsNullOrWhiteSpace(), x => |
|||
x.Name.Contains(input.Filter) || x.Layout.Contains(input.Filter)) |
|||
.OrderBy(sorting) |
|||
.Skip(input.SkipCount) |
|||
.Take(input.MaxResultCount); |
|||
|
|||
foreach (var templateDefinition in filterTemplates) |
|||
{ |
|||
var layout = templateDefinition.Layout; |
|||
if (!layout.IsNullOrWhiteSpace()) |
|||
{ |
|||
var layoutDefinition = await _store.GetOrNullAsync(templateDefinition.Layout); |
|||
if (layoutDefinition != null) |
|||
{ |
|||
layout = await layoutDefinition.DisplayName.LocalizeAsync(StringLocalizerFactory); |
|||
} |
|||
} |
|||
|
|||
var result = new TextTemplateDefinitionDto |
|||
{ |
|||
DefaultCultureName = templateDefinition.DefaultCultureName, |
|||
IsInlineLocalized = templateDefinition.IsInlineLocalized, |
|||
IsLayout = templateDefinition.IsLayout, |
|||
Layout = layout, |
|||
Name = templateDefinition.Name, |
|||
DisplayName = templateDefinition.DisplayName.Localize(StringLocalizerFactory), |
|||
}; |
|||
|
|||
var staticState = templateDefinition.Properties.GetOrDefault(nameof(TextTemplateDefinition.IsStatic)); |
|||
if (staticState != null && staticState is bool isStatic) |
|||
{ |
|||
result.IsStatic = isStatic; |
|||
} |
|||
|
|||
templates.Add(result); |
|||
} |
|||
|
|||
return new PagedResultDto<TextTemplateDefinitionDto>(templateDefinitions.Count, templates); |
|||
} |
|||
|
|||
[Authorize(AbpTextTemplatingPermissions.TextTemplateDefinition.Update)] |
|||
public async virtual Task<TextTemplateDefinitionDto> UpdateAsync(string name, TextTemplateDefinitionUpdateDto input) |
|||
{ |
|||
var templateDefinitionRecord = await _repository.FindByNameAsync(name); |
|||
|
|||
if (templateDefinitionRecord == null) |
|||
{ |
|||
var templateDefinition = await _store.GetAsync(name); |
|||
|
|||
templateDefinitionRecord = new TextTemplateDefinition( |
|||
GuidGenerator.Create(), |
|||
templateDefinition.Name, |
|||
_localizableStringSerializer.Serialize(templateDefinition.DisplayName), |
|||
templateDefinition.IsLayout, |
|||
templateDefinition.Layout, |
|||
templateDefinition.IsInlineLocalized, |
|||
templateDefinition.DefaultCultureName, |
|||
templateDefinition.RenderEngine); |
|||
|
|||
UpdateByInput(templateDefinitionRecord, input); |
|||
|
|||
await _store.CreateAsync(templateDefinitionRecord); |
|||
} |
|||
else |
|||
{ |
|||
UpdateByInput(templateDefinitionRecord, input); |
|||
|
|||
if (!string.Equals(templateDefinitionRecord.DisplayName, input.DisplayName, StringComparison.InvariantCultureIgnoreCase)) |
|||
{ |
|||
var displayNameD = _localizableStringSerializer.Deserialize(input.DisplayName); |
|||
|
|||
templateDefinitionRecord.DisplayName = await displayNameD.LocalizeAsync(StringLocalizerFactory); |
|||
} |
|||
|
|||
await _store.UpdateAsync(templateDefinitionRecord); |
|||
} |
|||
|
|||
await CurrentUnitOfWork.SaveChangesAsync(); |
|||
|
|||
var layout = templateDefinitionRecord.Layout; |
|||
if (!layout.IsNullOrWhiteSpace()) |
|||
{ |
|||
var layoutDefinition = await _store.GetAsync(layout); |
|||
layout = await layoutDefinition.DisplayName.LocalizeAsync(StringLocalizerFactory); |
|||
} |
|||
|
|||
var displayName = templateDefinitionRecord.DisplayName; |
|||
if (!displayName.IsNullOrWhiteSpace()) |
|||
{ |
|||
var displayNameD = _localizableStringSerializer.Deserialize(displayName); |
|||
displayName = await displayNameD.LocalizeAsync(StringLocalizerFactory); |
|||
} |
|||
|
|||
var result = new TextTemplateDefinitionDto |
|||
{ |
|||
DefaultCultureName = templateDefinitionRecord.DefaultCultureName, |
|||
IsInlineLocalized = templateDefinitionRecord.IsInlineLocalized, |
|||
IsLayout = templateDefinitionRecord.IsLayout, |
|||
Layout = layout, |
|||
Name = templateDefinitionRecord.Name, |
|||
DisplayName = displayName, |
|||
IsStatic = templateDefinitionRecord.IsStatic, |
|||
ConcurrencyStamp = templateDefinitionRecord.ConcurrencyStamp, |
|||
}; |
|||
|
|||
return result; |
|||
} |
|||
|
|||
protected virtual void UpdateByInput(TextTemplateDefinition templateDefinition, TextTemplateDefinitionCreateOrUpdateDto input) |
|||
{ |
|||
templateDefinition.IsInlineLocalized = input.IsInlineLocalized; |
|||
templateDefinition.IsLayout = input.IsLayout; |
|||
if (!string.Equals(templateDefinition.Layout, input.Layout, StringComparison.InvariantCultureIgnoreCase)) |
|||
{ |
|||
templateDefinition.Layout = input.Layout; |
|||
} |
|||
if (!string.Equals(templateDefinition.DefaultCultureName, input.DefaultCultureName, StringComparison.InvariantCultureIgnoreCase)) |
|||
{ |
|||
templateDefinition.DefaultCultureName = input.DefaultCultureName; |
|||
} |
|||
if (!string.Equals(templateDefinition.RenderEngine, input.RenderEngine, StringComparison.InvariantCultureIgnoreCase)) |
|||
{ |
|||
templateDefinition.RenderEngine = input.RenderEngine; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
namespace LINGYUN.Abp.TextTemplating; |
|||
public static class TextTemplateDefinitionConsts |
|||
{ |
|||
public static int MaxNameLength { get; set; } = 128; |
|||
public static int MaxDisplayNameLength { get; set; } = 512; |
|||
public static int MaxLayoutLength { get; set; } = 60; |
|||
public static int MaxDefaultCultureNameLength { get; set; } = 30; |
|||
public static int MaxRenderEngineLength { get; set; } = 30; |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace LINGYUN.Abp.TextTemplating; |
|||
public interface IStaticTemplateDefinitionSaver |
|||
{ |
|||
Task SaveAsync(); |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
using JetBrains.Annotations; |
|||
using System.Collections.Generic; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.TextTemplating; |
|||
|
|||
namespace LINGYUN.Abp.TextTemplating; |
|||
public interface ITemplateDefinitionStore |
|||
{ |
|||
Task CreateAsync(TextTemplateDefinition template); |
|||
|
|||
Task UpdateAsync(TextTemplateDefinition template); |
|||
|
|||
Task DeleteAsync(string name, CancellationToken cancellationToken = default); |
|||
|
|||
[NotNull] |
|||
Task<TemplateDefinition> GetAsync(string name, CancellationToken cancellationToken = default); |
|||
|
|||
[NotNull] |
|||
Task<IReadOnlyList<TemplateDefinition>> GetAllAsync(CancellationToken cancellationToken = default); |
|||
|
|||
[CanBeNull] |
|||
Task<TemplateDefinition> GetOrNullAsync(string name, CancellationToken cancellationToken = default); |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.TextTemplating; |
|||
|
|||
namespace LINGYUN.Abp.TextTemplating; |
|||
|
|||
public interface ITemplateDefinitionStoreCache |
|||
{ |
|||
string CacheStamp { get; set; } |
|||
|
|||
SemaphoreSlim SyncSemaphore { get; } |
|||
|
|||
DateTime? LastCheckTime { get; set; } |
|||
|
|||
Task FillAsync( |
|||
List<TextTemplateDefinition> templateDefinitionRecords, |
|||
IReadOnlyList<TemplateDefinition> templateDefinitions); |
|||
|
|||
TemplateDefinition GetOrNull(string name); |
|||
|
|||
IReadOnlyList<TemplateDefinition> GetAll(); |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Domain.Repositories; |
|||
|
|||
namespace LINGYUN.Abp.TextTemplating; |
|||
public interface ITextTemplateDefinitionRepository : IBasicRepository<TextTemplateDefinition, Guid> |
|||
{ |
|||
Task<TextTemplateDefinition> FindByNameAsync( |
|||
string name, |
|||
CancellationToken cancellationToken = default); |
|||
|
|||
Task<long> GetCountAsync( |
|||
string filter = null, |
|||
CancellationToken cancellationToken = default); |
|||
|
|||
Task<List<TextTemplateDefinition>> GetListAsync( |
|||
string filter = null, |
|||
string sorting = nameof(TextTemplateDefinition.Name), |
|||
int skipCount = 0, |
|||
int maxResultCount = 10, |
|||
CancellationToken cancellationToken = default); |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
using JetBrains.Annotations; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.TextTemplating; |
|||
|
|||
namespace LINGYUN.Abp.TextTemplating; |
|||
public interface ITextTemplateDefinitionSerializer |
|||
{ |
|||
Task<TextTemplateDefinition> SerializeAsync(TemplateDefinition template); |
|||
} |
|||
@ -0,0 +1,86 @@ |
|||
using System; |
|||
using System.Collections.Concurrent; |
|||
using System.Collections.Generic; |
|||
using System.Collections.Immutable; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Localization; |
|||
using Volo.Abp.TextTemplating; |
|||
|
|||
namespace LINGYUN.Abp.TextTemplating; |
|||
public class InMemoryTemplateDefinitionStoreCache : ITemplateDefinitionStoreCache, ISingletonDependency |
|||
{ |
|||
public string CacheStamp { get; set; } |
|||
public SemaphoreSlim SyncSemaphore { get; } |
|||
public DateTime? LastCheckTime { get; set; } |
|||
|
|||
protected IDictionary<string, TemplateDefinition> TemplateDefinitions { get; } |
|||
|
|||
protected ILocalizableStringSerializer LocalizableStringSerializer { get; } |
|||
|
|||
public InMemoryTemplateDefinitionStoreCache(ILocalizableStringSerializer localizableStringSerializer) |
|||
{ |
|||
LocalizableStringSerializer = localizableStringSerializer; |
|||
|
|||
SyncSemaphore = new(1, 1); |
|||
TemplateDefinitions = new ConcurrentDictionary<string, TemplateDefinition>(); |
|||
} |
|||
|
|||
public virtual Task FillAsync( |
|||
List<TextTemplateDefinition> templateDefinitionRecords, |
|||
IReadOnlyList<TemplateDefinition> templateDefinitions) |
|||
{ |
|||
TemplateDefinitions.Clear(); |
|||
|
|||
foreach (var templateDefinitionRecord in templateDefinitionRecords) |
|||
{ |
|||
var templateDefinition = new TemplateDefinition( |
|||
templateDefinitionRecord.Name, |
|||
typeof(NonTypedLocalizationResource), |
|||
LocalizableStringSerializer.Deserialize(templateDefinitionRecord.DisplayName), |
|||
templateDefinitionRecord.IsLayout, |
|||
templateDefinitionRecord.Layout, |
|||
templateDefinitionRecord.DefaultCultureName) |
|||
{ |
|||
IsInlineLocalized = templateDefinitionRecord.IsInlineLocalized, |
|||
}; |
|||
if (!templateDefinitionRecord.RenderEngine.IsNullOrWhiteSpace()) |
|||
{ |
|||
templateDefinition.WithRenderEngine(templateDefinitionRecord.RenderEngine); |
|||
} |
|||
foreach (var property in templateDefinitionRecord.ExtraProperties) |
|||
{ |
|||
templateDefinition.WithProperty(property.Key, property.Value); |
|||
} |
|||
templateDefinition.WithProperty(nameof(TextTemplateDefinition.IsStatic), templateDefinitionRecord.IsStatic); |
|||
|
|||
TemplateDefinitions[templateDefinition.Name] = templateDefinition; |
|||
} |
|||
|
|||
foreach (var templateDefinition in templateDefinitions) |
|||
{ |
|||
if (TemplateDefinitions.TryGetValue(templateDefinition.Name, out var inCacheTemplate)) |
|||
{ |
|||
inCacheTemplate.WithProperty(nameof(TextTemplateDefinition.IsStatic), true); |
|||
} |
|||
else |
|||
{ |
|||
templateDefinition.WithProperty(nameof(TextTemplateDefinition.IsStatic), true); |
|||
TemplateDefinitions[templateDefinition.Name] = templateDefinition; |
|||
} |
|||
} |
|||
|
|||
return Task.CompletedTask; |
|||
} |
|||
|
|||
public virtual TemplateDefinition GetOrNull(string name) |
|||
{ |
|||
return TemplateDefinitions.GetOrDefault(name); |
|||
} |
|||
|
|||
public virtual IReadOnlyList<TemplateDefinition> GetAll() |
|||
{ |
|||
return TemplateDefinitions.Values.ToImmutableList(); |
|||
} |
|||
} |
|||
@ -0,0 +1,96 @@ |
|||
using Microsoft.Extensions.Options; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Caching; |
|||
using Volo.Abp.Data; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.DistributedLocking; |
|||
using Volo.Abp.Guids; |
|||
using Volo.Abp.Localization; |
|||
using Volo.Abp.TextTemplating; |
|||
using Volo.Abp.Uow; |
|||
|
|||
namespace LINGYUN.Abp.TextTemplating; |
|||
|
|||
public class StaticTemplateDefinitionSaver : IStaticTemplateDefinitionSaver, ITransientDependency |
|||
{ |
|||
protected AbpDistributedCacheOptions CacheOptions { get; } |
|||
protected IGuidGenerator GuidGenerator { get; } |
|||
protected IAbpDistributedLock DistributedLock { get; } |
|||
protected ITextTemplateDefinitionRepository TemplateDefinitionRepository { get; } |
|||
protected AbpTextTemplatingCachingOptions TemplatingCachingOptions { get; } |
|||
protected ITemplateDefinitionManager TemplateDefinitionManager { get; } |
|||
protected ILocalizableStringSerializer LocalizableStringSerializer { get; } |
|||
|
|||
public StaticTemplateDefinitionSaver( |
|||
IOptions<AbpDistributedCacheOptions> cacheOptions, |
|||
IOptions<AbpTextTemplatingCachingOptions> templatingCachingOptions, |
|||
IGuidGenerator guidGenerator, |
|||
IAbpDistributedLock distributedLock, |
|||
ITextTemplateDefinitionRepository templateDefinitionRepository, |
|||
ITemplateDefinitionManager templateDefinitionManager, |
|||
ILocalizableStringSerializer localizableStringSerializer) |
|||
{ |
|||
CacheOptions = cacheOptions.Value; |
|||
GuidGenerator = guidGenerator; |
|||
DistributedLock = distributedLock; |
|||
TemplateDefinitionRepository = templateDefinitionRepository; |
|||
TemplatingCachingOptions = templatingCachingOptions.Value; |
|||
TemplateDefinitionManager = templateDefinitionManager; |
|||
LocalizableStringSerializer = localizableStringSerializer; |
|||
} |
|||
|
|||
[UnitOfWork] |
|||
public async virtual Task SaveAsync() |
|||
{ |
|||
if (TemplatingCachingOptions.SaveStaticTemplateDefinitionToDatabase) |
|||
{ |
|||
await using var commonLockHandle = await DistributedLock |
|||
.TryAcquireAsync(GetCommonDistributedLockKey(), TemplatingCachingOptions.TemplateDefinitionsCacheStampTimeOut); |
|||
|
|||
if (commonLockHandle == null) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
var templateDefinitions = TemplateDefinitionManager.GetAll(); |
|||
|
|||
var saveNewTemplateDefinitionRecords = new List<TextTemplateDefinition>(); |
|||
|
|||
foreach (var templateDefinition in templateDefinitions) |
|||
{ |
|||
if (await TemplateDefinitionRepository.FindByNameAsync(templateDefinition.Name) != null) |
|||
{ |
|||
continue; |
|||
} |
|||
|
|||
var templateDefinitionRecord = new TextTemplateDefinition( |
|||
GuidGenerator.Create(), |
|||
templateDefinition.Name, |
|||
LocalizableStringSerializer.Serialize(templateDefinition.DisplayName), |
|||
templateDefinition.IsLayout, |
|||
templateDefinition.Layout, |
|||
templateDefinition.IsInlineLocalized, |
|||
templateDefinition.DefaultCultureName, |
|||
templateDefinition.RenderEngine) |
|||
{ |
|||
IsStatic = true |
|||
}; |
|||
|
|||
foreach (var property in templateDefinition.Properties) |
|||
{ |
|||
templateDefinitionRecord.SetProperty(property.Key, property.Value); |
|||
} |
|||
|
|||
saveNewTemplateDefinitionRecords.Add(templateDefinitionRecord); |
|||
} |
|||
|
|||
await TemplateDefinitionRepository.InsertManyAsync(saveNewTemplateDefinitionRecords); |
|||
} |
|||
} |
|||
|
|||
protected virtual string GetCommonDistributedLockKey() |
|||
{ |
|||
return $"{CacheOptions.KeyPrefix}_Common_AbpTemplateDefinitionStaticSaverLock"; |
|||
} |
|||
} |
|||
@ -0,0 +1,209 @@ |
|||
using JetBrains.Annotations; |
|||
using Microsoft.Extensions.Caching.Distributed; |
|||
using Microsoft.Extensions.Options; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Caching; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.DistributedLocking; |
|||
using Volo.Abp.TextTemplating; |
|||
using Volo.Abp.Threading; |
|||
|
|||
namespace LINGYUN.Abp.TextTemplating; |
|||
|
|||
public class TemplateDefinitionStore : ITemplateDefinitionStore, ITransientDependency |
|||
{ |
|||
protected AbpDistributedCacheOptions CacheOptions { get; } |
|||
protected AbpTextTemplatingCachingOptions TemplatingCachingOptions { get; } |
|||
protected IAbpDistributedLock DistributedLock { get; } |
|||
protected IDistributedCache DistributedCache { get; } |
|||
protected ITextTemplateDefinitionRepository TextTemplateDefinitionRepository { get; } |
|||
protected ITemplateDefinitionManager TemplateDefinitionManager { get; } |
|||
protected ITemplateDefinitionStoreCache TemplateDefinitionStoreCache { get; } |
|||
|
|||
public TemplateDefinitionStore( |
|||
IOptions<AbpDistributedCacheOptions> cacheOptions, |
|||
IOptions<AbpTextTemplatingCachingOptions> templatingCachingOptions, |
|||
IAbpDistributedLock distributedLock, |
|||
IDistributedCache distributedCache, |
|||
ITextTemplateDefinitionRepository textTemplateDefinitionRepository, |
|||
ITemplateDefinitionManager templateDefinitionManager, |
|||
ITemplateDefinitionStoreCache templateDefinitionStoreCache) |
|||
{ |
|||
CacheOptions = cacheOptions.Value; |
|||
TemplatingCachingOptions = templatingCachingOptions.Value; |
|||
DistributedLock = distributedLock; |
|||
DistributedCache = distributedCache; |
|||
TextTemplateDefinitionRepository = textTemplateDefinitionRepository; |
|||
TemplateDefinitionManager = templateDefinitionManager; |
|||
TemplateDefinitionStoreCache = templateDefinitionStoreCache; |
|||
} |
|||
|
|||
public async virtual Task CreateAsync(TextTemplateDefinition template) |
|||
{ |
|||
await TextTemplateDefinitionRepository.InsertAsync(template); |
|||
|
|||
TemplateDefinitionStoreCache.LastCheckTime = DateTime.Now; |
|||
} |
|||
|
|||
public async virtual Task UpdateAsync(TextTemplateDefinition template) |
|||
{ |
|||
await TextTemplateDefinitionRepository.UpdateAsync(template); |
|||
|
|||
TemplateDefinitionStoreCache.LastCheckTime = DateTime.Now; |
|||
} |
|||
|
|||
public async virtual Task DeleteAsync(string name, CancellationToken cancellationToken = default) |
|||
{ |
|||
if (!TemplatingCachingOptions.IsDynamicTemplateDefinitionStoreEnabled) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
using (await TemplateDefinitionStoreCache.SyncSemaphore.LockAsync()) |
|||
{ |
|||
var templateDefinitionRecord = await TextTemplateDefinitionRepository.FindByNameAsync(name); |
|||
if (templateDefinitionRecord != null) |
|||
{ |
|||
await TextTemplateDefinitionRepository.DeleteAsync(templateDefinitionRecord); |
|||
// 及时更新便于下次检索刷新缓存
|
|||
TemplateDefinitionStoreCache.LastCheckTime = DateTime.Now; |
|||
} |
|||
} |
|||
} |
|||
|
|||
public async virtual Task<TemplateDefinition> GetAsync([NotNull] string name, CancellationToken cancellationToken = default) |
|||
{ |
|||
if (!TemplatingCachingOptions.IsDynamicTemplateDefinitionStoreEnabled) |
|||
{ |
|||
return TemplateDefinitionManager.Get(name); |
|||
} |
|||
|
|||
using (await TemplateDefinitionStoreCache.SyncSemaphore.LockAsync()) |
|||
{ |
|||
await EnsureCacheIsUptoDateAsync(); |
|||
|
|||
var templateDefinition = TemplateDefinitionStoreCache.GetOrNull(name); |
|||
templateDefinition ??= TemplateDefinitionManager.Get(name); |
|||
|
|||
return templateDefinition; |
|||
} |
|||
} |
|||
|
|||
public async virtual Task<IReadOnlyList<TemplateDefinition>> GetAllAsync(CancellationToken cancellationToken = default) |
|||
{ |
|||
if (!TemplatingCachingOptions.IsDynamicTemplateDefinitionStoreEnabled) |
|||
{ |
|||
return TemplateDefinitionManager.GetAll(); |
|||
} |
|||
|
|||
using (await TemplateDefinitionStoreCache.SyncSemaphore.LockAsync()) |
|||
{ |
|||
await EnsureCacheIsUptoDateAsync(); |
|||
|
|||
return TemplateDefinitionStoreCache.GetAll(); |
|||
} |
|||
} |
|||
|
|||
public async virtual Task<TemplateDefinition> GetOrNullAsync(string name, CancellationToken cancellationToken = default) |
|||
{ |
|||
if (!TemplatingCachingOptions.IsDynamicTemplateDefinitionStoreEnabled) |
|||
{ |
|||
return TemplateDefinitionManager.GetOrNull(name); |
|||
} |
|||
|
|||
using (await TemplateDefinitionStoreCache.SyncSemaphore.LockAsync()) |
|||
{ |
|||
await EnsureCacheIsUptoDateAsync(); |
|||
|
|||
var templateDefinition = TemplateDefinitionStoreCache.GetOrNull(name); |
|||
|
|||
return templateDefinition; |
|||
} |
|||
} |
|||
|
|||
protected async virtual Task EnsureCacheIsUptoDateAsync() |
|||
{ |
|||
if (TemplateDefinitionStoreCache.LastCheckTime.HasValue && |
|||
DateTime.Now.Subtract(TemplateDefinitionStoreCache.LastCheckTime.Value) < TemplatingCachingOptions.TemplateDefinitionsCacheRefreshInterval) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
var stampInDistributedCache = await GetOrSetStampInDistributedCache(); |
|||
|
|||
if (stampInDistributedCache == TemplateDefinitionStoreCache.CacheStamp) |
|||
{ |
|||
TemplateDefinitionStoreCache.LastCheckTime = DateTime.Now; |
|||
return; |
|||
} |
|||
|
|||
await UpdateInMemoryStoreCache(); |
|||
|
|||
TemplateDefinitionStoreCache.CacheStamp = stampInDistributedCache; |
|||
TemplateDefinitionStoreCache.LastCheckTime = DateTime.Now; |
|||
} |
|||
|
|||
protected async virtual Task UpdateInMemoryStoreCache() |
|||
{ |
|||
var templateDefinitions = TemplateDefinitionManager.GetAll(); |
|||
var textTemplateDefinitions = await TextTemplateDefinitionRepository.GetListAsync(includeDetails: false); |
|||
|
|||
await TemplateDefinitionStoreCache.FillAsync(textTemplateDefinitions, templateDefinitions); |
|||
} |
|||
|
|||
protected async virtual Task<string> GetOrSetStampInDistributedCache() |
|||
{ |
|||
var cacheKey = GetCommonStampCacheKey(); |
|||
|
|||
var stampInDistributedCache = await DistributedCache.GetStringAsync(cacheKey); |
|||
if (stampInDistributedCache != null) |
|||
{ |
|||
return stampInDistributedCache; |
|||
} |
|||
|
|||
await using (var commonLockHandle = await DistributedLock |
|||
.TryAcquireAsync(GetCommonDistributedLockKey(), TemplatingCachingOptions.TemplateDefinitionsCacheStampTimeOut)) |
|||
{ |
|||
if (commonLockHandle == null) |
|||
{ |
|||
/* This request will fail */ |
|||
throw new AbpException( |
|||
"Could not acquire distributed lock for template definition common stamp check!" |
|||
); |
|||
} |
|||
|
|||
stampInDistributedCache = await DistributedCache.GetStringAsync(cacheKey); |
|||
if (stampInDistributedCache != null) |
|||
{ |
|||
return stampInDistributedCache; |
|||
} |
|||
|
|||
stampInDistributedCache = Guid.NewGuid().ToString(); |
|||
|
|||
await DistributedCache.SetStringAsync( |
|||
cacheKey, |
|||
stampInDistributedCache, |
|||
new DistributedCacheEntryOptions |
|||
{ |
|||
SlidingExpiration = TemplatingCachingOptions.TemplateDefinitionsCacheStampExpiration |
|||
} |
|||
); |
|||
} |
|||
|
|||
return stampInDistributedCache; |
|||
} |
|||
|
|||
protected virtual string GetCommonStampCacheKey() |
|||
{ |
|||
return $"{CacheOptions.KeyPrefix}_AbpInMemoryTemplateDefinitionCacheStamp"; |
|||
} |
|||
|
|||
protected virtual string GetCommonDistributedLockKey() |
|||
{ |
|||
return $"{CacheOptions.KeyPrefix}_Common_AbpTemplateDefinitionUpdateLock"; |
|||
} |
|||
} |
|||
@ -0,0 +1,37 @@ |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Options; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.TextTemplating; |
|||
|
|||
namespace LINGYUN.Abp.TextTemplating; |
|||
|
|||
[Dependency(ReplaceServices = true)] |
|||
[ExposeServices( |
|||
typeof(ITemplateContentProvider), |
|||
typeof(TemplateContentProvider))] |
|||
public class TextTemplateContentProvider : TemplateContentProvider, ITransientDependency |
|||
{ |
|||
protected ITemplateDefinitionStore TemplateDefinitionStore { get; } |
|||
|
|||
public TextTemplateContentProvider( |
|||
ITemplateDefinitionManager templateDefinitionManager, |
|||
ITemplateDefinitionStore templateDefinitionStore, |
|||
IServiceScopeFactory serviceScopeFactory, |
|||
IOptions<AbpTextTemplatingOptions> options) |
|||
: base(templateDefinitionManager, serviceScopeFactory, options) |
|||
{ |
|||
TemplateDefinitionStore = templateDefinitionStore; |
|||
} |
|||
|
|||
public async override Task<string> GetContentOrNullAsync( |
|||
string templateName, |
|||
string cultureName = null, |
|||
bool tryDefaults = true, |
|||
bool useCurrentCultureIfCultureNameIsNull = true) |
|||
{ |
|||
var template = await TemplateDefinitionStore.GetAsync(templateName); |
|||
|
|||
return await GetContentOrNullAsync(template, cultureName); |
|||
} |
|||
} |
|||
@ -0,0 +1,41 @@ |
|||
using System; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Data; |
|||
using Volo.Abp.Domain.Entities; |
|||
|
|||
namespace LINGYUN.Abp.TextTemplating; |
|||
public class TextTemplateDefinition : AggregateRoot<Guid>, IHasExtraProperties |
|||
{ |
|||
public virtual string Name { get; protected set; } |
|||
public virtual string DisplayName { get; set; } |
|||
public virtual bool IsLayout { get; set; } |
|||
public virtual string Layout { get; set; } |
|||
public virtual bool IsInlineLocalized { get; set; } |
|||
public virtual string DefaultCultureName { get; set; } |
|||
public virtual string RenderEngine { get; set; } |
|||
public virtual bool IsStatic { get; set; } |
|||
protected TextTemplateDefinition() |
|||
{ |
|||
|
|||
} |
|||
|
|||
public TextTemplateDefinition( |
|||
Guid id, |
|||
string name, |
|||
string displayName, |
|||
bool isLayout = false, |
|||
string layout = null, |
|||
bool isInlineLocalized = false, |
|||
string defaultCultureName = null, |
|||
string renderEngine = null) |
|||
: base(id) |
|||
{ |
|||
Name = Check.NotNullOrWhiteSpace(name, nameof(name), TextTemplateDefinitionConsts.MaxNameLength); |
|||
DisplayName = Check.NotNullOrWhiteSpace(displayName, nameof(displayName), TextTemplateDefinitionConsts.MaxDisplayNameLength); |
|||
IsLayout = isLayout; |
|||
Layout = Check.Length(layout, nameof(layout), TextTemplateDefinitionConsts.MaxLayoutLength); |
|||
IsInlineLocalized = isInlineLocalized; |
|||
DefaultCultureName = Check.Length(defaultCultureName, nameof(defaultCultureName), TextTemplateDefinitionConsts.MaxDefaultCultureNameLength); |
|||
RenderEngine = Check.Length(renderEngine, nameof(renderEngine), TextTemplateDefinitionConsts.MaxRenderEngineLength); |
|||
} |
|||
} |
|||
@ -0,0 +1,113 @@ |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Hosting; |
|||
using Microsoft.Extensions.Logging; |
|||
using Microsoft.Extensions.Options; |
|||
using Polly; |
|||
using System; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Threading; |
|||
|
|||
namespace LINGYUN.Abp.TextTemplating; |
|||
public class TextTemplateDefinitionInitializer : ITransientDependency |
|||
{ |
|||
protected IRootServiceProvider RootServiceProvider { get; } |
|||
protected ICancellationTokenProvider CancellationTokenProvider { get; } |
|||
protected AbpTextTemplatingCachingOptions TextTemplatingCachingOptions { get; } |
|||
|
|||
public TextTemplateDefinitionInitializer( |
|||
IRootServiceProvider rootServiceProvider, |
|||
ICancellationTokenProvider cancellationTokenProvider, |
|||
IOptions<AbpTextTemplatingCachingOptions> textTemplatingCachingOptions) |
|||
{ |
|||
RootServiceProvider = rootServiceProvider; |
|||
CancellationTokenProvider = cancellationTokenProvider; |
|||
TextTemplatingCachingOptions = textTemplatingCachingOptions.Value; |
|||
} |
|||
|
|||
public async virtual Task InitializeDynamicTemplates(CancellationToken cancellationToken) |
|||
{ |
|||
if (!TextTemplatingCachingOptions.SaveStaticTemplateDefinitionToDatabase && !TextTemplatingCachingOptions.IsDynamicTemplateDefinitionStoreEnabled) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
using var scope = RootServiceProvider.CreateScope(); |
|||
var applicationLifetime = scope.ServiceProvider.GetService<IHostApplicationLifetime>(); |
|||
var token = applicationLifetime?.ApplicationStopping ?? cancellationToken; |
|||
using (CancellationTokenProvider.Use(cancellationToken)) |
|||
{ |
|||
if (CancellationTokenProvider.Token.IsCancellationRequested) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
await SaveStaticTemplateDefinitionsToDatabaseAsync(scope); |
|||
|
|||
if (CancellationTokenProvider.Token.IsCancellationRequested) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
await PreCacheDynamicTemplateDefinitionsAsync(scope); |
|||
} |
|||
} |
|||
|
|||
private async Task SaveStaticTemplateDefinitionsToDatabaseAsync(IServiceScope serviceScope) |
|||
{ |
|||
if (!TextTemplatingCachingOptions.SaveStaticTemplateDefinitionToDatabase) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
await Policy |
|||
.Handle<Exception>() |
|||
.WaitAndRetryAsync(8, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt) * 10)) |
|||
.ExecuteAsync(async _ => |
|||
{ |
|||
try |
|||
{ |
|||
// ReSharper disable once AccessToDisposedClosure
|
|||
var saver = serviceScope.ServiceProvider.GetRequiredService<IStaticTemplateDefinitionSaver>(); |
|||
|
|||
await saver.SaveAsync(); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
// ReSharper disable once AccessToDisposedClosure
|
|||
serviceScope.ServiceProvider |
|||
.GetService<ILogger<TextTemplateDefinitionInitializer>>()? |
|||
.LogException(ex); |
|||
|
|||
throw; // Polly will catch it
|
|||
} |
|||
}, CancellationTokenProvider.Token); |
|||
|
|||
} |
|||
|
|||
private async Task PreCacheDynamicTemplateDefinitionsAsync(IServiceScope serviceScope) |
|||
{ |
|||
if (!TextTemplatingCachingOptions.IsDynamicTemplateDefinitionStoreEnabled) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
try |
|||
{ |
|||
// ReSharper disable once AccessToDisposedClosure
|
|||
var store = serviceScope.ServiceProvider.GetRequiredService<ITemplateDefinitionStore>(); |
|||
|
|||
await store.GetAllAsync(); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
// ReSharper disable once AccessToDisposedClosure
|
|||
serviceScope.ServiceProvider |
|||
.GetService<ILogger<TextTemplateDefinitionInitializer>>()? |
|||
.LogException(ex); |
|||
|
|||
throw; // Polly will catch it
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,57 @@ |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Options; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.TextTemplating; |
|||
|
|||
namespace LINGYUN.Abp.TextTemplating; |
|||
|
|||
[Dependency(ReplaceServices = true)] |
|||
[ExposeServices( |
|||
typeof(ITemplateRenderer), |
|||
typeof(AbpTemplateRenderer))] |
|||
public class TextTemplateRenderer : AbpTemplateRenderer, ITransientDependency |
|||
{ |
|||
protected ITemplateDefinitionStore TemplateDefinitionStore { get; } |
|||
public TextTemplateRenderer( |
|||
IServiceScopeFactory serviceScopeFactory, |
|||
ITemplateDefinitionManager templateDefinitionManager, |
|||
ITemplateDefinitionStore templateDefinitionStore, |
|||
IOptions<AbpTextTemplatingOptions> options) |
|||
: base(serviceScopeFactory, templateDefinitionManager, options) |
|||
{ |
|||
TemplateDefinitionStore = templateDefinitionStore; |
|||
} |
|||
|
|||
public override async Task<string> RenderAsync( |
|||
string templateName, |
|||
object model = null, |
|||
string cultureName = null, |
|||
Dictionary<string, object> globalContext = null) |
|||
{ |
|||
var templateDefinition = await TemplateDefinitionStore.GetAsync(templateName); |
|||
|
|||
var renderEngine = templateDefinition.RenderEngine; |
|||
|
|||
if (renderEngine.IsNullOrWhiteSpace()) |
|||
{ |
|||
renderEngine = Options.DefaultRenderingEngine; |
|||
} |
|||
|
|||
var providerType = Options.RenderingEngines.GetOrDefault(renderEngine); |
|||
|
|||
if (providerType != null && typeof(ITemplateRenderingEngine).IsAssignableFrom(providerType)) |
|||
{ |
|||
using (var scope = ServiceScopeFactory.CreateScope()) |
|||
{ |
|||
var templateRenderingEngine = (ITemplateRenderingEngine)scope.ServiceProvider.GetRequiredService(providerType); |
|||
return await templateRenderingEngine.RenderAsync(templateName, model, cultureName, globalContext); |
|||
} |
|||
} |
|||
|
|||
throw new AbpException("There is no rendering engine found with template name: " + templateName); |
|||
} |
|||
} |
|||
@ -0,0 +1,55 @@ |
|||
using LINGYUN.Abp.TextTemplating.EntityFrameworkCore; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Linq.Dynamic.Core; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Domain.Repositories.EntityFrameworkCore; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
|
|||
namespace LINGYUN.Abp.TextTemplating; |
|||
public class EfCoreTextTemplateDefinitionRepository : EfCoreRepository<ITextTemplatingDbContext, TextTemplateDefinition, Guid>, ITextTemplateDefinitionRepository |
|||
{ |
|||
public EfCoreTextTemplateDefinitionRepository( |
|||
IDbContextProvider<ITextTemplatingDbContext> dbContextProvider) |
|||
: base(dbContextProvider) |
|||
{ |
|||
} |
|||
|
|||
public async virtual Task<TextTemplateDefinition> FindByNameAsync(string name, CancellationToken cancellationToken = default) |
|||
{ |
|||
return await (await GetDbSetAsync()) |
|||
.Where(x => x.Name == name) |
|||
.FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); |
|||
} |
|||
|
|||
public async virtual Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default) |
|||
{ |
|||
return await (await GetDbSetAsync()) |
|||
.WhereIf(!filter.IsNullOrWhiteSpace(), x => x.Name.Contains(filter) || |
|||
x.DefaultCultureName.Contains(filter) || x.Layout.Contains(filter)) |
|||
.CountAsync(GetCancellationToken(cancellationToken)); |
|||
} |
|||
|
|||
public async virtual Task<List<TextTemplateDefinition>> GetListAsync( |
|||
string filter = null, |
|||
string sorting = "Name", |
|||
int skipCount = 0, |
|||
int maxResultCount = 10, |
|||
CancellationToken cancellationToken = default) |
|||
{ |
|||
if (sorting.IsNullOrWhiteSpace()) |
|||
{ |
|||
sorting = nameof(TextTemplateDefinition.Name); |
|||
} |
|||
|
|||
return await (await GetDbSetAsync()) |
|||
.WhereIf(!filter.IsNullOrWhiteSpace(), x => x.Name.Contains(filter) || |
|||
x.DefaultCultureName.Contains(filter) || x.Layout.Contains(filter)) |
|||
.OrderBy(sorting) |
|||
.PageBy(skipCount, maxResultCount) |
|||
.ToListAsync(GetCancellationToken(cancellationToken)); |
|||
} |
|||
} |
|||
@ -0,0 +1,45 @@ |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp; |
|||
|
|||
namespace LINGYUN.Abp.TextTemplating; |
|||
|
|||
[Controller] |
|||
[Authorize(AbpTextTemplatingPermissions.TextTemplateContent.Default)] |
|||
[RemoteService(Name = AbpTextTemplatingRemoteServiceConsts.RemoteServiceName)] |
|||
[Area(AbpTextTemplatingRemoteServiceConsts.ModuleName)] |
|||
[Route("api/text-templating/templates/content")] |
|||
public class TextTemplateContentController : AbpTextTemplatingControllerBase, ITextTemplateContentAppService |
|||
{ |
|||
private readonly ITextTemplateContentAppService _service; |
|||
|
|||
public TextTemplateContentController(ITextTemplateContentAppService service) |
|||
{ |
|||
_service = service; |
|||
} |
|||
|
|||
[HttpGet] |
|||
[Route("{Name}")] |
|||
[Route("{Culture}/{Name}")] |
|||
public virtual Task<TextTemplateContentDto> GetAsync(TextTemplateContentGetInput input) |
|||
{ |
|||
return _service.GetAsync(input); |
|||
} |
|||
|
|||
[HttpPut] |
|||
[Route("{name}/restore-to-default")] |
|||
[Authorize(AbpTextTemplatingPermissions.TextTemplateContent.Delete)] |
|||
public virtual Task RestoreToDefaultAsync(string name, TextTemplateRestoreInput input) |
|||
{ |
|||
return _service.RestoreToDefaultAsync(name, input); |
|||
} |
|||
|
|||
[HttpPut] |
|||
[Authorize(AbpTextTemplatingPermissions.TextTemplateContent.Update)] |
|||
[Route("{name}")] |
|||
public virtual Task<TextTemplateContentDto> UpdateAsync(string name, TextTemplateContentUpdateDto input) |
|||
{ |
|||
return _service.UpdateAsync(name, input); |
|||
} |
|||
} |
|||
@ -1,59 +0,0 @@ |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Dtos; |
|||
|
|||
namespace LINGYUN.Abp.TextTemplating; |
|||
|
|||
[Controller] |
|||
[Authorize(AbpTextTemplatingPermissions.TextTemplate.Default)] |
|||
[RemoteService(Name = AbpTextTemplatingRemoteServiceConsts.RemoteServiceName)] |
|||
[Area(AbpTextTemplatingRemoteServiceConsts.ModuleName)] |
|||
[Route("api/text-templating/templates")] |
|||
public class TextTemplateController : AbpTextTemplatingControllerBase, ITextTemplateAppService |
|||
{ |
|||
protected ITextTemplateAppService TextTemplateAppService { get; } |
|||
|
|||
public TextTemplateController( |
|||
ITextTemplateAppService textTemplateAppService) |
|||
{ |
|||
TextTemplateAppService = textTemplateAppService; |
|||
} |
|||
|
|||
[HttpGet] |
|||
[Route("{name}")] |
|||
public virtual Task<TextTemplateDefinitionDto> GetAsync(string name) |
|||
{ |
|||
return TextTemplateAppService.GetAsync(name); |
|||
} |
|||
|
|||
[HttpGet] |
|||
[Route("content/{Name}")] |
|||
[Route("content/{Culture}/{Name}")] |
|||
public virtual Task<TextTemplateContentDto> GetContentAsync(TextTemplateContentGetInput input) |
|||
{ |
|||
return TextTemplateAppService.GetContentAsync(input); |
|||
} |
|||
|
|||
[HttpGet] |
|||
public virtual Task<PagedResultDto<TextTemplateDefinitionDto>> GetListAsync(TextTemplateDefinitionGetListInput input) |
|||
{ |
|||
return TextTemplateAppService.GetListAsync(input); |
|||
} |
|||
|
|||
[HttpPut] |
|||
[Route("restore-to-default")] |
|||
[Authorize(AbpTextTemplatingPermissions.TextTemplate.Delete)] |
|||
public virtual Task RestoreToDefaultAsync(TextTemplateRestoreInput input) |
|||
{ |
|||
return TextTemplateAppService.RestoreToDefaultAsync(input); |
|||
} |
|||
|
|||
[HttpPost] |
|||
[Authorize(AbpTextTemplatingPermissions.TextTemplate.Update)] |
|||
public virtual Task<TextTemplateDefinitionDto> UpdateAsync(TextTemplateUpdateInput input) |
|||
{ |
|||
return TextTemplateAppService.UpdateAsync(input); |
|||
} |
|||
} |
|||
@ -0,0 +1,58 @@ |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Dtos; |
|||
|
|||
namespace LINGYUN.Abp.TextTemplating; |
|||
|
|||
[Controller] |
|||
[Authorize(AbpTextTemplatingPermissions.TextTemplateDefinition.Default)] |
|||
[RemoteService(Name = AbpTextTemplatingRemoteServiceConsts.RemoteServiceName)] |
|||
[Area(AbpTextTemplatingRemoteServiceConsts.ModuleName)] |
|||
[Route("api/text-templating/template/definitions")] |
|||
public class TextTemplateDefinitionController : AbpTextTemplatingControllerBase, ITextTemplateDefinitionAppService |
|||
{ |
|||
private readonly ITextTemplateDefinitionAppService _service; |
|||
|
|||
public TextTemplateDefinitionController(ITextTemplateDefinitionAppService service) |
|||
{ |
|||
_service = service; |
|||
} |
|||
|
|||
[Authorize(AbpTextTemplatingPermissions.TextTemplateDefinition.Create)] |
|||
[HttpPost] |
|||
public virtual Task<TextTemplateDefinitionDto> CreateAsync(TextTemplateDefinitionCreateDto input) |
|||
{ |
|||
return _service.CreateAsync(input); |
|||
} |
|||
|
|||
[Authorize(AbpTextTemplatingPermissions.TextTemplateDefinition.Delete)] |
|||
[HttpDelete] |
|||
[Route("{name}")] |
|||
public virtual Task DeleteAsync(string name) |
|||
{ |
|||
return _service.DeleteAsync(name); |
|||
} |
|||
|
|||
[HttpGet] |
|||
[Route("{name}")] |
|||
public virtual Task<TextTemplateDefinitionDto> GetByNameAsync(string name) |
|||
{ |
|||
return _service.GetByNameAsync(name); |
|||
} |
|||
|
|||
[HttpGet] |
|||
public virtual Task<PagedResultDto<TextTemplateDefinitionDto>> GetListAsync(TextTemplateDefinitionGetListInput input) |
|||
{ |
|||
return _service.GetListAsync(input); |
|||
} |
|||
|
|||
[Authorize(AbpTextTemplatingPermissions.TextTemplateDefinition.Update)] |
|||
[HttpPut] |
|||
[Route("{name}")] |
|||
public virtual Task<TextTemplateDefinitionDto> UpdateAsync(string name, TextTemplateDefinitionUpdateDto input) |
|||
{ |
|||
return _service.UpdateAsync(name, input); |
|||
} |
|||
} |
|||
@ -0,0 +1,3 @@ |
|||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> |
|||
<ConfigureAwait /> |
|||
</Weavers> |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue