diff --git a/src/main/java/neatlogic/framework/auth/label/EXTRA_MENU_MODIFY.java b/src/main/java/neatlogic/framework/auth/label/EXTRA_MENU_MODIFY.java new file mode 100644 index 0000000000000000000000000000000000000000..e80b5ae33a599770aee224dec11eb68f1687fe9a --- /dev/null +++ b/src/main/java/neatlogic/framework/auth/label/EXTRA_MENU_MODIFY.java @@ -0,0 +1,41 @@ +/* + * Copyright(c) 2023 NeatLogic Co., Ltd. All Rights Reserved. + * + * 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 neatlogic.framework.auth.label; + +import neatlogic.framework.auth.core.AuthBase; + +public class EXTRA_MENU_MODIFY extends AuthBase { + @Override + public String getAuthDisplayName() { + return "nfal.extra_menu_modify.getauthdisplayname"; + } + + @Override + public String getAuthIntroduction() { + return "nfal.extra_menu_modify.getauthintroduction"; + } + + @Override + public String getAuthGroup() { + return "framework"; + } + + @Override + public Integer getSort() { + return 28; + } +} diff --git a/src/main/java/neatlogic/framework/extramenu/constvalue/ExtraMenuType.java b/src/main/java/neatlogic/framework/extramenu/constvalue/ExtraMenuType.java new file mode 100644 index 0000000000000000000000000000000000000000..a57542a4a6520abfd47570b8955e1988b849808f --- /dev/null +++ b/src/main/java/neatlogic/framework/extramenu/constvalue/ExtraMenuType.java @@ -0,0 +1,52 @@ +/* + * Copyright(c) 2023 NeatLogic Co., Ltd. All Rights Reserved. + * + * 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 neatlogic.framework.extramenu.constvalue; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import neatlogic.framework.common.constvalue.IEnum; + +import java.util.List; + +public enum ExtraMenuType implements IEnum { + DIRECTORY(0), MENU(1); + + private int type; + + ExtraMenuType(int _type) { + this.type = _type; + } + + @Override + public List getValueTextList() { + JSONArray array = new JSONArray(); + for (ExtraMenuType typeEnum : ExtraMenuType.values()) { + array.add(new JSONObject() { + { + this.put("value", typeEnum.getType()); + this.put("text", typeEnum.name()); + } + }); + } + return array; + } + + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } +} diff --git a/src/main/java/neatlogic/framework/extramenu/dto/ExtraMenuVo.java b/src/main/java/neatlogic/framework/extramenu/dto/ExtraMenuVo.java new file mode 100644 index 0000000000000000000000000000000000000000..af0167c1e8fce7dcb89ab4da41fc3cbf4d419dfc --- /dev/null +++ b/src/main/java/neatlogic/framework/extramenu/dto/ExtraMenuVo.java @@ -0,0 +1,201 @@ +/* + * Copyright(c) 2023 NeatLogic Co., Ltd. All Rights Reserved. + * + * 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 neatlogic.framework.extramenu.dto; + +import com.alibaba.fastjson.annotation.JSONField; +import neatlogic.framework.common.constvalue.ApiParamType; +import neatlogic.framework.common.constvalue.GroupSearch; +import neatlogic.framework.dto.AuthorityVo; +import neatlogic.framework.restful.annotation.EntityField; +import neatlogic.framework.util.SnowflakeUtil; +import org.apache.commons.collections4.CollectionUtils; + +import java.util.ArrayList; +import java.util.List; + +public class ExtraMenuVo { + public static final Long ROOT_PARENTID = -1L; + public static final Long ROOT_ID = 0L; + public static final String ROOT_NAME = "root"; + + @EntityField(name = "id", type = ApiParamType.LONG) + private Long id; + @EntityField(name = "common.name", type = ApiParamType.STRING) + private String name; + @EntityField(name = "common.type", type = ApiParamType.INTEGER) + private Integer type; + @EntityField(name = "common.isactive", type = ApiParamType.INTEGER) + private Integer isActive; + @EntityField(name = "url", type = ApiParamType.STRING) + private String url; + @EntityField(name = "common.description", type = ApiParamType.STRING) + private String description; + @EntityField(name = "common.authlist", type = ApiParamType.JSONARRAY) + private List authorityList = new ArrayList<>(); + @EntityField(name = "common.parentid", type = ApiParamType.LONG) + private Long parentId; + @EntityField(name = "common.lft", type = ApiParamType.INTEGER) + private Integer lft; + @EntityField(name = "common.rht", type = ApiParamType.INTEGER) + private Integer rht; + @EntityField(name = "nfdd.drorganizationvo.entityfield.childcount.name", type = ApiParamType.INTEGER) + private Integer childCount; + @EntityField(name = "nfdd.drorganizationvo.entityfield.children.name", type = ApiParamType.JSONARRAY) + private List children; + @JSONField(serialize = false) + private List authorityVoList; + @JSONField(serialize = false) + private ExtraMenuVo parent; + + public Long getId() { + if (id == null) { + id = SnowflakeUtil.uniqueLong(); + } + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + + public Integer getIsActive() { + return isActive; + } + + public void setIsActive(Integer isActive) { + this.isActive = isActive; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public List getAuthorityList() { + if (CollectionUtils.isEmpty(authorityList) && CollectionUtils.isNotEmpty(authorityVoList)) { + for (AuthorityVo authorityVo : authorityVoList) { + GroupSearch groupSearch = GroupSearch.getGroupSearch(authorityVo.getType()); + if (groupSearch != null) { + authorityList.add(groupSearch.getValuePlugin() + authorityVo.getUuid()); + } + } + } + return authorityList; + } + + public void setAuthorityList(List authorityList) { + this.authorityList = authorityList; + } + + public Long getParentId() { + return parentId; + } + + public void setParentId(Long parentId) { + this.parentId = parentId; + } + + public Integer getLft() { + return lft; + } + + public void setLft(Integer lft) { + this.lft = lft; + } + + public Integer getRht() { + return rht; + } + + public void setRht(Integer rht) { + this.rht = rht; + } + + public Integer getChildCount() { + return childCount; + } + + public void setChildCount(Integer childCount) { + this.childCount = childCount; + } + + public List getChildren() { + return children; + } + + public void setChildren(List children) { + this.children = children; + } + + public List getAuthorityVoList() { + if (authorityVoList == null && CollectionUtils.isNotEmpty(authorityList)) { + authorityVoList = new ArrayList<>(); + for (String authority : authorityList) { + String[] split = authority.split("#"); + if (GroupSearch.getGroupSearch(split[0]) != null) { + AuthorityVo authorityVo = new AuthorityVo(); + authorityVo.setType(split[0]); + authorityVo.setUuid(split[1]); + authorityVoList.add(authorityVo); + } + } + } + return authorityVoList; + } + + public void setAuthorityVoList(List authorityVoList) { + this.authorityVoList = authorityVoList; + } + + public ExtraMenuVo getParent() { + return parent; + } + + public void setParent(ExtraMenuVo parent) { + if (parent != null) { + this.parent = parent; + if (parent.getChildren() == null) { + parent.setChildren(new ArrayList<>()); + } + parent.getChildren().add(this); + } + } +} diff --git a/src/main/java/neatlogic/framework/extramenu/exception/ExtraMenuExistChildrenException.java b/src/main/java/neatlogic/framework/extramenu/exception/ExtraMenuExistChildrenException.java new file mode 100644 index 0000000000000000000000000000000000000000..7685a33d9c46c7ae7281a9e7158fbe31741c6f61 --- /dev/null +++ b/src/main/java/neatlogic/framework/extramenu/exception/ExtraMenuExistChildrenException.java @@ -0,0 +1,25 @@ +/* + * Copyright(c) 2023 NeatLogic Co., Ltd. All Rights Reserved. + * + * 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 neatlogic.framework.extramenu.exception; + +import neatlogic.framework.exception.core.ApiRuntimeException; + +public class ExtraMenuExistChildrenException extends ApiRuntimeException { + public ExtraMenuExistChildrenException(String name) { + super("nfee.extramenuexistchildrenexception.extramenuexistchildrenexception", name); + } +} diff --git a/src/main/java/neatlogic/framework/extramenu/exception/ExtraMenuNameRepeatException.java b/src/main/java/neatlogic/framework/extramenu/exception/ExtraMenuNameRepeatException.java new file mode 100644 index 0000000000000000000000000000000000000000..fe993db33880711a04176f8b1aff42443b1eddb3 --- /dev/null +++ b/src/main/java/neatlogic/framework/extramenu/exception/ExtraMenuNameRepeatException.java @@ -0,0 +1,25 @@ +/* + * Copyright(c) 2023 NeatLogic Co., Ltd. All Rights Reserved. + * + * 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 neatlogic.framework.extramenu.exception; + +import neatlogic.framework.exception.core.ApiRuntimeException; + +public class ExtraMenuNameRepeatException extends ApiRuntimeException { + public ExtraMenuNameRepeatException (String name) { + super("nfee.extramenunamerepeatexception.extramenunamerepeatexception", name); + } +} diff --git a/src/main/java/neatlogic/framework/extramenu/exception/ExtraMenuNotAllowedAddException.java b/src/main/java/neatlogic/framework/extramenu/exception/ExtraMenuNotAllowedAddException.java new file mode 100644 index 0000000000000000000000000000000000000000..e698421c3d746f2d11dc4f23818fc7814af46e7c --- /dev/null +++ b/src/main/java/neatlogic/framework/extramenu/exception/ExtraMenuNotAllowedAddException.java @@ -0,0 +1,22 @@ +/* + * Copyright(c) 2023 NeatLogic Co., Ltd. All Rights Reserved. + * + * 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 neatlogic.framework.extramenu.exception; + +import neatlogic.framework.exception.core.ApiRuntimeException; + +public class ExtraMenuNotAllowedAddException extends ApiRuntimeException { + public ExtraMenuNotAllowedAddException() { + super("nfee.extramenunotallowedaddexception.extramenunotallowedaddexception"); + } +} diff --git a/src/main/java/neatlogic/framework/extramenu/exception/ExtraMenuNotFoundException.java b/src/main/java/neatlogic/framework/extramenu/exception/ExtraMenuNotFoundException.java new file mode 100644 index 0000000000000000000000000000000000000000..57bb1088dde4fd54243be472cd8034876540bc71 --- /dev/null +++ b/src/main/java/neatlogic/framework/extramenu/exception/ExtraMenuNotFoundException.java @@ -0,0 +1,25 @@ +/* + * Copyright(c) 2023 NeatLogic Co., Ltd. All Rights Reserved. + * + * 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 neatlogic.framework.extramenu.exception; + +import neatlogic.framework.exception.core.ApiRuntimeException; + +public class ExtraMenuNotFoundException extends ApiRuntimeException { + public ExtraMenuNotFoundException(Long id) { + super("nfee.extramenunotfoundexception.extramenunotfoundexception", id); + } +} diff --git a/src/main/java/neatlogic/framework/extramenu/exception/ExtraMenuParamException.java b/src/main/java/neatlogic/framework/extramenu/exception/ExtraMenuParamException.java new file mode 100644 index 0000000000000000000000000000000000000000..55e6c0f4e7fab1352a75e6e9c34d916f6e4c6ae8 --- /dev/null +++ b/src/main/java/neatlogic/framework/extramenu/exception/ExtraMenuParamException.java @@ -0,0 +1,25 @@ +/* + * Copyright(c) 2023 NeatLogic Co., Ltd. All Rights Reserved. + * + * 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 neatlogic.framework.extramenu.exception; + +import neatlogic.framework.exception.core.ApiRuntimeException; + +public class ExtraMenuParamException extends ApiRuntimeException { + public ExtraMenuParamException(String param) { + super("nfee.extramenuparamexception.extramenuparamexception", param); + } +} diff --git a/src/main/java/neatlogic/framework/extramenu/exception/ExtraMenuRootException.java b/src/main/java/neatlogic/framework/extramenu/exception/ExtraMenuRootException.java new file mode 100644 index 0000000000000000000000000000000000000000..e25986e8bf729cd8cfe5da76b78bb7a66b0a9285 --- /dev/null +++ b/src/main/java/neatlogic/framework/extramenu/exception/ExtraMenuRootException.java @@ -0,0 +1,25 @@ +/* + * Copyright(c) 2023 NeatLogic Co., Ltd. All Rights Reserved. + * + * 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 neatlogic.framework.extramenu.exception; + +import neatlogic.framework.exception.core.ApiRuntimeException; + +public class ExtraMenuRootException extends ApiRuntimeException { + public ExtraMenuRootException() { + super("nfee.extramenurootexception.extramenurootexception"); + } +} diff --git a/src/main/java/neatlogic/framework/extramenu/exception/ExtraMenuRootNotAllowedException.java b/src/main/java/neatlogic/framework/extramenu/exception/ExtraMenuRootNotAllowedException.java new file mode 100644 index 0000000000000000000000000000000000000000..08ba569063a4c3f2cbb33f5b33758475d303a92a --- /dev/null +++ b/src/main/java/neatlogic/framework/extramenu/exception/ExtraMenuRootNotAllowedException.java @@ -0,0 +1,22 @@ +/* + * Copyright(c) 2023 NeatLogic Co., Ltd. All Rights Reserved. + * + * 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 neatlogic.framework.extramenu.exception; + +import neatlogic.framework.exception.core.ApiRuntimeException; + +public class ExtraMenuRootNotAllowedException extends ApiRuntimeException { + public ExtraMenuRootNotAllowedException() { + super("nfee.extramenurootnotallowedexception.extramenurootnotallowedexception"); + } +} diff --git a/src/main/resources/neatlogic/resources/framework/sqlscript/ddl.sql b/src/main/resources/neatlogic/resources/framework/sqlscript/ddl.sql index e5af6556e651b1295d87ace52338149cf25293a9..0d69c79fd095ea7351020d0c6fec3dada602a37b 100644 --- a/src/main/resources/neatlogic/resources/framework/sqlscript/ddl.sql +++ b/src/main/resources/neatlogic/resources/framework/sqlscript/ddl.sql @@ -1420,4 +1420,40 @@ CREATE TABLE IF NOT EXISTS `mail_server` ( PRIMARY KEY (`uuid`) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '邮件服务器表' ROW_FORMAT = Dynamic; +-- ---------------------------- +-- Table structure for extramenu +-- ---------------------------- +CREATE TABLE IF NOT EXISTS `extramenu` +( + `id` BIGINT NOT NULL COMMENT 'id', + `name` VARCHAR(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '名称', + `type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '类型,0:目录,1:菜单', + `is_active` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否激活', + `url` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '跳转链接', + `description` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '描述', + `parent_id` BIGINT DEFAULT NULL COMMENT '父id', + `lft` INT DEFAULT NULL COMMENT '左编码', + `rht` INT DEFAULT NULL COMMENT '右编码', + KEY `idx_lft_rht` (`lft`, `rht`), + KEY `idx_parent_id` (`parent_id`) +) ENGINE = INNODB + DEFAULT CHARSET = utf8mb4 + COLLATE = utf8mb4_general_ci COMMENT ='附加菜单表'; + +-- ---------------------------- +-- Table structure for extramenu_authority +-- ---------------------------- +CREATE TABLE IF NOT EXISTS `extramenu_authority` +( + `menu_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '菜单目录id', + `type` enum ('common','user','team','role') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '类型', + `uuid` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'uuid', + PRIMARY KEY (`menu_id`, `type`, `uuid`) USING BTREE, + KEY `idx_uuid` (`uuid`) USING BTREE, + KEY `idx_menu_id` (`menu_id`) USING BTREE +) ENGINE = InnoDB + DEFAULT CHARSET = utf8mb4 + COLLATE = utf8mb4_general_ci COMMENT ='附加菜单授权表'; + + SET FOREIGN_KEY_CHECKS = 1;