From 2439fff936397f9a05e98829f85ce3fb32cee331 Mon Sep 17 00:00:00 2001 From: zhouhao Date: Wed, 5 Apr 2017 16:48:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=8F=9C=E5=8D=95=E5=8A=9F?= =?UTF-8?q?=E8=83=BD(=E6=9B=BF=E4=BB=A3=E5=8E=9Fexplorer)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hsweb-system-explorer-service-api/pom.xml | 43 ---- .../service/explorer/simple/MenuService.java | 36 ---- .../explorer/simple/SimpleMenuService.java | 67 ------- .../hsweb-system-menu-controller}/pom.xml | 14 +- .../web/controller/menu/MenuController.java | 55 +++++ .../controller/menu/MenuGroupController.java | 57 ++++++ .../hsweb-system-menu-dao-api/pom.xml | 45 +++++ .../hswebframework/web/dao/menu/MenuDao.java | 30 +++ .../web/dao/menu/MenuGroupBindDao.java | 27 +++ .../web/dao/menu/MenuGroupDao.java | 27 +++ .../hsweb-system-menu-dao-mybatis/pom.xml | 44 ++++ .../mappers/menu/MenuGroupBindMapper.xml | 70 +++++++ .../mybatis/mappers/menu/MenuGroupMapper.xml | 68 +++++++ .../dao/mybatis/mappers/menu}/MenuMapper.xml | 6 +- .../hsweb-system-menu-dao/pom.xml | 36 ++++ .../hsweb-system-menu-entity/pom.xml | 45 +++++ .../web/entity/menu}/MenuEntity.java | 34 +--- .../web/entity/menu/MenuGroupBindEntity.java | 136 +++++++++++++ .../web/entity/menu/MenuGroupEntity.java | 108 ++++++++++ .../web/entity/menu/SimpleMenuEntity.java | 123 ++++++++++++ .../menu/SimpleMenuGroupBindEntity.java | 140 +++++++++++++ .../entity/menu/SimpleMenuGroupEntity.java | 121 +++++++++++ .../hsweb-system-menu-service-api}/pom.xml | 18 +- .../service/menu/MenuGroupBindService.java | 32 +++ .../web/service/menu/MenuGroupService.java | 40 ++++ .../web/service/menu/MenuService.java | 39 ++++ .../hsweb-system-menu-service-simple}/pom.xml | 20 +- .../service/menu/simple/CacheConstants.java | 30 +++ .../simple/SimpleMenuGroupBindService.java | 48 +++++ .../menu/simple/SimpleMenuGroupService.java | 189 ++++++++++++++++++ .../menu/simple/SimpleMenuService.java | 91 +++++++++ .../hsweb-system-menu-service}/pom.xml | 11 +- .../hsweb-system-menu-starter}/pom.xml | 30 ++- .../src/main/resources/hsweb-starter.js | 91 +++++++++ .../web/starter/menu/MenuGroupTests.java | 87 ++++++++ .../web/starter/menu}/MenuTests.java | 31 ++- .../src/test/resources/application.yml | 4 +- .../pom.xml | 11 +- 38 files changed, 1869 insertions(+), 235 deletions(-) delete mode 100644 hsweb-system/hsweb-system-explorer/hsweb-system-explorer-service/hsweb-system-explorer-service-api/pom.xml delete mode 100644 hsweb-system/hsweb-system-explorer/hsweb-system-explorer-service/hsweb-system-explorer-service-api/src/main/java/org/hswebframework/web/service/explorer/simple/MenuService.java delete mode 100644 hsweb-system/hsweb-system-explorer/hsweb-system-explorer-service/hsweb-system-explorer-service-simple/src/main/java/org/hswebframework/web/service/explorer/simple/SimpleMenuService.java rename hsweb-system/{hsweb-system-explorer/hsweb-system-explorer-dao/hsweb-system-explorer-dao-mybatis => hsweb-system-menu/hsweb-system-menu-controller}/pom.xml (75%) create mode 100644 hsweb-system/hsweb-system-menu/hsweb-system-menu-controller/src/main/java/org/hswebframework/web/controller/menu/MenuController.java create mode 100644 hsweb-system/hsweb-system-menu/hsweb-system-menu-controller/src/main/java/org/hswebframework/web/controller/menu/MenuGroupController.java create mode 100644 hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/hsweb-system-menu-dao-api/pom.xml create mode 100644 hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/hsweb-system-menu-dao-api/src/main/java/org/hswebframework/web/dao/menu/MenuDao.java create mode 100644 hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/hsweb-system-menu-dao-api/src/main/java/org/hswebframework/web/dao/menu/MenuGroupBindDao.java create mode 100644 hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/hsweb-system-menu-dao-api/src/main/java/org/hswebframework/web/dao/menu/MenuGroupDao.java create mode 100644 hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/hsweb-system-menu-dao-mybatis/pom.xml create mode 100644 hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/hsweb-system-menu-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/menu/MenuGroupBindMapper.xml create mode 100644 hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/hsweb-system-menu-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/menu/MenuGroupMapper.xml rename hsweb-system/{hsweb-system-explorer/hsweb-system-explorer-dao/hsweb-system-explorer-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/explorer => hsweb-system-menu/hsweb-system-menu-dao/hsweb-system-menu-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/menu}/MenuMapper.xml (95%) create mode 100644 hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/pom.xml create mode 100644 hsweb-system/hsweb-system-menu/hsweb-system-menu-entity/pom.xml rename hsweb-system/{hsweb-system-explorer/hsweb-system-explorer-entity/src/main/java/org/hswebframework/web/entity/explorer => hsweb-system-menu/hsweb-system-menu-entity/src/main/java/org/hswebframework/web/entity/menu}/MenuEntity.java (54%) create mode 100644 hsweb-system/hsweb-system-menu/hsweb-system-menu-entity/src/main/java/org/hswebframework/web/entity/menu/MenuGroupBindEntity.java create mode 100644 hsweb-system/hsweb-system-menu/hsweb-system-menu-entity/src/main/java/org/hswebframework/web/entity/menu/MenuGroupEntity.java create mode 100644 hsweb-system/hsweb-system-menu/hsweb-system-menu-entity/src/main/java/org/hswebframework/web/entity/menu/SimpleMenuEntity.java create mode 100644 hsweb-system/hsweb-system-menu/hsweb-system-menu-entity/src/main/java/org/hswebframework/web/entity/menu/SimpleMenuGroupBindEntity.java create mode 100644 hsweb-system/hsweb-system-menu/hsweb-system-menu-entity/src/main/java/org/hswebframework/web/entity/menu/SimpleMenuGroupEntity.java rename hsweb-system/{hsweb-system-explorer/hsweb-system-explorer-entity => hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-api}/pom.xml (81%) create mode 100644 hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-api/src/main/java/org/hswebframework/web/service/menu/MenuGroupBindService.java create mode 100644 hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-api/src/main/java/org/hswebframework/web/service/menu/MenuGroupService.java create mode 100644 hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-api/src/main/java/org/hswebframework/web/service/menu/MenuService.java rename hsweb-system/{hsweb-system-explorer/hsweb-system-explorer-dao/hsweb-system-explorer-dao-api => hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-simple}/pom.xml (67%) create mode 100644 hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-simple/src/main/java/org/hswebframework/web/service/menu/simple/CacheConstants.java create mode 100644 hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-simple/src/main/java/org/hswebframework/web/service/menu/simple/SimpleMenuGroupBindService.java create mode 100644 hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-simple/src/main/java/org/hswebframework/web/service/menu/simple/SimpleMenuGroupService.java create mode 100644 hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-simple/src/main/java/org/hswebframework/web/service/menu/simple/SimpleMenuService.java rename hsweb-system/{hsweb-system-explorer/hsweb-system-explorer-dao => hsweb-system-menu/hsweb-system-menu-service}/pom.xml (83%) rename hsweb-system/{hsweb-system-explorer/hsweb-system-explorer-starter => hsweb-system-menu/hsweb-system-menu-starter}/pom.xml (78%) create mode 100644 hsweb-system/hsweb-system-menu/hsweb-system-menu-starter/src/main/resources/hsweb-starter.js create mode 100644 hsweb-system/hsweb-system-menu/hsweb-system-menu-starter/src/test/java/org/hswebframework/web/starter/menu/MenuGroupTests.java rename hsweb-system/{hsweb-system-explorer/hsweb-system-explorer-starter/src/test/java/org/hswebframework/web/starter/explorer => hsweb-system-menu/hsweb-system-menu-starter/src/test/java/org/hswebframework/web/starter/menu}/MenuTests.java (57%) rename hsweb-system/{hsweb-system-explorer/hsweb-system-explorer-starter => hsweb-system-menu/hsweb-system-menu-starter}/src/test/resources/application.yml (74%) rename hsweb-system/{hsweb-system-explorer => hsweb-system-menu}/pom.xml (79%) diff --git a/hsweb-system/hsweb-system-explorer/hsweb-system-explorer-service/hsweb-system-explorer-service-api/pom.xml b/hsweb-system/hsweb-system-explorer/hsweb-system-explorer-service/hsweb-system-explorer-service-api/pom.xml deleted file mode 100644 index e312241e8..000000000 --- a/hsweb-system/hsweb-system-explorer/hsweb-system-explorer-service/hsweb-system-explorer-service-api/pom.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - hsweb-system-explorer-service - org.hswebframework.web - 3.0-SNAPSHOT - - 4.0.0 - - hsweb-system-explorer-service-api - - - - org.hswebframework.web - hsweb-system-explorer-entity - ${project.version} - - - org.hswebframework.web - hsweb-commons-service-api - ${project.version} - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-explorer/hsweb-system-explorer-service/hsweb-system-explorer-service-api/src/main/java/org/hswebframework/web/service/explorer/simple/MenuService.java b/hsweb-system/hsweb-system-explorer/hsweb-system-explorer-service/hsweb-system-explorer-service-api/src/main/java/org/hswebframework/web/service/explorer/simple/MenuService.java deleted file mode 100644 index d4411d154..000000000 --- a/hsweb-system/hsweb-system-explorer/hsweb-system-explorer-service/hsweb-system-explorer-service-api/src/main/java/org/hswebframework/web/service/explorer/simple/MenuService.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2016 http://www.hswebframework.org - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.hswebframework.web.service.explorer.simple; - -import org.hswebframework.web.entity.explorer.MenuEntity; -import org.hswebframework.web.service.CrudService; - -import java.util.List; - -/** - * TODO 完成注释 - * - * @author zhouhao - */ -public interface MenuService - extends CrudService, String> { - MenuEntity getByPermissionId(String permissionId); - - List> getByPermissionId(List permissionId); - -} diff --git a/hsweb-system/hsweb-system-explorer/hsweb-system-explorer-service/hsweb-system-explorer-service-simple/src/main/java/org/hswebframework/web/service/explorer/simple/SimpleMenuService.java b/hsweb-system/hsweb-system-explorer/hsweb-system-explorer-service/hsweb-system-explorer-service-simple/src/main/java/org/hswebframework/web/service/explorer/simple/SimpleMenuService.java deleted file mode 100644 index 21ab8093c..000000000 --- a/hsweb-system/hsweb-system-explorer/hsweb-system-explorer-service/hsweb-system-explorer-service-simple/src/main/java/org/hswebframework/web/service/explorer/simple/SimpleMenuService.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2016 http://www.hswebframework.org - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.hswebframework.web.service.explorer.simple; - -import org.hswebframework.web.dao.explorer.MenuDao; -import org.hswebframework.web.entity.authorization.ActionEntity; -import org.hswebframework.web.entity.explorer.MenuEntity; -import org.hswebframework.web.id.IDGenerator; -import org.hswebframework.web.service.AbstractTreeSortService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - * TODO 完成注释 - * - * @author zhouhao - */ -@Service("menuService") -public class SimpleMenuService - extends AbstractTreeSortService, String> - implements MenuService { - - //dao api - private MenuDao menuDao; - - @Override - protected IDGenerator getIDGenerator() { - return IDGenerator.MD5; - } - - @Autowired - public void setMenuDao(MenuDao menuDao) { - this.menuDao = menuDao; - } - - @Override - public MenuDao getDao() { - return menuDao; - } - - @Override - public List> getByPermissionId(List permissionId) { - return createQuery().noPaging().where().in("permissionId", permissionId).list(); - } - - @Override - public MenuEntity getByPermissionId(String permissionId) { - return createQuery().noPaging().where().is("permissionId", permissionId).single(); - } -} diff --git a/hsweb-system/hsweb-system-explorer/hsweb-system-explorer-dao/hsweb-system-explorer-dao-mybatis/pom.xml b/hsweb-system/hsweb-system-menu/hsweb-system-menu-controller/pom.xml similarity index 75% rename from hsweb-system/hsweb-system-explorer/hsweb-system-explorer-dao/hsweb-system-explorer-dao-mybatis/pom.xml rename to hsweb-system/hsweb-system-menu/hsweb-system-menu-controller/pom.xml index 3e4031e92..ded69ba5b 100644 --- a/hsweb-system/hsweb-system-explorer/hsweb-system-explorer-dao/hsweb-system-explorer-dao-mybatis/pom.xml +++ b/hsweb-system/hsweb-system-menu/hsweb-system-menu-controller/pom.xml @@ -20,23 +20,29 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - hsweb-system-explorer-dao + hsweb-system-menu org.hswebframework.web 3.0-SNAPSHOT 4.0.0 - hsweb-system-explorer-dao-mybatis + hsweb-system-menu-controller + + javax.servlet + servlet-api + 2.5 + true + org.hswebframework.web - hsweb-system-explorer-dao-api + hsweb-system-menu-service-api ${project.version} org.hswebframework.web - hsweb-commons-dao-mybatis + hsweb-commons-controller ${project.version} diff --git a/hsweb-system/hsweb-system-menu/hsweb-system-menu-controller/src/main/java/org/hswebframework/web/controller/menu/MenuController.java b/hsweb-system/hsweb-system-menu/hsweb-system-menu-controller/src/main/java/org/hswebframework/web/controller/menu/MenuController.java new file mode 100644 index 000000000..99c4f68cd --- /dev/null +++ b/hsweb-system/hsweb-system-menu/hsweb-system-menu-controller/src/main/java/org/hswebframework/web/controller/menu/MenuController.java @@ -0,0 +1,55 @@ +/* + * Copyright 2016 http://www.hswebframework.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ + +package org.hswebframework.web.controller.menu; + +import org.hswebframework.web.authorization.annotation.Authorize; +import org.hswebframework.web.commons.entity.param.QueryParamEntity; +import org.hswebframework.web.controller.GenericEntityController; +import org.hswebframework.web.entity.menu.MenuEntity; +import org.hswebframework.web.entity.menu.MenuGroupEntity; +import org.hswebframework.web.logging.AccessLogger; +import org.hswebframework.web.service.menu.MenuGroupService; +import org.hswebframework.web.service.menu.MenuService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * 菜单分组 + * + * @author hsweb-generator-online + */ +@RestController +@RequestMapping("${hsweb.web.mappings.menu:menu}") +@Authorize(permission = "menu") +@AccessLogger("菜单") +public class MenuController implements GenericEntityController, String, QueryParamEntity, MenuEntity> { + + private MenuService menuService; + + @Autowired + public void setMenuGroupService(MenuService menuService) { + this.menuService = menuService; + } + + @Override + public MenuService getService() { + return menuService; + } +} diff --git a/hsweb-system/hsweb-system-menu/hsweb-system-menu-controller/src/main/java/org/hswebframework/web/controller/menu/MenuGroupController.java b/hsweb-system/hsweb-system-menu/hsweb-system-menu-controller/src/main/java/org/hswebframework/web/controller/menu/MenuGroupController.java new file mode 100644 index 000000000..9fa0863bc --- /dev/null +++ b/hsweb-system/hsweb-system-menu/hsweb-system-menu-controller/src/main/java/org/hswebframework/web/controller/menu/MenuGroupController.java @@ -0,0 +1,57 @@ +/* + * Copyright 2016 http://www.hswebframework.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.hswebframework.web.controller.menu; + +import org.hswebframework.web.authorization.annotation.Authorize; +import org.hswebframework.web.commons.entity.param.QueryParamEntity; +import org.hswebframework.web.controller.GenericEntityController; +import org.hswebframework.web.entity.menu.MenuGroupEntity; +import org.hswebframework.web.logging.AccessLogger; +import org.hswebframework.web.service.menu.MenuGroupService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * 菜单分组 + * + * @author hsweb-generator-online + */ +@RestController +@RequestMapping("${hsweb.web.mappings.menu-group:menu-group}") +@Authorize(permission = "menu-group") +@AccessLogger("菜单分组") +public class MenuGroupController implements GenericEntityController { + + private MenuGroupService menuGroupService; + + @Override + public MenuGroupEntity modelToEntity(MenuGroupEntity model, MenuGroupEntity entity) { + return model; + } + + @Autowired + public void setMenuGroupService(MenuGroupService menuGroupService) { + this.menuGroupService = menuGroupService; + } + + @Override + public MenuGroupService getService() { + return menuGroupService; + } +} diff --git a/hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/hsweb-system-menu-dao-api/pom.xml b/hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/hsweb-system-menu-dao-api/pom.xml new file mode 100644 index 000000000..2dbb7d466 --- /dev/null +++ b/hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/hsweb-system-menu-dao-api/pom.xml @@ -0,0 +1,45 @@ + + + + + + hsweb-system-menu-dao + org.hswebframework.web + 3.0-SNAPSHOT + + 4.0.0 + + hsweb-system-menu-dao-api + + + + org.hswebframework.web + hsweb-system-menu-entity + ${project.version} + + + org.hswebframework.web + hsweb-commons-dao-api + ${project.version} + + + + \ No newline at end of file diff --git a/hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/hsweb-system-menu-dao-api/src/main/java/org/hswebframework/web/dao/menu/MenuDao.java b/hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/hsweb-system-menu-dao-api/src/main/java/org/hswebframework/web/dao/menu/MenuDao.java new file mode 100644 index 000000000..34c6db18e --- /dev/null +++ b/hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/hsweb-system-menu-dao-api/src/main/java/org/hswebframework/web/dao/menu/MenuDao.java @@ -0,0 +1,30 @@ +/* + * Copyright 2016 http://www.hswebframework.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ + +package org.hswebframework.web.dao.menu; + +import org.hswebframework.web.dao.CrudDao; +import org.hswebframework.web.entity.menu.MenuEntity; + +/** + * TODO 完成注释 + * + * @author zhouhao + */ +public interface MenuDao extends CrudDao, String> { +} diff --git a/hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/hsweb-system-menu-dao-api/src/main/java/org/hswebframework/web/dao/menu/MenuGroupBindDao.java b/hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/hsweb-system-menu-dao-api/src/main/java/org/hswebframework/web/dao/menu/MenuGroupBindDao.java new file mode 100644 index 000000000..3639de439 --- /dev/null +++ b/hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/hsweb-system-menu-dao-api/src/main/java/org/hswebframework/web/dao/menu/MenuGroupBindDao.java @@ -0,0 +1,27 @@ +/* + * Copyright 2016 http://www.hswebframework.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.hswebframework.web.dao.menu; + +import org.hswebframework.web.dao.CrudDao; +import org.hswebframework.web.entity.menu.MenuGroupBindEntity; + +/** +* 菜单分组关联 DAO接口 +* @author hsweb-generator-online + */ +public interface MenuGroupBindDao extends CrudDao { +} diff --git a/hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/hsweb-system-menu-dao-api/src/main/java/org/hswebframework/web/dao/menu/MenuGroupDao.java b/hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/hsweb-system-menu-dao-api/src/main/java/org/hswebframework/web/dao/menu/MenuGroupDao.java new file mode 100644 index 000000000..6ddc31cf9 --- /dev/null +++ b/hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/hsweb-system-menu-dao-api/src/main/java/org/hswebframework/web/dao/menu/MenuGroupDao.java @@ -0,0 +1,27 @@ +/* + * Copyright 2016 http://www.hswebframework.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.hswebframework.web.dao.menu; + +import org.hswebframework.web.dao.CrudDao; +import org.hswebframework.web.entity.menu.MenuGroupEntity; + +/** +* 菜单分组 DAO接口 +* @author hsweb-generator-online + */ +public interface MenuGroupDao extends CrudDao { +} diff --git a/hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/hsweb-system-menu-dao-mybatis/pom.xml b/hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/hsweb-system-menu-dao-mybatis/pom.xml new file mode 100644 index 000000000..1070a0dec --- /dev/null +++ b/hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/hsweb-system-menu-dao-mybatis/pom.xml @@ -0,0 +1,44 @@ + + + + + + hsweb-system-menu-dao + org.hswebframework.web + 3.0-SNAPSHOT + + 4.0.0 + + hsweb-system-menu-dao-mybatis + + + + org.hswebframework.web + hsweb-system-menu-dao-api + ${project.version} + + + org.hswebframework.web + hsweb-commons-dao-mybatis + ${project.version} + + + \ No newline at end of file diff --git a/hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/hsweb-system-menu-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/menu/MenuGroupBindMapper.xml b/hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/hsweb-system-menu-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/menu/MenuGroupBindMapper.xml new file mode 100644 index 000000000..7600f8529 --- /dev/null +++ b/hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/hsweb-system-menu-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/menu/MenuGroupBindMapper.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + delete from S_MENU_GROUP_BIND where u_id =#{id} + + + + + + + + + + + + + + + + diff --git a/hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/hsweb-system-menu-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/menu/MenuGroupMapper.xml b/hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/hsweb-system-menu-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/menu/MenuGroupMapper.xml new file mode 100644 index 000000000..b91901d12 --- /dev/null +++ b/hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/hsweb-system-menu-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/menu/MenuGroupMapper.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + delete from S_MENU_GROUP where u_id =#{id} + + + + + + + + + + + + + + + + diff --git a/hsweb-system/hsweb-system-explorer/hsweb-system-explorer-dao/hsweb-system-explorer-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/explorer/MenuMapper.xml b/hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/hsweb-system-menu-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/menu/MenuMapper.xml similarity index 95% rename from hsweb-system/hsweb-system-explorer/hsweb-system-explorer-dao/hsweb-system-explorer-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/explorer/MenuMapper.xml rename to hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/hsweb-system-menu-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/menu/MenuMapper.xml index b3c36d130..a83aa5a26 100644 --- a/hsweb-system/hsweb-system-explorer/hsweb-system-explorer-dao/hsweb-system-explorer-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/explorer/MenuMapper.xml +++ b/hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/hsweb-system-menu-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/menu/MenuMapper.xml @@ -20,8 +20,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd"> - - + + @@ -39,7 +39,7 @@ - + diff --git a/hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/pom.xml b/hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/pom.xml new file mode 100644 index 000000000..ccbbc1163 --- /dev/null +++ b/hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/pom.xml @@ -0,0 +1,36 @@ + + + + + + hsweb-system-menu + org.hswebframework.web + 3.0-SNAPSHOT + + 4.0.0 + + hsweb-system-menu-dao + pom + + hsweb-system-menu-dao-api + hsweb-system-menu-dao-mybatis + + \ No newline at end of file diff --git a/hsweb-system/hsweb-system-menu/hsweb-system-menu-entity/pom.xml b/hsweb-system/hsweb-system-menu/hsweb-system-menu-entity/pom.xml new file mode 100644 index 000000000..c717958a6 --- /dev/null +++ b/hsweb-system/hsweb-system-menu/hsweb-system-menu-entity/pom.xml @@ -0,0 +1,45 @@ + + + + + + hsweb-system-menu + org.hswebframework.web + 3.0-SNAPSHOT + + 4.0.0 + + hsweb-system-menu-entity + + + + org.hswebframework.web + hsweb-commons-entity + ${project.version} + + + org.hswebframework.web + hsweb-system-authorization-entity + ${project.version} + + + + \ No newline at end of file diff --git a/hsweb-system/hsweb-system-explorer/hsweb-system-explorer-entity/src/main/java/org/hswebframework/web/entity/explorer/MenuEntity.java b/hsweb-system/hsweb-system-menu/hsweb-system-menu-entity/src/main/java/org/hswebframework/web/entity/menu/MenuEntity.java similarity index 54% rename from hsweb-system/hsweb-system-explorer/hsweb-system-explorer-entity/src/main/java/org/hswebframework/web/entity/explorer/MenuEntity.java rename to hsweb-system/hsweb-system-menu/hsweb-system-menu-entity/src/main/java/org/hswebframework/web/entity/menu/MenuEntity.java index 2c02e86d2..b81f0c3da 100644 --- a/hsweb-system/hsweb-system-explorer/hsweb-system-explorer-entity/src/main/java/org/hswebframework/web/entity/explorer/MenuEntity.java +++ b/hsweb-system/hsweb-system-menu/hsweb-system-menu-entity/src/main/java/org/hswebframework/web/entity/menu/MenuEntity.java @@ -1,27 +1,27 @@ /* - * Copyright 2016 http://www.hswebframework.org + * Copyright 2016 http://www.hswebframework.org * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * + * */ -package org.hswebframework.web.entity.explorer; +package org.hswebframework.web.entity.menu; import org.hswebframework.web.commons.entity.*; import org.hswebframework.web.entity.authorization.ActionEntity; import java.util.List; -import java.util.Map; /** * TODO 完成注释 @@ -50,26 +50,10 @@ public interface MenuEntity void setIcon(String icon); - String getAuthentication(); - - void setAuthentication(String authentication); - - Map getAuthenticationConfig(); - - void setAuthenticationConfig(Map authenticationConfig); - - String getOnInit(); - - void setOnInit(String onInit); - boolean isEnabled(); void setEnabled(boolean enabled); - List getActions(); - - void setActions(List actions); - void setChildren(List children); @Override diff --git a/hsweb-system/hsweb-system-menu/hsweb-system-menu-entity/src/main/java/org/hswebframework/web/entity/menu/MenuGroupBindEntity.java b/hsweb-system/hsweb-system-menu/hsweb-system-menu-entity/src/main/java/org/hswebframework/web/entity/menu/MenuGroupBindEntity.java new file mode 100644 index 000000000..ee5317e49 --- /dev/null +++ b/hsweb-system/hsweb-system-menu/hsweb-system-menu-entity/src/main/java/org/hswebframework/web/entity/menu/MenuGroupBindEntity.java @@ -0,0 +1,136 @@ +/* + * Copyright 2016 http://www.hswebframework.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.hswebframework.web.entity.menu; + +import org.hswebframework.web.commons.entity.TreeSortSupportEntity; +import org.hswebframework.web.entity.authorization.DataAccessEntity; +import org.hswebframework.web.entity.authorization.FieldAccessEntity; + +import java.util.List; + +/** + * 菜单分组关联 实体 + * + * @author hsweb-generator-online + */ +public interface MenuGroupBindEntity extends TreeSortSupportEntity { + /*------------------------------------------- + | 属性名常量 | + ===========================================*/ + /** + * 树结构编码 + */ + String treeCode = "treeCode"; + /** + * 父级id + */ + String parentId = "parentId"; + /** + * 树层级 + */ + String level = "level"; + /** + * 排序序号 + */ + String sortIndex = "sortIndex"; + /** + * 是否启用 + */ + String enable = "enabled"; + /** + * 菜单id + */ + String menuId = "menuId"; + /** + * 分组id + */ + String groupId = "groupId"; + /** + * 可选按钮 + */ + String actions = "actions"; + /** + * 行级权限控制配置 + */ + String dataAccesses = "dataAccesses"; + /** + * 列级权限控制 + */ + String fieldAccesses = "fieldAccesses"; + + /** + * @return 是否启用 + */ + Boolean isEnabled(); + + /** + * 设置 是否启用 + */ + void setEnabled(Boolean enabled); + + /** + * @return 菜单id + */ + String getMenuId(); + + /** + * 设置 菜单id + */ + void setMenuId(String menuId); + + /** + * @return 分组id + */ + String getGroupId(); + + /** + * 设置 分组id + */ + void setGroupId(String groupId); + + /** + * @return 可选按钮 + */ + java.util.List getActions(); + + /** + * 设置 可选按钮 + */ + void setActions(java.util.List actions); + + /** + * @return 行级权限控制配置 + */ + java.util.List getDataAccesses(); + + /** + * 设置 行级权限控制配置 + */ + void setDataAccesses(java.util.List dataAccesses); + + /** + * @return 列级权限控制 + */ + java.util.List getFieldAccesses(); + + /** + * 设置 列级权限控制 + */ + void setFieldAccesses(java.util.List fieldAccesses); + + void setChildren(List children); +} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-menu/hsweb-system-menu-entity/src/main/java/org/hswebframework/web/entity/menu/MenuGroupEntity.java b/hsweb-system/hsweb-system-menu/hsweb-system-menu-entity/src/main/java/org/hswebframework/web/entity/menu/MenuGroupEntity.java new file mode 100644 index 000000000..3b9f74dc7 --- /dev/null +++ b/hsweb-system/hsweb-system-menu/hsweb-system-menu-entity/src/main/java/org/hswebframework/web/entity/menu/MenuGroupEntity.java @@ -0,0 +1,108 @@ +/* + * Copyright 2016 http://www.hswebframework.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.hswebframework.web.entity.menu; + +import org.hswebframework.web.commons.entity.TreeSortSupportEntity; + +import java.util.List; + +/** + * 菜单分组 实体 + * + * @author hsweb-generator-online + */ +public interface MenuGroupEntity extends TreeSortSupportEntity { + /*------------------------------------------- + | 属性名常量 | + ===========================================*/ + /** + * 分组名称 + */ + String name = "name"; + /** + * 分组描述 + */ + String describe = "describe"; + /** + * 是否默认 + */ + String defaultGroup = "defaultGroup"; + /** + * 树结构编码 + */ + String treeCode = "treeCode"; + /** + * 父级id + */ + String parentId = "parentId"; + /** + * 树层级 + */ + String level = "level"; + /** + * 排序序号 + */ + String sortIndex = "sortIndex"; + /** + * 是否启用 + */ + String enabled = "enabled"; + + /** + * @return 分组名称 + */ + String getName(); + + /** + * 设置 分组名称 + */ + void setName(String name); + + /** + * @return 分组描述 + */ + String getDescribe(); + + /** + * 设置 分组描述 + */ + void setDescribe(String describe); + + /** + * @return 是否默认 + */ + Boolean isDefaultGroup(); + + /** + * 设置 是否默认 + */ + void setDefaultGroup(Boolean defaultGroup); + + /** + * @return 是否启用 + */ + Boolean isEnabled(); + + /** + * 设置 是否启用 + */ + void setEnabled(Boolean enabled); + + List getBindInfo(); + + void setBindInfo(List bindInfo); +} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-menu/hsweb-system-menu-entity/src/main/java/org/hswebframework/web/entity/menu/SimpleMenuEntity.java b/hsweb-system/hsweb-system-menu/hsweb-system-menu-entity/src/main/java/org/hswebframework/web/entity/menu/SimpleMenuEntity.java new file mode 100644 index 000000000..484c977c6 --- /dev/null +++ b/hsweb-system/hsweb-system-menu/hsweb-system-menu-entity/src/main/java/org/hswebframework/web/entity/menu/SimpleMenuEntity.java @@ -0,0 +1,123 @@ +/* + * Copyright 2016 http://www.hswebframework.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ + +package org.hswebframework.web.entity.menu; + +import org.hswebframework.web.commons.entity.SimpleTreeSortSupportEntity; + +import java.util.List; +import java.util.stream.Collectors; + +/** + * TODO 完成注释 + * + * @author zhouhao + */ +public class SimpleMenuEntity extends SimpleTreeSortSupportEntity + implements MenuEntity { + + //菜单名称 + private String name; + + //备注 + private String describe; + + //权限ID + private String permissionId; + + //菜单对应的url + private String url; + + //图标 + private String icon; + + //是否启用 + private boolean enabled = true; + + //子菜单 + private List children; + + @Override + @SuppressWarnings("unchecked") + public List getChildren() { + return children; + } + + @Override + public void setChildren(List children) { + this.children = children; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescribe() { + return describe; + } + + public void setDescribe(String describe) { + this.describe = describe; + } + + public String getPermissionId() { + return permissionId; + } + + public void setPermissionId(String permissionId) { + this.permissionId = permissionId; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getIcon() { + return icon; + } + + public void setIcon(String icon) { + this.icon = icon; + } + + public boolean isEnabled() { + return enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + @Override + public SimpleMenuEntity clone() { + SimpleMenuEntity target = (SimpleMenuEntity) super.clone(); + target.setProperties(cloneProperties()); + if (null != getChildren()) { + target.setChildren(getChildren().stream().map(SimpleMenuEntity::clone).collect(Collectors.toList())); + } + return target; + } +} diff --git a/hsweb-system/hsweb-system-menu/hsweb-system-menu-entity/src/main/java/org/hswebframework/web/entity/menu/SimpleMenuGroupBindEntity.java b/hsweb-system/hsweb-system-menu/hsweb-system-menu-entity/src/main/java/org/hswebframework/web/entity/menu/SimpleMenuGroupBindEntity.java new file mode 100644 index 000000000..d85e1595e --- /dev/null +++ b/hsweb-system/hsweb-system-menu/hsweb-system-menu-entity/src/main/java/org/hswebframework/web/entity/menu/SimpleMenuGroupBindEntity.java @@ -0,0 +1,140 @@ +/* + * Copyright 2016 http://www.hswebframework.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.hswebframework.web.entity.menu; + +import org.hswebframework.web.commons.entity.SimpleTreeSortSupportEntity; +import org.hswebframework.web.entity.authorization.DataAccessEntity; +import org.hswebframework.web.entity.authorization.FieldAccessEntity; + +import java.util.ArrayList; +import java.util.List; + +/** + * 菜单分组关联 + * + * @author hsweb-generator-online + */ +public class SimpleMenuGroupBindEntity extends SimpleTreeSortSupportEntity implements MenuGroupBindEntity { + //是否启用 + private Boolean enabled; + //菜单id + private String menuId; + //分组id + private String groupId; + //可选按钮 + private java.util.List actions; + //行级权限控制配置 + private java.util.List dataAccesses; + //列级权限控制 + private java.util.List fieldAccesses; + //子节点 + private List children; + + /** + * @return 是否启用 + */ + public Boolean isEnabled() { + return this.enabled; + } + + /** + * 设置 是否启用 + */ + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } + + /** + * @return 菜单id + */ + public String getMenuId() { + return this.menuId; + } + + /** + * 设置 菜单id + */ + public void setMenuId(String menuId) { + this.menuId = menuId; + } + + /** + * @return 分组id + */ + public String getGroupId() { + return this.groupId; + } + + /** + * 设置 分组id + */ + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + /** + * @return 可选按钮 + */ + public java.util.List getActions() { + return this.actions; + } + + /** + * 设置 可选按钮 + */ + public void setActions(java.util.List actions) { + this.actions = actions; + } + + /** + * @return 行级权限控制配置 + */ + public java.util.List getDataAccesses() { + return this.dataAccesses; + } + + /** + * 设置 行级权限控制配置 + */ + public void setDataAccesses(java.util.List dataAccesses) { + this.dataAccesses = dataAccesses; + } + + /** + * @return 列级权限控制 + */ + public java.util.List getFieldAccesses() { + return this.fieldAccesses; + } + + /** + * 设置 列级权限控制 + */ + public void setFieldAccesses(java.util.List fieldAccesses) { + this.fieldAccesses = fieldAccesses; + } + + + public List getChildren() { + return children; + } + + @Override + public void setChildren(List children) { + this.children = new ArrayList(children); + } +} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-menu/hsweb-system-menu-entity/src/main/java/org/hswebframework/web/entity/menu/SimpleMenuGroupEntity.java b/hsweb-system/hsweb-system-menu/hsweb-system-menu-entity/src/main/java/org/hswebframework/web/entity/menu/SimpleMenuGroupEntity.java new file mode 100644 index 000000000..2329c0228 --- /dev/null +++ b/hsweb-system/hsweb-system-menu/hsweb-system-menu-entity/src/main/java/org/hswebframework/web/entity/menu/SimpleMenuGroupEntity.java @@ -0,0 +1,121 @@ +/* + * Copyright 2016 http://www.hswebframework.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.hswebframework.web.entity.menu; + +import org.hswebframework.web.commons.entity.SimpleTreeSortSupportEntity; + +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; + +/** + * 菜单分组 + * + * @author hsweb-generator-online + */ +public class SimpleMenuGroupEntity extends SimpleTreeSortSupportEntity implements MenuGroupEntity { + //分组名称 + private String name; + //分组描述 + private String describe; + //是否默认 + private Boolean defaultGroup; + //是否启用 + private Boolean enabled; + + private List children; + + private List bindInfo; + + /** + * @return 分组名称 + */ + public String getName() { + return this.name; + } + + /** + * 设置 分组名称 + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return 分组描述 + */ + public String getDescribe() { + return this.describe; + } + + /** + * 设置 分组描述 + */ + public void setDescribe(String describe) { + this.describe = describe; + } + + /** + * @return 是否默认 + */ + public Boolean isDefaultGroup() { + return this.defaultGroup; + } + + /** + * 设置 是否默认 + */ + public void setDefaultGroup(Boolean defaultGroup) { + this.defaultGroup = defaultGroup; + } + + @Override + public List getChildren() { + return children; + } + + public void setChildren(List children) { + this.children = children; + } + + @Override + public List getBindInfo() { + if (bindInfo == null) + return Collections.emptyList(); + return new LinkedList<>(bindInfo); + } + + @Override + public void setBindInfo(List bindInfo) { + // TODO: 17-4-5 可优化? + this.bindInfo = new LinkedList(bindInfo); + } + + /** + * @return 是否启用 + */ + public Boolean isEnabled() { + return this.enabled; + } + + /** + * 设置 是否启用 + */ + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } +} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-explorer/hsweb-system-explorer-entity/pom.xml b/hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-api/pom.xml similarity index 81% rename from hsweb-system/hsweb-system-explorer/hsweb-system-explorer-entity/pom.xml rename to hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-api/pom.xml index 19d0adc3f..c9dfd17ad 100644 --- a/hsweb-system/hsweb-system-explorer/hsweb-system-explorer-entity/pom.xml +++ b/hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-api/pom.xml @@ -15,28 +15,22 @@ ~ limitations under the License. ~ --> - - hsweb-system-explorer + hsweb-system-menu-service org.hswebframework.web 3.0-SNAPSHOT 4.0.0 - hsweb-system-explorer-entity + hsweb-system-menu-service-api - - com.alibaba - fastjson - test - org.hswebframework.web - hsweb-commons-entity + hsweb-commons-service-api ${project.version} @@ -44,6 +38,10 @@ hsweb-system-authorization-entity ${project.version} + + org.hswebframework.web + hsweb-system-menu-entity + ${project.version} + - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-api/src/main/java/org/hswebframework/web/service/menu/MenuGroupBindService.java b/hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-api/src/main/java/org/hswebframework/web/service/menu/MenuGroupBindService.java new file mode 100644 index 000000000..a3023c1a3 --- /dev/null +++ b/hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-api/src/main/java/org/hswebframework/web/service/menu/MenuGroupBindService.java @@ -0,0 +1,32 @@ +/* + * Copyright 2016 http://www.hswebframework.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.hswebframework.web.service.menu; + +import org.hswebframework.web.entity.menu.MenuGroupBindEntity; +import org.hswebframework.web.service.CrudService; +import org.hswebframework.web.service.TreeService; + +/** + * 菜单分组关联 服务类 + * + * @author hsweb-generator-online + */ +public interface MenuGroupBindService extends + CrudService + , TreeService { + +} diff --git a/hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-api/src/main/java/org/hswebframework/web/service/menu/MenuGroupService.java b/hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-api/src/main/java/org/hswebframework/web/service/menu/MenuGroupService.java new file mode 100644 index 000000000..e9b969aec --- /dev/null +++ b/hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-api/src/main/java/org/hswebframework/web/service/menu/MenuGroupService.java @@ -0,0 +1,40 @@ +/* + * Copyright 2016 http://www.hswebframework.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.hswebframework.web.service.menu; + +import org.hswebframework.web.entity.menu.MenuEntity; +import org.hswebframework.web.entity.menu.MenuGroupEntity; +import org.hswebframework.web.service.CrudService; +import org.hswebframework.web.service.TreeService; + +import java.util.List; + +/** + * 菜单分组 服务类 + * + * @author hsweb-generator-online + */ +public interface MenuGroupService extends + CrudService + , TreeService { + + List> getMenuByGroupId(List groupId); + + void enable(String id); + + void disable(String id); +} diff --git a/hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-api/src/main/java/org/hswebframework/web/service/menu/MenuService.java b/hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-api/src/main/java/org/hswebframework/web/service/menu/MenuService.java new file mode 100644 index 000000000..f51ebea87 --- /dev/null +++ b/hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-api/src/main/java/org/hswebframework/web/service/menu/MenuService.java @@ -0,0 +1,39 @@ +/* + * Copyright 2016 http://www.hswebframework.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ + +package org.hswebframework.web.service.menu; + + +import org.hswebframework.web.entity.menu.MenuEntity; +import org.hswebframework.web.service.CrudService; +import org.hswebframework.web.service.TreeService; + +import java.util.List; + +/** + * 菜单服务类 + * + * @author zhouhao + */ +public interface MenuService + extends CrudService, String> + , TreeService, String> { + MenuEntity getByPermissionId(String permissionId); + + List> getByPermissionId(List permissionId); +} diff --git a/hsweb-system/hsweb-system-explorer/hsweb-system-explorer-dao/hsweb-system-explorer-dao-api/pom.xml b/hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-simple/pom.xml similarity index 67% rename from hsweb-system/hsweb-system-explorer/hsweb-system-explorer-dao/hsweb-system-explorer-dao-api/pom.xml rename to hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-simple/pom.xml index 07b8527e4..bdaa38d80 100644 --- a/hsweb-system/hsweb-system-explorer/hsweb-system-explorer-dao/hsweb-system-explorer-dao-api/pom.xml +++ b/hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-simple/pom.xml @@ -15,29 +15,37 @@ ~ limitations under the License. ~ --> - - hsweb-system-explorer-dao + hsweb-system-menu-service org.hswebframework.web 3.0-SNAPSHOT 4.0.0 - hsweb-system-explorer-dao-api - + hsweb-system-menu-service-simple org.hswebframework.web - hsweb-system-explorer-entity + hsweb-commons-service-simple ${project.version} org.hswebframework.web - hsweb-commons-dao-api + hsweb-system-menu-service-api + ${project.version} + + + org.hswebframework.web + hsweb-system-authorization-service-api + ${project.version} + + + org.hswebframework.web + hsweb-system-menu-dao-api ${project.version} diff --git a/hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-simple/src/main/java/org/hswebframework/web/service/menu/simple/CacheConstants.java b/hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-simple/src/main/java/org/hswebframework/web/service/menu/simple/CacheConstants.java new file mode 100644 index 000000000..edb5da585 --- /dev/null +++ b/hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-simple/src/main/java/org/hswebframework/web/service/menu/simple/CacheConstants.java @@ -0,0 +1,30 @@ +/* + * Copyright 2016 http://www.hswebframework.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ + +package org.hswebframework.web.service.menu.simple; + +/** + * 缓存使用到的常量 + * + * @author zhouhao + * @see org.springframework.cache.annotation.Cacheable + * @see org.springframework.cache.annotation.CacheEvict + */ +public interface CacheConstants { + String MENU_CACHE_NAME = "hsweb-menu:"; +} diff --git a/hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-simple/src/main/java/org/hswebframework/web/service/menu/simple/SimpleMenuGroupBindService.java b/hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-simple/src/main/java/org/hswebframework/web/service/menu/simple/SimpleMenuGroupBindService.java new file mode 100644 index 000000000..b3ff6b3e0 --- /dev/null +++ b/hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-simple/src/main/java/org/hswebframework/web/service/menu/simple/SimpleMenuGroupBindService.java @@ -0,0 +1,48 @@ +/* + * Copyright 2016 http://www.hswebframework.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.hswebframework.web.service.menu.simple; + +import org.hswebframework.web.dao.menu.MenuGroupBindDao; +import org.hswebframework.web.entity.menu.MenuGroupBindEntity; +import org.hswebframework.web.id.IDGenerator; +import org.hswebframework.web.service.AbstractTreeSortService; +import org.hswebframework.web.service.GenericEntityService; +import org.hswebframework.web.service.menu.MenuGroupBindService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * 默认的服务实现 + * + * @author hsweb-generator-online + */ +@Service("menuGroupBindService") +public class SimpleMenuGroupBindService extends AbstractTreeSortService + implements MenuGroupBindService { + @Autowired + private MenuGroupBindDao menuGroupBindDao; + @Override + protected IDGenerator getIDGenerator() { + return IDGenerator.MD5; + } + + @Override + public MenuGroupBindDao getDao() { + return menuGroupBindDao; + } + +} diff --git a/hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-simple/src/main/java/org/hswebframework/web/service/menu/simple/SimpleMenuGroupService.java b/hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-simple/src/main/java/org/hswebframework/web/service/menu/simple/SimpleMenuGroupService.java new file mode 100644 index 000000000..e2a10fcc6 --- /dev/null +++ b/hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-simple/src/main/java/org/hswebframework/web/service/menu/simple/SimpleMenuGroupService.java @@ -0,0 +1,189 @@ +/* + * Copyright 2016 http://www.hswebframework.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.hswebframework.web.service.menu.simple; + +import org.hswebframework.web.dao.menu.MenuGroupDao; +import org.hswebframework.web.entity.authorization.PermissionRoleEntity; +import org.hswebframework.web.entity.authorization.bind.BindPermissionRoleEntity; +import org.hswebframework.web.entity.menu.MenuEntity; +import org.hswebframework.web.entity.menu.MenuGroupBindEntity; +import org.hswebframework.web.entity.menu.MenuGroupEntity; +import org.hswebframework.web.id.IDGenerator; +import org.hswebframework.web.service.AbstractTreeSortService; +import org.hswebframework.web.service.DefaultDSLUpdateService; +import org.hswebframework.web.service.authorization.RoleService; +import org.hswebframework.web.service.menu.MenuGroupBindService; +import org.hswebframework.web.service.menu.MenuGroupService; +import org.hswebframework.web.service.menu.MenuService; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.CacheConfig; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.cache.annotation.Cacheable; +import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; + +import java.util.LinkedList; +import java.util.List; +import java.util.function.Consumer; +import java.util.stream.Collectors; + +import static org.hswebframework.web.service.menu.simple.CacheConstants.MENU_CACHE_NAME; + +/** + * 默认的服务实现 + * + * @author hsweb-generator-online + */ +@Service("menuGroupService") +@CacheConfig(cacheNames = MENU_CACHE_NAME) +public class SimpleMenuGroupService + extends AbstractTreeSortService + implements MenuGroupService { + @Autowired + private MenuGroupDao menuGroupDao; + + @Autowired(required = false) + private RoleService roleService; + + @Autowired + private MenuService menuService; + + @Autowired + private MenuGroupBindService menuGroupBindService; + + @Override + protected IDGenerator getIDGenerator() { + return IDGenerator.MD5; + } + + @Override + public MenuGroupDao getDao() { + return menuGroupDao; + } + + private boolean checkRoleServiceIsEnable() { + if (roleService == null) { + logger.warn("roleService为空,将不会自动同步角色信息!"); + return false; + } + return true; + } + + @Cacheable(key = "'group-id-list:'+#groupId==null?0:#groupId.hashCode()") + public List> getMenuByGroupId(List groupId) { + List bindEntities = menuGroupBindService.selectByPk(groupId); + if (bindEntities == null || bindEntities.isEmpty()) return new LinkedList<>(); + return menuService.selectByPk(bindEntities.stream() + .map(MenuGroupBindEntity::getMenuId) + .collect(Collectors.toList())); + } + + @CacheEvict(allEntries = true) + public String insert(MenuGroupEntity entity) { + String id = super.insert(entity); + List bindEntities = entity.getBindInfo(); + if (bindEntities != null && !bindEntities.isEmpty()) { + bindEntities.forEach(bind -> bind.setGroupId(entity.getId())); + menuGroupBindService.insertBatch(bindEntities); + } + trySyncRoleInfo(entity); + return id; + } + + @CacheEvict(allEntries = true) + @Override + public int updateByPk(List data) { + return super.updateByPk(data); + } + + @Override + @CacheEvict(allEntries = true) + public int updateByPk(String id, MenuGroupEntity entity) { + return super.updateByPk(id, entity); + } + + @Override + @CacheEvict(allEntries = true) + public int deleteByPk(String id) { + return super.deleteByPk(id); + } + + @Override + public String saveOrUpdateForSingle(MenuGroupEntity entity) { + String id = super.saveOrUpdateForSingle(entity); + trySyncRoleInfo(entity); + return id; + } + + @Override + @CacheEvict(allEntries = true) + public void enable(String id) { + tryValidateProperty(StringUtils.hasLength(id), MenuGroupEntity.id, "{id_is_null}"); + DefaultDSLUpdateService + .createUpdate(getDao()) + .set(MenuGroupEntity.enabled, true) + .where(MenuGroupEntity.id, id).exec(); + if (checkRoleServiceIsEnable()) + roleService.enable(id); + } + + @Override + @CacheEvict(allEntries = true) + public void disable(String id) { + tryValidateProperty(StringUtils.hasLength(id), MenuGroupEntity.id, "{id_is_null}"); + DefaultDSLUpdateService + .createUpdate(getDao()) + .set(MenuGroupEntity.enabled, false) + .where(MenuGroupEntity.id, id).exec(); + if (checkRoleServiceIsEnable()) + roleService.disable(id); + } + + @SuppressWarnings("unchecked") + protected void trySyncRoleInfo(MenuGroupEntity menuGroupEntity) { + if (!checkRoleServiceIsEnable()) return; + //角色的操作,新增or更新 + Consumer> roleEntityConsumer = + roleService.selectByPk(menuGroupEntity.getId()) == null ? roleService::insert : roleService::update; + + //设置属性 + BindPermissionRoleEntity roleEntity = entityFactory.newInstance(BindPermissionRoleEntity.class); + roleEntity.setId(menuGroupEntity.getId()); + roleEntity.setName(menuGroupEntity.getName()); + roleEntity.setEnabled(menuGroupEntity.isEnabled()); + roleEntity.setDescribe(menuGroupEntity.getDescribe()); + List bindEntities = menuGroupEntity.getBindInfo(); + if (bindEntities != null && bindEntities.size() > 0) { + roleEntity.setPermissions(bindEntities.parallelStream() + .map(bind -> { + //转换 MenuGroupBindEntity 为PermissionRoleEntity + PermissionRoleEntity permission = entityFactory.newInstance(PermissionRoleEntity.class, bind); + permission.setRoleId(bind.getGroupId()); + MenuEntity menuEntity = menuService.selectByPk(bind.getMenuId()); + assertNotNull(menuEntity, "menu " + bind.getMenuId() + " not found"); + permission.setPermissionId(menuEntity.getPermissionId()); + return permission; + } + ).sorted() + .collect(Collectors.toList())); + } + + roleEntityConsumer.accept(roleEntity); + } + +} diff --git a/hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-simple/src/main/java/org/hswebframework/web/service/menu/simple/SimpleMenuService.java b/hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-simple/src/main/java/org/hswebframework/web/service/menu/simple/SimpleMenuService.java new file mode 100644 index 000000000..c48c15c06 --- /dev/null +++ b/hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-simple/src/main/java/org/hswebframework/web/service/menu/simple/SimpleMenuService.java @@ -0,0 +1,91 @@ +/* + * Copyright 2016 http://www.hswebframework.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ + +package org.hswebframework.web.service.menu.simple; + +import org.hswebframework.web.dao.menu.MenuDao; +import org.hswebframework.web.entity.menu.MenuEntity; +import org.hswebframework.web.id.IDGenerator; +import org.hswebframework.web.service.AbstractTreeSortService; +import org.hswebframework.web.service.menu.MenuService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.CacheConfig; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.cache.annotation.Cacheable; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * TODO 完成注释 + * + * @author zhouhao + */ +@Service("menuService") +@CacheConfig(cacheNames = CacheConstants.MENU_CACHE_NAME) +public class SimpleMenuService + extends AbstractTreeSortService, String> + implements MenuService { + + private MenuDao menuDao; + + @Override + protected IDGenerator getIDGenerator() { + return IDGenerator.MD5; + } + + @Autowired + public void setMenuDao(MenuDao menuDao) { + this.menuDao = menuDao; + } + + @Override + public MenuDao getDao() { + return menuDao; + } + + @Override + @CacheEvict(allEntries = true) + public int updateByPk(List> data) { + return super.updateByPk(data); + } + + @Override + @CacheEvict(allEntries = true) + public String insert(MenuEntity entity) { + return super.insert(entity); + } + + @Override + @CacheEvict(allEntries = true) + public int deleteByPk(String id) { + return super.deleteByPk(id); + } + + @Override + @Cacheable(key = "'permission-ids:'+#permissionId==null?'0':#permissionId.hashCode()") + public List> getByPermissionId(List permissionId) { + return createQuery().noPaging().where().in("permissionId", permissionId).list(); + } + + @Override + @Cacheable(key = "'permission-id:'+#permissionId") + public MenuEntity getByPermissionId(String permissionId) { + return createQuery().noPaging().where().is("permissionId", permissionId).single(); + } +} diff --git a/hsweb-system/hsweb-system-explorer/hsweb-system-explorer-dao/pom.xml b/hsweb-system/hsweb-system-menu/hsweb-system-menu-service/pom.xml similarity index 83% rename from hsweb-system/hsweb-system-explorer/hsweb-system-explorer-dao/pom.xml rename to hsweb-system/hsweb-system-menu/hsweb-system-menu-service/pom.xml index 7adf294e4..a10469c85 100644 --- a/hsweb-system/hsweb-system-explorer/hsweb-system-explorer-dao/pom.xml +++ b/hsweb-system/hsweb-system-menu/hsweb-system-menu-service/pom.xml @@ -15,23 +15,20 @@ ~ limitations under the License. ~ --> - - hsweb-system-explorer + hsweb-system-menu org.hswebframework.web 3.0-SNAPSHOT 4.0.0 - hsweb-system-explorer-dao + hsweb-system-menu-service pom - hsweb-system-explorer-dao-api - hsweb-system-explorer-dao-mybatis + hsweb-system-menu-service-api + hsweb-system-menu-service-simple - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-explorer/hsweb-system-explorer-starter/pom.xml b/hsweb-system/hsweb-system-menu/hsweb-system-menu-starter/pom.xml similarity index 78% rename from hsweb-system/hsweb-system-explorer/hsweb-system-explorer-starter/pom.xml rename to hsweb-system/hsweb-system-menu/hsweb-system-menu-starter/pom.xml index 2db8d0c6b..c420c9188 100644 --- a/hsweb-system/hsweb-system-explorer/hsweb-system-explorer-starter/pom.xml +++ b/hsweb-system/hsweb-system-menu/hsweb-system-menu-starter/pom.xml @@ -20,13 +20,15 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - hsweb-system-explorer + hsweb-system-menu org.hswebframework.web 3.0-SNAPSHOT 4.0.0 - hsweb-system-explorer-starter + hsweb-system-menu-starter + + @@ -39,20 +41,19 @@ org.hswebframework.web - hsweb-system-explorer-service-simple + hsweb-system-menu-service-simple ${project.version} - org.hswebframework.web - hsweb-system-explorer-dao-mybatis + hsweb-system-menu-dao-mybatis + ${project.version} + + + org.hswebframework.web + hsweb-system-menu-controller ${project.version} - - - - - com.h2database @@ -72,12 +73,19 @@ ${project.version} test + org.hswebframework.web hsweb-tests ${project.version} test - + + javax.servlet + servlet-api + 2.5 + test + + \ No newline at end of file diff --git a/hsweb-system/hsweb-system-menu/hsweb-system-menu-starter/src/main/resources/hsweb-starter.js b/hsweb-system/hsweb-system-menu/hsweb-system-menu-starter/src/main/resources/hsweb-starter.js new file mode 100644 index 000000000..ba4cecb66 --- /dev/null +++ b/hsweb-system/hsweb-system-menu/hsweb-system-menu-starter/src/main/resources/hsweb-starter.js @@ -0,0 +1,91 @@ +/* + * Copyright 2016 http://www.hswebframework.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +//组件信息 +var info = { + groupId: "${project.groupId}", + artifactId: "${project.artifactId}", + version: "${project.version}", + website: "https://github.com/hs-web/hsweb-framework/tree/master/hsweb-system/hsweb-system-menu", + author: "zh.sqy@qq.com", + comment: "菜单分组" +}; + +//版本更新信息 +var versions = [ + // { + // version: "3.0.0", + // upgrade: function (context) { + // java.lang.System.out.println("更新到3.0.2了"); + // } + // } +]; +var JDBCType = java.sql.JDBCType; +function install(context) { + var database = context.database; + database.createOrAlter("s_menu") + .addColumn().name("u_id").varchar(32).notNull().primaryKey().comment("uid").commit() + .addColumn().name("name").varchar(64).notNull().comment("名称").commit() + .addColumn().name("parent_id").varchar(32).comment("父级ID").commit() + .addColumn().name("permission_id").varchar(32).comment("权限ID").commit() + .addColumn().name("tree_code").varchar(2048).notNull().comment("树编码").commit() + .addColumn().name("sort_index").number(32).notNull().comment("树编码").commit() + .addColumn().name("describe").varchar(128).comment("备注").commit() + .addColumn().name("url").varchar(2000).comment("URL").commit() + .addColumn().name("icon").varchar(512).comment("图标").commit() + .addColumn().name("enabled").varchar(32).comment("是否启用").commit() + .comment("系统菜单表").commit() + + database.createOrAlter("s_menu_group") + .addColumn().name("u_id").alias("id").comment("ID").jdbcType(java.sql.JDBCType.VARCHAR).length(32).primaryKey().commit() + .addColumn().name("name").alias("name").comment("分组名称").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() + .addColumn().name("describe").alias("describe").comment("分组描述").jdbcType(java.sql.JDBCType.VARCHAR).length(64).commit() + .addColumn().name("default_group").alias("defaultGroup").comment("是否默认").jdbcType(java.sql.JDBCType.DECIMAL).length(4, 0).commit() + .addColumn().name("tree_code").alias("treeCode").comment("树结构编码").jdbcType(java.sql.JDBCType.VARCHAR).length(4000).commit() + .addColumn().name("parent_id").alias("parentId").comment("父级id").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() + .addColumn().name("level").alias("level").comment("树层级").jdbcType(java.sql.JDBCType.DECIMAL).length(32, 0).commit() + .addColumn().name("sort_index").alias("sortIndex").comment("排序序号").jdbcType(java.sql.JDBCType.DECIMAL).length(32, 0).commit() + .addColumn().name("enable").alias("enable").comment("是否启用").jdbcType(java.sql.JDBCType.DECIMAL).length(4, 0).commit() + .comment("菜单分组").commit(); + + database.createOrAlter("s_menu_group_bind") + .addColumn().name("u_id").alias("id").comment("ID").jdbcType(java.sql.JDBCType.VARCHAR).length(32).primaryKey().commit() + .addColumn().name("menu_id").alias("menuId").comment("菜单id").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() + .addColumn().name("group_id").alias("groupId").comment("分组id").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() + .addColumn().name("tree_code").alias("treeCode").comment("树结构编码").jdbcType(java.sql.JDBCType.VARCHAR).length(4000).commit() + .addColumn().name("parent_id").alias("parentId").comment("父级id").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() + .addColumn().name("level").alias("level").comment("树层级").jdbcType(java.sql.JDBCType.DECIMAL).length(32, 0).commit() + .addColumn().name("sort_index").alias("sortIndex").comment("排序序号").jdbcType(java.sql.JDBCType.DECIMAL).length(32, 0).commit() + .addColumn().name("enable").alias("enable").comment("是否启用").jdbcType(java.sql.JDBCType.DECIMAL).length(4, 0).commit() + .addColumn().name("actions").alias("actions").comment("可选按钮").jdbcType(java.sql.JDBCType.VARCHAR).length(4000).commit() + .addColumn().name("data_accesses").alias("dataAccesses").comment("行级权限控制配置").jdbcType(java.sql.JDBCType.CLOB).commit() + .addColumn().name("field_accesses").alias("fieldAccesses").comment("列级权限控制").jdbcType(java.sql.JDBCType.CLOB).commit() + .comment("菜单分组关联").commit(); +} + +//设置依赖 +dependency.setup(info) + .onInstall(install) + .onUpgrade(function (context) { //更新时执行 + var upgrader = context.upgrader; + upgrader.filter(versions) + .upgrade(function (newVer) { + newVer.upgrade(context); + }); + }) + .onUninstall(function (context) { //卸载时执行 + + }); \ No newline at end of file diff --git a/hsweb-system/hsweb-system-menu/hsweb-system-menu-starter/src/test/java/org/hswebframework/web/starter/menu/MenuGroupTests.java b/hsweb-system/hsweb-system-menu/hsweb-system-menu-starter/src/test/java/org/hswebframework/web/starter/menu/MenuGroupTests.java new file mode 100644 index 000000000..0ee386a82 --- /dev/null +++ b/hsweb-system/hsweb-system-menu/hsweb-system-menu-starter/src/test/java/org/hswebframework/web/starter/menu/MenuGroupTests.java @@ -0,0 +1,87 @@ +/* + * Copyright 2016 http://www.hswebframework.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ + +package org.hswebframework.web.starter.menu; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import org.hswebframework.web.entity.menu.MenuGroupEntity; +import org.hswebframework.web.entity.menu.SimpleMenuGroupEntity; +import org.hswebframework.web.starter.convert.FastJsonHttpMessageConverter; +import org.hswebframework.web.tests.SimpleWebApplicationTests; +import org.junit.Assert; +import org.junit.Test; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.MediaType; + +/** + * TODO 完善单元测试 + * + * @author hsweb-generator-online + */ +public class MenuGroupTests extends SimpleWebApplicationTests { + + @Autowired + private FastJsonHttpMessageConverter fastJsonHttpMessageConverter; + + @Test + public void testCrud() throws Exception { + MenuGroupEntity entity = entityFactory.newInstance(MenuGroupEntity.class); + //todo 设置测试属性 + entity.setName("test"); + entity.setId("test"); + + // test add data + String requestBody = JSON.toJSONString(entity); + JSONObject result = testPost("/menuGroup").setUp(setup -> setup.contentType(MediaType.APPLICATION_JSON).content(requestBody)).exec().resultAsJson(); + Assert.assertEquals(200, result.get("status")); + String id = result.getString("result"); + Assert.assertNotNull(id); + entity.setId(id); + // test get data + result = testGet("/menuGroup/" + id).exec().resultAsJson(); + entity = result.getObject("result", entityFactory.getInstanceType(MenuGroupEntity.class)); + + Assert.assertEquals(200, result.get("status")); + Assert.assertNotNull(result.getJSONObject("result")); + + Assert.assertEquals(fastJsonHttpMessageConverter.converter(entity), + fastJsonHttpMessageConverter.converter(result.getObject("data", entityFactory.getInstanceType(MenuGroupEntity.class)))); + //todo 修改测试属性 + MenuGroupEntity newEntity = entityFactory.newInstance(MenuGroupEntity.class); + newEntity.setName("test"); + + result = testPut("/menuGroup/" + id) + .setUp(setup -> + setup.contentType(MediaType.APPLICATION_JSON) + .content(JSON.toJSONString(newEntity))) + .exec().resultAsJson(); + Assert.assertEquals(200, result.get("status")); + + result = testGet("/menuGroup/" + id).exec().resultAsJson(); + result = result.getJSONObject("result"); + Assert.assertNotNull(result); + + result = testDelete("/menuGroup/" + id).exec().resultAsJson(); + Assert.assertEquals(200, result.get("status")); + + result = testGet("/menuGroup/" + id).exec().resultAsJson(); + Assert.assertEquals(404, result.get("status")); + } +} diff --git a/hsweb-system/hsweb-system-explorer/hsweb-system-explorer-starter/src/test/java/org/hswebframework/web/starter/explorer/MenuTests.java b/hsweb-system/hsweb-system-menu/hsweb-system-menu-starter/src/test/java/org/hswebframework/web/starter/menu/MenuTests.java similarity index 57% rename from hsweb-system/hsweb-system-explorer/hsweb-system-explorer-starter/src/test/java/org/hswebframework/web/starter/explorer/MenuTests.java rename to hsweb-system/hsweb-system-menu/hsweb-system-menu-starter/src/test/java/org/hswebframework/web/starter/menu/MenuTests.java index 9e1b0de05..07a2e973f 100644 --- a/hsweb-system/hsweb-system-explorer/hsweb-system-explorer-starter/src/test/java/org/hswebframework/web/starter/explorer/MenuTests.java +++ b/hsweb-system/hsweb-system-menu/hsweb-system-menu-starter/src/test/java/org/hswebframework/web/starter/menu/MenuTests.java @@ -1,26 +1,26 @@ /* - * Copyright 2016 http://www.hswebframework.org + * Copyright 2016 http://www.hswebframework.org * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * + * */ -package org.hswebframework.web.starter.explorer; +package org.hswebframework.web.starter.menu; import com.alibaba.fastjson.JSON; -import org.hswebframework.web.entity.authorization.ActionEntity; -import org.hswebframework.web.entity.explorer.MenuEntity; -import org.hswebframework.web.service.explorer.simple.MenuService; +import org.hswebframework.web.entity.menu.MenuEntity; +import org.hswebframework.web.service.menu.MenuService; import org.hswebframework.web.tests.SimpleWebApplicationTests; import org.junit.After; import org.junit.Test; @@ -47,19 +47,18 @@ public class MenuTests extends SimpleWebApplicationTests { sqlExecutor.delete("delete from s_menu"); } - public MenuEntity createMenu(String name, String... actions) { + public MenuEntity createMenu(String name) { MenuEntity menuEntity = menuService.createEntity(); menuEntity.setName(name); - menuEntity.setActions(ActionEntity.create(actions)); return menuEntity; } @Test public void testCrud() throws Exception { - MenuEntity menuEntity = createMenu("测试1", "C", "R"); + MenuEntity menuEntity = createMenu("测试1"); menuEntity.setSortIndex(1L); - MenuEntity child1 = createMenu("测试2", "C", "R"); - MenuEntity child3 = createMenu("测试2", "C", "R"); + MenuEntity child1 = createMenu("测试2"); + MenuEntity child3 = createMenu("测试2"); menuEntity.setChildren(Arrays.asList(child1, child3)); String id = menuService.insert(menuEntity); diff --git a/hsweb-system/hsweb-system-explorer/hsweb-system-explorer-starter/src/test/resources/application.yml b/hsweb-system/hsweb-system-menu/hsweb-system-menu-starter/src/test/resources/application.yml similarity index 74% rename from hsweb-system/hsweb-system-explorer/hsweb-system-explorer-starter/src/test/resources/application.yml rename to hsweb-system/hsweb-system-menu/hsweb-system-menu-starter/src/test/resources/application.yml index a8be21af5..20f1a08c7 100644 --- a/hsweb-system/hsweb-system-explorer/hsweb-system-explorer-starter/src/test/resources/application.yml +++ b/hsweb-system/hsweb-system-menu/hsweb-system-menu-starter/src/test/resources/application.yml @@ -2,12 +2,12 @@ spring: aop: auto: true datasource: - url : jdbc:h2:mem:explorer_test_mem + url : jdbc:h2:mem:menu_test_mem username : sa password : type: com.alibaba.druid.pool.DruidDataSource driver-class-name : org.h2.Driver hsweb: app: - name: 资源管理器测试 + name: 菜单分组测试 version: 3.0.0 \ No newline at end of file diff --git a/hsweb-system/hsweb-system-explorer/pom.xml b/hsweb-system/hsweb-system-menu/pom.xml similarity index 79% rename from hsweb-system/hsweb-system-explorer/pom.xml rename to hsweb-system/hsweb-system-menu/pom.xml index e95e33cd0..2d261dc95 100644 --- a/hsweb-system/hsweb-system-explorer/pom.xml +++ b/hsweb-system/hsweb-system-menu/pom.xml @@ -26,13 +26,14 @@ 4.0.0 - hsweb-system-explorer + hsweb-system-menu pom - hsweb-system-explorer-entity - hsweb-system-explorer-dao - hsweb-system-explorer-service - hsweb-system-explorer-starter + hsweb-system-menu-dao + hsweb-system-menu-service + hsweb-system-menu-controller + hsweb-system-menu-entity + hsweb-system-menu-starter