diff --git a/pom.xml b/pom.xml index 043343b..a5d18f9 100644 --- a/pom.xml +++ b/pom.xml @@ -199,6 +199,13 @@ ${ruoyi.version} + + + com.ruoyi + hw-common-i18n + ${ruoyi.version} + + com.ruoyi diff --git a/ruoyi-common/hw-common-i18n/.gitignore b/ruoyi-common/hw-common-i18n/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/ruoyi-common/hw-common-i18n/.gitignore @@ -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 \ No newline at end of file diff --git a/ruoyi-common/hw-common-i18n/pom.xml b/ruoyi-common/hw-common-i18n/pom.xml new file mode 100644 index 0000000..5537171 --- /dev/null +++ b/ruoyi-common/hw-common-i18n/pom.xml @@ -0,0 +1,56 @@ + + 4.0.0 + + com.ruoyi + ruoyi-common + 3.6.3 + + + hw-common-i18n + jar + + hw-common-i18n + http://maven.apache.org + + + UTF-8 + + + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-validation + + + + + com.ruoyi + ruoyi-common-core + + + + com.ruoyi + ruoyi-common-redis + + + + + junit + junit + 3.8.1 + test + + + org.springframework + spring-context + 5.3.28 + + + diff --git a/ruoyi-common/hw-common-i18n/src/main/java/com/ruoyi/i18n/config/I18nConfig.java b/ruoyi-common/hw-common-i18n/src/main/java/com/ruoyi/i18n/config/I18nConfig.java new file mode 100644 index 0000000..9c0b006 --- /dev/null +++ b/ruoyi-common/hw-common-i18n/src/main/java/com/ruoyi/i18n/config/I18nConfig.java @@ -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()); + } +} \ No newline at end of file diff --git a/ruoyi-common/hw-common-i18n/src/main/java/com/ruoyi/i18n/interceptor/MyLocaleChangeInterceptor.java b/ruoyi-common/hw-common-i18n/src/main/java/com/ruoyi/i18n/interceptor/MyLocaleChangeInterceptor.java new file mode 100644 index 0000000..00e3f7b --- /dev/null +++ b/ruoyi-common/hw-common-i18n/src/main/java/com/ruoyi/i18n/interceptor/MyLocaleChangeInterceptor.java @@ -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 + // 获取本地语言的优先级 cookieruoyi-common-security ruoyi-common-datascope ruoyi-common-datasource + hw-common-i18n ruoyi-common diff --git a/ruoyi-modules/hw-basic/pom.xml b/ruoyi-modules/hw-basic/pom.xml new file mode 100644 index 0000000..7ebc961 --- /dev/null +++ b/ruoyi-modules/hw-basic/pom.xml @@ -0,0 +1,111 @@ + + + + com.ruoyi + ruoyi-modules + 3.6.3 + + 4.0.0 + + ruoyi-modules-basic + + + 物联网平台基本模块 + + + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-sentinel + + + + + org.springframework.boot + spring-boot-starter-actuator + + + + + io.springfox + springfox-swagger-ui + ${swagger.fox.version} + + + + + com.mysql + mysql-connector-j + + + + + com.ruoyi + ruoyi-common-datasource + + + + + com.ruoyi + ruoyi-common-datascope + + + + + com.ruoyi + ruoyi-common-log + + + + + com.ruoyi + ruoyi-common-swagger + + + + + com.ruoyi + hw-common-i18n + + + org.springframework.boot + spring-boot-starter-web + + + + + + + ${project.artifactId} + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + + + \ No newline at end of file diff --git a/ruoyi-modules/hw-business/.gitignore b/ruoyi-modules/hw-business/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/ruoyi-modules/hw-business/.gitignore @@ -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 \ No newline at end of file diff --git a/ruoyi-modules/hw-business/pom.xml b/ruoyi-modules/hw-business/pom.xml new file mode 100644 index 0000000..7f65eaf --- /dev/null +++ b/ruoyi-modules/hw-business/pom.xml @@ -0,0 +1,111 @@ + + + + com.ruoyi + ruoyi-modules + 3.6.3 + + 4.0.0 + + rouyi-modules-business + + + 海威物联网平台业务模块 + + + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-sentinel + + + + + org.springframework.boot + spring-boot-starter-actuator + + + + + io.springfox + springfox-swagger-ui + ${swagger.fox.version} + + + + + com.mysql + mysql-connector-j + + + + + com.ruoyi + ruoyi-common-datasource + + + + + com.ruoyi + ruoyi-common-datascope + + + + + com.ruoyi + ruoyi-common-log + + + + + com.ruoyi + ruoyi-common-swagger + + + + + com.ruoyi + hw-common-i18n + + + org.springframework.boot + spring-boot-starter-web + + + + + + + ${project.artifactId} + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + + + \ No newline at end of file diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/Main.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/Main.java new file mode 100644 index 0000000..4922143 --- /dev/null +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/Main.java @@ -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); + } + } +} \ No newline at end of file diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/HwBusinessApplication.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/HwBusinessApplication.java new file mode 100644 index 0000000..06072cc --- /dev/null +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/HwBusinessApplication.java @@ -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" + + " ''-' `'-' `-..-' "); + } +} diff --git a/ruoyi-modules/hw-business/src/main/resources/banner.txt b/ruoyi-modules/hw-business/src/main/resources/banner.txt new file mode 100644 index 0000000..fbd45f5 --- /dev/null +++ b/ruoyi-modules/hw-business/src/main/resources/banner.txt @@ -0,0 +1,10 @@ +Spring Boot Version: ${spring-boot.version} +Spring Application Name: ${spring.application.name} + _ _ + (_) | | + _ __ _ _ ___ _ _ _ ______ ___ _ _ ___ | |_ ___ _ __ ___ +| '__|| | | | / _ \ | | | || ||______|/ __|| | | |/ __|| __| / _ \| '_ ` _ \ +| | | |_| || (_) || |_| || | \__ \| |_| |\__ \| |_ | __/| | | | | | +|_| \__,_| \___/ \__, ||_| |___/ \__, ||___/ \__| \___||_| |_| |_| + __/ | __/ | + |___/ |___/ \ No newline at end of file diff --git a/ruoyi-modules/hw-business/src/main/resources/bootstrap.yml b/ruoyi-modules/hw-business/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..ecdf076 --- /dev/null +++ b/ruoyi-modules/hw-business/src/main/resources/bootstrap.yml @@ -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} diff --git a/ruoyi-modules/hw-business/src/main/resources/logback.xml b/ruoyi-modules/hw-business/src/main/resources/logback.xml new file mode 100644 index 0000000..929cc3a --- /dev/null +++ b/ruoyi-modules/hw-business/src/main/resources/logback.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + ${log.pattern} + + + + + + ${log.path}/info.log + + + + ${log.path}/info.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + + INFO + + ACCEPT + + DENY + + + + + ${log.path}/error.log + + + + ${log.path}/error.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + + ERROR + + ACCEPT + + DENY + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwSceneMapper.xml b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwSceneMapper.xml new file mode 100644 index 0000000..bafc2ff --- /dev/null +++ b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwSceneMapper.xml @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + + + + + insert into hw_scene + + 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, + + + #{sceneName}, + #{tenantId}, + #{sceneModeId}, + #{scenePic}, + #{defaultFlag}, + #{sceneStatus}, + #{authMode}, + #{modeAccount}, + #{modeKey}, + #{modeSecret}, + #{preserveTime}, + #{testPreserveTime}, + #{remark}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{sceneEnvironment}, + #{sceneField}, + + + + + update hw_scene + + scene_name = #{sceneName}, + tenant_id = #{tenantId}, + scene_mode_id = #{sceneModeId}, + scene_pic = #{scenePic}, + default_flag = #{defaultFlag}, + scene_status = #{sceneStatus}, + auth_mode = #{authMode}, + mode_account = #{modeAccount}, + mode_key = #{modeKey}, + mode_secret = #{modeSecret}, + preserve_time = #{preserveTime}, + test_preserve_time = #{testPreserveTime}, + remark = #{remark}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + scene_environment = #{sceneEnvironment}, + scene_field = #{sceneField}, + + where scene_id = #{sceneId} + + + + delete from hw_scene where scene_id = #{sceneId} + + + + delete from hw_scene where scene_id in + + #{sceneId} + + + \ No newline at end of file diff --git a/ruoyi-modules/pom.xml b/ruoyi-modules/pom.xml index 72f2ef6..a5f5c70 100644 --- a/ruoyi-modules/pom.xml +++ b/ruoyi-modules/pom.xml @@ -6,6 +6,16 @@ ruoyi 3.6.3 + + + com.ruoyi + ruoyi-common-security + + + com.ruoyi + ruoyi-common-swagger + + 4.0.0 @@ -14,6 +24,8 @@ ruoyi-job ruoyi-file hw-mqtt-broker + hw-business + hw-basic ruoyi-modules diff --git a/ruoyi-modules/ruoyi-system/pom.xml b/ruoyi-modules/ruoyi-system/pom.xml index 320b770..2ed2245 100644 --- a/ruoyi-modules/ruoyi-system/pom.xml +++ b/ruoyi-modules/ruoyi-system/pom.xml @@ -78,6 +78,17 @@ ruoyi-common-swagger + + + com.ruoyi + hw-common-i18n + + + org.springframework.boot + spring-boot-starter-web + + + diff --git a/ruoyi-ui/src/api/business/scene.js b/ruoyi-ui/src/api/business/scene.js new file mode 100644 index 0000000..d10d4fc --- /dev/null +++ b/ruoyi-ui/src/api/business/scene.js @@ -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' + }) +} diff --git a/ruoyi-ui/src/views/business/scene/index.vue b/ruoyi-ui/src/views/business/scene/index.vue new file mode 100644 index 0000000..1e6db74 --- /dev/null +++ b/ruoyi-ui/src/views/business/scene/index.vue @@ -0,0 +1,452 @@ + + +