feat: 新增api代码生成模板
This commit is contained in:
parent
c0ad0e4e4f
commit
7dec936b94
34
docs/java/SysMenuServiceImpl.java
Normal file
34
docs/java/SysMenuServiceImpl.java
Normal file
@ -0,0 +1,34 @@
|
||||
/**
|
||||
* 查询系统菜单列表
|
||||
*
|
||||
* @param menu 菜单信息
|
||||
* @return 菜单列表
|
||||
*/
|
||||
@Override
|
||||
public List<SysMenuVo> selectMenuList(SysMenuBo menu, Long userId) {
|
||||
List<SysMenuVo> menuList;
|
||||
// 管理员显示所有菜单信息
|
||||
if (LoginHelper.isSuperAdmin(userId)) {
|
||||
menuList = baseMapper.selectVoList(new LambdaQueryWrapper<SysMenu>()
|
||||
.like(StringUtils.isNotBlank(menu.getMenuName()), SysMenu::getMenuName, menu.getMenuName())
|
||||
.eq(StringUtils.isNotBlank(menu.getVisible()), SysMenu::getVisible, menu.getVisible())
|
||||
.eq(StringUtils.isNotBlank(menu.getStatus()), SysMenu::getStatus, menu.getStatus())
|
||||
.eq(StringUtils.isNotBlank(menu.getMenuType()), SysMenu::getMenuType, menu.getMenuType())
|
||||
.eq(ObjectUtil.isNotNull(menu.getParentId()), SysMenu::getParentId, menu.getParentId())
|
||||
.orderByAsc(SysMenu::getParentId)
|
||||
.orderByAsc(SysMenu::getOrderNum));
|
||||
} else {
|
||||
QueryWrapper<SysMenu> wrapper = Wrappers.query();
|
||||
wrapper.inSql("r.role_id", "select role_id from sys_user_role where user_id = " + userId)
|
||||
.like(StringUtils.isNotBlank(menu.getMenuName()), "m.menu_name", menu.getMenuName())
|
||||
.eq(StringUtils.isNotBlank(menu.getVisible()), "m.visible", menu.getVisible())
|
||||
.eq(StringUtils.isNotBlank(menu.getStatus()), "m.status", menu.getStatus())
|
||||
.eq(StringUtils.isNotBlank(menu.getMenuType()), "m.menu_type", menu.getMenuType())
|
||||
.eq(ObjectUtil.isNotNull(menu.getParentId()), "m.parent_id", menu.getParentId())
|
||||
.orderByAsc("m.parent_id")
|
||||
.orderByAsc("m.order_num");
|
||||
List<SysMenu> list = baseMapper.selectMenuListByUserId(wrapper);
|
||||
menuList = MapstructUtils.convert(list, SysMenuVo.class);
|
||||
}
|
||||
return menuList;
|
||||
}
|
94
docs/java/VelocityUtils.java
Normal file
94
docs/java/VelocityUtils.java
Normal file
@ -0,0 +1,94 @@
|
||||
/**
|
||||
* 获取模板信息
|
||||
*
|
||||
* @return 模板列表
|
||||
*/
|
||||
public static List<String> getTemplateList(String tplCategory) {
|
||||
List<String> templates = new ArrayList<>();
|
||||
templates.add("vm/java/domain.java.vm");
|
||||
templates.add("vm/java/vo.java.vm");
|
||||
templates.add("vm/java/bo.java.vm");
|
||||
templates.add("vm/java/mapper.java.vm");
|
||||
templates.add("vm/java/service.java.vm");
|
||||
templates.add("vm/java/serviceImpl.java.vm");
|
||||
templates.add("vm/java/controller.java.vm");
|
||||
templates.add("vm/xml/mapper.xml.vm");
|
||||
if (DataBaseHelper.isOracle()) {
|
||||
templates.add("vm/sql/oracle/sql.vm");
|
||||
} else if (DataBaseHelper.isPostgerSql()) {
|
||||
templates.add("vm/sql/postgres/sql.vm");
|
||||
} else if (DataBaseHelper.isSqlServer()) {
|
||||
templates.add("vm/sql/sqlserver/sql.vm");
|
||||
} else {
|
||||
templates.add("vm/sql/sql.vm");
|
||||
}
|
||||
templates.add("vm/ts/api.ts.vm");
|
||||
templates.add("vm/ts/types.ts.vm");
|
||||
templates.add("vm/soybean/typings/soy.api.d.ts.vm");
|
||||
templates.add("vm/soybean/api/soy.api.ts.vm");
|
||||
if (GenConstants.TPL_CRUD.equals(tplCategory)) {
|
||||
templates.add("vm/vue/index.vue.vm");
|
||||
templates.add("vm/soybean/soy.index.vue.vm");
|
||||
} else if (GenConstants.TPL_TREE.equals(tplCategory)) {
|
||||
templates.add("vm/vue/index-tree.vue.vm");
|
||||
}
|
||||
return templates;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件名
|
||||
*/
|
||||
public static String getFileName(String template, GenTable genTable) {
|
||||
// 文件名称
|
||||
String fileName = "";
|
||||
// 包路径
|
||||
String packageName = genTable.getPackageName();
|
||||
// 模块名
|
||||
String moduleName = genTable.getModuleName();
|
||||
// 大写类名
|
||||
String className = genTable.getClassName();
|
||||
// 业务名称
|
||||
String businessName = genTable.getBusinessName();
|
||||
|
||||
String javaPath = PROJECT_PATH + "/" + StringUtils.replace(packageName, ".", "/");
|
||||
String mybatisPath = MYBATIS_PATH + "/" + moduleName;
|
||||
String vuePath = "vue";
|
||||
|
||||
if (template.contains("domain.java.vm")) {
|
||||
fileName = StringUtils.format("{}/domain/{}.java", javaPath, className);
|
||||
}
|
||||
if (template.contains("vo.java.vm")) {
|
||||
fileName = StringUtils.format("{}/domain/vo/{}Vo.java", javaPath, className);
|
||||
}
|
||||
if (template.contains("bo.java.vm")) {
|
||||
fileName = StringUtils.format("{}/domain/bo/{}Bo.java", javaPath, className);
|
||||
}
|
||||
if (template.contains("soy.index.vue.vm")) {
|
||||
fileName = StringUtils.format("soybean/views/{}/{}/index.vue", moduleName, businessName);
|
||||
} else if (template.contains("soy.api.d.ts.vm")) {
|
||||
fileName = StringUtils.format("soybean/typings/api/{}.d.ts", moduleName);
|
||||
} else if (template.contains("soy.api.ts.vm")) {
|
||||
fileName = StringUtils.format("soybean/api/{}/{}.ts", moduleName, businessName);
|
||||
} else if (template.contains("mapper.java.vm")) {
|
||||
fileName = StringUtils.format("{}/mapper/{}Mapper.java", javaPath, className);
|
||||
} else if (template.contains("service.java.vm")) {
|
||||
fileName = StringUtils.format("{}/service/I{}Service.java", javaPath, className);
|
||||
} else if (template.contains("serviceImpl.java.vm")) {
|
||||
fileName = StringUtils.format("{}/service/impl/{}ServiceImpl.java", javaPath, className);
|
||||
} else if (template.contains("controller.java.vm")) {
|
||||
fileName = StringUtils.format("{}/controller/{}Controller.java", javaPath, className);
|
||||
} else if (template.contains("mapper.xml.vm")) {
|
||||
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);
|
||||
} else if (template.contains("index-tree.vue.vm")) {
|
||||
fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName);
|
||||
}
|
||||
return fileName;
|
||||
}
|
36
docs/template/api/soy.api.ts.vm
vendored
Normal file
36
docs/template/api/soy.api.ts.vm
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
import { request } from '@/service/request';
|
||||
|
||||
/** 获取${functionName}列表 */
|
||||
export function fetchGet${BusinessName}List(params?: Api.System.${BusinessName}SearchParams) {
|
||||
return request<Api.${ModuleName}.${BusinessName}List>({
|
||||
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 fetchDelete${BusinessName}(${pkColumn.javaField}s: CommonType.IdType[]) {
|
||||
return request<boolean>({
|
||||
url: `/${moduleName}/${businessName}/${${pkColumn.javaField}s.join(',')}`,
|
||||
method: 'delete'
|
||||
});
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
import { ref, useAttrs } from 'vue';
|
||||
import { useLoading } from '@sa/hooks';
|
||||
import type { SelectOption, SelectProps } from 'naive-ui';
|
||||
import { fetchGetDictTypeOption } from '@/service/api';
|
||||
import { fetchGetDictTypeOption } from '@/service/api/system';
|
||||
|
||||
defineOptions({ name: 'DictSelect' });
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
import { ref, useAttrs } from 'vue';
|
||||
import { useLoading } from '@sa/hooks';
|
||||
import type { TreeOption, TreeSelectProps } from 'naive-ui';
|
||||
import { fetchGetMenuList } from '@/service/api';
|
||||
import { fetchGetMenuList } from '@/service/api/system';
|
||||
import SvgIcon from '@/components/custom/svg-icon.vue';
|
||||
import { handleMenuTree } from '@/utils/ruoyi';
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { ref } from 'vue';
|
||||
import { fetchGetDictDataByType } from '@/service/api';
|
||||
import { fetchGetDictDataByType } from '@/service/api/system';
|
||||
import { useDictStore } from '@/store/modules/dict';
|
||||
|
||||
export function useDict(dictType: string, immediate: boolean = true) {
|
||||
|
@ -1,4 +1,2 @@
|
||||
export * from './auth';
|
||||
export * from './route';
|
||||
export * from './system';
|
||||
export * from './tool';
|
||||
|
@ -3,7 +3,7 @@ import { ref } from 'vue';
|
||||
import { useBoolean, useLoading } from '@sa/hooks';
|
||||
import type { DataTableColumns, TreeInst, TreeOption } from 'naive-ui';
|
||||
import { NButton, NIcon, NInput, NPopconfirm, NTooltip } from 'naive-ui';
|
||||
import { fetchDeleteMenu, fetchGetMenuList } from '@/service/api';
|
||||
import { fetchDeleteMenu, fetchGetMenuList } from '@/service/api/system';
|
||||
import SvgIcon from '@/components/custom/svg-icon.vue';
|
||||
import { useAppStore } from '@/store/modules/app';
|
||||
import { menuIsFrameRecord, menuTypeRecord } from '@/constants/business';
|
||||
|
@ -4,7 +4,7 @@ import type { SelectOption } from 'naive-ui';
|
||||
import { NTooltip } from 'naive-ui';
|
||||
import { useFormRules, useNaiveForm } from '@/hooks/common/form';
|
||||
import { $t } from '@/locales';
|
||||
import { fetchCreateMenu, fetchUpdateMenu } from '@/service/api';
|
||||
import { fetchCreateMenu, fetchUpdateMenu } from '@/service/api/system';
|
||||
import { menuIconTypeOptions, menuIsFrameOptions, menuTypeOptions } from '@/constants/business';
|
||||
import SvgIcon from '@/components/custom/svg-icon.vue';
|
||||
import { getLocalMenuIcons } from '@/utils/icon';
|
||||
|
@ -9,7 +9,7 @@ import {
|
||||
fetchGetGenDataNames,
|
||||
fetchGetGenTableList,
|
||||
fetchSynchGenDbList
|
||||
} from '@/service/api';
|
||||
} from '@/service/api/tool';
|
||||
import { $t } from '@/locales';
|
||||
import { useAppStore } from '@/store/modules/app';
|
||||
import { useTable, useTableOperate } from '@/hooks/common/table';
|
||||
|
@ -1,6 +1,6 @@
|
||||
<script setup lang="tsx">
|
||||
import { watch } from 'vue';
|
||||
import { fetchGetGenDbList, fetchImportGenTable } from '@/service/api';
|
||||
import { fetchGetGenDbList, fetchImportGenTable } from '@/service/api/tool';
|
||||
import { $t } from '@/locales';
|
||||
import { useAppStore } from '@/store/modules/app';
|
||||
import { useTable, useTableOperate } from '@/hooks/common/table';
|
||||
|
@ -4,7 +4,8 @@ import type { FormInst, SelectOption } from 'naive-ui';
|
||||
import { NCheckbox, NInput, NSelect, NTabs } from 'naive-ui';
|
||||
import { useLoading } from '@sa/hooks';
|
||||
import { jsonClone } from '@sa/utils';
|
||||
import { fetchGetDictTypeOption, fetchGetGenTableInfo, fetchUpdateGenTable } from '@/service/api';
|
||||
import { fetchGetDictTypeOption } from '@/service/api/system';
|
||||
import { fetchGetGenTableInfo, fetchUpdateGenTable } from '@/service/api/tool';
|
||||
import { $t } from '@/locales';
|
||||
import { useAppStore } from '@/store/modules/app';
|
||||
import {
|
||||
@ -155,8 +156,8 @@ const columns: NaiveUI.TableColumn<Api.Tool.GenTableColumn>[] = [
|
||||
{
|
||||
key: 'sort',
|
||||
title: $t('common.index'),
|
||||
align: 'left',
|
||||
width: 64
|
||||
align: 'center',
|
||||
width: 80
|
||||
},
|
||||
{
|
||||
key: 'columnName',
|
||||
@ -314,7 +315,7 @@ const columns: NaiveUI.TableColumn<Api.Tool.GenTableColumn>[] = [
|
||||
:data="genTableInfo?.rows"
|
||||
size="small"
|
||||
:flex-height="!appStore.isMobile"
|
||||
:scroll-x="750"
|
||||
:scroll-x="1800"
|
||||
remote
|
||||
class="flex-1"
|
||||
/>
|
||||
|
@ -1,7 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { useLoading } from '@sa/hooks';
|
||||
import { ref, watch } from 'vue';
|
||||
import { fetchGetGenPreview } from '@/service/api';
|
||||
import { fetchGetGenPreview } from '@/service/api/tool';
|
||||
import MonacoEditor from '@/components/common/monaco-editor.vue';
|
||||
|
||||
defineOptions({
|
||||
@ -68,7 +68,7 @@ const genMap: Api.Tool.GenTablePreview = {
|
||||
'vm/java/controller.java.vm': 'controller.java',
|
||||
'vm/xml/mapper.xml.vm': 'mapper.xml',
|
||||
'vm/sql/sql.vm': 'sql',
|
||||
'vm/soybean/soy.api.ts.vm': 'api.ts',
|
||||
'vm/soybean/api/soy.api.ts.vm': 'api.ts',
|
||||
'vm/soybean/typings/soy.api.d.ts.vm': 'type.d.ts',
|
||||
'vm/soybean/soy.index.vue.vm': 'index.vue'
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user