feat(pet): 添加宠物医疗上下文功能模块
- 新增宠物医疗上下文实体类BizPetMedicalContext - 创建宠物医疗上下文业务对象BizPetMedicalContextBo - 实现宠物医疗上下文控制器BizPetMedicalContextController - 添加宠物医疗上下文数据访问层BizPetMedicalContextMapper - 实现宠物医疗上下文服务层BizPetMedicalContextServiceImpl - 创建宠物医疗上下文视图对象BizPetMedicalContextVo - 生成前端API接口文件api.d.ts.vm和api.ts.vm - 创建Vue组件模板index.vue.vm和操作抽屉operate-drawer.vue.vm - 更新代码生成配置generator.yml支持宠物模块 - 添加树形表格支持index-tree.vue.vm模板
This commit is contained in:
@@ -488,6 +488,11 @@
|
||||
<artifactId>ruoyi-chat</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-pet</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
<module>ruoyi-chat</module>
|
||||
<module>ruoyi-pay</module>
|
||||
<module>ruoyi-mall</module>
|
||||
<module>ruoyi-pet</module>
|
||||
</modules>
|
||||
|
||||
<artifactId>ruoyi-modules</artifactId>
|
||||
|
||||
@@ -67,11 +67,11 @@
|
||||
<!-- <version>${anyline.version}</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.anyline</groupId>-->
|
||||
<!-- <artifactId>anyline-data-jdbc-postgresql</artifactId>-->
|
||||
<!-- <version>${anyline.version}</version>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>org.anyline</groupId>
|
||||
<artifactId>anyline-data-jdbc-postgresql</artifactId>
|
||||
<version>${anyline.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.anyline</groupId>-->
|
||||
|
||||
+66
-18
@@ -3,12 +3,14 @@ package org.dromara.generator.util;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.lang.Dict;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.apache.velocity.VelocityContext;
|
||||
import org.dromara.common.core.utils.DateUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.json.utils.JsonUtils;
|
||||
import org.dromara.common.mybatis.enums.DataBaseType;
|
||||
import org.dromara.common.mybatis.helper.DataBaseHelper;
|
||||
import org.dromara.generator.constant.GenConstants;
|
||||
import org.dromara.generator.domain.GenTable;
|
||||
@@ -19,7 +21,7 @@ import java.util.*;
|
||||
/**
|
||||
* 模板处理工具类
|
||||
*
|
||||
* @author pengles
|
||||
* @author ruoyi
|
||||
*/
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class VelocityUtils {
|
||||
@@ -57,9 +59,12 @@ public class VelocityUtils {
|
||||
velocityContext.put("functionName", StringUtils.isNotEmpty(functionName) ? functionName : "【请填写功能名称】");
|
||||
velocityContext.put("ClassName", genTable.getClassName());
|
||||
velocityContext.put("className", StringUtils.uncapitalize(genTable.getClassName()));
|
||||
velocityContext.put("moduleName", genTable.getModuleName());
|
||||
velocityContext.put("moduleName", StrUtil.toSymbolCase(genTable.getModuleName(), '-'));
|
||||
velocityContext.put("BusinessName", StringUtils.capitalize(genTable.getBusinessName()));
|
||||
velocityContext.put("businessName", genTable.getBusinessName());
|
||||
velocityContext.put("business_name", StrUtil.toUnderlineCase(genTable.getBusinessName()));
|
||||
velocityContext.put("business__name", StrUtil.toSymbolCase(genTable.getBusinessName(), '-'));
|
||||
velocityContext.put("businessname", StrUtil.toSymbolCase(genTable.getBusinessName(), ' '));
|
||||
velocityContext.put("basePackage", getPackagePrefix(packageName));
|
||||
velocityContext.put("packageName", packageName);
|
||||
velocityContext.put("author", genTable.getFunctionAuthor());
|
||||
@@ -67,9 +72,12 @@ public class VelocityUtils {
|
||||
velocityContext.put("pkColumn", genTable.getPkColumn());
|
||||
velocityContext.put("importList", getImportList(genTable));
|
||||
velocityContext.put("permissionPrefix", getPermissionPrefix(moduleName, businessName));
|
||||
velocityContext.put("dicts", getDicts(genTable));
|
||||
velocityContext.put("dictList", getDictList(genTable));
|
||||
velocityContext.put("pkColumn", genTable.getPkColumn());
|
||||
velocityContext.put("columns", genTable.getColumns());
|
||||
velocityContext.put("table", genTable);
|
||||
velocityContext.put("dicts", getDicts(genTable));
|
||||
velocityContext.put("StrUtil", new StrUtil());
|
||||
setMenuVelocityContext(velocityContext, genTable);
|
||||
if (GenConstants.TPL_TREE.equals(tplCategory)) {
|
||||
setTreeVelocityContext(velocityContext, genTable);
|
||||
@@ -118,6 +126,7 @@ public class VelocityUtils {
|
||||
templates.add("vm/java/serviceImpl.java.vm");
|
||||
templates.add("vm/java/controller.java.vm");
|
||||
templates.add("vm/xml/mapper.xml.vm");
|
||||
DataBaseType dataBaseType = DataBaseHelper.getDataBaseType();
|
||||
if (DataBaseHelper.isOracle()) {
|
||||
templates.add("vm/sql/oracle/sql.vm");
|
||||
} else if (DataBaseHelper.isPostgerSql()) {
|
||||
@@ -127,12 +136,14 @@ public class VelocityUtils {
|
||||
} else {
|
||||
templates.add("vm/sql/sql.vm");
|
||||
}
|
||||
templates.add("vm/ts/api.ts.vm");
|
||||
templates.add("vm/ts/types.ts.vm");
|
||||
templates.add("vm/soy/typings/api.d.ts.vm");
|
||||
templates.add("vm/soy/api/api.ts.vm");
|
||||
templates.add("vm/soy/modules/search.vue.vm");
|
||||
templates.add("vm/soy/modules/operate-drawer.vue.vm");
|
||||
if (GenConstants.TPL_CRUD.equals(tplCategory)) {
|
||||
templates.add("vm/vue/index.vue.vm");
|
||||
templates.add("vm/soy/index.vue.vm");
|
||||
} else if (GenConstants.TPL_TREE.equals(tplCategory)) {
|
||||
templates.add("vm/vue/index-tree.vue.vm");
|
||||
templates.add("vm/soy/index-tree.vue.vm");
|
||||
}
|
||||
return templates;
|
||||
}
|
||||
@@ -154,8 +165,8 @@ public class VelocityUtils {
|
||||
|
||||
String javaPath = PROJECT_PATH + "/" + StringUtils.replace(packageName, ".", "/");
|
||||
String mybatisPath = MYBATIS_PATH + "/" + moduleName;
|
||||
String vuePath = "vue";
|
||||
|
||||
String soybeanPath = "soy";
|
||||
String soybeanModuleName = StrUtil.toSymbolCase(moduleName, '-');
|
||||
if (template.contains("domain.java.vm")) {
|
||||
fileName = StringUtils.format("{}/domain/{}.java", javaPath, className);
|
||||
}
|
||||
@@ -177,14 +188,18 @@ public class VelocityUtils {
|
||||
fileName = StringUtils.format("{}/{}Mapper.xml", mybatisPath, className);
|
||||
} else if (template.contains("sql.vm")) {
|
||||
fileName = businessName + "Menu.sql";
|
||||
} else if (template.contains("api.ts.vm")) {
|
||||
fileName = StringUtils.format("{}/api/{}/{}/index.ts", vuePath, moduleName, businessName);
|
||||
} else if (template.contains("types.ts.vm")) {
|
||||
fileName = StringUtils.format("{}/api/{}/{}/types.ts", vuePath, moduleName, businessName);
|
||||
} else if (template.contains("index.vue.vm")) {
|
||||
fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName);
|
||||
fileName = StringUtils.format("{}/views/{}/{}/index.vue", soybeanPath, soybeanModuleName, StrUtil.toSymbolCase(businessName, '-'));
|
||||
} else if (template.contains("index-tree.vue.vm")) {
|
||||
fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName);
|
||||
fileName = StringUtils.format("{}/views/{}/{}/index.vue", soybeanPath, soybeanModuleName, StrUtil.toSymbolCase(businessName, '-'));
|
||||
} else if (template.contains("api.d.ts.vm")) {
|
||||
fileName = StringUtils.format("{}/typings/api/{}.{}.api.d.ts", soybeanPath, soybeanModuleName, StrUtil.toSymbolCase(businessName, '-'));
|
||||
} else if (template.contains("api.ts.vm")) {
|
||||
fileName = StringUtils.format("{}/service/api/{}/{}.ts", soybeanPath, soybeanModuleName, StrUtil.toSymbolCase(businessName, '-'));
|
||||
} else if (template.contains("search.vue.vm")) {
|
||||
fileName = StringUtils.format("{}/views/{}/{}/modules/{}-search.vue", soybeanPath, soybeanModuleName, StrUtil.toSymbolCase(businessName, '-'), StrUtil.toSymbolCase(businessName, '-'));
|
||||
} else if (template.contains("operate-drawer.vue.vm")) {
|
||||
fileName = StringUtils.format("{}/views/{}/{}/modules/{}-operate-drawer.vue", soybeanPath, soybeanModuleName, StrUtil.toSymbolCase(businessName, '-'), StrUtil.toSymbolCase(businessName, '-'));
|
||||
}
|
||||
return fileName;
|
||||
}
|
||||
@@ -245,13 +260,46 @@ public class VelocityUtils {
|
||||
public static void addDicts(Set<String> dicts, List<GenTableColumn> columns) {
|
||||
for (GenTableColumn column : columns) {
|
||||
if (!column.isSuperColumn() && StringUtils.isNotEmpty(column.getDictType()) && StringUtils.equalsAny(
|
||||
column.getHtmlType(),
|
||||
new String[]{GenConstants.HTML_SELECT, GenConstants.HTML_RADIO, GenConstants.HTML_CHECKBOX})) {
|
||||
column.getHtmlType(),
|
||||
GenConstants.HTML_SELECT, GenConstants.HTML_RADIO, GenConstants.HTML_CHECKBOX)) {
|
||||
dicts.add("'" + column.getDictType() + "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据列类型获取字典组
|
||||
*
|
||||
* @param genTable 业务表对象
|
||||
* @return 返回字典组
|
||||
*/
|
||||
public static Set<Map<String, Object>> getDictList(GenTable genTable) {
|
||||
List<GenTableColumn> columns = genTable.getColumns();
|
||||
Set<Map<String, Object>> dicts = new HashSet<>();
|
||||
addDictList(dicts, columns);
|
||||
return dicts;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加字典列表
|
||||
*
|
||||
* @param dicts 字典列表
|
||||
* @param columns 列集合
|
||||
*/
|
||||
public static void addDictList(Set<Map<String, Object>> dicts, List<GenTableColumn> columns) {
|
||||
for (GenTableColumn column : columns) {
|
||||
if (!column.isSuperColumn() && StringUtils.isNotEmpty(column.getDictType()) && StringUtils.equalsAny(
|
||||
column.getHtmlType(),
|
||||
GenConstants.HTML_SELECT, GenConstants.HTML_RADIO, GenConstants.HTML_CHECKBOX)) {
|
||||
Map<String, Object> dict = new HashMap<>();
|
||||
dict.put("type", column.getDictType());
|
||||
dict.put("name", StringUtils.toCamelCase(column.getDictType()));
|
||||
dict.put("immediate", column.isList());
|
||||
dicts.add(dict);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取权限前缀
|
||||
*
|
||||
@@ -271,7 +319,7 @@ public class VelocityUtils {
|
||||
*/
|
||||
public static String getParentMenuId(Dict paramsObj) {
|
||||
if (CollUtil.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.PARENT_MENU_ID)
|
||||
&& StringUtils.isNotEmpty(paramsObj.getStr(GenConstants.PARENT_MENU_ID))) {
|
||||
&& StringUtils.isNotEmpty(paramsObj.getStr(GenConstants.PARENT_MENU_ID))) {
|
||||
return paramsObj.getStr(GenConstants.PARENT_MENU_ID);
|
||||
}
|
||||
return DEFAULT_PARENT_MENU_ID;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
# 代码生成
|
||||
gen:
|
||||
# 作者
|
||||
author: Lion Li
|
||||
author: shuo
|
||||
# 默认生成包路径 system 需改成自己的模块名称 如 system monitor tool
|
||||
packageName: org.dromara.system
|
||||
packageName: org.dromara.pet
|
||||
# 自动去除表前缀,默认是false
|
||||
autoRemovePre: false
|
||||
# 表前缀(生成类名不会包含表前缀,多个用逗号分隔)
|
||||
tablePrefix: sys_
|
||||
tablePrefix: sys_,biz_
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
import { request } from '@/service/request';
|
||||
#set($responseType = "")
|
||||
#if($tplCategory == "tree")
|
||||
#set($responseType = "Api.${ModuleName}.${BusinessName}[]")
|
||||
#else
|
||||
#set($responseType = "Api.${ModuleName}.${BusinessName}List")
|
||||
#end
|
||||
|
||||
/** 获取${functionName}列表 */
|
||||
export function fetchGet${BusinessName}List (params?: Api.${ModuleName}.${BusinessName}SearchParams) {
|
||||
return request<$responseType>({
|
||||
url: '/${moduleName}/${businessName}/list',
|
||||
method: 'get',
|
||||
params
|
||||
});
|
||||
}
|
||||
/** 新增${functionName} */
|
||||
export function fetchCreate${BusinessName} (data: Api.${ModuleName}.${BusinessName}OperateParams) {
|
||||
return request<boolean>({
|
||||
url: '/${moduleName}/${businessName}',
|
||||
method: 'post',
|
||||
data
|
||||
});
|
||||
}
|
||||
|
||||
/** 修改${functionName} */
|
||||
export function fetchUpdate${BusinessName} (data: Api.${ModuleName}.${BusinessName}OperateParams) {
|
||||
return request<boolean>({
|
||||
url: '/${moduleName}/${businessName}',
|
||||
method: 'put',
|
||||
data
|
||||
});
|
||||
}
|
||||
|
||||
/** 批量删除${functionName} */
|
||||
export function fetchBatchDelete${BusinessName} (${pkColumn.javaField}s: CommonType.IdType[]) {
|
||||
return request<boolean>({
|
||||
url: `/${moduleName}/${businessName}/${${pkColumn.javaField}s.join(',')}`,
|
||||
method: 'delete'
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,233 @@
|
||||
<script setup lang="tsx">
|
||||
import { ref } from 'vue';
|
||||
import { NDivider } from 'naive-ui';
|
||||
import { jsonClone } from '@sa/utils';
|
||||
import { fetchBatchDelete${BusinessName}, fetchGet${BusinessName}List } from '@/service/api/${moduleName}/${business__name}';
|
||||
import { useAppStore } from '@/store/modules/app';
|
||||
import { useAuth } from '@/hooks/business/auth';
|
||||
import { treeTransform, useNaiveTreeTable, useTableOperate } from '@/hooks/common/table';
|
||||
import { useDownload } from '@/hooks/business/download';
|
||||
import { $t } from '@/locales';
|
||||
import ButtonIcon from '@/components/custom/button-icon.vue';
|
||||
import ${BusinessName}OperateDrawer from './modules/${business__name}-operate-drawer.vue';
|
||||
import ${BusinessName}Search from './modules/${business__name}-search.vue';
|
||||
#if($dictList && $dictList.size() > 0)
|
||||
import { useDict } from '@/hooks/business/dict';
|
||||
#end
|
||||
|
||||
defineOptions({
|
||||
name: '${BusinessName}List'
|
||||
});
|
||||
|
||||
#if($dictList && $dictList.size() > 0)
|
||||
#foreach($dict in $dictList)
|
||||
useDict('${dict.type}'#if(!$dict.immediate), false#end);
|
||||
#end#end
|
||||
|
||||
const appStore = useAppStore();
|
||||
const { download } = useDownload();
|
||||
const { hasAuth } = useAuth();
|
||||
|
||||
const searchParams = ref<Api.$ModuleName.${BusinessName}SearchParams>({
|
||||
#foreach ($column in $columns)
|
||||
#if($column.query)
|
||||
$column.javaField: null#if($foreach.hasNext),#end
|
||||
#end
|
||||
#end
|
||||
params: {}
|
||||
});
|
||||
|
||||
const {
|
||||
columns,
|
||||
columnChecks,
|
||||
data,
|
||||
rows,
|
||||
getData,
|
||||
loading,
|
||||
expandedRowKeys,
|
||||
isCollapse,
|
||||
expandAll,
|
||||
collapseAll,
|
||||
scrollX
|
||||
} = useNaiveTreeTable({
|
||||
keyField: '$pkColumn.javaField',
|
||||
api: () => fetchGet${BusinessName}List(searchParams.value),
|
||||
transform: response => treeTransform(response, { idField: '$pkColumn.javaField' }),
|
||||
columns: () => [
|
||||
{
|
||||
type: 'selection',
|
||||
align: 'center',
|
||||
width: 48
|
||||
},
|
||||
{
|
||||
key: 'index',
|
||||
title: $t('common.index'),
|
||||
align: 'center',
|
||||
width: 64,
|
||||
render: (_, index) => index + 1
|
||||
},
|
||||
#foreach ($column in $columns)
|
||||
#if($column.list)
|
||||
{
|
||||
key: '$column.javaField',
|
||||
title: '$column.columnComment',
|
||||
align: 'center',
|
||||
minWidth: 120#if($column.dictType),
|
||||
render(row) {
|
||||
return <DictTag value={row.$column.javaField} dictCode="$column.dictType" />;
|
||||
}#end
|
||||
},
|
||||
#end
|
||||
#end
|
||||
{
|
||||
key: 'operate',
|
||||
title: $t('common.operate'),
|
||||
align: 'center',
|
||||
width: 130,
|
||||
render: row => {
|
||||
const addBtn = () => {
|
||||
return (
|
||||
<ButtonIcon
|
||||
text
|
||||
type="primary"
|
||||
icon="material-symbols:add-2-rounded"
|
||||
tooltipContent={$t('common.add')}
|
||||
onClick={() => addInRow(row)}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
const editBtn = () => {
|
||||
return (
|
||||
<ButtonIcon
|
||||
text
|
||||
type="primary"
|
||||
icon="material-symbols:drive-file-rename-outline-outline"
|
||||
tooltipContent={$t('common.edit')}
|
||||
onClick={() => edit(row.$pkColumn.javaField)}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
const deleteBtn = () => {
|
||||
return (
|
||||
<ButtonIcon
|
||||
text
|
||||
type="error"
|
||||
icon="material-symbols:delete-outline"
|
||||
tooltipContent={$t('common.delete')}
|
||||
popconfirmContent={$t('common.confirmDelete')}
|
||||
onPositiveClick={() => handleDelete(row.$pkColumn.javaField)}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
const buttons = [];
|
||||
if (hasAuth('${moduleName}:${businessName}:add')) buttons.push(addBtn());
|
||||
if (hasAuth('${moduleName}:${businessName}:edit')) buttons.push(editBtn());
|
||||
if (hasAuth('${moduleName}:${businessName}:remove')) buttons.push(deleteBtn());
|
||||
|
||||
return (
|
||||
<div class="flex-center gap-8px">
|
||||
{buttons.map((btn, index) => (
|
||||
<>
|
||||
{index !== 0 && <NDivider vertical />}
|
||||
{btn}
|
||||
</>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
const { drawerVisible, operateType, editingData, handleAdd, handleEdit, checkedRowKeys, onBatchDeleted, onDeleted } =
|
||||
useTableOperate(rows, '$pkColumn.javaField', getData);
|
||||
|
||||
async function handleBatchDelete() {
|
||||
// request
|
||||
const { error } = await fetchBatchDelete${BusinessName}(checkedRowKeys.value);
|
||||
if (error) return;
|
||||
onBatchDeleted();
|
||||
}
|
||||
|
||||
async function handleDelete($pkColumn.javaField: CommonType.IdType) {
|
||||
// request
|
||||
const { error } = await fetchBatchDelete${BusinessName}([$pkColumn.javaField]);
|
||||
if (error) return;
|
||||
onDeleted();
|
||||
}
|
||||
|
||||
function edit($pkColumn.javaField: CommonType.IdType) {
|
||||
handleEdit($pkColumn.javaField);
|
||||
}
|
||||
|
||||
function addInRow(row: Api.$ModuleName.${BusinessName}) {
|
||||
editingData.value = jsonClone(row);
|
||||
handleAdd();
|
||||
}
|
||||
|
||||
function handleExport() {
|
||||
download('/${moduleName}/${businessName}/export', searchParams.value, `${functionName}_#[[${new Date().getTime()}]]#.xlsx`);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="min-h-500px flex-col-stretch gap-16px overflow-hidden lt-sm:overflow-auto">
|
||||
<${BusinessName}Search v-model:model="searchParams" @search="getData" />
|
||||
<NCard title="${functionName}列表" :bordered="false" size="small" class="card-wrapper sm:flex-1-hidden">
|
||||
<template #header-extra>
|
||||
<TableHeaderOperation
|
||||
v-model:columns="columnChecks"
|
||||
:disabled-delete="checkedRowKeys.length === 0"
|
||||
:loading="loading"
|
||||
:show-add="hasAuth('${moduleName}:${businessName}:add')"
|
||||
:show-delete="hasAuth('${moduleName}:${businessName}:remove')"
|
||||
:show-export="false"
|
||||
@add="handleAdd"
|
||||
@delete="handleBatchDelete"
|
||||
@export="handleExport"
|
||||
@refresh="getData"
|
||||
>
|
||||
<template #prefix>
|
||||
<NButton v-if="!isCollapse" :disabled="!data.length" size="small" @click="expandAll">
|
||||
<template #icon>
|
||||
<icon-quill-expand />
|
||||
</template>
|
||||
全部展开
|
||||
</NButton>
|
||||
<NButton v-if="isCollapse" :disabled="!data.length" size="small" @click="collapseAll">
|
||||
<template #icon>
|
||||
<icon-quill-collapse />
|
||||
</template>
|
||||
全部收起
|
||||
</NButton>
|
||||
</template>
|
||||
</TableHeaderOperation>
|
||||
</template>
|
||||
<NDataTable
|
||||
v-model:checked-row-keys="checkedRowKeys"
|
||||
v-model:expanded-row-keys="expandedRowKeys"
|
||||
:columns="columns"
|
||||
:data="data"
|
||||
size="small"
|
||||
:indent="64"
|
||||
:flex-height="!appStore.isMobile"
|
||||
:scroll-x="scrollX"
|
||||
:loading="loading"
|
||||
remote
|
||||
:row-key="row => row.#foreach($column in $columns)#if($column.isPk == '1')$column.javaField#end#end"
|
||||
class="sm:h-full"
|
||||
/>
|
||||
<${BusinessName}OperateDrawer
|
||||
v-model:visible="drawerVisible"
|
||||
:operate-type="operateType"
|
||||
:row-data="editingData"
|
||||
@submitted="getData"
|
||||
/>
|
||||
</NCard>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
||||
@@ -0,0 +1,198 @@
|
||||
<script setup lang="tsx">
|
||||
import { ref } from 'vue';
|
||||
import { NDivider } from 'naive-ui';
|
||||
import { fetchBatchDelete${BusinessName}, fetchGet${BusinessName}List } from '@/service/api/${moduleName}/${business__name}';
|
||||
import { useAppStore } from '@/store/modules/app';
|
||||
import { useAuth } from '@/hooks/business/auth';
|
||||
import { useDownload } from '@/hooks/business/download';
|
||||
import { defaultTransform, useNaivePaginatedTable, useTableOperate } from '@/hooks/common/table';
|
||||
import { $t } from '@/locales';
|
||||
import ButtonIcon from '@/components/custom/button-icon.vue';
|
||||
import ${BusinessName}OperateDrawer from './modules/${business__name}-operate-drawer.vue';
|
||||
import ${BusinessName}Search from './modules/${business__name}-search.vue';
|
||||
#if($dictList && $dictList.size() > 0)
|
||||
import { useDict } from '@/hooks/business/dict';
|
||||
#end
|
||||
|
||||
defineOptions({
|
||||
name: '${BusinessName}List'
|
||||
});
|
||||
|
||||
#if($dictList && $dictList.size() > 0)
|
||||
#foreach($dict in $dictList)
|
||||
useDict('${dict.type}'#if(!$dict.immediate), false#end);
|
||||
#end#end
|
||||
|
||||
const appStore = useAppStore();
|
||||
const { download } = useDownload();
|
||||
const { hasAuth } = useAuth();
|
||||
|
||||
const searchParams = ref<Api.$ModuleName.${BusinessName}SearchParams>({
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
#foreach ($column in $columns)
|
||||
#if($column.query)
|
||||
$column.javaField: null#if($foreach.hasNext),#end
|
||||
#end
|
||||
#end
|
||||
params: {}
|
||||
});
|
||||
|
||||
const { columns, columnChecks, data, getData, getDataByPage, loading, mobilePagination, scrollX } =
|
||||
useNaivePaginatedTable({
|
||||
api: () => fetchGet${BusinessName}List(searchParams.value),
|
||||
transform: response => defaultTransform(response),
|
||||
onPaginationParamsChange: params => {
|
||||
searchParams.value.pageNum = params.page;
|
||||
searchParams.value.pageSize = params.pageSize;
|
||||
},
|
||||
columns: () => [
|
||||
{
|
||||
type: 'selection',
|
||||
align: 'center',
|
||||
width: 48
|
||||
},
|
||||
{
|
||||
key: 'index',
|
||||
title: $t('common.index'),
|
||||
align: 'center',
|
||||
width: 64,
|
||||
render: (_, index) => index + 1
|
||||
},
|
||||
#foreach ($column in $columns)
|
||||
#if($column.list)
|
||||
{
|
||||
key: '$column.javaField',
|
||||
title: '$column.columnComment',
|
||||
align: 'center',
|
||||
minWidth: 120#if($column.dictType),
|
||||
render(row) {
|
||||
return <DictTag value={row.$column.javaField} dictCode="$column.dictType" />;
|
||||
}#end
|
||||
},
|
||||
#end
|
||||
#end
|
||||
{
|
||||
key: 'operate',
|
||||
title: $t('common.operate'),
|
||||
align: 'center',
|
||||
width: 130,
|
||||
render: row => {
|
||||
const divider = () => {
|
||||
if (!hasAuth('${moduleName}:${businessName}:edit') || !hasAuth('${moduleName}:${businessName}:remove')) {
|
||||
return null;
|
||||
}
|
||||
return <NDivider vertical />;
|
||||
};
|
||||
|
||||
const editBtn = () => {
|
||||
if (!hasAuth('${moduleName}:${businessName}:edit')) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<ButtonIcon
|
||||
text
|
||||
type="primary"
|
||||
icon="material-symbols:drive-file-rename-outline-outline"
|
||||
tooltipContent={$t('common.edit')}
|
||||
onClick={() => edit(row.$pkColumn.javaField)}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
const deleteBtn = () => {
|
||||
if (!hasAuth('${moduleName}:${businessName}:remove')) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<ButtonIcon
|
||||
text
|
||||
type="error"
|
||||
icon="material-symbols:delete-outline"
|
||||
tooltipContent={$t('common.delete')}
|
||||
popconfirmContent={$t('common.confirmDelete')}
|
||||
onPositiveClick={() => handleDelete(row.$pkColumn.javaField)}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<div class="flex-center gap-8px">
|
||||
{editBtn()}
|
||||
{divider()}
|
||||
{deleteBtn()}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
const { drawerVisible, operateType, editingData, handleAdd, handleEdit, checkedRowKeys, onBatchDeleted, onDeleted } =
|
||||
useTableOperate(data, '$pkColumn.javaField', getData);
|
||||
|
||||
async function handleBatchDelete() {
|
||||
// request
|
||||
const { error } = await fetchBatchDelete${BusinessName}(checkedRowKeys.value);
|
||||
if (error) return;
|
||||
onBatchDeleted();
|
||||
}
|
||||
|
||||
async function handleDelete($pkColumn.javaField: CommonType.IdType) {
|
||||
// request
|
||||
const { error } = await fetchBatchDelete${BusinessName}([$pkColumn.javaField]);
|
||||
if (error) return;
|
||||
onDeleted();
|
||||
}
|
||||
|
||||
function edit($pkColumn.javaField: CommonType.IdType) {
|
||||
handleEdit($pkColumn.javaField);
|
||||
}
|
||||
|
||||
function handleExport() {
|
||||
download('/${moduleName}/${businessName}/export', searchParams.value, `${functionName}_#[[${new Date().getTime()}]]#.xlsx`);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="min-h-500px flex-col-stretch gap-16px overflow-hidden lt-sm:overflow-auto">
|
||||
<${BusinessName}Search v-model:model="searchParams" @search="getDataByPage" />
|
||||
<NCard title="${functionName}列表" :bordered="false" size="small" class="card-wrapper sm:flex-1-hidden">
|
||||
<template #header-extra>
|
||||
<TableHeaderOperation
|
||||
v-model:columns="columnChecks"
|
||||
:disabled-delete="checkedRowKeys.length === 0"
|
||||
:loading="loading"
|
||||
:show-add="hasAuth('${moduleName}:${businessName}:add')"
|
||||
:show-delete="hasAuth('${moduleName}:${businessName}:remove')"
|
||||
:show-export="hasAuth('${moduleName}:${businessName}:export')"
|
||||
@add="handleAdd"
|
||||
@delete="handleBatchDelete"
|
||||
@export="handleExport"
|
||||
@refresh="getData"
|
||||
/>
|
||||
</template>
|
||||
<NDataTable
|
||||
v-model:checked-row-keys="checkedRowKeys"
|
||||
:columns="columns"
|
||||
:data="data"
|
||||
size="small"
|
||||
:flex-height="!appStore.isMobile"
|
||||
:scroll-x="scrollX"
|
||||
:loading="loading"
|
||||
remote
|
||||
:row-key="row => row.$pkColumn.javaField"
|
||||
:pagination="mobilePagination"
|
||||
class="sm:h-full"
|
||||
/>
|
||||
<${BusinessName}OperateDrawer
|
||||
v-model:visible="drawerVisible"
|
||||
:operate-type="operateType"
|
||||
:row-data="editingData"
|
||||
@submitted="getDataByPage"
|
||||
/>
|
||||
</NCard>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
||||
+257
@@ -0,0 +1,257 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { jsonClone } from '@sa/utils';
|
||||
import { fetchCreate${BusinessName}, fetchUpdate${BusinessName}#if($tplCategory == 'tree'), fetchGet${BusinessName}List#end } from '@/service/api/${moduleName}/${business__name}';
|
||||
import { useFormRules, useNaiveForm } from '@/hooks/common/form';
|
||||
#if($tplCategory == 'tree')
|
||||
import { handleTree } from '@/utils/common';
|
||||
#end
|
||||
import { $t } from '@/locales';
|
||||
|
||||
defineOptions({
|
||||
name: '${BusinessName}OperateDrawer'
|
||||
});
|
||||
|
||||
interface Props {
|
||||
/** the type of operation */
|
||||
operateType: NaiveUI.TableOperateType;
|
||||
/** the edit row data */
|
||||
rowData?: Api.$ModuleName.${BusinessName} | null;
|
||||
}
|
||||
|
||||
const props = defineProps<Props>();
|
||||
|
||||
interface Emits {
|
||||
(e: 'submitted'): void;
|
||||
}
|
||||
|
||||
const emit = defineEmits<Emits>();
|
||||
|
||||
const visible = defineModel<boolean>('visible', {
|
||||
default: false
|
||||
});
|
||||
#if($tplCategory == 'tree')
|
||||
|
||||
const treeList = ref<Api.Demo.Tree[]>([]);
|
||||
#end
|
||||
|
||||
const { validate, restoreValidation } = useNaiveForm();
|
||||
const { createRequiredRule } = useFormRules();
|
||||
|
||||
const title = computed(() => {
|
||||
const titles: Record<NaiveUI.TableOperateType, string> = {
|
||||
add: '新增${functionName}',
|
||||
edit: '编辑${functionName}'
|
||||
};
|
||||
return titles[props.operateType];
|
||||
});
|
||||
|
||||
type Model = Api.$ModuleName.${BusinessName}OperateParams;
|
||||
|
||||
const model = ref<Model>(createDefaultModel());
|
||||
|
||||
function createDefaultModel(): Model {
|
||||
return {
|
||||
#foreach($column in $columns)
|
||||
#if($column.insert() || $column.isEdit())
|
||||
${column.javaField}:#if($column.javaType == 'String' || ($!column.dictType && $column.dictType != '')) ''#else null#end#if($foreach.hasNext),#end
|
||||
#end
|
||||
#end
|
||||
};
|
||||
}
|
||||
|
||||
type RuleKey = Extract<
|
||||
keyof Model,
|
||||
#foreach($column in $columns)
|
||||
#if($column.required)
|
||||
| '$column.javaField'#if($foreach.hasNext)#end
|
||||
#end#end>;
|
||||
|
||||
const rules: Record<RuleKey, App.Global.FormRule> = {
|
||||
#foreach($column in $columns)
|
||||
#if($column.required)
|
||||
$column.javaField: createRequiredRule('${column.columnComment}不能为空')#if($foreach.hasNext),#end
|
||||
#end
|
||||
#end
|
||||
};
|
||||
|
||||
function handleUpdateModelWhenEdit() {
|
||||
model.value = createDefaultModel();
|
||||
#if($tplCategory == 'tree')
|
||||
model.value.$treeParentCode = props.rowData?.$treeCode || 0;
|
||||
#end
|
||||
|
||||
if (props.operateType === 'edit' && props.rowData) {
|
||||
Object.assign(model.value, jsonClone(props.rowData));
|
||||
}
|
||||
}
|
||||
|
||||
function closeDrawer() {
|
||||
visible.value = false;
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
await validate();
|
||||
|
||||
#set($operateColumns = [])
|
||||
#foreach($column in $columns)#if($column.insert || $column.edit)#set($dummy = $operateColumns.add($column))#end#end
|
||||
const { #foreach($column in $operateColumns)$column.javaField#if($foreach.hasNext), #end#end } = model.value;
|
||||
|
||||
// request
|
||||
if (props.operateType === 'add') {
|
||||
#set($addFields = [])
|
||||
#foreach($column in $columns)#if($column.insert)#set($dummy = $addFields.add($column.javaField))#end#end
|
||||
const { error } = await fetchCreate${BusinessName}({ #foreach($field in $addFields)$field#if($foreach.hasNext), #end#end });
|
||||
if (error) return;
|
||||
}
|
||||
|
||||
if (props.operateType === 'edit') {
|
||||
#set($editFields = [])
|
||||
#foreach($column in $columns)#if($column.edit)#set($dummy = $editFields.add($column.javaField))#end#end
|
||||
const { error } = await fetchUpdate${BusinessName}({ #foreach($field in $editFields)$field#if($foreach.hasNext), #end#end });
|
||||
if (error) return;
|
||||
}
|
||||
|
||||
window.$message?.success($t('common.updateSuccess'));
|
||||
closeDrawer();
|
||||
emit('submitted');
|
||||
}
|
||||
#if($tplCategory == 'tree')
|
||||
|
||||
async function getTreeList() {
|
||||
const { data, error } = await fetchGet${BusinessName}List();
|
||||
if (error) {
|
||||
return;
|
||||
}
|
||||
const { tree } = handleTree(data);
|
||||
treeList.value = tree;
|
||||
}
|
||||
#end
|
||||
|
||||
watch(visible, () => {
|
||||
if (visible.value) {
|
||||
handleUpdateModelWhenEdit();
|
||||
restoreValidation();
|
||||
getTreeList();
|
||||
}
|
||||
});
|
||||
#if($tplCategory == 'tree')
|
||||
|
||||
const treeOptions = computed(() => {
|
||||
return [
|
||||
{
|
||||
id: 0,
|
||||
treeName: '顶级节点',
|
||||
children: treeList.value
|
||||
}
|
||||
];
|
||||
});
|
||||
#end
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<NDrawer v-model:show="visible" :title="title" display-directive="show" :width="800" class="max-w-90%">
|
||||
<NDrawerContent :title="title" :native-scrollbar="false" closable>
|
||||
<NForm :model="model" :rules="rules">
|
||||
#set($immediateDictList = [])
|
||||
#foreach($column in $columns)
|
||||
#set($field=$column.javaField)
|
||||
#if(($column.insert || $column.edit) && !$column.pk)
|
||||
#set($isImmediate = !$column.isList() && !$column.isQuery() && !$immediateDictList.contains($column.dictType))
|
||||
<NFormItem label="$column.columnComment" path="$column.javaField">
|
||||
#if($tplCategory == 'tree' && $column.javaField == $treeParentCode)
|
||||
<NTreeSelect
|
||||
v-model:value="model.$treeParentCode"
|
||||
filterable
|
||||
class="h-full"
|
||||
key-field="$treeCode"
|
||||
label-field="$treeName"
|
||||
:options="treeOptions"
|
||||
:default-expanded-keys="[0]"
|
||||
/>
|
||||
#elseif($column.htmlType == "textarea" || $column.htmlType == "editor")
|
||||
<NInput
|
||||
v-model:value="model.$column.javaField"
|
||||
:rows="3"
|
||||
type="textarea"
|
||||
placeholder="请输入$column.columnComment"
|
||||
/>
|
||||
#elseif($column.htmlType == "select" && $column.dictType)
|
||||
<DictSelect
|
||||
v-model:value="model.$column.javaField"
|
||||
placeholder="请选择$column.columnComment"
|
||||
dict-code="$column.dictType"
|
||||
clearable
|
||||
#if($isImmediate)#set($void = $immediateDictList.add($column.dictType))
|
||||
immediate
|
||||
#end
|
||||
/>
|
||||
#elseif($column.htmlType == "select" && !$column.dictType)
|
||||
<NSelect
|
||||
v-model:value="model.$column.javaField"
|
||||
placeholder="请选择$column.columnComment"
|
||||
:options="[{ value: '0', label: '请选择字典生成' }]"
|
||||
clearable
|
||||
/>
|
||||
#elseif($column.htmlType == "radio" && $column.dictType)
|
||||
<DictRadio
|
||||
v-model:value="model.$column.javaField"
|
||||
placeholder="请选择$column.columnComment"
|
||||
dict-code="$column.dictType"
|
||||
clearable
|
||||
#if($isImmediate)#set($void = $immediateDictList.add($column.dictType))
|
||||
immediate
|
||||
#end
|
||||
/>
|
||||
#elseif($column.htmlType == "radio" && !$column.dictType)
|
||||
<NRadioGroup v-model:value="model.$column.javaField">
|
||||
<NSpace>
|
||||
<NRadio value="0" label="请选择字典生成" />
|
||||
</NSpace>
|
||||
</NRadioGroup>
|
||||
#elseif($column.htmlType == "checkbox" && $column.dictType)
|
||||
<DictCheckbox
|
||||
v-model:value="model.$column.javaField"
|
||||
placeholder="请选择$column.columnComment"
|
||||
dict-code="$column.dictType"
|
||||
clearable
|
||||
#if($isImmediate)#set($void = $immediateDictList.add($column.dictType))
|
||||
immediate
|
||||
#end
|
||||
/>
|
||||
#elseif($column.htmlType == "checkbox" && $column.dictType)
|
||||
<NCheckboxGroup v-model:value="model.$column.javaField">
|
||||
<NSpace>
|
||||
<NCheckbox value="0" label="请选择字典生成" />
|
||||
</NSpace>
|
||||
</NCheckboxGroup>
|
||||
#elseif($column.htmlType == 'datetime')
|
||||
<NDatePicker
|
||||
v-model:formatted-value="model.$column.javaField"
|
||||
type="datetime"
|
||||
value-format="yyyy-MM-dd HH:mm:ss"
|
||||
clearable
|
||||
/>
|
||||
#elseif($column.htmlType == "imageUpload")
|
||||
<OssUpload v-model:value="model.$column.javaField" upload-type="image" />
|
||||
#elseif($column.htmlType == "fileUpload")
|
||||
<OssUpload v-model:value="model.$column.javaField" upload-type="file" />
|
||||
#elseif($column.htmlType == "editor")
|
||||
<TinymceEditor v-model:value="model.$column.javaField" />
|
||||
#else <NInput v-model:value="model.$column.javaField" placeholder="请输入$column.columnComment" />
|
||||
#end
|
||||
</NFormItem>
|
||||
#end
|
||||
#end
|
||||
</NForm>
|
||||
<template #footer>
|
||||
<NSpace :size="16">
|
||||
<NButton @click="closeDrawer">{{ $t('common.cancel') }}</NButton>
|
||||
<NButton type="primary" @click="handleSubmit">{{ $t('common.confirm') }}</NButton>
|
||||
</NSpace>
|
||||
</template>
|
||||
</NDrawerContent>
|
||||
</NDrawer>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
||||
@@ -0,0 +1,130 @@
|
||||
#set($ModuleName=$moduleName.substring(0, 1).toUpperCase() + $moduleName.substring(1))
|
||||
<script setup lang="ts">
|
||||
import { toRaw } from 'vue';
|
||||
import { jsonClone } from '@sa/utils';
|
||||
import { useNaiveForm } from '@/hooks/common/form';
|
||||
import { $t } from '@/locales';
|
||||
|
||||
defineOptions({
|
||||
name: '${BusinessName}Search'
|
||||
});
|
||||
|
||||
interface Emits {
|
||||
(e: 'search'): void;
|
||||
}
|
||||
|
||||
const emit = defineEmits<Emits>();
|
||||
|
||||
const { validate, restoreValidation } = useNaiveForm();
|
||||
|
||||
#foreach ($column in $columns)
|
||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
const dateRange${AttrName} = ref<[string, string] | null>(null);
|
||||
#end#end
|
||||
const model = defineModel<Api.$ModuleName.${BusinessName}SearchParams>('model', { required: true });
|
||||
|
||||
const defaultModel = jsonClone(toRaw(model.value));
|
||||
|
||||
function resetModel() {
|
||||
#foreach ($column in $columns)
|
||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
dateRange${AttrName}.value = null;
|
||||
#end
|
||||
#end
|
||||
Object.assign(model.value, defaultModel);
|
||||
}
|
||||
|
||||
async function reset() {
|
||||
await restoreValidation();
|
||||
resetModel();
|
||||
emit('search');
|
||||
}
|
||||
|
||||
async function search() {
|
||||
await validate();
|
||||
#foreach ($column in $columns)
|
||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
if (dateRange${AttrName}.value?.length) {
|
||||
model.value.params!.begin${AttrName} = dateRange${AttrName}.value[0];
|
||||
model.value.params!.end${AttrName} = dateRange${AttrName}.value[1];
|
||||
}
|
||||
#end
|
||||
#end
|
||||
emit('search');
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<NCard :bordered="false" size="small" class="card-wrapper">
|
||||
<NCollapse>
|
||||
<NCollapseItem :title="$t('common.search')" name="$moduleName-${business__name}-search">
|
||||
<NForm :model="model" label-placement="left" :label-width="80">
|
||||
<NGrid responsive="screen" item-responsive>
|
||||
#set($immediateDictList = [])
|
||||
#foreach($column in $columns)
|
||||
#if($column.query)
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
<NFormItemGi span="24 s:12 m:6" label="$column.columnComment" label-width="auto" path="$column.javaField" class="pr-24px">
|
||||
#if($!StrUtil.contains("select, radio, checkbox", $column.htmlType) && $column.dictType)
|
||||
<DictSelect
|
||||
v-model:value="model.$column.javaField"
|
||||
placeholder="请选择$column.columnComment"
|
||||
dict-code="$column.dictType"
|
||||
clearable
|
||||
#if(!$column.isList() && !$immediateDictList.contains($column.dictType))#set($void = $immediateDictList.add($column.dictType))
|
||||
immediate
|
||||
#end
|
||||
/>
|
||||
#elseif($!StrUtil.contains("select, radio, checkbox", $column.htmlType))
|
||||
<NSelect
|
||||
v-model:value="model.$column.javaField"
|
||||
placeholder="请选择$column.columnComment"
|
||||
:options="[]"
|
||||
clearable
|
||||
/>
|
||||
#elseif($column.htmlType == 'datetime' && $column.queryType != "BETWEEN")
|
||||
<NDatePicker
|
||||
v-model:formatted-value="model.$column.javaField"
|
||||
type="datetime"
|
||||
value-format="yyyy-MM-dd HH:mm:ss"
|
||||
clearable
|
||||
/>
|
||||
#elseif($column.htmlType == 'datetime' && $column.queryType == "BETWEEN")
|
||||
<NDatePicker
|
||||
v-model:formatted-value="dateRange${AttrName}"
|
||||
type="datetimerange"
|
||||
value-format="yyyy-MM-dd HH:mm:ss"
|
||||
clearable
|
||||
/>
|
||||
#else <NInput v-model:value="model.$column.javaField" placeholder="请输入$column.columnComment" />
|
||||
#end
|
||||
</NFormItemGi>
|
||||
#end
|
||||
#end
|
||||
<NFormItemGi :show-feedback="false" span="24" class="pr-24px">
|
||||
<NSpace class="w-full" justify="end">
|
||||
<NButton @click="reset">
|
||||
<template #icon>
|
||||
<icon-ic-round-refresh class="text-icon" />
|
||||
</template>
|
||||
{{ $t('common.reset') }}
|
||||
</NButton>
|
||||
<NButton type="primary" ghost @click="search">
|
||||
<template #icon>
|
||||
<icon-ic-round-search class="text-icon" />
|
||||
</template>
|
||||
{{ $t('common.search') }}
|
||||
</NButton>
|
||||
</NSpace>
|
||||
</NFormItemGi>
|
||||
</NGrid>
|
||||
</NForm>
|
||||
</NCollapseItem>
|
||||
</NCollapse>
|
||||
</NCard>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
||||
@@ -0,0 +1,51 @@
|
||||
#set($BaseEntity = ['createDept', 'createBy', 'createTime', 'updateBy', 'updateTime'])
|
||||
#set($ModuleName = $moduleName.substring(0, 1).toUpperCase() + $moduleName.substring(1))
|
||||
/**
|
||||
* Namespace Api
|
||||
*
|
||||
* All backend api type
|
||||
*/
|
||||
declare namespace Api {
|
||||
/**
|
||||
* namespace ${ModuleName}
|
||||
*
|
||||
* backend api module: "${ModuleName}"
|
||||
*/
|
||||
namespace ${ModuleName} {
|
||||
/** ${businessname} */
|
||||
type ${BusinessName} = Common.CommonRecord<{
|
||||
#foreach($column in $columns)#if(!$BaseEntity.contains($column.javaField))
|
||||
/** $column.columnComment */
|
||||
$column.javaField:#if($column.javaField.indexOf("id") != -1 || $column.javaField.indexOf("Id") != -1) CommonType.IdType; #elseif($column.javaType == 'Long' || $column.javaType == 'Integer' || $column.javaType == 'Double' || $column.javaType == 'Float' || $column.javaType == 'BigDecimal') number; #elseif($column.javaType == 'Boolean') boolean; #else string; #end
|
||||
#end#end
|
||||
}>;
|
||||
|
||||
/** ${businessname} search params */
|
||||
type ${BusinessName}SearchParams = CommonType.RecordNullable<
|
||||
Pick<
|
||||
Api.${ModuleName}.${BusinessName},
|
||||
#foreach($column in $columns)
|
||||
#if($column.query && $column.queryType != 'BETWEEN')
|
||||
| '${column.javaField}'
|
||||
#end
|
||||
#end
|
||||
> &
|
||||
Api.Common.CommonSearchParams
|
||||
>;
|
||||
|
||||
/** ${businessname} operate params */
|
||||
type ${BusinessName}OperateParams = CommonType.RecordNullable<
|
||||
Pick<
|
||||
Api.${ModuleName}.${BusinessName},
|
||||
#foreach($column in $columns)
|
||||
#if($column.insert || $column.edit)
|
||||
| '${column.javaField}'
|
||||
#end
|
||||
#end
|
||||
>
|
||||
>;
|
||||
|
||||
/** ${businessname} list */
|
||||
type ${BusinessName}List = Api.Common.PaginatingQueryRecord<${BusinessName}>;
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>ruoyi-face</artifactId>
|
||||
<artifactId>ruoyi-pet</artifactId>
|
||||
<description>chat聊天模块</description>
|
||||
|
||||
<dependencies>
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
package org.dromara.pet.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.*;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.pet.domain.vo.BizPetMedicalContextVo;
|
||||
import org.dromara.pet.domain.bo.BizPetMedicalContextBo;
|
||||
import org.dromara.pet.service.IBizPetMedicalContextService;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 宠物医疗上下文
|
||||
*
|
||||
* @author shuo
|
||||
* @date 2026-02-25
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/pet/petMedicalContext")
|
||||
public class BizPetMedicalContextController extends BaseController {
|
||||
|
||||
private final IBizPetMedicalContextService bizPetMedicalContextService;
|
||||
|
||||
/**
|
||||
* 查询宠物医疗上下文列表
|
||||
*/
|
||||
@SaCheckPermission("pet:petMedicalContext:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<BizPetMedicalContextVo> list(BizPetMedicalContextBo bo, PageQuery pageQuery) {
|
||||
return bizPetMedicalContextService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出宠物医疗上下文列表
|
||||
*/
|
||||
@SaCheckPermission("pet:petMedicalContext:export")
|
||||
@Log(title = "宠物医疗上下文", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(BizPetMedicalContextBo bo, HttpServletResponse response) {
|
||||
List<BizPetMedicalContextVo> list = bizPetMedicalContextService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "宠物医疗上下文", BizPetMedicalContextVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取宠物医疗上下文详细信息
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@SaCheckPermission("pet:petMedicalContext:query")
|
||||
@GetMapping("/{id}")
|
||||
public R<BizPetMedicalContextVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long id) {
|
||||
return R.ok(bizPetMedicalContextService.queryById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增宠物医疗上下文
|
||||
*/
|
||||
@SaCheckPermission("pet:petMedicalContext:add")
|
||||
@Log(title = "宠物医疗上下文", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody BizPetMedicalContextBo bo) {
|
||||
return toAjax(bizPetMedicalContextService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改宠物医疗上下文
|
||||
*/
|
||||
@SaCheckPermission("pet:petMedicalContext:edit")
|
||||
@Log(title = "宠物医疗上下文", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody BizPetMedicalContextBo bo) {
|
||||
return toAjax(bizPetMedicalContextService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除宠物医疗上下文
|
||||
*
|
||||
* @param ids 主键串
|
||||
*/
|
||||
@SaCheckPermission("pet:petMedicalContext:remove")
|
||||
@Log(title = "宠物医疗上下文", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] ids) {
|
||||
return toAjax(bizPetMedicalContextService.deleteWithValidByIds(List.of(ids), true));
|
||||
}
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
package org.dromara.pet.domain;
|
||||
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 宠物医疗上下文对象 biz_pet_medical_context
|
||||
*
|
||||
* @author shuo
|
||||
* @date 2026-02-25
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("biz_pet_medical_context")
|
||||
public class BizPetMedicalContext extends
|
||||
|
||||
BaseEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId(value = "id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 关联宠物ID
|
||||
*/
|
||||
private Long petId;
|
||||
|
||||
/**
|
||||
* 过敏史
|
||||
*/
|
||||
private String allergies;
|
||||
|
||||
/**
|
||||
* 疫苗接种记录
|
||||
*/
|
||||
private String vaccinations;
|
||||
|
||||
/**
|
||||
* 慢性病史
|
||||
*/
|
||||
private String chronicConditions;
|
||||
|
||||
/**
|
||||
* 日常用药
|
||||
*/
|
||||
private String regularMedications;
|
||||
|
||||
/**
|
||||
* 业务更新时间
|
||||
*/
|
||||
private Date updatedAt;
|
||||
|
||||
/**
|
||||
* 租户编号
|
||||
*/
|
||||
private String tenantId;
|
||||
|
||||
|
||||
}
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
package org.dromara.pet.domain.bo;
|
||||
|
||||
import org.dromara.pet.domain.BizPetMedicalContext;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import jakarta.validation.constraints.*;
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
/**
|
||||
* 宠物医疗上下文业务对象 biz_pet_medical_context
|
||||
*
|
||||
* @author shuo
|
||||
* @date 2026-02-25
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@AutoMapper(target = BizPetMedicalContext.class,reverseConvertGenerate =false)
|
||||
|
||||
public class BizPetMedicalContextBo extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 关联宠物ID
|
||||
*/
|
||||
private Long petId;
|
||||
|
||||
/**
|
||||
* 过敏史
|
||||
*/
|
||||
@NotBlank(message = "过敏史不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String allergies;
|
||||
|
||||
/**
|
||||
* 疫苗接种记录
|
||||
*/
|
||||
@NotBlank(message = "疫苗接种记录不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String vaccinations;
|
||||
|
||||
/**
|
||||
* 慢性病史
|
||||
*/
|
||||
@NotBlank(message = "慢性病史不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String chronicConditions;
|
||||
|
||||
/**
|
||||
* 日常用药
|
||||
*/
|
||||
@NotBlank(message = "日常用药不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String regularMedications;
|
||||
|
||||
/**
|
||||
* 业务更新时间
|
||||
*/
|
||||
@NotNull(message = "业务更新时间不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Date updatedAt;
|
||||
|
||||
/**
|
||||
* 租户编号
|
||||
*/
|
||||
@NotBlank(message = "租户编号不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String tenantId;
|
||||
|
||||
|
||||
}
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
package org.dromara.pet.domain.vo;
|
||||
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.dromara.pet.domain.BizPetMedicalContext;
|
||||
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
import org.dromara.common.excel.annotation.ExcelDictFormat;
|
||||
import org.dromara.common.excel.convert.ExcelDictConvert;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
* 宠物医疗上下文视图对象 biz_pet_medical_context
|
||||
*
|
||||
* @author shuo
|
||||
* @date 2026-02-25
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@AutoMapper(target = BizPetMedicalContext.class)
|
||||
|
||||
public class BizPetMedicalContextVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@ExcelProperty(value = "主键ID")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 关联宠物ID
|
||||
*/
|
||||
@ExcelProperty(value = "关联宠物ID")
|
||||
private Long petId;
|
||||
|
||||
/**
|
||||
* 过敏史
|
||||
*/
|
||||
@ExcelProperty(value = "过敏史")
|
||||
private String allergies;
|
||||
|
||||
/**
|
||||
* 疫苗接种记录
|
||||
*/
|
||||
@ExcelProperty(value = "疫苗接种记录")
|
||||
private String vaccinations;
|
||||
|
||||
/**
|
||||
* 慢性病史
|
||||
*/
|
||||
@ExcelProperty(value = "慢性病史")
|
||||
private String chronicConditions;
|
||||
|
||||
/**
|
||||
* 日常用药
|
||||
*/
|
||||
@ExcelProperty(value = "日常用药")
|
||||
private String regularMedications;
|
||||
|
||||
/**
|
||||
* 业务更新时间
|
||||
*/
|
||||
@ExcelProperty(value = "业务更新时间")
|
||||
private Date updatedAt;
|
||||
|
||||
/**
|
||||
* 租户编号
|
||||
*/
|
||||
@ExcelProperty(value = "租户编号")
|
||||
private String tenantId;
|
||||
|
||||
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package org.dromara.pet.mapper;
|
||||
|
||||
import org.dromara.pet.domain.BizPetMedicalContext;
|
||||
import org.dromara.pet.domain.vo.BizPetMedicalContextVo;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
|
||||
/**
|
||||
* 宠物医疗上下文Mapper接口
|
||||
*
|
||||
* @author shuo
|
||||
* @date 2026-02-25
|
||||
*/
|
||||
public interface BizPetMedicalContextMapper extends BaseMapperPlus<BizPetMedicalContext, BizPetMedicalContextVo> {
|
||||
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
package org.dromara.pet.service;
|
||||
|
||||
import org.dromara.pet.domain.vo.BizPetMedicalContextVo;
|
||||
import org.dromara.pet.domain.bo.BizPetMedicalContextBo;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 宠物医疗上下文Service接口
|
||||
*
|
||||
* @author shuo
|
||||
* @date 2026-02-25
|
||||
*/
|
||||
public interface IBizPetMedicalContextService {
|
||||
|
||||
/**
|
||||
* 查询宠物医疗上下文
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 宠物医疗上下文
|
||||
*/
|
||||
BizPetMedicalContextVo queryById(Long id);
|
||||
|
||||
/**
|
||||
* 分页查询宠物医疗上下文列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 宠物医疗上下文分页列表
|
||||
*/
|
||||
TableDataInfo<BizPetMedicalContextVo> queryPageList(BizPetMedicalContextBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询符合条件的宠物医疗上下文列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 宠物医疗上下文列表
|
||||
*/
|
||||
List<BizPetMedicalContextVo> queryList(BizPetMedicalContextBo bo);
|
||||
|
||||
/**
|
||||
* 新增宠物医疗上下文
|
||||
*
|
||||
* @param bo 宠物医疗上下文
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
Boolean insertByBo(BizPetMedicalContextBo bo);
|
||||
|
||||
/**
|
||||
* 修改宠物医疗上下文
|
||||
*
|
||||
* @param bo 宠物医疗上下文
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
Boolean updateByBo(BizPetMedicalContextBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除宠物医疗上下文信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
||||
+138
@@ -0,0 +1,138 @@
|
||||
package org.dromara.pet.service.impl;
|
||||
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.dromara.pet.domain.bo.BizPetMedicalContextBo;
|
||||
import org.dromara.pet.domain.vo.BizPetMedicalContextVo;
|
||||
import org.dromara.pet.domain.BizPetMedicalContext;
|
||||
import org.dromara.pet.mapper.BizPetMedicalContextMapper;
|
||||
import org.dromara.pet.service.IBizPetMedicalContextService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 宠物医疗上下文Service业务层处理
|
||||
*
|
||||
* @author shuo
|
||||
* @date 2026-02-25
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class BizPetMedicalContextServiceImpl implements IBizPetMedicalContextService {
|
||||
|
||||
private final BizPetMedicalContextMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 查询宠物医疗上下文
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 宠物医疗上下文
|
||||
*/
|
||||
@Override
|
||||
public BizPetMedicalContextVo queryById(Long id) {
|
||||
return baseMapper.selectVoById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询宠物医疗上下文列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 宠物医疗上下文分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<BizPetMedicalContextVo> queryPageList(BizPetMedicalContextBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<BizPetMedicalContext> lqw = buildQueryWrapper(bo);
|
||||
Page<BizPetMedicalContextVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询符合条件的宠物医疗上下文列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 宠物医疗上下文列表
|
||||
*/
|
||||
@Override
|
||||
public List<BizPetMedicalContextVo> queryList(BizPetMedicalContextBo bo) {
|
||||
LambdaQueryWrapper<BizPetMedicalContext> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<BizPetMedicalContext> buildQueryWrapper(BizPetMedicalContextBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<BizPetMedicalContext> lqw = Wrappers.lambdaQuery();
|
||||
lqw.orderByAsc(BizPetMedicalContext::getId);
|
||||
lqw.eq(bo.getPetId() != null, BizPetMedicalContext::getPetId, bo.getPetId());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getAllergies()), BizPetMedicalContext::getAllergies, bo.getAllergies());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getVaccinations()), BizPetMedicalContext::getVaccinations, bo.getVaccinations());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getChronicConditions()), BizPetMedicalContext::getChronicConditions, bo.getChronicConditions());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getRegularMedications()), BizPetMedicalContext::getRegularMedications, bo.getRegularMedications());
|
||||
lqw.eq(bo.getUpdatedAt() != null, BizPetMedicalContext::getUpdatedAt, bo.getUpdatedAt());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getTenantId()), BizPetMedicalContext::getTenantId, bo.getTenantId());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增宠物医疗上下文
|
||||
*
|
||||
* @param bo 宠物医疗上下文
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(BizPetMedicalContextBo bo) {
|
||||
BizPetMedicalContext add = MapstructUtils.convert(bo, BizPetMedicalContext. class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改宠物医疗上下文
|
||||
*
|
||||
* @param bo 宠物医疗上下文
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(BizPetMedicalContextBo bo) {
|
||||
BizPetMedicalContext update = MapstructUtils.convert(bo, BizPetMedicalContext. class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(BizPetMedicalContext entity) {
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验并批量删除宠物医疗上下文信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if (isValid) {
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.dromara.pet.mapper.BizPetMedicalContextMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -122,6 +122,11 @@
|
||||
<artifactId>ruoyi-chat</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-pet</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 支付模块 -->
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
|
||||
Reference in New Issue
Block a user