feat: 优化菜单管理功能和数据库结构
This commit is contained in:
parent
0d39feee20
commit
8161575e76
@ -22,8 +22,12 @@ MySQL数据库要求如下:
|
||||
10. 增加一个用户管理功能,允许用户自定义用户,用户可以自定义角色,角色可以自定义权限,用户可以自定义部门
|
||||
11. 创建一个用户登陆web界面,登陆后显示一个JasperReport报表。
|
||||
|
||||
12. 新增一个菜单数据表jhi_company,保存公司许可信息,后端API基本接口功能 和
|
||||
12. 新增一个数据表jhi_company,保存公司许可信息,后端API基本接口功能 和
|
||||
liquibase 数据库初始化脚本,同时将数据库初始化脚本 打包到项目中。
|
||||
|
||||
13. 新增一个数据表jhi_region,保存地区信息,需要有层级关系,而且地区要有对应一个所属公司编号,
|
||||
后端API基本接口功能 和 liquibase 数据库初始化脚本,同时将数据库初始化脚本 打包到项目中。
|
||||
|
||||
对应打开的功能项,用户可以配置自定义菜单。
|
||||
|
||||
请将前端有现的静态菜单 增加到菜单表格 ,然后修改前端为动态菜单方式,读取数据库的菜单配置信息,并显示
|
||||
@ -53,6 +57,7 @@ mvn spring-boot:run -P dev
|
||||
./mvnw clean package -DskipTests
|
||||
java -jar target/jewpms-0.0.1-SNAPSHOT.jar --spring.profiles.active=dev
|
||||
|
||||
修改为使用Bootstrap Vue的模态框ID方式
|
||||
请初始化git 连接到远程仓库
|
||||
https://gitea.vxnet.cn/admingit/jewpms.git
|
||||
提交更新项目代码
|
||||
|
||||
@ -11,6 +11,9 @@ import reactor.core.publisher.Mono;
|
||||
|
||||
@Repository
|
||||
public interface MenuRepository extends R2dbcRepository<Menu, Long> {
|
||||
@Query("SELECT * FROM jhi_menu ORDER BY id")
|
||||
Flux<Menu> findAll(Pageable pageable);
|
||||
|
||||
@Query("SELECT * FROM jhi_menu WHERE parent_id IS NULL ORDER BY order_num")
|
||||
Flux<Menu> findRootMenus();
|
||||
|
||||
|
||||
@ -65,8 +65,8 @@ public class MenuService {
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public Flux<Menu> getAllMenus() {
|
||||
return menuRepository.findAll();
|
||||
public Flux<Menu> getAllMenus(Pageable pageable) {
|
||||
return menuRepository.findAll(pageable);
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
|
||||
@ -40,8 +40,8 @@ public class MenuResource {
|
||||
}
|
||||
|
||||
@GetMapping("/menus")
|
||||
public Flux<Menu> getAllMenus() {
|
||||
return menuService.getAllMenus();
|
||||
public Flux<Menu> getAllMenus(@RequestParam(defaultValue = "0") int page, @RequestParam(defaultValue = "10") int size) {
|
||||
return menuService.getAllMenus(PageRequest.of(page, size));
|
||||
}
|
||||
|
||||
@GetMapping("/menus/tree")
|
||||
|
||||
@ -12,34 +12,34 @@
|
||||
-->
|
||||
<changeSet id="00000000000001" author="jhipster">
|
||||
<createTable tableName="jhi_user">
|
||||
<column name="id" type="bigint" autoIncrement="true" startWith="1050">
|
||||
<column name="id" type="bigint" autoIncrement="true" startWith="1050" remarks="主键ID">
|
||||
<constraints primaryKey="true" nullable="false"/>
|
||||
</column>
|
||||
<column name="login" type="varchar(50)">
|
||||
<column name="login" type="varchar(50)" remarks="登录账号">
|
||||
<constraints unique="true" nullable="false" uniqueConstraintName="ux_user_login"/>
|
||||
</column>
|
||||
<column name="password_hash" type="varchar(60)"/>
|
||||
<column name="first_name" type="varchar(50)"/>
|
||||
<column name="last_name" type="varchar(50)"/>
|
||||
<column name="email" type="varchar(191)">
|
||||
<column name="password_hash" type="varchar(60)" remarks="密码哈希"/>
|
||||
<column name="first_name" type="varchar(50)" remarks="名字"/>
|
||||
<column name="last_name" type="varchar(50)" remarks="姓氏"/>
|
||||
<column name="email" type="varchar(191)" remarks="电子邮箱">
|
||||
<constraints unique="true" nullable="true" uniqueConstraintName="ux_user_email"/>
|
||||
</column>
|
||||
<column name="image_url" type="varchar(256)"/>
|
||||
<column name="activated" type="boolean" valueBoolean="false">
|
||||
<column name="image_url" type="varchar(256)" remarks="头像URL"/>
|
||||
<column name="activated" type="boolean" valueBoolean="false" remarks="是否激活">
|
||||
<constraints nullable="false" />
|
||||
</column>
|
||||
<column name="lang_key" type="varchar(10)"/>
|
||||
<column name="activation_key" type="varchar(20)"/>
|
||||
<column name="reset_key" type="varchar(20)"/>
|
||||
<column name="created_by" type="varchar(50)">
|
||||
<column name="lang_key" type="varchar(10)" remarks="语言设置"/>
|
||||
<column name="activation_key" type="varchar(20)" remarks="激活密钥"/>
|
||||
<column name="reset_key" type="varchar(20)" remarks="重置密钥"/>
|
||||
<column name="created_by" type="varchar(50)" remarks="创建人">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="created_date" type="timestamp"/>
|
||||
<column name="reset_date" type="timestamp">
|
||||
<column name="created_date" type="timestamp" remarks="创建时间"/>
|
||||
<column name="reset_date" type="timestamp" remarks="重置时间">
|
||||
<constraints nullable="true"/>
|
||||
</column>
|
||||
<column name="last_modified_by" type="varchar(50)"/>
|
||||
<column name="last_modified_date" type="timestamp"/>
|
||||
<column name="last_modified_by" type="varchar(50)" remarks="最后修改人"/>
|
||||
<column name="last_modified_date" type="timestamp" remarks="最后修改时间"/>
|
||||
</createTable>
|
||||
|
||||
<createTable tableName="jhi_authority">
|
||||
|
||||
@ -8,46 +8,46 @@
|
||||
|
||||
<changeSet id="20240325000001" author="system">
|
||||
<createTable tableName="jhi_menu">
|
||||
<column name="id" type="bigint" autoIncrement="true">
|
||||
<column name="id" type="bigint" autoIncrement="true" remarks="主键ID">
|
||||
<constraints primaryKey="true" nullable="false"/>
|
||||
</column>
|
||||
<column name="name" type="varchar(50)">
|
||||
<column name="name" type="varchar(50)" remarks="菜单名称">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="path" type="varchar(255)">
|
||||
<column name="path" type="varchar(255)" remarks="路由地址">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="icon" type="varchar(50)"/>
|
||||
<column name="parent_id" type="bigint"/>
|
||||
<column name="order_num" type="int">
|
||||
<column name="icon" type="varchar(50)" remarks="菜单图标"/>
|
||||
<column name="parent_id" type="bigint" remarks="父菜单ID"/>
|
||||
<column name="order_num" type="int" remarks="显示顺序">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="component" type="varchar(255)"/>
|
||||
<column name="is_frame" type="boolean" defaultValueBoolean="false">
|
||||
<column name="component" type="varchar(255)" remarks="组件路径"/>
|
||||
<column name="is_frame" type="boolean" defaultValueBoolean="false" remarks="是否为外链">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="visible" type="boolean" defaultValueBoolean="true">
|
||||
<column name="visible" type="boolean" defaultValueBoolean="true" remarks="菜单状态(true显示 false隐藏)">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="status" type="varchar(1)" defaultValue="0">
|
||||
<column name="status" type="varchar(1)" defaultValue="0" remarks="菜单状态(0正常 1停用)">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="perms" type="varchar(100)"/>
|
||||
<column name="query" type="varchar(255)"/>
|
||||
<column name="remark" type="varchar(500)"/>
|
||||
<column name="menu_type" type="varchar(1)" defaultValue="M">
|
||||
<column name="perms" type="varchar(100)" remarks="权限标识"/>
|
||||
<column name="query" type="varchar(255)" remarks="路由参数"/>
|
||||
<column name="remark" type="varchar(500)" remarks="备注"/>
|
||||
<column name="menu_type" type="varchar(1)" defaultValue="M" remarks="菜单类型(M目录 C菜单 F按钮)">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="createtime" type="timestamp">
|
||||
<column name="createtime" type="timestamp" remarks="创建时间">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="updatetime" type="timestamp">
|
||||
<column name="updatetime" type="timestamp" remarks="更新时间">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="lastmodby" type="varchar(50)">
|
||||
<column name="lastmodby" type="varchar(50)" remarks="最后修改人">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="version" type="bigint" defaultValueNumeric="0">
|
||||
<column name="version" type="bigint" defaultValueNumeric="0" remarks="版本号">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
</createTable>
|
||||
|
||||
@ -8,22 +8,22 @@
|
||||
|
||||
<changeSet id="20240325000002" author="system">
|
||||
<createTable tableName="jhi_company">
|
||||
<column name="id" type="bigint" autoIncrement="true">
|
||||
<column name="id" type="bigint" autoIncrement="true" remarks="主键ID">
|
||||
<constraints primaryKey="true" nullable="false"/>
|
||||
</column>
|
||||
<column name="number" type="varchar(50)">
|
||||
<column name="number" type="varchar(50)" remarks="公司编号">
|
||||
<constraints nullable="false" unique="true"/>
|
||||
</column>
|
||||
<column name="name" type="varchar(100)">
|
||||
<column name="name" type="varchar(100)" remarks="公司名称">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="address" type="varchar(200)"/>
|
||||
<column name="license_no" type="varchar(50)"/>
|
||||
<column name="license_expire" type="timestamp"/>
|
||||
<column name="createtime" type="timestamp"/>
|
||||
<column name="updatetime" type="timestamp"/>
|
||||
<column name="lastmodby" type="varchar(50)"/>
|
||||
<column name="version" type="integer">
|
||||
<column name="address" type="varchar(200)" remarks="公司地址"/>
|
||||
<column name="license_no" type="varchar(50)" remarks="营业执照号码"/>
|
||||
<column name="license_expire" type="timestamp" remarks="营业执照到期日期"/>
|
||||
<column name="createtime" type="timestamp" remarks="创建时间"/>
|
||||
<column name="updatetime" type="timestamp" remarks="更新时间"/>
|
||||
<column name="lastmodby" type="varchar(50)" remarks="最后修改人"/>
|
||||
<column name="version" type="integer" remarks="版本号">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
</createTable>
|
||||
|
||||
@ -9,8 +9,8 @@ export default defineComponent({
|
||||
compatConfig: { MODE: 3 },
|
||||
setup() {
|
||||
const authenticationError: Ref<boolean> = ref(false);
|
||||
const login: Ref<string> = ref(null);
|
||||
const password: Ref<string> = ref(null);
|
||||
const login: Ref<string> = ref('admin');
|
||||
const password: Ref<string> = ref('admin');
|
||||
const rememberMe: Ref<boolean> = ref(false);
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
|
||||
@ -6,6 +6,7 @@ import axios from 'axios';
|
||||
import TreeTable from 'vue-table-with-tree-grid';
|
||||
|
||||
export default defineComponent({
|
||||
compatConfig: { MODE: 3 },
|
||||
name: 'Menu',
|
||||
components: {
|
||||
TreeTable,
|
||||
@ -17,6 +18,7 @@ export default defineComponent({
|
||||
const isFetching = ref(false);
|
||||
const removeId = ref(null);
|
||||
const dialogTitle = ref('');
|
||||
const editDialogRef = ref(null);
|
||||
|
||||
const columns = [
|
||||
{
|
||||
@ -101,9 +103,6 @@ export default defineComponent({
|
||||
loadAll();
|
||||
};
|
||||
|
||||
const editDialogRef = ref(null);
|
||||
const deleteDialogRef = ref(null);
|
||||
|
||||
const openDialog = () => {
|
||||
dialogTitle.value = t('jewpmsApp.menu.home.createLabel');
|
||||
menu.value = {
|
||||
@ -120,13 +119,7 @@ export default defineComponent({
|
||||
lastmodby: '',
|
||||
version: 0,
|
||||
};
|
||||
const modal = document.getElementById('editDialog');
|
||||
if (modal) {
|
||||
const bModal = (modal as any).__vue__.$refs.modal;
|
||||
if (bModal) {
|
||||
bModal.show();
|
||||
}
|
||||
}
|
||||
editDialogRef.value?.show();
|
||||
};
|
||||
|
||||
const closeDialog = () => {
|
||||
@ -141,8 +134,8 @@ export default defineComponent({
|
||||
|
||||
const prepareDelete = menuItem => {
|
||||
removeId.value = menuItem.id;
|
||||
menu.value = menuItem;
|
||||
deleteDialogRef.value?.show();
|
||||
menu.value = { ...menuItem };
|
||||
//deleteDialogRef.value?.show();
|
||||
};
|
||||
|
||||
const save = async () => {
|
||||
@ -166,7 +159,6 @@ export default defineComponent({
|
||||
const removeMenu = async () => {
|
||||
try {
|
||||
await axios.delete(`api/menus/${removeId.value}`);
|
||||
closeDialog();
|
||||
loadAll();
|
||||
} catch (err) {
|
||||
console.error('Error deleting menu:', err);
|
||||
@ -192,10 +184,8 @@ export default defineComponent({
|
||||
prepareDelete,
|
||||
save,
|
||||
removeMenu,
|
||||
deleteMenu: removeMenu,
|
||||
getParentName,
|
||||
editDialogRef,
|
||||
deleteDialogRef,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
@ -3,10 +3,6 @@
|
||||
<h2 class="jh-entity-heading" data-cy="MenuHeading">
|
||||
<span v-text="$t('jewpmsApp.menu.home.title')"></span>
|
||||
<div class="d-flex justify-content-end">
|
||||
<b-button v-b-modal.modal-1>Launch demo modal</b-button>
|
||||
<b-modal id="modal-1" title="BootstrapVue">
|
||||
<p class="my-4">Hello from modal!</p>
|
||||
</b-modal>
|
||||
<button class="btn btn-info mr-2" v-on:click="handleSyncList" data-cy="entitySyncListButton">
|
||||
<font-awesome-icon icon="sync" />
|
||||
<span v-text="$t('jewpmsApp.menu.home.refreshListLabel')"></span>
|
||||
@ -51,7 +47,7 @@
|
||||
<font-awesome-icon icon="pencil-alt" />
|
||||
<span v-text="$t('entity.action.edit')"></span>
|
||||
</button>
|
||||
<button type="button" class="btn btn-danger btn-sm" @click="prepareDelete(row)">
|
||||
<button type="button" class="btn btn-danger btn-sm" v-b-modal.deleteDialog @click="prepareDelete(row)">
|
||||
<font-awesome-icon icon="times" />
|
||||
<span v-text="$t('entity.action.delete')"></span>
|
||||
</button>
|
||||
@ -98,8 +94,8 @@
|
||||
</b-modal>
|
||||
|
||||
<!-- 删除确认对话框 -->
|
||||
<b-modal ref="deleteDialog" :title="$t('entity.delete.title')" @ok="deleteMenu">
|
||||
<p v-text="$t('jewpmsApp.menu.delete.question', { id: menu.id })"></p>
|
||||
<b-modal id="deleteDialog" :title="$t('entity.delete.title')" @ok="removeMenu">
|
||||
<p>{{ $t('jewpmsApp.menu.delete.question') }} id: {{ removeId }}</p>
|
||||
</b-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user