若依微服务1.02版本,搭建整体框架

1、ruoyi-common增加hw-common-i18n,支持后端国际化
2、ruoyi-modules增加hw-business:增加业务模块,并增加了场景的代码(自动生成的,需要修改),状态上有自定义注解,controller新建方法有validated方法来通过注解校验。(目前只是示例规范)
3、ruoyi-modules增加了hw-basic,增加平台的基本模块
4、rouyi-ui:增加了国际化支持,增加了场景的前端代码(自动生成的,需要修改)
pull/1/head
xins 1 year ago
parent 2eee79774a
commit f09c665fe5

@ -199,6 +199,13 @@
<version>${ruoyi.version}</version>
</dependency>
<!-- 国际化多语言 -->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>hw-common-i18n</artifactId>
<version>${ruoyi.version}</version>
</dependency>
<!-- 系统接口 -->
<dependency>
<groupId>com.ruoyi</groupId>

@ -0,0 +1,38 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

@ -0,0 +1,56 @@
<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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common</artifactId>
<version>3.6.3</version>
</parent>
<artifactId>hw-common-i18n</artifactId>
<packaging>jar</packaging>
<name>hw-common-i18n</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- SpringBoot Web容器 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-core</artifactId>
</dependency>
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-redis</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.3.28</version>
</dependency>
</dependencies>
</project>

@ -0,0 +1,71 @@
package com.ruoyi.i18n.config;
import com.ruoyi.i18n.interceptor.MyLocaleChangeInterceptor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
import org.springframework.web.servlet.i18n.SessionLocaleResolver;
import java.util.List;
import java.util.Locale;
/**
*
*
* @author ruoyi
*/
@Configuration
public class I18nConfig implements WebMvcConfigurer
{
// @Value("#{'${i18n_msg.baseName}'.split(',')}")
// @Value("${spring.messages.basename}")
// private String basename;
@Bean(name = "myLocaleResolver")
public LocaleResolver localeResolver()
{
WebMvcAutoConfiguration dd =null;
SessionLocaleResolver slr = new SessionLocaleResolver();
// 默认语言
slr.setDefaultLocale(Locale.SIMPLIFIED_CHINESE);
return slr;
}
@Bean
public MyLocaleChangeInterceptor localeChangeInterceptor()
{
MyLocaleChangeInterceptor lci = new MyLocaleChangeInterceptor();
// 参数名
//lci.setParamName("lang");
return lci;
}
@Bean
public MessageSource messageSource() {
ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
messageSource.setBasenames("classpath:i18n/messages");
messageSource.setDefaultEncoding("utf-8");
//设置缓存时间1个小时 1*60*60*1000毫秒
//可以设置成-1表示永久缓存设置成0表示每次都从文件中读取
messageSource.setCacheMillis(1*60*60*1000);
messageSource.setFallbackToSystemLocale(true);
return messageSource;
}
@Override
public void addInterceptors(InterceptorRegistry registry)
{
registry.addInterceptor(localeChangeInterceptor());
}
}

@ -0,0 +1,65 @@
package com.ruoyi.i18n.interceptor;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.lang.Nullable;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.util.WebUtils;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Enumeration;
import java.util.Locale;
public class MyLocaleChangeInterceptor implements HandlerInterceptor {
private final static String paramName = "language";
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
// cookie :language=en_US
// header :language=en_US
// parameter :language=en_US
//通过制定cookie,header,param
// 获取本地语言的优先级 cookie<header<parameter
String locale="";
//1、处理cookie中带有的语言信息
Cookie cookie = WebUtils.getCookie(request, paramName);
String cookieLocale="";
if (cookie!=null) {
// Proceed in cookie
cookieLocale=cookie.getValue();
}
if(cookieLocale!=null&& !cookieLocale.trim().equals("")){
locale=cookieLocale;
}
// 2、每次请求的header中可以单独指定语言 language=zh_CN
String headerLocale = request.getHeader(paramName);
// System.out.println((request.getHeader("accept-language")));
// System.out.println(request.getHeader("cookie"));
if(headerLocale!=null && !headerLocale.trim().equals("")){
locale=headerLocale;
}
// 3、从get 参数数据获取 language=zh_CN
String parameterLocale=request.getParameter(paramName);
if(parameterLocale!=null && !parameterLocale.trim().equals("")){
locale=parameterLocale;
}
//4 语言信息写入线程变量
if (locale!=null) {
LocaleContextHolder.setLocale(parseLocaleValue(locale));
}
return true;
}
@Nullable
protected Locale parseLocaleValue(String localeValue) {
return StringUtils.parseLocale(localeValue);
}
}

@ -0,0 +1,105 @@
package com.ruoyi.i18n.utils;
import com.ruoyi.common.redis.service.RedisService;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.util.Locale;
@Component
public class I18nUtils {
/**
*
*/
//private static String localeAttributeName = Constants.LOCALE_SESSION_ATTRIBUTE_NAME;
private static String localeAttributeName ="";
private static MessageSource messageSource;
private static RedisService redisService;
/**
*
* @param messageSource
*/
public I18nUtils(MessageSource messageSource,RedisService redisService) {
I18nUtils.messageSource = messageSource;
I18nUtils.redisService=redisService;
}
/**
* key
* @param msgKey
* @return
*/
public static String getMessage(String msgKey) {
return getMessage(msgKey, null);
}
/**
* key,args
* @param msgKey
* @param args
* @return
*/
public static String getMessage(String msgKey,Object[] args) {
try {
return messageSource.getMessage(msgKey, args, getLocaleFromRedis());
} catch (Exception e) {
return msgKey;
}
}
/**
* redis
* @return
*/
public static Locale getLocaleFromRedis(){
// String token ="";
// try {
// token = TokenUtil.getToken(getRequest());
// } catch (Exception e) {
// return LocaleContextHolder.getLocale();
// }
// String lan=redisService.getCacheObject(localeAttributeName + token);
// Locale locale=null;
// if(StringUtils.isNotBlank(lan)){
// String[] lans=lan.split("_");
// locale = new Locale(lans[0], lans[1]);
// }else{
// locale=LocaleContextHolder.getLocale();//获取浏览器请求
// }
Locale locale=null;
String[] lans = {"en","US"};
locale = new Locale(lans[0], lans[1]);
return locale;
}
/**
*
* @return
*/
public static ServletRequestAttributes getRequestAttributes()
{
RequestAttributes attributes = RequestContextHolder.getRequestAttributes();
return (ServletRequestAttributes) attributes;
}
/**
* request
* @return
*/
public static HttpServletRequest getRequest()
{
return getRequestAttributes().getRequest();
}
}

@ -0,0 +1,45 @@
package com.ruoyi.i18n.utils;
import com.ruoyi.common.core.utils.SpringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import java.util.Arrays;
/**
* desc i18n
*/
public class MessageUtils {
@Autowired
private static MessageSource messageSource = SpringUtils.getBean(MessageSource.class);
public MessageUtils() {
}
/**
* messageKey spring messageSource
*
* @param code key
* @return
*/
public static String getMessage(Object code) {
System.out.println("locale:"+LocaleContextHolder.getLocale());
return messageSource.getMessage(code.toString(), null, code.toString(), LocaleContextHolder.getLocale());
}
/**
* messageKey spring messageSource
*
* @param code key
* @param messageArgs
* @return
*/
public static String getMessages(Object code, Object... messageArgs) {
Object[] objs = Arrays.stream(messageArgs).map(MessageUtils::getMessage).toArray();
String message =
messageSource.getMessage(code.toString(), objs, code.toString(), LocaleContextHolder.getLocale());
return message;
}
}

@ -0,0 +1,5 @@
user.login.username=User name
user.login.password=Password
user.login.code=Security code
user.login.remember=Remember me
user.login.submit=Sign In

@ -0,0 +1,6 @@
user.login.username=\u7528\u6237\u540D
user.login.password=\u5BC6\u7801
user.login.code=\u9A8C\u8BC1\u7801
user.login.remember=\u8BB0\u4F4F\u6211
user.login.submit=\u767B\u5F55

@ -17,6 +17,7 @@
<module>ruoyi-common-security</module>
<module>ruoyi-common-datascope</module>
<module>ruoyi-common-datasource</module>
<module>hw-common-i18n</module>
</modules>
<artifactId>ruoyi-common</artifactId>

@ -0,0 +1,111 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-modules</artifactId>
<version>3.6.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>ruoyi-modules-basic</artifactId>
<description>
物联网平台基本模块
</description>
<dependencies>
<!-- SpringCloud Alibaba Nacos -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- SpringCloud Alibaba Nacos Config -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<!-- SpringCloud Alibaba Sentinel -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<!-- SpringBoot Actuator -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- Swagger UI -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger.fox.version}</version>
</dependency>
<!-- Mysql Connector -->
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
</dependency>
<!-- RuoYi Common DataSource -->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-datasource</artifactId>
</dependency>
<!-- RuoYi Common DataScope -->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-datascope</artifactId>
</dependency>
<!-- RuoYi Common Log -->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-log</artifactId>
</dependency>
<!-- RuoYi Common Swagger -->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-swagger</artifactId>
</dependency>
<!-- RuoYi Common International Language -->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>hw-common-i18n</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

@ -0,0 +1,38 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

@ -0,0 +1,111 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-modules</artifactId>
<version>3.6.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>rouyi-modules-business</artifactId>
<description>
海威物联网平台业务模块
</description>
<dependencies>
<!-- SpringCloud Alibaba Nacos -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- SpringCloud Alibaba Nacos Config -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<!-- SpringCloud Alibaba Sentinel -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<!-- SpringBoot Actuator -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- Swagger UI -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger.fox.version}</version>
</dependency>
<!-- Mysql Connector -->
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
</dependency>
<!-- RuoYi Common DataSource -->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-datasource</artifactId>
</dependency>
<!-- RuoYi Common DataScope -->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-datascope</artifactId>
</dependency>
<!-- RuoYi Common Log -->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-log</artifactId>
</dependency>
<!-- RuoYi Common Swagger -->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-swagger</artifactId>
</dependency>
<!-- RuoYi Common International Language -->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>hw-common-i18n</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

@ -0,0 +1,22 @@
package com.ruoyi;
import com.ruoyi.i18n.utils.MessageUtils;
// Press Shift twice to open the Search Everywhere dialog and type `show whitespaces`,
// then press Enter. You can now see whitespace characters in your code.
public class Main {
public static void main(String[] args) {
// Press Alt+Enter with your caret at the highlighted text to see how
// IntelliJ IDEA suggests fixing it.
System.out.printf("Hello and welcome!");
String dd = MessageUtils.getMessages("user.login.username");
System.out.println("dddd:"+dd);
// Press Shift+F10 or click the green arrow button in the gutter to run the code.
for (int i = 1; i <= 5; i++) {
// Press Shift+F9 to start debugging your code. We have set one breakpoint
// for you, but you can always add more by pressing Ctrl+F8.
System.out.println("i = " + i);
}
}
}

@ -0,0 +1,34 @@
package com.ruoyi.business;
import com.ruoyi.common.security.annotation.EnableCustomConfig;
import com.ruoyi.common.security.annotation.EnableRyFeignClients;
import com.ruoyi.common.swagger.annotation.EnableCustomSwagger2;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
*
*
* @author ruoyi
*/
@EnableCustomConfig
@EnableCustomSwagger2
@EnableRyFeignClients
@SpringBootApplication
public class HwBusinessApplication
{
public static void main(String[] args)
{
SpringApplication.run(HwBusinessApplication.class, args);
System.out.println("(♥◠‿◠)ノ゙ 物联网平台业务模块启动成功 ლ(´ڡ`ლ)゙ \n" +
" .-------. ____ __ \n" +
" | _ _ \\ \\ \\ / / \n" +
" | ( ' ) | \\ _. / ' \n" +
" |(_ o _) / _( )_ .' \n" +
" | (_,_).' __ ___(_ o _)' \n" +
" | |\\ \\ | || |(_,_)' \n" +
" | | \\ `' /| `-' / \n" +
" | | \\ / \\ / \n" +
" ''-' `'-' `-..-' ");
}
}

@ -0,0 +1,10 @@
Spring Boot Version: ${spring-boot.version}
Spring Application Name: ${spring.application.name}
_ _
(_) | |
_ __ _ _ ___ _ _ _ ______ ___ _ _ ___ | |_ ___ _ __ ___
| '__|| | | | / _ \ | | | || ||______|/ __|| | | |/ __|| __| / _ \| '_ ` _ \
| | | |_| || (_) || |_| || | \__ \| |_| |\__ \| |_ | __/| | | | | |
|_| \__,_| \___/ \__, ||_| |___/ \__, ||___/ \__| \___||_| |_| |_|
__/ | __/ |
|___/ |___/

@ -0,0 +1,25 @@
# Tomcat
server:
port: 9601
# Spring
spring:
application:
# 应用名称
name: hw-business
profiles:
# 环境配置
active: dev
cloud:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<!-- 日志存放路径 -->
<property name="log.path" value="logs/hw-business" />
<!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- 系统日志输出 -->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/info.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>INFO</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/error.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>ERROR</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 系统模块日志级别控制 -->
<logger name="com.ruoyi" level="info" />
<!-- Spring日志级别控制 -->
<logger name="org.springframework" level="warn" />
<root level="info">
<appender-ref ref="console" />
</root>
<!--系统操作日志-->
<root level="info">
<appender-ref ref="file_info" />
<appender-ref ref="file_error" />
</root>
</configuration>

@ -0,0 +1,141 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.business.mapper.HwSceneMapper">
<resultMap type="HwScene" id="HwSceneResult">
<result property="sceneId" column="scene_id" />
<result property="sceneName" column="scene_name" />
<result property="tenantId" column="tenant_id" />
<result property="sceneModeId" column="scene_mode_id" />
<result property="scenePic" column="scene_pic" />
<result property="defaultFlag" column="default_flag" />
<result property="sceneStatus" column="scene_status" />
<result property="authMode" column="auth_mode" />
<result property="modeAccount" column="mode_account" />
<result property="modeKey" column="mode_key" />
<result property="modeSecret" column="mode_secret" />
<result property="preserveTime" column="preserve_time" />
<result property="testPreserveTime" column="test_preserve_time" />
<result property="remark" column="remark" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="sceneEnvironment" column="scene_environment" />
<result property="sceneField" column="scene_field" />
</resultMap>
<sql id="selectHwSceneVo">
select scene_id, scene_name, tenant_id, scene_mode_id, scene_pic, default_flag, scene_status, auth_mode, mode_account, mode_key, mode_secret, preserve_time, test_preserve_time, remark, create_by, create_time, update_by, update_time, scene_environment, scene_field from hw_scene
</sql>
<select id="selectHwSceneList" parameterType="HwScene" resultMap="HwSceneResult">
<include refid="selectHwSceneVo"/>
<where>
<if test="sceneName != null and sceneName != ''"> and scene_name like concat('%', #{sceneName}, '%')</if>
<if test="tenantId != null "> and tenant_id = #{tenantId}</if>
<if test="sceneModeId != null "> and scene_mode_id = #{sceneModeId}</if>
<if test="scenePic != null and scenePic != ''"> and scene_pic = #{scenePic}</if>
<if test="defaultFlag != null and defaultFlag != ''"> and default_flag = #{defaultFlag}</if>
<if test="sceneStatus != null and sceneStatus != ''"> and scene_status = #{sceneStatus}</if>
<if test="authMode != null and authMode != ''"> and auth_mode = #{authMode}</if>
<if test="modeAccount != null and modeAccount != ''"> and mode_account = #{modeAccount}</if>
<if test="modeKey != null and modeKey != ''"> and mode_key = #{modeKey}</if>
<if test="modeSecret != null and modeSecret != ''"> and mode_secret = #{modeSecret}</if>
<if test="preserveTime != null "> and preserve_time = #{preserveTime}</if>
<if test="testPreserveTime != null "> and test_preserve_time = #{testPreserveTime}</if>
<if test="sceneEnvironment != null and sceneEnvironment != ''"> and scene_environment = #{sceneEnvironment}</if>
<if test="sceneField != null and sceneField != ''"> and scene_field = #{sceneField}</if>
</where>
</select>
<select id="selectHwSceneBySceneId" parameterType="Long" resultMap="HwSceneResult">
<include refid="selectHwSceneVo"/>
where scene_id = #{sceneId}
</select>
<insert id="insertHwScene" parameterType="HwScene" useGeneratedKeys="true" keyProperty="sceneId">
insert into hw_scene
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="sceneName != null and sceneName != ''">scene_name,</if>
<if test="tenantId != null">tenant_id,</if>
<if test="sceneModeId != null">scene_mode_id,</if>
<if test="scenePic != null">scene_pic,</if>
<if test="defaultFlag != null and defaultFlag != ''">default_flag,</if>
<if test="sceneStatus != null and sceneStatus != ''">scene_status,</if>
<if test="authMode != null and authMode != ''">auth_mode,</if>
<if test="modeAccount != null">mode_account,</if>
<if test="modeKey != null and modeKey != ''">mode_key,</if>
<if test="modeSecret != null and modeSecret != ''">mode_secret,</if>
<if test="preserveTime != null">preserve_time,</if>
<if test="testPreserveTime != null">test_preserve_time,</if>
<if test="remark != null">remark,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="sceneEnvironment != null">scene_environment,</if>
<if test="sceneField != null">scene_field,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sceneName != null and sceneName != ''">#{sceneName},</if>
<if test="tenantId != null">#{tenantId},</if>
<if test="sceneModeId != null">#{sceneModeId},</if>
<if test="scenePic != null">#{scenePic},</if>
<if test="defaultFlag != null and defaultFlag != ''">#{defaultFlag},</if>
<if test="sceneStatus != null and sceneStatus != ''">#{sceneStatus},</if>
<if test="authMode != null and authMode != ''">#{authMode},</if>
<if test="modeAccount != null">#{modeAccount},</if>
<if test="modeKey != null and modeKey != ''">#{modeKey},</if>
<if test="modeSecret != null and modeSecret != ''">#{modeSecret},</if>
<if test="preserveTime != null">#{preserveTime},</if>
<if test="testPreserveTime != null">#{testPreserveTime},</if>
<if test="remark != null">#{remark},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="sceneEnvironment != null">#{sceneEnvironment},</if>
<if test="sceneField != null">#{sceneField},</if>
</trim>
</insert>
<update id="updateHwScene" parameterType="HwScene">
update hw_scene
<trim prefix="SET" suffixOverrides=",">
<if test="sceneName != null and sceneName != ''">scene_name = #{sceneName},</if>
<if test="tenantId != null">tenant_id = #{tenantId},</if>
<if test="sceneModeId != null">scene_mode_id = #{sceneModeId},</if>
<if test="scenePic != null">scene_pic = #{scenePic},</if>
<if test="defaultFlag != null and defaultFlag != ''">default_flag = #{defaultFlag},</if>
<if test="sceneStatus != null and sceneStatus != ''">scene_status = #{sceneStatus},</if>
<if test="authMode != null and authMode != ''">auth_mode = #{authMode},</if>
<if test="modeAccount != null">mode_account = #{modeAccount},</if>
<if test="modeKey != null and modeKey != ''">mode_key = #{modeKey},</if>
<if test="modeSecret != null and modeSecret != ''">mode_secret = #{modeSecret},</if>
<if test="preserveTime != null">preserve_time = #{preserveTime},</if>
<if test="testPreserveTime != null">test_preserve_time = #{testPreserveTime},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="sceneEnvironment != null">scene_environment = #{sceneEnvironment},</if>
<if test="sceneField != null">scene_field = #{sceneField},</if>
</trim>
where scene_id = #{sceneId}
</update>
<delete id="deleteHwSceneBySceneId" parameterType="Long">
delete from hw_scene where scene_id = #{sceneId}
</delete>
<delete id="deleteHwSceneBySceneIds" parameterType="String">
delete from hw_scene where scene_id in
<foreach item="sceneId" collection="array" open="(" separator="," close=")">
#{sceneId}
</foreach>
</delete>
</mapper>

@ -6,6 +6,16 @@
<artifactId>ruoyi</artifactId>
<version>3.6.3</version>
</parent>
<dependencies>
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-security</artifactId>
</dependency>
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-swagger</artifactId>
</dependency>
</dependencies>
<modelVersion>4.0.0</modelVersion>
<modules>
@ -14,6 +24,8 @@
<module>ruoyi-job</module>
<module>ruoyi-file</module>
<module>hw-mqtt-broker</module>
<module>hw-business</module>
<module>hw-basic</module>
</modules>
<artifactId>ruoyi-modules</artifactId>

@ -78,6 +78,17 @@
<artifactId>ruoyi-common-swagger</artifactId>
</dependency>
<!-- RuoYi Common International Language -->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>hw-common-i18n</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>

@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询场景信息列表
export function listScene(query) {
return request({
url: '/business/scene/list',
method: 'get',
params: query
})
}
// 查询场景信息详细
export function getScene(sceneId) {
return request({
url: '/business/scene/' + sceneId,
method: 'get'
})
}
// 新增场景信息
export function addScene(data) {
return request({
url: '/business/scene',
method: 'post',
data: data
})
}
// 修改场景信息
export function updateScene(data) {
return request({
url: '/business/scene',
method: 'put',
data: data
})
}
// 删除场景信息
export function delScene(sceneId) {
return request({
url: '/business/scene/' + sceneId,
method: 'delete'
})
}

@ -0,0 +1,452 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="场景名称" prop="sceneName">
<el-input
v-model="queryParams.sceneName"
placeholder="请输入场景名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="租户ID关联hw_tenant的tenant_id" prop="tenantId">
<el-input
v-model="queryParams.tenantId"
placeholder="请输入租户ID关联hw_tenant的tenant_id"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="场景类型关联表hw_scene_mode的scene_mode_id" prop="sceneModeId">
<el-input
v-model="queryParams.sceneModeId"
placeholder="请输入场景类型关联表hw_scene_mode的scene_mode_id"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="场景图片地址" prop="scenePic">
<el-input
v-model="queryParams.scenePic"
placeholder="请输入场景图片地址"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="是否默认" prop="defaultFlag">
<el-input
v-model="queryParams.defaultFlag"
placeholder="请输入是否默认"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="认证方式" prop="authMode">
<el-input
v-model="queryParams.authMode"
placeholder="请输入认证方式"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="场景账号" prop="modeAccount">
<el-input
v-model="queryParams.modeAccount"
placeholder="请输入场景账号"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="场景key" prop="modeKey">
<el-input
v-model="queryParams.modeKey"
placeholder="请输入场景key"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="场景secret" prop="modeSecret">
<el-input
v-model="queryParams.modeSecret"
placeholder="请输入场景secret"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="保存周期(单位默认90天" prop="preserveTime">
<el-input
v-model="queryParams.preserveTime"
placeholder="请输入保存周期(单位默认90天"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="测试环境保存周期(单位默认30天" prop="testPreserveTime">
<el-input
v-model="queryParams.testPreserveTime"
placeholder="请输入测试环境保存周期(单位默认30天"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="预留字段,租户环境" prop="sceneEnvironment">
<el-input
v-model="queryParams.sceneEnvironment"
placeholder="请输入预留字段,租户环境"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="预留字段" prop="sceneField">
<el-input
v-model="queryParams.sceneField"
placeholder="请输入预留字段"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['business:scene:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['business:scene:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['business:scene:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['business:scene:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="sceneList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="场景ID" align="center" prop="sceneId" />
<el-table-column label="场景名称" align="center" prop="sceneName" />
<el-table-column label="租户ID关联hw_tenant的tenant_id" align="center" prop="tenantId" />
<el-table-column label="场景类型关联表hw_scene_mode的scene_mode_id" align="center" prop="sceneModeId" />
<el-table-column label="场景图片地址" align="center" prop="scenePic" />
<el-table-column label="是否默认" align="center" prop="defaultFlag" />
<el-table-column label="状态" align="center" prop="sceneStatus" />
<el-table-column label="认证方式" align="center" prop="authMode" />
<el-table-column label="场景账号" align="center" prop="modeAccount" />
<el-table-column label="场景key" align="center" prop="modeKey" />
<el-table-column label="场景secret" align="center" prop="modeSecret" />
<el-table-column label="保存周期(单位默认90天" align="center" prop="preserveTime" />
<el-table-column label="测试环境保存周期(单位默认30天" align="center" prop="testPreserveTime" />
<el-table-column label="场景描述" align="center" prop="remark" />
<el-table-column label="预留字段,租户环境" align="center" prop="sceneEnvironment" />
<el-table-column label="预留字段" align="center" prop="sceneField" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['business:scene:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['business:scene:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改场景信息对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="场景名称" prop="sceneName">
<el-input v-model="form.sceneName" placeholder="请输入场景名称" />
</el-form-item>
<el-form-item label="租户ID关联hw_tenant的tenant_id" prop="tenantId">
<el-input v-model="form.tenantId" placeholder="请输入租户ID关联hw_tenant的tenant_id" />
</el-form-item>
<el-form-item label="场景类型关联表hw_scene_mode的scene_mode_id" prop="sceneModeId">
<el-input v-model="form.sceneModeId" placeholder="请输入场景类型关联表hw_scene_mode的scene_mode_id" />
</el-form-item>
<el-form-item label="场景图片地址" prop="scenePic">
<el-input v-model="form.scenePic" placeholder="请输入场景图片地址" />
</el-form-item>
<el-form-item label="是否默认" prop="defaultFlag">
<el-input v-model="form.defaultFlag" placeholder="请输入是否默认" />
</el-form-item>
<el-form-item label="认证方式" prop="authMode">
<el-input v-model="form.authMode" placeholder="请输入认证方式" />
</el-form-item>
<el-form-item label="场景账号" prop="modeAccount">
<el-input v-model="form.modeAccount" placeholder="请输入场景账号" />
</el-form-item>
<el-form-item label="场景key" prop="modeKey">
<el-input v-model="form.modeKey" placeholder="请输入场景key" />
</el-form-item>
<el-form-item label="场景secret" prop="modeSecret">
<el-input v-model="form.modeSecret" placeholder="请输入场景secret" />
</el-form-item>
<el-form-item label="保存周期(单位默认90天" prop="preserveTime">
<el-input v-model="form.preserveTime" placeholder="请输入保存周期(单位默认90天" />
</el-form-item>
<el-form-item label="测试环境保存周期(单位默认30天" prop="testPreserveTime">
<el-input v-model="form.testPreserveTime" placeholder="请输入测试环境保存周期(单位默认30天" />
</el-form-item>
<el-form-item label="场景描述" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
</el-form-item>
<el-form-item label="预留字段,租户环境" prop="sceneEnvironment">
<el-input v-model="form.sceneEnvironment" placeholder="请输入预留字段,租户环境" />
</el-form-item>
<el-form-item label="预留字段" prop="sceneField">
<el-input v-model="form.sceneField" placeholder="请输入预留字段" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listScene, getScene, delScene, addScene, updateScene } from "@/api/business/scene";
export default {
name: "Scene",
data() {
return {
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
sceneList: [],
//
title: "",
//
open: false,
//
queryParams: {
pageNum: 1,
pageSize: 10,
sceneName: null,
tenantId: null,
sceneModeId: null,
scenePic: null,
defaultFlag: null,
sceneStatus: null,
authMode: null,
modeAccount: null,
modeKey: null,
modeSecret: null,
preserveTime: null,
testPreserveTime: null,
sceneEnvironment: null,
sceneField: null
},
//
form: {},
//
rules: {
sceneName: [
{ required: true, message: "场景名称不能为空", trigger: "blur" }
],
sceneModeId: [
{ required: true, message: "场景类型关联表hw_scene_mode的scene_mode_id不能为空", trigger: "blur" }
],
defaultFlag: [
{ required: true, message: "是否默认不能为空", trigger: "blur" }
],
sceneStatus: [
{ required: true, message: "状态不能为空", trigger: "change" }
],
authMode: [
{ required: true, message: "认证方式不能为空", trigger: "blur" }
],
modeKey: [
{ required: true, message: "场景key不能为空", trigger: "blur" }
],
modeSecret: [
{ required: true, message: "场景secret不能为空", trigger: "blur" }
],
preserveTime: [
{ required: true, message: "保存周期(单位默认90天不能为空", trigger: "blur" }
],
testPreserveTime: [
{ required: true, message: "测试环境保存周期(单位默认30天不能为空", trigger: "blur" }
],
}
};
},
created() {
this.getList();
},
methods: {
/** 查询场景信息列表 */
getList() {
this.loading = true;
listScene(this.queryParams).then(response => {
this.sceneList = response.rows;
this.total = response.total;
this.loading = false;
});
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
sceneId: null,
sceneName: null,
tenantId: null,
sceneModeId: null,
scenePic: null,
defaultFlag: null,
sceneStatus: null,
authMode: null,
modeAccount: null,
modeKey: null,
modeSecret: null,
preserveTime: null,
testPreserveTime: null,
remark: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null,
sceneEnvironment: null,
sceneField: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.sceneId)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加场景信息";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const sceneId = row.sceneId || this.ids
getScene(sceneId).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改场景信息";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.sceneId != null) {
updateScene(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addScene(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const sceneIds = row.sceneId || this.ids;
this.$modal.confirm('是否确认删除场景信息编号为"' + sceneIds + '"的数据项?').then(function() {
return delScene(sceneIds);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download('business/scene/export', {
...this.queryParams
}, `scene_${new Date().getTime()}.xlsx`)
}
}
};
</script>
Loading…
Cancel
Save