diff --git a/src/main/java/neatlogic/framework/auth/label/HOME_PAGE_MODIFY.java b/src/main/java/neatlogic/framework/auth/label/HOME_PAGE_MODIFY.java new file mode 100644 index 0000000000000000000000000000000000000000..89a12d68f98f05241d9dfcc486b91eae50403db6 --- /dev/null +++ b/src/main/java/neatlogic/framework/auth/label/HOME_PAGE_MODIFY.java @@ -0,0 +1,42 @@ +/*Copyright (C) 2023 深圳极向量科技有限公司 All Rights Reserved. + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see .*/ + +package neatlogic.framework.auth.label; + +import neatlogic.framework.auth.core.AuthBase; + +public class HOME_PAGE_MODIFY extends AuthBase { + + @Override + public String getAuthDisplayName() { + return "nfal.home_page_modify.getauthdisplayname"; + } + + @Override + public String getAuthIntroduction() { + return "nfal.home_page_modify.getauthintroduction"; + } + + @Override + public String getAuthGroup() { + return "framework"; + } + + @Override + public Integer getSort() { + return 100; + } + +} diff --git a/src/main/java/neatlogic/framework/dao/mapper/HomePageMapper.java b/src/main/java/neatlogic/framework/dao/mapper/HomePageMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..af53ab959e0f90eda1cd36f5ab0eeb6534d0efd4 --- /dev/null +++ b/src/main/java/neatlogic/framework/dao/mapper/HomePageMapper.java @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2024 深圳极向量科技有限公司 All Rights Reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package neatlogic.framework.dao.mapper; + +import neatlogic.framework.common.dto.BasePageVo; +import neatlogic.framework.dto.AuthenticationInfoVo; +import neatlogic.framework.dto.AuthorityVo; +import neatlogic.framework.dto.HomePageVo; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface HomePageMapper { + + int checkHomePageNameIsRepeat(HomePageVo homePage); + + HomePageVo getHomePageById(Long id); + + int getHomePageCount(BasePageVo basePageVo); + + List getHomePageList(BasePageVo basePageVo); + + List getHomePageAuthorityListByHomePageId(Long homePageId); + + Integer getMaxSort(); + + List getHomePageIdListByAuthority(AuthenticationInfoVo authenticationInfoVo); + + HomePageVo getMinSortHomePageByIdList(List idList); + + int insertHomePage(HomePageVo homePage); + + int insertHomePageAuthority(@Param("homePageId") Long homePageId, @Param("authorityVo") AuthorityVo authorityVo); + + int updateHomePageSortById(HomePageVo homePageVo); + + void updateHomePageIsActiveById(Long id); + + int updateSortDecrement(@Param("fromSort")Integer fromSort, @Param("toSort")Integer toSort); + + int updateSortIncrement(@Param("fromSort")Integer fromSort, @Param("toSort")Integer toSort); + + int deleteHomePageById(Long id); + + int deleteHomePageAuthorityByHomePageId(Long homePageId); +} diff --git a/src/main/java/neatlogic/framework/dao/mapper/HomePageMapper.xml b/src/main/java/neatlogic/framework/dao/mapper/HomePageMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..fd04f2dab38845d9873fe60a7dc0fe577a741659 --- /dev/null +++ b/src/main/java/neatlogic/framework/dao/mapper/HomePageMapper.xml @@ -0,0 +1,163 @@ + + + + + + + + + + + + + + + + + + + + + + + INSERT INTO `home_page` (`id`, `name`, `is_active`, `sort`, `config`) + VALUES (#{id}, #{name}, #{isActive}, #{sort}, #{configStr}) + ON DUPLICATE KEY + UPDATE `config` = #{configStr}, + `is_active` = #{isActive} + + + + INSERT INTO `home_page_authority` (`home_page_id`, `type`, `uuid`) + VALUES (#{homePageId}, #{authorityVo.type}, #{authorityVo.uuid}) + + + + UPDATE `home_page` SET `sort` = #{sort} WHERE `id` = #{id} + + + + UPDATE `home_page` SET `is_active` = 1 - `is_active` WHERE `id` = #{id} + + + + update `home_page` SET `sort` = `sort` + 1 + WHERE `sort` >= #{fromSort} + + AND `sort` <= #{toSort} + + + + + update `home_page` SET `sort` = `sort` - 1 + WHERE `sort` >= #{fromSort} + + AND `sort` <= #{toSort} + + + + + DELETE FROM `home_page` WHERE `id` = #{value} + + + + DELETE FROM `home_page_authority` WHERE `home_page_id` = #{value} + + \ No newline at end of file diff --git a/src/main/java/neatlogic/framework/dto/HomePageVo.java b/src/main/java/neatlogic/framework/dto/HomePageVo.java new file mode 100644 index 0000000000000000000000000000000000000000..ffc1da5feae0fc6e5a042bce38d0abb59879d6a2 --- /dev/null +++ b/src/main/java/neatlogic/framework/dto/HomePageVo.java @@ -0,0 +1,123 @@ +/* + * Copyright (C) 2024 深圳极向量科技有限公司 All Rights Reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package neatlogic.framework.dto; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.annotation.JSONField; +import neatlogic.framework.common.constvalue.ApiParamType; +import neatlogic.framework.restful.annotation.EntityField; +import neatlogic.framework.util.SnowflakeUtil; + +import java.util.List; + +public class HomePageVo { + @EntityField(name = "common.id", type = ApiParamType.LONG) + private Long id; + @EntityField(name = "common.name", type = ApiParamType.STRING) + private String name; + @EntityField(name = "common.isactive", type = ApiParamType.INTEGER) + private Integer isActive; + @EntityField(name = "common.sort", type = ApiParamType.INTEGER) + private Integer sort; + @EntityField(name = "common.config", type = ApiParamType.STRING) + private JSONObject config; + + @JSONField(serialize = false) + private String configStr; + @EntityField(name = "common.authoritylist", type = ApiParamType.JSONARRAY) + private List authorityList; + @EntityField(name = "common.authoritylist", type = ApiParamType.JSONARRAY) + private JSONArray authorityVoList; + + 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 getIsActive() { + return isActive; + } + + public void setIsActive(Integer isActive) { + this.isActive = isActive; + } + + public Integer getSort() { + if (sort == null) { + sort = 0; + } + return sort; + } + + public void setSort(Integer sort) { + this.sort = sort; + } + + public JSONObject getConfig() { + if (config == null && configStr != null) { + config = JSONObject.parseObject(configStr); + } + return config; + } + + public void setConfig(JSONObject config) { + this.config = config; + } + + public String getConfigStr() { + if (configStr == null && config != null) { + configStr = config.toJSONString(); + } + return configStr; + } + + public void setConfigStr(String configStr) { + this.configStr = configStr; + } + + public List getAuthorityList() { + return authorityList; + } + + public void setAuthorityList(List authorityList) { + this.authorityList = authorityList; + } + + public JSONArray getAuthorityVoList() { + return authorityVoList; + } + + public void setAuthorityVoList(JSONArray authorityVoList) { + this.authorityVoList = authorityVoList; + } +} diff --git a/src/main/java/neatlogic/framework/exception/homepage/HomePageNameRepeatException.java b/src/main/java/neatlogic/framework/exception/homepage/HomePageNameRepeatException.java new file mode 100644 index 0000000000000000000000000000000000000000..ab887dfa8b44d8ff4127ef28ab2801af38544799 --- /dev/null +++ b/src/main/java/neatlogic/framework/exception/homepage/HomePageNameRepeatException.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2024 深圳极向量科技有限公司 All Rights Reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package neatlogic.framework.exception.homepage; + +import neatlogic.framework.exception.core.ApiRuntimeException; + +public class HomePageNameRepeatException extends ApiRuntimeException { + public HomePageNameRepeatException(String name) { + super("nfeh.homepagenamerepeatexception.homepagenamerepeatexception", name); + } +} diff --git a/src/main/java/neatlogic/framework/exception/homepage/HomePageNotFoundException.java b/src/main/java/neatlogic/framework/exception/homepage/HomePageNotFoundException.java new file mode 100644 index 0000000000000000000000000000000000000000..d310aa12b0f1fdf3f5ced226377a03822bc9139e --- /dev/null +++ b/src/main/java/neatlogic/framework/exception/homepage/HomePageNotFoundException.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2024 深圳极向量科技有限公司 All Rights Reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package neatlogic.framework.exception.homepage; + +import neatlogic.framework.exception.core.ApiRuntimeException; + +public class HomePageNotFoundException extends ApiRuntimeException { + + public HomePageNotFoundException(Long id) { + super("nfeh.homepagenotfoundexception.homepagenotfoundexception", id); + } + + public HomePageNotFoundException(String name) { + super("nfeh.homepagenotfoundexception.homepagenotfoundexception", name); + } +} diff --git a/src/main/resources/neatlogic/resources/framework/changelog/2024-07-30/neatlogic_tenant.sql b/src/main/resources/neatlogic/resources/framework/changelog/2024-07-30/neatlogic_tenant.sql new file mode 100644 index 0000000000000000000000000000000000000000..d93bf40fa5f1c0cd3dcebbe5f99e348743a2a3ab --- /dev/null +++ b/src/main/resources/neatlogic/resources/framework/changelog/2024-07-30/neatlogic_tenant.sql @@ -0,0 +1,15 @@ +CREATE TABLE IF NOT EXISTS `home_page` ( + `id` bigint NOT NULL COMMENT 'ID', + `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '名称', + `is_active` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否启用', + `sort` int NOT NULL COMMENT '排序', + `config` longtext COLLATE utf8mb4_general_ci NOT NULL COMMENT '配置', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT = '首页设置表'; + +CREATE TABLE IF NOT EXISTS `home_page_authority` ( + `home_page_id` bigint NOT NULL COMMENT '首页ID', + `type` enum('common','user','team','role') COLLATE utf8mb4_general_ci NOT NULL COMMENT '类型', + `uuid` char(32) COLLATE utf8mb4_general_ci NOT NULL COMMENT 'UUID', + PRIMARY KEY (`home_page_id`,`type`,`uuid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='首页设置授权表'; \ No newline at end of file diff --git a/src/main/resources/neatlogic/resources/framework/changelog/2024-07-30/version.json b/src/main/resources/neatlogic/resources/framework/changelog/2024-07-30/version.json new file mode 100644 index 0000000000000000000000000000000000000000..139f297a983d1e5ceeace1867eb17c503c53315f --- /dev/null +++ b/src/main/resources/neatlogic/resources/framework/changelog/2024-07-30/version.json @@ -0,0 +1,10 @@ +{ + "content":[ + { + "type":"新增功能", + "detail":[ + {"msg":"1.全局控制用户默认首页"} + ] + } + ] +} diff --git a/src/main/resources/neatlogic/resources/framework/sqlscript/ddl.sql b/src/main/resources/neatlogic/resources/framework/sqlscript/ddl.sql index d86782841d0011ca47d45f3ad6c31829d9471f38..65db70dcb725c5db08cc43f4f7a40c94635e233f 100644 --- a/src/main/resources/neatlogic/resources/framework/sqlscript/ddl.sql +++ b/src/main/resources/neatlogic/resources/framework/sqlscript/ddl.sql @@ -1318,3 +1318,25 @@ CREATE TABLE IF NOT EXISTS `user_session_content` ( `content` text COLLATE utf8mb4_general_ci COMMENT '信息', PRIMARY KEY (`hash`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='用户会话'; + +-- ---------------------------- +-- Table structure for home_page +-- ---------------------------- +CREATE TABLE IF NOT EXISTS `home_page` ( + `id` bigint NOT NULL COMMENT 'ID', + `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '名称', + `is_active` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否启用', + `sort` int NOT NULL COMMENT '排序', + `config` longtext COLLATE utf8mb4_general_ci NOT NULL COMMENT '配置', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT = '首页设置表'; + +-- ---------------------------- +-- Table structure for home_page_authority +-- ---------------------------- +CREATE TABLE IF NOT EXISTS `home_page_authority` ( + `home_page_id` bigint NOT NULL COMMENT '首页ID', + `type` enum('common','user','team','role') COLLATE utf8mb4_general_ci NOT NULL COMMENT '类型', + `uuid` char(32) COLLATE utf8mb4_general_ci NOT NULL COMMENT 'UUID', + PRIMARY KEY (`home_page_id`,`type`,`uuid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='首页设置授权表'; \ No newline at end of file