mirror of
https://github.com/hs-web/hsweb-framework.git
synced 2026-06-08 17:03:39 +08:00
新增菜单功能(替代原explorer)
This commit is contained in:
@@ -1,43 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ 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.
|
||||
~
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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">
|
||||
<parent>
|
||||
<artifactId>hsweb-system-explorer-service</artifactId>
|
||||
<groupId>org.hswebframework.web</groupId>
|
||||
<version>3.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>hsweb-system-explorer-service-api</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.hswebframework.web</groupId>
|
||||
<artifactId>hsweb-system-explorer-entity</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hswebframework.web</groupId>
|
||||
<artifactId>hsweb-commons-service-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -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<MenuEntity<MenuEntity>, String> {
|
||||
MenuEntity<MenuEntity> getByPermissionId(String permissionId);
|
||||
|
||||
List<MenuEntity<MenuEntity>> getByPermissionId(List<String> permissionId);
|
||||
|
||||
}
|
||||
@@ -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<MenuEntity<MenuEntity>, String>
|
||||
implements MenuService {
|
||||
|
||||
//dao api
|
||||
private MenuDao menuDao;
|
||||
|
||||
@Override
|
||||
protected IDGenerator<String> getIDGenerator() {
|
||||
return IDGenerator.MD5;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setMenuDao(MenuDao menuDao) {
|
||||
this.menuDao = menuDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MenuDao getDao() {
|
||||
return menuDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MenuEntity<MenuEntity>> getByPermissionId(List<String> permissionId) {
|
||||
return createQuery().noPaging().where().in("permissionId", permissionId).list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MenuEntity<MenuEntity> getByPermissionId(String permissionId) {
|
||||
return createQuery().noPaging().where().is("permissionId", permissionId).single();
|
||||
}
|
||||
}
|
||||
@@ -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">
|
||||
<parent>
|
||||
<artifactId>hsweb-system-explorer-dao</artifactId>
|
||||
<artifactId>hsweb-system-menu</artifactId>
|
||||
<groupId>org.hswebframework.web</groupId>
|
||||
<version>3.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>hsweb-system-explorer-dao-mybatis</artifactId>
|
||||
<artifactId>hsweb-system-menu-controller</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.5</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hswebframework.web</groupId>
|
||||
<artifactId>hsweb-system-explorer-dao-api</artifactId>
|
||||
<artifactId>hsweb-system-menu-service-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hswebframework.web</groupId>
|
||||
<artifactId>hsweb-commons-dao-mybatis</artifactId>
|
||||
<artifactId>hsweb-commons-controller</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
@@ -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<MenuEntity<MenuEntity>, String, QueryParamEntity, MenuEntity> {
|
||||
|
||||
private MenuService menuService;
|
||||
|
||||
@Autowired
|
||||
public void setMenuGroupService(MenuService menuService) {
|
||||
this.menuService = menuService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MenuService getService() {
|
||||
return menuService;
|
||||
}
|
||||
}
|
||||
@@ -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<MenuGroupEntity, String, QueryParamEntity, MenuGroupEntity> {
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~
|
||||
~ 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.
|
||||
~
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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">
|
||||
<parent>
|
||||
<artifactId>hsweb-system-menu-dao</artifactId>
|
||||
<groupId>org.hswebframework.web</groupId>
|
||||
<version>3.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>hsweb-system-menu-dao-api</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.hswebframework.web</groupId>
|
||||
<artifactId>hsweb-system-menu-entity</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hswebframework.web</groupId>
|
||||
<artifactId>hsweb-commons-dao-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -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<MenuEntity<MenuEntity>, String> {
|
||||
}
|
||||
@@ -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<MenuGroupBindEntity,String> {
|
||||
}
|
||||
@@ -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<MenuGroupEntity,String> {
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~
|
||||
~ 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.
|
||||
~
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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">
|
||||
<parent>
|
||||
<artifactId>hsweb-system-menu-dao</artifactId>
|
||||
<groupId>org.hswebframework.web</groupId>
|
||||
<version>3.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>hsweb-system-menu-dao-mybatis</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.hswebframework.web</groupId>
|
||||
<artifactId>hsweb-system-menu-dao-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hswebframework.web</groupId>
|
||||
<artifactId>hsweb-commons-dao-mybatis</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,70 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!--
|
||||
~ 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.
|
||||
~
|
||||
-->
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.hswebframework.web.dao.menu.MenuGroupBindDao">
|
||||
<resultMap id="MenuGroupBindResultMap" type="org.hswebframework.web.entity.menu.SimpleMenuGroupBindEntity">
|
||||
<id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
|
||||
<result property="treeCode" column="tree_code" javaType="String" jdbcType="VARCHAR"/>
|
||||
<result property="parentId" column="parent_id" javaType="String" jdbcType="VARCHAR"/>
|
||||
<result property="level" column="level" javaType="Integer" jdbcType="DECIMAL"/>
|
||||
<result property="sortIndex" column="sort_index" javaType="Long" jdbcType="DECIMAL"/>
|
||||
<result property="enabled" column="enabled" javaType="Boolean" jdbcType="DECIMAL"/>
|
||||
<result property="menuId" column="menu_id" javaType="String" jdbcType="VARCHAR"/>
|
||||
<result property="groupId" column="group_id" javaType="String" jdbcType="VARCHAR"/>
|
||||
<result property="actions" column="actions" javaType="java.util.List" jdbcType="VARCHAR"/>
|
||||
<result property="dataAccesses" column="data_accesses" javaType="java.util.List" jdbcType="CLOB"/>
|
||||
<result property="fieldAccesses" column="field_accesses" javaType="java.util.List" jdbcType="CLOB"/>
|
||||
</resultMap>
|
||||
|
||||
<!--用于动态生成sql所需的配置-->
|
||||
<sql id="config">
|
||||
<bind name="resultMapId" value="'MenuGroupBindResultMap'"/>
|
||||
<bind name="tableName" value="'S_MENU_GROUP_BIND'"/>
|
||||
</sql>
|
||||
|
||||
<insert id="insert" parameterType="org.hswebframework.web.entity.menu.SimpleMenuGroupBindEntity" >
|
||||
<include refid="config"/>
|
||||
<include refid="BasicMapper.buildInsertSql"/>
|
||||
</insert>
|
||||
|
||||
<delete id="deleteByPk" parameterType="String">
|
||||
delete from S_MENU_GROUP_BIND where u_id =#{id}
|
||||
</delete>
|
||||
|
||||
<delete id="delete" parameterType="org.hswebframework.web.commons.entity.Entity">
|
||||
<include refid="config"/>
|
||||
<include refid="BasicMapper.buildDeleteSql"/>
|
||||
</delete>
|
||||
|
||||
<update id="update" parameterType="org.hswebframework.web.commons.entity.Entity">
|
||||
<include refid="config"/>
|
||||
<include refid="BasicMapper.buildUpdateSql"/>
|
||||
</update>
|
||||
|
||||
<select id="query" parameterType="org.hswebframework.web.commons.entity.Entity" resultMap="MenuGroupBindResultMap">
|
||||
<include refid="config"/>
|
||||
<include refid="BasicMapper.buildSelectSql"/>
|
||||
</select>
|
||||
|
||||
<select id="count" parameterType="org.hswebframework.web.commons.entity.Entity" resultType="int">
|
||||
<include refid="config"/>
|
||||
<include refid="BasicMapper.buildTotalSql"/>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!--
|
||||
~ 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.
|
||||
~
|
||||
-->
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.hswebframework.web.dao.menu.MenuGroupDao">
|
||||
<resultMap id="MenuGroupResultMap" type="org.hswebframework.web.entity.menu.SimpleMenuGroupEntity">
|
||||
<id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
|
||||
<result property="name" column="name" javaType="String" jdbcType="VARCHAR"/>
|
||||
<result property="describe" column="describe" javaType="String" jdbcType="VARCHAR"/>
|
||||
<result property="defaultGroup" column="default_group" javaType="Boolean" jdbcType="DECIMAL"/>
|
||||
<result property="treeCode" column="tree_code" javaType="String" jdbcType="VARCHAR"/>
|
||||
<result property="parentId" column="parent_id" javaType="String" jdbcType="VARCHAR"/>
|
||||
<result property="level" column="level" javaType="Integer" jdbcType="DECIMAL"/>
|
||||
<result property="sortIndex" column="sort_index" javaType="Long" jdbcType="DECIMAL"/>
|
||||
<result property="enabled" column="enabled" javaType="Boolean" jdbcType="DECIMAL"/>
|
||||
</resultMap>
|
||||
|
||||
<!--用于动态生成sql所需的配置-->
|
||||
<sql id="config">
|
||||
<bind name="resultMapId" value="'MenuGroupResultMap'"/>
|
||||
<bind name="tableName" value="'S_MENU_GROUP'"/>
|
||||
</sql>
|
||||
|
||||
<insert id="insert" parameterType="org.hswebframework.web.entity.menu.SimpleMenuGroupEntity" >
|
||||
<include refid="config"/>
|
||||
<include refid="BasicMapper.buildInsertSql"/>
|
||||
</insert>
|
||||
|
||||
<delete id="deleteByPk" parameterType="String">
|
||||
delete from S_MENU_GROUP where u_id =#{id}
|
||||
</delete>
|
||||
|
||||
<delete id="delete" parameterType="org.hswebframework.web.commons.entity.Entity">
|
||||
<include refid="config"/>
|
||||
<include refid="BasicMapper.buildDeleteSql"/>
|
||||
</delete>
|
||||
|
||||
<update id="update" parameterType="org.hswebframework.web.commons.entity.Entity">
|
||||
<include refid="config"/>
|
||||
<include refid="BasicMapper.buildUpdateSql"/>
|
||||
</update>
|
||||
|
||||
<select id="query" parameterType="org.hswebframework.web.commons.entity.Entity" resultMap="MenuGroupResultMap">
|
||||
<include refid="config"/>
|
||||
<include refid="BasicMapper.buildSelectSql"/>
|
||||
</select>
|
||||
|
||||
<select id="count" parameterType="org.hswebframework.web.commons.entity.Entity" resultType="int">
|
||||
<include refid="config"/>
|
||||
<include refid="BasicMapper.buildTotalSql"/>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -20,8 +20,8 @@
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="org.hswebframework.web.dao.explorer.MenuDao">
|
||||
<resultMap id="MenuResultMap" type="org.hswebframework.web.entity.explorer.SimpleMenuEntity">
|
||||
<mapper namespace="org.hswebframework.web.dao.menu.MenuDao">
|
||||
<resultMap id="MenuResultMap" type="org.hswebframework.web.entity.menu.SimpleMenuEntity">
|
||||
<id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
|
||||
<result property="describe" column="describe" javaType="String" jdbcType="VARCHAR"/>
|
||||
<result property="parentId" column="parent_id" javaType="String" jdbcType="VARCHAR"/>
|
||||
@@ -39,7 +39,7 @@
|
||||
<bind name="tableName" value="'s_menu'"/>
|
||||
</sql>
|
||||
|
||||
<insert id="insert" parameterType="org.hswebframework.web.entity.explorer.MenuEntity">
|
||||
<insert id="insert" parameterType="org.hswebframework.web.entity.menu.MenuEntity">
|
||||
<include refid="config"/>
|
||||
<include refid="BasicMapper.buildInsertSql"/>
|
||||
</insert>
|
||||
36
hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/pom.xml
Normal file
36
hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/pom.xml
Normal file
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~
|
||||
~ 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.
|
||||
~
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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">
|
||||
<parent>
|
||||
<artifactId>hsweb-system-menu</artifactId>
|
||||
<groupId>org.hswebframework.web</groupId>
|
||||
<version>3.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>hsweb-system-menu-dao</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>hsweb-system-menu-dao-api</module>
|
||||
<module>hsweb-system-menu-dao-mybatis</module>
|
||||
</modules>
|
||||
</project>
|
||||
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~
|
||||
~ 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.
|
||||
~
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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">
|
||||
<parent>
|
||||
<artifactId>hsweb-system-menu</artifactId>
|
||||
<groupId>org.hswebframework.web</groupId>
|
||||
<version>3.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>hsweb-system-menu-entity</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.hswebframework.web</groupId>
|
||||
<artifactId>hsweb-commons-entity</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hswebframework.web</groupId>
|
||||
<artifactId>hsweb-system-authorization-entity</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -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<C extends MenuEntity>
|
||||
|
||||
void setIcon(String icon);
|
||||
|
||||
String getAuthentication();
|
||||
|
||||
void setAuthentication(String authentication);
|
||||
|
||||
Map<String, Object> getAuthenticationConfig();
|
||||
|
||||
void setAuthenticationConfig(Map<String, Object> authenticationConfig);
|
||||
|
||||
String getOnInit();
|
||||
|
||||
void setOnInit(String onInit);
|
||||
|
||||
boolean isEnabled();
|
||||
|
||||
void setEnabled(boolean enabled);
|
||||
|
||||
List<ActionEntity> getActions();
|
||||
|
||||
void setActions(List<ActionEntity> actions);
|
||||
|
||||
void setChildren(List<C> children);
|
||||
|
||||
@Override
|
||||
@@ -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> {
|
||||
/*-------------------------------------------
|
||||
| 属性名常量 |
|
||||
===========================================*/
|
||||
/**
|
||||
* 树结构编码
|
||||
*/
|
||||
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<String> getActions();
|
||||
|
||||
/**
|
||||
* 设置 可选按钮
|
||||
*/
|
||||
void setActions(java.util.List<String> actions);
|
||||
|
||||
/**
|
||||
* @return 行级权限控制配置
|
||||
*/
|
||||
java.util.List<DataAccessEntity> getDataAccesses();
|
||||
|
||||
/**
|
||||
* 设置 行级权限控制配置
|
||||
*/
|
||||
void setDataAccesses(java.util.List<DataAccessEntity> dataAccesses);
|
||||
|
||||
/**
|
||||
* @return 列级权限控制
|
||||
*/
|
||||
java.util.List<FieldAccessEntity> getFieldAccesses();
|
||||
|
||||
/**
|
||||
* 设置 列级权限控制
|
||||
*/
|
||||
void setFieldAccesses(java.util.List<FieldAccessEntity> fieldAccesses);
|
||||
|
||||
void setChildren(List<MenuGroupBindEntity> children);
|
||||
}
|
||||
@@ -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> {
|
||||
/*-------------------------------------------
|
||||
| 属性名常量 |
|
||||
===========================================*/
|
||||
/**
|
||||
* 分组名称
|
||||
*/
|
||||
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<MenuGroupBindEntity> getBindInfo();
|
||||
|
||||
void setBindInfo(List<MenuGroupBindEntity> bindInfo);
|
||||
}
|
||||
@@ -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<String>
|
||||
implements MenuEntity<SimpleMenuEntity> {
|
||||
|
||||
//菜单名称
|
||||
private String name;
|
||||
|
||||
//备注
|
||||
private String describe;
|
||||
|
||||
//权限ID
|
||||
private String permissionId;
|
||||
|
||||
//菜单对应的url
|
||||
private String url;
|
||||
|
||||
//图标
|
||||
private String icon;
|
||||
|
||||
//是否启用
|
||||
private boolean enabled = true;
|
||||
|
||||
//子菜单
|
||||
private List<SimpleMenuEntity> children;
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<SimpleMenuEntity> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChildren(List<SimpleMenuEntity> 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;
|
||||
}
|
||||
}
|
||||
@@ -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<String> implements MenuGroupBindEntity {
|
||||
//是否启用
|
||||
private Boolean enabled;
|
||||
//菜单id
|
||||
private String menuId;
|
||||
//分组id
|
||||
private String groupId;
|
||||
//可选按钮
|
||||
private java.util.List<String> actions;
|
||||
//行级权限控制配置
|
||||
private java.util.List<DataAccessEntity> dataAccesses;
|
||||
//列级权限控制
|
||||
private java.util.List<FieldAccessEntity> fieldAccesses;
|
||||
//子节点
|
||||
private List<SimpleMenuGroupBindEntity> 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<String> getActions() {
|
||||
return this.actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 可选按钮
|
||||
*/
|
||||
public void setActions(java.util.List<String> actions) {
|
||||
this.actions = actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 行级权限控制配置
|
||||
*/
|
||||
public java.util.List<DataAccessEntity> getDataAccesses() {
|
||||
return this.dataAccesses;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 行级权限控制配置
|
||||
*/
|
||||
public void setDataAccesses(java.util.List<DataAccessEntity> dataAccesses) {
|
||||
this.dataAccesses = dataAccesses;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 列级权限控制
|
||||
*/
|
||||
public java.util.List<FieldAccessEntity> getFieldAccesses() {
|
||||
return this.fieldAccesses;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 列级权限控制
|
||||
*/
|
||||
public void setFieldAccesses(java.util.List<FieldAccessEntity> fieldAccesses) {
|
||||
this.fieldAccesses = fieldAccesses;
|
||||
}
|
||||
|
||||
|
||||
public List<SimpleMenuGroupBindEntity> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChildren(List<MenuGroupBindEntity> children) {
|
||||
this.children = new ArrayList(children);
|
||||
}
|
||||
}
|
||||
@@ -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<String> implements MenuGroupEntity {
|
||||
//分组名称
|
||||
private String name;
|
||||
//分组描述
|
||||
private String describe;
|
||||
//是否默认
|
||||
private Boolean defaultGroup;
|
||||
//是否启用
|
||||
private Boolean enabled;
|
||||
|
||||
private List<SimpleMenuGroupEntity> children;
|
||||
|
||||
private List<SimpleMenuGroupBindEntity> 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<SimpleMenuGroupEntity> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<SimpleMenuGroupEntity> children) {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MenuGroupBindEntity> getBindInfo() {
|
||||
if (bindInfo == null)
|
||||
return Collections.emptyList();
|
||||
return new LinkedList<>(bindInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBindInfo(List<MenuGroupBindEntity> 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;
|
||||
}
|
||||
}
|
||||
@@ -15,28 +15,22 @@
|
||||
~ limitations under the License.
|
||||
~
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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">
|
||||
<parent>
|
||||
<artifactId>hsweb-system-explorer</artifactId>
|
||||
<artifactId>hsweb-system-menu-service</artifactId>
|
||||
<groupId>org.hswebframework.web</groupId>
|
||||
<version>3.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>hsweb-system-explorer-entity</artifactId>
|
||||
<artifactId>hsweb-system-menu-service-api</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hswebframework.web</groupId>
|
||||
<artifactId>hsweb-commons-entity</artifactId>
|
||||
<artifactId>hsweb-commons-service-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -44,6 +38,10 @@
|
||||
<artifactId>hsweb-system-authorization-entity</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hswebframework.web</groupId>
|
||||
<artifactId>hsweb-system-menu-entity</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -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<MenuGroupBindEntity, String>
|
||||
, TreeService<MenuGroupBindEntity, String> {
|
||||
|
||||
}
|
||||
@@ -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<MenuGroupEntity, String>
|
||||
, TreeService<MenuGroupEntity, String> {
|
||||
|
||||
List<MenuEntity<MenuEntity>> getMenuByGroupId(List<String> groupId);
|
||||
|
||||
void enable(String id);
|
||||
|
||||
void disable(String id);
|
||||
}
|
||||
@@ -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<MenuEntity<MenuEntity>, String>
|
||||
, TreeService<MenuEntity<MenuEntity>, String> {
|
||||
MenuEntity<MenuEntity> getByPermissionId(String permissionId);
|
||||
|
||||
List<MenuEntity<MenuEntity>> getByPermissionId(List<String> permissionId);
|
||||
}
|
||||
@@ -15,29 +15,37 @@
|
||||
~ limitations under the License.
|
||||
~
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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">
|
||||
<parent>
|
||||
<artifactId>hsweb-system-explorer-dao</artifactId>
|
||||
<artifactId>hsweb-system-menu-service</artifactId>
|
||||
<groupId>org.hswebframework.web</groupId>
|
||||
<version>3.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>hsweb-system-explorer-dao-api</artifactId>
|
||||
|
||||
<artifactId>hsweb-system-menu-service-simple</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.hswebframework.web</groupId>
|
||||
<artifactId>hsweb-system-explorer-entity</artifactId>
|
||||
<artifactId>hsweb-commons-service-simple</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hswebframework.web</groupId>
|
||||
<artifactId>hsweb-commons-dao-api</artifactId>
|
||||
<artifactId>hsweb-system-menu-service-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hswebframework.web</groupId>
|
||||
<artifactId>hsweb-system-authorization-service-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hswebframework.web</groupId>
|
||||
<artifactId>hsweb-system-menu-dao-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
@@ -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:";
|
||||
}
|
||||
@@ -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<MenuGroupBindEntity, String>
|
||||
implements MenuGroupBindService {
|
||||
@Autowired
|
||||
private MenuGroupBindDao menuGroupBindDao;
|
||||
@Override
|
||||
protected IDGenerator<String> getIDGenerator() {
|
||||
return IDGenerator.MD5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MenuGroupBindDao getDao() {
|
||||
return menuGroupBindDao;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<MenuGroupEntity, String>
|
||||
implements MenuGroupService {
|
||||
@Autowired
|
||||
private MenuGroupDao menuGroupDao;
|
||||
|
||||
@Autowired(required = false)
|
||||
private RoleService roleService;
|
||||
|
||||
@Autowired
|
||||
private MenuService menuService;
|
||||
|
||||
@Autowired
|
||||
private MenuGroupBindService menuGroupBindService;
|
||||
|
||||
@Override
|
||||
protected IDGenerator<String> 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<MenuEntity<MenuEntity>> getMenuByGroupId(List<String> groupId) {
|
||||
List<MenuGroupBindEntity> 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<MenuGroupBindEntity> 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<MenuGroupEntity> 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<BindPermissionRoleEntity<PermissionRoleEntity>> roleEntityConsumer =
|
||||
roleService.selectByPk(menuGroupEntity.getId()) == null ? roleService::insert : roleService::update;
|
||||
|
||||
//设置属性
|
||||
BindPermissionRoleEntity<PermissionRoleEntity> roleEntity = entityFactory.newInstance(BindPermissionRoleEntity.class);
|
||||
roleEntity.setId(menuGroupEntity.getId());
|
||||
roleEntity.setName(menuGroupEntity.getName());
|
||||
roleEntity.setEnabled(menuGroupEntity.isEnabled());
|
||||
roleEntity.setDescribe(menuGroupEntity.getDescribe());
|
||||
List<MenuGroupBindEntity> 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<? extends 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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<MenuEntity<MenuEntity>, String>
|
||||
implements MenuService {
|
||||
|
||||
private MenuDao menuDao;
|
||||
|
||||
@Override
|
||||
protected IDGenerator<String> 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<MenuEntity<MenuEntity>> data) {
|
||||
return super.updateByPk(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(allEntries = true)
|
||||
public String insert(MenuEntity<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<MenuEntity<MenuEntity>> getByPermissionId(List<String> permissionId) {
|
||||
return createQuery().noPaging().where().in("permissionId", permissionId).list();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(key = "'permission-id:'+#permissionId")
|
||||
public MenuEntity<MenuEntity> getByPermissionId(String permissionId) {
|
||||
return createQuery().noPaging().where().is("permissionId", permissionId).single();
|
||||
}
|
||||
}
|
||||
@@ -15,23 +15,20 @@
|
||||
~ limitations under the License.
|
||||
~
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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">
|
||||
<parent>
|
||||
<artifactId>hsweb-system-explorer</artifactId>
|
||||
<artifactId>hsweb-system-menu</artifactId>
|
||||
<groupId>org.hswebframework.web</groupId>
|
||||
<version>3.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>hsweb-system-explorer-dao</artifactId>
|
||||
<artifactId>hsweb-system-menu-service</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>hsweb-system-explorer-dao-api</module>
|
||||
<module>hsweb-system-explorer-dao-mybatis</module>
|
||||
<module>hsweb-system-menu-service-api</module>
|
||||
<module>hsweb-system-menu-service-simple</module>
|
||||
</modules>
|
||||
|
||||
|
||||
</project>
|
||||
@@ -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">
|
||||
<parent>
|
||||
<artifactId>hsweb-system-explorer</artifactId>
|
||||
<artifactId>hsweb-system-menu</artifactId>
|
||||
<groupId>org.hswebframework.web</groupId>
|
||||
<version>3.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>hsweb-system-explorer-starter</artifactId>
|
||||
<artifactId>hsweb-system-menu-starter</artifactId>
|
||||
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
@@ -39,20 +41,19 @@
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.hswebframework.web</groupId>
|
||||
<artifactId>hsweb-system-explorer-service-simple</artifactId>
|
||||
<artifactId>hsweb-system-menu-service-simple</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.hswebframework.web</groupId>
|
||||
<artifactId>hsweb-system-explorer-dao-mybatis</artifactId>
|
||||
<artifactId>hsweb-system-menu-dao-mybatis</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hswebframework.web</groupId>
|
||||
<artifactId>hsweb-system-menu-controller</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<!--<dependency>-->
|
||||
<!--<groupId>org.hswebframework.web</groupId>-->
|
||||
<!--<artifactId>hsweb-system-explorer-controller</artifactId>-->
|
||||
<!--<version>${project.version}</version>-->
|
||||
<!--</dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
@@ -72,12 +73,19 @@
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.hswebframework.web</groupId>
|
||||
<artifactId>hsweb-tests</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.5</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -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) { //卸载时执行
|
||||
|
||||
});
|
||||
@@ -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"));
|
||||
}
|
||||
}
|
||||
@@ -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<MenuEntity> createMenu(String name, String... actions) {
|
||||
public MenuEntity<MenuEntity> createMenu(String name) {
|
||||
MenuEntity<MenuEntity> menuEntity = menuService.createEntity();
|
||||
menuEntity.setName(name);
|
||||
menuEntity.setActions(ActionEntity.create(actions));
|
||||
return menuEntity;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCrud() throws Exception {
|
||||
MenuEntity<MenuEntity> menuEntity = createMenu("测试1", "C", "R");
|
||||
MenuEntity<MenuEntity> menuEntity = createMenu("测试1");
|
||||
menuEntity.setSortIndex(1L);
|
||||
MenuEntity<MenuEntity> child1 = createMenu("测试2", "C", "R");
|
||||
MenuEntity<MenuEntity> child3 = createMenu("测试2", "C", "R");
|
||||
MenuEntity<MenuEntity> child1 = createMenu("测试2");
|
||||
MenuEntity<MenuEntity> child3 = createMenu("测试2");
|
||||
menuEntity.setChildren(Arrays.asList(child1, child3));
|
||||
|
||||
String id = menuService.insert(menuEntity);
|
||||
@@ -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
|
||||
@@ -26,13 +26,14 @@
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>hsweb-system-explorer</artifactId>
|
||||
<artifactId>hsweb-system-menu</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>hsweb-system-explorer-entity</module>
|
||||
<module>hsweb-system-explorer-dao</module>
|
||||
<module>hsweb-system-explorer-service</module>
|
||||
<module>hsweb-system-explorer-starter</module>
|
||||
<module>hsweb-system-menu-dao</module>
|
||||
<module>hsweb-system-menu-service</module>
|
||||
<module>hsweb-system-menu-controller</module>
|
||||
<module>hsweb-system-menu-entity</module>
|
||||
<module>hsweb-system-menu-starter</module>
|
||||
</modules>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user