增加im模块

master
xiaoning 1 month ago
parent 948a3fced5
commit a3ed7449cb

@ -8,10 +8,6 @@
<artifactId>ruoyi</artifactId> <artifactId>ruoyi</artifactId>
<version>3.8.3</version> <version>3.8.3</version>
<name>ruoyi</name>
<url>http://www.ruoyi.vip</url>
<description>若依管理系统</description>
<properties> <properties>
<ruoyi.version>3.8.3</ruoyi.version> <ruoyi.version>3.8.3</ruoyi.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@ -151,44 +147,40 @@
<version>${kaptcha.version}</version> <version>${kaptcha.version}</version>
</dependency> </dependency>
<!-- 定时任务--> <!-- 核心模块-->
<dependency> <dependency>
<groupId>com.ruoyi</groupId> <groupId>com.ruoyi</groupId>
<artifactId>ruoyi-quartz</artifactId> <artifactId>ruoyi-framework</artifactId>
<version>${ruoyi.version}</version> <version>${ruoyi.version}</version>
</dependency> </dependency>
<!-- 代码生成--> <!-- 系统模块-->
<dependency> <dependency>
<groupId>com.ruoyi</groupId> <groupId>com.ruoyi</groupId>
<artifactId>ruoyi-generator</artifactId> <artifactId>ruoyi-system</artifactId>
<version>${ruoyi.version}</version> <version>${ruoyi.version}</version>
</dependency> </dependency>
<!-- 核心模块--> <!-- 通用工具-->
<dependency> <dependency>
<groupId>com.ruoyi</groupId> <groupId>com.ruoyi</groupId>
<artifactId>ruoyi-framework</artifactId> <artifactId>ruoyi-common</artifactId>
<version>${ruoyi.version}</version> <version>${ruoyi.version}</version>
</dependency> </dependency>
<!-- 系统模块-->
<dependency> <dependency>
<groupId>com.ruoyi</groupId> <groupId>com.ruoyi</groupId>
<artifactId>ruoyi-system</artifactId> <artifactId>ruoyi-app-domain</artifactId>
<version>${ruoyi.version}</version> <version>${ruoyi.version}</version>
</dependency> </dependency>
<!-- 通用工具-->
<dependency> <dependency>
<groupId>com.ruoyi</groupId> <groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common</artifactId> <artifactId>ruoyi-im-client</artifactId>
<version>${ruoyi.version}</version> <version>${ruoyi.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.ruoyi</groupId> <groupId>com.ruoyi</groupId>
<artifactId>ruoyi-app-domain</artifactId> <artifactId>ruoyi-im-server</artifactId>
<version>${ruoyi.version}</version> <version>${ruoyi.version}</version>
</dependency> </dependency>
@ -199,9 +191,10 @@
<module>ruoyi-admin</module> <module>ruoyi-admin</module>
<module>ruoyi-framework</module> <module>ruoyi-framework</module>
<module>ruoyi-system</module> <module>ruoyi-system</module>
<module>ruoyi-quartz</module>
<module>ruoyi-generator</module>
<module>ruoyi-common</module> <module>ruoyi-common</module>
<module>ruoyi-im-client</module>
<module>ruoyi-im-server</module>
</modules> </modules>
<packaging>pom</packaging> <packaging>pom</packaging>

@ -18,19 +18,11 @@
<dependencies> <dependencies>
<!-- spring-boot-devtools --> <!-- spring-boot-devtools -->
<dependency> <!-- <dependency>-->
<groupId>org.springframework.boot</groupId> <!-- <groupId>org.springframework.boot</groupId>-->
<artifactId>spring-boot-devtools</artifactId> <!-- <artifactId>spring-boot-devtools</artifactId>-->
<optional>true</optional> <!-- 表示依赖不会传递 --> <!-- <optional>true</optional> &lt;!&ndash; 表示依赖不会传递 &ndash;&gt;-->
</dependency> <!-- </dependency>-->
<!-- Mysql驱动包 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!-- 核心模块--> <!-- 核心模块-->
<dependency> <dependency>
@ -38,16 +30,7 @@
<artifactId>ruoyi-framework</artifactId> <artifactId>ruoyi-framework</artifactId>
</dependency> </dependency>
<!-- 定时任务-->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-quartz</artifactId>
</dependency>
<!-- 代码生成-->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-generator</artifactId>
</dependency>
<!--极光推送--> <!--极光推送-->
<!-- <dependency>--> <!-- <dependency>-->
<!-- <groupId>cn.jpush.api</groupId>--> <!-- <groupId>cn.jpush.api</groupId>-->
@ -59,23 +42,13 @@
<!-- <artifactId>jpush-client</artifactId>--> <!-- <artifactId>jpush-client</artifactId>-->
<!-- <version>3.4.3</version>--> <!-- <version>3.4.3</version>-->
<!-- </dependency>--> <!-- </dependency>-->
<!-- //微信支付-->
<dependency>
<groupId>com.github.wechatpay-apiv3</groupId>
<artifactId>wechatpay-apache-httpclient</artifactId>
<version>0.4.8</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId> <!-- <dependency>-->
<artifactId>okhttp-android-support</artifactId> <!-- <groupId>com.squareup.okhttp3</groupId>-->
<version>3.13.1</version> <!-- <artifactId>okhttp-android-support</artifactId>-->
</dependency> <!-- <version>3.13.1</version>-->
<!-- </dependency>-->
</dependencies> </dependencies>

@ -0,0 +1,219 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="web" name="Web">
<configuration>
<webroots />
<sourceRoots />
</configuration>
</facet>
<facet type="Spring" name="Spring">
<configuration />
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="ruoyi-framework" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:2.5.14" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:2.5.14" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:2.5.14" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-logging:2.5.14" level="project" />
<orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.2.11" level="project" />
<orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.2.11" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-to-slf4j:2.17.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.17.2" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.7.36" level="project" />
<orderEntry type="library" name="Maven: jakarta.annotation:jakarta.annotation-api:1.3.5" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-core:5.3.20" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-jcl:5.3.20" level="project" />
<orderEntry type="library" name="Maven: org.yaml:snakeyaml:1.28" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-json:2.5.14" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.12.6.1" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.12.6" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.12.6" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.module:jackson-module-parameter-names:2.12.6" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-tomcat:2.5.14" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-core:9.0.63" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-el:9.0.63" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-websocket:9.0.63" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-web:5.3.20" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-beans:5.3.20" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-webmvc:5.3.20" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-context:5.3.20" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-expression:5.3.20" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-aop:2.5.14" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-aop:5.3.20" level="project" />
<orderEntry type="library" name="Maven: org.aspectj:aspectjweaver:1.9.7" level="project" />
<orderEntry type="library" name="Maven: com.alibaba:druid-spring-boot-starter:1.2.11" level="project" />
<orderEntry type="library" name="Maven: com.alibaba:druid:1.2.11" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.36" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-autoconfigure:2.5.14" level="project" />
<orderEntry type="library" name="Maven: com.github.penggle:kaptcha:2.3.2" level="project" />
<orderEntry type="library" name="Maven: com.jhlabs:filters:2.0.235-1" level="project" />
<orderEntry type="library" name="Maven: com.github.oshi:oshi-core:6.2.2" level="project" />
<orderEntry type="library" name="Maven: net.java.dev.jna:jna:5.12.1" level="project" />
<orderEntry type="library" name="Maven: net.java.dev.jna:jna-platform:5.12.1" level="project" />
<orderEntry type="module" module-name="ruoyi-system" />
<orderEntry type="module" module-name="ruoyi-common" />
<orderEntry type="library" name="Maven: org.springframework:spring-context-support:5.3.20" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-security:2.5.14" level="project" />
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-config:5.5.8" level="project" />
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-core:5.5.8" level="project" />
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-crypto:5.5.8" level="project" />
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-web:5.5.8" level="project" />
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper-spring-boot-starter:1.4.3" level="project" />
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-starter:2.2.2" level="project" />
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-autoconfigure:2.2.2" level="project" />
<orderEntry type="library" name="Maven: org.mybatis:mybatis:3.5.9" level="project" />
<orderEntry type="library" name="Maven: org.mybatis:mybatis-spring:2.0.7" level="project" />
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper-spring-boot-autoconfigure:1.4.3" level="project" />
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper:5.3.1" level="project" />
<orderEntry type="library" name="Maven: com.github.jsqlparser:jsqlparser:4.2" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-validation:2.5.14" level="project" />
<orderEntry type="library" name="Maven: org.hibernate.validator:hibernate-validator:6.2.3.Final" level="project" />
<orderEntry type="library" name="Maven: jakarta.validation:jakarta.validation-api:2.0.2" level="project" />
<orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.4.3.Final" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.12.0" level="project" />
<orderEntry type="library" name="Maven: com.alibaba.fastjson2:fastjson2:2.0.12" level="project" />
<orderEntry type="library" name="Maven: commons-io:commons-io:2.11.0" level="project" />
<orderEntry type="library" name="Maven: commons-fileupload:commons-fileupload:1.4" level="project" />
<orderEntry type="library" name="Maven: org.apache.poi:poi-ooxml:4.1.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.poi:poi:4.1.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-collections4:4.4" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-math3:3.6.1" level="project" />
<orderEntry type="library" name="Maven: com.zaxxer:SparseBitSet:1.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.poi:poi-ooxml-schemas:4.1.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.xmlbeans:xmlbeans:3.1.0" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-compress:1.19" level="project" />
<orderEntry type="library" name="Maven: com.github.virtuald:curvesapi:1.06" level="project" />
<orderEntry type="library" name="Maven: io.jsonwebtoken:jjwt:0.9.1" level="project" />
<orderEntry type="library" name="Maven: javax.xml.bind:jaxb-api:2.3.1" level="project" />
<orderEntry type="library" name="Maven: javax.activation:javax.activation-api:1.2.0" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-data-redis:2.5.14" level="project" />
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-redis:2.5.11" level="project" />
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-keyvalue:2.5.11" level="project" />
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-commons:2.5.11" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-tx:5.3.20" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-oxm:5.3.20" level="project" />
<orderEntry type="library" name="Maven: io.lettuce:lettuce-core:6.1.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-common:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-handler:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-transport:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.projectreactor:reactor-core:3.4.18" level="project" />
<orderEntry type="library" name="Maven: org.reactivestreams:reactive-streams:1.0.3" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-pool2:2.9.0" level="project" />
<orderEntry type="library" name="Maven: eu.bitwalker:UserAgentUtils:1.21" level="project" />
<orderEntry type="library" name="Maven: javax.servlet:javax.servlet-api:4.0.1" level="project" />
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-boot-starter:3.4.3.4" level="project" />
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus:3.4.3.4" level="project" />
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-extension:3.4.3.4" level="project" />
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-core:3.4.3.4" level="project" />
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-annotation:3.4.3.4" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-jdbc:2.5.14" level="project" />
<orderEntry type="library" name="Maven: com.zaxxer:HikariCP:4.0.3" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-jdbc:5.3.20" level="project" />
<orderEntry type="library" name="Maven: cn.hutool:hutool-all:5.7.1" level="project" />
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.18.24" level="project" />
<orderEntry type="library" name="Maven: cn.jpush.api:jiguang-common:1.1.7" level="project" />
<orderEntry type="library" name="Maven: org.bouncycastle:bcprov-jdk15on:1.60" level="project" />
<orderEntry type="library" name="Maven: org.bouncycastle:bcpkix-jdk15on:1.60" level="project" />
<orderEntry type="library" name="Maven: cn.jpush.api:jpush-client:3.4.3" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-all:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-buffer:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-codec:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-codec-dns:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-codec-haproxy:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-codec-http:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-codec-http2:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-codec-memcache:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-codec-mqtt:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-codec-redis:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-codec-smtp:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-codec-socks:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-codec-stomp:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-codec-xml:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-handler-proxy:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-resolver:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-resolver-dns:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-transport-rxtx:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-transport-sctp:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-transport-udt:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-transport-classes-epoll:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-transport-native-unix-common:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-transport-classes-kqueue:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-resolver-dns-classes-macos:4.1.77.Final" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-transport-native-epoll:linux-x86_64:4.1.77.Final" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-transport-native-epoll:linux-aarch_64:4.1.77.Final" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-transport-native-kqueue:osx-x86_64:4.1.77.Final" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-transport-native-kqueue:osx-aarch_64:4.1.77.Final" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-resolver-dns-native-macos:osx-x86_64:4.1.77.Final" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-resolver-dns-native-macos:osx-aarch_64:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-boot-starter:3.0.0" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-oas:3.0.0" level="project" />
<orderEntry type="library" name="Maven: io.swagger.core.v3:swagger-annotations:2.1.2" level="project" />
<orderEntry type="library" name="Maven: io.swagger.core.v3:swagger-models:2.1.2" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-spi:3.0.0" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-schema:3.0.0" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-core:3.0.0" level="project" />
<orderEntry type="library" name="Maven: net.bytebuddy:byte-buddy:1.10.22" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-spring-web:3.0.0" level="project" />
<orderEntry type="library" name="Maven: io.github.classgraph:classgraph:4.8.83" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-spring-webmvc:3.0.0" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-spring-webflux:3.0.0" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger-common:3.0.0" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.mapstruct:mapstruct:1.3.1.Final" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-data-rest:3.0.0" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-bean-validators:3.0.0" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger2:3.0.0" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger-ui:3.0.0" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml:classmate:1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-core:2.0.0.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-metadata:2.0.0.RELEASE" level="project" />
<orderEntry type="library" name="Maven: io.swagger:swagger-models:1.6.2" level="project" />
<orderEntry type="library" name="Maven: io.swagger:swagger-annotations:1.6.2" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-joda:2.12.6" level="project" />
<orderEntry type="library" name="Maven: joda-time:joda-time:2.10.8" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-websocket:2.5.14" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-messaging:5.3.20" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-websocket:5.3.20" level="project" />
<orderEntry type="library" name="Maven: com.auth0:java-jwt:3.11.0" level="project" />
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.15" level="project" />
<orderEntry type="library" name="Maven: mysql:mysql-connector-java:8.0.29" level="project" />
<orderEntry type="module" module-name="ruoyi-im-client" />
<orderEntry type="library" name="Maven: com.squareup.okhttp3:okhttp:3.14.9" level="project" />
<orderEntry type="library" name="Maven: com.squareup.okio:okio:1.17.2" level="project" />
<orderEntry type="library" name="Maven: io.minio:minio:8.2.1" level="project" />
<orderEntry type="library" name="Maven: com.carrotsearch.thirdparty:simple-xml-safe:2.7.1" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:guava:29.0-jre" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:failureaccess:1.0.1" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava" level="project" />
<orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:3.0.2" level="project" />
<orderEntry type="library" name="Maven: org.checkerframework:checker-qual:2.11.1" level="project" />
<orderEntry type="library" name="Maven: com.google.errorprone:error_prone_annotations:2.3.4" level="project" />
<orderEntry type="library" name="Maven: com.google.j2objc:j2objc-annotations:1.3" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.12.6" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.12.6" level="project" />
<orderEntry type="library" name="Maven: net.coobird:thumbnailator:0.4.8" level="project" />
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.9" level="project" />
<orderEntry type="library" name="Maven: com.github.wechatpay-apiv3:wechatpay-java:0.2.9" level="project" />
<orderEntry type="library" name="Maven: com.github.wechatpay-apiv3:wechatpay-java-core:0.2.9" level="project" />
<orderEntry type="library" name="Maven: com.github.wechatpay-apiv3:wechatpay-apache-httpclient:0.4.8" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.13" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.15" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.apache.httpcomponents:httpmime:4.5.13" level="project" />
<orderEntry type="library" name="Maven: junit:junit:4.13.2" level="project" />
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:2.2" level="project" />
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest:2.2" level="project" />
</component>
</module>

@ -3,12 +3,14 @@ package com.ruoyi;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
/** /**
* *
* *
* @author ruoyi * @author ruoyi
*/ */
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class }) @SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
public class RuoYiApplication public class RuoYiApplication
{ {

@ -1,125 +0,0 @@
package com.ruoyi.web.controller.app_course;
import cn.hutool.core.date.DateUtil;
import com.ruoyi.RestResponse;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.course.domain.Appointment;
import com.ruoyi.course.domain.AppointmentVo;
import com.ruoyi.course.mapper.AppointmentMapper;
import com.ruoyi.course.service.AppointmentServiceImpl;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* <p>
*
* </p>
*
* @author xhj
* @since 2022-09-22
*/
@Api(tags = "课程", description = "提供课程相关的API")
@RestController
@RequestMapping("/api/appointment")
public class AppointmentAppController extends BaseController {
@Autowired
AppointmentServiceImpl appointmentService;
@Autowired
AppointmentMapper mapper;
// @PostMapping("/getAppointmentList")
public RestResponse getAppointmentList(@RequestBody Map map) {
// List<Course> list = appointmentService.getList(map);
// return new RestResponse().setData(list);
return RestResponse.success().setData(appointmentService.findList(map));
}
// @PostMapping("/updateAppointment")
public RestResponse updateAppointment(@RequestBody Appointment appointment) {
String username = SecurityUtils.getUsername();
appointment.setUpdateUser(username);
// LocalDateTime now= ;
appointment.setUpdateTime(DateUtil.parseLocalDateTime(DateUtil.now(),"yyyy-MM-dd HH:mm:ss"));
appointmentService.updateById(appointment);
return RestResponse.success();
}
/**
*
* @param appointment
* @return
*/
// @PostMapping("/yy")
public RestResponse yy(@RequestBody Appointment appointment) {
appointment.setCreateTime(DateUtil.parseLocalDateTime(DateUtil.now(),"yyyy-MM-dd HH:mm:ss"));
appointmentService.save(appointment);
return RestResponse.success();
}
//我的预约
//预约成功
//预约失败
@PostMapping("/appointments")
public RestResponse appointments(HttpServletRequest request) {
Long userId= Long.parseLong(request.getAttribute("userId").toString());
Map map=new HashMap();
map.put("consumerId",userId);
List<AppointmentVo> list=appointmentService.findList(map);
List<AppointmentVo> list1=new ArrayList<>();//预约中
List<AppointmentVo> list2=new ArrayList<>();//预约成功
List<AppointmentVo> list3=new ArrayList<>();//预约失败
List<AppointmentVo> list4=new ArrayList<>();//取消预约
for (AppointmentVo a:list){
if (a.getFlag()==0){
list1.add(a);
continue;
}
if (a.getFlag()==1){
list2.add(a);
continue;
}
if (a.getFlag()==2){
list3.add(a);
continue;
}
if (a.getFlag()==3){
list4.add(a);
}
}
map.clear();
map.put("list1",list1);
map.put("list2",list2);
map.put("list3",list3);
map.put("list4",list4);
return RestResponse.success().setData(map);
}
//取消预约
@PostMapping("/cancel")
public RestResponse cancel(@RequestBody Appointment appointment) {
appointment.setUpdateTime(DateUtil.parseLocalDateTime(DateUtil.now(),"yyyy-MM-dd HH:mm:ss"));
int i= mapper.cancel(appointment);
return RestResponse.success().setMessage(i==0?"修改失败,当前状态无法取消预约!":"成功!");
}
}

@ -1,62 +0,0 @@
package com.ruoyi.web.controller.app_course;
import com.ruoyi.RestResponse;
import com.ruoyi.course.domain.CourseLog;
import com.ruoyi.course.mapper.ConsumerCourseMapper;
import com.ruoyi.course.service.ConsumerCourseServiceImpl;
import com.ruoyi.course.service.CourseServiceImpl;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* <p>
*
* </p>
*
* @author xn
* @since 2022-12-29
*/
@RestController
@RequestMapping("/api/consumerCourse")
public class ConsumerCourseController {
@Resource
private CourseServiceImpl courseService;
@Resource
private ConsumerCourseServiceImpl consumerCourseService;
@Resource
private ConsumerCourseMapper mapper;
//我的课程 (视频)
@PostMapping("/myCourse")
public RestResponse myCourse(HttpServletRequest request){
Long userId= Long.parseLong(request.getAttribute("userId").toString());
List<CourseLog> list= mapper.myCourse(userId);
List<CourseLog> list1=new ArrayList<>();
List<CourseLog> list2=new ArrayList<>();
for (CourseLog l:list){
if (l.getCourseType().equals("2")){
list1.add(l);
}
if (l.getCourseType().equals("3")){
list2.add(l);
}
}
Map map=new HashMap();
map.put("list1",list1);//大咖课
map.put("list2",list2);//教练培训
return new RestResponse().setSuccess(true).setData(map);
}
}

@ -1,406 +0,0 @@
package com.ruoyi.web.controller.app_course;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.RestResponse;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.entity.SysDictData;
import com.ruoyi.common.utils.JpushClientUtil;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.course.domain.*;
import com.ruoyi.course.service.ConsumerCourseServiceImpl;
import com.ruoyi.course.service.CourseLogServiceImpl;
import com.ruoyi.course.service.CourseServiceImpl;
import com.ruoyi.course.service.HistoryMessageServiceImpl;
import com.ruoyi.search.domain.MemberUser;
import com.ruoyi.search.service.MemberUserServicelmpl;
import com.ruoyi.shop.domain.ShopOrder;
import com.ruoyi.shop.domain.ShopOrderItem;
import com.ruoyi.shop.service.impl.ShopOrderItemServiceImpl;
import com.ruoyi.shop.service.impl.ShopOrderServiceImpl;
import com.ruoyi.system.domain.SysUserRole;
import com.ruoyi.system.mapper.SysUserRoleMapper;
import com.ruoyi.system.service.ISysDictDataService;
import com.ruoyi.web.util.PayUtil;
import com.ruoyi.web.util.SnowFlake;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* <p>
*
* </p>
*
* @author xhj
* @since 2022-09-22
*/
@RestController
@RequestMapping("/api/course")
public class CourseAppController extends BaseController {
@Autowired
CourseServiceImpl courseService;
@Autowired
HistoryMessageServiceImpl historyMessageService;
@Autowired
CourseLogServiceImpl courseLogService;
@Autowired
ISysDictDataService iSysDictDataService;
@Autowired
MemberUserServicelmpl memberUserService;
@Resource
private ShopOrderServiceImpl orderService;
@Resource
private ShopOrderItemServiceImpl itemService;
@Resource
private ConsumerCourseServiceImpl consumerCourseService;
@Resource
private SysUserRoleMapper sysUserRoleMapper;
/**
*
* courseName
* courseType //1 传入1
* memberType[]
* @param map
* @return courseType1
*/
@PostMapping("/list")
public RestResponse list(@RequestBody Map map) {
map.put("releases",1);
List<Course> list = courseService.getList(map);
return new RestResponse().setData(list);
}
/**
*
* @param map
* @return
*/
@PostMapping("/listByCourseType1")
public RestResponse listByCourseType1(@RequestBody Map map) {
SysDictData sysDictData= new SysDictData();
sysDictData.setDictType("yj_source_pt_type");
sysDictData.setMerchantId(SecurityUtils.getMerchanId());
return RestResponse.success().setData(iSysDictDataService.selectDictDataList(sysDictData));
}
/**
*
* @param appointment
* @return
*/
// @PostMapping("/yyCourse")
public RestResponse yyCourse(@RequestBody Appointment appointment) {
courseService.yyCourse(appointment);
return RestResponse.success();
}
/**
* courseId id id
* @param map
* @return userName course_names memberType course_picture
* memberType 1 courseType1 = /11 courseType
*/
@PostMapping("/listLog")
public RestResponse listLog(@RequestBody Map map) {
//todo
List<CourseLogVo> list = courseService.getListLog(map);
return new RestResponse().setData(list);
}
/**
*
*
* @param map date courseId id
* @return
* 2022.11.30xn
*/
@PostMapping("/listLogDate")
public RestResponse listLogDate(@RequestBody Map map) {
// Map map1 = courseService.listLogDate(map);
map.put("userId",null);
Map map1 = courseService.listLogDate1(map);
return new RestResponse().setData(map1);
}
@PostMapping("/listLogDateForMember")
public RestResponse listLogDateForMember(@RequestBody Map map,HttpServletRequest request) {
Long userId= Long.parseLong(request.getAttribute("userId").toString());
// Map map1 = courseService.listLogDate(map);
map.put("userId",userId);
Map map1 = courseService.listLogDate1(map);
return new RestResponse().setData(map1);
}
@PostMapping("/getTeacherList")
public RestResponse getTeacherList(@RequestBody Map map) {
// sysUserService.selectUserList()
List<SysUserRole> sysUserRoles = sysUserRoleMapper.selectALLByRole(map.get("merchantId").toString());
if(sysUserRoles.size()==0){
return RestResponse.failure("没有教练信息");
}
return RestResponse.success().setData(sysUserRoles);
}
/**
*
* app-/
* @param course
* @return
* @author xn
*/
// @PostMapping("/listForService")
public RestResponse listForService(@RequestBody Course course) {
course.setReleases(1);
List<Course> list = courseService.listForApp(course);
return new RestResponse().success().setData(list);
}
/**
*
* app-
* @param course
* @return
* @author xn
*/
// @PostMapping("/getOne")
public RestResponse getOne(@RequestBody Course course) {
Course c = courseService.listForApp(course).get(0);
return new RestResponse().success().setData(c);
}
/**
* ()
* @param courseLogVo
* @return
*/
@PostMapping("/getDetail")
public RestResponse getDetail(@RequestBody CourseLogVo courseLogVo) {
CourseLog courseLog =courseLogService.getById(courseLogVo.getId());
Course course =courseService.getById(courseLog.getCourseId());
courseLog.generateMemberNum();
Map map=new HashMap();
map.put("course",course);
courseLog.setVideoLong("1");
map.put("courseLog",courseLog);
return new RestResponse().success().setData(map);
}
/**
*
* @param courseLogVo
* @param request
* @return
*/
@PostMapping("/watchLongVideo")
public RestResponse watchLongVideo(@RequestBody CourseLogVo courseLogVo, HttpServletRequest request) {
Long userId= Long.parseLong(request.getAttribute("userId").toString());
CourseLog courseLog =courseLogService.getById(courseLogVo.getId());
Course course =courseService.getById(courseLog.getCourseId());
Map map=new HashMap();
map.put("course",course);
map.put("courseLog",courseLog);
//判断是否购买过
Long l= consumerCourseService.count(new QueryWrapper<ConsumerCourse>()
.eq("consumer_id",userId)
.eq("course_log_id",courseLogVo.getId()));
if (l<1l){
courseLog.setVideoLong("1"); //页面
return new RestResponse().success().setData(map);
}
return new RestResponse().success().setData(map);
}
/**
* 1
* @param appointment
* @return
*/
@PostMapping("/yyCourse1")
@Transactional(rollbackFor = RuntimeException.class)
public RestResponse yyCourse1(@RequestBody Appointment appointment, HttpServletRequest request) {
Long userId= Long.parseLong(request.getAttribute("userId").toString());
//查看校验课程是否符合预约条件
CourseLog log=courseLogService.getById(appointment.getCourseLogId());
if ( DateUtil.parse(log.getStartDate()+" "+log.getStartTime(),"yyyy-MM-dd HH:mm").before(DateUtil.date())){
return new RestResponse().setSuccess(false).setMessage("该课程已过期,请选择其他课程!");
}
if (log.getNumber()==log.getAppointmentNum()){
return new RestResponse().setSuccess(false).setMessage("该课程预约已满,请选择其他课程!");
}
log.generateMemberNum();
if (ObjectUtil.isNotEmpty(log.getMemberNum())){
//判断是否为会员
List<MemberUser> memberUsers=memberUserService.list(new QueryWrapper<MemberUser>().eq("consumer_id",userId));
if (ObjectUtil.isEmpty(memberUsers)){
return new RestResponse().setSuccess(false).setMessage("该课程为会员课,请加入相应会籍后预约!");
}
int flag=0;
for (Object memberId:log.getMemberNum()){
int id=Integer.parseInt(memberId.toString());
for (MemberUser user:memberUsers){
//判断会员会籍与课程会籍是否相符
if (user.getMemberId()==id){
//如果上课日期在会员有效期之内
if (DateUtil.parse(log.getStartDate(),"yyyy-MM-dd").before(
DateUtil.parse(user.getValidityTime(),"yyyy-MM-dd"))){
flag=1;
}
}
}
}
if (flag==0){
return new RestResponse().setSuccess(false).setMessage("该课程为会员课,您的会籍类型与课程不符,请加入相应会籍后预约!");
}
}
appointment.setPhone(request.getAttribute("phone").toString());
courseService.yyCourse1(appointment);
//给教练发送消息,提醒确认
Context context=courseService.getTeacherPhone(appointment.getCourseLogId());
String notification_title=context.getUserName()+"教练,您有一条课程预约";
String msg_content="学员:"+request.getAttribute("phone").toString()+"预约您的课程,请登录后台处理!";
try {
JpushClientUtil.sendMessage(context.getPhonenumber(),notification_title,msg_content);
} catch (Exception e) {
e.printStackTrace();
}
//消息记录
HistoryMessage message=new HistoryMessage();
message.setPhone(context.getPhonenumber());
message.setNotificationTitle(notification_title);
message.setMsgContent(msg_content);
message.setSendTime(DateUtil.now());
historyMessageService.save(message);
return RestResponse.success();
}
/**
*
* @param courseLogVo
* @param request
* @return
* @throws Exception
*/
@PostMapping("/createOrderForCourse")
@Transactional(rollbackFor = RuntimeException.class)
public RestResponse createOrderForCourse(@RequestBody CourseLogVo courseLogVo, HttpServletRequest request) throws Exception{
Long userId= Long.parseLong(request.getAttribute("userId").toString());
//判断是否购买过
long count= consumerCourseService.count(new QueryWrapper<ConsumerCourse>()
.eq("consumer_id",userId)
.eq("course_log_id",courseLogVo.getId()));
if (count>0l){
return new RestResponse().setSuccess(false).setMessage("课程已购买过,请到 我的->我的课程 中查看!");
}
//生成订单(支付中)
ShopOrder order=new ShopOrder();
order.setOrderSn(SnowFlake.getOrder()+"");//订单号
order.setBusinessId(courseLogVo.getStroreId());//商户
order.setIdUser(userId);//客户id
order.setMobile(request.getAttribute("phone").toString());//收件人电话(客户电话)
order.setCreateTime(DateUtil.parseLocalDateTime(DateUtil.now(),"yyyy-MM-dd HH:mm:ss"));
order.setOrderType(3);//订单类型1.商品 2.会籍 3.课程
order.setPayType("微信支付");
order.setTradeAmount(courseLogVo.getCoursePrice());//TradeAmount交易金额 MemberPrice价格
orderService.save(order);
//生成订单详情
ShopOrderItem item=new ShopOrderItem();
item.setIdOrder(order.getId());//订单id
item.setIdSouseLog(courseLogVo.getId());//开课记录id
item.setTotalPrice(courseLogVo.getCoursePrice());//总价
item.setThumbnail(courseLogVo.getCoursePicture());//缩略图
item.setType("3");//1 商品 2 会籍 3 课程
item.setCourseContext(courseLogVo.getCourseContext());//课程内容
item.setCourseType(courseLogVo.getCourseType());//2大咖课 3教练培训
item.setCourseNames(courseLogVo.getCourseNames());
itemService.save(item);
//单位: 元 转换成 分
BigDecimal total=courseLogVo.getCoursePrice().multiply(new BigDecimal(100));
Map map=new HashMap();
//0元
if (total.equals(BigDecimal.ZERO)){
//支付成功 给用户添加课程 TODO
map.put("timeStamp","1");
return new RestResponse().setSuccess(true).setMessage("成功").setData(map);
}
map= PayUtil.creatOrder(total.setScale(1, RoundingMode.HALF_UP).intValue(),order.getOrderSn());
return new RestResponse().setSuccess(true).setMessage("成功").setData(map);
}
//视频以流的方式播放
// @RequestMapping(value = "/longView", method = {RequestMethod.GET})
@GetMapping("/longView")
public void imageView1(HttpServletRequest request, HttpServletResponse httpServletResponse){
String fileName="/profile/upload/2022/11/10/WeChat_20221110133401_20221110133433A027.mp4";
byte[] bytes = file2byte("../ruoyi/uploadPath"+fileName.substring(8));
httpServletResponse.setContentType("application/octet-stream");
httpServletResponse.setContentLength(bytes.length);
try {
httpServletResponse.getOutputStream().write(bytes);
} catch (IOException e) {
System.out.println("IO异常----");
}
}
public byte[] file2byte(String filePath) {
byte[] buffer = null;
try {
File file = new File(filePath);
FileInputStream fis = new FileInputStream(file);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
byte[] b = new byte[1024];
int n;
while ((n = fis.read(b)) != -1) {
bos.write(b, 0, n);
}
fis.close();
bos.close();
buffer = bos.toByteArray();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return buffer;
}
}

@ -1,54 +0,0 @@
package com.ruoyi.web.controller.app_course;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.RestResponse;
import com.ruoyi.course.domain.HistoryMessage;
import com.ruoyi.course.service.HistoryMessageServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
*
*/
@Api(tags = "我的消息", description = "提供我的消息相关的API")
@RestController
@RequestMapping("/api/historyMessage")
public class HistoryMessageController {
@Autowired
HistoryMessageServiceImpl historyMessageService;
@ApiOperation("我的消息列表")
@PostMapping("/getMessages")
public RestResponse getMessages(HttpServletRequest request){
List<HistoryMessage> list= historyMessageService.list(new QueryWrapper<HistoryMessage>()
.eq("phone",request.getAttribute("phone").toString())
.eq("releases",true));
return new RestResponse().setSuccess(true).setData(list);
}
@ApiOperation("消息详情")
@PostMapping("/getOne")
public RestResponse getOne(@RequestBody HistoryMessage message){
HistoryMessage historyMessage= historyMessageService.getById(message.getId());
return new RestResponse().setSuccess(true).setData(historyMessage);
}
@ApiOperation("删除消息")
@PostMapping("/remove")
public RestResponse remove(@RequestBody HistoryMessage message){
message.setReleases(false);
historyMessageService.updateById(message);
return new RestResponse().setSuccess(true);
}
}

@ -1,186 +0,0 @@
package com.ruoyi.web.controller.app_course;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.RestResponse;
import com.ruoyi.course.domain.Member;
import com.ruoyi.course.service.ConsumerCourseServiceImpl;
import com.ruoyi.course.service.MemberServiceImpl;
import com.ruoyi.search.domain.MemberUser;
import com.ruoyi.search.service.MemberUserServicelmpl;
import com.ruoyi.shop.domain.ShopOrder;
import com.ruoyi.shop.domain.ShopOrderItem;
import com.ruoyi.shop.service.impl.ShopOrderItemServiceImpl;
import com.ruoyi.shop.service.impl.ShopOrderServiceImpl;
import com.ruoyi.web.util.PayUtil;
import com.ruoyi.web.util.SnowFlake;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* <p>
*
* </p>
*
* @author xhj
* @since 2022-09-23
*/
@Api(tags = "会籍", description = "提供会籍相关的API")
@RestController
@RequestMapping("/api/member")
public class
MemberAppController {
@Autowired
private MemberServiceImpl memberService;
@Autowired
private MemberUserServicelmpl memberUserServicel;
@Resource
private ShopOrderServiceImpl orderService;
@Resource
private ShopOrderItemServiceImpl itemService;
@Resource
private ConsumerCourseServiceImpl consumerCourseService;
/**
* app-
* @param member
* @return
* @author xn
*/
// @ApiOperation("获取本店会籍列表")
@PostMapping("/getMembers")
public RestResponse getMembers(@RequestBody Member member) {
List<Member> list = memberService.list(new QueryWrapper<Member>()
.eq("strore_id",member.getStroreId())
.eq("releases",1)
);
return new RestResponse().setData(list);
}
/**
* app-
* @param member
* @return
* @author xn
*/
// @ApiOperation("会籍详情")
@PostMapping("/getOne")
public RestResponse getOne(@RequestBody Member member) {
Member m = memberService.getById(member.getMemberId());
return new RestResponse().setData(m);
}
/**
*
* @param member
* @return
*/
// @ApiOperation("会籍数据字典")
@PostMapping(value = "/getList")
public RestResponse findList1(@RequestBody Member member) {
List<Member> list =memberService.findList(member);
return new RestResponse().setSuccess(true).setMessage("成功").setData(list);
}
/**
*
* @param memberUser
* @param request
* @return
*/
// @ApiOperation("购买会籍")
@PostMapping("/createOrderForMember")
@Transactional(rollbackFor = RuntimeException.class)
public RestResponse createOrderForMember(@RequestBody MemberUser memberUser, HttpServletRequest request) throws Exception{
Long userId= Long.parseLong(request.getAttribute("userId").toString());
//判断是否已经在籍
LocalDateTime dateTime= DateUtil.parseLocalDateTime(DateUtil.format(DateUtil.tomorrow(),"yyyy-MM-dd 00:00:00"));
List<MemberUser> list=memberUserServicel.list(new QueryWrapper<MemberUser>()//DateUtil.now()
.eq("member_id",memberUser.getMemberId())
.eq("consumer_id",userId)
.last(" and (validity_time > now() or come_time ='"+dateTime+"')"));//截止日期为今天之后(未到期) 或 开始日期在明天(今天办的)
if (list.size()>0){
if (list.get(0).getComeTime().equals(dateTime)){
return new RestResponse().setSuccess(false).setMessage("您已成功办理会籍,生效时间为"+DateUtil.tomorrow().toString("yyyy-MM-dd 00:00:00")+"!请勿重复办理!");
}else {
return new RestResponse().setSuccess(false).setMessage("会籍存续中,请勿重复办理!");
}
}
//价格/月 * 有效期(月)
BigDecimal price= memberUser.getMemberPrice().multiply(new BigDecimal(memberUser.getValidity()));
//生成订单(支付中)
ShopOrder order=new ShopOrder();
order.setOrderSn(SnowFlake.getOrder()+"");//订单号
order.setBusinessId(memberUser.getStroreId());//商户
order.setIdUser(userId);//客户id
order.setMobile(request.getAttribute("phone").toString());//收件人电话(客户电话)
order.setCreateTime(DateUtil.parseLocalDateTime(DateUtil.now(),"yyyy-MM-dd HH:mm:ss"));
order.setOrderType(2);//订单类型1.商品 2.会籍 3.课程
order.setPayType("微信支付");
order.setTradeAmount(price);//TradeAmount交易金额
orderService.save(order);
//生成订单详情
ShopOrderItem item=new ShopOrderItem();
item.setIdOrder(order.getId());//订单id
item.setIdMember(memberUser.getMemberId());//会员id
item.setTotalPrice(price);//总价
item.setThumbnail(memberUser.getMemberPicture());//缩略图
item.setType("2");//1 商品 2 会籍 3 课程
item.setMemberType(memberUser.getMemberName());//会籍类型=会籍名称
item.setMemberValidity(memberUser.getValidity());//会籍有效期(月)
item.setBrief(memberUser.getMemberContext());//简介=会籍内容
item.setMemberRecommend(memberUser.getRecommend());//推荐人
itemService.save(item);
//单位: 元 转换成 分
BigDecimal total=price.multiply(new BigDecimal(100));
Map map=new HashMap();
//0元
if (total.equals(BigDecimal.ZERO)){
//支付成功 生成会籍
map.put("timeStamp","1");
return new RestResponse().setSuccess(true).setMessage("成功").setData(map);
}
map= PayUtil.creatOrder(total.setScale(1, RoundingMode.HALF_UP).intValue(),order.getOrderSn());
return new RestResponse().setSuccess(true).setMessage("成功").setData(map);
}
/**
*
*
* @return
*/
// @ApiOperation("我的会籍")
@PostMapping("/myMembers")
public RestResponse myMembers(HttpServletRequest request){
Long userId= Long.parseLong(request.getAttribute("userId").toString());
List<MemberUser> list=memberUserServicel.list(new QueryWrapper<MemberUser>()
.eq("consumer_id",userId)
.last("and validity_time > now()"));
return new RestResponse().setSuccess(true).setData(list);
}
//课程表与会籍相关联
}

@ -1,72 +0,0 @@
package com.ruoyi.web.controller.app_shop;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.RestResponse;
import com.ruoyi.course.domain.CourseLog;
import com.ruoyi.course.service.CourseLogServiceImpl;
import com.ruoyi.shop.domain.YjCourseLp;
import com.ruoyi.shop.service.impl.YjCourceLpMenuServiceImpl;
import com.ruoyi.shop.service.impl.YjCourceLpServiceImpl;
import com.ruoyi.shop.service.impl.YjMerchantServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
@Api(tags = "瑜伽流派", description = "提供瑜伽流派相关的API")
@RestController
@RequestMapping("/api/courseLp")
public class CourceLpController {
@Resource
private YjCourceLpServiceImpl service;
@Resource
private YjMerchantServiceImpl merchantService;
@Resource
private YjCourceLpMenuServiceImpl menuService;
@Resource
private CourseLogServiceImpl courseLogService;
/**
*
* @param lp
* @return
*/
@PostMapping("/list")
@ApiOperation("获取瑜伽流派 列表")
public RestResponse list(@RequestBody YjCourseLp lp){
List<YjCourseLp> list=service.list(new QueryWrapper<YjCourseLp>()
.eq("merchant_id", lp.getMerchantId())
.eq("enabled",true)
.orderByDesc("modify_time")
);
return new RestResponse().setSuccess(true).setMessage("成功").setData(list);
}
@ApiOperation("获取当前瑜伽流派下的课程")
@PostMapping("/courseList")
public RestResponse courseList(@RequestBody YjCourseLp lp){
// 课程分类courseType 是否显示releases
List<YjCourseLp> list=service.list(new QueryWrapper<YjCourseLp>()
.eq("merchant_id", lp.getMerchantId())
.eq("enabled",true)
.orderByDesc("modify_time")
);
list.forEach(l->{
l.setCourseType(lp.getCourseType());
l.setReleases(true);
List<CourseLog> courseList=courseLogService.list(new QueryWrapper<CourseLog>()
.select("id","course_id","course_names","course_price","course_picture","course_type")
.eq("course_type",lp.getCourseType())//课程类型 2大咖课 3教练培训
.eq("releases",true) //上架
.eq("lp_id",l.getId())//流派
);
l.setCourseList(courseList);
});
return new RestResponse().setSuccess(true).setMessage("成功").setData(list);
}
}

@ -1,58 +0,0 @@
package com.ruoyi.web.controller.app_shop;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.RestResponse;
import com.ruoyi.shop.domain.ShopGoods;
import com.ruoyi.shop.domain.ShopGoodsCategory;
import com.ruoyi.shop.mapper.ShopGoodsMapper;
import com.ruoyi.shop.service.impl.ShopGoodsCategoryServiceImpl;
import com.ruoyi.shop.service.impl.ShopGoodsServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
@Api(tags = "商品", description = "提供商品相关的API")
@RestController
@RequestMapping("/api/goods")
public class GoodsController {
@Resource
private ShopGoodsServiceImpl service;
@Resource
private ShopGoodsCategoryServiceImpl categoryService;
@Resource
private ShopGoodsMapper goodsMapper;
@ApiOperation("商品类别")
@PostMapping("/getGoodsCategory")
public RestResponse getGoodsCategory(@RequestBody ShopGoodsCategory category){
List<ShopGoodsCategory> categoryList=categoryService.list(new QueryWrapper<ShopGoodsCategory>()
.eq("business_id",category.getBusinessId())
.eq("pid","0")
.eq("display",true)
.eq("is_delete",false));
return new RestResponse().setSuccess(true).setMessage("成功").setData(categoryList);
}
@ApiOperation("商品列表")
@PostMapping("/getGoods")
public RestResponse getGoods(@RequestBody ShopGoodsCategory category){
List<ShopGoods> goods=goodsMapper.getByPid(category.getId());
return new RestResponse().setSuccess(true).setMessage("成功").setData(goods);
}
@ApiOperation("商品详情")
@PostMapping("/getOne")
public RestResponse getOne(@RequestBody ShopGoods goods){
return new RestResponse().setSuccess(true).setMessage("成功").setData(service.getById(goods.getId()));
}
}

@ -1,56 +0,0 @@
package com.ruoyi.web.controller.app_shop;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.RestResponse;
import com.ruoyi.shop.domain.YjIndex;
import com.ruoyi.shop.domain.YjMerchant;
import com.ruoyi.shop.service.impl.YjIndexServiceImpl;
import com.ruoyi.shop.service.impl.YjMerchantServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
@Api(tags = "首页", description = "提供首页信息相关的API")
@RestController
@RequestMapping("/api/index")
public class IndexController {
@Resource
private YjIndexServiceImpl indexService;
@Resource
private YjMerchantServiceImpl merchantService;
//商户list
@ApiOperation("门店列表")
@PostMapping("/getMerchant")
public RestResponse getMerchant(){
List<YjMerchant> list=merchantService.list(new QueryWrapper<YjMerchant>()
.select("address","enterprise_name","phone","banner","id")
.eq("status",2));
return new RestResponse().setSuccess(true).setData(list);
}
@ApiOperation("首页图标")
@ApiImplicitParam(name = "merchantId", value = "商户ID", required = true, dataType = "String", dataTypeClass = String.class)
@PostMapping("/getIndex")
public RestResponse getIndex(@RequestBody YjIndex yjIndex){
YjIndex y= indexService.getOne(new QueryWrapper<YjIndex>()
.eq("merchant_id",yjIndex.getMerchantId()));
if (ObjectUtil.isNotEmpty(y)){
return new RestResponse().setSuccess(true).setData(y);
}else {
return new RestResponse().setSuccess(false);
}
}
}

@ -1,315 +0,0 @@
package com.ruoyi.web.controller.app_shop;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.RestResponse;
import com.ruoyi.common.constant.CacheConstants;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginBody;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.exception.user.CaptchaException;
import com.ruoyi.common.exception.user.CaptchaExpireException;
import com.ruoyi.common.exception.user.UserPasswordNotMatchException;
import com.ruoyi.common.utils.*;
import com.ruoyi.common.utils.ip.IpUtils;
import com.ruoyi.framework.config.JwtUtil1;
import com.ruoyi.framework.manager.AsyncManager;
import com.ruoyi.framework.manager.factory.AsyncFactory;
import com.ruoyi.framework.security.context.AuthenticationContextHolder;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.shop.domain.Consumer;
import com.ruoyi.shop.domain.YjMerchant;
import com.ruoyi.shop.service.ConsumerService;
import com.ruoyi.shop.service.impl.YjMerchantServiceImpl;
import com.ruoyi.system.service.ISysConfigService;
import com.ruoyi.system.service.ISysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.TimeUnit;
@Api(tags = "登录与验证")
@RestController
@RequestMapping("/api")
public class LoginController {
@Resource
private ConsumerService service;
@Autowired
private ISysUserService userService;
@Resource
JwtUtil1 jwtUtil1;
@Autowired
private TokenService tokenService;
@Resource
RedisTemplate<String,Object> redisTemplate;
@Autowired
private RedisCache redisCache;
@Autowired
private ISysConfigService configService;
@Resource
private AuthenticationManager authenticationManager;
@ApiOperation("登录")
@PostMapping("/login")
public AjaxResult login(@RequestBody LoginBody loginBody){
AjaxResult ajax = AjaxResult.success();
if (StrUtil.isEmpty(loginBody.getRegisterId())){
ajax.put(Constants.FAIL, "设备id异常");
return ajax;
}
boolean captchaEnabled = configService.selectCaptchaEnabled();
// 验证码开关
if (captchaEnabled)
{
validateCaptcha(loginBody.getAccount(),loginBody.getCode(),loginBody.getUuid());
}
//用户名是否存在
SysUser user = userService.selectUserByUserName(loginBody.getAccount());
//未注册
if(ObjectUtil.isEmpty(user) ){
//注册并登录
//用户账号 昵称 门店 密码 头像
// registerId 地址
// 必填 user_name nick_name merchant_id
user=new SysUser();
user.setUserName(loginBody.getAccount());
user.setNickName("用户"+loginBody.getAccount());
user.setPassword(SecurityUtils.encryptPassword(loginBody.getPassword()));
user.setRegisterId(loginBody.getRegisterId());
user.setVisitStore(getIndex(user).get("id"));
Long[] ros={107l};//用户角色
user.setRoleIds(ros);
userService.insertUser(user);
String token = validateUser(loginBody.getAccount(),loginBody.getPassword());
//设置推送别名
JpushClientUtil.bindAlias(loginBody.getRegisterId(),loginBody.getAccount());
ajax.put(Constants.TOKEN, token);
return ajax;
}
//已注册 直接登录
String token = validateUser(loginBody.getAccount(),loginBody.getPassword());
//设置推送别名
JpushClientUtil.bindAlias(loginBody.getRegisterId(),loginBody.getAccount());
if (!loginBody.getRegisterId().equals(user.getRegisterId())){
//判断登录设备是否更换 todo
// userService.updateUser();
}
//返回token
ajax.put(Constants.TOKEN, token);
return ajax;
}
/**
*
*
* @param code
* @param uuid
* @return
*/
public void validateCaptcha(String username, String code, String uuid)
{
String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + StringUtils.nvl(uuid, "");
String captcha = redisCache.getCacheObject(verifyKey);
redisCache.deleteObject(verifyKey);
if (captcha == null)
{
//验证码为空
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire")));
throw new CaptchaExpireException();
}
if (!code.equalsIgnoreCase(captcha))
{
//验证码不存在
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error")));
throw new CaptchaException();
}
}
//用户验证
public String validateUser(String username,String password){
// 用户验证
Authentication authentication = null;
try
{
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(username, password);
AuthenticationContextHolder.setContext(authenticationToken);
// 该方法会去调用UserDetailsServiceImpl.loadUserByUsername
authentication = authenticationManager.authenticate(authenticationToken);
}
catch (Exception e)
{
if (e instanceof BadCredentialsException)
{
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match")));
throw new UserPasswordNotMatchException();
}
else
{
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, e.getMessage()));
throw new ServiceException(e.getMessage());
}
}
finally
{
AuthenticationContextHolder.clearContext();
}
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
LoginUser loginUser = (LoginUser) authentication.getPrincipal();
if (StrUtil.isEmpty(loginUser.getUser().getMerchantId())){
throw new RuntimeException("未建商户无法登录");
}
recordLoginInfo(loginUser.getUserId());
// 生成token
return tokenService.createToken(loginUser);
}
/**
*
*
* @return
*/
@GetMapping("/getInfo")
public AjaxResult getInfo()
{
SysUser user = SecurityUtils.getLoginUser().getUser();
// 角色集合
// Set<String> roles = permissionService.getRolePermission(user);
// 权限集合
// Set<String> permissions = permissionService.getMenuPermission(user);
AjaxResult ajax = AjaxResult.success();
ajax.put("user", user);
ajax.put("merchant",getIndex(user));
// ajax.put("roles", roles);
// ajax.put("permissions", permissions);
return ajax;
}
/**
*
*
* @param userId ID
*/
public void recordLoginInfo(Long userId)
{
SysUser sysUser = new SysUser();
sysUser.setUserId(userId);
sysUser.setLoginIp(IpUtils.getIpAddr(ServletUtils.getRequest()));
sysUser.setLoginDate(DateUtils.getNowDate());
userService.updateUserProfile(sysUser);
}
// -----------------------------------------------
@ApiOperation("获取验证码")
// @PostMapping ("/getCode")
public RestResponse getCode(@RequestBody Consumer consumer){
String captcha=(String) redisTemplate.opsForValue().get(consumer.getConsumerPhonenumber());
if (StrUtil.isNotEmpty(captcha)){
return new RestResponse().setSuccess(false).setMessage("请1分钟后重试");
}
captcha =gen()+"";
//发送成功 手机号存到redis 对应code 1分钟有效期
redisTemplate.opsForValue().set(consumer.getConsumerPhonenumber(),
captcha,
1,
TimeUnit.MINUTES);
return new RestResponse().setSuccess(true).setMessage("发送成功").setData(captcha);
}
public int gen() {
Random r = new Random( System.currentTimeMillis() );
return ((1 + r.nextInt(2)) * 100000 + r.nextInt(100000));
}
/**
*
* @param map
* @return
*/
public RestResponse login(@RequestBody Map<String,String> map){
System.out.println("---------------------registerId"+map.get("registerId"));
String captcha=(String)redisTemplate.opsForValue().get(map.get("consumerPhonenumber"));
if(map.get("captcha").equals(captcha)){
//登录成功
redisTemplate.delete(map.get("consumerPhonenumber"));
Map<String, Object> dataMap = new HashMap<>();
//查找数据库,判断是否为新用户:
//老用戶
Consumer consumer=service.getOne(new QueryWrapper<Consumer>()
.eq("consumer_phonenumber",map.get("consumerPhonenumber")));
if (ObjectUtil.isNotEmpty(consumer)){
//老客户
if (StrUtil.isNotEmpty(map.get("registerId"))){
consumer.setRegisterId(map.get("registerId"));
service.updateById(consumer);
//设置推送别名
JpushClientUtil.bindAlias(consumer.getRegisterId(),consumer.getConsumerPhonenumber());
}
String token = jwtUtil1.generateToken(consumer.getConsumerId().toString(),consumer.getConsumerPhonenumber());
dataMap.put("jwt",token);
dataMap.put("userInfo",consumer);
return new RestResponse().setSuccess(true).setMessage("成功").setData(dataMap);
}
//新用戶
consumer=new Consumer();
consumer.setConsumerPhonenumber(map.get("consumerPhonenumber"));
consumer.setConsumerName("用户"+map.get("consumerPhonenumber"));
consumer.setConsumerNickName("用户"+map.get("consumerPhonenumber"));
consumer.setRegisterId(map.get("registerId"));
consumer.setConsumerAvatar("/default.jpeg");
service.save(consumer);
//设置推送别名
JpushClientUtil.bindAlias(consumer.getRegisterId(),consumer.getConsumerPhonenumber());
String token = jwtUtil1.generateToken(consumer.getConsumerId().toString(),consumer.getConsumerPhonenumber());
dataMap.put("jwt",token);
dataMap.put("userInfo",consumer);
// dataMap.put("index",getIndex(consumer));
return new RestResponse().setSuccess(true).setMessage("成功").setData(dataMap);
}
return new RestResponse().setSuccess(false).setMessage("失败");
}
@Resource
private YjMerchantServiceImpl merchantService;
public Map<String,String> getIndex(SysUser c){
YjMerchant merchant;
Map m=new HashMap();
if (StrUtil.isNotEmpty(c.getVisitStore())){
merchant=merchantService.getById(c.getVisitStore());
}else {
merchant= merchantService.list().get(0);
}
m.put("address",merchant.getAddress());
m.put("enterpriseName",merchant.getEnterpriseName());
m.put("phone",merchant.getPhone());
m.put("banner",merchant.getBanner());
m.put("id",merchant.getId());
return m;
}
}

@ -1,323 +0,0 @@
package com.ruoyi.web.controller.app_shop;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.ruoyi.RestResponse;
import com.ruoyi.shop.domain.ShopGoods;
import com.ruoyi.shop.domain.ShopOrder;
import com.ruoyi.shop.domain.ShopOrderItem;
import com.ruoyi.shop.service.impl.ShopCartServiceImpl;
import com.ruoyi.shop.service.impl.ShopGoodsServiceImpl;
import com.ruoyi.shop.service.impl.ShopOrderItemServiceImpl;
import com.ruoyi.shop.service.impl.ShopOrderServiceImpl;
import com.ruoyi.web.controller.app_shop.dto.ShopOrderDto;
import com.ruoyi.web.util.PayUtil;
import com.ruoyi.web.util.SnowFlake;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Api(tags = "订单信息", description = "提供订单信息相关的API")
@RestController
@RequestMapping("/api/order")
public class OrderController {
@Resource
private ShopGoodsServiceImpl goodsService;
@Resource
private ShopCartServiceImpl cartService;
@Resource
private ShopOrderServiceImpl orderService;
@Resource
private ShopOrderItemServiceImpl itemService;
/**
*
* @param orderDto
* @param request
* @return
*
*
*
*
*/
@ApiOperation("提交订单-生成预付单")
@PostMapping("/createOrder")
@Transactional(rollbackFor = RuntimeException.class)
public RestResponse createOrder(@RequestBody ShopOrderDto orderDto, HttpServletRequest request) throws Exception{
Long userId= Long.parseLong(request.getAttribute("userId").toString());
//商户:商品list
Map<String,List<ShopGoods>> goodsMap=orderDto.getList().stream().collect(Collectors.groupingBy(ShopGoods::getBusinessId));
String OrderSn=SnowFlake.getOrder()+"";
BigDecimal total=new BigDecimal(0);//微信支付金额
for (String key:goodsMap.keySet()){
//生成订单
ShopOrder order=new ShopOrder();
order.setBusinessId(key);//商户
order.setIdUser(userId);
order.setConsignee(orderDto.getName());//收件人
order.setConsigneeAddress(orderDto.getProvince()+" "+
orderDto.getCity()+" "+
orderDto.getAddress());//收件地址
order.setMobile(orderDto.getPhone());//收件人电话
order.setCreateTime(DateUtil.parseLocalDateTime(DateUtil.now(),"yyyy-MM-dd HH:mm:ss"));
order.setOrderSn(OrderSn);//订单号
order.setPayType("微信支付");
order.setOrderType(1);//订单类型1.商品 2.会籍 3.课程
orderService.save(order);
BigDecimal totalPrice=new BigDecimal(0);//总金额
BigDecimal tradeAmount=new BigDecimal(0);//交易金额
for (ShopGoods goods:goodsMap.get(key)){
ShopOrderItem item=new ShopOrderItem();
item.setGoodsName(goods.getName());//* 商品名称
item.setIdGoods(goods.getId());//* 商品名称
item.setThumbnail(goods.getThumbnail());//* 商品缩略图
item.setBrief(goods.getBrief());//* 商品简介
item.setAttribute(goods.getAttribute());//* 规格
item.setCount(goods.getCount());//数量
item.setPrice(goods.getPrice());//单价
item.setIdOrder(order.getId());//订单id
item.setType("1");//1 商品 2 会籍 3 课程
BigDecimal to=goods.getPrice().multiply(new BigDecimal(goods.getCount()));
item.setTotalPrice(to);//总金额
//商品库存更改
Boolean isEnough= goodsService.update(new UpdateWrapper<ShopGoods>()
.setSql("stock=stock-"+goods.getCount())
.eq("id",goods.getId())
.ge("stock",goods.getCount()));
if(!isEnough){
throw new RuntimeException("商品["+goods.getName()+"]库存不足!");
// return new RestResponse().setSuccess(false).setMessage("商品["+goods.getName()+"]库存不足!");
}
itemService.save(item);
if (StrUtil.isNotEmpty(goods.getCartId())){
cartService.removeById(goods.getCartId());
}
tradeAmount=tradeAmount.add(to);//实际需要支付的金额
totalPrice=totalPrice.add(goods.getMarketPrice().multiply(new BigDecimal(goods.getCount())));
}
order.setTotalPrice(totalPrice);
order.setTradeAmount( tradeAmount);//实际需要支付的金额
orderService.updateById(order);
//
total=total.add(order.getTradeAmount());
}
total=total.multiply(new BigDecimal(100));
Map map=new HashMap();
if (total.equals(BigDecimal.ZERO)){
//0元直接支付成功 无需调用微信支付
orderService.paySuccess(OrderSn,DateUtil.now(),"","0");
map.put("timeStamp","1");
return new RestResponse().setSuccess(true).setMessage("成功").setData(map);
}
//调用微信支付 生成预付单
map= PayUtil.creatOrder(total.setScale(1, RoundingMode.HALF_UP).intValue(),OrderSn);
return new RestResponse().setSuccess(true).setMessage("成功").setData(map);
}
// public RestResponse createOrder(@RequestBody ShopOrderDto orderDto, HttpServletRequest request){
// Long userId= Long.parseLong(request.getAttribute("userId").toString());
//
//// List<String> goodsIds = orderDto.getList().stream().map(ShopGoods::getId).collect(Collectors.toList());
//// List<ShopGoods> goodsList = goodsMapper.selectBatchIds(goodsIds);
// Map<String,List<ShopGoods>> goodsMap=orderDto.getList().stream().collect(Collectors.groupingBy(ShopGoods::getBusinessId));
//
// for (String key:goodsMap.keySet()){
// //生成订单
// ShopOrder order=new ShopOrder();
// order.setBusinessId(key);//商户
// order.setIdUser(userId);
// order.setConsignee(orderDto.getName());//收件人
// order.setConsigneeAddress(orderDto.getProvince()+" "+
// orderDto.getCity()+" "+
// orderDto.getAddress());//收件地址
// order.setMobile(orderDto.getPhone());//收件人电话
// order.setCreateTime(DateUtil.parseLocalDateTime(DateUtil.now(),"yyyy-MM-dd HH:mm:ss"));
// order.setOrderSn(SnowFlake.getOrder()+"");
// orderService.save(order);
// BigDecimal totalPrice=new BigDecimal(0);//总金额
// BigDecimal tradeAmount=new BigDecimal(0);//交易金额
//
// for (ShopGoods goods:goodsMap.get(key)){
// ShopOrderItem item=new ShopOrderItem();
// item.setGoodsName(goods.getName());//* 商品名称
// item.setIdGoods(goods.getId());//* 商品名称
// item.setThumbnail(goods.getThumbnail());//* 商品缩略图
// item.setBrief(goods.getBrief());//* 商品简介
// item.setAttribute(goods.getAttribute());//* 规格
// item.setCount(goods.getCount());//数量
// item.setPrice(goods.getPrice());//单价
// item.setIdOrder(order.getId());//订单id
// BigDecimal To=goods.getPrice().multiply(new BigDecimal(goods.getCount()));
// item.setTotalPrice(To);//总金额
// //商品库存更改
// Boolean isEnough= goodsService.update(new UpdateWrapper<ShopGoods>()
// .setSql("stock=stock-"+goods.getCount())
// .eq("id",goods.getId())
// .ge("stock",goods.getCount()));
// if(!isEnough){
// throw new RuntimeException("商品["+goods.getName()+"]库存不足!");
//// return new RestResponse().setSuccess(false).setMessage("商品["+goods.getName()+"]库存不足!");
// }
// itemService.save(item);
// if (StrUtil.isNotEmpty(goods.getCartId())){
// cartService.removeById(goods.getCartId());
// }
// totalPrice=totalPrice.add(To);
// tradeAmount=tradeAmount.add(goods.getMarketPrice().multiply(new BigDecimal(goods.getCount())));
// }
// order.setTotalPrice(tradeAmount);
// order.setTradeAmount(totalPrice);//
// orderService.updateById(order);
// }
// return new RestResponse().setSuccess(true).setMessage("成功");
// }
/**
* 1/
*
*
* @param order
* @return
*/
// @PostMapping("/cancelOrder")
@Transactional(rollbackFor = RuntimeException.class)
public RestResponse cancelOrder(@RequestBody ShopOrder order){
//更改订单状态
//查询对应订单详情
//根据订单详情数量 更改商品库存
Boolean isUpdate= orderService.update(new UpdateWrapper<ShopOrder>()
.set("status",2)
.eq("id",order.getId())
.eq("status",1));
if (isUpdate){
List<ShopOrderItem> itemList=itemService.list(new QueryWrapper<ShopOrderItem>()
.eq("id_order",order.getId()));
for (ShopOrderItem item:itemList){
goodsService.update(new UpdateWrapper<ShopGoods>()
.setSql("stock=stock+"+item.getCount())
.eq("id",item.getIdGoods()));
}
return new RestResponse().setSuccess(true).setMessage("订单取消成功");
}
return new RestResponse().setSuccess(false).setMessage("该订单无法取消");
}
/**
*
* @param order
* @return
*/
// @PostMapping("/pay")
public RestResponse pay(@RequestBody ShopOrder order){
if(orderService.getById(order.getId()).getPayStatus()==2){
return new RestResponse().setSuccess(true).setMessage("该订单已支付成功,请勿重复支付!");
}
ShopOrder o=orderService.getById(order);
order.setStatus(3);
order.setPayStatus(2);
order.setPayTime(DateUtil.now());
order.setRealPrice(o.getTradeAmount());
orderService.updateById(order);
return new RestResponse().setSuccess(true).setMessage("订单支付成功");
}
/**
*
* @param order
* @return
*/
@ApiOperation("确认收货")
@PostMapping("/received")
public RestResponse received(@RequestBody ShopOrder order){
order.setStatus(6);
orderService.updateById(order);
return new RestResponse().setSuccess(true).setMessage("成功");
}
/**
*
* @param request
* @return
*/
@ApiOperation(value = "获取订单列表", notes = "我的订单")
@PostMapping("/orderList")
public RestResponse orderList(HttpServletRequest request){
Long userId= Long.parseLong(request.getAttribute("userId").toString());
List<ShopOrder> list=orderService.list(new QueryWrapper<ShopOrder>()
.eq("id_user",userId));
List<ShopOrder> list1=new ArrayList<>();
List<ShopOrder> list2=new ArrayList<>();
List<ShopOrder> list3=new ArrayList<>();
List<ShopOrder> list4=new ArrayList<>();
List<ShopOrder> list6=new ArrayList<>();
for (ShopOrder order:list){
order.setItemList(getItemList(order.getId()));
if (order.getStatus()==1){
list1.add(order);
}
if (order.getStatus()==2){
list2.add(order);
}
if (order.getStatus()==3){
list3.add(order);
}
if (order.getStatus()==4){
list4.add(order);
}
if (order.getStatus()==6){
list6.add(order);
}
}
Map<String,List<ShopOrder>> map=new HashMap<>();
map.put("list",list);//全部订单
map.put("list1",list1);//未付款
map.put("list2",list2);//2已取消
map.put("list3",list3);//3已付款/待发货
map.put("list4",list4);//4已发货/待收货
map.put("list6",list6);//6已签收
return new RestResponse().setSuccess(true).setMessage("成功").setData(map);
}
/**
*
* @param order
* @return
*/
@ApiOperation("订单详情")
@PostMapping("/getOrder")
public RestResponse getOrder(@RequestBody ShopOrder order){
ShopOrder o= orderService.getById(order.getId());
o.setItemList(getItemList(order.getId()));
return new RestResponse().setSuccess(true).setMessage("成功").setData(o);
}
public List<ShopOrderItem> getItemList(String orderId){
return itemService.list(new QueryWrapper<ShopOrderItem>().eq("id_order",orderId));
}
}

@ -1,220 +0,0 @@
package com.ruoyi.web.controller.app_shop;
import cn.hutool.core.date.DateTime;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.ruoyi.shop.domain.ShopOrder;
import com.ruoyi.shop.service.impl.ShopOrderServiceImpl;
import com.ruoyi.web.util.PayConstants;
import com.ruoyi.web.util.PayUtil;
import com.wechat.pay.contrib.apache.httpclient.WechatPayHttpClientBuilder;
import com.wechat.pay.contrib.apache.httpclient.auth.PrivateKeySigner;
import com.wechat.pay.contrib.apache.httpclient.auth.Verifier;
import com.wechat.pay.contrib.apache.httpclient.auth.WechatPay2Credentials;
import com.wechat.pay.contrib.apache.httpclient.auth.WechatPay2Validator;
import com.wechat.pay.contrib.apache.httpclient.cert.CertificatesManager;
import com.wechat.pay.contrib.apache.httpclient.util.PemUtil;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.util.EntityUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.security.PrivateKey;
import java.text.SimpleDateFormat;
import java.util.*;
@RestController
@RequestMapping("/api")
public class PayController {
@Resource
private ShopOrderServiceImpl orderService;
/**
*
* @param amount
* @return
* @throws Exception
*/
// @PostMapping("/creat_order")
// private Map creatOrder(int amount) throws Exception{
// return PayUtil.creatOrder("三朵兰",amount,"123");
// }
/**
*
* @return
* https://www.test.com/callback
*/
@PostMapping("/callback")
public Map callback(HttpServletRequest request) {
System.out.println("Wechatpay-Timestamp:"+ request.getHeader("Wechatpay-Timestamp"));
System.out.println("Wechatpay-Nonce:"+ request.getHeader("Wechatpay-Nonce"));
System.out.println("Wechatpay-Signature:"+ request.getHeader("Wechatpay-Signature"));
System.out.println("Wechatpay-Serial:"+ request.getHeader("Wechatpay-Serial"));
Map result=new HashMap();
result.put("code","FAIL");
try {
StringBuilder signStr=new StringBuilder();
signStr.append( request.getHeader("Wechatpay-Timestamp")).append("\n");
signStr.append( request.getHeader("Wechatpay-Nonce")).append("\n");
BufferedReader br=request.getReader();
String str=null;
StringBuilder builder=new StringBuilder();
while ((str=br.readLine())!=null){
builder.append(str);
}
System.out.println(builder);
signStr.append( builder.toString()).append("\n");
//验证签名
if (!PayUtil.signVerify(request.getHeader("Wechatpay-Serial"),signStr.toString(),request.getHeader("Wechatpay-Signature"))){
result.put("message","sign error");
return result;
}
//解密密文
String ciphertext=PayUtil.decryptOrder(builder.toString());
System.out.println(ciphertext);
//验证订单
ObjectMapper objectMapper = new ObjectMapper();
JsonNode node=objectMapper.readTree(ciphertext);
JsonNode amount=node.get("amount");//订单金额信息
String payer_total=amount.get("payer_total").textValue();//用户支付金额,单位为分
String payer_currency=amount.get("payer_currency").textValue();//用户支付币种 示例值CNY
String trade_state=node.get("trade_state").textValue();//交易状态 SUCCESS
String out_trade_no=node.get("out_trade_no").textValue();//商户订单号
String success_time=node.get("success_time").textValue();//支付完成时间
String transaction_id=node.get("transaction_id").textValue();//支付完成时间
List<ShopOrder> list = orderService.list(new QueryWrapper<ShopOrder>().eq("orderSn",out_trade_no));
//判断交易状态 可能是多次 SUCCESS 也可能是 多次不同状态
// 现只处理支付成功与支付失败两种状态
//判断是否处理过
if (list.get(0).getPayStatus()==1){
System.out.println("处理订单:"+out_trade_no+" 交易状态:"+trade_state);
//支付失败
if (trade_state.equals("PAYERROR")){
System.out.println("取消订单+关单");
orderService.cancelOrder(out_trade_no);
try {
PayUtil.closeOrder(out_trade_no);//关单
} catch (Exception e) {
e.printStackTrace();
}
}
//支付成功
if (trade_state.equals("SUCCESS")){
System.out.println("支付成功");
orderService.paySuccess(out_trade_no
,getStringByRFC3339(success_time)
,transaction_id
,payer_total);
result.put("code","SUCCESS");
}
}
}catch (IOException e){
e.printStackTrace();
}
return result;
}
public void a(@RequestBody Map<String,String> map){
String out_trade_no=map.get("out_trade_no");
String trade_state=map.get("trade_state");
String success_time="2022-12-31T10:34:56+08:00";
String transaction_id="微信支付订单号";
String payer_total="0.1";
List<ShopOrder> list = orderService.list(new QueryWrapper<ShopOrder>().eq("order_sn",out_trade_no));
//判断交易状态 可能是多次 SUCCESS 也可能是 多次不同状态
// 现只处理支付成功与支付失败两种状态
//判断是否处理过
if (list.get(0).getPayStatus()==1){
//支付失败
if (trade_state.equals("PAYERROR")){
System.out.println("取消订单+关单");
orderService.cancelOrder(out_trade_no);
try {
PayUtil.closeOrder(out_trade_no);//关单
System.out.println("code,***");
} catch (Exception e) {
e.printStackTrace();
}
}
//支付成功
if (trade_state.equals("SUCCESS")){
System.out.println("支付成功");
orderService.paySuccess(out_trade_no
,getStringByRFC3339(success_time)
,transaction_id
,payer_total);
System.out.println("code,SUCCESS");
}
}
}
//查询订单
public void queryOrder() throws Exception{
PrivateKey merchantPrivateKey = PemUtil.loadPrivateKey(PayConstants.PRIVATE_KEY);
// 获取证书管理器实例
CertificatesManager certificatesManager = CertificatesManager.getInstance();
// 向证书管理器增加需要自动更新平台证书的商户信息
certificatesManager.putMerchant(PayConstants.MCH_ID, new WechatPay2Credentials(PayConstants.MCH_ID,
new PrivateKeySigner(PayConstants.MCH_SERIAL_NO, merchantPrivateKey)),
PayConstants.API_V3KEY.getBytes(StandardCharsets.UTF_8));
// 从证书管理器中获取verifier
Verifier verifier = certificatesManager.getVerifier(PayConstants.MCH_ID);
CloseableHttpClient httpClient = WechatPayHttpClientBuilder.create()
.withMerchant(PayConstants.MCH_ID, PayConstants.MCH_SERIAL_NO, merchantPrivateKey)
.withValidator(new WechatPay2Validator(certificatesManager.getVerifier(PayConstants.MCH_ID)))
.build();
//***********************
URIBuilder uriBuilder = new URIBuilder("https://api.mch.weixin.qq.com/v3/pay/partner/transactions/id/"+"订单号"+"?mchid="+PayConstants.MCH_ID);
HttpGet httpGet = new HttpGet(uriBuilder.build());
httpGet.addHeader("Accept", "application/json");
CloseableHttpResponse response = httpClient.execute(httpGet);
String bodyAsString = EntityUtils.toString(response.getEntity());
System.out.println(bodyAsString);
}
/**
*
*
* rfc3339
* yyyy-MM-DDTHH:mm:ss+TIMEZONE
* 2018-06-08T10:34:56+08:00
* @param dateStr
* @return
*/
public static String getStringByRFC3339(String dateStr){
DateTime dateTime = new DateTime(dateStr);
long timeInMillis = dateTime.toCalendar(Locale.getDefault()).getTimeInMillis();
Date date = new Date(timeInMillis);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String time = format.format(date);
return time;
}
}

@ -1,68 +0,0 @@
package com.ruoyi.web.controller.app_shop;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.RestResponse;
import com.ruoyi.shop.domain.ShopCart;
import com.ruoyi.shop.domain.ShopGoods;
import com.ruoyi.shop.mapper.ShopCartMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
@Api(tags = "购物车", description = "提供购物车相关的API")
@RestController
@RequestMapping("/api/shopCart")
public class ShopCartController {
@Resource
private ShopCartMapper shopCartMapper;
@ApiOperation("加入购物车")
@PostMapping("/addShopCart")
public RestResponse addShopCart(@RequestBody ShopCart shopCart, HttpServletRequest request){
Long userId= Long.parseLong(request.getAttribute("userId").toString());
ShopCart s=shopCartMapper.selectOne(new QueryWrapper<ShopCart>()
.eq("id_user",userId)
.eq("id_goods",shopCart.getIdGoods()));
if (ObjectUtil.isNotEmpty(s)){
s.setCount(s.getCount()+1);
shopCartMapper.updateById(s);
return new RestResponse().setSuccess(true).setMessage("成功");
}
shopCart.setIdUser(userId);
shopCartMapper.insert(shopCart);
return new RestResponse().setSuccess(true).setMessage("成功");
}
@ApiOperation("购物车删除商品")
@PostMapping("/removeShopCart")
public RestResponse removeShopCart(@RequestBody Map<String, List<String>> map){
List<String> ids=map.get("ids");
shopCartMapper.deleteBatchIds(ids);
return new RestResponse().setSuccess(true).setMessage("成功");
}
@ApiOperation("购物车商品列表")
@PostMapping("/shopCartList")
public RestResponse shopCartList(HttpServletRequest request){
Long userId= Long.parseLong(request.getAttribute("userId").toString());
List<ShopGoods> list=shopCartMapper.cartList(userId);
return new RestResponse().setSuccess(true).setMessage("成功").setData(list);
}
@ApiOperation("购物车修改商品数量")
@PostMapping("/changeCount")
public RestResponse changeCount(@RequestBody ShopCart shopCart){
shopCartMapper.updateById(shopCart);
return new RestResponse().setSuccess(true).setMessage("成功");
}
}

@ -1,40 +0,0 @@
package com.ruoyi.web.controller.app_shop.dto;
import com.ruoyi.shop.domain.ShopGoods;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
public class ShopOrderDto {
/**
*
*/
@ApiModelProperty("省")
private String province;
/**
*
*/
private String city;
/**
*
*/
private String address;
/**
*
*/
private String phone;
/**
*
*/
private String name;
private String message;
private List<ShopGoods> list;
}

@ -1,10 +1,10 @@
package com.ruoyi.web.controller.app_shop; package com.ruoyi.web.controller.basic;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.ruoyi.RestResponse; import com.ruoyi.RestResponse;
import com.ruoyi.shop.domain.YjAppreciate; import com.ruoyi.basic.domain.YjAppreciate;
import com.ruoyi.shop.service.impl.YjAppreciateServiceImpl; import com.ruoyi.basic.service.impl.YjAppreciateServiceImpl;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
@ -18,7 +18,7 @@ import java.util.List;
/** /**
* *
*/ */
@Api(tags = "瑜伽欣赏", description = "提供瑜伽欣赏相关的API") @Api(tags = "034-瑜伽欣赏", description = "提供瑜伽欣赏相关的API")
@RestController @RestController
@RequestMapping("/api/appreciate") @RequestMapping("/api/appreciate")
public class AppreciateController { public class AppreciateController {
@ -35,7 +35,8 @@ public class AppreciateController {
@PostMapping("/getList") @PostMapping("/getList")
public RestResponse getList(@RequestBody YjAppreciate appreciate){ public RestResponse getList(@RequestBody YjAppreciate appreciate){
List<YjAppreciate> list= service.list(new QueryWrapper<YjAppreciate>() List<YjAppreciate> list= service.list(new QueryWrapper<YjAppreciate>()
.eq("merchan_id",appreciate.getMerchanId()) .select("id,title,image,read_num,start_time")
.eq("visit_store",appreciate.getVisitStore())
.eq("status",true) .eq("status",true)
.orderByDesc("modify_time")); .orderByDesc("modify_time"));
return new RestResponse().setSuccess(true).setMessage("成功").setData(list); return new RestResponse().setSuccess(true).setMessage("成功").setData(list);

@ -1,9 +1,12 @@
package com.ruoyi.web.controller.app_course; package com.ruoyi.web.controller.basic;
import com.ruoyi.RestResponse; import com.ruoyi.RestResponse;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.course.domain.Context; import com.ruoyi.course.domain.Context;
import com.ruoyi.course.service.ContextServicelmpl; import com.ruoyi.course.domain.ReqSearchClaTime;
import com.ruoyi.course.domain.time.RespBusinessClaTimeCalendar;
import com.ruoyi.course.service.ScClaTimeService;
import com.ruoyi.course.service.impl.ContextServicelmpl;
import com.ruoyi.system.service.impl.SysUserServiceImpl; import com.ruoyi.system.service.impl.SysUserServiceImpl;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -16,7 +19,7 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@Api(tags = "教练", description = "获取教练信息") @Api(tags = "022-教练", description = "获取教练信息")
@RestController @RestController
@RequestMapping("/api/context") @RequestMapping("/api/context")
public class ContextAppController extends BaseController { public class ContextAppController extends BaseController {
@ -24,11 +27,12 @@ public class ContextAppController extends BaseController {
ContextServicelmpl contextService; ContextServicelmpl contextService;
@Autowired @Autowired
SysUserServiceImpl userService; SysUserServiceImpl userService;
@Autowired
ScClaTimeService scClaTimeService;
@ApiOperation("教练列表") @ApiOperation("教练列表")
@PostMapping(value = "/getList") @PostMapping(value = "/getList")
public RestResponse findList1(@RequestBody Map<String, Object> params) { public RestResponse findList1(@RequestBody Map<String, Object> params) {
params.put("releases",true);
List<Context> list =contextService.getList(params); List<Context> list =contextService.getList(params);
return new RestResponse().setSuccess(true).setMessage("成功").setData(list); return new RestResponse().setSuccess(true).setMessage("成功").setData(list);
} }
@ -36,7 +40,14 @@ public class ContextAppController extends BaseController {
@ApiOperation("教练详细信息") @ApiOperation("教练详细信息")
@PostMapping("/getOne") @PostMapping("/getOne")
public RestResponse update(@RequestBody Map<String, Object> params) { public RestResponse update(@RequestBody Map<String, Object> params) {
Context c =contextService.getList(params).get(0); Context c =contextService.getOne(params);
return RestResponse.success().setData(c);
}
@ApiOperation("教练课程表")
@PostMapping("/searchListForCalendar")
public RestResponse update(@RequestBody ReqSearchClaTime reqSearchClaTime) {
RespBusinessClaTimeCalendar c =scClaTimeService.searchListForCalendar(reqSearchClaTime);
return RestResponse.success().setData(c); return RestResponse.success().setData(c);
} }
} }

@ -1,10 +1,10 @@
package com.ruoyi.web.controller.app_shop; package com.ruoyi.web.controller.basic;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.ruoyi.RestResponse; import com.ruoyi.RestResponse;
import com.ruoyi.shop.domain.YjHealthy; import com.ruoyi.basic.domain.YjHealthy;
import com.ruoyi.shop.service.impl.YjHealthyServiceImpl; import com.ruoyi.basic.service.impl.YjHealthyServiceImpl;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
@ -18,7 +18,7 @@ import java.util.List;
/** /**
* *
*/ */
@Api(tags = "健康饮食", description = "提供健康饮食相关的API") @Api(tags = "036-健康饮食", description = "提供健康饮食相关的API")
@RestController @RestController
@RequestMapping("/api/healthy") @RequestMapping("/api/healthy")
public class HealthyController { public class HealthyController {
@ -34,7 +34,8 @@ public class HealthyController {
@PostMapping("/getList") @PostMapping("/getList")
public RestResponse getList(@RequestBody YjHealthy healthy){ public RestResponse getList(@RequestBody YjHealthy healthy){
List<YjHealthy> list= service.list(new QueryWrapper<YjHealthy>() List<YjHealthy> list= service.list(new QueryWrapper<YjHealthy>()
.eq("merchan_id",healthy.getMerchanId()) .select("id,title,image,read_num,start_time")
.eq("visit_store",healthy.getVisitStore())
.eq("status",true) .eq("status",true)
.orderByDesc("modify_time")); .orderByDesc("modify_time"));
return new RestResponse().setSuccess(true).setMessage("成功").setData(list); return new RestResponse().setSuccess(true).setMessage("成功").setData(list);

@ -0,0 +1,77 @@
package com.ruoyi.web.controller.basic;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.ruoyi.RestResponse;
import com.ruoyi.basic.service.YjAppUserService;
import com.ruoyi.common.core.domain.entity.AppUser;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.basic.domain.YjStore;
import com.ruoyi.basic.service.impl.YjStoreServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Api(tags = "021-首页", description = "提供首页信息相关的API")
@RestController
@RequestMapping("/api/index")
public class IndexController {
@Resource
private YjStoreServiceImpl storeService;
@Autowired
private YjAppUserService appUserService;
@ApiOperation("门店列表")
@PostMapping("/getStores")
public RestResponse getStores(){
Long userId = SecurityUtils.getAppLoginUser().getAppUser().getId();
AppUser appUser =appUserService.getById(userId);
YjStore s=storeService.getOne(new QueryWrapper<YjStore>().select("tenant_id").eq("id",appUser.getVisitStore()));
List<YjStore> list= storeService.list(new QueryWrapper<YjStore>()
.select("address","" +
"store_name","phone","id","parent_id")
.eq("status",2)
.eq("tenant_id",s.getTenantId())
.orderByAsc("tenant_id")
);
list.forEach(l->{
if (l.getParentId().equals("0")){
l.setStoreName(l.getStoreName()+"(总店)");
}
});
return new RestResponse().setSuccess(true).setData(list);
}
@ApiOperation("切换门店")
@PostMapping("/changeStore")
public RestResponse changeStore(@RequestBody Map<String,String> map){
String visitStoreId =map.get("visitStoreId");
//登录用户的访问门店字段修改
AppUser appUser = SecurityUtils.getAppLoginUser().getAppUser();
appUserService.update(new UpdateWrapper<AppUser>()
.eq("app_user_id",appUser)
.set("visit_store",visitStoreId));
//返回新切换的门店信息
YjStore yjStore= storeService.getById(visitStoreId);
Map m=new HashMap();
m.put("address",yjStore.getAddress());
m.put("storeName",yjStore.getStoreName());
m.put("phone",yjStore.getPhone());
m.put("banner",yjStore.getBanner());
m.put("id",yjStore.getId());
return new RestResponse().setSuccess(true).setData(m);
}
}

@ -1,10 +1,10 @@
package com.ruoyi.web.controller.app_shop; package com.ruoyi.web.controller.basic;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.ruoyi.RestResponse; import com.ruoyi.RestResponse;
import com.ruoyi.shop.domain.YjInherit; import com.ruoyi.basic.domain.YjInherit;
import com.ruoyi.shop.service.impl.YjInheritServiceImpl; import com.ruoyi.basic.service.impl.YjInheritServiceImpl;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
@ -18,7 +18,7 @@ import java.util.List;
/** /**
* *
*/ */
@Api(tags = "瑜伽传承", description = "提供瑜伽传承相关的API") @Api(tags = "031-瑜伽传承", description = "提供瑜伽传承相关的API")
@RestController @RestController
@RequestMapping("/api/inherit") @RequestMapping("/api/inherit")
public class InheritController { public class InheritController {
@ -35,7 +35,8 @@ public class InheritController {
@PostMapping("/getList") @PostMapping("/getList")
public RestResponse getList(@RequestBody YjInherit inherit){ public RestResponse getList(@RequestBody YjInherit inherit){
List<YjInherit> list= inheritService.list(new QueryWrapper<YjInherit>() List<YjInherit> list= inheritService.list(new QueryWrapper<YjInherit>()
.eq("merchan_id",inherit.getMerchanId()) .select("id,title,image,read_num,start_time")
.eq("visit_store",inherit.getVisitStore())
.eq("status",true) .eq("status",true)
.orderByDesc("modify_time")); .orderByDesc("modify_time"));
return new RestResponse().setSuccess(true).setMessage("成功").setData(list); return new RestResponse().setSuccess(true).setMessage("成功").setData(list);

@ -1,9 +1,9 @@
package com.ruoyi.web.controller.app_shop; package com.ruoyi.web.controller.basic;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.RestResponse; import com.ruoyi.RestResponse;
import com.ruoyi.shop.domain.YjPracticeMoments; import com.ruoyi.basic.domain.YjPracticeMoments;
import com.ruoyi.shop.service.impl.YjPracticeMomentsServiceImpl; import com.ruoyi.basic.service.impl.YjPracticeMomentsServiceImpl;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
@ -17,7 +17,7 @@ import java.util.List;
/** /**
* *
*/ */
@Api(tags = "练习瞬间", description = "提供练习瞬间相关的API") @Api(tags = "033-练习瞬间", description = "提供练习瞬间相关的API")
@RestController @RestController
@RequestMapping("/api/moments") @RequestMapping("/api/moments")
public class PracticeMomentsController { public class PracticeMomentsController {
@ -34,7 +34,8 @@ public class PracticeMomentsController {
@PostMapping("/getList") @PostMapping("/getList")
public RestResponse getList(@RequestBody YjPracticeMoments moments){ public RestResponse getList(@RequestBody YjPracticeMoments moments){
List<YjPracticeMoments> list=momentsService.list(new QueryWrapper<YjPracticeMoments>() List<YjPracticeMoments> list=momentsService.list(new QueryWrapper<YjPracticeMoments>()
.eq("merchan_id",moments.getMerchanId()) .select("id,title,image,read_num,start_time")
.eq("visit_store",moments.getVisitStore())
.eq("status",true) .eq("status",true)
.orderByDesc("modify_time")); .orderByDesc("modify_time"));
return new RestResponse().setSuccess(true).setMessage("成功").setData(list); return new RestResponse().setSuccess(true).setMessage("成功").setData(list);

@ -1,10 +1,10 @@
package com.ruoyi.web.controller.app_shop; package com.ruoyi.web.controller.basic;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.ruoyi.RestResponse; import com.ruoyi.RestResponse;
import com.ruoyi.shop.domain.YjSense; import com.ruoyi.basic.domain.YjSense;
import com.ruoyi.shop.service.impl.YjSenseServiceImpl; import com.ruoyi.basic.service.impl.YjSenseServiceImpl;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
@ -18,7 +18,7 @@ import java.util.List;
/** /**
* *
*/ */
@Api(tags = "瑜伽常识", description = "提供瑜伽常识相关的API") @Api(tags = "035-瑜伽常识", description = "提供瑜伽常识相关的API")
@RestController @RestController
@RequestMapping("/api/sense") @RequestMapping("/api/sense")
public class SenseController { public class SenseController {
@ -34,7 +34,8 @@ public class SenseController {
@PostMapping("/getList") @PostMapping("/getList")
public RestResponse getList(@RequestBody YjSense sense){ public RestResponse getList(@RequestBody YjSense sense){
List<YjSense> list= service.list(new QueryWrapper<YjSense>() List<YjSense> list= service.list(new QueryWrapper<YjSense>()
.eq("merchan_id",sense.getMerchanId()) .select("id,title,image,read_num,start_time")
.eq("visit_store",sense.getVisitStore())
.eq("status",true) .eq("status",true)
.orderByDesc("modify_time")); .orderByDesc("modify_time"));
return new RestResponse().setSuccess(true).setMessage("成功").setData(list); return new RestResponse().setSuccess(true).setMessage("成功").setData(list);

@ -1,9 +1,9 @@
package com.ruoyi.web.controller.app_shop; package com.ruoyi.web.controller.basic;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.RestResponse; import com.ruoyi.RestResponse;
import com.ruoyi.shop.domain.YjMerchant; import com.ruoyi.basic.domain.YjStore;
import com.ruoyi.shop.service.impl.YjMerchantServiceImpl; import com.ruoyi.basic.service.impl.YjStoreServiceImpl;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
@ -12,28 +12,29 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Map;
/** /**
* *
*/ */
@Api(tags = "门店", description = "提供门店相关的API") @Api(tags = "032-了解场馆", description = "提供门店相关的API")
@RestController @RestController
@RequestMapping("/api/merchan") @RequestMapping("/api/store")
public class MerchantController { public class StoreController {
@Resource @Resource
private YjMerchantServiceImpl merchantService; private YjStoreServiceImpl merchantService;
/** /**
* + * +
* @param merchan * @param map
* @return * @return
*/ */
@ApiOperation(value = "创始人+企业简介+门店列表") @ApiOperation(value = "创始人+企业简介+门店列表")
@PostMapping("/getList") @PostMapping("/getList")
public RestResponse getList(@RequestBody YjMerchant merchan){ public RestResponse getList(@RequestBody Map map){
YjMerchant m=merchantService.getOne(new QueryWrapper<YjMerchant>() YjStore m=merchantService.getOne(new QueryWrapper<YjStore>()
.select("id,enterprise_name,address,phone,founder,profile") .select("id,enterprise_name,address,phone,founder,profile")
.eq("id",merchan.getId())); .eq("id",map.get("visitStore")));
return new RestResponse().setSuccess(true).setMessage("成功").setData(m); return new RestResponse().setSuccess(true).setMessage("成功").setData(m);
} }

@ -0,0 +1,46 @@
package com.ruoyi.web.controller.basic;
import cn.hutool.crypto.SecureUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Arrays;
@RestController
public class WeChatController {
@Value("${wechat.token}")
String TOKEN;
/**
*
* @param signature
* @param timestamp
* @param nonce
* @param echostr
* @return
*/
@GetMapping("")
public String check(@RequestParam("signature") String signature,
@RequestParam("timestamp") String timestamp,
@RequestParam("nonce") String nonce,
@RequestParam("echostr") String echostr){
return this.check1(signature,timestamp,nonce,echostr);
}
public String check1(String signature,String timestamp,String nonce,String echostr) {
String[] arr = new String[]{TOKEN,timestamp,nonce};
Arrays.sort(arr);
StringBuilder content = new StringBuilder();
for (String s : arr) {
content.append(s);
}
String temp = SecureUtil.sha1(content.toString());
if (temp.equals(signature)){
return echostr;
}
return null;
}
}

@ -0,0 +1,62 @@
package com.ruoyi.web.controller.basic.dto;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.annotation.Excel.ColumnType;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ApiModel(value = "AppLoginUser", description = "app登录用户信息")
@Data
public class AppLoginUser
{
private static final long serialVersionUID = 1L;
/** 用户ID */
@ApiModelProperty("用户ID")
@Excel(name = "用户序号", cellType = ColumnType.NUMERIC, prompt = "用户编号")
private Long userId;
/** 用户账号 */
@ApiModelProperty("用户昵称")
@Excel(name = "登录名称")
private String userName;
/** 用户昵称 */
@ApiModelProperty("用户名称")
@Excel(name = "用户名称")
private String nickName;
/** 用户邮箱 */
@ApiModelProperty("用户邮箱")
@Excel(name = "用户邮箱")
private String email;
/** 手机号码 */
@ApiModelProperty("手机号码")
@Excel(name = "手机号码")
private String phonenumber;
/** 用户性别 */
@ApiModelProperty("用户性别0=男,1=女,2=未知")
@Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知")
private String sex;
/** 用户头像 */
@ApiModelProperty("用户头像")
private String avatar;
/** 角色ID */
@ApiModelProperty("角色ID顾问103 教练104 店长105 普通用户107")
private Long roleId;
/** 所属门店id */
@ApiModelProperty("所属门店id")
private String venId;
@ApiModelProperty("设备id")
private String registerId;
@ApiModelProperty("访问/浏览门店id")
private String visitStore;
}

@ -1,223 +0,0 @@
package com.ruoyi.web.controller.common;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.file.FileUploadUtils;
import com.ruoyi.common.utils.file.FileUtils;
import com.ruoyi.framework.config.ServerConfig;
import com.ruoyi.shop.service.impl.YjLinkServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
/**
*
*
* @author ruoyi
*/
@RestController
@RequestMapping("/common")
public class CommonController
{
private static final Logger log = LoggerFactory.getLogger(CommonController.class);
@Autowired
private ServerConfig serverConfig;
@Autowired
private YjLinkServiceImpl yjLinkService;
private static final String FILE_DELIMETER = ",";
/**
*
*
* @param fileName
* @param delete
*/
@GetMapping("/download")
public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request)
{
try
{
if (!FileUtils.checkAllowDownload(fileName))
{
throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName));
}
String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1);
String filePath = RuoYiConfig.getDownloadPath() + fileName;
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
FileUtils.setAttachmentResponseHeader(response, realFileName);
FileUtils.writeBytes(filePath, response.getOutputStream());
if (delete)
{
FileUtils.deleteFile(filePath);
}
}
catch (Exception e)
{
log.error("下载文件失败", e);
}
}
/**
*
*/
@PostMapping("/upload")
public AjaxResult uploadFile(MultipartFile file) throws Exception
{
try
{
// 上传文件路径
String filePath = RuoYiConfig.getUploadPath();
// 上传并返回新文件名称
String fileName = FileUploadUtils.upload(filePath, file);
yjLinkService.add(fileName,"picture");
String url = serverConfig.getUrl() + fileName;
AjaxResult ajax = AjaxResult.success();
ajax.put("url", url);
ajax.put("fileName", fileName);
ajax.put("newFileName", FileUtils.getName(fileName));
ajax.put("originalFilename", file.getOriginalFilename());
return ajax;
}
catch (Exception e)
{
return AjaxResult.error(e.getMessage());
}
}
@PostMapping("/uploadVideo")
public AjaxResult uploadVideo(MultipartFile file) throws Exception
{
try
{
// 上传文件路径
String filePath = RuoYiConfig.getUploadPath();
// 上传并返回新文件名称
String fileName = FileUploadUtils.upload(filePath, file);
yjLinkService.add(fileName,"video");
String url = serverConfig.getUrl() + fileName;
AjaxResult ajax = AjaxResult.success();
ajax.put("url", url);
ajax.put("fileName", fileName);
ajax.put("newFileName", FileUtils.getName(fileName));
ajax.put("originalFilename", file.getOriginalFilename());
return ajax;
}
catch (Exception e)
{
return AjaxResult.error(e.getMessage());
}
}
@PostMapping("/uploadSp")
public AjaxResult uploadFileSp(MultipartFile file) throws Exception
{
try
{
// 上传文件路径
String filePath = RuoYiConfig.getUploadPath();
// 上传并返回新文件名称
String fileName = FileUploadUtils.upload(filePath, file);
yjLinkService.add(fileName,"video");
String url = serverConfig.getUrl() + fileName;
AjaxResult ajax = AjaxResult.success();
ajax.put("url", url);
ajax.put("fileName", fileName);
ajax.put("newFileName", FileUtils.getName(fileName));
ajax.put("originalFilename", file.getOriginalFilename());
return ajax;
}
catch (Exception e)
{
return AjaxResult.error(e.getMessage());
}
}
/**
*
*/
@PostMapping("/uploads")
public AjaxResult uploadFiles(List<MultipartFile> files) throws Exception
{
try
{
// 上传文件路径
String filePath = RuoYiConfig.getUploadPath();
List<String> urls = new ArrayList<String>();
List<String> fileNames = new ArrayList<String>();
List<String> newFileNames = new ArrayList<String>();
List<String> originalFilenames = new ArrayList<String>();
for (MultipartFile file : files)
{
// 上传并返回新文件名称
String fileName = FileUploadUtils.upload(filePath, file);
yjLinkService.add(fileName,"picture");
String url = serverConfig.getUrl() + fileName;
urls.add(url);
fileNames.add(fileName);
newFileNames.add(FileUtils.getName(fileName));
originalFilenames.add(file.getOriginalFilename());
}
AjaxResult ajax = AjaxResult.success();
ajax.put("urls", StringUtils.join(urls, FILE_DELIMETER));
ajax.put("fileNames", StringUtils.join(fileNames, FILE_DELIMETER));
ajax.put("newFileNames", StringUtils.join(newFileNames, FILE_DELIMETER));
ajax.put("originalFilenames", StringUtils.join(originalFilenames, FILE_DELIMETER));
return ajax;
}
catch (Exception e)
{
return AjaxResult.error(e.getMessage());
}
}
/**
*
*/
@GetMapping("/download/resource")
public void resourceDownload(String resource, HttpServletRequest request, HttpServletResponse response)
throws Exception
{
try
{
if (!FileUtils.checkAllowDownload(resource))
{
throw new Exception(StringUtils.format("资源文件({})非法,不允许下载。 ", resource));
}
// 本地资源路径
String localPath = RuoYiConfig.getProfile();
// 数据库资源地址
String downloadPath = localPath + StringUtils.substringAfter(resource, Constants.RESOURCE_PREFIX);
// 下载名称
String downloadName = StringUtils.substringAfterLast(downloadPath, "/");
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
FileUtils.setAttachmentResponseHeader(response, downloadName);
FileUtils.writeBytes(downloadPath, response.getOutputStream());
}
catch (Exception e)
{
log.error("下载文件失败", e);
}
}
}

@ -0,0 +1,32 @@
package com.ruoyi.web.controller.course;
import com.ruoyi.RestResponse;
import com.ruoyi.common.core.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
@Api(tags = "040-教练", description = "获取商品及课程分类")
@RestController
@RequestMapping("/api/course/category")
public class CourseController extends BaseController {
// @Autowired
// ContextServicelmpl contextService;
// @Autowired
// SysUserServiceImpl userService;
@ApiOperation("商品及课程类型列表")
@PostMapping(value = "/getList")
public RestResponse findList(@RequestBody Map<String, Object> params) {
// List<Context> list =contextService.getList(params);
return new RestResponse().setSuccess(true).setMessage("成功");
}
}

@ -0,0 +1,40 @@
package com.ruoyi.web.controller.im;
import com.ruoyi.im.domain.vo.UploadImageVO;
import com.ruoyi.im.service.FileService;
import com.ruoyi.web.controller.im.result.Result;
import com.ruoyi.web.controller.im.result.ResultUtils;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.logging.log4j.util.Strings;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
@Slf4j
@RestController
@Tag(name = "文件上传")
@RequiredArgsConstructor
@RequestMapping("/api")
public class FileController {
private final FileService fileService;
@Operation(summary = "上传图片", description = "上传图片,上传后返回原图和缩略图的url")
@PostMapping("/image/upload")
public Result<UploadImageVO> uploadImage(@RequestParam("file") MultipartFile file,
@RequestParam(defaultValue = "true") Boolean isPermanent) {
return ResultUtils.success(fileService.uploadImage(file,isPermanent));
}
@Operation(summary = "上传文件", description = "上传文件上传后返回文件url")
@PostMapping("/file/upload")
public Result<String> uploadFile(@RequestParam("file") MultipartFile file) {
return ResultUtils.success(fileService.uploadFile(file), Strings.EMPTY);
}
}

@ -0,0 +1,65 @@
package com.ruoyi.web.controller.im;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.basic.service.YjAppUserService;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.core.domain.entity.AppUser;
import com.ruoyi.im.domain.vo.FriendVO;
import com.ruoyi.im.domain.vo.UserVO;
import com.ruoyi.im.service.FriendService;
import com.ruoyi.web.controller.im.result.Result;
import com.ruoyi.web.controller.im.result.ResultUtils;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotNull;
import java.util.List;
@RestController
@RequestMapping("/api/friend")
@RequiredArgsConstructor
public class FriendController {
private final FriendService friendService;
private final YjAppUserService appUserService;
@GetMapping("/list")
@Operation(summary = "好友列表", description = "获取好友列表")
public Result<List<FriendVO>> findFriends() {
return ResultUtils.success(friendService.findFriends());
}
@GetMapping("/find/{phonenumber}")
@Operation(summary = "查找用户", description = "根据电话查找用户")
public Result<UserVO> findById(@NotNull @PathVariable("phonenumber") String phonenumber) {
//权限:课程顾问 店长 教练 查询客户信息
//todo
AppUser appUser=appUserService.getOne(new QueryWrapper<AppUser>().eq("phoneNumber",phonenumber));
ResultUtils.success(appUser);
return null;
}
@RepeatSubmit
@PostMapping("/add")
@Operation(summary = "添加好友", description = "双方建立好友关系")
public Result addFriend(@NotNull(message = "好友id不可为空") @RequestParam Long friendId) {
friendService.addFriend(friendId);
return ResultUtils.success();
}
@GetMapping("/find/{friendId}")
@Operation(summary = "查找好友信息", description = "查找好友信息")
public Result<FriendVO> findFriend(@NotNull(message = "好友id不可为空") @PathVariable Long friendId) {
return ResultUtils.success(friendService.findFriend(friendId));
}
@DeleteMapping("/delete/{friendId}")
@Operation(summary = "删除好友", description = "解除好友关系")
public Result delFriend(@NotNull(message = "好友id不可为空") @PathVariable Long friendId) {
friendService.delFriend(friendId);
return ResultUtils.success();
}
}

@ -0,0 +1,73 @@
package com.ruoyi.web.controller.im;
import com.ruoyi.im.domain.dto.PrivateMessageDTO;
import com.ruoyi.im.domain.vo.FriendVO;
import com.ruoyi.im.domain.vo.PrivateMessageVO;
import com.ruoyi.im.service.FriendService;
import com.ruoyi.im.service.PrivateMessageService;
import com.ruoyi.web.controller.im.result.Result;
import com.ruoyi.web.controller.im.result.ResultUtils;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.io.IOException;
import java.util.List;
@Tag(name = "私聊消息")
@RestController
@RequestMapping("/api/message/private")
@RequiredArgsConstructor
public class PrivateMessageController {
private final PrivateMessageService privateMessageService;
@PostMapping("/send")
@Operation(summary = "发送消息", description = "发送私聊消息")
public Result<PrivateMessageVO> sendMessage(@Valid @RequestBody PrivateMessageDTO vo) {
return ResultUtils.success(privateMessageService.sendMessage(vo));
}
/**
*
* @param minId id
* @return
*/
@GetMapping("/pullOfflineMessage")
@Operation(summary = "拉取离线消息", description = "拉取离线消息,消息将通过webscoket异步推送")
public Result pullOfflineMessage(@RequestParam Long minId) {
privateMessageService.pullOfflineMessage(minId);
return ResultUtils.success();
}
@PutMapping("/readed")
@Operation(summary = "消息已读", description = "将会话中接收的消息状态置为已读")
public Result readedMessage(@RequestParam Long friendId) {
privateMessageService.readedMessage(friendId);
return ResultUtils.success();
}
@GetMapping("/maxReadedId")
@Operation(summary = "获取最大已读消息的id", description = "获取某个会话中已读消息的最大id")
public Result<Long> getMaxReadedId(@RequestParam Long friendId) {
return ResultUtils.success(privateMessageService.getMaxReadedId(friendId));
}
// @GetMapping("/history")
@Operation(summary = "查询聊天记录", description = "查询聊天记录")
public Result<List<PrivateMessageVO>> recallMessage(
@NotNull(message = "好友id不能为空") @RequestParam Long friendId,
@NotNull(message = "页码不能为空") @RequestParam Long page,
@NotNull(message = "size不能为空") @RequestParam Long size) {
return ResultUtils.success(privateMessageService.findHistoryMessage(friendId, page, size));
}
}

@ -0,0 +1,34 @@
package com.ruoyi.web.controller.im;
import com.ruoyi.common.config.WebrtcConfig;
import com.ruoyi.im.domain.vo.SystemConfigVO;
import com.ruoyi.web.controller.im.result.ResultUtils;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.web.controller.im.result.Result;
/**
* @author: blue
* @date: 2024-06-10
* @version: 1.0
*/
@Tag(name = "系统相关")
@RestController
@RequestMapping("/system")
@RequiredArgsConstructor
public class SystemController {
private final WebrtcConfig webrtcConfig;
@GetMapping("/config")
@Operation(summary = "加载系统配置", description = "加载系统配置")
public Result<SystemConfigVO> loadConfig() {
return ResultUtils.success(new SystemConfigVO(webrtcConfig));
}
}

@ -0,0 +1,76 @@
package com.ruoyi.web.controller.im;
import com.ruoyi.im.service.WebrtcPrivateService;
import com.ruoyi.web.controller.im.result.ResultUtils;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.web.controller.im.result.Result;
@Tag(name = "单人通话")
@RestController
@RequestMapping("/webrtc/private")
@RequiredArgsConstructor
public class WebrtcPrivateController {
private final WebrtcPrivateService webrtcPrivateService;
@Operation(summary = "呼叫视频通话")
@PostMapping("/call")
public Result call(@RequestParam Long uid, @RequestParam(defaultValue = "video") String mode,
@RequestBody String offer) {
webrtcPrivateService.call(uid, mode, offer);
return ResultUtils.success();
}
@Operation(summary = "接受视频通话")
@PostMapping("/accept")
public Result accept(@RequestParam Long uid, @RequestBody String answer) {
webrtcPrivateService.accept(uid, answer);
return ResultUtils.success();
}
@Operation(summary = "拒绝视频通话")
@PostMapping("/reject")
public Result reject(@RequestParam Long uid) {
webrtcPrivateService.reject(uid);
return ResultUtils.success();
}
@Operation(summary = "取消呼叫")
@PostMapping("/cancel")
public Result cancel(@RequestParam Long uid) {
webrtcPrivateService.cancel(uid);
return ResultUtils.success();
}
@Operation(summary = "呼叫失败")
@PostMapping("/failed")
public Result failed(@RequestParam Long uid, @RequestParam String reason) {
webrtcPrivateService.failed(uid, reason);
return ResultUtils.success();
}
@Operation(summary = "挂断")
@PostMapping("/handup")
public Result handup(@RequestParam Long uid) {
webrtcPrivateService.handup(uid);
return ResultUtils.success();
}
@PostMapping("/candidate")
@Operation(summary = "同步candidate")
public Result candidate(@RequestParam Long uid, @RequestBody String candidate) {
webrtcPrivateService.candidate(uid, candidate);
return ResultUtils.success();
}
@Operation(summary = "心跳")
@PostMapping("/heartbeat")
public Result heartbeat(@RequestParam Long uid) {
webrtcPrivateService.heartbeat(uid);
return ResultUtils.success();
}
}

@ -0,0 +1,14 @@
package com.ruoyi.web.controller.im.result;
import lombok.Data;
@Data
public class Result<T> {
private int code;
private String message;
private T data;
}

@ -0,0 +1,64 @@
package com.ruoyi.web.controller.im.result;
import com.ruoyi.common.im.enums.ResultCode;
public final class ResultUtils {
private ResultUtils() {
}
public static <T> Result<T> success() {
Result<T> result = new Result<>();
result.setCode(ResultCode.SUCCESS.getCode());
result.setMessage(ResultCode.SUCCESS.getMsg());
return result;
}
public static <T> Result<T> success(T data) {
Result<T> result = new Result<>();
result.setCode(ResultCode.SUCCESS.getCode());
result.setMessage(ResultCode.SUCCESS.getMsg());
result.setData(data);
return result;
}
public static <T> Result<T> success(T data, String messsage) {
Result<T> result = new Result<>();
result.setCode(ResultCode.SUCCESS.getCode());
result.setMessage(messsage);
result.setData(data);
return result;
}
public static <T> Result<T> success(String messsage) {
Result<T> result = new Result<>();
result.setCode(ResultCode.SUCCESS.getCode());
result.setMessage(messsage);
return result;
}
public static <T> Result<T> error(Integer code, String messsage) {
Result<T> result = new Result<>();
result.setCode(code);
result.setMessage(messsage);
return result;
}
public static <T> Result<T> error(ResultCode resultCode, String messsage) {
Result<T> result = new Result<>();
result.setCode(resultCode.getCode());
result.setMessage(messsage);
return result;
}
public static <T> Result<T> error(ResultCode resultCode) {
Result<T> result = new Result<>();
result.setCode(resultCode.getCode());
result.setMessage(resultCode.getMsg());
return result;
}
}

@ -0,0 +1,21 @@
package com.ruoyi.web.controller.im.session;
import com.ruoyi.common.im.model.IMSessionInfo;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class UserSession extends IMSessionInfo {
/**
*
*/
private String userName;
/**
*
*/
private String nickName;
}

@ -0,0 +1,34 @@
package com.ruoyi.web.controller.im.session;
import com.ruoyi.common.im.model.IMUserInfo;
import lombok.Data;
import java.util.LinkedList;
import java.util.List;
/**
* @author: Blue
* @date: 2024-06-01
* @version: 1.0
*/
@Data
public class WebrtcGroupSession {
/**
*
*/
private IMUserInfo host;
/**
*
*/
private List<WebrtcUserInfo> userInfos;
/**
*
*/
private List<IMUserInfo> inChatUsers = new LinkedList<>();
}

@ -0,0 +1,39 @@
package com.ruoyi.web.controller.im.session;
import lombok.Data;
/*
* webrtc
* @Author Blue
* @Date 2022/10/21
*/
@Data
public class WebrtcPrivateSession {
/**
* id
*/
private Long callerId;
/**
*
*/
private Integer callerTerminal;
/**
* id
*/
private Long acceptorId;
/**
*
*/
private Integer acceptorTerminal;
/**
*
*/
private String mode;
/**
*
*/
private Long chatTimeStamp;
}

@ -0,0 +1,28 @@
package com.ruoyi.web.controller.im.session;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
* @author: Blue
* @date: 2024-06-02
* @version: 1.0
*/
@Data
@Schema(description = "用户信息")
public class WebrtcUserInfo {
@Schema(description = "用户id")
private Long id;
@Schema(description = "用户昵称")
private String nickName;
@Schema(description = "用户头像")
private String headImage;
@Schema(description = "是否开启摄像头")
private Boolean isCamera;
@Schema(description = "是否开启麦克风")
private Boolean isMicroPhone;
}

@ -0,0 +1,143 @@
package com.ruoyi.web.controller.login;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.basic.domain.dto.StoreDto;
import com.ruoyi.basic.mapper.YjStoreMapper;
import com.ruoyi.basic.service.impl.YjAppUserServiceImpl;
import com.ruoyi.common.constant.CacheConstants;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.AppUser;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.AppUserLoginBody;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.framework.web.service.AppLoginService;
import com.ruoyi.basic.domain.YjStore;
import com.ruoyi.basic.service.impl.YjStoreServiceImpl;
import com.ruoyi.mall.util.PayConstants;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Api(tags = "01-登录与验证")
@RestController
@RequestMapping("/api")
public class AppLoginController {
@Autowired
private AppLoginService appLoginService;
@Autowired
private YjAppUserServiceImpl appUserService;
@Autowired
private YjStoreMapper storeMapper;
/**
*
* @param loginBody
* @return
*/
@PostMapping("/register")
public AjaxResult register(@RequestBody AppUserLoginBody loginBody){
AppUser appUser=new AppUser();
appUser.setPhoneNumber("15004070930");
appUser.setPassword(SecurityUtils.encryptPassword(loginBody.getPassword()));
appUser.setStatus(1);
appUser.setVisitStore("14b8471ff004e074e928d795053b4233");
appUserService.save(appUser);
//todo 默认visitstore
//todo openid
return null;
}
/**
* ++
* @param loginBody
* @return
*/
@ApiOperation("登录")
@PostMapping("/login")
public AjaxResult login(@RequestBody AppUserLoginBody loginBody){
AjaxResult ajax = AjaxResult.success();
String token=appLoginService.login(loginBody.getPhonenumber(),loginBody.getPassword(),loginBody.getCode(),loginBody.getUuid(),loginBody.getRegisterId(),loginBody.getMiniAppCode());
ajax.put(Constants.TOKEN, token);
return ajax;
}
/**
*
*
* @return
*/
@ApiOperation(value = "获取用户信息")
@GetMapping("/getInfo")
public AjaxResult getInfo()
{
AppUser user = SecurityUtils.getAppLoginUser().getAppUser();
AjaxResult ajax = AjaxResult.success();
ajax.put("appLoginUser", user);
ajax.put("visitStore",getIndex(user.getVisitStore()));
return ajax;
}
@Resource
private YjStoreServiceImpl merchantService;
public Map<String,String> getIndex(String visitStore){
YjStore yjStore;
Map m=new HashMap();
if (StrUtil.isNotEmpty(visitStore)){
yjStore=merchantService.getById(visitStore);
}else {
yjStore= merchantService.list().get(0);
}
m.put("address",yjStore.getAddress());
m.put("storeName",yjStore.getStoreName());
m.put("phone",yjStore.getPhone());
m.put("banner",yjStore.getBanner());
m.put("id",yjStore.getId());
return m;
}
/**
*
* @param address使
* @return
*/
@GetMapping("/getStoreList")
public AjaxResult getStoreList(String address) {
AjaxResult ajax = AjaxResult.success();
List<StoreDto> dtoList= storeMapper.getListForLogin();
dtoList.forEach(l->{
l.setChildList(storeMapper.getChilds(l.getId()));
});
ajax.put("storeList",dtoList);
return ajax;
}
}

@ -1,6 +1,9 @@
package com.ruoyi.web.controller.common; package com.ruoyi.web.controller.login;
import com.google.code.kaptcha.Producer; import com.google.code.kaptcha.Producer;
import com.ruoyi.basic.domain.YjStore;
import com.ruoyi.basic.domain.dto.StoreDto;
import com.ruoyi.basic.mapper.YjStoreMapper;
import com.ruoyi.common.config.RuoYiConfig; import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.constant.CacheConstants; import com.ruoyi.common.constant.CacheConstants;
import com.ruoyi.common.constant.Constants; import com.ruoyi.common.constant.Constants;
@ -16,9 +19,10 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletResponse;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
/** /**
@ -40,11 +44,13 @@ public class CaptchaController
@Autowired @Autowired
private ISysConfigService configService; private ISysConfigService configService;
/** /**
* *
*/ */
@GetMapping("/captchaImage") @GetMapping("/captchaImage")
public AjaxResult getCode(HttpServletResponse response) throws IOException public AjaxResult getCode() throws IOException
{ {
AjaxResult ajax = AjaxResult.success(); AjaxResult ajax = AjaxResult.success();
boolean captchaEnabled = configService.selectCaptchaEnabled(); boolean captchaEnabled = configService.selectCaptchaEnabled();
@ -92,4 +98,6 @@ public class CaptchaController
ajax.put("img", Base64.encode(os.toByteArray())); ajax.put("img", Base64.encode(os.toByteArray()));
return ajax; return ajax;
} }
} }

@ -1,21 +1,18 @@
package com.ruoyi.web.controller.app_shop; package com.ruoyi.web.controller.mall;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.ruoyi.RestResponse; import com.ruoyi.RestResponse;
import com.ruoyi.shop.domain.ShopAddress; import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.shop.mapper.ShopAddressMapper; import com.ruoyi.mall.domain.MemberAddress;
import com.ruoyi.shop.service.ShopAddressService; import com.ruoyi.mall.mapper.MemberAddressMapper;
import com.ruoyi.mall.service.MemberAddressService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -30,17 +27,22 @@ import java.util.List;
@Api(tags = "用户地址", description = "提供用户地址相关的API") @Api(tags = "用户地址", description = "提供用户地址相关的API")
@RestController @RestController
@RequestMapping("/api/address") @RequestMapping("/api/address")
public class ShopAddressController { public class MemberAddressController {
@Resource @Resource
private ShopAddressMapper mapper; private MemberAddressMapper mapper;
@Resource @Resource
private ShopAddressService service; private MemberAddressService service;
@ApiOperation("地址list")
@GetMapping("/addressList")
public RestResponse getAddressList(){
return new RestResponse().setSuccess(true).setData(service.getAddressList());
}
@ApiOperation("新增收货地址") @ApiOperation("新增收货地址")
@PostMapping("/add") @PostMapping("/add")
public RestResponse add(@RequestBody ShopAddress address, HttpServletRequest request){ public RestResponse add(@RequestBody MemberAddress address){
Long userId= Long.parseLong(request.getAttribute("userId").toString()); Long userId= SecurityUtils.getAppLoginUser().getAppUser().getId();
address.setUserId(userId); address.setUserId(userId);
if (address.getIsDefault()){ if (address.getIsDefault()){
changeDefault(userId); changeDefault(userId);
@ -50,13 +52,13 @@ public class ShopAddressController {
} }
@ApiOperation("收货地址列表") @ApiOperation("收货地址列表")
@PostMapping("/list") @PostMapping("/memberAddressList")
public RestResponse list(HttpServletRequest request){ public RestResponse list(){
Long userId= Long.parseLong(request.getAttribute("userId").toString()); Long userId= SecurityUtils.getAppLoginUser().getAppUser().getId();
List<String> columns=new ArrayList<>(); List<String> columns=new ArrayList<>();
columns.add("add_time"); columns.add("add_time");
columns.add("is_default"); columns.add("is_default");
List<ShopAddress> list=mapper.selectList(new QueryWrapper<ShopAddress>() List<MemberAddress> list=mapper.selectList(new QueryWrapper<MemberAddress>()
.eq("user_id",userId) .eq("user_id",userId)
.orderByDesc(columns)); .orderByDesc(columns));
return new RestResponse().setSuccess(true).setMessage("成功").setData(list); return new RestResponse().setSuccess(true).setMessage("成功").setData(list);
@ -64,8 +66,8 @@ public class ShopAddressController {
@ApiOperation("修改收货地址") @ApiOperation("修改收货地址")
@PostMapping("/edit") @PostMapping("/edit")
public RestResponse edit(@RequestBody ShopAddress address, HttpServletRequest request){ public RestResponse edit(@RequestBody MemberAddress address){
Long userId= Long.parseLong(request.getAttribute("userId").toString()); Long userId= SecurityUtils.getAppLoginUser().getAppUser().getId();
if (address.getIsDefault()){ if (address.getIsDefault()){
changeDefault(userId); changeDefault(userId);
} }
@ -75,13 +77,16 @@ public class ShopAddressController {
@ApiOperation("删除收货地址") @ApiOperation("删除收货地址")
@PostMapping("/del") @PostMapping("/del")
public RestResponse del(@RequestBody ShopAddress address){ public RestResponse del(@RequestBody MemberAddress address){
mapper.deleteById(address.getId()); mapper.deleteById(address.getId());
return new RestResponse().setSuccess(true).setMessage("成功"); return new RestResponse().setSuccess(true).setMessage("成功");
} }
public void changeDefault(Long userId){ public void changeDefault(Long userId){
service.update(new UpdateWrapper<ShopAddress>().set("is_default",false).eq("user_id",userId)); service.update(new UpdateWrapper<MemberAddress>().set("is_default",false).eq("user_id",userId));
} }
} }

@ -0,0 +1,88 @@
package com.ruoyi.web.controller.mall;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.mall.domain.MemberCart;
import com.ruoyi.mall.domain.query.MemberCartQuery;
import com.ruoyi.mall.domain.vo.MemberCartVO;
import com.ruoyi.mall.service.impl.MemberCartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/api/cart")
public class MemberCartController {
@Autowired
private MemberCartService memberCartService;
/**
*
*
* @return
*/
@PostMapping("add")
public ResponseEntity<Integer> add(@RequestBody MemberCart memberCart) {
return ResponseEntity.ok(memberCartService.insert(memberCart));
}
/**
*
*
* @return
*/
@GetMapping("list")
public ResponseEntity<List<MemberCartVO>> list() {
MemberCartQuery query = new MemberCartQuery();
query.setMemberId(SecurityUtils.getAppLoginUser().getAppUserId());
return ResponseEntity.ok(memberCartService.selectList(query, null));
}
/**
*
*
* @return
*/
@GetMapping("goodscount")
public ResponseEntity<Integer> goodscount() {
return ResponseEntity.ok(memberCartService.mineCartNum());
}
/**
* id
*
* @return
*/
@GetMapping("cart-ids")
public ResponseEntity<List<Long>> cartIds() {
return ResponseEntity.ok(memberCartService.mineCartIds());
}
/**
*
*
* @return
*/
@PostMapping("modify")
public ResponseEntity<Integer> modify(@Valid @RequestBody MemberCart memberCart) {
return ResponseEntity.ok(memberCartService.update(memberCart));
}
/**
*
*
* @return
*/
@DeleteMapping("remove")
public ResponseEntity<Integer> remove(@RequestBody Map<String,List<Long>> map) {
List<Long> ids=map.get("ids");
return ResponseEntity.ok(memberCartService.deleteByIds(ids));
}
}

@ -0,0 +1,246 @@
package com.ruoyi.web.controller.mall;
import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.redis.RedisService;
import com.ruoyi.common.enums.AftersaleStatus;
import com.ruoyi.common.enums.OrderStatus;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.mall.domain.dto.DeliveryReq;
import com.ruoyi.mall.domain.form.*;
import com.ruoyi.mall.domain.order.Aftersale;
import com.ruoyi.mall.domain.order.Order;
import com.ruoyi.mall.domain.vo.*;
import com.ruoyi.mall.service.impl.AftersaleService;
import com.ruoyi.mall.service.impl.OrderService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
@RestController
@RequestMapping("/api/order")
@Slf4j
public class OrderController {
@Autowired
private RedisService redisService;
@Autowired
private OrderService service;
@Autowired
private AftersaleService aftersaleService;
@ApiOperation("下单")
@PostMapping("/add")
public ResponseEntity<Long> submit(@RequestBody OrderSubmitForm form) {
Long memberId = SecurityUtils.getAppLoginUser().getAppUserId();
String redisKey = "app_order_add" + memberId;
String redisValue = memberId + "_" + System.currentTimeMillis();
try{
redisService.lock(redisKey, redisValue, 60);
return ResponseEntity.ok(service.submit(form));
}catch (Exception e){
log.info("创建订单方法异常", e);
throw new RuntimeException(e.getMessage());
}finally {
try {
redisService.unLock(redisKey, redisValue);
} catch (Exception e) {
e.printStackTrace();
}
}
}
@ApiOperation("下单前校验")
@PostMapping("/addOrderCheck")
public ResponseEntity<OrderCalcVO> addOrderCheck(@RequestBody OrderCreateForm orderCreateForm){
return ResponseEntity.ok(service.addOrderCheck(orderCreateForm));
}
@ApiOperation("订单支付")
@PostMapping("/orderPay")
public ResponseEntity<OrderPayVO> orderPay(@RequestBody OrderPayForm req){
log.info("订单支付","提交的数据:"+ JSONObject.toJSONString(req));
String redisKey = "app_oms_order_pay_"+req.getPayId();
String redisValue = req.getPayId()+"_"+System.currentTimeMillis();
try {
redisService.lock(redisKey, redisValue, 60);
req.setMemberId(SecurityUtils.getAppLoginUser().getAppUserId());
return ResponseEntity.ok(service.orderPay(req));
}catch (Exception e){
log.error("支付方法异常", e);
throw new RuntimeException(e.getMessage());
}finally {
try{
redisService.unLock(redisKey,redisValue);
}catch (Exception e){
log.error("",e);
}
}
}
@ApiOperation("订单列表")
@GetMapping("/page")
public ResponseEntity<PageImpl<AppOrderVO>> orderPage(Integer status, Pageable pageable){
return ResponseEntity.ok(service.orderPage(status, SecurityUtils.getAppLoginUser().getAppUserId(), pageable));
}
@ApiOperation("订单详情")
@GetMapping("/orderDetail")
public ResponseEntity<AppOrderVO> orderDetail(@RequestParam(required = false) Long orderId){
if (orderId == null){
throw new RuntimeException("系统繁忙");
}
return ResponseEntity.ok(service.orderDetail(orderId));
}
@ApiOperation("确认收货")
@GetMapping("/orderComplete")
public ResponseEntity<String> orderComplete(Long orderId) {
log.info("确认收货订单id"+orderId);
String redisKey = "app_oms_order_complete_"+orderId;
String redisValue = orderId+"_"+System.currentTimeMillis();
try{
redisService.lock(redisKey,redisValue,60);
return ResponseEntity.ok(service.orderComplete(orderId));
}catch (Exception e){
log.error("确认收货异常",e);
throw new RuntimeException(e.getMessage());
}finally {
try{
redisService.unLock(redisKey,redisValue);
}catch (Exception e){
log.error("",e);
}
}
}
@ApiOperation("订单数量统计")
@GetMapping("/countOrder")
public ResponseEntity<CountOrderVO> orderNumCount(){
Long memberId = SecurityUtils.getAppLoginUser().getAppUserId();
return ResponseEntity.ok(service.orderNumCount(memberId));
}
@ApiOperation("取消订单")
@PostMapping("/orderCancel")
public ResponseEntity<String> orderCancel(@RequestBody CancelOrderForm request){
String redisKey = "app_oms_order_cancel_"+ request.getIdList().get(0);
String redisValue = request.getIdList().get(0)+"_"+System.currentTimeMillis();
try{
redisService.lock(redisKey,redisValue,60);
return ResponseEntity.ok(service.orderBatchCancel(request, SecurityUtils.getAppLoginUser().getAppUserId()));
}catch (Exception e){
log.error("订单取消方法异常",e);
throw new RuntimeException("订单取消失败");
}finally {
try {
redisService.unLock(redisKey,redisValue);
}catch (Exception e){
log.error("",e);
}
}
}
@ApiOperation("申请售后")
@PostMapping("/applyRefund")
public ResponseEntity<Boolean> applyRefund(@RequestBody ApplyRefundForm applyRefundForm){
String redisKey = "app_oms_order_applyRefund_" + applyRefundForm.getOrderId();
String redisValue = applyRefundForm.getOrderId() + "_" + System.currentTimeMillis();
try{
redisService.lock(redisKey, redisValue, 60);
Order order = service.applyRefund(applyRefundForm);
// 如果是未发货,系统自动退款
if (order.getStatus().equals(OrderStatus.NOT_DELIVERED.getType())) {
DealWithAftersaleForm req = new DealWithAftersaleForm();
req.setOrderId(applyRefundForm.getOrderId());
req.setOptType(1);
aftersaleService.dealWith(req, order.getMemberId(), "直接发起退款");
}
return ResponseEntity.ok(true);
}catch (Exception e){
log.error("申请售后发生异常",e);
throw new RuntimeException(e.getMessage());
}finally {
try {
redisService.unLock(redisKey, redisValue);
} catch (Exception e) {
log.error("", e);
}
}
}
@ApiOperation("取消售后")
@GetMapping("/cancelRefund")
public ResponseEntity<String> cancelRefund(Long orderId){
log.info("【取消售后】订单id" + orderId);
String redisKey = "app_oms_order_cancelRefund_" + orderId;
String redisValue = orderId + "_" + System.currentTimeMillis();
try{
redisService.lock(redisKey, redisValue, 60);
return ResponseEntity.ok(service.cancelRefund(orderId));
}catch (Exception e){
log.error("取消售后发生异常",e);
throw new RuntimeException(e.getMessage());
}finally {
try {
redisService.unLock(redisKey, redisValue);
} catch (Exception e) {
log.error("", e);
}
}
}
@ApiOperation("售后订单详情")
@GetMapping("/refundOrderDetail")
public ResponseEntity<AftersaleRefundInfoVO> refundOrderDetail(@RequestParam Long orderId){
return ResponseEntity.ok(service.refundOrderDetail(orderId));
}
@ApiOperation("用户提交退货单号")
@PostMapping("/aftersale/delivery")
public AjaxResult delivery(@RequestBody @Valid DeliveryReq req){
log.info("用户提交退货单号","提交的数据:"+JSONObject.toJSONString(req));
String redisKey = "app_oms_order_delivery_"+req.getOrderId();
String redisValue = req.getOrderId()+"_"+System.currentTimeMillis();
try {
redisService.lock(redisKey, redisValue, 60);
Order order = service.selectById(req.getOrderId());
Aftersale aftersale = aftersaleService.queryAfterSale(req.getOrderId());
if(order == null || aftersale == null){
return AjaxResult.error("未查询到订单信息");
}
//仅退款不需要退货
if(aftersale.getType() == 1){
return AjaxResult.error("仅退款不需要退货");
}
if(aftersale.getStatus() != AftersaleStatus.WAIT.getType()){
return AjaxResult.error("当前状态不可退货");
}
//更新退款单
aftersale.setRefundWpCode(req.getDeliveryCompanyCode());
aftersale.setRefundWaybillCode(req.getDeliverySn());
aftersaleService.update(aftersale);
return AjaxResult.success();
}catch (Exception e){
log.error("用户提交退货单号异常", e);
return AjaxResult.error("提交发货信息失败");
}finally {
try{
redisService.unLock(redisKey,redisValue);
}catch (Exception e){
log.error("",e);
}
}
}
}

@ -0,0 +1,143 @@
package com.ruoyi.web.controller.mall;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.ruoyi.mall.domain.dto.PayNotifyMessageDTO;
import com.ruoyi.mall.service.impl.OrderService;
import com.ruoyi.web.core.config.WechatPayConfig;
import com.wechat.pay.java.core.Config;
import com.wechat.pay.java.core.notification.NotificationConfig;
import com.wechat.pay.java.core.notification.NotificationParser;
import com.wechat.pay.java.core.notification.RequestParam;
import com.wechat.pay.java.service.partnerpayments.jsapi.model.Transaction;
import com.wechat.pay.java.service.refund.model.RefundNotification;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Controller
*
* @author sjm
* @date 2023-04-05
*/
@Api(description ="微信回调接口列表")
@RestController
@RequestMapping("/no-auth/wechat")
public class PayNotifyController {
private static final Logger log = LoggerFactory.getLogger(PayNotifyController.class);
@Autowired
private OrderService OrderService;
// @Autowired
// private AftersaleService aftersaleService;
private final SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
/**
*
* @param request
* @throws IOException
*/
@PostMapping("/notify")
public void weChatPayNotify(HttpServletRequest request) throws Exception {
log.info("收到了微信支付回调");
// 从请求头中获取信息
String timestamp = request.getHeader("Wechatpay-Timestamp");
String nonce = request.getHeader("Wechatpay-Nonce");
String signature = request.getHeader("Wechatpay-Signature");
String singType = request.getHeader("Wechatpay-Signature-Type");
String wechatPayCertificateSerialNumber = request.getHeader("Wechatpay-Serial");
// 拿到请求体body
StringBuilder requestBody = new StringBuilder();
String line;
BufferedReader reader;
reader = request.getReader();
while (null != (line = reader.readLine())) {
requestBody.append(line);
}
// 构造 RequestParam
RequestParam requestParam = new RequestParam.Builder()
.serialNumber(wechatPayCertificateSerialNumber)
.nonce(nonce)
.signature(signature)
.timestamp(timestamp)
.body(requestBody.toString())
.build();
// log.info("【requestParam】" + JSONObject.toJSON(requestParam));
//初始化了 RSAAutoCertificateConfig
Config config = WechatPayConfig.getInstance();
// 初始化解析器 NotificationParser
NotificationParser parser = new NotificationParser((NotificationConfig) config);
// 以支付通知回调为例,验签、解密并转换成 Transaction
Transaction transaction = parser.parse(requestParam, Transaction.class);
// log.info("【transaction】" + JSONObject.toJSON(transaction));
PayNotifyMessageDTO message = new PayNotifyMessageDTO();
message.setOutTradeNo(Long.valueOf(transaction.getOutTradeNo()));
message.setMemberId(Long.valueOf(transaction.getAttach()));
message.setTradeStatus(transaction.getTradeState());
if (StrUtil.isEmpty(transaction.getSuccessTime())){
throw new RuntimeException("微信支付回调失败");
}
message.setPayTime(formatter.parse(transaction.getSuccessTime().substring(0, transaction.getSuccessTime().indexOf("+"))));
message.setTradeNo(transaction.getTransactionId());
// OrderService.payCallBack(message);
}
// @ApiOperation(value = "微信退款回调")
// @PostMapping("/weChatRefundNotify")
// public void weChatRefundNotify(HttpServletRequest request) throws IOException {
// log.info("收到了微信支付退款回调");
// // 从请求头中获取信息
// String timestamp = request.getHeader("Wechatpay-Timestamp");
// String nonce = request.getHeader("Wechatpay-Nonce");
// String signature = request.getHeader("Wechatpay-Signature");
// String singType = request.getHeader("Wechatpay-Signature-Type");
// String wechatPayCertificateSerialNumber = request.getHeader("Wechatpay-Serial");
// // 拿到请求体body
// StringBuilder requestBody = new StringBuilder();
// String line;
// BufferedReader reader;
// reader = request.getReader();
// while (null != (line = reader.readLine())) {
// requestBody.append(line);
// }
// // 构造 RequestParam
// RequestParam requestParam = new RequestParam.Builder()
// .serialNumber(wechatPayCertificateSerialNumber)
// .nonce(nonce)
// .signature(signature)
// .timestamp(timestamp)
// .body(requestBody.toString())
// .build();
//
// log.info("【requestParam】" + JSONObject.toJSON(requestParam));
// //初始化了 RSAAutoCertificateConfig
// Config config = WechatPayConfig.getInstance();
// // 初始化解析器 NotificationParser
// NotificationParser parser = new NotificationParser((NotificationConfig) config);
//
// //获取退款回调的信息
// RefundNotification refundInfo = parser.parse(requestParam, RefundNotification.class);
// aftersaleService.refundOrderExc(refundInfo);
// }
}

@ -0,0 +1,86 @@
package com.ruoyi.web.controller.mall;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.ruoyi.RestResponse;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.mall.domain.MemberAddress;
import com.ruoyi.mall.domain.Product;
import com.ruoyi.mall.domain.query.ProductQuery;
import com.ruoyi.mall.domain.vo.AppProductVO;
import com.ruoyi.mall.domain.vo.ProductDetailVO;
import com.ruoyi.mall.domain.vo.ProductVO;
import com.ruoyi.mall.mapper.MemberAddressMapper;
import com.ruoyi.mall.service.MemberAddressService;
import com.ruoyi.mall.service.ProductCategoryService;
import com.ruoyi.mall.service.impl.ProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* <p>
*
* </p>
*
* @author xn
* @since 2022-09-29
*/
@Api(tags = "app商品信息")
@RestController
@RequestMapping("/api/product")
public class ProductController {
@Autowired
private ProductCategoryService categoryService;
@Autowired
private ProductService productService;
/**
* list
* @return
*/
@ApiOperation("商品类别")
@PostMapping("/categoryList")
public RestResponse getAddressList(@RequestBody Map params){
return new RestResponse().setSuccess(true).setData(categoryService.getProductCategorys(params));
}
/**
*
* @param query {categoryIdsearch} null
* @param page
* @return
*/
@PostMapping("/list")
public ResponseEntity<Page<AppProductVO>> queryGoodByPage(@RequestBody ProductQuery query, Pageable page) {
List<Product> pageRes = productService.selectList(query, page);
return ResponseEntity.ok(new PageImpl<>(BeanUtil.copyToList(pageRes,AppProductVO.class), page, ((com.github.pagehelper.Page) pageRes).getTotal()));
}
/**
*
* @param id
* @return
*/
@GetMapping("/detail/{id}")
public ResponseEntity<ProductDetailVO> queryDetail(@PathVariable Long id) {
ProductDetailVO detail = productService.queryDetail(id);
return ResponseEntity.ok(detail);
}
}

@ -1,120 +0,0 @@
package com.ruoyi.web.controller.monitor;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisCallback;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.constant.CacheConstants;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.SysCache;
/**
*
*
* @author ruoyi
*/
@RestController
@RequestMapping("/monitor/cache")
public class CacheController
{
@Autowired
private RedisTemplate<String, String> redisTemplate;
private final static List<SysCache> caches = new ArrayList<SysCache>();
{
caches.add(new SysCache(CacheConstants.LOGIN_TOKEN_KEY, "用户信息"));
caches.add(new SysCache(CacheConstants.SYS_CONFIG_KEY, "配置信息"));
caches.add(new SysCache(CacheConstants.SYS_DICT_KEY, "数据字典"));
caches.add(new SysCache(CacheConstants.CAPTCHA_CODE_KEY, "验证码"));
caches.add(new SysCache(CacheConstants.REPEAT_SUBMIT_KEY, "防重提交"));
caches.add(new SysCache(CacheConstants.RATE_LIMIT_KEY, "限流处理"));
caches.add(new SysCache(CacheConstants.PWD_ERR_CNT_KEY, "密码错误次数"));
}
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
@GetMapping()
public AjaxResult getInfo() throws Exception
{
Properties info = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info());
Properties commandStats = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info("commandstats"));
Object dbSize = redisTemplate.execute((RedisCallback<Object>) connection -> connection.dbSize());
Map<String, Object> result = new HashMap<>(3);
result.put("info", info);
result.put("dbSize", dbSize);
List<Map<String, String>> pieList = new ArrayList<>();
commandStats.stringPropertyNames().forEach(key -> {
Map<String, String> data = new HashMap<>(2);
String property = commandStats.getProperty(key);
data.put("name", StringUtils.removeStart(key, "cmdstat_"));
data.put("value", StringUtils.substringBetween(property, "calls=", ",usec"));
pieList.add(data);
});
result.put("commandStats", pieList);
return AjaxResult.success(result);
}
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
@GetMapping("/getNames")
public AjaxResult cache()
{
return AjaxResult.success(caches);
}
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
@GetMapping("/getKeys/{cacheName}")
public AjaxResult getCacheKeys(@PathVariable String cacheName)
{
Set<String> cacheKeys = redisTemplate.keys(cacheName + "*");
return AjaxResult.success(cacheKeys);
}
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
@GetMapping("/getValue/{cacheName}/{cacheKey}")
public AjaxResult getCacheValue(@PathVariable String cacheName, @PathVariable String cacheKey)
{
String cacheValue = redisTemplate.opsForValue().get(cacheKey);
SysCache sysCache = new SysCache(cacheName, cacheKey, cacheValue);
return AjaxResult.success(sysCache);
}
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
@DeleteMapping("/clearCacheName/{cacheName}")
public AjaxResult clearCacheName(@PathVariable String cacheName)
{
Collection<String> cacheKeys = redisTemplate.keys(cacheName + "*");
redisTemplate.delete(cacheKeys);
return AjaxResult.success();
}
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
@DeleteMapping("/clearCacheKey/{cacheKey}")
public AjaxResult clearCacheKey(@PathVariable String cacheKey)
{
redisTemplate.delete(cacheKey);
return AjaxResult.success();
}
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
@DeleteMapping("/clearCacheAll")
public AjaxResult clearCacheAll()
{
Collection<String> cacheKeys = redisTemplate.keys("*");
redisTemplate.delete(cacheKeys);
return AjaxResult.success();
}
}

@ -1,27 +0,0 @@
package com.ruoyi.web.controller.monitor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.framework.web.domain.Server;
/**
*
*
* @author ruoyi
*/
@RestController
@RequestMapping("/monitor/server")
public class ServerController
{
@PreAuthorize("@ss.hasPermi('monitor:server:list')")
@GetMapping()
public AjaxResult getInfo() throws Exception
{
Server server = new Server();
server.copyTo();
return AjaxResult.success(server);
}
}

@ -1,82 +0,0 @@
package com.ruoyi.web.controller.monitor;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.service.SysPasswordService;
import com.ruoyi.system.domain.SysLogininfor;
import com.ruoyi.system.service.ISysLogininforService;
/**
* 访
*
* @author ruoyi
*/
@RestController
@RequestMapping("/monitor/logininfor")
public class SysLogininforController extends BaseController
{
@Autowired
private ISysLogininforService logininforService;
@Autowired
private SysPasswordService passwordService;
@PreAuthorize("@ss.hasPermi('monitor:logininfor:list')")
@GetMapping("/list")
public TableDataInfo list(SysLogininfor logininfor)
{
startPage();
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
return getDataTable(list);
}
@Log(title = "登录日志", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('monitor:logininfor:export')")
@PostMapping("/export")
public void export(HttpServletResponse response, SysLogininfor logininfor)
{
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
ExcelUtil<SysLogininfor> util = new ExcelUtil<SysLogininfor>(SysLogininfor.class);
util.exportExcel(response, list, "登录日志");
}
@PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')")
@Log(title = "登录日志", businessType = BusinessType.DELETE)
@DeleteMapping("/{infoIds}")
public AjaxResult remove(@PathVariable Long[] infoIds)
{
return toAjax(logininforService.deleteLogininforByIds(infoIds));
}
@PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')")
@Log(title = "登录日志", businessType = BusinessType.CLEAN)
@DeleteMapping("/clean")
public AjaxResult clean()
{
logininforService.cleanLogininfor();
return success();
}
@PreAuthorize("@ss.hasPermi('monitor:logininfor:unlock')")
@Log(title = "账户解锁", businessType = BusinessType.OTHER)
@GetMapping("/unlock/{userName}")
public AjaxResult unlock(@PathVariable("userName") String userName)
{
passwordService.clearLoginRecordCache(userName);
return success();
}
}

@ -1,69 +0,0 @@
package com.ruoyi.web.controller.monitor;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SysOperLog;
import com.ruoyi.system.service.ISysOperLogService;
/**
*
*
* @author ruoyi
*/
@RestController
@RequestMapping("/monitor/operlog")
public class SysOperlogController extends BaseController
{
@Autowired
private ISysOperLogService operLogService;
@PreAuthorize("@ss.hasPermi('monitor:operlog:list')")
@GetMapping("/list")
public TableDataInfo list(SysOperLog operLog)
{
startPage();
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
return getDataTable(list);
}
@Log(title = "操作日志", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('monitor:operlog:export')")
@PostMapping("/export")
public void export(HttpServletResponse response, SysOperLog operLog)
{
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
ExcelUtil<SysOperLog> util = new ExcelUtil<SysOperLog>(SysOperLog.class);
util.exportExcel(response, list, "操作日志");
}
@Log(title = "操作日志", businessType = BusinessType.DELETE)
@PreAuthorize("@ss.hasPermi('monitor:operlog:remove')")
@DeleteMapping("/{operIds}")
public AjaxResult remove(@PathVariable Long[] operIds)
{
return toAjax(operLogService.deleteOperLogByIds(operIds));
}
@Log(title = "操作日志", businessType = BusinessType.CLEAN)
@PreAuthorize("@ss.hasPermi('monitor:operlog:remove')")
@DeleteMapping("/clean")
public AjaxResult clean()
{
operLogService.cleanOperLog();
return AjaxResult.success();
}
}

@ -1,92 +0,0 @@
package com.ruoyi.web.controller.monitor;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.constant.CacheConstants;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.SysUserOnline;
import com.ruoyi.system.service.ISysUserOnlineService;
/**
* 线
*
* @author ruoyi
*/
@RestController
@RequestMapping("/monitor/online")
public class SysUserOnlineController extends BaseController
{
@Autowired
private ISysUserOnlineService userOnlineService;
@Autowired
private RedisCache redisCache;
@PreAuthorize("@ss.hasPermi('monitor:online:list')")
@GetMapping("/list")
public TableDataInfo list(String ipaddr, String userName)
{
Collection<String> keys = redisCache.keys(CacheConstants.LOGIN_TOKEN_KEY + "*");
List<SysUserOnline> userOnlineList = new ArrayList<SysUserOnline>();
for (String key : keys)
{
LoginUser user = redisCache.getCacheObject(key);
if (StringUtils.isNotEmpty(ipaddr) && StringUtils.isNotEmpty(userName))
{
if (StringUtils.equals(ipaddr, user.getIpaddr()) && StringUtils.equals(userName, user.getUsername()))
{
userOnlineList.add(userOnlineService.selectOnlineByInfo(ipaddr, userName, user));
}
}
else if (StringUtils.isNotEmpty(ipaddr))
{
if (StringUtils.equals(ipaddr, user.getIpaddr()))
{
userOnlineList.add(userOnlineService.selectOnlineByIpaddr(ipaddr, user));
}
}
else if (StringUtils.isNotEmpty(userName) && StringUtils.isNotNull(user.getUser()))
{
if (StringUtils.equals(userName, user.getUsername()))
{
userOnlineList.add(userOnlineService.selectOnlineByUserName(userName, user));
}
}
else
{
userOnlineList.add(userOnlineService.loginUserToUserOnline(user));
}
}
Collections.reverse(userOnlineList);
userOnlineList.removeAll(Collections.singleton(null));
return getDataTable(userOnlineList);
}
/**
* 退
*/
@PreAuthorize("@ss.hasPermi('monitor:online:forceLogout')")
@Log(title = "在线用户", businessType = BusinessType.FORCE)
@DeleteMapping("/{tokenId}")
public AjaxResult forceLogout(@PathVariable String tokenId)
{
redisCache.deleteObject(CacheConstants.LOGIN_TOKEN_KEY + tokenId);
return AjaxResult.success();
}
}

@ -1,38 +0,0 @@
package com.ruoyi.web.controller.search;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.search.domain.MemberUserWo;
import com.ruoyi.search.service.MemberUserServicelmpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/member_user")
public class MemberUserController extends BaseController {
@Autowired
MemberUserServicelmpl memberuserService;
@GetMapping("/list")
public TableDataInfo list(@RequestParam Map map) {
startPage();
map.put("stroreId", SecurityUtils.getMerchanId());
List<MemberUserWo> list = memberuserService.getList(map);
return getDataTable(list);
}
// @PostMapping(value = "/getList")
// public RestResponse findList1(@RequestBody Map<String, Object> params) {
// List<MemberUser> list =memberuserService.findList((String) params.get("memberName"));
// return new RestResponse().setSuccess(true).setMessage("成功").setData(list);
//
// }
}

@ -1,134 +0,0 @@
package com.ruoyi.web.controller.system;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SysConfig;
import com.ruoyi.system.service.ISysConfigService;
/**
*
*
* @author ruoyi
*/
@RestController
@RequestMapping("/system/config")
public class SysConfigController extends BaseController
{
@Autowired
private ISysConfigService configService;
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:config:list')")
@GetMapping("/list")
public TableDataInfo list(SysConfig config)
{
startPage();
List<SysConfig> list = configService.selectConfigList(config);
return getDataTable(list);
}
@Log(title = "参数管理", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:config:export')")
@PostMapping("/export")
public void export(HttpServletResponse response, SysConfig config)
{
List<SysConfig> list = configService.selectConfigList(config);
ExcelUtil<SysConfig> util = new ExcelUtil<SysConfig>(SysConfig.class);
util.exportExcel(response, list, "参数数据");
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:config:query')")
@GetMapping(value = "/{configId}")
public AjaxResult getInfo(@PathVariable Long configId)
{
return AjaxResult.success(configService.selectConfigById(configId));
}
/**
*
*/
@GetMapping(value = "/configKey/{configKey}")
public AjaxResult getConfigKey(@PathVariable String configKey)
{
return AjaxResult.success(configService.selectConfigByKey(configKey));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:config:add')")
@Log(title = "参数管理", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody SysConfig config)
{
if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config)))
{
return AjaxResult.error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在");
}
config.setCreateBy(getUsername());
return toAjax(configService.insertConfig(config));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:config:edit')")
@Log(title = "参数管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysConfig config)
{
if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config)))
{
return AjaxResult.error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在");
}
config.setUpdateBy(getUsername());
return toAjax(configService.updateConfig(config));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:config:remove')")
@Log(title = "参数管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{configIds}")
public AjaxResult remove(@PathVariable Long[] configIds)
{
configService.deleteConfigByIds(configIds);
return success();
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:config:remove')")
@Log(title = "参数管理", businessType = BusinessType.CLEAN)
@DeleteMapping("/refreshCache")
public AjaxResult refreshCache()
{
configService.resetConfigCache();
return AjaxResult.success();
}
}

@ -1,147 +0,0 @@
package com.ruoyi.web.controller.system;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.service.ISysDeptService;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.stream.Collectors;
/**
*
*
* @author ruoyi
*/
@RestController
@RequestMapping("/system/dept")
public class SysDeptController extends BaseController
{
@Autowired
private ISysDeptService deptService;
@Resource
private TokenService tokenService;
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:dept:list')")
@GetMapping("/list")
public AjaxResult list(SysDept dept, HttpServletRequest request){
SysUser loginUser=tokenService.getLoginUser(request).getUser();
dept.setMerchanId(loginUser.getMerchantId());
List<SysDept> depts = deptService.selectDeptList(dept);
if (!loginUser.isAdmin()){
depts=depts.stream().filter(d->d.getParentId() !=0l).collect(Collectors.toList());
}
return AjaxResult.success(depts);
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:dept:list')")
@GetMapping("/list/exclude/{deptId}")
public AjaxResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId, HttpServletRequest request){
SysUser loginUser=tokenService.getLoginUser(request).getUser();
SysDept dept=new SysDept();
dept.setMerchanId(loginUser.getMerchantId());
List<SysDept> depts = deptService.selectDeptList(dept);
depts.removeIf(d -> d.getDeptId().intValue() == deptId || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""));
return AjaxResult.success(depts);
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:dept:query')")
@GetMapping(value = "/{deptId}")
public AjaxResult getInfo(@PathVariable Long deptId)
{
deptService.checkDeptDataScope(deptId);
return AjaxResult.success(deptService.selectDeptById(deptId));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:dept:add')")
@Log(title = "部门管理", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody SysDept dept){
SysDept d=new SysDept();
d.setParentId(0l);
d.setMerchanId(SecurityUtils.getMerchanId());
dept.setParentId(deptService.selectDeptList(d).get(0).getDeptId());
dept.setMerchanId(SecurityUtils.getMerchanId());
if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept)))
{
return AjaxResult.error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
}
dept.setCreateBy(getUsername());
return toAjax(deptService.insertDept(dept));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:dept:edit')")
@Log(title = "部门管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysDept dept)
{
Long deptId = dept.getDeptId();
deptService.checkDeptDataScope(deptId);
if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept)))
{
return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
}
else if (dept.getParentId().equals(deptId))
{
return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
}
else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) && deptService.selectNormalChildrenDeptById(deptId) > 0)
{
return AjaxResult.error("该部门包含未停用的子部门!");
}
dept.setUpdateBy(getUsername());
return toAjax(deptService.updateDept(dept));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:dept:remove')")
@Log(title = "部门管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{deptId}")
public AjaxResult remove(@PathVariable Long deptId)
{
if (deptService.hasChildByDeptId(deptId))
{
return AjaxResult.error("存在下级部门,不允许删除");
}
if (deptService.checkDeptExistUser(deptId))
{
return AjaxResult.error("部门存在用户,不允许删除");
}
deptService.checkDeptDataScope(deptId);
return toAjax(deptService.deleteDeptById(deptId));
}
}

@ -1,139 +0,0 @@
package com.ruoyi.web.controller.system;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysDictData;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.shop.domain.YjMerchant;
import com.ruoyi.shop.service.impl.YjMerchantServiceImpl;
import com.ruoyi.system.service.ISysDictDataService;
import com.ruoyi.system.service.ISysDictTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
/**
*
*
* @author ruoyi
*/
@RestController
@RequestMapping("/system/dict/data")
public class SysDictDataController extends BaseController
{
@Autowired
private ISysDictDataService dictDataService;
@Autowired
private ISysDictTypeService dictTypeService;
@Resource
private YjMerchantServiceImpl merchantService;
@PreAuthorize("@ss.hasPermi('system:dict:list')")
@GetMapping("/list")
public TableDataInfo list(SysDictData dictData)
{
dictData.setMerchantId(SecurityUtils.getMerchanId());
startPage();
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
return getDataTable(list);
}
@Log(title = "字典数据", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:dict:export')")
@PostMapping("/export")
public void export(HttpServletResponse response, SysDictData dictData)
{
dictData.setMerchantId(SecurityUtils.getMerchanId());
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
ExcelUtil<SysDictData> util = new ExcelUtil<SysDictData>(SysDictData.class);
util.exportExcel(response, list, "字典数据");
}
/**
*
*/
// @PreAuthorize("@ss.hasPermi('system:dict:query')")
@PreAuthorize("@ss.hasPermi('system:dict:list')")
@GetMapping(value = "/{dictCode}")
public AjaxResult getInfo(@PathVariable Long dictCode)
{
return AjaxResult.success(dictDataService.selectDictDataById(dictCode));
}
/**
*
*/
@GetMapping(value = "/type/{dictType}")
public AjaxResult dictType(@PathVariable String dictType)
{
List<SysDictData> data = dictTypeService.selectDictDataByType(dictType);
if (StringUtils.isNull(data))
{
data = new ArrayList<SysDictData>();
}
return AjaxResult.success(data);
}
/**
*
*/
// @PreAuthorize("@ss.hasPermi('system:dict:add')")
// @Log(title = "字典数据", businessType = BusinessType.INSERT)
@PreAuthorize("@ss.hasPermi('system:dict:list')")
@PostMapping
public AjaxResult add(@Validated @RequestBody SysDictData dict)
{
dict.setCreateBy(getUsername());
List<YjMerchant> list= merchantService.list();
for (YjMerchant m:list){
dict.setMerchantId(m.getId());
dictDataService.insertDictData(dict);
}
return toAjax(1);
}
/**
*
*/
// @PreAuthorize("@ss.hasPermi('system:dict:edit')")
// @Log(title = "字典数据", businessType = BusinessType.UPDATE)
@PreAuthorize("@ss.hasPermi('system:dict:list')")
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysDictData dict)
{
if (!SecurityUtils.getUserId().equals(1)) {
SysDictData d=new SysDictData();
d.setDictCode(dict.getDictCode());
d.setDictLabel(dict.getDictLabel());
return toAjax(dictDataService.updateDictData(d));
}
dict.setUpdateBy(getUsername());
return toAjax(dictDataService.updateDictData(dict));
}
/**
*
*/
// @PreAuthorize("@ss.hasPermi('system:dict:remove')")
// @Log(title = "字典类型", businessType = BusinessType.DELETE)
@PreAuthorize("@ss.hasPermi('system:dict:list')")
@DeleteMapping("/{dictCodes}")
public AjaxResult remove(@PathVariable Long[] dictCodes)
{
dictDataService.deleteDictDataByIds(dictCodes);
return success();
}
}

@ -1,134 +0,0 @@
package com.ruoyi.web.controller.system;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysDictType;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.mapper.SysDictTypeMapper;
import com.ruoyi.system.service.ISysDictTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
*
*
* @author ruoyi
*/
@RestController
@RequestMapping("/system/dict/type")
public class SysDictTypeController extends BaseController
{
@Autowired
private ISysDictTypeService dictTypeService;
@Resource
private SysDictTypeMapper dictTypeMapper;
@PreAuthorize("@ss.hasPermi('system:dict:list')")
@GetMapping("/list")
public TableDataInfo list(SysDictType dictType){
startPage();
List<SysDictType> list ;
if (SecurityUtils.getMerchanId().equals("1")){
list = dictTypeService.selectDictTypeList(dictType);
}else {
list = dictTypeMapper.selectDictTypeList1(dictType);
}
return getDataTable(list);
}
@Log(title = "字典类型", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:dict:export')")
@PostMapping("/export")
public void export(HttpServletResponse response, SysDictType dictType)
{
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
ExcelUtil<SysDictType> util = new ExcelUtil<SysDictType>(SysDictType.class);
util.exportExcel(response, list, "字典类型");
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:dict:query')")
@GetMapping(value = "/{dictId}")
public AjaxResult getInfo(@PathVariable Long dictId)
{
return AjaxResult.success(dictTypeService.selectDictTypeById(dictId));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:dict:add')")
@Log(title = "字典类型", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody SysDictType dict){
if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict)))
{
return AjaxResult.error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在");
}
dict.setCreateBy(getUsername());
return toAjax(dictTypeService.insertDictType(dict));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:dict:edit')")
@Log(title = "字典类型", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysDictType dict)
{
if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict)))
{
return AjaxResult.error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在");
}
dict.setUpdateBy(getUsername());
return toAjax(dictTypeService.updateDictType(dict));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
@Log(title = "字典类型", businessType = BusinessType.DELETE)
@DeleteMapping("/{dictIds}")
public AjaxResult remove(@PathVariable Long[] dictIds)
{
dictTypeService.deleteDictTypeByIds(dictIds);
return success();
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
@Log(title = "字典类型", businessType = BusinessType.CLEAN)
@DeleteMapping("/refreshCache")
public AjaxResult refreshCache()
{
dictTypeService.resetDictCache();
return AjaxResult.success();
}
/**
*
*/
@GetMapping("/optionselect")
public AjaxResult optionselect()
{
List<SysDictType> dictTypes = dictTypeService.selectDictTypeAll();
return AjaxResult.success(dictTypes);
}
}

@ -1,29 +0,0 @@
package com.ruoyi.web.controller.system;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.utils.StringUtils;
/**
*
*
* @author ruoyi
*/
@RestController
public class SysIndexController
{
/** 系统基础配置 */
@Autowired
private RuoYiConfig ruoyiConfig;
/**
* 访
*/
@RequestMapping("/")
public String index()
{
return StringUtils.format("欢迎使用{}后台管理框架当前版本v{},请通过前端地址访问。", ruoyiConfig.getName(), ruoyiConfig.getVersion());
}
}

@ -1,86 +0,0 @@
package com.ruoyi.web.controller.system;
import java.util.List;
import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysMenu;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginBody;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.framework.web.service.SysLoginService;
import com.ruoyi.framework.web.service.SysPermissionService;
import com.ruoyi.system.service.ISysMenuService;
/**
*
*
* @author ruoyi
*/
@RestController
public class SysLoginController
{
@Autowired
private SysLoginService loginService;
@Autowired
private ISysMenuService menuService;
@Autowired
private SysPermissionService permissionService;
/**
*
*
* @param loginBody
* @return
*/
@PostMapping("/login")
public AjaxResult login(@RequestBody LoginBody loginBody)
{
AjaxResult ajax = AjaxResult.success();
// 生成令牌
String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
loginBody.getUuid());
ajax.put(Constants.TOKEN, token);
return ajax;
}
/**
*
*
* @return
*/
@GetMapping("getInfo")
public AjaxResult getInfo()
{
SysUser user = SecurityUtils.getLoginUser().getUser();
// 角色集合
Set<String> roles = permissionService.getRolePermission(user);
// 权限集合
Set<String> permissions = permissionService.getMenuPermission(user);
AjaxResult ajax = AjaxResult.success();
ajax.put("user", user);
ajax.put("roles", roles);
ajax.put("permissions", permissions);
return ajax;
}
/**
*
*
* @return
*/
@GetMapping("getRouters")
public AjaxResult getRouters()
{
Long userId = SecurityUtils.getUserId();
List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId);
return AjaxResult.success(menuService.buildMenus(menus));
}
}

@ -1,142 +0,0 @@
package com.ruoyi.web.controller.system;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysMenu;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.service.ISysMenuService;
/**
*
*
* @author ruoyi
*/
@RestController
@RequestMapping("/system/menu")
public class SysMenuController extends BaseController
{
@Autowired
private ISysMenuService menuService;
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:menu:list')")
@GetMapping("/list")
public AjaxResult list(SysMenu menu)
{
List<SysMenu> menus = menuService.selectMenuList(menu, getUserId());
return AjaxResult.success(menus);
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:menu:query')")
@GetMapping(value = "/{menuId}")
public AjaxResult getInfo(@PathVariable Long menuId)
{
return AjaxResult.success(menuService.selectMenuById(menuId));
}
/**
*
*/
@GetMapping("/treeselect")
public AjaxResult treeselect(SysMenu menu)
{
List<SysMenu> menus = menuService.selectMenuList(menu, getUserId());
return AjaxResult.success(menuService.buildMenuTreeSelect(menus));
}
/**
*
*/
@GetMapping(value = "/roleMenuTreeselect/{roleId}")
public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId)
{
List<SysMenu> menus = menuService.selectMenuList(getUserId());
AjaxResult ajax = AjaxResult.success();
ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId));
ajax.put("menus", menuService.buildMenuTreeSelect(menus));
return ajax;
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:menu:add')")
@Log(title = "菜单管理", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody SysMenu menu)
{
if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu)))
{
return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
}
else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath()))
{
return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败地址必须以http(s)://开头");
}
menu.setCreateBy(getUsername());
return toAjax(menuService.insertMenu(menu));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:menu:edit')")
@Log(title = "菜单管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysMenu menu)
{
if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu)))
{
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
}
else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath()))
{
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败地址必须以http(s)://开头");
}
else if (menu.getMenuId().equals(menu.getParentId()))
{
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,上级菜单不能选择自己");
}
menu.setUpdateBy(getUsername());
return toAjax(menuService.updateMenu(menu));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:menu:remove')")
@Log(title = "菜单管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{menuId}")
public AjaxResult remove(@PathVariable("menuId") Long menuId)
{
if (menuService.hasChildByMenuId(menuId))
{
return AjaxResult.error("存在子菜单,不允许删除");
}
if (menuService.checkMenuExistRole(menuId))
{
return AjaxResult.error("菜单已分配,不允许删除");
}
return toAjax(menuService.deleteMenuById(menuId));
}
}

@ -1,91 +0,0 @@
package com.ruoyi.web.controller.system;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysNotice;
import com.ruoyi.system.service.ISysNoticeService;
/**
*
*
* @author ruoyi
*/
@RestController
@RequestMapping("/system/notice")
public class SysNoticeController extends BaseController
{
@Autowired
private ISysNoticeService noticeService;
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:notice:list')")
@GetMapping("/list")
public TableDataInfo list(SysNotice notice)
{
startPage();
List<SysNotice> list = noticeService.selectNoticeList(notice);
return getDataTable(list);
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:notice:query')")
@GetMapping(value = "/{noticeId}")
public AjaxResult getInfo(@PathVariable Long noticeId)
{
return AjaxResult.success(noticeService.selectNoticeById(noticeId));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:notice:add')")
@Log(title = "通知公告", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody SysNotice notice)
{
notice.setCreateBy(getUsername());
return toAjax(noticeService.insertNotice(notice));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:notice:edit')")
@Log(title = "通知公告", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysNotice notice)
{
notice.setUpdateBy(getUsername());
return toAjax(noticeService.updateNotice(notice));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:notice:remove')")
@Log(title = "通知公告", businessType = BusinessType.DELETE)
@DeleteMapping("/{noticeIds}")
public AjaxResult remove(@PathVariable Long[] noticeIds)
{
return toAjax(noticeService.deleteNoticeByIds(noticeIds));
}
}

@ -1,133 +0,0 @@
package com.ruoyi.web.controller.system;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.domain.SysPost;
import com.ruoyi.system.service.ISysPostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
*
*
* @author ruoyi
*/
@RestController
@RequestMapping("/system/post")
public class SysPostController extends BaseController
{
@Autowired
private ISysPostService postService;
@Resource
private TokenService tokenService;
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:post:list')")
@GetMapping("/list")
public TableDataInfo list(SysPost post, HttpServletRequest request){
SysUser loginUser=tokenService.getLoginUser(request).getUser();
post.setMerchanId(loginUser.getMerchantId());
startPage();
List<SysPost> list = postService.selectPostList(post);
return getDataTable(list);
}
@Log(title = "岗位管理", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:post:export')")
@PostMapping("/export")
public void export(HttpServletResponse response, SysPost post)
{
List<SysPost> list = postService.selectPostList(post);
ExcelUtil<SysPost> util = new ExcelUtil<SysPost>(SysPost.class);
util.exportExcel(response, list, "岗位数据");
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:post:query')")
@GetMapping(value = "/{postId}")
public AjaxResult getInfo(@PathVariable Long postId)
{
return AjaxResult.success(postService.selectPostById(postId));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:post:add')")
@Log(title = "岗位管理", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody SysPost post, HttpServletRequest request){
SysUser loginUser=tokenService.getLoginUser(request).getUser();
post.setMerchanId(loginUser.getMerchantId());
if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post)))
{
return AjaxResult.error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在");
}
else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post)))
{
return AjaxResult.error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在");
}
post.setCreateBy(getUsername());
return toAjax(postService.insertPost(post));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:post:edit')")
@Log(title = "岗位管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysPost post)
{
if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post)))
{
return AjaxResult.error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在");
}
else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post)))
{
return AjaxResult.error("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在");
}
post.setUpdateBy(getUsername());
return toAjax(postService.updatePost(post));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:post:remove')")
@Log(title = "岗位管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{postIds}")
public AjaxResult remove(@PathVariable Long[] postIds)
{
return toAjax(postService.deletePostByIds(postIds));
}
/**
*
*/
@GetMapping("/optionselect")
public AjaxResult optionselect(HttpServletRequest request){
SysUser loginUser=tokenService.getLoginUser(request).getUser();
List<SysPost> posts = postService.selectPostAll(loginUser.getMerchantId());
return AjaxResult.success(posts);
}
}

@ -1,144 +0,0 @@
package com.ruoyi.web.controller.system;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.file.FileUploadUtils;
import com.ruoyi.common.utils.file.MimeTypeUtils;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.service.ISysUserService;
/**
*
*
* @author ruoyi
*/
@RestController
@RequestMapping("/system/user/profile")
public class SysProfileController extends BaseController
{
@Autowired
private ISysUserService userService;
@Autowired
private TokenService tokenService;
/**
*
*/
@GetMapping
public AjaxResult profile()
{
LoginUser loginUser = getLoginUser();
SysUser user = loginUser.getUser();
AjaxResult ajax = AjaxResult.success(user);
ajax.put("roleGroup", userService.selectUserRoleGroup(loginUser.getUsername()));
ajax.put("postGroup", userService.selectUserPostGroup(loginUser.getUsername()));
return ajax;
}
/**
*
*/
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult updateProfile(@RequestBody SysUser user)
{
LoginUser loginUser = getLoginUser();
SysUser sysUser = loginUser.getUser();
user.setUserName(sysUser.getUserName());
if (StringUtils.isNotEmpty(user.getPhonenumber())
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
{
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
}
if (StringUtils.isNotEmpty(user.getEmail())
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
{
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
}
user.setUserId(sysUser.getUserId());
user.setPassword(null);
user.setAvatar(null);
user.setDeptId(null);
if (userService.updateUserProfile(user) > 0)
{
// 更新缓存用户信息
sysUser.setNickName(user.getNickName());
sysUser.setPhonenumber(user.getPhonenumber());
sysUser.setEmail(user.getEmail());
sysUser.setSex(user.getSex());
tokenService.setLoginUser(loginUser);
return AjaxResult.success();
}
return AjaxResult.error("修改个人信息异常,请联系管理员");
}
/**
*
*/
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
@PutMapping("/updatePwd")
public AjaxResult updatePwd(String oldPassword, String newPassword)
{
LoginUser loginUser = getLoginUser();
String userName = loginUser.getUsername();
String password = loginUser.getPassword();
if (!SecurityUtils.matchesPassword(oldPassword, password))
{
return AjaxResult.error("修改密码失败,旧密码错误");
}
if (SecurityUtils.matchesPassword(newPassword, password))
{
return AjaxResult.error("新密码不能与旧密码相同");
}
if (userService.resetUserPwd(userName, SecurityUtils.encryptPassword(newPassword)) > 0)
{
// 更新缓存用户密码
loginUser.getUser().setPassword(SecurityUtils.encryptPassword(newPassword));
tokenService.setLoginUser(loginUser);
return AjaxResult.success();
}
return AjaxResult.error("修改密码异常,请联系管理员");
}
/**
*
*/
@Log(title = "用户头像", businessType = BusinessType.UPDATE)
@PostMapping("/avatar")
public AjaxResult avatar(@RequestParam("avatarfile") MultipartFile file) throws Exception
{
if (!file.isEmpty())
{
LoginUser loginUser = getLoginUser();
String avatar = FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), file, MimeTypeUtils.IMAGE_EXTENSION);
if (userService.updateUserAvatar(loginUser.getUsername(), avatar))
{
AjaxResult ajax = AjaxResult.success();
ajax.put("imgUrl", avatar);
// 更新缓存用户头像
loginUser.getUser().setAvatar(avatar);
tokenService.setLoginUser(loginUser);
return ajax;
}
}
return AjaxResult.error("上传图片异常,请联系管理员");
}
}

@ -1,38 +0,0 @@
package com.ruoyi.web.controller.system;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.model.RegisterBody;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.web.service.SysRegisterService;
import com.ruoyi.system.service.ISysConfigService;
/**
*
*
* @author ruoyi
*/
@RestController
public class SysRegisterController extends BaseController
{
@Autowired
private SysRegisterService registerService;
@Autowired
private ISysConfigService configService;
@PostMapping("/register")
public AjaxResult register(@RequestBody RegisterBody user)
{
if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser"))))
{
return error("当前系统没有开启注册功能!");
}
String msg = registerService.register(user);
return StringUtils.isEmpty(msg) ? success() : error(msg);
}
}

@ -1,260 +0,0 @@
package com.ruoyi.web.controller.system;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.service.SysPermissionService;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.domain.SysUserRole;
import com.ruoyi.system.service.ISysDeptService;
import com.ruoyi.system.service.ISysRoleService;
import com.ruoyi.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
*
*
* @author ruoyi
*/
@RestController
@RequestMapping("/system/role")
public class SysRoleController extends BaseController
{
@Autowired
private ISysRoleService roleService;
@Autowired
private TokenService tokenService;
@Autowired
private SysPermissionService permissionService;
@Autowired
private ISysUserService userService;
@Autowired
private ISysDeptService deptService;
@PreAuthorize("@ss.hasPermi('system:role:list')")
@GetMapping("/list")
public TableDataInfo list(SysRole role)
{
startPage();
List<SysRole> list = roleService.selectRoleList(role);
return getDataTable(list);
}
@Log(title = "角色管理", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:role:export')")
@PostMapping("/export")
public void export(HttpServletResponse response, SysRole role)
{
List<SysRole> list = roleService.selectRoleList(role);
ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class);
util.exportExcel(response, list, "角色数据");
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:role:query')")
@GetMapping(value = "/{roleId}")
public AjaxResult getInfo(@PathVariable Long roleId)
{
roleService.checkRoleDataScope(roleId);
return AjaxResult.success(roleService.selectRoleById(roleId));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:role:add')")
@Log(title = "角色管理", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody SysRole role)
{
if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role)))
{
return AjaxResult.error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在");
}
else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role)))
{
return AjaxResult.error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在");
}
role.setCreateBy(getUsername());
return toAjax(roleService.insertRole(role));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:role:edit')")
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysRole role)
{
roleService.checkRoleAllowed(role);
roleService.checkRoleDataScope(role.getRoleId());
if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role)))
{
return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在");
}
else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role)))
{
return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在");
}
role.setUpdateBy(getUsername());
if (roleService.updateRole(role) > 0)
{
// 更新缓存用户权限
LoginUser loginUser = getLoginUser();
if (StringUtils.isNotNull(loginUser.getUser()) && !loginUser.getUser().isAdmin())
{
loginUser.setPermissions(permissionService.getMenuPermission(loginUser.getUser()));
loginUser.setUser(userService.selectUserByUserName(loginUser.getUser().getUserName()));
tokenService.setLoginUser(loginUser);
}
return AjaxResult.success();
}
return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,请联系管理员");
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:role:edit')")
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PutMapping("/dataScope")
public AjaxResult dataScope(@RequestBody SysRole role)
{
roleService.checkRoleAllowed(role);
roleService.checkRoleDataScope(role.getRoleId());
return toAjax(roleService.authDataScope(role));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:role:edit')")
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PutMapping("/changeStatus")
public AjaxResult changeStatus(@RequestBody SysRole role)
{
roleService.checkRoleAllowed(role);
roleService.checkRoleDataScope(role.getRoleId());
role.setUpdateBy(getUsername());
return toAjax(roleService.updateRoleStatus(role));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:role:remove')")
@Log(title = "角色管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{roleIds}")
public AjaxResult remove(@PathVariable Long[] roleIds)
{
return toAjax(roleService.deleteRoleByIds(roleIds));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:role:query')")
@GetMapping("/optionselect")
public AjaxResult optionselect()
{
return AjaxResult.success(roleService.selectRoleAll());
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:role:list')")
@GetMapping("/authUser/allocatedList")
public TableDataInfo allocatedList(SysUser user)
{
startPage();
List<SysUser> list = userService.selectAllocatedList(user);
return getDataTable(list);
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:role:list')")
@GetMapping("/authUser/unallocatedList")
public TableDataInfo unallocatedList(SysUser user)
{
startPage();
List<SysUser> list = userService.selectUnallocatedList(user);
return getDataTable(list);
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:role:edit')")
@Log(title = "角色管理", businessType = BusinessType.GRANT)
@PutMapping("/authUser/cancel")
public AjaxResult cancelAuthUser(@RequestBody SysUserRole userRole)
{
return toAjax(roleService.deleteAuthUser(userRole));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:role:edit')")
@Log(title = "角色管理", businessType = BusinessType.GRANT)
@PutMapping("/authUser/cancelAll")
public AjaxResult cancelAuthUserAll(Long roleId, Long[] userIds)
{
return toAjax(roleService.deleteAuthUsers(roleId, userIds));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:role:edit')")
@Log(title = "角色管理", businessType = BusinessType.GRANT)
@PutMapping("/authUser/selectAll")
public AjaxResult selectAuthUserAll(Long roleId, Long[] userIds)
{
roleService.checkRoleDataScope(roleId);
return toAjax(roleService.insertAuthUsers(roleId, userIds));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:role:query')")
@GetMapping(value = "/deptTree/{roleId}")
public AjaxResult deptTree(@PathVariable("roleId") Long roleId, HttpServletRequest request){
SysUser loginUser=tokenService.getLoginUser(request).getUser();
SysDept dept=new SysDept();
dept.setMerchanId(loginUser.getMerchantId());
AjaxResult ajax = AjaxResult.success();
ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId));
ajax.put("depts", deptService.selectDeptTreeList(dept));
return ajax;
}
}

@ -1,290 +0,0 @@
package com.ruoyi.web.controller.system;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.mapper.SysRoleMapper;
import com.ruoyi.system.service.ISysDeptService;
import com.ruoyi.system.service.ISysPostService;
import com.ruoyi.system.service.ISysRoleService;
import com.ruoyi.system.service.ISysUserService;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.stream.Collectors;
/**
*
*
* @author ruoyi
*/
@RestController
@RequestMapping("/system/user")
public class SysUserController extends BaseController
{
@Autowired
private ISysUserService userService;
@Autowired
private ISysRoleService roleService;
@Autowired
private SysRoleMapper roleMapper;
@Autowired
private ISysDeptService deptService;
@Autowired
private ISysPostService postService;
@Resource
private TokenService tokenService;
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:user:list')")
@GetMapping("/list")
public TableDataInfo list(SysUser user){
if (!SecurityUtils.getMerchanId().equals("1")){
user.setMerchantId(SecurityUtils.getMerchanId());
}
startPage();
List<SysUser> list = userService.selectUserList(user);
if (!SecurityUtils.getMerchanId().equals("1")){
list.forEach(u->{
for (SysRole role:u.getRoles()){
if(role.isMerchant()){
u.setResponsible(true);
break;
}
}
});
}else {
list.forEach(u->{
for (SysRole role:u.getRoles()){
if(role.getRoleId() != null && 1L ==role.getRoleId()){
u.setResponsible(true);
break;
}
}
});
}
return getDataTable(list);
}
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:user:export')")
@PostMapping("/export")
public void export(HttpServletResponse response, SysUser user)
{
List<SysUser> list = userService.selectUserList(user);
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
util.exportExcel(response, list, "用户数据");
}
@Log(title = "用户管理", businessType = BusinessType.IMPORT)
@PreAuthorize("@ss.hasPermi('system:user:import')")
// @PostMapping("/importData")
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
{
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
List<SysUser> userList = util.importExcel(file.getInputStream());
String operName = getUsername();
String message = userService.importUser(userList, updateSupport, operName);
return AjaxResult.success(message);
}
@PostMapping("/importTemplate")
public void importTemplate(HttpServletResponse response)
{
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
util.importTemplateExcel(response, "用户数据");
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:user:query')")
@GetMapping(value = { "/", "/{userId}" })
public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId,HttpServletRequest request){
SysUser loginUser=tokenService.getLoginUser(request).getUser();
userService.checkUserDataScope(userId);
AjaxResult ajax = AjaxResult.success();
//todo 角色
// List<SysRole> roles = roleService.selectRoleAll();
List<SysRole> roles = roleMapper.selectRoleAll();
// ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
ajax.put("roles", SysUser.isAdmin(SecurityUtils.getUserId())?
roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList())
:
roles.stream().filter(r -> !r.isMerchant()).collect(Collectors.toList()));
//todo
// 岗位
ajax.put("posts", postService.selectPostAll(loginUser.getMerchantId()));
if (StringUtils.isNotNull(userId))
{
SysUser sysUser = userService.selectUserById(userId);
ajax.put(AjaxResult.DATA_TAG, sysUser);
ajax.put("postIds", postService.selectPostListByUserId(userId));
ajax.put("roleIds", sysUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList()));
}
return ajax;
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:user:add')")
@Log(title = "用户管理", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody SysUser user, HttpServletRequest request){
SysUser loginUser=tokenService.getLoginUser(request).getUser();
user.setMerchantId(loginUser.getMerchantId());
if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user.getUserName())))
{
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
}
else if (StringUtils.isNotEmpty(user.getPhonenumber())
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
{
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,手机号码已存在");
}
else if (StringUtils.isNotEmpty(user.getEmail())
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
{
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
}
user.setCreateBy(getUsername());
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
return toAjax(userService.insertUser(user));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:user:edit')")
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysUser user)
{
userService.checkUserAllowed(user);
userService.checkUserDataScope(user.getUserId());
if (StringUtils.isNotEmpty(user.getPhonenumber())
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
{
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
}
else if (StringUtils.isNotEmpty(user.getEmail())
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
{
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
}
user.setUpdateBy(getUsername());
return toAjax(userService.updateUser(user));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:user:remove')")
@Log(title = "用户管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{userIds}")
public AjaxResult remove(@PathVariable Long[] userIds)
{
if (ArrayUtils.contains(userIds, getUserId()))
{
return error("当前用户不能删除");
}
return toAjax(userService.deleteUserByIds(userIds));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:user:resetPwd')")
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
@PutMapping("/resetPwd")
public AjaxResult resetPwd(@RequestBody SysUser user)
{
userService.checkUserAllowed(user);
userService.checkUserDataScope(user.getUserId());
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
user.setUpdateBy(getUsername());
return toAjax(userService.resetPwd(user));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:user:edit')")
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
@PutMapping("/changeStatus")
public AjaxResult changeStatus(@RequestBody SysUser user)
{
userService.checkUserAllowed(user);
userService.checkUserDataScope(user.getUserId());
user.setUpdateBy(getUsername());
return toAjax(userService.updateUserStatus(user));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:user:query')")
@GetMapping("/authRole/{userId}")
public AjaxResult authRole(@PathVariable("userId") Long userId)
{
AjaxResult ajax = AjaxResult.success();
SysUser user = userService.selectUserById(userId);
List<SysRole> roles = roleService.selectRolesByUserId(userId);
ajax.put("user", user);
ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
return ajax;
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:user:edit')")
@Log(title = "用户管理", businessType = BusinessType.GRANT)
@PutMapping("/authRole")
public AjaxResult insertAuthRole(Long userId, Long[] roleIds)
{
userService.checkUserDataScope(userId);
userService.insertUserAuth(userId, roleIds);
return success();
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:user:list')")
@GetMapping("/deptTree")
public AjaxResult deptTree(SysDept dept){
if (!SecurityUtils.getMerchanId().equals("1")){
dept.setMerchanId(SecurityUtils.getMerchanId());
}
return AjaxResult.success(deptService.selectDeptTreeList(dept));
}
}

@ -1,183 +0,0 @@
package com.ruoyi.web.controller.tool;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.utils.StringUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
/**
* swagger
*
* @author ruoyi
*/
@Api("用户信息管理")
@RestController
@RequestMapping("/test/user")
public class TestController extends BaseController
{
private final static Map<Integer, UserEntity> users = new LinkedHashMap<Integer, UserEntity>();
{
users.put(1, new UserEntity(1, "admin", "admin123", "15888888888"));
users.put(2, new UserEntity(2, "ry", "admin123", "15666666666"));
}
@ApiOperation("获取用户列表")
@GetMapping("/list")
public R<List<UserEntity>> userList()
{
List<UserEntity> userList = new ArrayList<UserEntity>(users.values());
return R.ok(userList);
}
@ApiOperation("获取用户详细")
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class)
@GetMapping("/{userId}")
public R<UserEntity> getUser(@PathVariable Integer userId)
{
if (!users.isEmpty() && users.containsKey(userId))
{
return R.ok(users.get(userId));
}
else
{
return R.fail("用户不存在");
}
}
@ApiOperation("新增用户")
@ApiImplicitParams({
@ApiImplicitParam(name = "userId", value = "用户id", dataType = "Integer", dataTypeClass = Integer.class),
@ApiImplicitParam(name = "username", value = "用户名称", dataType = "String", dataTypeClass = String.class),
@ApiImplicitParam(name = "password", value = "用户密码", dataType = "String", dataTypeClass = String.class),
@ApiImplicitParam(name = "mobile", value = "用户手机", dataType = "String", dataTypeClass = String.class)
})
@PostMapping("/save")
public R<String> save(UserEntity user)
{
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId()))
{
return R.fail("用户ID不能为空");
}
users.put(user.getUserId(), user);
return R.ok();
}
@ApiOperation("更新用户")
@PutMapping("/update")
public R<String> update(@RequestBody UserEntity user)
{
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId()))
{
return R.fail("用户ID不能为空");
}
if (users.isEmpty() || !users.containsKey(user.getUserId()))
{
return R.fail("用户不存在");
}
users.remove(user.getUserId());
users.put(user.getUserId(), user);
return R.ok();
}
@ApiOperation("删除用户信息")
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class)
@DeleteMapping("/{userId}")
public R<String> delete(@PathVariable Integer userId)
{
if (!users.isEmpty() && users.containsKey(userId))
{
users.remove(userId);
return R.ok();
}
else
{
return R.fail("用户不存在");
}
}
}
@ApiModel(value = "UserEntity", description = "用户实体")
class UserEntity
{
@ApiModelProperty("用户ID")
private Integer userId;
@ApiModelProperty("用户名称")
private String username;
@ApiModelProperty("用户密码")
private String password;
@ApiModelProperty("用户手机")
private String mobile;
public UserEntity()
{
}
public UserEntity(Integer userId, String username, String password, String mobile)
{
this.userId = userId;
this.username = username;
this.password = password;
this.mobile = mobile;
}
public Integer getUserId()
{
return userId;
}
public void setUserId(Integer userId)
{
this.userId = userId;
}
public String getUsername()
{
return username;
}
public void setUsername(String username)
{
this.username = username;
}
public String getPassword()
{
return password;
}
public void setPassword(String password)
{
this.password = password;
}
public String getMobile()
{
return mobile;
}
public void setMobile(String mobile)
{
this.mobile = mobile;
}
}

@ -0,0 +1,26 @@
package com.ruoyi.web.core.config;
import com.ruoyi.mall.util.PayConstants;
import com.wechat.pay.java.core.Config;
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
public class WechatPayConfig {
private static Config wechatPayConfig;
private WechatPayConfig(){}
public static Config getInstance() {
if (wechatPayConfig == null) {
wechatPayConfig = new RSAAutoCertificateConfig.Builder()
.merchantId(PayConstants.MCH_ID)
.privateKeyFromPath(PayConstants.PRIVATE_KEY_FILE_PATH)
.merchantSerialNumber(PayConstants.MCH_SERIAL_NO)
.apiV3Key(PayConstants.API_V3KEY)
.build();
}
return wechatPayConfig;
}
}

@ -1,291 +0,0 @@
package com.ruoyi.web.util;
/**
* Base64
*
*/
public final class Base64
{
static private final int BASELENGTH = 128;
static private final int LOOKUPLENGTH = 64;
static private final int TWENTYFOURBITGROUP = 24;
static private final int EIGHTBIT = 8;
static private final int SIXTEENBIT = 16;
static private final int FOURBYTE = 4;
static private final int SIGN = -128;
static private final char PAD = '=';
static final private byte[] base64Alphabet = new byte[BASELENGTH];
static final private char[] lookUpBase64Alphabet = new char[LOOKUPLENGTH];
static
{
for (int i = 0; i < BASELENGTH; ++i)
{
base64Alphabet[i] = -1;
}
for (int i = 'Z'; i >= 'A'; i--)
{
base64Alphabet[i] = (byte) (i - 'A');
}
for (int i = 'z'; i >= 'a'; i--)
{
base64Alphabet[i] = (byte) (i - 'a' + 26);
}
for (int i = '9'; i >= '0'; i--)
{
base64Alphabet[i] = (byte) (i - '0' + 52);
}
base64Alphabet['+'] = 62;
base64Alphabet['/'] = 63;
for (int i = 0; i <= 25; i++)
{
lookUpBase64Alphabet[i] = (char) ('A' + i);
}
for (int i = 26, j = 0; i <= 51; i++, j++)
{
lookUpBase64Alphabet[i] = (char) ('a' + j);
}
for (int i = 52, j = 0; i <= 61; i++, j++)
{
lookUpBase64Alphabet[i] = (char) ('0' + j);
}
lookUpBase64Alphabet[62] = (char) '+';
lookUpBase64Alphabet[63] = (char) '/';
}
private static boolean isWhiteSpace(char octect)
{
return (octect == 0x20 || octect == 0xd || octect == 0xa || octect == 0x9);
}
private static boolean isPad(char octect)
{
return (octect == PAD);
}
private static boolean isData(char octect)
{
return (octect < BASELENGTH && base64Alphabet[octect] != -1);
}
/**
* Encodes hex octects into Base64
*
* @param binaryData Array containing binaryData
* @return Encoded Base64 array
*/
public static String encode(byte[] binaryData)
{
if (binaryData == null)
{
return null;
}
int lengthDataBits = binaryData.length * EIGHTBIT;
if (lengthDataBits == 0)
{
return "";
}
int fewerThan24bits = lengthDataBits % TWENTYFOURBITGROUP;
int numberTriplets = lengthDataBits / TWENTYFOURBITGROUP;
int numberQuartet = fewerThan24bits != 0 ? numberTriplets + 1 : numberTriplets;
char encodedData[] = null;
encodedData = new char[numberQuartet * 4];
byte k = 0, l = 0, b1 = 0, b2 = 0, b3 = 0;
int encodedIndex = 0;
int dataIndex = 0;
for (int i = 0; i < numberTriplets; i++)
{
b1 = binaryData[dataIndex++];
b2 = binaryData[dataIndex++];
b3 = binaryData[dataIndex++];
l = (byte) (b2 & 0x0f);
k = (byte) (b1 & 0x03);
byte val1 = ((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0);
byte val2 = ((b2 & SIGN) == 0) ? (byte) (b2 >> 4) : (byte) ((b2) >> 4 ^ 0xf0);
byte val3 = ((b3 & SIGN) == 0) ? (byte) (b3 >> 6) : (byte) ((b3) >> 6 ^ 0xfc);
encodedData[encodedIndex++] = lookUpBase64Alphabet[val1];
encodedData[encodedIndex++] = lookUpBase64Alphabet[val2 | (k << 4)];
encodedData[encodedIndex++] = lookUpBase64Alphabet[(l << 2) | val3];
encodedData[encodedIndex++] = lookUpBase64Alphabet[b3 & 0x3f];
}
// form integral number of 6-bit groups
if (fewerThan24bits == EIGHTBIT)
{
b1 = binaryData[dataIndex];
k = (byte) (b1 & 0x03);
byte val1 = ((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0);
encodedData[encodedIndex++] = lookUpBase64Alphabet[val1];
encodedData[encodedIndex++] = lookUpBase64Alphabet[k << 4];
encodedData[encodedIndex++] = PAD;
encodedData[encodedIndex++] = PAD;
}
else if (fewerThan24bits == SIXTEENBIT)
{
b1 = binaryData[dataIndex];
b2 = binaryData[dataIndex + 1];
l = (byte) (b2 & 0x0f);
k = (byte) (b1 & 0x03);
byte val1 = ((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0);
byte val2 = ((b2 & SIGN) == 0) ? (byte) (b2 >> 4) : (byte) ((b2) >> 4 ^ 0xf0);
encodedData[encodedIndex++] = lookUpBase64Alphabet[val1];
encodedData[encodedIndex++] = lookUpBase64Alphabet[val2 | (k << 4)];
encodedData[encodedIndex++] = lookUpBase64Alphabet[l << 2];
encodedData[encodedIndex++] = PAD;
}
return new String(encodedData);
}
/**
* Decodes Base64 data into octects
*
* @param encoded string containing Base64 data
* @return Array containind decoded data.
*/
public static byte[] decode(String encoded)
{
if (encoded == null)
{
return null;
}
char[] base64Data = encoded.toCharArray();
// remove white spaces
int len = removeWhiteSpace(base64Data);
if (len % FOURBYTE != 0)
{
return null;// should be divisible by four
}
int numberQuadruple = (len / FOURBYTE);
if (numberQuadruple == 0)
{
return new byte[0];
}
byte decodedData[] = null;
byte b1 = 0, b2 = 0, b3 = 0, b4 = 0;
char d1 = 0, d2 = 0, d3 = 0, d4 = 0;
int i = 0;
int encodedIndex = 0;
int dataIndex = 0;
decodedData = new byte[(numberQuadruple) * 3];
for (; i < numberQuadruple - 1; i++)
{
if (!isData((d1 = base64Data[dataIndex++])) || !isData((d2 = base64Data[dataIndex++]))
|| !isData((d3 = base64Data[dataIndex++])) || !isData((d4 = base64Data[dataIndex++])))
{
return null;
} // if found "no data" just return null
b1 = base64Alphabet[d1];
b2 = base64Alphabet[d2];
b3 = base64Alphabet[d3];
b4 = base64Alphabet[d4];
decodedData[encodedIndex++] = (byte) (b1 << 2 | b2 >> 4);
decodedData[encodedIndex++] = (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf));
decodedData[encodedIndex++] = (byte) (b3 << 6 | b4);
}
if (!isData((d1 = base64Data[dataIndex++])) || !isData((d2 = base64Data[dataIndex++])))
{
return null;// if found "no data" just return null
}
b1 = base64Alphabet[d1];
b2 = base64Alphabet[d2];
d3 = base64Data[dataIndex++];
d4 = base64Data[dataIndex++];
if (!isData((d3)) || !isData((d4)))
{// Check if they are PAD characters
if (isPad(d3) && isPad(d4))
{
if ((b2 & 0xf) != 0)// last 4 bits should be zero
{
return null;
}
byte[] tmp = new byte[i * 3 + 1];
System.arraycopy(decodedData, 0, tmp, 0, i * 3);
tmp[encodedIndex] = (byte) (b1 << 2 | b2 >> 4);
return tmp;
}
else if (!isPad(d3) && isPad(d4))
{
b3 = base64Alphabet[d3];
if ((b3 & 0x3) != 0)// last 2 bits should be zero
{
return null;
}
byte[] tmp = new byte[i * 3 + 2];
System.arraycopy(decodedData, 0, tmp, 0, i * 3);
tmp[encodedIndex++] = (byte) (b1 << 2 | b2 >> 4);
tmp[encodedIndex] = (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf));
return tmp;
}
else
{
return null;
}
}
else
{ // No PAD e.g 3cQl
b3 = base64Alphabet[d3];
b4 = base64Alphabet[d4];
decodedData[encodedIndex++] = (byte) (b1 << 2 | b2 >> 4);
decodedData[encodedIndex++] = (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf));
decodedData[encodedIndex++] = (byte) (b3 << 6 | b4);
}
return decodedData;
}
/**
* remove WhiteSpace from MIME containing encoded Base64 data.
*
* @param data the byte array of base64 data (with WS)
* @return the new length
*/
private static int removeWhiteSpace(char[] data)
{
if (data == null)
{
return 0;
}
// count characters that's not whitespace
int newSize = 0;
int len = data.length;
for (int i = 0; i < len; i++)
{
if (!isWhiteSpace(data[i]))
{
data[newSize++] = data[i];
}
}
return newSize;
}
}

@ -1,44 +0,0 @@
package com.ruoyi.web.util;
import java.security.MessageDigest;
public class MD5Util {
private static String byteArrayToHexString(byte b[]) {
StringBuffer resultSb = new StringBuffer();
for (int i = 0; i < b.length; i++)
resultSb.append(byteToHexString(b[i]));
return resultSb.toString();
}
private static String byteToHexString(byte b) {
int n = b;
if (n < 0)
n += 256;
int d1 = n / 16;
int d2 = n % 16;
return hexDigits[d1] + hexDigits[d2];
}
public static String MD5Encode(String origin, String charsetname) {
String resultString = null;
try {
resultString = new String(origin);
MessageDigest md = MessageDigest.getInstance("MD5");
if (charsetname == null || "".equals(charsetname))
resultString = byteArrayToHexString(md.digest(resultString
.getBytes()));
else
resultString = byteArrayToHexString(md.digest(resultString
.getBytes(charsetname)));
} catch (Exception exception) {
}
return resultString;
}
private static final String hexDigits[] = {"0", "1", "2", "3", "4", "5",
"6", "7", "8", "9", "A", "B", "C", "D", "E", "F"};
}

@ -1,360 +0,0 @@
package com.ruoyi.web.util;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.json.JSONUtil;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.wechat.pay.contrib.apache.httpclient.WechatPayHttpClientBuilder;
import com.wechat.pay.contrib.apache.httpclient.auth.*;
import com.wechat.pay.contrib.apache.httpclient.cert.CertificatesManager;
import com.wechat.pay.contrib.apache.httpclient.exception.HttpCodeException;
import com.wechat.pay.contrib.apache.httpclient.exception.NotFoundException;
import com.wechat.pay.contrib.apache.httpclient.util.AesUtil;
import com.wechat.pay.contrib.apache.httpclient.util.PemUtil;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.util.EntityUtils;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.security.*;
import java.util.Base64;
import java.util.*;
public class PayUtil {
// String schema = "WECHATPAY2-SHA256-RSA2048";
// HttpUrl httpurl = HttpUrl.parse(url);
/**
*
* @param amount
* @param orderSn
* @return
* @throws Exception
*/
public static Map creatOrder(int amount,String orderSn) throws Exception{
PrivateKey merchantPrivateKey = PemUtil.loadPrivateKey(
new ByteArrayInputStream(PayConstants.PRIVATE_KEY.getBytes(StandardCharsets.UTF_8)));
//使用自动更新的签名验证器,不需要传入证书
Verifier verifier = new AutoUpdateCertificatesVerifier(
new WechatPay2Credentials(PayConstants.MCH_ID,
new PrivateKeySigner(PayConstants.MCH_SERIAL_NO, merchantPrivateKey)),
PayConstants.API_V3KEY.getBytes(StandardCharsets.UTF_8));
CloseableHttpClient httpClient = WechatPayHttpClientBuilder.create()
.withMerchant(PayConstants.MCH_ID, PayConstants.MCH_SERIAL_NO, merchantPrivateKey)
.withValidator(new WechatPay2Validator(verifier))
.build();
String url="https://api.mch.weixin.qq.com/v3/pay/transactions/app";
HttpPost httpPost = new HttpPost(url);
httpPost.addHeader("Accept", "application/json");
httpPost.addHeader("Content-type","application/json; charset=utf-8");
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectMapper objectMapper = new ObjectMapper();
ObjectNode rootNode = objectMapper.createObjectNode();
rootNode.put("mchid", PayConstants.MCH_ID)
.put("appid", PayConstants.APP_ID)
.put("notify_url", PayConstants.NOTIFY_URL)
.put("description", "三朵兰瑜伽")
.put("out_trade_no",orderSn);//订单号 目前是时间戳System.currentTimeMillis()
rootNode.putObject("amount")
.put("total", amount)//订单金额 int类型单位为分
.put("currency", "CNY");//CNY人民币境内商户号仅支持人民币。
objectMapper.writeValue(bos, rootNode);
httpPost.setEntity(new StringEntity(bos.toString("UTF-8"), "UTF-8"));
CloseableHttpResponse response = httpClient.execute(httpPost);
//-----------------------------------------------------------------------------------------
String bodyAsString = EntityUtils.toString(response.getEntity());
System.out.println(bodyAsString);
Map<String,String> json=(Map)JSONUtil.parse(bodyAsString);
Long timestamp= System.currentTimeMillis();//时间戳
String nonce= RandomUtil.randomString(32);//随机字符串
StringBuilder builder=new StringBuilder();
//应用id
builder.append(PayConstants.APP_ID).append("\n");
//时间戳
builder.append(timestamp).append("\n");
//随机字符串
builder.append(nonce).append("\n");
//预支付交易会话ID
builder.append(json.get("prepay_id")).append("\n");
//生成签名 RSA
String ciphertext = sign(builder.toString().getBytes(StandardCharsets.UTF_8));
System.out.println(ciphertext);
//---------------------------------------------------------------------------------------------
//生成签名 MD5
// SortedMap<String,String> sort=new TreeMap();
// sort.put("appid",PayConstants.APP_ID);
// sort.put("timestamp",timestamp.toString());
// sort.put("noncestr",nonce);
// sort.put("prepayid",node.get("prepay_id").toString());
// String ciphertext = createSign(sort).toUpperCase();
// String stringA=
// "appid="+PayConstants.APP_ID
// +"&noncestr="+nonce
//// +"&package="+PayConstants.PACKAGE
// +"&partnerid="+PayConstants.MCH_ID
// +"&prepayid="+json.get("prepay_id").toString()
// +"&timestamp="+timestamp;
//
// System.out.println(stringA);
// String stringSignTemp = stringA+"&key="+PayConstants.API_V3KEY;
// String ciphertext = MD5Util.MD5Encode(stringSignTemp,"UTF-8").toUpperCase();
System.out.println(ciphertext);
Map map=new HashMap();
map.put("appid",PayConstants.APP_ID);
map.put("partnerid",PayConstants.MCH_ID);
map.put("prepayid",json.get("prepay_id").toString());//有效期为2小时超过2小时商户需要使用原下单参数重新请求下单接口获取新的prepay_id
map.put("package",PayConstants.PACKAGE);
map.put("noncestr",nonce);
map.put("timestamp",timestamp);
map.put("sign",ciphertext);
return map;
}
/**
* RSA
* @param message
* @return
*/
/*message为appId、timeStamp、nonceStr、package拼接成的字符串 计算得出paySign*/
static String sign(byte[] message) {
try {
PrivateKey merchantPrivateKey = PemUtil.loadPrivateKey(PayConstants.PRIVATE_KEY);
Signature sign = Signature.getInstance("SHA256withRSA");
sign.initSign(merchantPrivateKey);
sign.update(message);
return Base64.getEncoder().encodeToString(sign.sign());
} catch (InvalidKeyException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (SignatureException e) {
e.printStackTrace();
}
return null;
}
/**
* MD5
* @param parameters
* @return
*/
public static String createSign(SortedMap parameters){
StringBuffer sb = new StringBuffer();
Set es = parameters.entrySet();//全部参与传参的参数按照accsii排序(升序)
Iterator it = es.iterator();
while(it.hasNext()) {
Map.Entry entry = (Map.Entry)it.next();
String k = (String)entry.getKey();
Object v = entry.getValue();
if(null != v && !"".equals(v)
&& !"sign".equals(k) && !"key".equals(k)) {
sb.append(k + "=" + v + "&");
}
}
sb.append("key=" + PayConstants.API_V3KEY);//这里是商户那里设置的key
System.out.println("签名字符串:"+sb.toString());
String sign =MD5Util.MD5Encode(sb.toString(),"UTF-8");
return sign;
}
/**
*
* @param serialNumber
* @param message
* @param signature
* @return
*/
public static boolean signVerify(String serialNumber,String message,String signature){
try {
PrivateKey merchantPrivateKey = PemUtil.loadPrivateKey(PayConstants.PRIVATE_KEY);
// 获取证书管理器实例
CertificatesManager certificatesManager = CertificatesManager.getInstance();
// 向证书管理器增加需要自动更新平台证书的商户信息
certificatesManager.putMerchant(PayConstants.MCH_ID, new WechatPay2Credentials(PayConstants.MCH_ID,
new PrivateKeySigner(PayConstants.MCH_SERIAL_NO, merchantPrivateKey)),
PayConstants.API_V3KEY.getBytes(StandardCharsets.UTF_8));
// 从证书管理器中获取verifier
Verifier verifier = certificatesManager.getVerifier(PayConstants.MCH_ID);
return verifier.verify(serialNumber, message.getBytes(StandardCharsets.UTF_8), signature);
} catch (IOException e) {
e.printStackTrace();
} catch (GeneralSecurityException e) {
e.printStackTrace();
} catch (HttpCodeException e) {
e.printStackTrace();
} catch (NotFoundException e) {
e.printStackTrace();
}
return false;
}
/**
* 使
* @param body
* @return
*/
public static String decryptOrder(String body){
try {
AesUtil util=new AesUtil(PayConstants.API_V3KEY.getBytes(StandardCharsets.UTF_8));
ObjectMapper objectMapper = new ObjectMapper();
JsonNode node=objectMapper.readTree(body);
JsonNode resource=node.get("resource");
String ciphertext=resource.get("ciphertext").textValue();
String associatedData=resource.get("associated_data").textValue();
String nonce=resource.get("nonce").textValue();
return util.decryptToString(associatedData.getBytes(StandardCharsets.UTF_8)
,nonce.getBytes(StandardCharsets.UTF_8)
,ciphertext);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
//关单
public static void closeOrder(String outTradeNo) throws Exception{
PrivateKey merchantPrivateKey = PemUtil.loadPrivateKey(
new ByteArrayInputStream(PayConstants.PRIVATE_KEY.getBytes(StandardCharsets.UTF_8)));
//使用自动更新的签名验证器,不需要传入证书
Verifier verifier = new AutoUpdateCertificatesVerifier(
new WechatPay2Credentials(PayConstants.MCH_ID,
new PrivateKeySigner(PayConstants.MCH_SERIAL_NO, merchantPrivateKey)),
PayConstants.API_V3KEY.getBytes(StandardCharsets.UTF_8));
CloseableHttpClient httpClient = WechatPayHttpClientBuilder.create()
.withMerchant(PayConstants.MCH_ID, PayConstants.MCH_SERIAL_NO, merchantPrivateKey)
.withValidator(new WechatPay2Validator(verifier))
.build();
//************************************************
HttpPost httpPost = new HttpPost("https://api.mch.weixin.qq.com/v3/pay/transactions/out-trade-no/"+outTradeNo+"/close");
httpPost.addHeader("Accept", "application/json");
httpPost.addHeader("Content-type","application/json; charset=utf-8");
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectMapper objectMapper = new ObjectMapper();
ObjectNode rootNode = objectMapper.createObjectNode();
rootNode.put("mchid",PayConstants.MCH_ID);
objectMapper.writeValue(bos, rootNode);
httpPost.setEntity(new StringEntity(bos.toString("UTF-8"), "UTF-8"));
CloseableHttpResponse response = httpClient.execute(httpPost);
//204关单成功
System.out.println(response.getStatusLine().getStatusCode()+"----204关单成功");
// String bodyAsString = EntityUtils.toString(response.getEntity());
// System.out.println(bodyAsString);
}
/**
*
* @param amount
* @param orderSn
* @return
* @throws Exception
*/
public static Map creatMergeOrder(int amount,String orderSn) throws Exception{
PrivateKey merchantPrivateKey = PemUtil.loadPrivateKey(
new ByteArrayInputStream(PayConstants.PRIVATE_KEY.getBytes(StandardCharsets.UTF_8)));
//使用自动更新的签名验证器,不需要传入证书
Verifier verifier = new AutoUpdateCertificatesVerifier(
new WechatPay2Credentials(PayConstants.MCH_ID,
new PrivateKeySigner(PayConstants.MCH_SERIAL_NO, merchantPrivateKey)),
PayConstants.API_V3KEY.getBytes(StandardCharsets.UTF_8));
CloseableHttpClient httpClient = WechatPayHttpClientBuilder.create()
.withMerchant(PayConstants.MCH_ID, PayConstants.MCH_SERIAL_NO, merchantPrivateKey)
.withValidator(new WechatPay2Validator(verifier))
.build();
HttpPost httpPost = new HttpPost("https://api.mch.weixin.qq.com/v3/combine-transactions/app");
httpPost.addHeader("Accept", "application/json");
httpPost.addHeader("Content-type","application/json; charset=utf-8");
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectMapper objectMapper = new ObjectMapper();
ObjectNode rootNode = objectMapper.createObjectNode();
rootNode.put("combine_mchid", PayConstants.MCH_ID)
.put("combine_appid", PayConstants.APP_ID)
.put("notify_url", PayConstants.NOTIFY_URL)
.put("combine_out_trade_no",orderSn);//订单号// 目前是时间戳System.currentTimeMillis()
rootNode.putArray("sub_orders")
.addObject()
.put("total", amount)//订单金额 int类型单位为分
.put("currency", "CNY");//CNY人民币境内商户号仅支持人民币。
objectMapper.writeValue(bos, rootNode);
httpPost.setEntity(new StringEntity(bos.toString("UTF-8"), "UTF-8"));
CloseableHttpResponse response = httpClient.execute(httpPost);
String bodyAsString = EntityUtils.toString(response.getEntity());
System.out.println(bodyAsString);
String timestamp=System.currentTimeMillis()+"";//时间戳
String nonce= RandomUtil.randomString(32);//随机字符串
StringBuilder builder=new StringBuilder();
//应用id
builder.append(PayConstants.APP_ID).append("\n");
//时间戳
builder.append(timestamp).append("\n");
//随机字符串
builder.append(nonce).append("\n");
JsonNode node=objectMapper.readTree(bodyAsString);
//预支付交易会话ID
builder.append(node.get("prepay_id")).append("\n");
// String cirphertext= RsaCryptoUtil.encryptOAEP(builder.toString(),verifier.getValidCertificate());
String ciphertext = sign(builder.toString().getBytes(StandardCharsets.UTF_8));
System.out.println(ciphertext);
Map map=new HashMap();
map.put("noncestr",nonce);
map.put("package",PayConstants.PACKAGE);
map.put("timeStamp",timestamp);
map.put("signType","RSA");
map.put("paySign",ciphertext);
return map;
}
}

@ -1,188 +0,0 @@
package com.ruoyi.web.util;
public class SnowFlake {
// ==============================Fields===========================================
/**
* (2018-07-03)
*/
private final Long twepoch = 1530607760000L;
/**
* id
*/
private final Long workerIdBits = 5L;
/**
* id
*/
private final Long datacenterIdBits = 5L;
/**
* id31 ()
*/
private final Long maxWorkerId = -1L ^ (-1L << workerIdBits);
/**
* id31
*/
private final Long maxDatacenterId = -1L ^ (-1L << datacenterIdBits);
/**
* id
*/
private final Long sequenceBits = 12L;
/**
* ID12
*/
private final Long workerIdShift = sequenceBits;
/**
* id17(12+5)
*/
private final Long datacenterIdShift = sequenceBits + workerIdBits;
/**
* 22(5+5+12)
*/
private final Long timestampLeftShift = sequenceBits + workerIdBits + datacenterIdBits;
/**
* 4095 (0b111111111111=0xfff=4095)
*/
private final Long sequenceMask = -1L ^ (-1L << sequenceBits);
/**
* ID(0~31)
*/
private Long workerId;
/**
* ID(0~31)
*/
private Long datacenterId;
/**
* (0~4095)
*/
private Long sequence = 0L;
/**
* ID
*/
private Long lastTimestamp = -1L;
//==============================Constructors=====================================
/**
*
*
* @param workerId ID (0~31)
* @param datacenterId ID (0~31)
*/
public SnowFlake(Long workerId, Long datacenterId) {
if (workerId > maxWorkerId || workerId < 0) {
throw new IllegalArgumentException(String.format("worker Id can't be greater than %d or less than 0", maxWorkerId));
}
if (datacenterId > maxDatacenterId || datacenterId < 0) {
throw new IllegalArgumentException(String.format("datacenter Id can't be greater than %d or less than 0", maxDatacenterId));
}
this.workerId = workerId;
this.datacenterId = datacenterId;
}
// ==============================Methods==========================================
/**
* ID (线)
*
* @return SnowflakeId
*/
public synchronized Long nextId() {
Long timestamp = timeGen();
//如果当前时间小于上一次ID生成的时间戳说明系统时钟回退过这个时候应当抛出异常
if (timestamp < lastTimestamp) {
throw new RuntimeException(
String.format("Clock moved backwards. Refusing to generate id for %d milliseconds", lastTimestamp - timestamp));
}
//如果是同一时间生成的,则进行毫秒内序列
if (lastTimestamp == timestamp) {
sequence = (sequence + 1) & sequenceMask;
//毫秒内序列溢出
if (sequence == 0) {
//阻塞到下一个毫秒,获得新的时间戳
timestamp = tilNextMillis(lastTimestamp);
}
}
//时间戳改变,毫秒内序列重置
else {
sequence = 0L;
}
//上次生成ID的时间截
lastTimestamp = timestamp;
//移位并通过或运算拼到一起组成64位的ID
return (((timestamp - twepoch) << timestampLeftShift)
| (datacenterId << datacenterIdShift)
| (workerId << workerIdShift)
| sequence);
}
/**
*
*
* @param lastTimestamp ID
* @return
*/
protected Long tilNextMillis(Long lastTimestamp) {
Long timestamp = timeGen();
while (timestamp <= lastTimestamp) {
timestamp = timeGen();
}
return timestamp;
}
/**
*
*
* @return ()
*/
protected Long timeGen() {
return System.currentTimeMillis();
}
//==============================Test=============================================
/**
*
*/
// public static void main(String[] args) {
// SnowFlake idWorker = new SnowFlake(0l, 0l);
// Long id = idWorker.nextId();
// System.out.println(id);
// }
public static Long getOrder() {
SnowFlake idWorker = new SnowFlake(0l, 0l);
Long id = idWorker.nextId();
return id;
}
// public String getOrder() {
// Long startTime = System.currentTimeMillis();
// SnowFlake idWorker = new SnowFlake(0, 0);
// Long id = idWorker.nextId();
// Set set = new HashSet();
// for (int i = 0; i < 10000000; i++) {
// Long id = idWorker.nextId();
// set.add(id);
// System.out.println("id----"+i+":"+id);
// }
// Long endTime = System.currentTimeMillis();
// System.out.println("set.size():" + set.size());
// System.out.println("endTime-startTime:" + (endTime - startTime));
// }
}

@ -1,486 +0,0 @@
package com.ruoyi.web.util;
import cn.hutool.core.exceptions.UtilException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;
/**
* universally unique identifierUUID
*
*/
public final class UUID implements java.io.Serializable, Comparable<UUID>
{
private static final long serialVersionUID = -1185015143654744140L;
/**
* SecureRandom
*
*/
private static class Holder
{
static final SecureRandom numberGenerator = getSecureRandom();
}
/** 此UUID的最高64有效位 */
private final long mostSigBits;
/** 此UUID的最低64有效位 */
private final long leastSigBits;
/**
*
*
* @param data
*/
private UUID(byte[] data)
{
long msb = 0;
long lsb = 0;
assert data.length == 16 : "data must be 16 bytes in length";
for (int i = 0; i < 8; i++)
{
msb = (msb << 8) | (data[i] & 0xff);
}
for (int i = 8; i < 16; i++)
{
lsb = (lsb << 8) | (data[i] & 0xff);
}
this.mostSigBits = msb;
this.leastSigBits = lsb;
}
/**
* 使 UUID
*
* @param mostSigBits {@code UUID} 64
* @param leastSigBits {@code UUID} 64
*/
public UUID(long mostSigBits, long leastSigBits)
{
this.mostSigBits = mostSigBits;
this.leastSigBits = leastSigBits;
}
/**
* 4UUID 使线 UUID
*
* @return {@code UUID}
*/
public static UUID fastUUID()
{
return randomUUID(false);
}
/**
* 4UUID 使 UUID
*
* @return {@code UUID}
*/
public static UUID randomUUID()
{
return randomUUID(true);
}
/**
* 4UUID 使 UUID
*
* @param isSecure 使{@link SecureRandom}
* @return {@code UUID}
*/
public static UUID randomUUID(boolean isSecure)
{
final Random ng = isSecure ? Holder.numberGenerator : getSecureRandom();
byte[] randomBytes = new byte[16];
ng.nextBytes(randomBytes);
randomBytes[6] &= 0x0f; /* clear version */
randomBytes[6] |= 0x40; /* set to version 4 */
randomBytes[8] &= 0x3f; /* clear variant */
randomBytes[8] |= 0x80; /* set to IETF variant */
return new UUID(randomBytes);
}
/**
* 3UUID
*
* @param name UUID
*
* @return {@code UUID}
*/
public static UUID nameUUIDFromBytes(byte[] name)
{
MessageDigest md;
try
{
md = MessageDigest.getInstance("MD5");
}
catch (NoSuchAlgorithmException nsae)
{
throw new InternalError("MD5 not supported");
}
byte[] md5Bytes = md.digest(name);
md5Bytes[6] &= 0x0f; /* clear version */
md5Bytes[6] |= 0x30; /* set to version 3 */
md5Bytes[8] &= 0x3f; /* clear variant */
md5Bytes[8] |= 0x80; /* set to IETF variant */
return new UUID(md5Bytes);
}
/**
* {@link #toString()} {@code UUID}
*
* @param name {@code UUID}
* @return {@code UUID}
* @throws IllegalArgumentException name {@link #toString}
*
*/
public static UUID fromString(String name)
{
String[] components = name.split("-");
if (components.length != 5)
{
throw new IllegalArgumentException("Invalid UUID string: " + name);
}
for (int i = 0; i < 5; i++)
{
components[i] = "0x" + components[i];
}
long mostSigBits = Long.decode(components[0]).longValue();
mostSigBits <<= 16;
mostSigBits |= Long.decode(components[1]).longValue();
mostSigBits <<= 16;
mostSigBits |= Long.decode(components[2]).longValue();
long leastSigBits = Long.decode(components[3]).longValue();
leastSigBits <<= 48;
leastSigBits |= Long.decode(components[4]).longValue();
return new UUID(mostSigBits, leastSigBits);
}
/**
* UUID 128 64
*
* @return UUID 128 64
*/
public long getLeastSignificantBits()
{
return leastSigBits;
}
/**
* UUID 128 64
*
* @return UUID 128 64
*/
public long getMostSignificantBits()
{
return mostSigBits;
}
/**
* {@code UUID} . {@code UUID}
* <p>
* :
* <ul>
* <li>1 UUID
* <li>2 DCE UUID
* <li>3 UUID
* <li>4 UUID
* </ul>
*
* @return {@code UUID}
*/
public int version()
{
// Version is bits masked by 0x000000000000F000 in MS long
return (int) ((mostSigBits >> 12) & 0x0f);
}
/**
* {@code UUID} {@code UUID}
* <p>
*
* <ul>
* <li>0 NCS
* <li>2 <a href="http://www.ietf.org/rfc/rfc4122.txt">IETF&nbsp;RFC&nbsp;4122</a>(Leach-Salz),
* <li>6
* <li>7 使
* </ul>
*
* @return {@code UUID}
*/
public int variant()
{
// This field is composed of a varying number of bits.
// 0 - - Reserved for NCS backward compatibility
// 1 0 - The IETF aka Leach-Salz variant (used by this class)
// 1 1 0 Reserved, Microsoft backward compatibility
// 1 1 1 Reserved for future definition.
return (int) ((leastSigBits >>> (64 - (leastSigBits >>> 62))) & (leastSigBits >> 63));
}
/**
* UUID
*
* <p>
* 60 {@code UUID} time_lowtime_mid time_hi <br>
* 100 UTC 1582 10 15
*
* <p>
* UUID version 1<br>
* {@code UUID} UUID UnsupportedOperationException
*
* @throws UnsupportedOperationException {@code UUID} version 1 UUID
*/
public long timestamp() throws UnsupportedOperationException
{
checkTimeBase();
return (mostSigBits & 0x0FFFL) << 48//
| ((mostSigBits >> 16) & 0x0FFFFL) << 32//
| mostSigBits >>> 32;
}
/**
* UUID
*
* <p>
* 14 UUID clock_seq clock_seq UUID
* <p>
* {@code clockSequence} UUID version 1 UUID UUID
* UnsupportedOperationException
*
* @return {@code UUID}
*
* @throws UnsupportedOperationException UUID version 1
*/
public int clockSequence() throws UnsupportedOperationException
{
checkTimeBase();
return (int) ((leastSigBits & 0x3FFF000000000000L) >>> 48);
}
/**
* UUID
*
* <p>
* 48 UUID node IEEE 802 UUID
* <p>
* UUID version 1<br>
* UUID UUID UnsupportedOperationException
*
* @return {@code UUID}
*
* @throws UnsupportedOperationException UUID version 1
*/
public long node() throws UnsupportedOperationException
{
checkTimeBase();
return leastSigBits & 0x0000FFFFFFFFFFFFL;
}
/**
* {@code UUID}
*
* <p>
* UUID BNF
*
* <pre>
* {@code
* UUID = <time_low>-<time_mid>-<time_high_and_version>-<variant_and_sequence>-<node>
* time_low = 4*<hexOctet>
* time_mid = 2*<hexOctet>
* time_high_and_version = 2*<hexOctet>
* variant_and_sequence = 2*<hexOctet>
* node = 6*<hexOctet>
* hexOctet = <hexDigit><hexDigit>
* hexDigit = [0-9a-fA-F]
* }
* </pre>
*
* </blockquote>
*
* @return {@code UUID}
* @see #toString(boolean)
*/
@Override
public String toString()
{
return toString(false);
}
/**
* {@code UUID}
*
* <p>
* UUID BNF
*
* <pre>
* {@code
* UUID = <time_low>-<time_mid>-<time_high_and_version>-<variant_and_sequence>-<node>
* time_low = 4*<hexOctet>
* time_mid = 2*<hexOctet>
* time_high_and_version = 2*<hexOctet>
* variant_and_sequence = 2*<hexOctet>
* node = 6*<hexOctet>
* hexOctet = <hexDigit><hexDigit>
* hexDigit = [0-9a-fA-F]
* }
* </pre>
*
* </blockquote>
*
* @param isSimple '-'UUID
* @return {@code UUID}
*/
public String toString(boolean isSimple)
{
final StringBuilder builder = new StringBuilder(isSimple ? 32 : 36);
// time_low
builder.append(digits(mostSigBits >> 32, 8));
if (false == isSimple)
{
builder.append('-');
}
// time_mid
builder.append(digits(mostSigBits >> 16, 4));
if (false == isSimple)
{
builder.append('-');
}
// time_high_and_version
builder.append(digits(mostSigBits, 4));
if (false == isSimple)
{
builder.append('-');
}
// variant_and_sequence
builder.append(digits(leastSigBits >> 48, 4));
if (false == isSimple)
{
builder.append('-');
}
// node
builder.append(digits(leastSigBits, 12));
return builder.toString();
}
/**
* UUID
*
* @return UUID
*/
@Override
public int hashCode()
{
long hilo = mostSigBits ^ leastSigBits;
return ((int) (hilo >> 32)) ^ (int) hilo;
}
/**
*
* <p>
* {@code null} UUID UUID varriant {@code true}
*
* @param obj
*
* @return {@code true} {@code false}
*/
@Override
public boolean equals(Object obj)
{
if ((null == obj) || (obj.getClass() != UUID.class))
{
return false;
}
UUID id = (UUID) obj;
return (mostSigBits == id.mostSigBits && leastSigBits == id.leastSigBits);
}
// Comparison Operations
/**
* UUID UUID
*
* <p>
* UUID UUID UUID UUID UUID
*
* @param val UUID UUID
*
* @return UUID val -10 1
*
*/
@Override
public int compareTo(UUID val)
{
// The ordering is intentionally set up so that the UUIDs
// can simply be numerically compared as two numbers
return (this.mostSigBits < val.mostSigBits ? -1 : //
(this.mostSigBits > val.mostSigBits ? 1 : //
(this.leastSigBits < val.leastSigBits ? -1 : //
(this.leastSigBits > val.leastSigBits ? 1 : //
0))));
}
// -------------------------------------------------------------------------------------------------------------------
// Private method start
/**
* hex
*
* @param val
* @param digits
* @return
*/
private static String digits(long val, int digits)
{
long hi = 1L << (digits * 4);
return Long.toHexString(hi | (val & (hi - 1))).substring(1);
}
/**
* time-basedUUID
*/
private void checkTimeBase()
{
if (version() != 1)
{
throw new UnsupportedOperationException("Not a time-based UUID");
}
}
/**
* {@link SecureRandom} (RNG)
*
* @return {@link SecureRandom}
*/
public static SecureRandom getSecureRandom()
{
try
{
return SecureRandom.getInstance("SHA1PRNG");
}
catch (NoSuchAlgorithmException e)
{
throw new UtilException(e);
}
}
/**
* <br>
* ThreadLocalRandomJDK 7线
*
* @return {@link ThreadLocalRandom}
*/
public static ThreadLocalRandom getRandom()
{
return ThreadLocalRandom.current();
}
}

@ -1,225 +0,0 @@
package com.ruoyi.web.util;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.OutputStream;
import java.security.SecureRandom;
import java.util.Arrays;
import java.util.Random;
/**
*
*
*/
public class VerifyCodeUtils
{
// 使用到Algerian字体系统里没有的话需要安装字体字体只显示大写去掉了1,0,i,o几个容易混淆的字符
public static final String VERIFY_CODES = "123456789ABCDEFGHJKLMNPQRSTUVWXYZ";
private static Random random = new SecureRandom();
/**
* 使
*
* @param verifySize
* @return
*/
public static String generateVerifyCode(int verifySize)
{
return generateVerifyCode(verifySize, VERIFY_CODES);
}
/**
* 使
*
* @param verifySize
* @param sources
* @return
*/
public static String generateVerifyCode(int verifySize, String sources)
{
if (sources == null || sources.length() == 0)
{
sources = VERIFY_CODES;
}
int codesLen = sources.length();
Random rand = new Random(System.currentTimeMillis());
StringBuilder verifyCode = new StringBuilder(verifySize);
for (int i = 0; i < verifySize; i++)
{
verifyCode.append(sources.charAt(rand.nextInt(codesLen - 1)));
}
return verifyCode.toString();
}
/**
*
*
* @param w
* @param h
* @param os
* @param code
* @throws IOException
*/
public static void outputImage(int w, int h, OutputStream os, String code) throws IOException
{
int verifySize = code.length();
BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
Random rand = new Random();
Graphics2D g2 = image.createGraphics();
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
Color[] colors = new Color[5];
Color[] colorSpaces = new Color[] { Color.WHITE, Color.CYAN, Color.GRAY, Color.LIGHT_GRAY, Color.MAGENTA,
Color.ORANGE, Color.PINK, Color.YELLOW };
float[] fractions = new float[colors.length];
for (int i = 0; i < colors.length; i++)
{
colors[i] = colorSpaces[rand.nextInt(colorSpaces.length)];
fractions[i] = rand.nextFloat();
}
Arrays.sort(fractions);
g2.setColor(Color.GRAY);// 设置边框色
g2.fillRect(0, 0, w, h);
Color c = getRandColor(200, 250);
g2.setColor(c);// 设置背景色
g2.fillRect(0, 2, w, h - 4);
// 绘制干扰线
Random random = new Random();
g2.setColor(getRandColor(160, 200));// 设置线条的颜色
for (int i = 0; i < 20; i++)
{
int x = random.nextInt(w - 1);
int y = random.nextInt(h - 1);
int xl = random.nextInt(6) + 1;
int yl = random.nextInt(12) + 1;
g2.drawLine(x, y, x + xl + 40, y + yl + 20);
}
// 添加噪点
float yawpRate = 0.05f;// 噪声率
int area = (int) (yawpRate * w * h);
for (int i = 0; i < area; i++)
{
int x = random.nextInt(w);
int y = random.nextInt(h);
int rgb = getRandomIntColor();
image.setRGB(x, y, rgb);
}
shear(g2, w, h, c);// 使图片扭曲
g2.setColor(getRandColor(100, 160));
int fontSize = h - 4;
Font font = new Font("Algerian", Font.ITALIC, fontSize);
g2.setFont(font);
char[] chars = code.toCharArray();
for (int i = 0; i < verifySize; i++)
{
AffineTransform affine = new AffineTransform();
affine.setToRotation(Math.PI / 4 * rand.nextDouble() * (rand.nextBoolean() ? 1 : -1),
(w / verifySize) * i + fontSize / 2, h / 2);
g2.setTransform(affine);
g2.drawChars(chars, i, 1, ((w - 10) / verifySize) * i + 5, h / 2 + fontSize / 2 - 10);
}
g2.dispose();
ImageIO.write(image, "jpg", os);
}
private static Color getRandColor(int fc, int bc)
{
if (fc > 255) {
fc = 255;
}
if (bc > 255) {
bc = 255;
}
int r = fc + random.nextInt(bc - fc);
int g = fc + random.nextInt(bc - fc);
int b = fc + random.nextInt(bc - fc);
return new Color(r, g, b);
}
private static int getRandomIntColor()
{
int[] rgb = getRandomRgb();
int color = 0;
for (int c : rgb)
{
color = color << 8;
color = color | c;
}
return color;
}
private static int[] getRandomRgb()
{
int[] rgb = new int[3];
for (int i = 0; i < 3; i++)
{
rgb[i] = random.nextInt(255);
}
return rgb;
}
private static void shear(Graphics g, int w1, int h1, Color color)
{
shearX(g, w1, h1, color);
shearY(g, w1, h1, color);
}
private static void shearX(Graphics g, int w1, int h1, Color color)
{
int period = random.nextInt(2);
boolean borderGap = true;
int frames = 1;
int phase = random.nextInt(2);
for (int i = 0; i < h1; i++)
{
double d = (double) (period >> 1)
* Math.sin((double) i / (double) period + (6.2831853071795862D * (double) phase) / (double) frames);
g.copyArea(0, i, w1, 1, (int) d, 0);
if (borderGap)
{
g.setColor(color);
g.drawLine((int) d, i, 0, i);
g.drawLine((int) d + w1, i, w1, i);
}
}
}
private static void shearY(Graphics g, int w1, int h1, Color color)
{
int period = random.nextInt(40) + 10; // 50;
boolean borderGap = true;
int frames = 20;
int phase = 7;
for (int i = 0; i < w1; i++)
{
double d = (double) (period >> 1)
* Math.sin((double) i / (double) period + (6.2831853071795862D * (double) phase) / (double) frames);
g.copyArea(i, 0, 1, h1, 0, (int) d);
if (borderGap)
{
g.setColor(color);
g.drawLine(i, (int) d, i, 0);
g.drawLine(i, (int) d + h1, i, h1);
}
}
}
}

@ -1,7 +0,0 @@
package com.ruoyi.web.util;
public class clientServiceImpl {
}

@ -0,0 +1,75 @@
# 数据源配置
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
druid:
# 主库数据源
master:
# url: jdbc:mysql://101.43.111.159:3306/yoga?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
url: jdbc:mysql://localhost:3306/yj?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
# password: '!Runpeng888'
password: 123456
# 从库数据源
slave:
# 从数据源开关/默认关闭
enabled: false
url:
username:
password:
# 初始连接数
initialSize: 5
# 最小连接池数量
minIdle: 10
# 最大连接池数量
maxActive: 20
# 配置获取连接等待超时的时间
maxWait: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis: 300000
# 配置一个连接在池中最大生存的时间,单位是毫秒
maxEvictableIdleTimeMillis: 900000
# 配置检测连接是否有效
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
webStatFilter:
enabled: true
statViewServlet:
enabled: true
# 设置白名单,不填则允许所有访问
allow:
url-pattern: /druid/*
# 控制台管理用户名和密码
login-username: ruoyi
login-password: 123456
filter:
stat:
enabled: true
# 慢SQL记录
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: true
wall:
config:
multi-statement-allow: true
minio:
endpoint: http://127.0.0.1:9000 #内网地址
domain: http://127.0.0.1:9000 #外网访问地址
accessKey: minioadmin
secretKey: minioadmin
bucketName: box-im
imagePath: image
filePath: file
videoPath: video
expireIn: 180 # 文件过期时间,单位:天
webrtc:
max-channel: 9 # 多人通话最大通道数量最大不能超过16,建议值:4,9,16
iceServers:
- urls: stun:stun.l.google.com:19302

@ -0,0 +1,74 @@
# 数据源配置
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
druid:
# 主库数据源
master:
url: jdbc:mysql://101.43.111.159:3306/yoga?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
# url: jdbc:mysql://localhost:3306/yj?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: '!Runpeng888'
# password: 123456
# 从库数据源
slave:
# 从数据源开关/默认关闭
enabled: false
url:
username:
password:
# 初始连接数
initialSize: 5
# 最小连接池数量
minIdle: 10
# 最大连接池数量
maxActive: 20
# 配置获取连接等待超时的时间
maxWait: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis: 300000
# 配置一个连接在池中最大生存的时间,单位是毫秒
maxEvictableIdleTimeMillis: 900000
# 配置检测连接是否有效
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
webStatFilter:
enabled: true
statViewServlet:
enabled: true
# 设置白名单,不填则允许所有访问
allow:
url-pattern: /druid/*
# 控制台管理用户名和密码
login-username: ruoyi
login-password: 123456
filter:
stat:
enabled: true
# 慢SQL记录
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: true
wall:
config:
multi-statement-allow: true
minio:
endpoint: http://101.43.111.159:9000 #内网地址
accessKey: KHuC4x81wQNGtDHC1dnS
secretKey: jCA4JpAJIIPXfIUJCWn0dZXKs2QCv5007dEhU1KB
bucketName: yoga-im
imagePath: image
filePath: file
videoPath: video
expireIn: 180 # 文件过期时间,单位:天
webrtc:
max-channel: 9 # 多人通话最大通道数量最大不能超过16,建议值:4,9,16
iceServers:
- urls: stun:stun.l.google.com:19302

@ -1,7 +1,7 @@
# 项目相关配置 # 项目相关配置
ruoyi: ruoyi:
# 名称 # 名称
name: RuoYi name: yoga
# 版本 # 版本
version: 3.8.3 version: 3.8.3
# 版权年份 # 版权年份
@ -10,7 +10,7 @@ ruoyi:
demoEnabled: true demoEnabled: true
# 文件路径 示例( Windows配置D:/ruoyi/uploadPathLinux配置 /home/ruoyi/uploadPath # 文件路径 示例( Windows配置D:/ruoyi/uploadPathLinux配置 /home/ruoyi/uploadPath
# profile: D:/ruoyi/uploadPath # profile: D:/ruoyi/uploadPath
profile: ../ruoyi/uploadPath profile: /workspace/project/yoga/uploadPath
# 获取ip地址开关 # 获取ip地址开关
addressEnabled: false addressEnabled: false
# 验证码类型 math 数组计算 char 字符验证 # 验证码类型 math 数组计算 char 字符验证
@ -20,7 +20,6 @@ ruoyi:
server: server:
# 服务器的HTTP端口默认为8080 # 服务器的HTTP端口默认为8080
port: 8083 port: 8083
# port: 8083
servlet: servlet:
# 应用的访问路径 # 应用的访问路径
context-path: / context-path: /
@ -51,12 +50,15 @@ user:
# Spring配置 # Spring配置
spring: spring:
jackson:
parser:
allow-numeric-leading-zeros: true
# 资源信息 # 资源信息
messages: messages:
# 国际化资源文件路径 # 国际化资源文件路径
basename: i18n/messages basename: i18n/messages
profiles: profiles:
active: druid active: dev
# 文件上传 # 文件上传
servlet: servlet:
multipart: multipart:
@ -91,24 +93,32 @@ spring:
max-active: 8 max-active: 8
# #连接池最大阻塞等待时间(使用负值表示没有限制) # #连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1ms max-wait: -1ms
mvc:
pathmatch:
matching-strategy: ant_path_matcher
# token配置 # token配置
token: token:
# 令牌自定义标识 # 令牌自定义标识
header: Authorization header: Authorization
# 令牌密钥 # 令牌密钥
secret: abcdefghijklmnopqrstuvwxyz secret: 4b5c4d8cc1a5d54afac74291c8f43dc6
# 令牌有效期( 3000分钟 # 令牌有效期( 3000分钟
expireTime: 3000 expireTime: 1800
appuserExpireTime: 1800
mybatis-plus:
# 搜索指定包别名
typeAliasesPackage: com.ruoyi.**.domain
# 配置mapper的扫描找到所有的mapper.xml映射文件
mapperLocations: classpath*:mapper/**/*Mapper.xml
# 加载全局的配置文件
configLocation: classpath:mybatis/mybatis-config.xml
global-config:
db-config:
id-type: AUTO # ID自增
# MyBatis配置 # MyBatis配置
mybatis:
# 搜索指定包别名
typeAliasesPackage: com.ruoyi.**.domain
# 配置mapper的扫描找到所有的mapper.xml映射文件
mapperLocations: classpath*:mapper/**/*Mapper.xml
# 加载全局的配置文件
configLocation: classpath:mybatis/mybatis-config.xml
# PageHelper分页插件 # PageHelper分页插件
pagehelper: pagehelper:
@ -130,12 +140,8 @@ xss:
# 排除链接(多个用逗号分隔) # 排除链接(多个用逗号分隔)
excludes: /system/notice excludes: /system/notice
# 匹配链接 # 匹配链接
urlPatterns: /system/*,/monitor/*,/tool/* urlPatterns: /api/*,/tool/*
wechat:
token: runpeng
mybatis-plus:
# 搜索指定包别名
typeAliasesPackage: com.ruoyi.**.domain
# 配置mapper的扫描找到所有的mapper.xml映射文件
mapperLocations: classpath*:mapper/**/*Mapper.xml
# 加载全局的配置文件
configLocation: classpath:mybatis/mybatis-config.xml

@ -64,7 +64,6 @@
<groupId>com.alibaba.fastjson2</groupId> <groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2</artifactId> <artifactId>fastjson2</artifactId>
</dependency> </dependency>
<!-- io常用工具类 --> <!-- io常用工具类 -->
<dependency> <dependency>
<groupId>commons-io</groupId> <groupId>commons-io</groupId>
@ -170,6 +169,32 @@
<artifactId>swagger-models</artifactId> <artifactId>swagger-models</artifactId>
<version>1.6.2</version> <version>1.6.2</version>
</dependency> </dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-joda</artifactId>
</dependency>
<!-- slf4j -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<!-- 引入操作JWT的相关依赖 -->
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>3.11.0</version>
</dependency>
</dependencies> </dependencies>
</project> </project>

@ -0,0 +1,188 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="web" name="Web">
<configuration>
<webroots />
<sourceRoots>
<root url="file://$MODULE_DIR$/src/main/java" />
</sourceRoots>
</configuration>
</facet>
<facet type="Spring" name="Spring">
<configuration />
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: org.springframework:spring-context-support:5.3.20" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-context:5.3.20" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-expression:5.3.20" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-core:5.3.20" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-jcl:5.3.20" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-web:5.3.20" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-security:2.5.14" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:2.5.14" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:2.5.14" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-logging:2.5.14" level="project" />
<orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.2.11" level="project" />
<orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.2.11" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-to-slf4j:2.17.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.17.2" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.7.36" level="project" />
<orderEntry type="library" name="Maven: jakarta.annotation:jakarta.annotation-api:1.3.5" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-aop:5.3.20" level="project" />
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-config:5.5.8" level="project" />
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-core:5.5.8" level="project" />
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-crypto:5.5.8" level="project" />
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-web:5.5.8" level="project" />
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper-spring-boot-starter:1.4.3" level="project" />
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-starter:2.2.2" level="project" />
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-autoconfigure:2.2.2" level="project" />
<orderEntry type="library" name="Maven: org.mybatis:mybatis:3.5.9" level="project" />
<orderEntry type="library" name="Maven: org.mybatis:mybatis-spring:2.0.7" level="project" />
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper-spring-boot-autoconfigure:1.4.3" level="project" />
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper:5.3.1" level="project" />
<orderEntry type="library" name="Maven: com.github.jsqlparser:jsqlparser:4.2" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-validation:2.5.14" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-el:9.0.63" level="project" />
<orderEntry type="library" name="Maven: org.hibernate.validator:hibernate-validator:6.2.3.Final" level="project" />
<orderEntry type="library" name="Maven: jakarta.validation:jakarta.validation-api:2.0.2" level="project" />
<orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.4.3.Final" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.12.0" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.12.6.1" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.12.6" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.12.6" level="project" />
<orderEntry type="library" name="Maven: com.alibaba.fastjson2:fastjson2:2.0.12" level="project" />
<orderEntry type="library" name="Maven: commons-io:commons-io:2.11.0" level="project" />
<orderEntry type="library" name="Maven: commons-fileupload:commons-fileupload:1.4" level="project" />
<orderEntry type="library" name="Maven: org.apache.poi:poi-ooxml:4.1.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.poi:poi:4.1.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-collections4:4.4" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-math3:3.6.1" level="project" />
<orderEntry type="library" name="Maven: com.zaxxer:SparseBitSet:1.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.poi:poi-ooxml-schemas:4.1.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.xmlbeans:xmlbeans:3.1.0" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-compress:1.19" level="project" />
<orderEntry type="library" name="Maven: com.github.virtuald:curvesapi:1.06" level="project" />
<orderEntry type="library" name="Maven: org.yaml:snakeyaml:1.28" level="project" />
<orderEntry type="library" name="Maven: io.jsonwebtoken:jjwt:0.9.1" level="project" />
<orderEntry type="library" name="Maven: javax.xml.bind:jaxb-api:2.3.1" level="project" />
<orderEntry type="library" name="Maven: javax.activation:javax.activation-api:1.2.0" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-data-redis:2.5.14" level="project" />
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-redis:2.5.11" level="project" />
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-keyvalue:2.5.11" level="project" />
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-commons:2.5.11" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-tx:5.3.20" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-oxm:5.3.20" level="project" />
<orderEntry type="library" name="Maven: io.lettuce:lettuce-core:6.1.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-common:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-handler:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-transport:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.projectreactor:reactor-core:3.4.18" level="project" />
<orderEntry type="library" name="Maven: org.reactivestreams:reactive-streams:1.0.3" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-pool2:2.9.0" level="project" />
<orderEntry type="library" name="Maven: eu.bitwalker:UserAgentUtils:1.21" level="project" />
<orderEntry type="library" name="Maven: javax.servlet:javax.servlet-api:4.0.1" level="project" />
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-boot-starter:3.4.3.4" level="project" />
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus:3.4.3.4" level="project" />
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-extension:3.4.3.4" level="project" />
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-core:3.4.3.4" level="project" />
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-annotation:3.4.3.4" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-autoconfigure:2.5.14" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-jdbc:2.5.14" level="project" />
<orderEntry type="library" name="Maven: com.zaxxer:HikariCP:4.0.3" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-jdbc:5.3.20" level="project" />
<orderEntry type="library" name="Maven: cn.hutool:hutool-all:5.7.1" level="project" />
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.18.12" level="project" />
<orderEntry type="library" name="Maven: cn.jpush.api:jiguang-common:1.1.7" level="project" />
<orderEntry type="library" name="Maven: org.bouncycastle:bcprov-jdk15on:1.60" level="project" />
<orderEntry type="library" name="Maven: org.bouncycastle:bcpkix-jdk15on:1.60" level="project" />
<orderEntry type="library" name="Maven: cn.jpush.api:jpush-client:3.4.3" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.13" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.15" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-all:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-buffer:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-codec:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-codec-dns:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-codec-haproxy:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-codec-http:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-codec-http2:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-codec-memcache:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-codec-mqtt:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-codec-redis:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-codec-smtp:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-codec-socks:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-codec-stomp:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-codec-xml:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-handler-proxy:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-resolver:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-resolver-dns:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-transport-rxtx:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-transport-sctp:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-transport-udt:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-transport-classes-epoll:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-transport-native-unix-common:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-transport-classes-kqueue:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-resolver-dns-classes-macos:4.1.77.Final" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-transport-native-epoll:linux-x86_64:4.1.77.Final" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-transport-native-epoll:linux-aarch_64:4.1.77.Final" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-transport-native-kqueue:osx-x86_64:4.1.77.Final" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-transport-native-kqueue:osx-aarch_64:4.1.77.Final" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-resolver-dns-native-macos:osx-x86_64:4.1.77.Final" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-resolver-dns-native-macos:osx-aarch_64:4.1.77.Final" level="project" />
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.9" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-boot-starter:3.0.0" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-oas:3.0.0" level="project" />
<orderEntry type="library" name="Maven: io.swagger.core.v3:swagger-annotations:2.1.2" level="project" />
<orderEntry type="library" name="Maven: io.swagger.core.v3:swagger-models:2.1.2" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-spi:3.0.0" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-schema:3.0.0" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-core:3.0.0" level="project" />
<orderEntry type="library" name="Maven: net.bytebuddy:byte-buddy:1.10.22" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-spring-web:3.0.0" level="project" />
<orderEntry type="library" name="Maven: io.github.classgraph:classgraph:4.8.83" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-spring-webmvc:3.0.0" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-spring-webflux:3.0.0" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger-common:3.0.0" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.mapstruct:mapstruct:1.3.1.Final" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-data-rest:3.0.0" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-bean-validators:3.0.0" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger2:3.0.0" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger-ui:3.0.0" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml:classmate:1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-core:2.0.0.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-metadata:2.0.0.RELEASE" level="project" />
<orderEntry type="library" name="Maven: io.swagger:swagger-models:1.6.2" level="project" />
<orderEntry type="library" name="Maven: io.swagger:swagger-annotations:1.6.2" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-beans:5.3.20" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-joda:2.12.6" level="project" />
<orderEntry type="library" name="Maven: joda-time:joda-time:2.10.8" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.36" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-websocket:2.5.14" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:2.5.14" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-json:2.5.14" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.12.6" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.12.6" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.module:jackson-module-parameter-names:2.12.6" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-tomcat:2.5.14" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-core:9.0.63" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-websocket:9.0.63" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-webmvc:5.3.20" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-messaging:5.3.20" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-websocket:5.3.20" level="project" />
<orderEntry type="library" name="Maven: com.auth0:java-jwt:3.11.0" level="project" />
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.15" level="project" />
</component>
</module>

@ -0,0 +1,15 @@
package com.ruoyi.common.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 线
*/
@Retention(RetentionPolicy.RUNTIME)//运行时生效
@Target(ElementType.METHOD)//作用在方法上
public @interface OnlineCheck {
}

@ -1,4 +1,4 @@
package com.ruoyi.framework.config; package com.ruoyi.common.config;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import org.springframework.data.redis.serializer.RedisSerializer; import org.springframework.data.redis.serializer.RedisSerializer;
@ -18,6 +18,7 @@ public class FastJson2JsonRedisSerializer<T> implements RedisSerializer<T>
private Class<T> clazz; private Class<T> clazz;
public FastJson2JsonRedisSerializer(Class<T> clazz) public FastJson2JsonRedisSerializer(Class<T> clazz)
{ {
super(); super();

@ -0,0 +1,11 @@
package com.ruoyi.common.config;
import lombok.Data;
@Data
public class ICEServer {
private String urls;
private String username;
private String credential;
}

@ -0,0 +1,22 @@
package com.ruoyi.common.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
/**
* WebSocketWebSocket
*/
@Configuration
public class WebSocketConfig {
/**
* bean@ServerEndpointWebsocket Endpoint()Websocket bean
* 使servlet使springbootServerEndpointExporter
*/
@Bean
public ServerEndpointExporter serverEndpointExporter() {
return new ServerEndpointExporter();
}
}

@ -0,0 +1,19 @@
package com.ruoyi.common.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
@Data
@Component
@ConfigurationProperties(prefix = "webrtc")
public class WebrtcConfig {
private Integer maxChannel = 9;
private List<ICEServer> iceServers = new ArrayList<>();
}

@ -11,6 +11,8 @@ public class CacheConstants
* redis key * redis key
*/ */
public static final String LOGIN_TOKEN_KEY = "login_tokens:"; public static final String LOGIN_TOKEN_KEY = "login_tokens:";
public static final String LOGIN_APPUSER_TOKEN_KEY = "login_appUser_tokens:";
public static final String APPUSER_INFO = "appUser_info";
/** /**
* redis key * redis key

@ -2,6 +2,9 @@ package com.ruoyi.common.constant;
import io.jsonwebtoken.Claims; import io.jsonwebtoken.Claims;
import java.util.HashMap;
import java.util.Map;
/** /**
* *
* *
@ -83,6 +86,7 @@ public class Constants
* *
*/ */
public static final String LOGIN_USER_KEY = "login_user_key"; public static final String LOGIN_USER_KEY = "login_user_key";
public static final String LOGIN_APPUSER_KEY = "login_appUser_key";
/** /**
* ID * ID
@ -139,4 +143,133 @@ public class Constants
*/ */
public static final String[] JOB_ERROR_STR = { "java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml", public static final String[] JOB_ERROR_STR = { "java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml",
"org.springframework", "org.apache", "com.ruoyi.common.utils.file" }; "org.springframework", "org.apache", "com.ruoyi.common.utils.file" };
/**
*
*/
public static class LOGIN_INFO {
public static final String WRONG = "账号或密码错误";
public static final String FORBIDDEN = "您的账号被禁用,请联系管理员";
public static final String SUCCESS = "登录成功";
public static final String TO_REGISTER = "请先注册";
}
/**
*
*/
public static class VERIFY_CODE_INFO {
public static final String EXPIRED = "验证码已过期";
public static final String WRONG = "验证码错误";
}
/**
* appUser
*/
public static class MEMBER_ACCOUNT_STATUS {
public static final Integer FORBIDDEN = 0;
public static final Integer NORMAL = 1;
}
/**
*
*/
public static final Map<Integer, String> WEEK_DAY_MAP = new HashMap<>();
/**
*
* key:
* value:
*/
public static final Map<Integer, String> CLA_TIME_MAP = new HashMap<>();
static {
WEEK_DAY_MAP.clear();
WEEK_DAY_MAP.put(2, "星期一");
WEEK_DAY_MAP.put(3, "星期二");
WEEK_DAY_MAP.put(4, "星期三");
WEEK_DAY_MAP.put(5, "星期四");
WEEK_DAY_MAP.put(6, "星期五");
WEEK_DAY_MAP.put(7, "星期六");
WEEK_DAY_MAP.put(1, "星期日");
CLA_TIME_MAP.clear();
CLA_TIME_MAP.put(8, "08:30");
CLA_TIME_MAP.put(9, "10:00");
CLA_TIME_MAP.put(10, "11:00");
CLA_TIME_MAP.put(11, "14:00");
CLA_TIME_MAP.put(12, "15:00");
CLA_TIME_MAP.put(13, "16:00");
CLA_TIME_MAP.put(14, "17:00");
CLA_TIME_MAP.put(15, "18:00");
CLA_TIME_MAP.put(16, "19:30");
}
/**
* 0->1->
*/
public static class PublishStatus {
public static final Integer GROUNDING = 1;
public static final Integer UNDERCARRIAGE = 0;
}
/**
* 0->1->2->
*/
public static class PayType {
public static final Integer NO_PAY = 0;
public static final Integer ALIPAY = 1;
public static final Integer WECHAT = 2;
}
/**
* 0->1->2->3->4->5->
*/
public static class OrderStatus {
public static final Integer NOTPAID = 0;
public static final Integer SEND = 1;
public static final Integer GET = 2;
public static final Integer CONFIRM = 3;
public static final Integer CLOSED = 4;
public static final Integer UNVAILD = 5;
}
/**
* cart
*/
public static class OrderFrom {
public static final String CART = "cart";
}
/**
* app
* -1-> 0->1->2->/使3->4->5-> -2->
*/
public static class AppOrderStatus{
public static final Integer ALL = -1;
public static final Integer UN_PAY = 0;
public static final Integer NOT_DELIVERED = 1;
public static final Integer DELIVERED = 2;
public static final Integer COMPLETED = 3;
public static final Integer CLOSED = 4;
public static final Integer INVALID = 5;
public static final Integer REFUND = -2;
}
/**
* 1 2 3退
*/
public static class PaymentOpType {
public static final Integer PAY = 1;
public static final Integer WITHDRAWAL = 2;
public static final Integer REFUND = 3;
}
/**
* 0 1
*/
public static class PaymentStatus {
public static final Integer INCOMPLETE = 0;
public static final Integer COMPLETE = 1;
}
public static class OptType {
public static final Integer AGREE = 1;
public static final Integer REFUSE = 2;
public static final Integer GIVING = 3;
}
} }

@ -3,6 +3,8 @@ package com.ruoyi.common.core.controller;
import java.beans.PropertyEditorSupport; import java.beans.PropertyEditorSupport;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import com.ruoyi.common.core.domain.model.LoginUser;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.WebDataBinder;
@ -11,7 +13,7 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.ruoyi.common.constant.HttpStatus; import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.core.domain.model.AppLoginUser;
import com.ruoyi.common.core.page.PageDomain; import com.ruoyi.common.core.page.PageDomain;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.page.TableSupport; import com.ruoyi.common.core.page.TableSupport;

@ -1,105 +0,0 @@
package com.ruoyi.common.core.domain;
import java.io.Serializable;
import com.ruoyi.common.constant.HttpStatus;
/**
*
*
* @author ruoyi
*/
public class R<T> implements Serializable
{
private static final long serialVersionUID = 1L;
/** 成功 */
public static final int SUCCESS = HttpStatus.SUCCESS;
/** 失败 */
public static final int FAIL = HttpStatus.ERROR;
private int code;
private String msg;
private T data;
public static <T> R<T> ok()
{
return restResult(null, SUCCESS, "操作成功");
}
public static <T> R<T> ok(T data)
{
return restResult(data, SUCCESS, "操作成功");
}
public static <T> R<T> ok(T data, String msg)
{
return restResult(data, SUCCESS, msg);
}
public static <T> R<T> fail()
{
return restResult(null, FAIL, "操作失败");
}
public static <T> R<T> fail(String msg)
{
return restResult(null, FAIL, msg);
}
public static <T> R<T> fail(T data)
{
return restResult(data, FAIL, "操作失败");
}
public static <T> R<T> fail(T data, String msg)
{
return restResult(data, FAIL, msg);
}
public static <T> R<T> fail(int code, String msg)
{
return restResult(null, code, msg);
}
private static <T> R<T> restResult(T data, int code, String msg)
{
R<T> apiResult = new R<>();
apiResult.setCode(code);
apiResult.setData(data);
apiResult.setMsg(msg);
return apiResult;
}
public int getCode()
{
return code;
}
public void setCode(int code)
{
this.code = code;
}
public String getMsg()
{
return msg;
}
public void setMsg(String msg)
{
this.msg = msg;
}
public T getData()
{
return data;
}
public void setData(T data)
{
this.data = data;
}
}

@ -0,0 +1,90 @@
package com.ruoyi.common.core.domain.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.data.annotation.Id;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;
/**
* app yj_app_user
*
* @author zcc
*/
@ApiModel(description="会员信息对象")
@Data
@TableName("yj_app_user")
public class AppUser{
private static final long serialVersionUID = 1L;
@ApiModelProperty("ID")
@TableId(value = "app_user_id")
private Long id;
@ApiModelProperty("昵称")
private String nickName;
@ApiModelProperty("名称")
private String userName;
@ApiModelProperty("密码")
private String password;
@ApiModelProperty("手机号")
private String phoneNumber;
@ApiModelProperty("帐号启用状态:0->禁用1->启用")
private Integer status;
@ApiModelProperty("头像")
private String avatar;
@ApiModelProperty("性别0->未知1->男2->女")
private Integer gender;
@ApiModelProperty("用户所在城市")
private String city;
@ApiModelProperty("用户所在省份")
private String province;
@ApiModelProperty("用户所在国家")
private String country;
@ApiModelProperty("生日")
@Excel(name = "生日", width = 30, dateFormat = "yyyy-MM-dd")
private LocalDate birthday;
@ApiModelProperty("设备id")
private String registerId;
@ApiModelProperty("访问/浏览门店id")
private String visitStore;
@ApiModelProperty("小程序unionid")
private String unionid;
@ApiModelProperty("小程序openid")
private String openid;
/** 员工所属门店id */
private String storeId;
/** 员工所属商户id */
private String tenantId;
/** 最后登录IP */
private String loginIp;
/** 最后登录时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date loginDate;
}

@ -0,0 +1,112 @@
package com.ruoyi.common.core.domain.model;
import java.util.Collection;
import java.util.Set;
import com.ruoyi.common.core.domain.entity.AppUser;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import com.alibaba.fastjson2.annotation.JSONField;
import com.ruoyi.common.core.domain.entity.SysUser;
/**
*
*
* @author ruoyi
*/
@Data
public class AppLoginUser implements UserDetails
{
private static final long serialVersionUID = 1L;
private Long appUserId;
private String token;
private Long loginTime;
private Long expireTime;
/**
*
*/
private AppUser appUser;
public AppLoginUser(Long appUserId, String token, Long loginTime, Long expireTime, AppUser appUser) {
this.appUserId = appUserId;
this.token = token;
this.loginTime = loginTime;
this.expireTime = expireTime;
this.appUser = appUser;
}
public AppLoginUser() {
}
public AppLoginUser(Long appUserId,AppUser appUser) {
this.appUserId = appUserId;
this.appUser = appUser;
}
@JSONField(serialize = false)
@Override
public String getPassword()
{
return appUser.getPassword();
}
@Override
public String getUsername()
{
return appUser.getUserName();
}
/**
* ,
*/
@JSONField(serialize = false)
@Override
public boolean isAccountNonExpired()
{
return true;
}
/**
* ,
*
* @return
*/
@JSONField(serialize = false)
@Override
public boolean isAccountNonLocked()
{
return true;
}
/**
* (),
*
* @return
*/
@JSONField(serialize = false)
@Override
public boolean isCredentialsNonExpired()
{
return true;
}
/**
* ,
*
* @return
*/
@JSONField(serialize = false)
@Override
public boolean isEnabled()
{
return true;
}
@Override
public Collection<? extends GrantedAuthority> getAuthorities()
{
return null;
}
}

@ -0,0 +1,68 @@
package com.ruoyi.common.core.domain.model;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
/**
*
*
* @author ruoyi
*/
@Data
public class AppUserLoginBody
{
/**
*
*/
private String username;
/**
*
*/
private String phonenumber;
/**
*
*/
private String smsCode;
/**
*
*/
private String password;
/**
*
*/
private String code;
/**
* id
*/
private String registerId;
/**
* code openID
*/
private String miniAppCode;
@Max(value = 2, message = "登录终端类型取值范围:0,2")
@Min(value = 1, message = "登录终端类型取值范围:0,2")
@NotNull(message = "登录终端类型不可为空")
@Schema(description = "登录终端 1:app 2:小程序")
private Integer terminal;
/**
*
*/
private String uuid;
/**
* 访
*/
private String visitStoreId;
}

@ -1,12 +1,13 @@
package com.ruoyi.common.core.domain.model; package com.ruoyi.common.core.domain.model;
import io.swagger.annotations.ApiModelProperty; import lombok.Data;
/** /**
* *
* *
* @author ruoyi * @author ruoyi
*/ */
@Data
public class LoginBody public class LoginBody
{ {
/** /**
@ -14,11 +15,6 @@ public class LoginBody
*/ */
private String username; private String username;
/**
*
*/
private String phonenumber;
private String account;
/** /**
* *
*/ */
@ -29,75 +25,8 @@ public class LoginBody
*/ */
private String code; private String code;
@ApiModelProperty("设备id")
private String registerId;
/** /**
* *
*/ */
private String uuid; private String uuid = "";
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public String getRegisterId() {
return registerId;
}
public void setRegisterId(String registerId) {
this.registerId = registerId;
}
public String getPhonenumber() {
return phonenumber;
}
public void setPhonenumber(String phonenumber) {
this.phonenumber = phonenumber;
}
public String getUsername()
{
return username;
}
public void setUsername(String username)
{
this.username = username;
}
public String getPassword()
{
return password;
}
public void setPassword(String password)
{
this.password = password;
}
public String getCode()
{
return code;
}
public void setCode(String code)
{
this.code = code;
}
public String getUuid()
{
return uuid;
}
public void setUuid(String uuid)
{
this.uuid = uuid;
}
} }

@ -1,11 +1,12 @@
package com.ruoyi.common.core.domain.model; package com.ruoyi.common.core.domain.model;
import java.util.Collection;
import java.util.Set;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import com.alibaba.fastjson2.annotation.JSONField; import com.alibaba.fastjson2.annotation.JSONField;
import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.domain.entity.SysUser;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import java.util.Collection;
import java.util.Set;
/** /**
* *

@ -5,7 +5,7 @@ package com.ruoyi.common.core.domain.model;
* *
* @author ruoyi * @author ruoyi
*/ */
public class RegisterBody extends LoginBody public class RegisterBody extends AppUserLoginBody
{ {
} }

@ -0,0 +1,110 @@
package com.ruoyi.common.core.redis;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.concurrent.TimeUnit;
@Service
@Slf4j
public class RedisService {
@Autowired
private RedisCache redisCache;
public void setMatchList(Long userId, List<Long> userIds) {
String key = RedisKeys.MATCH_LIST_OF + userId;
redisCache.setCacheList(key, userIds);
redisCache.expire(key, 7, TimeUnit.DAYS);
}
public List<Long> getMatchList(Long userId) {
String key = RedisKeys.MATCH_LIST_OF + userId;
return redisCache.getCacheList(key);
}
public String getAddressList() {
String key = RedisKeys.ADDRESS_LIST_KEY;
return redisCache.getCacheObject(key);
}
public void setAddressList(String list) {
String key = RedisKeys.ADDRESS_LIST_KEY;
redisCache.setCacheObject(key,list);
}
public void setVerifyCode(String code) {
String key = RedisKeys.VERIFY_CODE + code;
redisCache.setCacheObject(key, code);
redisCache.expire(key, 5, TimeUnit.MINUTES);
}
public void deleteVerifyCode(String code) {
redisCache.deleteObject(RedisKeys.VERIFY_CODE + code);
}
public String getVerifyCode(String code) {
return redisCache.getCacheObject(RedisKeys.VERIFY_CODE + code);
}
public String getWechatToken() {
return redisCache.getCacheObject(RedisKeys.WECHAT_ACCESS_TOKEN);
}
public void setWechatToken(String token) {
redisCache.setCacheObject(RedisKeys.WECHAT_ACCESS_TOKEN, token, 100, TimeUnit.MINUTES);
}
public void setQrCode(String code, String scene) {
redisCache.setCacheObject(RedisKeys.WECHAT_QR_CODE + scene, code, 30, TimeUnit.DAYS);
}
public String getQrCode(String scene) {
return redisCache.getCacheObject(RedisKeys.WECHAT_QR_CODE + scene);
}
interface RedisKeys {
String MATCH_LIST_OF = "MATCH_LIST_OF_";
String ADDRESS_LIST_KEY = "ADDRESS_LIST_KEY_";
String WECHAT_ACCESS_TOKEN = "WECHAT_ACCESS_TOKEN_";
String WECHAT_QR_CODE = "WECHAT_QR_CODE_";
String VERIFY_CODE = "VERIFY_CODE:";
}
/**
* redis ---
*
* @param key
* @param jobInfo
* @param lockSecond
* @return
* @throws Exception
*/
public void lock(String key, String jobInfo, Integer lockSecond) throws Exception {
String existJobInfo = redisCache.getCacheObject(key);
if (StringUtils.isNotEmpty(existJobInfo)) {
log.info("获取锁失败: redisKey: {}, existJobInfo: {}", key, existJobInfo);
throw new Exception("请不要反复提交订单!");
}
redisCache.setCacheObject(key, jobInfo, lockSecond, TimeUnit.SECONDS);
}
/**
* redis ---
*
* @param key
* @param jobInfo
* @throws Exception
*/
public void unLock(String key, String jobInfo) throws Exception {
String existJobInfo = redisCache.getCacheObject(key);
if (jobInfo.equals(existJobInfo)) {
redisCache.deleteObject(key);
} else {
throw new Exception(String.format("释放锁异常: redisKey: %s, existJobInfo: %s, jobInfo: %s", key, existJobInfo, jobInfo));
}
}
}

@ -0,0 +1,31 @@
package com.ruoyi.common.enums;
/**
*
*
* @author ruoyi
*/
public enum AftersaleStatus
{
APPLY(0, "待处理"),
WAIT(1, "退货中"),
SUCCESS(2, "已完成"),
REJECT(3, "已拒绝"),
CANCEL(4,"用户取消");
private final Integer type;
private final String msg;
private AftersaleStatus(Integer type, String msg) {
this.type = type;
this.msg = msg;
}
public Integer getType() {
return this.type;
}
public String getMsg() {
return this.msg;
}
}

@ -0,0 +1,31 @@
package com.ruoyi.common.enums;
/**
*
*
* @author ruoyi
*/
public enum OrderRefundStatus
{
NO_REFUND(1, "无售后"),
APPLY(2, "申请中"),
WAIT(3, "退款中"),
SUCCESS(4, "退款成功"),
FAIL(5,"退款失败");
private final Integer type;
private final String msg;
private OrderRefundStatus(Integer type, String msg) {
this.type = type;
this.msg = msg;
}
public Integer getType() {
return this.type;
}
public String getMsg() {
return this.msg;
}
}

@ -0,0 +1,34 @@
package com.ruoyi.common.enums;
/**
*
*
* @author ruoyi
*/
public enum OrderStatus
{
ALL_DATA(-1,"全部订单"),
UN_PAY(0, "待付款"),
NOT_DELIVERED(1, "待发货"),
DELIVERED(2, "待收货"),
COMPLETE(3, "已完成"),
CLOSED(4, "已关闭"),
INVALID(5, "无效订单"),
REFUUND(-2, "售后订单");
private final Integer type;
private final String msg;
private OrderStatus(Integer type, String msg) {
this.type = type;
this.msg = msg;
}
public Integer getType() {
return this.type;
}
public String getMsg() {
return this.msg;
}
}

@ -1,14 +1,21 @@
package com.ruoyi.common.exception; package com.ruoyi.common.exception;
import com.ruoyi.common.im.enums.ResultCode;
import lombok.Data;
import java.io.Serializable;
/** /**
* *
* *
* @author ruoyi * @author ruoyi
*/ */
public class GlobalException extends RuntimeException @Data
public class GlobalException extends RuntimeException implements Serializable
{ {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private Integer code;
/** /**
* *
*/ */
@ -33,26 +40,21 @@ public class GlobalException extends RuntimeException
this.message = message; this.message = message;
} }
public String getDetailMessage()
{
return detailMessage;
}
public GlobalException setDetailMessage(String detailMessage) public GlobalException(Integer code, String message) {
{ this.code = code;
this.detailMessage = detailMessage; this.message = message;
return this;
} }
@Override public GlobalException(ResultCode resultCode, String message) {
public String getMessage() this.code = resultCode.getCode();
{ this.message = message;
return message;
} }
public GlobalException setMessage(String message) public GlobalException(ResultCode resultCode) {
{ this.code = resultCode.getCode();
this.message = message; this.message = resultCode.getMsg();
return this;
} }
} }

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save