mirror of https://gitee.com/stylefeng/roses
【7.6.0】【sys】整理starter模块
parent
24243e7e02
commit
a123ebaa3f
|
@ -47,4 +47,14 @@ public interface SysConstants {
|
||||||
*/
|
*/
|
||||||
String DEFAULT_LOGIN_PASSWORD = "Aa123456!";
|
String DEFAULT_LOGIN_PASSWORD = "Aa123456!";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 超级管理员的角色编码
|
||||||
|
*/
|
||||||
|
String SUPER_ADMIN_ROLE_CODE = "superAdmin";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化超级管理员的监听器顺序
|
||||||
|
*/
|
||||||
|
Integer SUPER_ADMIN_INIT_LISTENER_SORT = 400;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,135 @@
|
||||||
<groupId>cn.stylefeng.roses</groupId>
|
<groupId>cn.stylefeng.roses</groupId>
|
||||||
<artifactId>sys-business-hr</artifactId>
|
<artifactId>sys-business-hr</artifactId>
|
||||||
<version>${roses.version}</version>
|
<version>${roses.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!--应用权限管理模块-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.stylefeng.roses</groupId>
|
||||||
|
<artifactId>sys-business-permission</artifactId>
|
||||||
|
<version>${roses.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--门户业务-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.stylefeng.roses</groupId>
|
||||||
|
<artifactId>sys-business-portal</artifactId>
|
||||||
|
<version>${roses.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--缓存配置-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.stylefeng.roses</groupId>
|
||||||
|
<artifactId>cache-sdk-memory</artifactId>
|
||||||
|
<version>${roses.version}</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.stylefeng.roses</groupId>
|
||||||
|
<artifactId>cache-sdk-redis</artifactId>
|
||||||
|
<version>${roses.version}</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--将常用的模块集成在system中,主项目中保持简洁-->
|
||||||
|
|
||||||
|
<!--认证和鉴权模块-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.stylefeng.roses</groupId>
|
||||||
|
<artifactId>auth-spring-boot-starter</artifactId>
|
||||||
|
<version>${roses.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--安全模块-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.stylefeng.roses</groupId>
|
||||||
|
<artifactId>security-spring-boot-starter</artifactId>
|
||||||
|
<version>${roses.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--数据源连接和dao框架-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.stylefeng.roses</groupId>
|
||||||
|
<artifactId>db-spring-boot-starter</artifactId>
|
||||||
|
<version>${roses.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--文件管理-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.stylefeng.roses</groupId>
|
||||||
|
<artifactId>file-spring-boot-starter</artifactId>
|
||||||
|
<version>${roses.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--资源扫描-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.stylefeng.roses</groupId>
|
||||||
|
<artifactId>scanner-spring-boot-starter</artifactId>
|
||||||
|
<version>${roses.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--字典业务-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.stylefeng.roses</groupId>
|
||||||
|
<artifactId>dict-spring-boot-starter</artifactId>
|
||||||
|
<version>${roses.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--c端用户-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.stylefeng.roses</groupId>
|
||||||
|
<artifactId>customer-spring-boot-starter</artifactId>
|
||||||
|
<version>${roses.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--日志模块-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.stylefeng.roses</groupId>
|
||||||
|
<artifactId>log-spring-boot-starter</artifactId>
|
||||||
|
<version>${roses.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--定时任务-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.stylefeng.roses</groupId>
|
||||||
|
<artifactId>timer-spring-boot-starter</artifactId>
|
||||||
|
<version>${roses.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--Socket模块-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.stylefeng.roses</groupId>
|
||||||
|
<artifactId>socket-spring-boot-starter</artifactId>
|
||||||
|
<version>${roses.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--wrapper工具-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.stylefeng.roses</groupId>
|
||||||
|
<artifactId>wrapper-spring-boot-starter</artifactId>
|
||||||
|
<version>${roses.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--多数据源配置-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.stylefeng.roses</groupId>
|
||||||
|
<artifactId>ds-container-spring-boot-starter</artifactId>
|
||||||
|
<version>${roses.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--硬件信息获取-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.stylefeng.roses</groupId>
|
||||||
|
<artifactId>monitor-spring-boot-starter</artifactId>
|
||||||
|
<version>${roses.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--字段拓展信息-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.stylefeng.roses</groupId>
|
||||||
|
<artifactId>expand-spring-boot-starter</artifactId>
|
||||||
|
<version>${roses.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
package cn.stylefeng.roses.kernel.sys.starter;
|
||||||
|
|
||||||
|
import cn.stylefeng.roses.kernel.rule.pojo.response.ErrorResponseData;
|
||||||
|
import cn.stylefeng.roses.kernel.rule.util.ResponseRenderUtil;
|
||||||
|
import org.springframework.web.servlet.View;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当请求404的时候返回的错误界面
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @since 2021/5/17 10:45
|
||||||
|
*/
|
||||||
|
public class ErrorStaticJsonView implements View {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(Map<String, ?> model, HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||||
|
if (response.isCommitted()) {
|
||||||
|
// response已经提交不能响应
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果是运维平台404,Redirect到首页
|
||||||
|
if (model.get("path") != null && String.valueOf(model.get("path")).startsWith("/guns-devops")) {
|
||||||
|
response.sendRedirect("/guns-devops");
|
||||||
|
} else {
|
||||||
|
ErrorResponseData<Object> errorResponseData = new ErrorResponseData<>("404", "请求资源不存在");
|
||||||
|
ResponseRenderUtil.renderJsonResponse(response, errorResponseData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getContentType() {
|
||||||
|
return "text/html";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,59 @@
|
||||||
|
/*
|
||||||
|
* Copyright [2020-2030] [https://www.stylefeng.cn]
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||||
|
*
|
||||||
|
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||||
|
* 2.请不要删除和修改Guns源码头部的版权声明。
|
||||||
|
* 3.请保留源码和相关描述文件的项目出处,作者声明等。
|
||||||
|
* 4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||||
|
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||||
|
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||||
|
*/
|
||||||
|
package cn.stylefeng.roses.kernel.sys.starter.cache;
|
||||||
|
|
||||||
|
import cn.hutool.cache.CacheUtil;
|
||||||
|
import cn.hutool.cache.impl.TimedCache;
|
||||||
|
import cn.stylefeng.roses.kernel.cache.api.CacheOperatorApi;
|
||||||
|
import cn.stylefeng.roses.kernel.cache.api.constants.CacheConstants;
|
||||||
|
import cn.stylefeng.roses.kernel.scanner.api.pojo.resource.ResourceDefinition;
|
||||||
|
import cn.stylefeng.roses.kernel.sys.modular.resource.cache.MemoryResourceCache;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资源缓存自动配置
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @since 2021/5/17 16:44
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
@ConditionalOnMissingClass("org.springframework.data.redis.connection.RedisConnectionFactory")
|
||||||
|
public class ResourceMemoryCacheAutoConfiguration {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资源缓存
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @since 2021/5/17 16:44
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public CacheOperatorApi<ResourceDefinition> resourceCache() {
|
||||||
|
TimedCache<String, ResourceDefinition> timedCache = CacheUtil.newTimedCache(CacheConstants.NONE_EXPIRED_TIME);
|
||||||
|
return new MemoryResourceCache(timedCache);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,59 @@
|
||||||
|
/*
|
||||||
|
* Copyright [2020-2030] [https://www.stylefeng.cn]
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||||
|
*
|
||||||
|
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||||
|
* 2.请不要删除和修改Guns源码头部的版权声明。
|
||||||
|
* 3.请保留源码和相关描述文件的项目出处,作者声明等。
|
||||||
|
* 4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||||
|
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||||
|
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||||
|
*/
|
||||||
|
package cn.stylefeng.roses.kernel.sys.starter.cache;
|
||||||
|
|
||||||
|
import cn.stylefeng.roses.kernel.cache.api.CacheOperatorApi;
|
||||||
|
import cn.stylefeng.roses.kernel.cache.redis.util.CreateRedisTemplateUtil;
|
||||||
|
import cn.stylefeng.roses.kernel.scanner.api.pojo.resource.ResourceDefinition;
|
||||||
|
import cn.stylefeng.roses.kernel.sys.modular.resource.cache.RedisResourceCache;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资源缓存自动配置,Redis配置
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @since 2022/11/8 23:26
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
@ConditionalOnClass(name = "org.springframework.data.redis.connection.RedisConnectionFactory")
|
||||||
|
public class ResourceRedisCacheAutoConfiguration {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资源缓存
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @since 2022/11/8 23:27
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public CacheOperatorApi<ResourceDefinition> resourceCache(RedisConnectionFactory redisConnectionFactory) {
|
||||||
|
RedisTemplate<String, ResourceDefinition> redisTemplate = CreateRedisTemplateUtil.createObject(redisConnectionFactory);
|
||||||
|
return new RedisResourceCache(redisTemplate);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -22,17 +22,37 @@
|
||||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||||
*/
|
*/
|
||||||
package cn.stylefeng.roses.kernel.sys.starter;
|
package cn.stylefeng.roses.kernel.sys.starter.cache;
|
||||||
|
|
||||||
|
import cn.hutool.cache.CacheUtil;
|
||||||
|
import cn.hutool.cache.impl.TimedCache;
|
||||||
|
import cn.stylefeng.roses.kernel.cache.api.CacheOperatorApi;
|
||||||
|
import cn.stylefeng.roses.kernel.sys.modular.theme.cache.ThemeMemoryCache;
|
||||||
|
import cn.stylefeng.roses.kernel.sys.modular.theme.pojo.DefaultTheme;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 基础核心业务自动装配
|
* 系统管理缓存的自动配置(默认内存缓存)
|
||||||
*
|
*
|
||||||
* @author fengshuonan
|
* @author fengshuonan
|
||||||
* @date 2023-06-10 20:50:43
|
* @since 2021/2/28 10:29
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
public class SysAutoConfiguration {
|
@ConditionalOnMissingClass("org.springframework.data.redis.connection.RedisConnectionFactory")
|
||||||
|
public class SystemMemoryCacheAutoConfiguration {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主题的缓存
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @since 2021/7/31 17:59
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public CacheOperatorApi<DefaultTheme> themeCacheApi() {
|
||||||
|
TimedCache<String, DefaultTheme> themeCache = CacheUtil.newTimedCache(Long.MAX_VALUE);
|
||||||
|
return new ThemeMemoryCache(themeCache);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,59 @@
|
||||||
|
/*
|
||||||
|
* Copyright [2020-2030] [https://www.stylefeng.cn]
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||||
|
*
|
||||||
|
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||||
|
* 2.请不要删除和修改Guns源码头部的版权声明。
|
||||||
|
* 3.请保留源码和相关描述文件的项目出处,作者声明等。
|
||||||
|
* 4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||||
|
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||||
|
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||||
|
*/
|
||||||
|
package cn.stylefeng.roses.kernel.sys.starter.cache;
|
||||||
|
|
||||||
|
import cn.stylefeng.roses.kernel.cache.api.CacheOperatorApi;
|
||||||
|
import cn.stylefeng.roses.kernel.cache.redis.util.CreateRedisTemplateUtil;
|
||||||
|
import cn.stylefeng.roses.kernel.sys.modular.theme.cache.ThemeRedisCache;
|
||||||
|
import cn.stylefeng.roses.kernel.sys.modular.theme.pojo.DefaultTheme;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统管理缓存的自动配置,Redis配置
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @since 2022/11/8 23:26
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
@ConditionalOnClass(name = "org.springframework.data.redis.connection.RedisConnectionFactory")
|
||||||
|
public class SystemRedisCacheAutoConfiguration {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主题的缓存
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @since 2022/11/8 23:32
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public CacheOperatorApi<DefaultTheme> themeCacheApi(RedisConnectionFactory redisConnectionFactory) {
|
||||||
|
RedisTemplate<String, DefaultTheme> redisTemplate = CreateRedisTemplateUtil.createObject(redisConnectionFactory);
|
||||||
|
return new ThemeRedisCache(redisTemplate);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
package cn.stylefeng.roses.kernel.sys.starter.config;
|
||||||
|
|
||||||
|
import cn.stylefeng.roses.kernel.sys.starter.ErrorStaticJsonView;
|
||||||
|
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
|
import org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 错误界面自动配置,一般用于404响应
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @since 2021/5/17 11:16
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
@AutoConfigureBefore(ErrorMvcAutoConfiguration.class)
|
||||||
|
public class RestErrorViewAutoConfiguration {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 默认错误页面,返回json
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @since 2020/12/16 15:47
|
||||||
|
*/
|
||||||
|
@Bean("error")
|
||||||
|
@ConditionalOnMissingBean(name = "error")
|
||||||
|
public ErrorStaticJsonView error() {
|
||||||
|
return new ErrorStaticJsonView();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,75 @@
|
||||||
|
/*
|
||||||
|
* Copyright [2020-2030] [https://www.stylefeng.cn]
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||||
|
*
|
||||||
|
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||||
|
* 2.请不要删除和修改Guns源码头部的版权声明。
|
||||||
|
* 3.请保留源码和相关描述文件的项目出处,作者声明等。
|
||||||
|
* 4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||||
|
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||||
|
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||||
|
*/
|
||||||
|
package cn.stylefeng.roses.kernel.sys.starter.init;
|
||||||
|
|
||||||
|
import cn.stylefeng.roses.kernel.sys.api.constants.SysConstants;
|
||||||
|
import cn.stylefeng.roses.kernel.sys.modular.resource.service.SysResourceService;
|
||||||
|
import cn.stylefeng.roses.kernel.sys.modular.role.entity.SysRole;
|
||||||
|
import cn.stylefeng.roses.kernel.sys.modular.role.service.SysRoleResourceService;
|
||||||
|
import cn.stylefeng.roses.kernel.sys.modular.role.service.SysRoleService;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化admin管理员的服务
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @since 2020/12/17 21:56
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class InitAdminService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private SysRoleService sysRoleService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private SysResourceService sysResourceService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private SysRoleResourceService sysRoleResourceService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化超级管理员,超级管理员拥有最高权限
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @since 2020/12/17 21:57
|
||||||
|
*/
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void initSuperAdmin() {
|
||||||
|
|
||||||
|
// 找到超级管理员的角色id
|
||||||
|
LambdaQueryWrapper<SysRole> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(SysRole::getRoleCode, SysConstants.SUPER_ADMIN_ROLE_CODE);
|
||||||
|
SysRole superAdminRole = sysRoleService.getOne(queryWrapper);
|
||||||
|
|
||||||
|
// todo 超级管理员绑定所有的菜单 和 菜单功能
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,62 @@
|
||||||
|
/*
|
||||||
|
* Copyright [2020-2030] [https://www.stylefeng.cn]
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||||
|
*
|
||||||
|
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||||
|
* 2.请不要删除和修改Guns源码头部的版权声明。
|
||||||
|
* 3.请保留源码和相关描述文件的项目出处,作者声明等。
|
||||||
|
* 4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||||
|
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||||
|
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||||
|
*/
|
||||||
|
package cn.stylefeng.roses.kernel.sys.starter.listener;
|
||||||
|
|
||||||
|
import cn.stylefeng.roses.kernel.rule.listener.ApplicationReadyListener;
|
||||||
|
import cn.stylefeng.roses.kernel.sys.api.constants.SysConstants;
|
||||||
|
import cn.stylefeng.roses.kernel.sys.starter.init.InitAdminService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
||||||
|
import org.springframework.core.Ordered;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目启动后初始化超级管理员
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @since 2020/12/17 21:44
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class SuperAdminInitListener extends ApplicationReadyListener implements Ordered {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private InitAdminService initAdminService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void eventCallback(ApplicationReadyEvent event) {
|
||||||
|
long startTime = System.currentTimeMillis();
|
||||||
|
initAdminService.initSuperAdmin();
|
||||||
|
log.info("初始化超级管理员权限完成,耗时:{}ms", (System.currentTimeMillis() - startTime));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getOrder() {
|
||||||
|
return SysConstants.SUPER_ADMIN_INIT_LISTENER_SORT;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,2 +1,7 @@
|
||||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||||
cn.stylefeng.roses.kernel.sys.starter.SysAutoConfiguration
|
cn.stylefeng.roses.kernel.sys.starter.cache.SystemMemoryCacheAutoConfiguration,\
|
||||||
|
cn.stylefeng.roses.kernel.sys.starter.cache.SystemRedisCacheAutoConfiguration,\
|
||||||
|
cn.stylefeng.roses.kernel.sys.starter.cache.ResourceMemoryCacheAutoConfiguration,\
|
||||||
|
cn.stylefeng.roses.kernel.sys.starter.cache.ResourceRedisCacheAutoConfiguration,\
|
||||||
|
cn.stylefeng.roses.kernel.sys.starter.SystemHomeStatisticsAutoConfiguration,\
|
||||||
|
cn.stylefeng.roses.kernel.sys.starter.config.RestErrorViewAutoConfiguration
|
Loading…
Reference in New Issue