diff --git a/docs/java/SysMenuServiceImpl.java b/docs/java/SysMenuServiceImpl.java new file mode 100644 index 00000000..4c63a211 --- /dev/null +++ b/docs/java/SysMenuServiceImpl.java @@ -0,0 +1,34 @@ + /** + * 查询系统菜单列表 + * + * @param menu 菜单信息 + * @return 菜单列表 + */ + @Override + public List selectMenuList(SysMenuBo menu, Long userId) { + List menuList; + // 管理员显示所有菜单信息 + if (LoginHelper.isSuperAdmin(userId)) { + menuList = baseMapper.selectVoList(new LambdaQueryWrapper() + .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 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 list = baseMapper.selectMenuListByUserId(wrapper); + menuList = MapstructUtils.convert(list, SysMenuVo.class); + } + return menuList; + } diff --git a/docs/java/VelocityUtils.java b/docs/java/VelocityUtils.java new file mode 100644 index 00000000..8545a422 --- /dev/null +++ b/docs/java/VelocityUtils.java @@ -0,0 +1,94 @@ + /** + * 获取模板信息 + * + * @return 模板列表 + */ + public static List getTemplateList(String tplCategory) { + List 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; + } diff --git a/docs/template/api/soy.api.ts.vm b/docs/template/api/soy.api.ts.vm new file mode 100644 index 00000000..3483a4f6 --- /dev/null +++ b/docs/template/api/soy.api.ts.vm @@ -0,0 +1,36 @@ +import { request } from '@/service/request'; + +/** 获取${functionName}列表 */ +export function fetchGet${BusinessName}List(params?: Api.System.${BusinessName}SearchParams) { + return request({ + url: '/${moduleName}/${businessName}/list', + method: 'get', + params + }); +} + +/** 新增${functionName} */ +export function fetchCreate${BusinessName}(data: Api.${ModuleName}.${BusinessName}OperateParams) { + return request({ + url: '/${moduleName}/${businessName}', + method: 'post', + data + }); +} + +/** 修改${functionName} */ +export function fetchUpdate${BusinessName}(data: Api.${ModuleName}.${BusinessName}OperateParams) { + return request({ + url: '/${moduleName}/${businessName}', + method: 'put', + data + }); +} + +/** 批量删除${functionName} */ +export function fetchDelete${BusinessName}(${pkColumn.javaField}s: CommonType.IdType[]) { + return request({ + url: `/${moduleName}/${businessName}/${${pkColumn.javaField}s.join(',')}`, + method: 'delete' + }); +} diff --git a/template/soy.index.vue.vm b/docs/template/soy.index.vue.vm similarity index 100% rename from template/soy.index.vue.vm rename to docs/template/soy.index.vue.vm diff --git a/template/typings/soy.api.d.ts.vm b/docs/template/typings/soy.api.d.ts.vm similarity index 100% rename from template/typings/soy.api.d.ts.vm rename to docs/template/typings/soy.api.d.ts.vm diff --git a/src/components/custom/dict-select.vue b/src/components/custom/dict-select.vue index a6cdaf1b..c7de1bb3 100644 --- a/src/components/custom/dict-select.vue +++ b/src/components/custom/dict-select.vue @@ -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' }); diff --git a/src/components/custom/menu-tree-select.vue b/src/components/custom/menu-tree-select.vue index e483d74c..734dc223 100644 --- a/src/components/custom/menu-tree-select.vue +++ b/src/components/custom/menu-tree-select.vue @@ -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'; diff --git a/src/hooks/business/dict.ts b/src/hooks/business/dict.ts index 5ebc17a0..30db36f1 100644 --- a/src/hooks/business/dict.ts +++ b/src/hooks/business/dict.ts @@ -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) { diff --git a/src/service/api/index.ts b/src/service/api/index.ts index 3a7184f5..89f4e581 100644 --- a/src/service/api/index.ts +++ b/src/service/api/index.ts @@ -1,4 +1,2 @@ export * from './auth'; export * from './route'; -export * from './system'; -export * from './tool'; diff --git a/src/views/system/menu/index.vue b/src/views/system/menu/index.vue index 1b9c3f0d..ea668ee4 100644 --- a/src/views/system/menu/index.vue +++ b/src/views/system/menu/index.vue @@ -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'; diff --git a/src/views/system/menu/modules/menu-operate-drawer.vue b/src/views/system/menu/modules/menu-operate-drawer.vue index 5a865ced..e9106085 100644 --- a/src/views/system/menu/modules/menu-operate-drawer.vue +++ b/src/views/system/menu/modules/menu-operate-drawer.vue @@ -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'; diff --git a/src/views/tool/gen/index.vue b/src/views/tool/gen/index.vue index 2e47b102..2fe62fa0 100644 --- a/src/views/tool/gen/index.vue +++ b/src/views/tool/gen/index.vue @@ -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'; diff --git a/src/views/tool/gen/modules/gen-table-import-drawer.vue b/src/views/tool/gen/modules/gen-table-import-drawer.vue index 2644187b..e01b49d7 100644 --- a/src/views/tool/gen/modules/gen-table-import-drawer.vue +++ b/src/views/tool/gen/modules/gen-table-import-drawer.vue @@ -1,6 +1,6 @@