mirror of
https://gitee.com/yudaocode/yudao-boot-mini.git
synced 2025-12-26 07:06:22 +08:00
Merge branch 'master-jdk17' of https://gitee.com/zhijiantianya/ruoyi-vue-pro
This commit is contained in:
commit
755d5e48cc
25
README.md
25
README.md
@ -232,18 +232,19 @@
|
||||
|
||||
### 微信公众号
|
||||
|
||||
| | 功能 | 描述 |
|
||||
|-----|--------|-------------------------------|
|
||||
| 🚀 | 账号管理 | 配置接入的微信公众号,可支持多个公众号 |
|
||||
| 🚀 | 数据统计 | 统计公众号的用户增减、累计用户、消息概况、接口分析等数据 |
|
||||
| 🚀 | 粉丝管理 | 查看已关注、取关的粉丝列表,可对粉丝进行同步、打标签等操作 |
|
||||
| 🚀 | 消息管理 | 查看粉丝发送的消息列表,可主动回复粉丝消息 |
|
||||
| 🚀 | 自动回复 | 自动回复粉丝发送的消息,支持关注回复、消息回复、关键字回复 |
|
||||
| 🚀 | 标签管理 | 对公众号的标签进行创建、查询、修改、删除等操作 |
|
||||
| 🚀 | 菜单管理 | 自定义公众号的菜单,也可以从公众号同步菜单 |
|
||||
| 🚀 | 素材管理 | 管理公众号的图片、语音、视频等素材,支持在线播放语音、视频 |
|
||||
| 🚀 | 图文草稿箱 | 新增常用的图文素材到草稿箱,可发布到公众号 |
|
||||
| 🚀 | 图文发表记录 | 查看已发布成功的图文素材,支持删除操作 |
|
||||
| | 功能 | 描述 |
|
||||
|----|--------|-------------------------------|
|
||||
| 🚀 | 账号管理 | 配置接入的微信公众号,可支持多个公众号 |
|
||||
| 🚀 | 数据统计 | 统计公众号的用户增减、累计用户、消息概况、接口分析等数据 |
|
||||
| 🚀 | 粉丝管理 | 查看已关注、取关的粉丝列表,可对粉丝进行同步、打标签等操作 |
|
||||
| 🚀 | 消息管理 | 查看粉丝发送的消息列表,可主动回复粉丝消息 |
|
||||
| 🚀 | 模版消息 | 配置和发送模版消息,用于向粉丝推送通知类消息 |
|
||||
| 🚀 | 自动回复 | 自动回复粉丝发送的消息,支持关注回复、消息回复、关键字回复 |
|
||||
| 🚀 | 标签管理 | 对公众号的标签进行创建、查询、修改、删除等操作 |
|
||||
| 🚀 | 菜单管理 | 自定义公众号的菜单,也可以从公众号同步菜单 |
|
||||
| 🚀 | 素材管理 | 管理公众号的图片、语音、视频等素材,支持在线播放语音、视频 |
|
||||
| 🚀 | 图文草稿箱 | 新增常用的图文素材到草稿箱,可发布到公众号 |
|
||||
| 🚀 | 图文发表记录 | 查看已发布成功的图文素材,支持删除操作 |
|
||||
|
||||
### 商城系统
|
||||
|
||||
|
||||
@ -38,6 +38,7 @@ public class MyBatisUtils {
|
||||
public static <T> Page<T> buildPage(PageParam pageParam, Collection<SortingField> sortingFields) {
|
||||
// 页码 + 数量
|
||||
Page<T> page = new Page<>(pageParam.getPageNo(), pageParam.getPageSize());
|
||||
page.setOptimizeJoinOfCountSql(false); // 关联 issue:https://gitee.com/zhijiantianya/yudao-cloud/issues/ID2QLL
|
||||
// 排序字段
|
||||
if (CollUtil.isNotEmpty(sortingFields)) {
|
||||
for (SortingField sortingField : sortingFields) {
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
</description>
|
||||
<properties>
|
||||
<spring-ai.version>1.1.0</spring-ai.version>
|
||||
<alibaba-ai.version>1.0.0.4</alibaba-ai.version>
|
||||
<alibaba-ai.version>1.1.0.0-M5</alibaba-ai.version>
|
||||
<tinyflow.version>1.2.6</tinyflow.version>
|
||||
</properties>
|
||||
|
||||
|
||||
@ -949,11 +949,13 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
Set<String> needSimulateTaskDefinitionKeys = getNeedSimulateTaskDefinitionKeys(bpmnModel, currentTask, targetElement);
|
||||
|
||||
// 4. 执行驳回
|
||||
// 使用 moveExecutionsToSingleActivityId 替换 moveActivityIdsToSingleActivityId 原因:
|
||||
// 当多实例任务回退的时候有问题。相关 issue: https://github.com/flowable/flowable-engine/issues/3944
|
||||
// ① 使用 moveExecutionsToSingleActivityId 替换 moveActivityIdsToSingleActivityId。原因:当多实例任务回退的时候有问题。
|
||||
// 相关 issue: https://github.com/flowable/flowable-engine/issues/3944
|
||||
// ② flowable 7.2.0 版本后,继续使用 moveActivityIdsToSingleActivityId 方法。原因:flowable 7.2.0 版本修复了该问题。
|
||||
// 相关 issue:https://github.com/YunaiV/ruoyi-vue-pro/issues/1018
|
||||
runtimeService.createChangeActivityStateBuilder()
|
||||
.processInstanceId(currentTask.getProcessInstanceId())
|
||||
.moveExecutionsToSingleActivityId(runExecutionIds, reqVO.getTargetTaskDefinitionKey())
|
||||
.moveActivityIdsToSingleActivityId(runExecutionIds, reqVO.getTargetTaskDefinitionKey())
|
||||
// 设置需要预测的任务 ids 的流程变量,用于辅助预测
|
||||
.processVariable(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_TASK_IDS, needSimulateTaskDefinitionKeys)
|
||||
// 设置流程变量(local)节点退回标记, 用于退回到节点,不执行 BpmUserTaskAssignStartUserHandlerTypeEnum 策略,导致自动通过
|
||||
|
||||
@ -91,9 +91,8 @@ public class FileTypeUtils {
|
||||
}
|
||||
// 针对 video 的特殊处理,解决视频地址在移动端播放的兼容性问题
|
||||
if (StrUtil.containsIgnoreCase(mineType, "video")) {
|
||||
response.setHeader("Content-Length", String.valueOf(content.length));
|
||||
response.setHeader("Content-Range", "bytes 0-" + (content.length - 1) + "/" + content.length);
|
||||
response.setHeader("Accept-Ranges", "bytes");
|
||||
response.setHeader("Content-Length", String.valueOf(content.length));
|
||||
}
|
||||
// 输出附件
|
||||
IoUtil.write(response.getOutputStream(), false, content);
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<script lang="ts" setup>
|
||||
import type { Rule } from 'ant-design-vue/es/form';
|
||||
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
||||
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${table.businessName}';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
@ -11,7 +11,7 @@ import { Tinymce as RichTextarea } from '#/components/tinymce';
|
||||
import { ImageUpload, FileUpload } from "#/components/upload";
|
||||
import { message, Tabs, Form, Input, Textarea, Select, RadioGroup, Radio, CheckboxGroup, Checkbox, DatePicker, TreeSelect } from 'ant-design-vue';
|
||||
#if($table.templateType == 2)## 树表需要导入这些
|
||||
import { get${simpleClassName}List } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
||||
import { get${simpleClassName}List } from '#/api/${table.moduleName}/${table.businessName}';
|
||||
import { handleTree } from '@vben/utils'
|
||||
#end
|
||||
## 特殊:主子表专属逻辑
|
||||
@ -24,7 +24,7 @@ import { handleTree } from '@vben/utils'
|
||||
#end
|
||||
|
||||
import { $t } from '#/locales';
|
||||
import { get${simpleClassName}, create${simpleClassName}, update${simpleClassName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
||||
import { get${simpleClassName}, create${simpleClassName}, update${simpleClassName} } from '#/api/${table.moduleName}/${table.businessName}';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<script lang="ts" setup>
|
||||
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
||||
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${table.businessName}';
|
||||
|
||||
import { ref, h, reactive, onMounted, nextTick } from 'vue';
|
||||
|
||||
@ -7,12 +7,13 @@ import { Page, useVbenModal } from '@vben/common-ui';
|
||||
import { DICT_TYPE } from '@vben/constants';
|
||||
import { getDictOptions } from '@vben/hooks';
|
||||
import { useTableToolbar, VbenVxeTableToolbar } from '@vben/plugins/vxe-table';
|
||||
import { cloneDeep, downloadFileFromBlobPart, formatDateTime } from '@vben/utils';
|
||||
import { Button, message,Tabs,Pagination,Form,RangePicker,DatePicker,Select,Input } from 'ant-design-vue';
|
||||
import { cloneDeep, downloadFileFromBlobPart, formatDateTime, isEmpty } from '@vben/utils';
|
||||
import { Button, Card, message, Tabs, Pagination, Form, RangePicker, DatePicker, Select, Input } from 'ant-design-vue';
|
||||
import ${simpleClassName}Form from './modules/form.vue';
|
||||
import { Download, Plus, RefreshCw, Search, Trash2 } from '@vben/icons';
|
||||
import { ContentWrap } from '#/components/content-wrap';
|
||||
import { DictTag } from '#/components/dict-tag';
|
||||
import { VxeColumn, VxeTable } from '#/adapter/vxe-table';
|
||||
import { getRangePickerDefaultProps } from '#/utils/rangePickerProps';
|
||||
|
||||
## 特殊:主子表专属逻辑
|
||||
#if ( $table.templateType == 11 || $table.templateType == 12 )
|
||||
@ -25,13 +26,11 @@ import { VxeColumn, VxeTable } from '#/adapter/vxe-table';
|
||||
|
||||
import { $t } from '#/locales';
|
||||
#if (${table.templateType} == 2)## 树表接口
|
||||
import { handleTree,isEmpty } from '@vben/utils'
|
||||
import { get${simpleClassName}List, delete${simpleClassName}, export${simpleClassName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
||||
import { handleTree } from '@vben/utils'
|
||||
import { get${simpleClassName}List, delete${simpleClassName}, export${simpleClassName} } from '#/api/${table.moduleName}/${table.businessName}';
|
||||
#else## 标准表接口
|
||||
import { isEmpty } from '@vben/utils';
|
||||
import { get${simpleClassName}Page, delete${simpleClassName},#if ($deleteBatchEnable) delete${simpleClassName}List,#end export${simpleClassName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
||||
import { get${simpleClassName}Page, delete${simpleClassName},#if ($deleteBatchEnable) delete${simpleClassName}List,#end export${simpleClassName} } from '#/api/${table.moduleName}/${table.businessName}';
|
||||
#end
|
||||
import { downloadFileFromBlobPart } from '@vben/utils';
|
||||
|
||||
#if ($table.templateType == 12 || $table.templateType == 11) ## 内嵌和erp情况
|
||||
/** 子表的列表 */
|
||||
@ -211,7 +210,7 @@ onMounted(() => {
|
||||
<Page auto-content-height>
|
||||
<FormModal @success="getList" />
|
||||
|
||||
<ContentWrap v-if="!hiddenSearchBar">
|
||||
<Card v-if="!hiddenSearchBar" class="mb-4">
|
||||
<!-- 搜索工作栏 -->
|
||||
<Form
|
||||
:model="queryParams"
|
||||
@ -292,10 +291,10 @@ onMounted(() => {
|
||||
</Button>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</ContentWrap>
|
||||
</Card>
|
||||
|
||||
<!-- 列表 -->
|
||||
<ContentWrap title="${table.classComment}">
|
||||
<Card title="${table.classComment}">
|
||||
<template #extra>
|
||||
<VbenVxeTableToolbar
|
||||
ref="tableToolbarRef"
|
||||
@ -338,9 +337,9 @@ onMounted(() => {
|
||||
批量删除
|
||||
</Button>
|
||||
#end
|
||||
</TableToolbar>
|
||||
</VbenVxeTableToolbar>
|
||||
</template>
|
||||
<vxe-table
|
||||
<VxeTable
|
||||
ref="tableRef"
|
||||
:data="list"
|
||||
#if ( $table.templateType == 2 )
|
||||
@ -368,12 +367,12 @@ onMounted(() => {
|
||||
#end
|
||||
>
|
||||
#if ($table.templateType != 2 && $deleteBatchEnable)
|
||||
<vxe-column type="checkbox" width="40"></vxe-column>
|
||||
<VxeColumn type="checkbox" width="40" />
|
||||
#end
|
||||
## 特殊:主子表专属逻辑
|
||||
#if ( $table.templateType == 12 && $subTables && $subTables.size() > 0 )
|
||||
<!-- 子表的列表 -->
|
||||
<vxe-column type="expand" width="60">
|
||||
<VxeColumn type="expand" width="60">
|
||||
<template #content="{ row }">
|
||||
<!-- 子表的表单 -->
|
||||
<Tabs v-model:active-key="subTabsName" class="mx-8">
|
||||
@ -388,7 +387,7 @@ onMounted(() => {
|
||||
#end
|
||||
</Tabs>
|
||||
</template>
|
||||
</vxe-column>
|
||||
</VxeColumn>
|
||||
#end
|
||||
#foreach($column in $columns)
|
||||
#if ($column.listOperationResult)
|
||||
@ -397,31 +396,31 @@ onMounted(() => {
|
||||
#set ($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
#set ($comment=$column.columnComment)
|
||||
#if ($column.javaType == "LocalDateTime")## 时间类型
|
||||
<vxe-column field="${javaField}" title="${comment}" align="center">
|
||||
<VxeColumn field="${javaField}" title="${comment}" align="center">
|
||||
<template #default="{row}">
|
||||
{{formatDateTime(row.${javaField})}}
|
||||
</template>
|
||||
</vxe-column>
|
||||
</VxeColumn>
|
||||
#elseif($column.dictType && "" != $column.dictType)## 数据字典
|
||||
<vxe-column field="${javaField}" title="${comment}" align="center">
|
||||
<VxeColumn field="${javaField}" title="${comment}" align="center">
|
||||
<template #default="{row}">
|
||||
<dict-tag :type="DICT_TYPE.$dictType.toUpperCase()" :value="row.${javaField}" />
|
||||
</template>
|
||||
</vxe-column>
|
||||
</VxeColumn>
|
||||
#elseif ($table.templateType == 2 && $javaField == $treeNameColumn.javaField)
|
||||
<vxe-column field="${javaField}" title="${comment}" align="center" tree-node/>
|
||||
<VxeColumn field="${javaField}" title="${comment}" align="center" tree-node/>
|
||||
#else
|
||||
<vxe-column field="${javaField}" title="${comment}" align="center" />
|
||||
<VxeColumn field="${javaField}" title="${comment}" align="center" />
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
<vxe-column field="operation" title="操作" align="center">
|
||||
<VxeColumn field="operation" title="操作" align="center">
|
||||
<template #default="{row}">
|
||||
#if ( $table.templateType == 2 )
|
||||
<Button
|
||||
size="small"
|
||||
type="link"
|
||||
@click="handleAppend(row as any)"
|
||||
@click="handleAppend(row)"
|
||||
v-access:code="['${permissionPrefix}:create']"
|
||||
>
|
||||
新增下级
|
||||
@ -430,7 +429,7 @@ onMounted(() => {
|
||||
<Button
|
||||
size="small"
|
||||
type="link"
|
||||
@click="handleEdit(row as any)"
|
||||
@click="handleEdit(row)"
|
||||
v-access:code="['${permissionPrefix}:update']"
|
||||
>
|
||||
{{ $t('ui.actionTitle.edit') }}
|
||||
@ -443,14 +442,14 @@ onMounted(() => {
|
||||
#if ( $table.templateType == 2 )
|
||||
:disabled="!isEmpty(row?.children)"
|
||||
#end
|
||||
@click="handleDelete(row as any)"
|
||||
@click="handleDelete(row)"
|
||||
v-access:code="['${permissionPrefix}:delete']"
|
||||
>
|
||||
{{ $t('ui.actionTitle.delete') }}
|
||||
</Button>
|
||||
</template>
|
||||
</vxe-column>
|
||||
</vxe-table>
|
||||
</VxeColumn>
|
||||
</VxeTable>
|
||||
#if ( $table.templateType != 2 )
|
||||
<!-- 分页 -->
|
||||
<div class="mt-2 flex justify-end">
|
||||
@ -463,9 +462,9 @@ onMounted(() => {
|
||||
/>
|
||||
</div>
|
||||
#end
|
||||
</ContentWrap>
|
||||
</Card>
|
||||
#if ($table.templateType == 11) ## erp情况
|
||||
<ContentWrap>
|
||||
<Card>
|
||||
<!-- 子表的表单 -->
|
||||
<Tabs v-model:active-key="subTabsName">
|
||||
#foreach ($subTable in $subTables)
|
||||
@ -478,7 +477,7 @@ onMounted(() => {
|
||||
</Tabs.TabPane>
|
||||
#end
|
||||
</Tabs>
|
||||
</ContentWrap>
|
||||
</Card>
|
||||
#end
|
||||
</Page>
|
||||
</template>
|
||||
|
||||
@ -4,21 +4,20 @@
|
||||
#set ($subSimpleClassName = $subSimpleClassNames.get($subIndex))
|
||||
<script lang="ts" setup>
|
||||
import type { Rule } from 'ant-design-vue/es/form';
|
||||
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
||||
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${table.businessName}';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
import { DICT_TYPE } from '@vben/constants';
|
||||
import { getDictOptions } from '@vben/hooks';
|
||||
import { cloneDeep, formatDateTime } from '@vben/utils';
|
||||
import { Tinymce as RichTextarea } from '#/components/tinymce';
|
||||
import { ImageUpload, FileUpload } from "#/components/upload";
|
||||
import { message, Tabs, Form, Input, Textarea, Select, RadioGroup, Radio, CheckboxGroup, Checkbox, DatePicker, TreeSelect } from 'ant-design-vue';
|
||||
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { get${subSimpleClassName}, create${subSimpleClassName}, update${subSimpleClassName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
||||
import { get${subSimpleClassName}, create${subSimpleClassName}, update${subSimpleClassName} } from '#/api/${table.moduleName}/${table.businessName}';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const getTitle = computed(() => {
|
||||
|
||||
@ -5,25 +5,27 @@
|
||||
#set ($subClassNameVar = $subClassNameVars.get($subIndex))
|
||||
#set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写
|
||||
<script lang="ts" setup>
|
||||
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
||||
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${table.businessName}';
|
||||
|
||||
import { computed, ref, h, onMounted,watch,nextTick } from 'vue';
|
||||
import { computed, ref, h, onMounted, watch, nextTick } from 'vue';
|
||||
|
||||
import { DICT_TYPE } from '@vben/constants';
|
||||
import { getDictOptions } from '@vben/hooks';
|
||||
|
||||
import { message, Tabs, Form, Input, Textarea,Button, Select, RadioGroup, Radio, CheckboxGroup, Checkbox, DatePicker } from 'ant-design-vue';
|
||||
import { message, Tabs, Form, Input, Textarea, Button, Select, RadioGroup, Radio, CheckboxGroup, Checkbox, DatePicker } from 'ant-design-vue';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
#if ($subTable.subJoinMany) ## 一对多
|
||||
import type { VxeTableInstance } from '#/adapter/vxe-table';
|
||||
import { Plus } from "@vben/icons";
|
||||
import { VxeColumn, VxeTable } from '#/adapter/vxe-table';
|
||||
import { get${subSimpleClassName}ListBy${SubJoinColumnName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
||||
import { ImageUpload, FileUpload } from "#/components/upload";
|
||||
import { get${subSimpleClassName}ListBy${SubJoinColumnName} } from '#/api/${table.moduleName}/${table.businessName}';
|
||||
#else
|
||||
import type { Rule } from 'ant-design-vue/es/form';
|
||||
import { Tinymce as RichTextarea } from '#/components/tinymce';
|
||||
import { get${subSimpleClassName}By${SubJoinColumnName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
||||
import { ImageUpload, FileUpload } from "#/components/upload";
|
||||
import { get${subSimpleClassName}By${SubJoinColumnName} } from '#/api/${table.moduleName}/${table.businessName}';
|
||||
#end
|
||||
|
||||
const props = defineProps<{
|
||||
@ -55,6 +57,7 @@ defineExpose({
|
||||
(row) => !removeRecords.some((removed) => removed.id === row.id),
|
||||
),
|
||||
...insertRecords.map((row: any) => ({ ...row, id: undefined })),
|
||||
];
|
||||
},
|
||||
});
|
||||
|
||||
@ -113,7 +116,7 @@ watch(
|
||||
|
||||
<template>
|
||||
#if ($subTable.subJoinMany) ## 一对多
|
||||
<vxe-table ref="tableRef" :data="list" show-overflow class="mx-4">
|
||||
<VxeTable ref="tableRef" :data="list" show-overflow class="mx-4">
|
||||
#foreach($column in $subColumns)
|
||||
#if ($column.createOperation || $column.updateOperation)
|
||||
#set ($comment = $column.columnComment)
|
||||
@ -128,25 +131,25 @@ watch(
|
||||
#end
|
||||
#if ( $column.id == $subJoinColumn.id) ## 特殊:忽略主子表的 join 字段,不用填写
|
||||
#elseif ($column.htmlType == "input" && !$column.primaryKey)## 忽略主键,不用在表单里
|
||||
<vxe-column field="${javaField}" title="${comment}" align="center">
|
||||
<VxeColumn field="${javaField}" title="${comment}" align="center">
|
||||
<template #default="{ row }">
|
||||
<Input v-model:value="row.${javaField}" />
|
||||
</template>
|
||||
</vxe-column>
|
||||
</VxeColumn>
|
||||
#elseif($column.htmlType == "imageUpload")## 图片上传
|
||||
<vxe-column field="${javaField}" title="${comment}" align="center">
|
||||
<VxeColumn field="${javaField}" title="${comment}" align="center">
|
||||
<template #default="{ row }">
|
||||
<ImageUpload v-model:value="row.${javaField}" />
|
||||
</template>
|
||||
</vxe-column>
|
||||
</VxeColumn>
|
||||
#elseif($column.htmlType == "fileUpload")## 文件上传
|
||||
<vxe-column field="${javaField}" title="${comment}" align="center">
|
||||
<VxeColumn field="${javaField}" title="${comment}" align="center">
|
||||
<template #default="{ row }">
|
||||
<FileUpload v-model:value="row.${javaField}" />
|
||||
</template>
|
||||
</vxe-column>
|
||||
</VxeColumn>
|
||||
#elseif($column.htmlType == "select")## 下拉框
|
||||
<vxe-column field="${javaField}" title="${comment}" align="center">
|
||||
<VxeColumn field="${javaField}" title="${comment}" align="center">
|
||||
<template #default="{ row }">
|
||||
<Select v-model:value="row.${javaField}" placeholder="请选择${comment}">
|
||||
#if ("" != $dictType)## 有数据字典
|
||||
@ -162,9 +165,9 @@ watch(
|
||||
#end
|
||||
</Select>
|
||||
</template>
|
||||
</vxe-column>
|
||||
</VxeColumn>
|
||||
#elseif($column.htmlType == "checkbox")## 多选框
|
||||
<vxe-column field="${javaField}" title="${comment}" align="center">
|
||||
<VxeColumn field="${javaField}" title="${comment}" align="center">
|
||||
<template #default="{ row }">
|
||||
<CheckboxGroup v-model:value="row.${javaField}">
|
||||
#if ("" != $dictType)## 有数据字典
|
||||
@ -180,9 +183,9 @@ watch(
|
||||
#end
|
||||
</CheckboxGroup>
|
||||
</template>
|
||||
</vxe-column>
|
||||
</VxeColumn>
|
||||
#elseif($column.htmlType == "radio")## 单选框
|
||||
<vxe-column field="${javaField}" title="${comment}" align="center">
|
||||
<VxeColumn field="${javaField}" title="${comment}" align="center">
|
||||
<template #default="{ row }">
|
||||
<RadioGroup v-model:value="row.${javaField}">
|
||||
#if ("" != $dictType)## 有数据字典
|
||||
@ -198,9 +201,9 @@ watch(
|
||||
#end
|
||||
</RadioGroup>
|
||||
</template>
|
||||
</vxe-column>
|
||||
</VxeColumn>
|
||||
#elseif($column.htmlType == "datetime")## 时间框
|
||||
<vxe-column field="${javaField}" title="${comment}" align="center">
|
||||
<VxeColumn field="${javaField}" title="${comment}" align="center">
|
||||
<template #default="{ row }">
|
||||
<DatePicker
|
||||
v-model:value="row.${javaField}"
|
||||
@ -209,30 +212,30 @@ watch(
|
||||
valueFormat='x'
|
||||
/>
|
||||
</template>
|
||||
</vxe-column>
|
||||
</VxeColumn>
|
||||
#elseif($column.htmlType == "textarea" || $column.htmlType == "editor")## 文本框
|
||||
<vxe-column field="${javaField}" title="${comment}" align="center">
|
||||
<VxeColumn field="${javaField}" title="${comment}" align="center">
|
||||
<template #default="{ row }">
|
||||
<Textarea v-model:value="row.${javaField}" />
|
||||
</template>
|
||||
</vxe-column>
|
||||
</VxeColumn>
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
<vxe-column field="operation" title="操作" align="center">
|
||||
<VxeColumn field="operation" title="操作" align="center">
|
||||
<template #default="{ row }">
|
||||
<Button
|
||||
size="small"
|
||||
type="link"
|
||||
danger
|
||||
@click="handleDelect(row)"
|
||||
@click="handleDelete(row)"
|
||||
v-access:code="['${permissionPrefix}:delete']"
|
||||
>
|
||||
{{ $t('ui.actionTitle.delete') }}
|
||||
</Button>
|
||||
</template>
|
||||
</vxe-column>
|
||||
</vxe-table>
|
||||
</VxeColumn>
|
||||
</VxeTable>
|
||||
<div class="flex justify-center mt-4">
|
||||
<Button :icon="h(Plus)" type="primary" ghost @click="handleAdd" v-access:code="['${permissionPrefix}:create']">
|
||||
{{ $t('ui.actionTitle.create', ['${subTable.classComment}']) }}
|
||||
|
||||
@ -6,18 +6,18 @@
|
||||
#set ($subSimpleClassName_strikeCase = $subSimpleClassName_strikeCases.get($subIndex))
|
||||
#set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写
|
||||
<script lang="ts" setup>
|
||||
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
||||
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${table.businessName}';
|
||||
import type { VxeTableInstance } from '#/adapter/vxe-table';
|
||||
|
||||
import { reactive,ref, h, nextTick,watch,onMounted } from 'vue';
|
||||
import { reactive, ref, h, nextTick, watch, onMounted } from 'vue';
|
||||
|
||||
import { DICT_TYPE } from '@vben/constants';
|
||||
import { getDictOptions } from '@vben/hooks';
|
||||
|
||||
import { DictTag } from '#/components/dict-tag';
|
||||
import { getRangePickerDefaultProps } from '#/utils';
|
||||
import { getRangePickerDefaultProps } from '#/utils/rangePickerProps';
|
||||
import { VxeColumn, VxeTable } from '#/adapter/vxe-table';
|
||||
import { ContentWrap } from '#/components/content-wrap';
|
||||
import { formatDateTime } from '@vben/utils';
|
||||
|
||||
#if ($table.templateType == 11) ## erp
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
@ -25,19 +25,19 @@ import { useTableToolbar, VbenVxeTableToolbar } from '@vben/plugins/vxe-table';
|
||||
import ${subSimpleClassName}Form from './${subSimpleClassName_strikeCase}-form.vue'
|
||||
import { Tinymce as RichTextarea } from '#/components/tinymce';
|
||||
import { ImageUpload, FileUpload } from "#/components/upload";
|
||||
import { message,Button, Tabs,Pagination, Form, Input, Textarea, Select, RadioGroup, Radio, CheckboxGroup, Checkbox,RangePicker, DatePicker, TreeSelect } from 'ant-design-vue';
|
||||
import { message, Button, Card, Tabs, Pagination, Form, Input, Textarea, Select, RadioGroup, Radio, CheckboxGroup, Checkbox, RangePicker, DatePicker, TreeSelect } from 'ant-design-vue';
|
||||
import { Plus, Trash2 } from '@vben/icons';
|
||||
import { $t } from '#/locales';
|
||||
#end
|
||||
|
||||
#if ($table.templateType == 11) ## erp
|
||||
import { delete${subSimpleClassName},#if ($deleteBatchEnable) delete${subSimpleClassName}List,#end get${subSimpleClassName}Page } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
||||
import { isEmpty } from '@vben/utils';
|
||||
import { delete${subSimpleClassName},#if ($deleteBatchEnable) delete${subSimpleClassName}List,#end get${subSimpleClassName}Page } from '#/api/${table.moduleName}/${table.businessName}';
|
||||
import { isEmpty, cloneDeep } from '@vben/utils';
|
||||
#else
|
||||
#if ($subTable.subJoinMany) ## 一对多
|
||||
import { get${subSimpleClassName}ListBy${SubJoinColumnName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
||||
import { get${subSimpleClassName}ListBy${SubJoinColumnName} } from '#/api/${table.moduleName}/${table.businessName}';
|
||||
#else
|
||||
import { get${subSimpleClassName}By${SubJoinColumnName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
||||
import { get${subSimpleClassName}By${SubJoinColumnName} } from '#/api/${table.moduleName}/${table.businessName}';
|
||||
#end
|
||||
#end
|
||||
|
||||
@ -203,7 +203,7 @@ onMounted(() => {
|
||||
#if ($table.templateType == 11) ## erp
|
||||
<FormModal @success="getList" />
|
||||
<div class="h-[600px]">
|
||||
<ContentWrap v-if="!hiddenSearchBar">
|
||||
<Card v-if="!hiddenSearchBar" class="mb-4">
|
||||
<!-- 搜索工作栏 -->
|
||||
<Form
|
||||
:model="queryParams"
|
||||
@ -284,10 +284,10 @@ onMounted(() => {
|
||||
</Button>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</ContentWrap>
|
||||
</Card>
|
||||
|
||||
<!-- 列表 -->
|
||||
<ContentWrap title="${table.classComment}">
|
||||
<Card title="${table.classComment}">
|
||||
<template #extra>
|
||||
<VbenVxeTableToolbar
|
||||
ref="tableToolbarRef"
|
||||
@ -315,9 +315,9 @@ onMounted(() => {
|
||||
批量删除
|
||||
</Button>
|
||||
#end
|
||||
</TableToolbar>
|
||||
</VbenVxeTableToolbar>
|
||||
</template>
|
||||
<vxe-table
|
||||
<VxeTable
|
||||
ref="tableRef"
|
||||
:data="list"
|
||||
show-overflow
|
||||
@ -328,7 +328,7 @@ onMounted(() => {
|
||||
#end
|
||||
>
|
||||
#if ($deleteBatchEnable)
|
||||
<vxe-column type="checkbox" width="40"></vxe-column>
|
||||
<VxeColumn type="checkbox" width="40" />
|
||||
#end
|
||||
#foreach($column in $subColumns)
|
||||
#if ($column.listOperationResult)
|
||||
@ -336,30 +336,30 @@ onMounted(() => {
|
||||
#set ($javaField = $column.javaField)
|
||||
#set ($comment=$column.columnComment)
|
||||
#if ($column.javaType == "LocalDateTime")## 时间类型
|
||||
<vxe-column field="${javaField}" title="${comment}" align="center">
|
||||
<VxeColumn field="${javaField}" title="${comment}" align="center">
|
||||
<template #default="{row}">
|
||||
{{formatDateTime(row.${javaField})}}
|
||||
</template>
|
||||
</vxe-column>
|
||||
</VxeColumn>
|
||||
#elseif($column.dictType && "" != $column.dictType)## 数据字典
|
||||
<vxe-column field="${javaField}" title="${comment}" align="center">
|
||||
<VxeColumn field="${javaField}" title="${comment}" align="center">
|
||||
<template #default="{row}">
|
||||
<dict-tag :type="DICT_TYPE.$dictType.toUpperCase()" :value="row.${javaField}" />
|
||||
</template>
|
||||
</vxe-column>
|
||||
</VxeColumn>
|
||||
#elseif ($table.templateType == 2 && $javaField == $treeNameColumn.javaField)
|
||||
<vxe-column field="${javaField}" title="${comment}" align="center" tree-node/>
|
||||
<VxeColumn field="${javaField}" title="${comment}" align="center" tree-node/>
|
||||
#else
|
||||
<vxe-column field="${javaField}" title="${comment}" align="center" />
|
||||
<VxeColumn field="${javaField}" title="${comment}" align="center" />
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
<vxe-column field="operation" title="操作" align="center">
|
||||
<VxeColumn field="operation" title="操作" align="center">
|
||||
<template #default="{row}">
|
||||
<Button
|
||||
size="small"
|
||||
type="link"
|
||||
@click="handleEdit(row as any)"
|
||||
@click="handleEdit(row)"
|
||||
v-access:code="['${permissionPrefix}:update']"
|
||||
>
|
||||
{{ $t('ui.actionTitle.edit') }}
|
||||
@ -369,14 +369,14 @@ onMounted(() => {
|
||||
type="link"
|
||||
danger
|
||||
class="ml-2"
|
||||
@click="handleDelete(row as any)"
|
||||
@click="handleDelete(row)"
|
||||
v-access:code="['${permissionPrefix}:delete']"
|
||||
>
|
||||
{{ $t('ui.actionTitle.delete') }}
|
||||
</Button>
|
||||
</template>
|
||||
</vxe-column>
|
||||
</vxe-table>
|
||||
</VxeColumn>
|
||||
</VxeTable>
|
||||
<!-- 分页 -->
|
||||
<div class="mt-2 flex justify-end">
|
||||
<Pagination
|
||||
@ -387,11 +387,11 @@ onMounted(() => {
|
||||
@change="getList"
|
||||
/>
|
||||
</div>
|
||||
</ContentWrap>
|
||||
</Card>
|
||||
</div>
|
||||
#else
|
||||
<ContentWrap title="${subTable.classComment}列表">
|
||||
<vxe-table
|
||||
<Card title="${subTable.classComment}列表">
|
||||
<VxeTable
|
||||
:data="list"
|
||||
show-overflow
|
||||
:loading="loading"
|
||||
@ -402,23 +402,23 @@ onMounted(() => {
|
||||
#set ($javaField = $column.javaField)
|
||||
#set ($comment=$column.columnComment)
|
||||
#if ($column.javaType == "LocalDateTime")## 时间类型
|
||||
<vxe-column field="${javaField}" title="${comment}" align="center">
|
||||
<VxeColumn field="${javaField}" title="${comment}" align="center">
|
||||
<template #default="{row}">
|
||||
{{formatDateTime(row.${javaField})}}
|
||||
</template>
|
||||
</vxe-column>
|
||||
</VxeColumn>
|
||||
#elseif($column.dictType && "" != $column.dictType)## 数据字典
|
||||
<vxe-column field="${javaField}" title="${comment}" align="center">
|
||||
<VxeColumn field="${javaField}" title="${comment}" align="center">
|
||||
<template #default="{row}">
|
||||
<dict-tag :type="DICT_TYPE.$dictType.toUpperCase()" :value="row.${javaField}" />
|
||||
</template>
|
||||
</vxe-column>
|
||||
</VxeColumn>
|
||||
#else
|
||||
<vxe-column field="${javaField}" title="${comment}" align="center" />
|
||||
<VxeColumn field="${javaField}" title="${comment}" align="center" />
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
</vxe-table>
|
||||
</ContentWrap>
|
||||
</VxeTable>
|
||||
</Card>
|
||||
#end
|
||||
</template>
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
<script lang="ts" setup>
|
||||
import type { ${apiName} } from '#/api/${table.moduleName}/${table.businessName}';
|
||||
|
||||
import { computed, ref, h, onMounted,watch,nextTick } from 'vue';
|
||||
import { computed, ref, h, onMounted, watch, nextTick } from 'vue';
|
||||
|
||||
import { $t } from '#/locales';
|
||||
|
||||
@ -16,7 +16,6 @@
|
||||
import { Plus } from "@vben/icons";
|
||||
import { Button, Tabs, Checkbox, Input, Textarea, Select,RadioGroup,CheckboxGroup, DatePicker } from 'ant-design-vue';
|
||||
import { ImageUpload, FileUpload } from "#/components/upload";
|
||||
import type { OnActionClickParams } from '#/adapter/vxe-table';
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { use${subSimpleClassName}GridEditColumns } from '../data';
|
||||
import { get${subSimpleClassName}ListBy${SubJoinColumnName} } from '#/api/${table.moduleName}/${table.businessName}';
|
||||
@ -31,22 +30,9 @@ const props = defineProps<{
|
||||
}>()
|
||||
|
||||
#if ($subTable.subJoinMany) ## 一对多
|
||||
/** 表格操作按钮的回调函数 */
|
||||
function onActionClick({
|
||||
code,
|
||||
row,
|
||||
}: OnActionClickParams<${apiName}.${subSimpleClassName}>) {
|
||||
switch (code) {
|
||||
case 'delete': {
|
||||
handleDelete(row);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions: {
|
||||
columns: use${subSimpleClassName}GridEditColumns(onActionClick),
|
||||
columns: use${subSimpleClassName}GridEditColumns(),
|
||||
border: true,
|
||||
showOverflow: true,
|
||||
autoResize: true,
|
||||
@ -186,6 +172,17 @@ watch(
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
<template #actions="{ row }">
|
||||
<Button
|
||||
size="small"
|
||||
type="link"
|
||||
danger
|
||||
@click="handleDelete(row)"
|
||||
v-access:code="['${subTable.moduleName}:${simpleClassName_strikeCase}:delete']"
|
||||
>
|
||||
{{ $t('ui.actionTitle.delete') }}
|
||||
</Button>
|
||||
</template>
|
||||
</Grid>
|
||||
<div class="flex justify-center -mt-4">
|
||||
<Button :icon="h(Plus)" type="primary" ghost @click="handleAdd" v-access:code="['${subTable.moduleName}:${simpleClassName_strikeCase}:create']">
|
||||
|
||||
@ -82,7 +82,7 @@ async function handleDeleteBatch() {
|
||||
try {
|
||||
await delete${subSimpleClassName}List(checkedIds.value);
|
||||
checkedIds.value = [];
|
||||
message.success($t('ui.actionMessage.deleteSuccess', [row.id]));
|
||||
message.success($t('ui.actionMessage.deleteSuccess'));
|
||||
handleRefresh();
|
||||
} finally {
|
||||
hideLoading();
|
||||
@ -134,7 +134,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
#else
|
||||
columns: use${subSimpleClassName}GridColumns(),
|
||||
pagerConfig: {
|
||||
nabled: false,
|
||||
enabled: false,
|
||||
},
|
||||
toolbarConfig: {
|
||||
enabled: false,
|
||||
|
||||
@ -146,7 +146,7 @@ public class IotProductController {
|
||||
public CommonResult<List<IotProductRespVO>> getProductSimpleList() {
|
||||
List<IotProductDO> list = productService.getProductList();
|
||||
return success(convertList(list, product -> // 只返回 id、name 字段
|
||||
new IotProductRespVO().setId(product.getId()).setName(product.getName())
|
||||
new IotProductRespVO().setId(product.getId()).setName(product.getName()).setStatus(product.getStatus())
|
||||
.setDeviceType(product.getDeviceType()).setLocationType(product.getLocationType())));
|
||||
}
|
||||
|
||||
|
||||
@ -241,13 +241,13 @@ public class IotSceneRuleServiceImpl implements IotSceneRuleService {
|
||||
*/
|
||||
private List<IotSceneRuleDO> getMatchedSceneRuleListByMessage(IotDeviceMessage message) {
|
||||
// 1.1 通过 deviceId 获取设备信息
|
||||
IotDeviceDO device = getSelf().deviceService.getDeviceFromCache(message.getDeviceId());
|
||||
IotDeviceDO device = deviceService.getDeviceFromCache(message.getDeviceId());
|
||||
if (device == null) {
|
||||
log.warn("[getMatchedSceneRuleListByMessage][设备({}) 不存在]", message.getDeviceId());
|
||||
return ListUtil.of();
|
||||
}
|
||||
// 1.2 通过 productId 获取产品信息
|
||||
IotProductDO product = getSelf().productService.getProductFromCache(device.getProductId());
|
||||
IotProductDO product = productService.getProductFromCache(device.getProductId());
|
||||
if (product == null) {
|
||||
log.warn("[getMatchedSceneRuleListByMessage][产品({}) 不存在]", device.getProductId());
|
||||
return ListUtil.of();
|
||||
|
||||
@ -48,13 +48,13 @@ public class IotDeviceEventPostTriggerMatcher implements IotSceneRuleTriggerMatc
|
||||
// 2. 对于事件触发器,通常不需要检查操作符和值,只要事件发生即匹配
|
||||
// 但如果配置了操作符和值,则需要进行条件匹配
|
||||
if (StrUtil.isNotBlank(trigger.getOperator()) && StrUtil.isNotBlank(trigger.getValue())) {
|
||||
Object eventData = message.getData();
|
||||
if (eventData == null) {
|
||||
IotSceneRuleMatcherHelper.logTriggerMatchFailure(message, trigger, "消息中事件数据为空");
|
||||
Object eventParams = message.getParams();
|
||||
if (eventParams == null) {
|
||||
IotSceneRuleMatcherHelper.logTriggerMatchFailure(message, trigger, "消息中事件参数为空");
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean matched = IotSceneRuleMatcherHelper.evaluateCondition(eventData, trigger.getOperator(), trigger.getValue());
|
||||
boolean matched = IotSceneRuleMatcherHelper.evaluateCondition(eventParams, trigger.getOperator(), trigger.getValue());
|
||||
if (!matched) {
|
||||
IotSceneRuleMatcherHelper.logTriggerMatchFailure(message, trigger, "事件数据条件不匹配");
|
||||
return false;
|
||||
|
||||
@ -0,0 +1,44 @@
|
||||
### 请求 /mp/message-template/get 接口 => 成功
|
||||
GET {{baseUrl}}/mp/message-template/get?id=1
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{token}}
|
||||
tenant-id: {{adminTenantId}}
|
||||
|
||||
### 请求 /mp/message-template/list 接口 => 成功
|
||||
GET {{baseUrl}}/mp/message-template/list?accountId=1
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{token}}
|
||||
tenant-id: {{adminTenantId}}
|
||||
|
||||
### 请求 /mp/message-template/delete 接口 => 成功
|
||||
DELETE {{baseUrl}}/mp/message-template/delete?id=1
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{token}}
|
||||
tenant-id: {{adminTenantId}}
|
||||
|
||||
### 请求 /mp/message-template/sync 接口 => 成功
|
||||
POST {{baseUrl}}/mp/message-template/sync?accountId=5
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{token}}
|
||||
tenant-id: {{adminTenantId}}
|
||||
|
||||
### 请求 /mp/message-template/send 接口 => 成功
|
||||
POST {{baseUrl}}/mp/message-template/send
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{token}}
|
||||
tenant-id: {{adminTenantId}}
|
||||
|
||||
{
|
||||
"id": 66,
|
||||
"userId": 65,
|
||||
"url": "https://example.com",
|
||||
"data": {
|
||||
"result": "领奖成功",
|
||||
"withdrawMoney": "1000.00元",
|
||||
"withdrawTime": "2024-01-01 10:00:00",
|
||||
"cardInfo": "工商银行(尾号1234)",
|
||||
"arrivedTime": "2024-01-01 10:30:00"
|
||||
}
|
||||
}
|
||||
|
||||
// "miniprogram": "{\"appid\":\"wx1234567890\",\"pagepath\":\"pages/index/index\"}",
|
||||
@ -0,0 +1,76 @@
|
||||
package cn.iocoder.yudao.module.mp.controller.admin.message;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.mp.controller.admin.message.vo.template.MpMessageTemplateListReqVO;
|
||||
import cn.iocoder.yudao.module.mp.controller.admin.message.vo.template.MpMessageTemplateRespVO;
|
||||
import cn.iocoder.yudao.module.mp.controller.admin.message.vo.template.MpMessageTemplateSendReqVO;
|
||||
import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpMessageTemplateDO;
|
||||
import cn.iocoder.yudao.module.mp.service.message.MpMessageTemplateService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - 公众号模版消息")
|
||||
@RestController
|
||||
@RequestMapping("/mp/message-template")
|
||||
@Validated
|
||||
public class MpMessageTemplateController {
|
||||
|
||||
@Resource
|
||||
private MpMessageTemplateService messageTemplateService;
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除模版消息")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('mp:message-template:delete')")
|
||||
public CommonResult<Boolean> deleteMessageTemplate(@RequestParam("id") Long id) {
|
||||
messageTemplateService.deleteMessageTemplate(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得模版消息")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('mp:message-template:query')")
|
||||
public CommonResult<MpMessageTemplateRespVO> getMessageTemplate(@RequestParam("id") Long id) {
|
||||
MpMessageTemplateDO msgTemplate = messageTemplateService.getMessageTemplate(id);
|
||||
return success(BeanUtils.toBean(msgTemplate, MpMessageTemplateRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获得模版消息列表")
|
||||
@Parameter(name = "accountId", description = "公众号账号的编号", required = true, example = "2048")
|
||||
@PreAuthorize("@ss.hasPermission('mp:message-template:query')")
|
||||
public CommonResult<List<MpMessageTemplateRespVO>> getMessageTemplateList(MpMessageTemplateListReqVO listReqVO) {
|
||||
List<MpMessageTemplateDO> list = messageTemplateService.getMessageTemplateList(listReqVO);
|
||||
return success(BeanUtils.toBean(list, MpMessageTemplateRespVO.class));
|
||||
}
|
||||
|
||||
@PostMapping("/sync")
|
||||
@Operation(summary = "同步公众号模板")
|
||||
@Parameter(name = "accountId", description = "公众号账号的编号", required = true, example = "2048")
|
||||
@PreAuthorize("@ss.hasPermission('mp:message-template:sync')")
|
||||
public CommonResult<Boolean> syncMessageTemplate(@RequestParam("accountId") Long accountId) {
|
||||
messageTemplateService.syncMessageTemplate(accountId);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PostMapping("/send")
|
||||
@Operation(summary = "给粉丝发送模版消息")
|
||||
@PreAuthorize("@ss.hasPermission('mp:message-template:send')")
|
||||
public CommonResult<Boolean> sendMessageTemplate(@Valid @RequestBody MpMessageTemplateSendReqVO sendReqVO) {
|
||||
messageTemplateService.sendMessageTempalte(sendReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package cn.iocoder.yudao.module.mp.controller.admin.message.vo.template;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 公众号模版消息列表 Request VO")
|
||||
@Data
|
||||
public class MpMessageTemplateListReqVO {
|
||||
|
||||
@Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048")
|
||||
@NotNull(message = "公众号账号的编号不能为空")
|
||||
private Long accountId;
|
||||
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
package cn.iocoder.yudao.module.mp.controller.admin.message.vo.template;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 公众号模版消息 Response VO")
|
||||
@Data
|
||||
public class MpMessageTemplateRespVO {
|
||||
|
||||
@Schema(description = "模版主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "7019")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long accountId;
|
||||
|
||||
@Schema(description = "appId", requiredMode = Schema.RequiredMode.REQUIRED, example = "wx1234567890abcdef")
|
||||
private String appId;
|
||||
|
||||
@Schema(description = "公众号模板ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "IjkGxO9M_mC9pE5Yl7QYJk1h0Dj2N4lC3oOp6rRsT8u")
|
||||
private String templateId;
|
||||
|
||||
@Schema(description = "标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "订单状态提醒")
|
||||
private String title;
|
||||
|
||||
@Schema(description = "模板内容", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String content;
|
||||
|
||||
@Schema(description = "模板示例")
|
||||
private String example;
|
||||
|
||||
@Schema(description = "模板所属行业的一级行业", example = "电商")
|
||||
private String primaryIndustry;
|
||||
|
||||
@Schema(description = "模板所属行业的二级行业", example = "商品售后")
|
||||
private String deputyIndustry;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
package cn.iocoder.yudao.module.mp.controller.admin.message.vo.template;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Schema(description = "管理后台 - 公众号消息模版发送 Request VO") // 关联 https://developers.weixin.qq.com/doc/service/api/notify/template/api_sendtemplatemessage.html 文档
|
||||
@Data
|
||||
public class MpMessageTemplateSendReqVO {
|
||||
|
||||
@Schema(description = "模版主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "7019")
|
||||
@NotNull(message = "模版主键不能为空")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "公众号粉丝的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
@NotNull(message = "公众号粉丝的编号不能为空")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "模板跳转链接")
|
||||
private String url;
|
||||
|
||||
@Schema(description = "跳转小程序时填写")
|
||||
private String miniprogram;
|
||||
|
||||
@Schema(description = "模板内容")
|
||||
private Map<String, String> data;
|
||||
|
||||
}
|
||||
@ -0,0 +1,69 @@
|
||||
package cn.iocoder.yudao.module.mp.dal.dataobject.message;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* 公众号模版消息 DO
|
||||
*
|
||||
* @author dengsl
|
||||
*/
|
||||
@TableName("mp_message_template")
|
||||
@KeySequence("mp_message_template_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class MpMessageTemplateDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 公众号账号的编号
|
||||
*
|
||||
* 关联 {@link MpAccountDO#getId()}
|
||||
*/
|
||||
private Long accountId;
|
||||
/**
|
||||
* 公众号 appId
|
||||
*
|
||||
* 冗余 {@link MpAccountDO#getAppId()}
|
||||
*/
|
||||
private String appId;
|
||||
/**
|
||||
* 公众号模板 ID
|
||||
*/
|
||||
private String templateId;
|
||||
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
private String title;
|
||||
/**
|
||||
* 模板内容
|
||||
*/
|
||||
private String content;
|
||||
/**
|
||||
* 模板示例
|
||||
*/
|
||||
private String example;
|
||||
|
||||
/**
|
||||
* 模板所属行业的一级行业
|
||||
*/
|
||||
private String primaryIndustry;
|
||||
/**
|
||||
* 模板所属行业的二级行业
|
||||
*/
|
||||
private String deputyIndustry;
|
||||
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package cn.iocoder.yudao.module.mp.dal.mysql.message;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.mp.controller.admin.message.vo.template.MpMessageTemplateListReqVO;
|
||||
import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpMessageTemplateDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface MpMessageTemplateMapper extends BaseMapperX<MpMessageTemplateDO> {
|
||||
|
||||
default List<MpMessageTemplateDO> selectList(MpMessageTemplateListReqVO listReqVO) {
|
||||
return selectList(MpMessageTemplateDO::getAccountId, listReqVO.getAccountId());
|
||||
}
|
||||
|
||||
}
|
||||
@ -61,4 +61,10 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode AUTO_REPLY_ADD_MESSAGE_FAIL_EXISTS = new ErrorCode(1_006_009_002, "操作失败,原因:已存在该消息类型的回复");
|
||||
ErrorCode AUTO_REPLY_ADD_KEYWORD_FAIL_EXISTS = new ErrorCode(1_006_009_003, "操作失败,原因:已关在该关键字的回复");
|
||||
|
||||
// ========== 公众号模版消息 1-006-010-000 ============
|
||||
ErrorCode MESSAGE_TEMPLATE_NOT_EXISTS = new ErrorCode(1_006_010_000, "模版消息不存在");
|
||||
ErrorCode MESSAGE_TEMPLATE_DELETE_FAIL = new ErrorCode(1_006_010_002, "删除模版消息失败,原因:{}");
|
||||
ErrorCode MESSAGE_TEMPLATE_SYNC_FAIL = new ErrorCode(1_006_010_003, "同步模版消息失败,原因:{}");
|
||||
ErrorCode MESSAGE_TEMPLATE_SEND_FAIL = new ErrorCode(1_006_010_004, "发送模版消息失败,原因:{}");
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,53 @@
|
||||
package cn.iocoder.yudao.module.mp.service.message;
|
||||
|
||||
import cn.iocoder.yudao.module.mp.controller.admin.message.vo.template.MpMessageTemplateListReqVO;
|
||||
import cn.iocoder.yudao.module.mp.controller.admin.message.vo.template.MpMessageTemplateSendReqVO;
|
||||
import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpMessageTemplateDO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 公众号模版消息 Service 接口
|
||||
*
|
||||
* @author dengsl
|
||||
*/
|
||||
public interface MpMessageTemplateService {
|
||||
|
||||
/**
|
||||
* 删除模版消息
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteMessageTemplate(Long id);
|
||||
|
||||
/**
|
||||
* 获得模版消息
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 模版消息
|
||||
*/
|
||||
MpMessageTemplateDO getMessageTemplate(Long id);
|
||||
|
||||
/**
|
||||
* 获得模版消息列表
|
||||
*
|
||||
* @param listReqVO 查询条件
|
||||
* @return 模版消息列表
|
||||
*/
|
||||
List<MpMessageTemplateDO> getMessageTemplateList(MpMessageTemplateListReqVO listReqVO);
|
||||
|
||||
/**
|
||||
* 同步公众号已添加的模版消息
|
||||
*
|
||||
* @param accountId 公众号账号的编号
|
||||
*/
|
||||
void syncMessageTemplate(Long accountId);
|
||||
|
||||
/**
|
||||
* 使用公众号,给粉丝发送【模版】消息
|
||||
*
|
||||
* @param sendReqVO 消息内容
|
||||
*/
|
||||
void sendMessageTempalte(MpMessageTemplateSendReqVO sendReqVO);
|
||||
|
||||
}
|
||||
@ -0,0 +1,176 @@
|
||||
package cn.iocoder.yudao.module.mp.service.message;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.mp.controller.admin.message.vo.template.MpMessageTemplateListReqVO;
|
||||
import cn.iocoder.yudao.module.mp.controller.admin.message.vo.template.MpMessageTemplateSendReqVO;
|
||||
import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO;
|
||||
import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpMessageTemplateDO;
|
||||
import cn.iocoder.yudao.module.mp.dal.dataobject.user.MpUserDO;
|
||||
import cn.iocoder.yudao.module.mp.dal.mysql.message.MpMessageTemplateMapper;
|
||||
import cn.iocoder.yudao.module.mp.framework.mp.core.MpServiceFactory;
|
||||
import cn.iocoder.yudao.module.mp.service.account.MpAccountService;
|
||||
import cn.iocoder.yudao.module.mp.service.user.MpUserService;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.mp.bean.template.WxMpTemplate;
|
||||
import me.chanjar.weixin.mp.bean.template.WxMpTemplateData;
|
||||
import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
|
||||
import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 公众号模版消息 Service 实现类
|
||||
*
|
||||
* @author dengsl
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
@Slf4j
|
||||
public class MpMessageTemplateServiceImpl implements MpMessageTemplateService {
|
||||
|
||||
@Resource
|
||||
@Lazy // 延迟加载,为了解决延迟加载
|
||||
private MpServiceFactory mpServiceFactory;
|
||||
|
||||
@Resource
|
||||
private MpMessageTemplateMapper messageTemplateMapper;
|
||||
|
||||
@Resource
|
||||
private MpAccountService mpAccountService;
|
||||
|
||||
@Resource
|
||||
private MpUserService mpUserService;
|
||||
|
||||
@Override
|
||||
public void deleteMessageTemplate(Long id) {
|
||||
// 校验存在
|
||||
MpMessageTemplateDO template = validateMsgTemplateExists(id);
|
||||
|
||||
// 第一步,删除模板到公众号平台
|
||||
try {
|
||||
mpServiceFactory.getRequiredMpService(template.getAppId())
|
||||
.getTemplateMsgService().delPrivateTemplate(template.getTemplateId());
|
||||
} catch (WxErrorException e) {
|
||||
throw exception(MESSAGE_TEMPLATE_DELETE_FAIL, e.getError().getErrorMsg());
|
||||
}
|
||||
|
||||
// 第二步,删除模板到数据库
|
||||
messageTemplateMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private MpMessageTemplateDO validateMsgTemplateExists(Long id) {
|
||||
MpMessageTemplateDO template = messageTemplateMapper.selectById(id);
|
||||
if (template == null) {
|
||||
throw exception(MESSAGE_TEMPLATE_NOT_EXISTS);
|
||||
}
|
||||
return template;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MpMessageTemplateDO getMessageTemplate(Long id) {
|
||||
return messageTemplateMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MpMessageTemplateDO> getMessageTemplateList(MpMessageTemplateListReqVO listReqVO) {
|
||||
return messageTemplateMapper.selectList(listReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void syncMessageTemplate(Long accountId) {
|
||||
MpAccountDO account = mpAccountService.getRequiredAccount(accountId);
|
||||
|
||||
// 第一步,从公众号平台获取最新的模板列表
|
||||
List<WxMpTemplate> wxTemplates;
|
||||
try {
|
||||
wxTemplates = mpServiceFactory.getRequiredMpService(accountId)
|
||||
.getTemplateMsgService().getAllPrivateTemplate();
|
||||
} catch (WxErrorException e) {
|
||||
throw exception(MESSAGE_TEMPLATE_SYNC_FAIL, e.getError().getErrorMsg());
|
||||
}
|
||||
|
||||
// 第二步,合并更新回自己的数据库
|
||||
Map<String, MpMessageTemplateDO> templateMap = convertMap(
|
||||
messageTemplateMapper.selectList(new LambdaQueryWrapperX<MpMessageTemplateDO>()
|
||||
.eq(MpMessageTemplateDO::getAppId, account.getAppId())),
|
||||
MpMessageTemplateDO::getTemplateId);
|
||||
wxTemplates.forEach(wxTemplate -> {
|
||||
MpMessageTemplateDO template = templateMap.remove(wxTemplate.getTemplateId());
|
||||
// 情况一,不存在,新增
|
||||
if (template == null) {
|
||||
template = new MpMessageTemplateDO().setAccountId(account.getId()).setAppId(account.getAppId())
|
||||
.setTemplateId(wxTemplate.getTemplateId()).setTitle(wxTemplate.getTitle())
|
||||
.setContent(wxTemplate.getContent()).setExample(wxTemplate.getExample())
|
||||
.setPrimaryIndustry(wxTemplate.getPrimaryIndustry()).setDeputyIndustry(wxTemplate.getDeputyIndustry());
|
||||
messageTemplateMapper.insert(template);
|
||||
return;
|
||||
}
|
||||
// 情况二,存在,则更新
|
||||
messageTemplateMapper.updateById(new MpMessageTemplateDO().setId(template.getId())
|
||||
.setTitle(wxTemplate.getTitle()).setContent(wxTemplate.getContent()).setExample(wxTemplate.getExample())
|
||||
.setPrimaryIndustry(wxTemplate.getPrimaryIndustry()).setDeputyIndustry(wxTemplate.getDeputyIndustry()));
|
||||
});
|
||||
// 情况三,部分模板已经不存在了,删除
|
||||
if (CollUtil.isNotEmpty(templateMap)) {
|
||||
messageTemplateMapper.deleteByIds(convertList(templateMap.values(), MpMessageTemplateDO::getId));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessageTempalte(MpMessageTemplateSendReqVO sendReqVO) {
|
||||
// 获得关联信息
|
||||
MpUserDO user = mpUserService.getRequiredUser(sendReqVO.getUserId());
|
||||
MpMessageTemplateDO template = validateMsgTemplateExists(sendReqVO.getId());
|
||||
|
||||
// 发送模版消息
|
||||
WxMpTemplateMessage templateMessage = buildTemplateMessage(template, user, sendReqVO);
|
||||
try {
|
||||
mpServiceFactory.getRequiredMpService(template.getAppId())
|
||||
.getTemplateMsgService().sendTemplateMsg(templateMessage);
|
||||
} catch (WxErrorException e) {
|
||||
throw exception(MESSAGE_TEMPLATE_SEND_FAIL, e.getError().getErrorMsg());
|
||||
}
|
||||
|
||||
// 不用记录 MpMessageDO 记录,因为,微信会主动推送,可见文档 https://developers.weixin.qq.com/doc/service/guide/product/template_message/Template_Message_Interface.html
|
||||
}
|
||||
|
||||
private WxMpTemplateMessage buildTemplateMessage(MpMessageTemplateDO msgTemplateDO, MpUserDO user,
|
||||
MpMessageTemplateSendReqVO sendReqVO) {
|
||||
List<WxMpTemplateData> data = new ArrayList<>();
|
||||
WxMpTemplateMessage.WxMpTemplateMessageBuilder builder = WxMpTemplateMessage.builder()
|
||||
.templateId(msgTemplateDO.getTemplateId())
|
||||
.data(data)
|
||||
.toUser(user.getOpenid());
|
||||
// 设置跳转链接
|
||||
if (StrUtil.isNotBlank(sendReqVO.getUrl())) {
|
||||
builder.url(sendReqVO.getUrl());
|
||||
}
|
||||
// 设置小程序跳转
|
||||
if (StrUtil.isNotBlank(sendReqVO.getMiniprogram())) {
|
||||
// https://developers.weixin.qq.com/doc/service/api/notify/template/api_sendtemplatemessage.html#Body__miniprogram
|
||||
builder.miniProgram(JsonUtils.parseObject(sendReqVO.getMiniprogram(), WxMpTemplateMessage.MiniProgram.class));
|
||||
}
|
||||
// 设置模板数据
|
||||
if (sendReqVO.getData() != null) {
|
||||
sendReqVO.getData().forEach((key, value) -> data.add(new WxMpTemplateData(key, value)));
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.module.pay.controller.app.order;
|
||||
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
@ -46,13 +47,21 @@ public class AppPayOrderController {
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得支付订单")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024"),
|
||||
@Parameter(name = "id", description = "编号", example = "1024"),
|
||||
@Parameter(name = "no", description = "支付订单号", example = "Pxxx"),
|
||||
@Parameter(name = "sync", description = "是否同步", example = "true")
|
||||
})
|
||||
public CommonResult<PayOrderRespVO> getOrder(@RequestParam("id") Long id,
|
||||
public CommonResult<PayOrderRespVO> getOrder(@RequestParam(value = "id", required = false) Long id,
|
||||
@RequestParam(value = "no", required = false) String no,
|
||||
@RequestParam(value = "sync", required = false) Boolean sync) {
|
||||
PayOrderDO order = payOrderService.getOrder(id);
|
||||
if (order== null) {
|
||||
PayOrderDO order = null;
|
||||
if (CharSequenceUtil.isNotEmpty(no)) {
|
||||
order = payOrderService.getOrder(no);
|
||||
}
|
||||
if (ObjUtil.isNull(order) && ObjUtil.isNotNull(id)) {
|
||||
order = payOrderService.getOrder(id);
|
||||
}
|
||||
if (order == null) {
|
||||
return success(null);
|
||||
}
|
||||
// 重要:校验订单是否是当前用户,避免越权
|
||||
@ -65,7 +74,7 @@ public class AppPayOrderController {
|
||||
if (Boolean.TRUE.equals(sync) && PayOrderStatusEnum.isWaiting(order.getStatus())) {
|
||||
payOrderService.syncOrderQuietly(order.getId());
|
||||
// 重新查询,因为同步后,可能会有变化
|
||||
order = payOrderService.getOrder(id);
|
||||
order = payOrderService.getOrder(order.getId());
|
||||
}
|
||||
return success(BeanUtils.toBean(order, PayOrderRespVO.class));
|
||||
}
|
||||
|
||||
@ -48,6 +48,10 @@ public interface PayOrderMapper extends BaseMapperX<PayOrderDO> {
|
||||
PayOrderDO::getMerchantOrderId, merchantOrderId);
|
||||
}
|
||||
|
||||
default PayOrderDO selectByNo(String no) {
|
||||
return selectOne(PayOrderDO::getNo, no);
|
||||
}
|
||||
|
||||
default int updateByIdAndStatus(Long id, Integer status, PayOrderDO update) {
|
||||
return update(update, new LambdaQueryWrapper<PayOrderDO>()
|
||||
.eq(PayOrderDO::getId, id).eq(PayOrderDO::getStatus, status));
|
||||
|
||||
@ -31,6 +31,14 @@ public interface PayOrderService {
|
||||
*/
|
||||
PayOrderDO getOrder(Long id);
|
||||
|
||||
/**
|
||||
* 获得支付订单
|
||||
*
|
||||
* @param no 支付订单号
|
||||
* @return 支付订单
|
||||
*/
|
||||
PayOrderDO getOrder(String no);
|
||||
|
||||
/**
|
||||
* 获得支付订单
|
||||
*
|
||||
|
||||
@ -79,6 +79,11 @@ public class PayOrderServiceImpl implements PayOrderService {
|
||||
return orderMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PayOrderDO getOrder(String no) {
|
||||
return orderMapper.selectByNo(no);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PayOrderDO getOrder(Long appId, String merchantOrderId) {
|
||||
return orderMapper.selectByAppIdAndMerchantOrderId(appId, merchantOrderId);
|
||||
|
||||
@ -32,4 +32,9 @@ public interface OAuth2AccessTokenMapper extends BaseMapperX<OAuth2AccessTokenDO
|
||||
.orderByDesc(OAuth2AccessTokenDO::getId));
|
||||
}
|
||||
|
||||
default List<OAuth2AccessTokenDO> selectListByUserIdAndUserType(Long userId, Integer userType) {
|
||||
return selectList(OAuth2AccessTokenDO::getUserId, userId,
|
||||
OAuth2AccessTokenDO::getUserType, userType);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -69,6 +69,17 @@ public interface OAuth2TokenService {
|
||||
*/
|
||||
OAuth2AccessTokenDO removeAccessToken(String accessToken);
|
||||
|
||||
/**
|
||||
* 移除访问令牌
|
||||
* 注意:该流程中,会移除相关的刷新令牌
|
||||
*
|
||||
* 参考 DefaultTokenServices 的 revokeToken 方法
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @param userType 用户类型
|
||||
*/
|
||||
void removeAccessToken(Long userId, Integer userType);
|
||||
|
||||
/**
|
||||
* 获得访问令牌分页
|
||||
*
|
||||
|
||||
@ -153,6 +153,21 @@ public class OAuth2TokenServiceImpl implements OAuth2TokenService {
|
||||
return accessTokenDO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAccessToken(Long userId, Integer userType) {
|
||||
List<OAuth2AccessTokenDO> accessTokens = oauth2AccessTokenMapper.selectListByUserIdAndUserType(userId, userType);
|
||||
if (CollUtil.isEmpty(accessTokens)) {
|
||||
return;
|
||||
}
|
||||
accessTokens.forEach(accessToken -> {
|
||||
// 删除访问令牌
|
||||
oauth2AccessTokenMapper.deleteById(accessToken.getId());
|
||||
oauth2AccessTokenRedisDAO.delete(accessToken.getAccessToken());
|
||||
// 删除刷新令牌
|
||||
oauth2RefreshTokenMapper.deleteByRefreshToken(accessToken.getRefreshToken());
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<OAuth2AccessTokenDO> getAccessTokenPage(OAuth2AccessTokenPageReqVO reqVO) {
|
||||
return oauth2AccessTokenMapper.selectPage(reqVO);
|
||||
|
||||
@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
@ -26,6 +27,7 @@ import cn.iocoder.yudao.module.system.dal.mysql.dept.UserPostMapper;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.user.AdminUserMapper;
|
||||
import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
||||
import cn.iocoder.yudao.module.system.service.dept.PostService;
|
||||
import cn.iocoder.yudao.module.system.service.oauth2.OAuth2TokenService;
|
||||
import cn.iocoder.yudao.module.system.service.permission.PermissionService;
|
||||
import cn.iocoder.yudao.module.system.service.tenant.TenantService;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
@ -75,6 +77,9 @@ public class AdminUserServiceImpl implements AdminUserService {
|
||||
@Resource
|
||||
@Lazy // 延迟,避免循环依赖报错
|
||||
private TenantService tenantService;
|
||||
@Resource
|
||||
@Lazy // 懒加载,避免循环依赖
|
||||
private OAuth2TokenService oauth2TokenService;
|
||||
|
||||
@Resource
|
||||
private UserPostMapper userPostMapper;
|
||||
@ -227,6 +232,11 @@ public class AdminUserServiceImpl implements AdminUserService {
|
||||
updateObj.setId(id);
|
||||
updateObj.setStatus(status);
|
||||
userMapper.updateById(updateObj);
|
||||
|
||||
// 如果是禁用用户,则删除其 Token 信息
|
||||
if (CommonStatusEnum.isDisable(status)) {
|
||||
oauth2TokenService.removeAccessToken(id, UserTypeEnum.ADMIN.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -70,8 +70,8 @@ spring:
|
||||
username: root
|
||||
password: 123456
|
||||
# tdengine: # IoT 数据库(需要 IoT 物联网再开启噢!)
|
||||
# url: jdbc:TAOS-RS://127.0.0.1:6041/ruoyi_vue_pro
|
||||
# driver-class-name: com.taosdata.jdbc.rs.RestfulDriver
|
||||
# url: jdbc:TAOS-WS://127.0.0.1:6041/ruoyi_vue_pro
|
||||
# driver-class-name: com.taosdata.jdbc.ws.WebSocketDriver
|
||||
# username: root
|
||||
# password: taosdata
|
||||
# druid:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user