若依微服务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
parent
2eee79774a
commit
f09c665fe5
@ -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,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 @@
|
||||
com.ruoyi.i18n.config.I18nConfig
|
@ -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
|
||||
|
@ -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>
|
@ -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'
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue