diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index 06edc15f..00000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1 +0,0 @@ -custom: http://doc.ruoyi.vip/ruoyi-cloud/other/donate.html diff --git a/LICENSE b/LICENSE deleted file mode 100644 index bd95df18..00000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2020 若依 - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/README.md b/README.md index 67f4a4d3..ca673ba5 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ ## 平台简介 -若依是一套全部开源的快速开发平台,毫无保留给个人及企业免费使用。 +租研舍是一套全部开源的快速开发平台,毫无保留给个人及企业免费使用。 * 采用前后端分离的模式,微服务版本前端(基于 [RuoYi-Vue](https://gitee.com/y_project/RuoYi-Vue))。 * 后端采用Spring Boot、Spring Cloud & Alibaba。 @@ -22,7 +22,7 @@ * 阿里云折扣场:[点我进入](http://aly.ruoyi.vip),腾讯云秒杀场:[点我进入](http://txy.ruoyi.vip)   * 阿里云优惠券:[点我领取](https://www.aliyun.com/minisite/goods?userCode=brki8iof&share_source=copy_link),腾讯云优惠券:[点我领取](https://cloud.tencent.com/redirect.php?redirect=1025&cps_key=198c8df2ed259157187173bc7f4f32fd&from=console)   -#### 友情链接 [若依/RuoYi-Cloud](https://gitee.com/zhangmrit/ruoyi-cloud) Ant Design版本。 +#### 友情链接 [租研舍/RuoYi-Cloud](https://gitee.com/zhangmrit/ruoyi-cloud) Ant Design版本。 ## 系统模块 @@ -126,6 +126,6 @@ com.ruoyi -## 若依微服务交流群 +## 租研舍微服务交流群 QQ群: [![加入QQ群](https://img.shields.io/badge/已满-42799195-blue.svg)](https://jq.qq.com/?_wv=1027&k=yqInfq0S) [![加入QQ群](https://img.shields.io/badge/已满-170157040-blue.svg)](https://jq.qq.com/?_wv=1027&k=Oy1mb3p8) [![加入QQ群](https://img.shields.io/badge/已满-130643120-blue.svg)](https://jq.qq.com/?_wv=1027&k=rvxkJtXK) [![加入QQ群](https://img.shields.io/badge/已满-225920371-blue.svg)](https://jq.qq.com/?_wv=1027&k=0Ck3PvTe) [![加入QQ群](https://img.shields.io/badge/已满-201705537-blue.svg)](https://jq.qq.com/?_wv=1027&k=FnHHP4TT) [![加入QQ群](https://img.shields.io/badge/已满-236543183-blue.svg)](https://jq.qq.com/?_wv=1027&k=qdT1Ojpz) [![加入QQ群](https://img.shields.io/badge/已满-213618602-blue.svg)](https://jq.qq.com/?_wv=1027&k=nw3OiyXs) [![加入QQ群](https://img.shields.io/badge/已满-148794840-blue.svg)](https://jq.qq.com/?_wv=1027&k=kiU5WDls) [![加入QQ群](https://img.shields.io/badge/已满-118752664-blue.svg)](https://jq.qq.com/?_wv=1027&k=MtBy6YfT) [![加入QQ群](https://img.shields.io/badge/已满-101038945-blue.svg)](https://jq.qq.com/?_wv=1027&k=FqImHgH2) [![加入QQ群](https://img.shields.io/badge/已满-128355254-blue.svg)](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=G4jZ4EtdT50PhnMBudTnEwgonxkXOscJ&authKey=FkGHYfoTKlGE6wHdKdjH9bVoOgQjtLP9WM%2Fj7pqGY1msoqw9uxDiBo39E2mLgzYg&noverify=0&group_code=128355254) [![加入QQ群](https://img.shields.io/badge/已满-179219821-blue.svg)](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=irnwcXhbLOQEv1g-TwGifjNTA_f4wZiA&authKey=4bpzEwhcUY%2FvsPDHvzYn6xfoS%2FtOArvZ%2BGXzfr7O0%2FEqLfkKA%2BuCDXlzHIFg8t93&noverify=0&group_code=179219821) [![加入QQ群](https://img.shields.io/badge/158753145-blue.svg)](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=lx1uEdEDuxeM7rUvF3qmlFdqKqdJ5Z-R&authKey=rgyPW9yhhh4IIURKVFa6NgP3qiqH04WAzrJ0trsgkr3pjzm6sKIOGyA58oOjoj%2FJ&noverify=0&group_code=158753145) 点击按钮入群。 \ No newline at end of file diff --git a/docker/copy.sh b/docker/copy.sh deleted file mode 100644 index 5d895913..00000000 --- a/docker/copy.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh - -# 复制项目的文件到对应docker路径,便于一键生成镜像。 -usage() { - echo "Usage: sh copy.sh" - exit 1 -} - - -# copy sql -echo "begin copy sql " -cp ../sql/ry_20240629.sql ./mysql/db -cp ../sql/ry_config_20240902.sql ./mysql/db - -# copy html -echo "begin copy html " -cp -r ../ruoyi-ui/dist/** ./nginx/html/dist - - -# copy jar -echo "begin copy ruoyi-gateway " -cp ../ruoyi-gateway/target/ruoyi-gateway.jar ./ruoyi/gateway/jar - -echo "begin copy ruoyi-auth " -cp ../ruoyi-auth/target/ruoyi-auth.jar ./ruoyi/auth/jar - -echo "begin copy ruoyi-visual " -cp ../ruoyi-visual/ruoyi-monitor/target/ruoyi-visual-monitor.jar ./ruoyi/visual/monitor/jar - -echo "begin copy ruoyi-modules-system " -cp ../ruoyi-modules/ruoyi-system/target/ruoyi-modules-system.jar ./ruoyi/modules/system/jar - -echo "begin copy ruoyi-modules-file " -cp ../ruoyi-modules/ruoyi-file/target/ruoyi-modules-file.jar ./ruoyi/modules/file/jar - -echo "begin copy ruoyi-modules-job " -cp ../ruoyi-modules/ruoyi-job/target/ruoyi-modules-job.jar ./ruoyi/modules/job/jar - -echo "begin copy ruoyi-modules-gen " -cp ../ruoyi-modules/ruoyi-gen/target/ruoyi-modules-gen.jar ./ruoyi/modules/gen/jar - diff --git a/docker/deploy.sh b/docker/deploy.sh deleted file mode 100644 index 02489092..00000000 --- a/docker/deploy.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/sh - -# 使用说明,用来提示输入参数 -usage() { - echo "Usage: sh 执行脚本.sh [port|base|modules|stop|rm]" - exit 1 -} - -# 开启所需端口 -port(){ - firewall-cmd --add-port=80/tcp --permanent - firewall-cmd --add-port=8080/tcp --permanent - firewall-cmd --add-port=8848/tcp --permanent - firewall-cmd --add-port=9848/tcp --permanent - firewall-cmd --add-port=9849/tcp --permanent - firewall-cmd --add-port=6379/tcp --permanent - firewall-cmd --add-port=3306/tcp --permanent - firewall-cmd --add-port=9100/tcp --permanent - firewall-cmd --add-port=9200/tcp --permanent - firewall-cmd --add-port=9201/tcp --permanent - firewall-cmd --add-port=9202/tcp --permanent - firewall-cmd --add-port=9203/tcp --permanent - firewall-cmd --add-port=9300/tcp --permanent - service firewalld restart -} - -# 启动基础环境(必须) -base(){ - docker-compose up -d ruoyi-mysql ruoyi-redis ruoyi-nacos -} - -# 启动程序模块(必须) -modules(){ - docker-compose up -d ruoyi-nginx ruoyi-gateway ruoyi-auth ruoyi-modules-system -} - -# 关闭所有环境/模块 -stop(){ - docker-compose stop -} - -# 删除所有环境/模块 -rm(){ - docker-compose rm -} - -# 根据输入参数,选择执行对应方法,不输入则执行使用说明 -case "$1" in -"port") - port -;; -"base") - base -;; -"modules") - modules -;; -"stop") - stop -;; -"rm") - rm -;; -*) - usage -;; -esac diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml deleted file mode 100644 index 5fb8da1c..00000000 --- a/docker/docker-compose.yml +++ /dev/null @@ -1,140 +0,0 @@ -version : '3.8' -services: - ruoyi-nacos: - container_name: ruoyi-nacos - image: nacos/nacos-server - build: - context: ./nacos - environment: - - MODE=standalone - volumes: - - ./nacos/logs/:/home/nacos/logs - - ./nacos/conf/application.properties:/home/nacos/conf/application.properties - ports: - - "8848:8848" - - "9848:9848" - - "9849:9849" - depends_on: - - ruoyi-mysql - ruoyi-mysql: - container_name: ruoyi-mysql - image: mysql:5.7 - build: - context: ./mysql - ports: - - "3306:3306" - volumes: - - ./mysql/conf:/etc/mysql/conf.d - - ./mysql/logs:/logs - - ./mysql/data:/var/lib/mysql - command: [ - 'mysqld', - '--innodb-buffer-pool-size=80M', - '--character-set-server=utf8mb4', - '--collation-server=utf8mb4_unicode_ci', - '--default-time-zone=+8:00', - '--lower-case-table-names=1' - ] - environment: - MYSQL_DATABASE: 'ry-cloud' - MYSQL_ROOT_PASSWORD: password - ruoyi-redis: - container_name: ruoyi-redis - image: redis - build: - context: ./redis - ports: - - "6379:6379" - volumes: - - ./redis/conf/redis.conf:/home/ruoyi/redis/redis.conf - - ./redis/data:/data - command: redis-server /home/ruoyi/redis/redis.conf - ruoyi-nginx: - container_name: ruoyi-nginx - image: nginx - build: - context: ./nginx - ports: - - "80:80" - volumes: - - ./nginx/html/dist:/home/ruoyi/projects/ruoyi-ui - - ./nginx/conf/nginx.conf:/etc/nginx/nginx.conf - - ./nginx/logs:/var/log/nginx - - ./nginx/conf.d:/etc/nginx/conf.d - depends_on: - - ruoyi-gateway - links: - - ruoyi-gateway - ruoyi-gateway: - container_name: ruoyi-gateway - build: - context: ./ruoyi/gateway - dockerfile: dockerfile - ports: - - "8080:8080" - depends_on: - - ruoyi-redis - links: - - ruoyi-redis - ruoyi-auth: - container_name: ruoyi-auth - build: - context: ./ruoyi/auth - dockerfile: dockerfile - ports: - - "9200:9200" - depends_on: - - ruoyi-redis - links: - - ruoyi-redis - ruoyi-modules-system: - container_name: ruoyi-modules-system - build: - context: ./ruoyi/modules/system - dockerfile: dockerfile - ports: - - "9201:9201" - depends_on: - - ruoyi-redis - - ruoyi-mysql - links: - - ruoyi-redis - - ruoyi-mysql - ruoyi-modules-gen: - container_name: ruoyi-modules-gen - build: - context: ./ruoyi/modules/gen - dockerfile: dockerfile - ports: - - "9202:9202" - depends_on: - - ruoyi-mysql - links: - - ruoyi-mysql - ruoyi-modules-job: - container_name: ruoyi-modules-job - build: - context: ./ruoyi/modules/job - dockerfile: dockerfile - ports: - - "9203:9203" - depends_on: - - ruoyi-mysql - links: - - ruoyi-mysql - ruoyi-modules-file: - container_name: ruoyi-modules-file - build: - context: ./ruoyi/modules/file - dockerfile: dockerfile - ports: - - "9300:9300" - volumes: - - ./ruoyi/uploadPath:/home/ruoyi/uploadPath - ruoyi-visual-monitor: - container_name: ruoyi-visual-monitor - build: - context: ./ruoyi/visual/monitor - dockerfile: dockerfile - ports: - - "9100:9100" diff --git a/docker/mysql/db/readme.txt b/docker/mysql/db/readme.txt deleted file mode 100644 index 0b22f3fe..00000000 --- a/docker/mysql/db/readme.txt +++ /dev/null @@ -1 +0,0 @@ -sqlĿ¼µнűdockerԶִС \ No newline at end of file diff --git a/docker/mysql/dockerfile b/docker/mysql/dockerfile deleted file mode 100644 index b35dc5fd..00000000 --- a/docker/mysql/dockerfile +++ /dev/null @@ -1,7 +0,0 @@ -# 基础镜像 -FROM mysql:5.7 -# author -MAINTAINER ruoyi - -# 执行sql脚本 -ADD ./db/*.sql /docker-entrypoint-initdb.d/ diff --git a/docker/nacos/conf/application.properties b/docker/nacos/conf/application.properties deleted file mode 100644 index 7f2a61f2..00000000 --- a/docker/nacos/conf/application.properties +++ /dev/null @@ -1,32 +0,0 @@ -spring.datasource.platform=mysql -db.num=1 -db.url.0=jdbc:mysql://ruoyi-mysql:3306/ry-config?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC -db.user=root -db.password=password - -nacos.naming.empty-service.auto-clean=true -nacos.naming.empty-service.clean.initial-delay-ms=50000 -nacos.naming.empty-service.clean.period-time-ms=30000 - -management.endpoints.web.exposure.include=* - -management.metrics.export.elastic.enabled=false -management.metrics.export.influx.enabled=false - -server.tomcat.accesslog.enabled=true -server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D %{User-Agent}i %{Request-Source}i - -server.tomcat.basedir=/home/ruoyi/nacos/tomcat/logs - -nacos.security.ignore.urls=/,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-ui/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/** - -nacos.core.auth.system.type=nacos -nacos.core.auth.enabled=false -nacos.core.auth.default.token.expire.seconds=18000 -nacos.core.auth.default.token.secret.key=SecretKey012345678901234567890123456789012345678901234567890123456789 -nacos.core.auth.caching.enabled=true -nacos.core.auth.enable.userAgentAuthWhite=false -nacos.core.auth.server.identity.key=serverIdentity -nacos.core.auth.server.identity.value=security - -nacos.istio.mcp.server.enabled=false diff --git a/docker/nacos/dockerfile b/docker/nacos/dockerfile deleted file mode 100644 index a9f72d99..00000000 --- a/docker/nacos/dockerfile +++ /dev/null @@ -1,7 +0,0 @@ -# 基础镜像 -FROM nacos/nacos-server -# author -MAINTAINER ruoyi - -# 复制conf文件到路径 -COPY ./conf/application.properties /home/nacos/conf/application.properties diff --git a/docker/nginx/conf/nginx.conf b/docker/nginx/conf/nginx.conf deleted file mode 100644 index eccee523..00000000 --- a/docker/nginx/conf/nginx.conf +++ /dev/null @@ -1,41 +0,0 @@ -worker_processes 1; - -events { - worker_connections 1024; -} - -http { - include mime.types; - default_type application/octet-stream; - sendfile on; - keepalive_timeout 65; - - server { - listen 80; - server_name localhost; - - location / { - root /home/ruoyi/projects/ruoyi-ui; - try_files $uri $uri/ /index.html; - index index.html index.htm; - } - - location /prod-api/{ - proxy_set_header Host $http_host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header REMOTE-HOST $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_pass http://ruoyi-gateway:8080/; - } - - # 避免actuator暴露 - if ($request_uri ~ "/actuator") { - return 403; - } - - error_page 500 502 503 504 /50x.html; - location = /50x.html { - root html; - } - } -} \ No newline at end of file diff --git a/docker/nginx/dockerfile b/docker/nginx/dockerfile deleted file mode 100644 index e0025b1b..00000000 --- a/docker/nginx/dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -# 基础镜像 -FROM nginx -# author -MAINTAINER ruoyi - -# 挂载目录 -VOLUME /home/ruoyi/projects/ruoyi-ui -# 创建目录 -RUN mkdir -p /home/ruoyi/projects/ruoyi-ui -# 指定路径 -WORKDIR /home/ruoyi/projects/ruoyi-ui -# 复制conf文件到路径 -COPY ./conf/nginx.conf /etc/nginx/nginx.conf -# 复制html文件到路径 -COPY ./html/dist /home/ruoyi/projects/ruoyi-ui diff --git a/docker/nginx/html/dist/readme.txt b/docker/nginx/html/dist/readme.txt deleted file mode 100644 index eea3a328..00000000 --- a/docker/nginx/html/dist/readme.txt +++ /dev/null @@ -1 +0,0 @@ -ǰruoyi-uiõľ̬ļnginxʡ \ No newline at end of file diff --git a/docker/redis/conf/redis.conf b/docker/redis/conf/redis.conf deleted file mode 100644 index d762d650..00000000 --- a/docker/redis/conf/redis.conf +++ /dev/null @@ -1 +0,0 @@ -# requirepass 123456 \ No newline at end of file diff --git a/docker/redis/dockerfile b/docker/redis/dockerfile deleted file mode 100644 index dd7eaa80..00000000 --- a/docker/redis/dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -# 基础镜像 -FROM redis -# author -MAINTAINER ruoyi - -# 挂载目录 -VOLUME /home/ruoyi/redis -# 创建目录 -RUN mkdir -p /home/ruoyi/redis -# 指定路径 -WORKDIR /home/ruoyi/redis -# 复制conf文件到路径 -COPY ./conf/redis.conf /home/ruoyi/redis/redis.conf diff --git a/docker/ruoyi/auth/dockerfile b/docker/ruoyi/auth/dockerfile deleted file mode 100644 index 01e777f0..00000000 --- a/docker/ruoyi/auth/dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -# 基础镜像 -FROM openjdk:8-jre -# author -MAINTAINER ruoyi - -# 挂载目录 -VOLUME /home/ruoyi -# 创建目录 -RUN mkdir -p /home/ruoyi -# 指定路径 -WORKDIR /home/ruoyi -# 复制jar文件到路径 -COPY ./jar/ruoyi-auth.jar /home/ruoyi/ruoyi-auth.jar -# 启动认证服务 -ENTRYPOINT ["java","-jar","ruoyi-auth.jar"] \ No newline at end of file diff --git a/docker/ruoyi/auth/jar/readme.txt b/docker/ruoyi/auth/jar/readme.txt deleted file mode 100644 index c35ba276..00000000 --- a/docker/ruoyi/auth/jar/readme.txt +++ /dev/null @@ -1 +0,0 @@ -֤ĴõjarļdockerӦá \ No newline at end of file diff --git a/docker/ruoyi/gateway/dockerfile b/docker/ruoyi/gateway/dockerfile deleted file mode 100644 index 016fdce7..00000000 --- a/docker/ruoyi/gateway/dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -# 基础镜像 -FROM openjdk:8-jre -# author -MAINTAINER ruoyi - -# 挂载目录 -VOLUME /home/ruoyi -# 创建目录 -RUN mkdir -p /home/ruoyi -# 指定路径 -WORKDIR /home/ruoyi -# 复制jar文件到路径 -COPY ./jar/ruoyi-gateway.jar /home/ruoyi/ruoyi-gateway.jar -# 启动网关服务 -ENTRYPOINT ["java","-jar","ruoyi-gateway.jar"] \ No newline at end of file diff --git a/docker/ruoyi/gateway/jar/readme.txt b/docker/ruoyi/gateway/jar/readme.txt deleted file mode 100644 index 5dfbec76..00000000 --- a/docker/ruoyi/gateway/jar/readme.txt +++ /dev/null @@ -1 +0,0 @@ -ģõjarļdockerӦá \ No newline at end of file diff --git a/docker/ruoyi/modules/file/dockerfile b/docker/ruoyi/modules/file/dockerfile deleted file mode 100644 index 7178d134..00000000 --- a/docker/ruoyi/modules/file/dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -# 基础镜像 -FROM openjdk:8-jre -# author -MAINTAINER ruoyi - -# 挂载目录 -VOLUME /home/ruoyi -# 创建目录 -RUN mkdir -p /home/ruoyi -# 指定路径 -WORKDIR /home/ruoyi -# 复制jar文件到路径 -COPY ./jar/ruoyi-modules-file.jar /home/ruoyi/ruoyi-modules-file.jar -# 启动文件服务 -ENTRYPOINT ["java","-jar","ruoyi-modules-file.jar"] \ No newline at end of file diff --git a/docker/ruoyi/modules/file/jar/readme.txt b/docker/ruoyi/modules/file/jar/readme.txt deleted file mode 100644 index bf2b2a7f..00000000 --- a/docker/ruoyi/modules/file/jar/readme.txt +++ /dev/null @@ -1 +0,0 @@ -ļõjarļdockerӦá \ No newline at end of file diff --git a/docker/ruoyi/modules/gen/dockerfile b/docker/ruoyi/modules/gen/dockerfile deleted file mode 100644 index def260d3..00000000 --- a/docker/ruoyi/modules/gen/dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -# 基础镜像 -FROM openjdk:8-jre -# author -MAINTAINER ruoyi - -# 挂载目录 -VOLUME /home/ruoyi -# 创建目录 -RUN mkdir -p /home/ruoyi -# 指定路径 -WORKDIR /home/ruoyi -# 复制jar文件到路径 -COPY ./jar/ruoyi-modules-gen.jar /home/ruoyi/ruoyi-modules-gen.jar -# 启动代码生成服务 -ENTRYPOINT ["java","-jar","ruoyi-modules-gen.jar"] \ No newline at end of file diff --git a/docker/ruoyi/modules/gen/jar/readme.txt b/docker/ruoyi/modules/gen/jar/readme.txt deleted file mode 100644 index 2f25c0af..00000000 --- a/docker/ruoyi/modules/gen/jar/readme.txt +++ /dev/null @@ -1 +0,0 @@ -ŴɴõjarļdockerӦá \ No newline at end of file diff --git a/docker/ruoyi/modules/job/dockerfile b/docker/ruoyi/modules/job/dockerfile deleted file mode 100644 index 100ecae2..00000000 --- a/docker/ruoyi/modules/job/dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -# 基础镜像 -FROM openjdk:8-jre -# author -MAINTAINER ruoyi - -# 挂载目录 -VOLUME /home/ruoyi -# 创建目录 -RUN mkdir -p /home/ruoyi -# 指定路径 -WORKDIR /home/ruoyi -# 复制jar文件到路径 -COPY ./jar/ruoyi-modules-job.jar /home/ruoyi/ruoyi-modules-job.jar -# 启动定时任务服务 -ENTRYPOINT ["java","-jar","ruoyi-modules-job.jar"] \ No newline at end of file diff --git a/docker/ruoyi/modules/job/jar/readme.txt b/docker/ruoyi/modules/job/jar/readme.txt deleted file mode 100644 index 58aea0b1..00000000 --- a/docker/ruoyi/modules/job/jar/readme.txt +++ /dev/null @@ -1 +0,0 @@ -ŶʱõjarļdockerӦá \ No newline at end of file diff --git a/docker/ruoyi/modules/system/dockerfile b/docker/ruoyi/modules/system/dockerfile deleted file mode 100644 index ced23b2e..00000000 --- a/docker/ruoyi/modules/system/dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -# 基础镜像 -FROM openjdk:8-jre -# author -MAINTAINER ruoyi - -# 挂载目录 -VOLUME /home/ruoyi -# 创建目录 -RUN mkdir -p /home/ruoyi -# 指定路径 -WORKDIR /home/ruoyi -# 复制jar文件到路径 -COPY ./jar/ruoyi-modules-system.jar /home/ruoyi/ruoyi-modules-system.jar -# 启动系统服务 -ENTRYPOINT ["java","-jar","ruoyi-modules-system.jar"] \ No newline at end of file diff --git a/docker/ruoyi/modules/system/jar/readme.txt b/docker/ruoyi/modules/system/jar/readme.txt deleted file mode 100644 index cfc2a927..00000000 --- a/docker/ruoyi/modules/system/jar/readme.txt +++ /dev/null @@ -1 +0,0 @@ -ϵͳģõjarļdockerӦá \ No newline at end of file diff --git a/docker/ruoyi/visual/monitor/dockerfile b/docker/ruoyi/visual/monitor/dockerfile deleted file mode 100644 index ea9370a3..00000000 --- a/docker/ruoyi/visual/monitor/dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -# 基础镜像 -FROM openjdk:8-jre -# author -MAINTAINER ruoyi - -# 挂载目录 -VOLUME /home/ruoyi -# 创建目录 -RUN mkdir -p /home/ruoyi -# 指定路径 -WORKDIR /home/ruoyi -# 复制jar文件到路径 -COPY ./jar/ruoyi-visual-monitor.jar /home/ruoyi/ruoyi-visual-monitor.jar -# 启动系统服务 -ENTRYPOINT ["java","-jar","ruoyi-visual-monitor.jar"] \ No newline at end of file diff --git a/docker/ruoyi/visual/monitor/jar/readme.txt b/docker/ruoyi/visual/monitor/jar/readme.txt deleted file mode 100644 index 62b28410..00000000 --- a/docker/ruoyi/visual/monitor/jar/readme.txt +++ /dev/null @@ -1 +0,0 @@ -żĴõjarļdockerӦá \ No newline at end of file diff --git a/pom.xml b/pom.xml index 51ad294f..628a00da 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ ruoyi http://www.ruoyi.vip - 若依微服务系统 + 租研舍微服务系统 3.6.4 @@ -35,6 +35,9 @@ 4.1.2 1.6.9 2.14.4 + 3.5.2 + 1.18.30 + 5.8.26 @@ -216,6 +219,21 @@ ruoyi-api-system ${ruoyi.version} + + com.baomidou + mybatis-plus-boot-starter + ${mybatis-plus.version} + + + org.projectlombok + lombok + ${lombok.version} + + + cn.hutool + hutool-all + ${hutools.version} + diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/RemoteChannelService.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/RemoteChannelService.java new file mode 100644 index 00000000..8933a4c6 --- /dev/null +++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/RemoteChannelService.java @@ -0,0 +1,25 @@ +package com.ruoyi.system.api; + +import com.ruoyi.common.core.constant.SecurityConstants; +import com.ruoyi.common.core.constant.ServiceNameConstants; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.core.domain.http.CustomerApplyLog; +import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.system.api.factory.RemoteChannelFallbackFactory; +import com.ruoyi.system.api.factory.RemoteCustomerApplyLogFallbackFactory; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.*; + +/** + * 用户服务 + * + * @author ruoyi + */ +@FeignClient(contextId = "remoteChannelService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteChannelFallbackFactory.class) +public interface RemoteChannelService +{ + + + + +} diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/RemoteCustomerApplyLogService.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/RemoteCustomerApplyLogService.java new file mode 100644 index 00000000..37392683 --- /dev/null +++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/RemoteCustomerApplyLogService.java @@ -0,0 +1,54 @@ +package com.ruoyi.system.api; + +import com.ruoyi.common.core.constant.SecurityConstants; +import com.ruoyi.common.core.constant.ServiceNameConstants; +import com.ruoyi.common.core.domain.GetSumDto; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.core.domain.http.CustomerApplyLog; +import com.ruoyi.common.core.domain.http.Merchant; +import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.system.api.factory.RemoteCustomerApplyLogFallbackFactory; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 用户服务 + * + * @author ruoyi + */ +@FeignClient(contextId = "remoteCustomerApplyLogService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteCustomerApplyLogFallbackFactory.class) +public interface RemoteCustomerApplyLogService +{ + /** + * 获取商户今日已申请数 + * + * + * @param getSumDto + * @param source 请求来源 + * @return 结果 + */ + @PostMapping("/log/sum") + public R sum(@RequestBody GetSumDto getSumDto, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); + + /** + * 获取用户今日是否是否已申请 + * + * + * @param customerID + * @param source 请求来源 + * @return 结果 + */ + @GetMapping("/log/customerApply") + public R customerApply(@RequestParam("customerID") Long customerID,@RequestHeader(SecurityConstants.FROM_SOURCE) String source); + + /** + * 新增用户 + * @param customerApplyLog + * @return + */ + @PostMapping("/log") + public AjaxResult add(@RequestBody CustomerApplyLog customerApplyLog); + +} diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/RemoteCustomerService.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/RemoteCustomerService.java new file mode 100644 index 00000000..a5f67da4 --- /dev/null +++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/RemoteCustomerService.java @@ -0,0 +1,63 @@ +package com.ruoyi.system.api; + +import com.ruoyi.common.core.constant.SecurityConstants; +import com.ruoyi.common.core.constant.ServiceNameConstants; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.core.domain.http.Customer; +import com.ruoyi.system.api.factory.RemoteCustomerFallbackFactory; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.*; + +/** + * 用户服务 + * + * @author ruoyi + */ +@FeignClient(contextId = "remoteCustomerService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteCustomerFallbackFactory.class) +public interface RemoteCustomerService +{ + /** + * 通过用户名查询用户信息 + * + * @param id 用户名 + * @param source 请求来源 + * @return 结果 + */ + @GetMapping("/customer/{id}") + public R getCustomerInfoById(@PathVariable("id") Long id, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); + + /** + * 通过手机号MD5查询用户信息 + * + * @param phoneMD5 用户名 + * @param source 请求来源 + * @return 结果 + */ + @GetMapping("/customer/getByMd5") + public R getCustomerInfoByPhoneMd5(@RequestParam("phoneMD5")String phoneMD5, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); + + /** + * 通过手机号MD5更新用户信息 + * + * @param customer 用户 + * @return 结果 + */ + @PostMapping("/customer/updateByPhoneMd5") + public R updateByPhoneMd5(Customer customer ,@RequestHeader(SecurityConstants.FROM_SOURCE) String source); + + /** + * 新增客户信息 + * @return + */ + @PostMapping("/customer/addNewCustomer") + public R add(@RequestBody Customer customer,@RequestHeader(SecurityConstants.FROM_SOURCE) String source); + + /** + * 获取用户token + * @param phone + * @param channelId + * @return + */ + @GetMapping("/customer/getCustomerToken") + public String getCustomerToken(@RequestParam("phone") String phone,@RequestParam("channelId")Long channelId); +} diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/RemoteMerchantService.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/RemoteMerchantService.java new file mode 100644 index 00000000..9503672b --- /dev/null +++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/RemoteMerchantService.java @@ -0,0 +1,33 @@ +package com.ruoyi.system.api; + +import com.ruoyi.common.core.constant.SecurityConstants; +import com.ruoyi.common.core.constant.ServiceNameConstants; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.core.domain.http.Merchant; +import com.ruoyi.system.api.domain.SysUser; +import com.ruoyi.system.api.factory.RemoteMerChantFallbackFactory; +import com.ruoyi.system.api.factory.RemoteUserFallbackFactory; +import com.ruoyi.system.api.model.LoginUser; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 用户服务 + * + * @author ruoyi + */ +@FeignClient(contextId = "remoteMerchantService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteMerChantFallbackFactory.class) +public interface RemoteMerchantService +{ + /** + * 获取合适的产品 前筛 + * + * @param source 请求来源 + * @return 结果 + */ + @GetMapping("/merchant/merchantList") + public R> merchantList(@RequestHeader(SecurityConstants.FROM_SOURCE) String source); + +} diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteChannelFallbackFactory.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteChannelFallbackFactory.java new file mode 100644 index 00000000..9c865b21 --- /dev/null +++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteChannelFallbackFactory.java @@ -0,0 +1,30 @@ +package com.ruoyi.system.api.factory; + + +import com.ruoyi.system.api.RemoteChannelService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.cloud.openfeign.FallbackFactory; +import org.springframework.stereotype.Component; + + +/** + * 用户服务降级处理 + * + * @author ruoyi + */ +@Component +@Slf4j +public class RemoteChannelFallbackFactory implements FallbackFactory +{ + + @Override + public RemoteChannelService create(Throwable throwable) + { + log.error("用户服务调用失败:{}", throwable.getMessage()); + return new RemoteChannelService() + { + + + }; + } +} diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteCustomerApplyLogFallbackFactory.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteCustomerApplyLogFallbackFactory.java new file mode 100644 index 00000000..d88ba8b0 --- /dev/null +++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteCustomerApplyLogFallbackFactory.java @@ -0,0 +1,52 @@ +package com.ruoyi.system.api.factory; + +import com.ruoyi.common.core.constant.SecurityConstants; +import com.ruoyi.common.core.domain.GetSumDto; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.core.domain.http.CustomerApplyLog; +import com.ruoyi.common.core.domain.http.Merchant; +import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.system.api.RemoteCustomerApplyLogService; +import com.ruoyi.system.api.RemoteMerchantService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.cloud.openfeign.FallbackFactory; +import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestHeader; + +import java.util.List; + +/** + * 用户服务降级处理 + * + * @author ruoyi + */ +@Component +@Slf4j +public class RemoteCustomerApplyLogFallbackFactory implements FallbackFactory +{ + + @Override + public RemoteCustomerApplyLogService create(Throwable throwable) + { + log.error("用户服务调用失败:{}", throwable.getMessage()); + return new RemoteCustomerApplyLogService() + { + @Override + public R sum(GetSumDto getSumDto, @RequestHeader(SecurityConstants.FROM_SOURCE) String source) + { + return R.fail("获取商户已申请数失败:" + throwable.getMessage()); + } + + @Override + public R customerApply(Long customerID, String source) { + return null; + } + + @Override + public AjaxResult add(CustomerApplyLog customerApplyLog) { + return null; + } + }; + } +} diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteCustomerFallbackFactory.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteCustomerFallbackFactory.java new file mode 100644 index 00000000..2ad2a2d0 --- /dev/null +++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteCustomerFallbackFactory.java @@ -0,0 +1,54 @@ +package com.ruoyi.system.api.factory; + +import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.core.domain.http.Customer; +import com.ruoyi.system.api.RemoteCustomerService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.cloud.openfeign.FallbackFactory; +import org.springframework.stereotype.Component; + +/** + * 用户服务降级处理 + * + * @author ruoyi + */ +@Component +@Slf4j +public class RemoteCustomerFallbackFactory implements FallbackFactory +{ + @Override + public RemoteCustomerService create(Throwable throwable) + { + log.error("用户服务调用失败:{}", throwable.getMessage()); + return new RemoteCustomerService() + { + @Override + public R getCustomerInfoById(Long id, String source) + { + return R.fail("获取用户失败:" + throwable.getMessage()); + } + + @Override + public R getCustomerInfoByPhoneMd5(String phoneMD5, String source) { + log.info("查询用户失败:{}",throwable.getMessage()); + return R.fail("查询用户失败:" + throwable.getMessage()); + } + + @Override + public R updateByPhoneMd5(Customer customer, String source) { + return R.fail("更新用户失败:" + throwable.getMessage()); + } + + @Override + public R add(Customer customer, String source) { + log.info("新增用户失败:{}",throwable.getMessage()); + return R.fail("新增用户失败"); + } + + @Override + public String getCustomerToken(String phone, Long channelId) { + return null; + } + }; + } +} diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteMerChantFallbackFactory.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteMerChantFallbackFactory.java new file mode 100644 index 00000000..f8392786 --- /dev/null +++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteMerChantFallbackFactory.java @@ -0,0 +1,37 @@ +package com.ruoyi.system.api.factory; + +import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.core.domain.http.Merchant; +import com.ruoyi.system.api.RemoteMerchantService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.cloud.openfeign.FallbackFactory; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + * 用户服务降级处理 + * + * @author ruoyi + */ +@Component +@Slf4j +public class RemoteMerChantFallbackFactory implements FallbackFactory +{ + + @Override + public RemoteMerchantService create(Throwable throwable) + { + log.error("用户服务调用失败:{}", throwable.getMessage()); + return new RemoteMerchantService() + { + @Override + public R> merchantList(String source) + { + return R.fail("获取用户失败:" + throwable.getMessage()); + } + + + }; + } +} diff --git a/ruoyi-api/ruoyi-api-system/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/ruoyi-api/ruoyi-api-system/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports index 9212ec04..4c526d6d 100644 --- a/ruoyi-api/ruoyi-api-system/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ b/ruoyi-api/ruoyi-api-system/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -1,3 +1,6 @@ com.ruoyi.system.api.factory.RemoteUserFallbackFactory com.ruoyi.system.api.factory.RemoteLogFallbackFactory com.ruoyi.system.api.factory.RemoteFileFallbackFactory +com.ruoyi.system.api.factory.RemoteCustomerFallbackFactory +com.ruoyi.system.api.factory.RemoteMerChantFallbackFactory +com.ruoyi.system.api.factory.RemoteCustomerApplyLogFallbackFactory \ No newline at end of file diff --git a/ruoyi-auth/src/main/java/com/ruoyi/auth/RuoYiAuthApplication.java b/ruoyi-auth/src/main/java/com/ruoyi/auth/RuoYiAuthApplication.java index 00a499df..5b2ec135 100644 --- a/ruoyi-auth/src/main/java/com/ruoyi/auth/RuoYiAuthApplication.java +++ b/ruoyi-auth/src/main/java/com/ruoyi/auth/RuoYiAuthApplication.java @@ -17,15 +17,6 @@ public class RuoYiAuthApplication public static void main(String[] args) { SpringApplication.run(RuoYiAuthApplication.class, args); - System.out.println("(♥◠‿◠)ノ゙ 认证授权中心启动成功 ლ(´ڡ`ლ)゙ \n" + - " .-------. ____ __ \n" + - " | _ _ \\ \\ \\ / / \n" + - " | ( ' ) | \\ _. / ' \n" + - " |(_ o _) / _( )_ .' \n" + - " | (_,_).' __ ___(_ o _)' \n" + - " | |\\ \\ | || |(_,_)' \n" + - " | | \\ `' /| `-' / \n" + - " | | \\ / \\ / \n" + - " ''-' `'-' `-..-' "); + System.out.println("(♥◠‿◠)ノ゙ 认证授权中心启动成功 ლ(´ڡ`ლ)゙ "); } } diff --git a/ruoyi-auth/src/main/resources/bootstrap.yml b/ruoyi-auth/src/main/resources/bootstrap.yml index f456b03c..c83ed94f 100644 --- a/ruoyi-auth/src/main/resources/bootstrap.yml +++ b/ruoyi-auth/src/main/resources/bootstrap.yml @@ -14,10 +14,12 @@ spring: nacos: discovery: # 服务注册地址 - server-addr: 127.0.0.1:8848 + server-addr: 47.109.135.151:8848 + namespace: b8ad3fd2-18ea-4cdf-a82c-4ce483392b1a config: # 配置中心地址 - server-addr: 127.0.0.1:8848 + server-addr: 47.109.135.151:8848 + namespace: b8ad3fd2-18ea-4cdf-a82c-4ce483392b1a # 配置文件格式 file-extension: yml # 共享配置 diff --git a/ruoyi-auth/src/main/resources/logback.xml b/ruoyi-auth/src/main/resources/logback.xml index 098a610b..42eba955 100644 --- a/ruoyi-auth/src/main/resources/logback.xml +++ b/ruoyi-auth/src/main/resources/logback.xml @@ -67,7 +67,7 @@ - + diff --git a/ruoyi-common/pom.xml b/ruoyi-common/pom.xml index 3129e2d6..513918dc 100644 --- a/ruoyi-common/pom.xml +++ b/ruoyi-common/pom.xml @@ -18,6 +18,7 @@ ruoyi-common-sensitive ruoyi-common-datascope ruoyi-common-datasource + ruoyi-common-sms ruoyi-common diff --git a/ruoyi-common/ruoyi-common-core/pom.xml b/ruoyi-common/ruoyi-common-core/pom.xml index 151b9ed4..a0b7b0d3 100644 --- a/ruoyi-common/ruoyi-common-core/pom.xml +++ b/ruoyi-common/ruoyi-common-core/pom.xml @@ -106,7 +106,21 @@ javax.servlet javax.servlet-api + + org.projectlombok + lombok + + + cn.hutool + hutool-all + + + com.baomidou + mybatis-plus-annotation + 3.5.2 + compile + diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/CacheConstants.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/CacheConstants.java index e2df52b6..a3f6cc45 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/CacheConstants.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/CacheConstants.java @@ -56,4 +56,20 @@ public class CacheConstants * 登录IP黑名单 cache key */ public static final String SYS_LOGIN_BLACKIPLIST = SYS_CONFIG_KEY + "sys.login.blackIPList"; + + + public static final String PROJET = "xymz:"; + /** + * 渠道redis缓存键 + */ + public static final String CHANNEL_ID = PROJET + "channel:id:"; + /** + * 渠道redis缓存键 + */ + public static final String CHANNEL_SIGN = PROJET + "channel:sign:"; + + /** + * 商户redis缓存键 + */ + public static final String MERCHANT = PROJET + "merchant:key:"; } diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/RedisConstant.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/RedisConstant.java new file mode 100644 index 00000000..4b6579ce --- /dev/null +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/RedisConstant.java @@ -0,0 +1,42 @@ +package com.ruoyi.common.core.constant; + +public class RedisConstant { + + /** + * 用户登录缓存 + */ + public final static String APP_CUSTOMER_KEY = CacheConstants.PROJET + ":customer:key:"; + + /** + * 用户名缓存 + */ + public final static String APP_CUSTOMER_USERNAME_KEY = CacheConstants.PROJET + ":app:customer:username:key:"; + /** + * 渠道ID缓存 + */ + public final static String APP_CUSTOMER_CHANNEL_KEY = CacheConstants.PROJET + ":app:customer:channel:key:"; + /** + * 用户登录缓存 + */ + public final static String APP_CUSTOMER_TOKEN_KEY = CacheConstants.PROJET + ":app:customer:token:key:"; + + /** + * app用户设备标识 + */ + public final static String APP_DEVICE_IDENTIFICATION = CacheConstants.PROJET + ":app:app:device:identification:"; + + /** + * H5登录验证码 + */ + public final static String H5_LOGIN_CACHE = CacheConstants.PROJET+"H5:login:cache:"; + + /** + * H5申请幂等校验 + */ + public final static String H5_APPLY_CHECK = CacheConstants.PROJET+"H5:apply:check:"; + + /** + * 撞库幂等校验 + */ + public final static String HIT_CHECK_CACHE = CacheConstants.PROJET+"hit:check:cache:"; +} diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/domain/GetSumDto.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/domain/GetSumDto.java new file mode 100644 index 00000000..7d3d8d81 --- /dev/null +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/domain/GetSumDto.java @@ -0,0 +1,9 @@ +package com.ruoyi.common.core.domain; + +import lombok.Data; + +@Data +public class GetSumDto { + + private Long merchantId; +} diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/domain/GuestProbabilityReq.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/domain/GuestProbabilityReq.java new file mode 100644 index 00000000..929c00bc --- /dev/null +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/domain/GuestProbabilityReq.java @@ -0,0 +1,35 @@ +package com.ruoyi.common.core.domain; + +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * 概率计算 + * @Author: daisi + * @Date: 2022/4/2 9:49 + */ +@Data +@Accessors(chain = true) +public class GuestProbabilityReq implements Serializable { + private static final long serialVersionUID = -9096451963988288187L; + + /** + * 计划Id + */ + private Long planId; + /** + * 排序价格 + */ + private BigDecimal orderPrice; + /** + * 概率 + */ + private Double guestProbability; + /** + * 计算结果概率 + */ + private Integer resultGuestProbability; +} diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/domain/http/Channel.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/domain/http/Channel.java new file mode 100644 index 00000000..0d290876 --- /dev/null +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/domain/http/Channel.java @@ -0,0 +1,57 @@ +package com.ruoyi.common.core.domain.http; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Data; +import com.ruoyi.common.core.annotation.Excel; +import com.ruoyi.common.core.web.domain.BaseEntity; + +/** + * 渠道配置对象 channel + * + * @author ruoyi + * @date 2024-09-15 + */ +@Data +public class Channel extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** 渠道名称 */ + @Excel(name = "渠道名称") + private String channelName; + + /** 渠道签名 */ + @Excel(name = "渠道签名") + private String channelSign; + + /** 渠道类型 1H5 2连登 3半流程 4全流程*/ + @Excel(name = "渠道类型") + private String channelType; + + /** 扣量比 */ + @Excel(name = "扣量比") + private Long score; + + /** 推广页名称 */ + @Excel(name = "推广页名称") + private String htmlName; + + /** 推广页地址 */ + @Excel(name = "推广页地址") + private String htmlLocation; + + /** 可访问IP */ + @Excel(name = "可访问IP") + private String ips; + + /** 开启关闭时段 */ + @Excel(name = "开启关闭时段") + private String period; + + +} diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/domain/http/Customer.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/domain/http/Customer.java new file mode 100644 index 00000000..441bbdd8 --- /dev/null +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/domain/http/Customer.java @@ -0,0 +1,138 @@ +package com.ruoyi.common.core.domain.http; + +import java.util.Date; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.core.annotation.Excel; +import com.ruoyi.common.core.web.domain.BaseEntity; + +/** + * 客户信息对象 customer + * + * @author ruoyi + * @date 2024-09-15 + */ +@Data +public class Customer extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /**渠道ID**/ + @Excel(name = "渠道ID") + private Long channelId; + + /** 年龄 */ + @Excel(name = "年龄") + private Integer age; + + /** 0 男 1 女 */ + @Excel(name = "0 男 1 女") + private Integer sex; + + @Excel(name="身份证号") + private String idCard; + + /** 昵称 */ + @Excel(name = "昵称") + private String name; + + /** 真实姓名 */ + @Excel(name = "真实姓名") + private String acturlName; + + /** 手机号 */ + @Excel(name = "手机号") + private String phone; + + /** 手机号MD5 */ + @Excel(name = "手机号MD5") + private String phoneMd5; + + /** 0 未实名 1已实名 */ + @Excel(name = "0 未实名 1已实名") + private Boolean isAuth; + + /** 城市 */ + @Excel(name = "城市") + private String city; + + /** 城市编码 */ + @Excel(name = "城市编码") + private Integer cityCode; + + /** 首次登录时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "首次登录时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date firstLoginTime; + + /** 最后登录时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date lastLoginTime; + + /** 最后登录IP */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "最后登录IP", width = 30, dateFormat = "yyyy-MM-dd") + private Date lastLoginIp; + + /** 用户状态 1正常 2异常 可继续扩展 */ + @Excel(name = "用户状态 1正常 2异常 可继续扩展") + private Integer status; + + /** 无社保 */ + @Excel(name = "社保") + private Integer socialSecurity; + + /** 无车 */ + @Excel(name = "车") + private Integer car; + + /** 保单缴纳不满一年 */ + @Excel(name = "保单") + private Integer guaranteeSlip; + + /** 初中 */ + @Excel(name = "学历") + private Integer education; + + /** 公积金未满6个月 */ + @Excel(name = "公积金") + private Integer accumulationFund; + + /** 本地无房 */ + @Excel(name = "房") + private Integer hourse; + + /** 上班族 */ + @Excel(name = "职业") + private Integer career; + + + /** 花呗5000以下 */ + @Excel(name = "花呗") + private Integer huaBei; + + /** 白条5000以下 */ + @Excel(name = "白条") + private Integer baiTiao; + + /** 芝麻分 */ + @Excel(name = "芝麻分") + private Integer zhiMa; + + + /** 月收入 */ + @Excel(name = "月收入") + private Integer income; + + +} diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/domain/http/CustomerApplyLog.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/domain/http/CustomerApplyLog.java new file mode 100644 index 00000000..bee75de3 --- /dev/null +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/domain/http/CustomerApplyLog.java @@ -0,0 +1,51 @@ +package com.ruoyi.common.core.domain.http; + +import java.math.BigDecimal; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Data; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.core.annotation.Excel; +import com.ruoyi.common.core.web.domain.BaseEntity; + +/** + * 客户申请记录对象 customer_apply_log + * + * @author ruoyi + * @date 2024-09-15 + */ +@Data +public class CustomerApplyLog extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** 用户id */ + @Excel(name = "用户id") + private Long customerId; + + /** 商户ID */ + @Excel(name = "商户ID") + private Long merchantId; + + /** $column.columnComment */ + @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") + private Long channelId; + + /** 订单状态 0 已申请 1 注册中 2风控中 3下单中 4 下单成功 5已成交 */ + @Excel(name = "订单状态 0 已申请 1 注册中 2风控中 3下单中 4 下单成功 5已成交 ") + private Long orderStatus; + + /** 成交金额 分 */ + @Excel(name = "成交金额 分") + private BigDecimal price; + + @Excel(name = "订单号") + private String orderNo; + +} diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/domain/http/Merchant.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/domain/http/Merchant.java new file mode 100644 index 00000000..01a7795b --- /dev/null +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/domain/http/Merchant.java @@ -0,0 +1,243 @@ +package com.ruoyi.common.core.domain.http; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Data; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.core.annotation.Excel; +import com.ruoyi.common.core.web.domain.BaseEntity; + +/** + * 商户对象 merchant + * + * @author ruoyi + * @date 2024-09-15 + */ +@Data +public class Merchant extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** 商户类型 1H5 2连登 3半流程 4全流程 */ + @Excel(name = "商户类型 1H5 2连登 3半流程 4全流程") + private Long merchantType; + + /** 商户名称 */ + @Excel(name = "商户名称") + private String merchantName; + + /** 商户描述 */ + @Excel(name = "商户描述") + private String merchantDescribe; + + /** 商户主体 */ + @Excel(name = "商户主体") + private String merchantCompany; + + /** logo文件地址 */ + @Excel(name = "logo文件地址") + private String logo; + + /** 是否上下架 */ + @Excel(name = "是否上下架") + private Integer status; + + /** 定量数 */ + @Excel(name = "定量数") + private Integer limitNum; + + /** 是否定量 0否 1是 */ + @Excel(name = "是否定量 0否 1是") + private Integer limitType; + + + /** 是否开启余额监控 0否 1是 */ + @Excel(name = " 是否开启余额监控 0否 1是") + private Integer isBalanceMonitoring; + + /** 余额监控余额 */ + @Excel(name = "余额") + private Integer balanceMonitoring ; + + + /** 渠道限制ID */ + @Excel(name = "渠道限制ID") + private String channelLimit; + + /** 是否通过 0否 1是 */ + @Excel(name = "是否通过 0否 1是") + private Integer ispass; + + /** 渠道限制类型 0不限 1满足其一 2满足全部 */ + @Excel(name = "渠道限制类型 0不限 1满足其一 2满足全部") + private Integer customerInfoFilterType; + + /** 渠道限制类型 0不限 1准入 2禁入 */ + @Excel(name = "渠道限制类型 0不限 1准入 2禁入") + private Integer channelLimitType; + + /** 执行时段 */ + @Excel(name = "执行时段") + private String period; + + /**撞库地址**/ + @Excel(name = "撞库地址") + private String hitUrl; + + /**注册地址**/ + @Excel(name = "注册地址") + private String registUrl; + + /** 年龄限制开始 */ + @Excel(name = "年龄限制开始") + private Integer ageLimitStart; + + /** 年龄限制结束 */ + @Excel(name = "年龄限制结束") + private Integer ageLimitEnd; + + /** 手机号禁入号段英文逗号分隔 */ + @Excel(name = "手机号禁入号段英文逗号分隔") + private String phoneLimit; + + /** 标签 */ + @Excel(name = "标签") + private String label; + + /** 商户是否开启二要素 0 否 1 是 */ + @Excel(name = "商户是否开启二要素") + private Boolean merchantAuth; + + @Excel(name = "下游渠道标识") + private String channelSign; + + /** 无社保 */ + @Excel(name = "无社保") + private Boolean socialSecurityNo; + + /** 社保未满6个月 */ + @Excel(name = "社保未满6个月") + private Boolean socialSecurityLow; + + /** 社保6个月以上 */ + @Excel(name = "社保6个月以上") + private Boolean socialSecurityHigh; + + /** 无车 */ + @Excel(name = "无车") + private Boolean carNo; + + /** 有车 */ + @Excel(name = "有车") + private Boolean carHave; + + /** 保单缴纳不满一年 */ + @Excel(name = "保单缴纳不满一年") + private Boolean guaranteeSlipLow; + + /** 保单缴纳一年以上 */ + @Excel(name = "保单缴纳一年以上") + private Boolean guaranteeSlipCentre; + + /** 保单缴纳2年以上 */ + @Excel(name = "保单缴纳2年以上") + private Boolean guaranteeSlipHigh; + + /** 初中 */ + @Excel(name = "初中") + private Boolean educationMiddle; + + /** 高中 */ + @Excel(name = "高中") + private Boolean educationHighSchool; + + /** 中专 */ + @Excel(name = "中专") + private Boolean educationPolytechnic; + + /** 大专 */ + @Excel(name = "大专") + private Boolean educationJuniorCollege; + + /** 本科 */ + @Excel(name = "本科") + private Boolean educationUndergraduateCourse; + + /** 研究生及以上 */ + @Excel(name = "研究生及以上") + private Boolean educationPostgraduate; + + /** 公积金未满6个月 */ + @Excel(name = "公积金未满6个月") + private Boolean accumulationFundLow; + + /** 公积金满6个月以上 */ + @Excel(name = "公积金满6个月以上") + private Boolean accumulationFundHigh; + + /** 本地无房 */ + @Excel(name = "本地无房") + private Boolean hourseNo; + + /** 本地全款房 */ + @Excel(name = "本地全款房") + private Boolean hourseFullPayment; + + /** 本地按揭 */ + @Excel(name = "本地按揭") + private Boolean hourseMortgaging; + + /** 上班族 */ + @Excel(name = "上班族") + private Boolean officeWorker; + + /** 公务员 */ + @Excel(name = "公务员") + private Boolean civilServant; + + /** 私营业主 */ + @Excel(name = "私营业主") + private Boolean privatePropertyOwners; + + /** 个体户 */ + @Excel(name = "个体户") + private Boolean selfEmployedPerson; + + /** 其他职业 */ + @Excel(name = "其他职业") + private Boolean otherOccupations; + + /** 花呗5000以下 */ + @Excel(name = "花呗5000以下") + private Boolean huaBeiLow; + + /** 花呗5000-10000 */ + @Excel(name = "花呗5000-10000") + private Boolean huaBeiMiddle; + + /** 花呗10000以上 */ + @Excel(name = "花呗10000以上") + private Boolean huaBeiHigh; + + /** 白条5000以下 */ + @Excel(name = "白条5000以下") + private Boolean baiTiaoLow; + + /** 白条5000-10000 */ + @Excel(name = "白条5000-10000") + private Boolean baiTiaoMiddle; + + /** 白条10000以上 */ + @Excel(name = "白条10000以上") + private Boolean baiTiaoHigh; + + /** 芝麻分 */ + @Excel(name = "芝麻分") + private Integer zhiMa; + +} diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/EncryptUtil.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/EncryptUtil.java new file mode 100644 index 00000000..4c536769 --- /dev/null +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/EncryptUtil.java @@ -0,0 +1,636 @@ +package com.ruoyi.common.core.utils; + +import cn.hutool.core.codec.Base64; +import org.apache.commons.codec.binary.Hex; +import org.springframework.stereotype.Component; +import javax.crypto.*; +import javax.crypto.spec.DESKeySpec; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; +import java.io.UnsupportedEncodingException; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.security.*; +import java.util.regex.Pattern; + +/** + * @program: JieYiHua-Cloud + * @description: 加密解密 + * @author: LiYu + * @create: 2021-07-23 17:02 + **/ +@Component +public class EncryptUtil { + + public static final String MD5 = "MD5"; + public static final String SHA1 = "SHA1"; + public static final String HmacMD5 = "HmacMD5"; + public static final String HmacSHA1 = "HmacSHA1"; + public static final String DES = "DES"; + public static final String AES = "AES"; + public static final Charset CHARSET = StandardCharsets.UTF_8; + + public static final byte keyStrSize = 16; + + + public static final byte ivStrSize = 16; + + public static final String AES_CBC_NOPADDING = "AES/CBC/NoPadding"; + public static final String DES_ECB_PKCS7PADDING = "DES/ECB/PKCS7Padding"; + public static final String AES_ECB_PKCS5PADDING = "AES/ECB/PKCS5Padding"; + + /** + * 编码格式;默认使用uft-8 + */ + public static String charset = "utf-8"; + /** + * DES + */ + public static int keysizeDES = 0; + /** + * AES + */ + public static int keysizeAES = 128; + + public static EncryptUtil me; + + private EncryptUtil() { + //单例 + } + + //双重锁 + public static EncryptUtil getInstance() { + if (me == null) { + synchronized (EncryptUtil.class) { + if (me == null) { + me = new EncryptUtil(); + } + } + } + return me; + } + + /** + * 使用MessageDigest进行单向加密(无密码) + * + * @param res 被加密的文本 + * @param algorithm 加密算法名称 + * @return + */ + private static String messageDigest(String res, String algorithm) { + try { + MessageDigest md = MessageDigest.getInstance(algorithm); + byte[] resBytes = charset == null ? res.getBytes() : res.getBytes(charset); + return base64(md.digest(resBytes)); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + /** + * 使用KeyGenerator进行单向/双向加密(可设密码) + * + * @param res 被加密的原文 + * @param algorithm 加密使用的算法名称 + * @param key 加密使用的秘钥 + * @return + */ + private String keyGeneratorMac(String res, String algorithm, String key) { + try { + SecretKey sk = null; + if (key == null) { + KeyGenerator kg = KeyGenerator.getInstance(algorithm); + sk = kg.generateKey(); + } else { + byte[] keyBytes = charset == null ? key.getBytes() : key.getBytes(charset); + sk = new SecretKeySpec(keyBytes, algorithm); + } + Mac mac = Mac.getInstance(algorithm); + mac.init(sk); + byte[] result = mac.doFinal(res.getBytes()); + return base64(result); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + /** + * 使用KeyGenerator双向加密,DES/AES,注意这里转化为字符串的时候是将2进制转为16进制格式的字符串,不是直接转,因为会出错 + * + * @param res 加密的原文 + * @param algorithm 加密使用的算法名称 + * @param key 加密的秘钥 + * @param keysize + * @param isEncode + * @return + */ + private static String keyGeneratorES(String res, String algorithm, String key, int keysize, boolean isEncode) { + try { + KeyGenerator kg = KeyGenerator.getInstance(algorithm); + if (keysize == 0) { + byte[] keyBytes = charset == null ? key.getBytes() : key.getBytes(charset); + kg.init(new SecureRandom(keyBytes)); + } else if (key == null) { + kg.init(keysize); + } else { + byte[] keyBytes = charset == null ? key.getBytes() : key.getBytes(charset); + kg.init(keysize, new SecureRandom(keyBytes)); + } + SecretKey sk = kg.generateKey(); + SecretKeySpec sks = new SecretKeySpec(sk.getEncoded(), algorithm); + Cipher cipher = Cipher.getInstance(algorithm); + if (isEncode) { + cipher.init(Cipher.ENCRYPT_MODE, sks); + byte[] resBytes = charset == null ? res.getBytes() : res.getBytes(charset); + return parseByte2HexStr(cipher.doFinal(resBytes)); + } else { + cipher.init(Cipher.DECRYPT_MODE, sks); + return new String(cipher.doFinal(parseHexStr2Byte(res))); + } + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + @Deprecated + private static String base64(byte[] res) { + return Base64.encode(res); + } + + /** + * 将二进制转换成16进制 + */ + public static String parseByte2HexStr(byte buf[]) { + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < buf.length; i++) { + String hex = Integer.toHexString(buf[i] & 0xFF); + if (hex.length() == 1) { + hex = '0' + hex; + } + sb.append(hex.toUpperCase()); + } + return sb.toString(); + } + + /** + * 将16进制转换为二进制 + */ + public static byte[] parseHexStr2Byte(String hexStr) { + if (hexStr.length() < 1) { + return null; + } + byte[] result = new byte[hexStr.length() / 2]; + for (int i = 0; i < hexStr.length() / 2; i++) { + int high = Integer.parseInt(hexStr.substring(i * 2, i * 2 + 1), 16); + int low = Integer.parseInt(hexStr.substring(i * 2 + 1, i * 2 + 2), 16); + result[i] = (byte) (high * 16 + low); + } + return result; + } + + /** + * md5加密算法进行加密(不可逆) + * + * @param res 需要加密的原文 + * @return + */ + @Deprecated + public String MD5(String res) { + return messageDigest(res, MD5); + } + + /** + * md5加密算法进行加密(不可逆) + * + * @param res 需要加密的原文 + * @param key 秘钥 + * @return + */ + @Deprecated + public String MD5(String res, String key) { + return keyGeneratorMac(res, HmacMD5, key); + } + + /** + * 使用SHA1加密算法进行加密(不可逆) + * + * @param res 需要加密的原文 + * @return + */ + public static String SHA1(String res) { + return messageDigest(res, SHA1); + } + + /** + * 使用SHA1加密算法进行加密(不可逆) + * + * @param res 需要加密的原文 + * @param key 秘钥 + * @return + */ + public String SHA1(String res, String key) { + return keyGeneratorMac(res, HmacSHA1, key); + } + + /** + * 使用DES加密算法进行加密(可逆) + * + * @param res 需要加密的原文 + * @param key 秘钥 + * @return + */ + public static String DESencode(String res, String key) { + return keyGeneratorES(res, DES, key, keysizeDES, true); + } + + /** + * 对使用DES加密算法的密文进行解密(可逆) + * + * @param res 需要解密的密文 + * @param key 秘钥 + * @return + */ + public String DESdecode(String res, String key) { + return keyGeneratorES(res, DES, key, keysizeDES, false); + } + + + /** + * 使用异或进行加密 + * + * @param res 需要加密的密文 + * @param key 秘钥 + * @return + */ + public String XORencode(String res, String key) { + byte[] bs = res.getBytes(); + for (int i = 0; i < bs.length; i++) { + bs[i] = (byte) ((bs[i]) ^ key.hashCode()); + } + return parseByte2HexStr(bs); + } + + /** + * 使用异或进行解密 + * + * @param res 需要解密的密文 + * @param key 秘钥 + * @return + */ + public String XORdecode(String res, String key) { + byte[] bs = parseHexStr2Byte(res); + for (int i = 0; i < bs.length; i++) { + bs[i] = (byte) ((bs[i]) ^ key.hashCode()); + } + return new String(bs); + } + + /** + * 直接使用异或(第一调用加密,第二次调用解密) + * + * @param res 密文 + * @param key 秘钥 + * @return + */ + public int XOR(int res, String key) { + return res ^ key.hashCode(); + } + + /** + * 使用Base64进行加密 + * + * @param res 密文 + * @return + */ + public String Base64Encode(String res) { + return Base64.encode(res.getBytes()); + } + + /** + * 使用Base64进行解密 + * + * @param res + * @return + */ + public String Base64Decode(String res) { + return new String(Base64.decode(res)); + } + + + private static final int length = 128; + + /** + * 加密 + * + * @param content 需要加密的内容 + * @param password 加密密码 + * @return + * @throws NoSuchAlgorithmException + * @throws NoSuchPaddingException + * @throws UnsupportedEncodingException + * @throws InvalidKeyException + * @throws BadPaddingException + * @throws IllegalBlockSizeException + */ + private static byte[] encrypt(String content, String password) + throws Exception { + + KeyGenerator kgen = KeyGenerator.getInstance("AES"); + SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG"); + secureRandom.setSeed(password.getBytes()); + kgen.init(length, secureRandom); + SecretKey secretKey = kgen.generateKey(); + byte[] enCodeFormat = secretKey.getEncoded(); + SecretKeySpec key = new SecretKeySpec(enCodeFormat, "AES"); + Cipher cipher = Cipher.getInstance("AES");// 创建密码器 + byte[] byteContent = content.getBytes("utf-8"); + cipher.init(Cipher.ENCRYPT_MODE, key);// 初始化 + byte[] result = cipher.doFinal(byteContent); + return result; // 加密 + + } + + /** + * 解密 + * + * @param content 待解密内容 + * @param password 解密密钥 + * @return + */ + private static byte[] decrypt(byte[] content, String password) + throws Exception { + KeyGenerator kgen = KeyGenerator.getInstance("AES"); + SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG"); + secureRandom.setSeed(password.getBytes()); + kgen.init(length, secureRandom); + SecretKey secretKey = kgen.generateKey(); + byte[] enCodeFormat = secretKey.getEncoded(); + SecretKeySpec key = new SecretKeySpec(enCodeFormat, "AES"); + Cipher cipher = Cipher.getInstance("AES");// 创建密码器 + cipher.init(Cipher.DECRYPT_MODE, key);// 初始化 + byte[] result = cipher.doFinal(content); + return result; // 加密 + + + } + + /** + * 加密 + * + * @param content 需要加密的内容 + * @param password 加密密码 + * @return + */ + public static byte[] encrypt2(String content, String password) { + try { + SecretKeySpec key = new SecretKeySpec(password.getBytes(), "AES"); + Cipher cipher = Cipher.getInstance("AES/ECB/NoPadding"); + byte[] byteContent = content.getBytes("utf-8"); + cipher.init(Cipher.ENCRYPT_MODE, key);// 初始化 + byte[] result = cipher.doFinal(byteContent); + return result; // 加密 + } catch (NoSuchAlgorithmException | NoSuchPaddingException | UnsupportedEncodingException | BadPaddingException | IllegalBlockSizeException | InvalidKeyException e) { + e.printStackTrace(); + } + return null; + } + + @Deprecated + public static String AESencode(String content, String password) { + try { + byte[] encryptResult = encrypt(content, password); + return Base64.encode(encryptResult); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + @Deprecated + public static String AESdecode(String content, String password) { + try { + byte[] decryptResult = decrypt(Base64.decode(content), password); + return new String(decryptResult, StandardCharsets.UTF_8); + } catch (Exception e) { + e.printStackTrace(); + return content; + } + } + + public static boolean isBase64(String str) { + String base64Pattern = "^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)$"; + return Pattern.matches(base64Pattern, str); + } + + public static void main(String[] args) { +// String s = AESencode("430602200007025537", "wfwbkdyrdmr"); +// System.out.println(s); + +// String s = AESencode("18058743226", "gsdfeygasfw"); +// String s1 = AESencode("张三", "gsdfeygasfw"); +// System.out.println(s); +// System.out.println(s1); +// System.out.println(Arrays.toString(Base64.decode("5vpdaf8bTigPCRakqzIZXA=="))); +// String s = AESdecode("Lsz+2WDokzxEuAaoZYf0cQ==", "gsdfeygasfw"); +// +// String phone = AESdecode("j6rj21kehQqc4JJS4NxTug==", "fdsasdfsdds"); +// System.out.println("phone:" + phone); +// String s = AESencode("18058743226", "gsdfeygasfw"); +// String s1 = AESdecode("CVr/+AgX/sHe00OQnXet9Q==", "wfwbkdyrdmr");许 +// System.out.println(s1); +// String s = AESencode("13750869639", "gsdfeygasfw"); +// System.out.println(s); +// System.out.println(AESdecode("O1ZWNkiAaIJLDGzwAaTfug==","gsdfeygasfw")); +// String a = AESdecode("罗娜","wfwbkdyrdmr"); +// System.out.println(a); +// System.out.println(MD5Utils.encrypt(a)); + +// System.out.println(AESencode("17707051035","gsdfeygasfw")); + System.out.println(AESdecode("W+/dxhwi5yBWiDnqtLKY+w==", "gsdfeygasfw")); + System.out.println(AESdecode("J88FbYTTmTeKXfIBBedw1A==", "gsdfeygasfw")); + + } + + /*** + * 利用Apache的工具类实现SHA-256加密 + * @param str 加密后的报文 + * @return + */ + public static String getSHA256Str(String str){ + MessageDigest messageDigest; + String encdeStr = ""; + try { + messageDigest = MessageDigest.getInstance("SHA-256"); + byte[] hash = messageDigest.digest(str.getBytes(StandardCharsets.UTF_8)); + encdeStr = Hex.encodeHexString(hash); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + } + return encdeStr; + } + + /** + * 用 AES 算法加密 inputStr。 + * 使用 secretStr 作为 key,ivStr作为 iv。 + * 并对加密后的字节数组调用 sun.misc.BASE64Encoder.encode 方法, + * 转换成 base64 字符串返回。 + * + * (仅作为测试用途,具体加密流程以接口文档为准) + * + * @param secretStr + * @param inputStr + * @return + */ + public static String base64StrDecode(String secretStr, String ivStr, String inputStr){ + byte[] inputBytes; + inputBytes = org.apache.commons.codec.binary.Base64.decodeBase64(inputStr); + String outputStr = new String(decode(secretStr, ivStr, inputBytes), CHARSET); + System.out.println("base64Decode > base64 decrypt " + outputStr); + return outputStr.trim(); + } + + /** + * 用 AES 算法解密 inputStr。 + * 使用 secretStr 作为 key,ivStr作为 iv。 + * + * @param secretStr + * @param ivStr + * @return + */ + public static byte[] decode(String secretStr, String ivStr, byte[] inputBytes){ + if (keyStrSize != secretStr.length() || ivStrSize != ivStr.length()) { + return null; + } + byte[] secretKeyBytes = secretStr.getBytes(CHARSET); + byte[] ivBytes = ivStr.getBytes(CHARSET); + + byte[] outputBytes = decryptCBCNoPadding(secretKeyBytes, ivBytes, inputBytes); + return outputBytes; + } + + /** + * AES/CBC/NoPadding decrypt + * 16 bytes secretKeyStr + * 16 bytes intVector + * + * @param secretKeyBytes + * @param intVectorBytes + * @param input + * @return + */ + public static byte[] decryptCBCNoPadding(byte[] secretKeyBytes, byte[] intVectorBytes, byte[] input) { + try { + IvParameterSpec iv = new IvParameterSpec(intVectorBytes); + SecretKey secretKey = new SecretKeySpec(secretKeyBytes, AES); + + Cipher cipher = Cipher.getInstance(AES_CBC_NOPADDING); + cipher.init(Cipher.DECRYPT_MODE, secretKey, iv); + byte[] encryptBytes = cipher.doFinal(input); + return encryptBytes; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + /** + * DES 加密加密模式 ECB,填充方式 Pkcs7,输出方式 Base64,字符集 utf8 + * @param data + * @param password + * @return + */ + public static String encryptECBPkcs7(String data, String password) { + if (password== null || password.length() < 8) { throw new RuntimeException("加密失败,key不能小于8位"); } + if(StringUtils.isBlank(data)){ return null; } + + try { + //下面这行在进行PKCS7Padding加密时必须加上,否则报错 + Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); + + //根据传入的秘钥内容生成符合DES加密解密格式的秘钥内容 + DESKeySpec dks = new DESKeySpec(password.getBytes()); + //获取DES秘钥生成器对象 + SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(DES); + // 生成秘钥:key的长度不能够小于8位字节 + Key secretKey = keyFactory.generateSecret(dks); + //获取DES/ECB/PKCS7Padding该种级别的加解密对象 + Cipher cipher = Cipher.getInstance(DES_ECB_PKCS7PADDING); + //初始化加解密对象【opmode:确定是加密还是解密模式;secretKey是加密解密所用秘钥】 + cipher.init(Cipher.ENCRYPT_MODE, secretKey); + byte[] bytes = cipher.doFinal(data.getBytes(CHARSET)); + return Base64.encode(bytes); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + public static String decryptECBPkcs7(String data, String password) { + if (password== null || password.length() < 8) { throw new RuntimeException("解密失败,key不能小于8位"); } + if(StringUtils.isBlank(data)){ return null; } + + try { + //下面这行在进行PKCS7Padding加密时必须加上,否则报错 + Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); + + //根据传入的秘钥内容生成符合DES加密解密格式的秘钥内容 + DESKeySpec dks = new DESKeySpec(password.getBytes()); + //获取DES秘钥生成器对象 + SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(DES); + // 生成秘钥:key的长度不能够小于8位字节 + Key secretKey = keyFactory.generateSecret(dks); + //获取DES/ECB/PKCS7Padding该种级别的加解密对象 + Cipher cipher = Cipher.getInstance(DES_ECB_PKCS7PADDING); + //初始化加解密对象【opmode:确定是加密还是解密模式;secretKey是加密解密所用秘钥】 + cipher.init(Cipher.DECRYPT_MODE, secretKey); + return new String(cipher.doFinal(Base64.decode(data.getBytes(charset))), charset); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + + + /** + * AES加密 + * @param content 内容 + * @param password 密钥 + * @return 加密后数据 + */ + public static byte[] encryptECBPkcs5(byte[] content, byte[] password) { + if (content == null || password == null) + return null; + try { + Cipher cipher = Cipher.getInstance(AES_ECB_PKCS5PADDING); + cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(password, AES)); + return cipher.doFinal(content); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + /** + * AES解密 + * @param content 加密内容 + * @param password 密钥 + * @return 解密后数据 + */ + public static byte[] decryptECBPkcs5(byte[] content, byte[] password) { + if (content == null || password == null) + return null; + try { + Cipher cipher = Cipher.getInstance(AES_ECB_PKCS5PADDING); + cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(password, AES)); + return cipher.doFinal(content); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + +} diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/LocalDateTimeUtils.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/LocalDateTimeUtils.java new file mode 100644 index 00000000..eef18ef1 --- /dev/null +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/LocalDateTimeUtils.java @@ -0,0 +1,483 @@ +package com.ruoyi.common.core.utils; + +import java.text.SimpleDateFormat; +import java.time.*; +import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoUnit; +import java.time.temporal.TemporalAdjusters; +import java.util.*; + +/** + * @program: JieYiHua-Cloud + * @description: 时间工具类 + * @author: LiYu + * @create: 2021-08-04 15:45 + **/ +public class LocalDateTimeUtils { + /** + * 获取指定日期所属周的周一的日期 + * + * @param localDate + * @return + */ + public static LocalDateTime getMondayForThisWeek(LocalDate localDate) { + LocalDateTime monday = LocalDateTime.of(localDate, LocalTime.MIN).with(DayOfWeek.MONDAY); + return monday; + } + + /** + * 获取指定日期所属周的周日的日期 + * + * @param localDate + * @return + */ + public static LocalDateTime getSundayForThisWeek(LocalDate localDate) { + LocalDateTime sunday = LocalDateTime.of(localDate, LocalTime.MIN).with(DayOfWeek.SUNDAY); + return sunday; + } + + /** + * 获取指定日期所属周的下周一的日期 + * + * @param localDate + * @return + */ + public static LocalDateTime getMondayForNextWeek(LocalDate localDate) { + LocalDateTime monday = LocalDateTime.of(localDate, LocalTime.MIN).plusWeeks(1).with(DayOfWeek.MONDAY); + return monday; + } + + /** + * 获取指定日期所属周的下周日的日期 + * + * @param localDate + * @return + */ + public static LocalDateTime getSundayForNextWeek(LocalDate localDate) { + LocalDateTime sunday = LocalDateTime.of(localDate, LocalTime.MIN).plusWeeks(1).with(DayOfWeek.SUNDAY); + return sunday; + } + + /** + * 指定格式为"yyyy-MM-dd HH:mm:ss"的字符串时间转化为LocalDateTime类型 + * + * @param dateStr + * @return + */ + public static LocalDateTime getLocalDateTimeFromString(String dateStr) { + LocalDateTime localDateTime = LocalDateTime.parse(dateStr, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); + return localDateTime; + } + + /** + * 指定格式为"yyyy-MM-ddTHH:mm:ss"的字符串时间转化为LocalDateTime类型 + * + * @param dateStr + * @return + */ + public static LocalDateTime getLocalDateTimeFromString2(String dateStr) { + LocalDateTime localDateTime = LocalDateTime.parse(dateStr, DateTimeFormatter.ofPattern("yyyy-MM-dd w hh:mm:ss")); + return localDateTime; + } + + /** + * LocalDateTime类型转化为格式为"yyyy-MM-dd HH:mm:ss"的字符串时间类型 + * + * @param localDateTime + * @return + */ + public static String getStringFromLocalDateTime(LocalDateTime localDateTime) { + String localDateTimeStr = localDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); + return localDateTimeStr; + } + + + /** + * LocalDateTime类型转化为格式为"yyyy-MM-dd"的字符串时间类型 + * + * @param localDateTime 时间 + * @return 结果 + */ + public static String getStringFromLocalDateTime2(LocalDateTime localDateTime) { + if (localDateTime == null) { return null; } + return localDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); + } + + /** + * LocalDateTime类型转化为格式为"yyyy-MM-dd HH"的字符串时间类型 + * + * @param localDateTime 时间 + * @return 结果 + */ + public static String getStringFromLocalDateTime4(LocalDateTime localDateTime) { + if (localDateTime == null) { return null; } + return localDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH")); + } + + /** + * LocalDateTime类型转化为格式为"yyyy-MM"的字符串时间类型 + */ + public static String getStringFromLocalDateTime3(LocalDateTime localDateTime) { + if (localDateTime == null) { + return null; + } + return localDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM")); + } + + /** + * Date类型时间转化为LocalDateTime类型 + * + * @param date + * @return + */ + public static LocalDateTime getLocalDateTimeFromDate(Date date) { + LocalDateTime localDateTime = date.toInstant().atOffset(ZoneOffset.of("+8")).toLocalDateTime(); + return localDateTime; + } + + /** + * LocalDateTime类型转化为Date类型时间 + * + * @param localDateTime + * @return + */ + public static Date getDateFromLocalDateTime(LocalDateTime localDateTime) { + Date date = Date.from(localDateTime.toInstant(ZoneOffset.of("+8"))); + return date; + } + + /** + * 获取指定时间的00:00:00 + * + * @param localDateTime + * @return + */ + public static LocalDateTime getLocalDateTimeForBegin(LocalDateTime localDateTime) { + LocalDateTime begin = LocalDateTime.of(localDateTime.toLocalDate(), LocalTime.MIN); + return begin; + } + + /** + * 获取指定时间的23:59:59 + * + * @param localDateTime + * @return + */ + public static LocalDateTime getLocalDateTimeForEnd(LocalDateTime localDateTime) { + LocalDateTime end = LocalDateTime.of(localDateTime.toLocalDate(), LocalTime.MAX); + return end; + } + + /** + * 时间戳(毫秒)转化为LocalDateTime格式 + * + * @param timestamp + * @return + */ + public static LocalDateTime getLocalDateTimeFromTimestamp(Long timestamp) { + LocalDateTime localDateTime = LocalDateTime.ofEpochSecond(timestamp / 1000, 0, ZoneOffset.ofHours(8)); + return localDateTime; + } + + /** + * LocalDateTime格式转化为时间戳(毫秒) + * + * @param localDateTime + * @return + */ + public static Long getTimestampFromLocalDateTime(LocalDateTime localDateTime) { + Long timestamp = localDateTime.toInstant(ZoneOffset.of("+8")).toEpochMilli(); + return timestamp; + } + + /** + * 时间戳(毫秒)转 yyyy-MM-dd HH:mm:ss + * @param timestamp + * @return + */ + public static String getStringFromTimestamp(Long timestamp) { + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + return dateFormat.format(timestamp); + } + + /** + * 获取本月开始时间 + * + * @return 开始时间 + */ + public static LocalDateTime getFirstDayOfMonth() { + return LocalDateTime.of(LocalDate.from(LocalDateTime.now().with(TemporalAdjusters.firstDayOfMonth())), LocalTime.MIN); + } + + /** + * 获取月初 + * + * @param localDateTime 时间 + * @return 数据 + */ + public static LocalDateTime getTheBeginningOfTheMonth(LocalDateTime localDateTime) { + return LocalDateTime.of(LocalDate.from(localDateTime.with(TemporalAdjusters.firstDayOfMonth())), LocalTime.MIN); + } + + /** + * 获取本月结束时间 + * + * @return 结束时间 + */ + public static LocalDateTime getLastDay() { + return LocalDateTime.of(LocalDate.from(LocalDateTime.now().with(TemporalAdjusters.lastDayOfMonth())), LocalTime.MAX); + } + + public static LocalDateTime getTheEndOfTheMonth(LocalDateTime localDateTime) { + return LocalDateTime.of(LocalDate.from(localDateTime.with(TemporalAdjusters.lastDayOfMonth())), LocalTime.MAX); + } + + /** + * 获取时间差 (秒) + * + * @param startTime 开始时间 + * @param endTime 结束时间 + * @return 秒 + */ + public static Long getTimeDifference(LocalDateTime startTime, LocalDateTime endTime) { + Duration duration = Duration.between(startTime, endTime); + return duration.toMinutes() * 60; + } + + /** + * 获取两个时间差 (天数) + * + * @param localDateTime 时间 + * @return 天数 + */ + public static Long timeDifferenceByDay(LocalDateTime localDateTime) { + LocalDateTime now = LocalDateTime.now(); + Duration duration = Duration.between(localDateTime, now); + return duration.toDays(); + } + + /** + * 获取两天时间间隔 + * + * @param startingTime 开始时间 + * @param endTime 结束时间 + * @return 结果 + */ + public static Long twoDayInterval(LocalDateTime startingTime, LocalDateTime endTime) { + Duration duration = Duration.between(startingTime, endTime); + return duration.toDays(); + } + + /** + * 转白话 + * + * @param localDateTime 时间 + * @return 字符串 + */ + public static String toTheVernacular(LocalDateTime localDateTime) { + return localDateTime.getYear() + "年" + localDateTime.getMonthValue() + "月" + localDateTime.getDayOfMonth() + "日"; + } + + + /** + * 获取昨天 + * + * @return 获取昨天 + */ + public static LocalDateTime getYesterdaySDate() { + return LocalDateTime.now().plusDays(1); + } + /** + * 获取昨天 + * + * @return 获取昨天 + */ + public static LocalDateTime getMinusDays() { + return LocalDateTime.now().minusDays(1); + } + /** + * 获取明天 + * + * @return 获取明天 + */ + public static LocalDateTime getPlusDays() { + return LocalDateTime.now().plusDays(1); + } + + /** + * 获取今年开始时间 + * + * @return 开始时间 + */ + public static LocalDateTime startThisYear() { + return LocalDateTime.of(LocalDate.from(LocalDateTime.now().with(TemporalAdjusters.firstDayOfYear())), LocalTime.MIN); + } + + + /** + * 根据日期获取 星期 (2019-05-06 ——> 星期一) + * + * @param datetime + * @return + */ + public static int dateToWeek(LocalDateTime datetime) { + //获取当前时间 + LocalDateTime currentDate = LocalDateTime.now(); + //获取当前周 + int week = currentDate.getDayOfWeek().getValue(); + System.out.println("获取当前周:" + week); + return week; + } + + public static void main(String[] args) { + System.out.println(twoDayInterval(LocalDateTime.now(),LocalDateTime.now())); + System.out.println(getNowBeforeHourTime(-24L)); + } + + + + /** + * 获取今天开始时间 + * + * @return 结果 + */ + public static LocalDateTime getTodayStartTime() { + return getLocalDateTimeForBegin(LocalDateTime.now()); + } + + /** + * 获取今天结束时间 + * + * @return 结果 + */ + public static LocalDateTime getTodayEndTime() { + return getLocalDateTimeForEnd(LocalDateTime.now()); + } + + + + + + /** + * 相隔所有时间 + * + * @param startingTime 开始时间 + * @param endTime 结束时间 + * @return 结果 + */ + public static List allTimeApart(String startingTime, String endTime) { + Long size = LocalDateTimeUtils.twoDayInterval(LocalDateTimeUtils.getLocalDateTimeFromString(startingTime), LocalDateTimeUtils.getLocalDateTimeFromString(endTime)); + List list = new ArrayList<>(Math.toIntExact(size)); + LocalDateTime time = getLocalDateTimeFromString(endTime); + for (int i = 0; i <= size; i++) { + LocalDateTime localDateTime = time.minusDays(i); + list.add(getStringFromLocalDateTime2(localDateTime)); + } + return list; + } + + + /** + * 判断当前用户登录时段是否在09:00-18:00 + * @param + * @return + */ + public static boolean setFirstLogTime(){ + SimpleDateFormat formatter = new SimpleDateFormat("HH:mm");//获取时,分 + //当前系统时间 + Date data = new Date(); + String dateString = formatter.format(data); + String format = "HH:mm"; + try{ + Date nowTime = new SimpleDateFormat(format).parse(dateString); + Date startTime = new SimpleDateFormat(format).parse("09:00"); + Date endTime = new SimpleDateFormat(format).parse("18:00"); + return isEffectiveDate(nowTime, startTime, endTime); + }catch (Exception e){ + e.printStackTrace(); + return false; + } + } + + /** + * 判断当前时间是否在[startTime, endTime]区间,注意时间格式要一致 + * + * @param nowTime 当前时间 + * @param startTime 开始时间 + * @param endTime 结束时间 + * @return + */ + public static boolean isEffectiveDate(Date nowTime, Date startTime, Date endTime) { + if (nowTime.getTime() == startTime.getTime() || nowTime.getTime() == endTime.getTime()) { + return true; + } + Calendar date = Calendar.getInstance(); + date.setTime(nowTime); + Calendar begin = Calendar.getInstance(); + begin.setTime(startTime); + Calendar end = Calendar.getInstance(); + end.setTime(endTime); + if (date.after(begin) && date.before(end)) { + return true; + } else { + return false; + } + } + + /** + * 判断当前日期是否大于某个日期 + * @param date yyyy-MM-dd + * @return + */ + public static boolean afterDate(LocalDateTime date){ + //针对好享管家图片相反 + String times = "2022-08-23"; + DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + //把String转为LocalDate + LocalDate localTime=LocalDate.parse(times,dtf); + //判断当前日期是否大于指定日期 + return date.toLocalDate().isAfter(localTime); + } + + + /** + * 获取当前时间指定偏移多长小时前的时间 + * @param hour 负向前偏移 正向后偏移 + * @return + */ + public static LocalDateTime getNowBeforeHourTime(Long hour){ + LocalDateTime localDateTime = LocalDateTime.now(ZoneId.systemDefault()); + return localDateTime.plusHours(hour); + } + + public static Long timeDifferenceByLocalDate(LocalDateTime localDateTime) { + LocalDate toLocalDate = localDateTime.toLocalDate(); + LocalDate now = LocalDate.now(); + long until = toLocalDate.until(now, ChronoUnit.DAYS); + return toLocalDate.until(now, ChronoUnit.DAYS); + } + + /** + * 判断时间是否是今天 + * @param localDateTime 时间 + * @return 结果 + */ + public static boolean isToday(LocalDateTime localDateTime) { + return localDateTime.toLocalDate().equals(LocalDate.now()); + } + + /** + * 判断日期是否是指定天数内 + * @param localDateTime 时间 + * @param day 天数 + * @return 结果 + */ + public static boolean isDay(LocalDateTime localDateTime,Long day) { + return localDateTime.toLocalDate().equals(LocalDate.now().plusDays(day)); + } + + public static long getTimeStamp(String dateTime){ + LocalDateTime time = LocalDateTimeUtils.getLocalDateTimeFromString(dateTime); + return time.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(); + } +} diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/ProbitUtil.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/ProbitUtil.java new file mode 100644 index 00000000..3c06bcec --- /dev/null +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/ProbitUtil.java @@ -0,0 +1,155 @@ +package com.ruoyi.common.core.utils; + + +import com.ruoyi.common.core.domain.GuestProbabilityReq; +import lombok.extern.slf4j.Slf4j; + +import java.math.BigDecimal; +import java.util.*; + +/** + * 计算助贷计划概率 + * @Author: daisi + * @Date: 2022/4/2 11:10 + */ +@Slf4j +public class ProbitUtil { + public static GuestProbabilityReq calculatePlanTheProbability(List guestProbabilityReqs) { + //按排序价格排序 + Collections.sort(guestProbabilityReqs, new Comparator() { + @Override + public int compare(GuestProbabilityReq o1, GuestProbabilityReq o2) { + return o2.getOrderPrice().compareTo(o1.getOrderPrice()); + } + }); + List list = new ArrayList<>(5); + for (GuestProbabilityReq guestProbabilityReq : guestProbabilityReqs) { +// if (guestProbabilityReq.getOrderPrice().compareTo(guestProbabilityReqs.get(0).getOrderPrice()) == 0) { +// list.add(guestProbabilityReq); +// } + list.add(guestProbabilityReq); + } + log.info("排序后的数据:{}",list); + //重置概率 + resetTranslate(list); + int index = drawGift(list); + return guestProbabilityReqs.get(index); + } + + private static List resetTranslate(List reqs) { + if (reqs.size()!=1){ + //高值得一部分 + int count = 0; + //获取计数 + BigDecimal orderPrice = reqs.get(0).getOrderPrice(); + for (int i = 0; i < reqs.size(); i++) { + if (i+1 guestProbabilityReqList) { + if (null != guestProbabilityReqList && guestProbabilityReqList.size() > 0) { + List orgProbList = new ArrayList(guestProbabilityReqList.size()); + for (GuestProbabilityReq guest : guestProbabilityReqList) { + //按顺序将概率添加到集合中 + orgProbList.add(guest.getGuestProbability()); + } + return draw(orgProbList); + } + return -1; + } + public static int draw(List giftProbList) { + List sortRateList = new ArrayList(); + // 计算概率总和 + Double sumRate = 0D; + for (Double prob : giftProbList) { + sumRate += prob; + } + if (sumRate != 0) { + double rate = 0D; //概率所占比例 + for (Double prob : giftProbList) { + rate += prob; + // 构建一个比例区段组成的集合(避免概率和不为1) + sortRateList.add(rate / sumRate); + } + // 随机生成一个随机数,并排序 + double random = Math.random(); + sortRateList.add(random); + Collections.sort(sortRateList); + // 返回该随机数在比例集合中的索引 + return sortRateList.indexOf(random); + } + return -1; + } + +// public static void main(String[] args) { +//// System.out.println(LocalDateTimeUtils.getStringFromLocalDateTime(LocalDateTimeUtil.beginOfDay(LocalDateTimeUtil.offset(LocalDateTime.now(), -7, ChronoUnit.DAYS)))); +//// System.out.println(LocalDateTimeUtils.getStringFromLocalDateTime(LocalDateTimeUtil.endOfDay(LocalDateTimeUtil.offset(LocalDateTime.now(), -1, ChronoUnit.DAYS)))); +// int a=0; +// List guestProbabilityReqs = new ArrayList<>(); +// for (int i = 0; i < 20; i++) { +// List list = new ArrayList<>(); +// GuestProbabilityReq req = new GuestProbabilityReq(); +// req.setPlanId(1L).setOrderPrice(new BigDecimal(104.00)).setGuestProbability(0.8D); +// +// GuestProbabilityReq req1 = new GuestProbabilityReq(); +// req1.setPlanId(2L).setOrderPrice(new BigDecimal(120)).setGuestProbability(0.8D); +// +// GuestProbabilityReq req2 = new GuestProbabilityReq(); +// req2.setPlanId(3L).setOrderPrice(new BigDecimal(90)).setGuestProbability(0.8D); +// +// GuestProbabilityReq req3 = new GuestProbabilityReq(); +// req3.setPlanId(4L).setOrderPrice(new BigDecimal(110)).setGuestProbability(0.4D); +// +// GuestProbabilityReq req4 = new GuestProbabilityReq(); +// req4.setPlanId(5L).setOrderPrice(new BigDecimal(110)).setGuestProbability(0.6D); +//// +//// GuestProbabilityReq req5 = new GuestProbabilityReq(); +//// req5.setPlanId(6L).setOrderPrice(new BigDecimal(80)).setGuestProbability(0.6D); +// +// list.add(req); +// list.add(req1); +// list.add(req2); +// list.add(req3); +// list.add(req4); +//// list.add(req5); +// +// guestProbabilityReqs.add(calculatePlanTheProbability(list)); +// +// } +// int b = 0; +// int c = 0; +// for (GuestProbabilityReq req:guestProbabilityReqs) { +// if (req.getPlanId()==2){ +// b++; +// }else { +// c++; +// } +// } +// System.out.println("几率:"+c+" "+b); +// } + +} diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/SecureUtils.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/SecureUtils.java new file mode 100644 index 00000000..609f43e0 --- /dev/null +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/SecureUtils.java @@ -0,0 +1,517 @@ +package com.ruoyi.common.core.utils; + + +import com.ruoyi.common.core.constant.HttpStatus; +import lombok.extern.slf4j.Slf4j; + +import javax.crypto.*; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; +import java.net.URLDecoder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; +import java.util.Base64; +import java.util.Objects; +import java.util.Random; +import java.util.regex.Pattern; + +/** + * @author LiYu + * @ClassName SecureUtil.java + * @Description 加解密工具类 + * @createTime 2024年05月20日 11:04:00 + */ +@Slf4j +public class SecureUtils { + /** + * md5加密 + */ + public static class Md5Util { + + /** + * 判断是否为md5加密 + * + * @param str 字符串 + * @return 结果 + */ + public static boolean isMd5(String str) { + return str.matches("^[a-f0-9]{32}$"); + } + + /** + * MD5加密并转大写 + * + * @param str 字符串 + * @return 结果 + */ + public static String md5ToUpperCase(String str) { + return StringUtils.hasText(str) ? isMd5(str) ? str : cn.hutool.crypto.SecureUtil.md5(str).toUpperCase() : null; + } + + /** + * MD5加密并转小写 + * + * @param str 字符串 + * @return 结果 + */ + public static String md5ToLowerCase(String str) { + return StringUtils.hasText(str) ? isMd5(str) ? str : cn.hutool.crypto.SecureUtil.md5(str).toLowerCase() : null; + } + + /** + * MD5加密 + * + * @param str 字符串 + * @return 结果 + */ + public static String md5(String str) { + return StringUtils.hasText(str) ? isMd5(str) ? str : cn.hutool.crypto.SecureUtil.md5(str) : null; + } + } + + /** + * des加密 + */ + public static class DesUtil { + /** + * 加密key + */ + public static final String KEY = "_@Ks`Y*9jLb.hvho}C;GwDpw"; + /** + * 偏移量 + */ + public static final String IV = "2%8iTpSi"; + + /** + * 创建加密对象 + * + * @param iv 偏移量 + * @param mode 模式 + * @return 结果 + */ + private static Cipher createCipher(String iv, int mode) throws NoSuchAlgorithmException, NoSuchPaddingException, + InvalidKeyException, InvalidAlgorithmParameterException { + byte[] key = KEY.getBytes(); + Cipher cipher = Cipher.getInstance("DESede/CBC/PKCS5Padding"); + IvParameterSpec ivParameterSpec = new IvParameterSpec(iv.getBytes()); + cipher.init(mode, new SecretKeySpec(key, "DESede"), ivParameterSpec); + return cipher; + } + + /** + * 加密 + * + * @param data 数据 + * @param iv 偏移量 + * @return 结果 + */ + public static String encrypt(String data, String iv) { + try { + Cipher cipher = createCipher(iv, Cipher.ENCRYPT_MODE); + return URLEncoder.encode(Base64.getEncoder().encodeToString(cipher.doFinal(data.getBytes())), "UTF-8"); + } catch (Exception e) { + log.error("加密失败", e); + } + return null; + } + + /** + * 加密 + * + * @param data 数据 + * @return 结果 + */ + public static String encrypt(String data) { + return encrypt(data, IV); + } + + /** + * 解密 + * + * @param data 数据 + * @param iv 偏移量 + * @return 结果 + */ + public static String decrypt(String data, String iv) { + try { + Cipher cipher = createCipher(iv, Cipher.DECRYPT_MODE); + return new String(cipher.doFinal(Base64.getDecoder().decode(URLDecoder.decode(data, "UTF-8")))); + } catch (Exception e) { + log.error("解密失败", e); + } + return null; + } + + /** + * 解密 + * + * @param data 数据 + * @return 结果 + */ + public static String decrypt(String data) { + return decrypt(data, IV); + } + + } + + /** + * AES加解密 + */ + public static class AesUtil { + /** + * 加密模式之 ECB,算法/模式/补码方式 + */ + public static final String AES_ECB = "AES/ECB/PKCS5Padding"; + + /** + * 加密模式之 CBC,算法/模式/补码方式 + */ + public static final String AES_CBC = "AES/CBC/PKCS5Padding"; + + /** + * 加密模式之 CFB,算法/模式/补码方式 + */ + public static final String AES_CFB = "AES/CFB/PKCS5Padding"; + + /** + * AES 中的 IV 必须是 16 字节(128位)长 + */ + public static final Integer IV_LENGTH = 16; + + /*** + * 空校验 + * @param str 需要判断的值 + */ + public static boolean isEmpty(Object str) { + return null == str || "".equals(str); + } + + /*** + * String 转 byte + * @param str 需要转换的字符串 + */ + public static byte[] getBytes(String str) { + if (isEmpty(str)) { + return null; + } + + try { + return str.getBytes(StandardCharsets.UTF_8); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + /*** + * 初始化向量(IV),它是一个随机生成的字节数组,用于增加加密和解密的安全性 + */ + public static String getIv() { + String str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; + Random random = new Random(); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < IV_LENGTH; i++) { + int number = random.nextInt(str.length()); + sb.append(str.charAt(number)); + } + return sb.toString(); + } + + + /*** + * 获取一个 AES 密钥规范 + */ + public static SecretKeySpec getSecretKeySpec(String key) { + return new SecretKeySpec(Objects.requireNonNull(getBytes(key)), "AES"); + } + + /** + * 加密 - 模式 ECB + * + * @param text 需要加密的文本内容 + * @param key 加密的密钥 key + */ + public static String encrypt(String text, String key) { + if (isEmpty(text) || isEmpty(key)) { + return null; + } + try { + // 创建AES加密器 + Cipher cipher = Cipher.getInstance(AES_ECB); + SecretKeySpec secretKeySpec = getSecretKeySpec(key); + cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec); + // 加密字节数组 + byte[] encryptedBytes = cipher.doFinal(Objects.requireNonNull(getBytes(text))); + // 将密文转换为 Base64 编码字符串 + return Base64.getEncoder().encodeToString(encryptedBytes); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + + /** + * 解密 - 模式 ECB + * + * @param text 需要解密的文本内容 + * @param key 解密的密钥 key + */ + public static String decrypt(String text, String key) { + if (isEmpty(text) || isEmpty(key)) { + return null; + } + // 将密文转换为16字节的字节数组 + byte[] textBytes = Base64.getDecoder().decode(text); + try { + // 创建AES加密器 + Cipher cipher = Cipher.getInstance(AES_ECB); + SecretKeySpec secretKeySpec = getSecretKeySpec(key); + cipher.init(Cipher.DECRYPT_MODE, secretKeySpec); + // 解密字节数组 + byte[] decryptedBytes = cipher.doFinal(textBytes); + // 将明文转换为字符串 + return new String(decryptedBytes, StandardCharsets.UTF_8); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + /** + * 加密 - 自定义加密模式 + * + * @param text 需要加密的文本内容 + * @param key 加密的密钥 key + * @param iv 初始化向量 + * @param mode 加密模式 + */ + public static String encrypt(String text, String key, String iv, String mode) { + if (isEmpty(text) || isEmpty(key) || isEmpty(iv)) { + return null; + } + try { + // 创建AES加密器 + Cipher cipher = Cipher.getInstance(mode); + SecretKeySpec secretKeySpec = getSecretKeySpec(key); + cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec, new IvParameterSpec(Objects.requireNonNull(getBytes(iv)))); + // 加密字节数组 + byte[] encryptedBytes = cipher.doFinal(Objects.requireNonNull(getBytes(text))); + // 将密文转换为 Base64 编码字符串 + return Base64.getEncoder().encodeToString(encryptedBytes); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + /** + * 加密 + * + * @param content 待加密内容 + * @param password 加密密钥 + * @return 加密后的内容 + */ + public static String AesEncode(String content, String password) { + try { + byte[] encryptResult = encryptByte(content, password); + return Base64Util.encode(encryptResult); + } catch (Exception e) { + log.error("加密出现问题!", e); + e.printStackTrace(); + } + return null; + } + + public static void main(String[] args) { + + String s = "{\"accumulationFund\":1,\"age\":18,\"car\":1,\"career\":1,\"city\":\"重庆\",\"cityCode\":1000,\"creditCard\":1,\"education\":1,\"guarantee\":1,\"hourse\":1,\"idCardMd5\":\"331d17d1ca8a091410e3238fab16a863\",\"monthlyIncome\":5000,\"nameMd5\":\"331d17d1ca8a091410e3238fab16a863\",\"phoneMd5\":\"331d17d1ca8a091410e3238fab16a863\",\"sex\":0,\"socialSecurity\":1,\"zhiMa\":600}"; + String s1 = "{\"accumulationFund\":1,\"age\":18,\"car\":1,\"career\":1,\"city\":\"重庆\",\"cityCode\":1000,\"creditCard\":1,\"education\":1,\"guarantee\":1,\"hourse\":1,\"idCard\":\"341202199306023511\",\"idCardMd5\":\"331d17d1ca8a091410e3238fab16a863\",\"monthlyIncome\":5000,\"name\":\"朱三\",\"nameMd5\":\"331d17d1ca8a091410e3238fab16a863\",\"phone\":\"15205600635\",\"phoneMd5\":\"331d17d1ca8a091410e3238fab16a863\",\"sex\":0,\"socialSecurity\":1,\"zhiMa\":600}"; + String s3 = "{\n" + + " \"orderNo\":\"111111\",\n" + + " \"md5\":\"aaaaaa\",\n" + + " \"price\":100.00,\n" + + " \"orderStatus\":\"2\"\n" + + "}"; + + System.out.println(AesEncode(s1,"g5N8XTYaOEwEmBgg")); + } + /** + * 解密 + * + * @param content 待解密内容 + * @param password 解密密钥 + * @return 解密后的内容 + */ + public static String AesDecode(String content, String password) { + try { + byte[] decryptResult = decryptByte(Base64Util.decodeToByteArray(content), password); + return new String(decryptResult, StandardCharsets.UTF_8); + } catch (Exception e) { + log.error("解密出现问题!", e); + return null; + } + } + + /** + * 加密 - 模式 CBC + * + * @param text 需要加密的文本内容 + * @param key 加密的密钥 key + * @param iv 初始化向量 + * @return 加密后的内容 + */ + public static String encryptCbc(String text, String key, String iv) { + return encrypt(text, key, iv, AES_CBC); + } + + /** + * 解密 - 自定义加密模式 + * + * @param text 需要解密的文本内容 + * @param key 解密的密钥 key + * @param iv 初始化向量 + * @param mode 加密模式 + */ + public static String decrypt(String text, String key, String iv, String mode) { + if (isEmpty(text) || isEmpty(key) || isEmpty(iv)) { + return null; + } + // 将密文转换为16字节的字节数组 + byte[] textBytes = Base64.getDecoder().decode(text); + try { + // 创建AES加密器 + Cipher cipher = Cipher.getInstance(mode); + SecretKeySpec secretKeySpec = getSecretKeySpec(key); + cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, new IvParameterSpec(Objects.requireNonNull(getBytes(iv)))); + // 解密字节数组 + byte[] decryptedBytes = cipher.doFinal(textBytes); + // 将明文转换为字符串 + return new String(decryptedBytes, StandardCharsets.UTF_8); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + /** + * 解密 + * + * @param content 待解密内容 + * @param password 解密密钥 + * @return 解密后的内容 + */ + private static byte[] decryptByte(byte[] content, String password) + throws Exception { + KeyGenerator keyGenerator = KeyGenerator.getInstance("AES"); + SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG"); + secureRandom.setSeed(password.getBytes()); + keyGenerator.init(128, secureRandom); + SecretKey secretKey = keyGenerator.generateKey(); + byte[] enCodeFormat = secretKey.getEncoded(); + SecretKeySpec key = new SecretKeySpec(enCodeFormat, "AES"); + Cipher cipher = Cipher.getInstance("AES"); + cipher.init(Cipher.DECRYPT_MODE, key); + return cipher.doFinal(content); + } + + /** + * 加密 + * + * @param content 需要加密的内容 + * @param password 加密密码 + * @return 加密后的字节数组 + */ + private static byte[] encryptByte(String content, String password) + throws Exception { + KeyGenerator keyGenerator = KeyGenerator.getInstance("AES"); + SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG"); + secureRandom.setSeed(password.getBytes()); + keyGenerator.init(128, secureRandom); + SecretKey secretKey = keyGenerator.generateKey(); + byte[] enCodeFormat = secretKey.getEncoded(); + SecretKeySpec key = new SecretKeySpec(enCodeFormat, "AES"); + Cipher cipher = Cipher.getInstance("AES");// 创建密码器 + byte[] byteContent = content.getBytes(StandardCharsets.UTF_8); + cipher.init(Cipher.ENCRYPT_MODE, key); + return cipher.doFinal(byteContent); + } + + /** + * 解密 - 模式 CBC + * + * @param text 需要加密的文本内容 + * @param key 加密的密钥 key + * @param iv 初始化向量 + * @return 加密后的内容 + */ + public static String decryptCbc(String text, String key, String iv) { + return decrypt(text, key, iv, AES_CBC); + } + + + + + } + + + /** + * Base64加解密 + */ + public static class Base64Util { + /** + * 编码字符串为Base64 + * + * @param input 需要编码的字符串 + * @return 编码后的Base64字符串 + */ + public static String encode(String input) { + return Base64.getEncoder().encodeToString(input.getBytes()); + } + + /** + * 从Base64编码解码为字符串 + * + * @param input Base64编码的字符串 + * @return 解码后的字符串 + */ + public static String decode(String input) { + byte[] decodedBytes = Base64.getDecoder().decode(input); + return new String(decodedBytes); + } + + /** + * 编码字节数组为Base64字符串 + * + * @param input 需要编码的字节数组 + * @return 编码后的Base64字符串 + */ + public static String encode(byte[] input) { + return Base64.getEncoder().encodeToString(input); + } + + /** + * 解码Base64字符串为字节数组 + * + * @param input Base64编码的字符串 + * @return 解码后的字节数组 + */ + public static byte[] decodeToByteArray(String input) { + return Base64.getDecoder().decode(input); + } + + /** + * 判断是否为Base64编码 + * + * @param str 字符串 + * @return 结果 + */ + public static boolean isBase64(String str) { + String base64Pattern = "^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)$"; + return Pattern.matches(base64Pattern, str); + } + } + + public static void main(String[] args) { + + } +} diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/match/MatchQualification.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/match/MatchQualification.java new file mode 100644 index 00000000..44576ee7 --- /dev/null +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/match/MatchQualification.java @@ -0,0 +1,456 @@ +package com.ruoyi.common.core.utils.match; + +import com.ruoyi.common.core.domain.http.Customer; +import com.ruoyi.common.core.domain.http.Merchant; +import lombok.extern.slf4j.Slf4j; + +import java.util.Objects; + +@Slf4j +public class MatchQualification { + + /** + * 是否可以匹配上产品 + * @param customer 用户信息 + * @param merchant 产品前筛 + * openInfoFilter 开启资质筛选 0:不筛选, 1:满足1, 2:满足全部 + * + * @return 结构 + */ + public static Boolean doesItMatchProduct(Customer customer, Merchant merchant) { +// if (Objects.isNull(merchant)){ +// return true; +// } +// +// if (Objects.isNull(merchant.getCustomerInfoFilterType()) || merchant.getCustomerInfoFilterType() == 0){ +// return true; +// } +// +// //满足1个 +// boolean openOne = merchant.getCustomerInfoFilterType() == 1; +// //满足所有 +// boolean openAll = merchant.getCustomerInfoFilterType() == 2; +// //结果 +// boolean result = false; +// +// String userInfo = customer.getId() + "-" + customer.getChannelId() + "-" + merchant.getId(); +// +// //社保 +// if (merchant.getSocialSecurityHigh() || merchant.getSocialSecurityNo() ||merchant.getSocialSecurityLow()) { +// if (openAll && Objects.isNull(customer.getSocialSecurity())){ +// log.info("资质匹配筛选, 配置[满足所有]-社保为空, 匹配不通过, 结束匹配, 用户id-渠道id-渠道名称-产品id:{}", userInfo); +// return false; +// } +// +// Integer infoByCode = customer.getSocialSecurity(); +// if (Objects.nonNull(customer.getSocialSecurity())) { +// if (merchant.getSocialSecurityNo()) { +// if (customer.getSocialSecurity()==merchant.getSocialSecurityNo())) { +// result = true; +// } +// } +// +// if (merchant.getSocialSecurityLow()) { +// if (customer.getSocialSecurity().equals(CustomerSocialSecurityType.GREAT_SOCIAL_SECURITY.getCode())) { +// result = true; +// } +// } +// +// //条件为 满足一个即可, 恰巧现在就有满足的, 则返回true(通过) +// if (openOne && result) { +//// log.info("资质匹配筛选, 配置[满足其一]-社保:{}, 匹配通过, 结束匹配, 用户id-渠道id-渠道名称-产品id:{}", userDetailsDTO.getSocialSecurity() + "-" + infoByCode, userInfo); +// return result; +// } +// } +// +// //条件为 满足全部, 恰巧现在这个不满足, 则返回false(不通过) +// if (openAll && !result) { +// log.info("资质匹配筛选, 配置[满足所有]-社保:{}, 匹配不通过, 结束匹配, 用户id-渠道id-渠道名称-产品id:{}", userDetailsDTO.getSocialSecurity() + "-" + infoByCode, userInfo); +// return false; +// } +// } +// +// //公积金 +// if (productLimit.getSmallProvidentFund() || productLimit.getGreatProvidentFund()) { +// if (openAll && Objects.isNull(userDetailsDTO.getProvidentFund())){ +// log.info("资质匹配筛选, 配置[满足所有]-公积金为空, 匹配不通过, 结束匹配, 用户id-渠道id-渠道名称-产品id:{}", userInfo); +// return false; +// } +// +// //判断结果置默认 +// result = false; +// String infoByCode = CustomerProvidentFundType.getInfoByCode(userDetailsDTO.getProvidentFund()); +// if (Objects.nonNull(userDetailsDTO.getProvidentFund())) { +// if (productLimit.getSmallProvidentFund()) { +// if (userDetailsDTO.getProvidentFund().equals(CustomerProvidentFundType.SMALL_PROVIDENT_FUND.getCode())) { +// result = true; +// } +// } +// +// if (productLimit.getGreatProvidentFund()) { +// if (userDetailsDTO.getProvidentFund().equals(CustomerProvidentFundType.GREAT_PROVIDENT_FUND.getCode())) { +// result = true; +// } +// } +// +// //条件为 满足一个即可, 恰巧现在就有满足的, 则返回true(通过) +// if (openOne && result) { +//// log.info("资质匹配筛选, 配置[满足其一]-公积金:{}, 匹配通过, 结束匹配, 用户id-渠道id-渠道名称-产品id:{}", userDetailsDTO.getProvidentFund() + "-" + infoByCode, userInfo); +// return result; +// } +// } +// +// //条件为 满足全部, 恰巧现在这个不满足, 则返回false(不通过) +// if (openAll && !result) { +//// log.info("资质匹配筛选, 配置[满足所有]-公积金:{}, 匹配不通过, 结束匹配, 用户id-渠道id-渠道名称-产品id:{}", userDetailsDTO.getProvidentFund() + "-" + infoByCode, userInfo); +// return false; +// } +// } +// +// //车产 +// if (productLimit.getHavaCar()) { +// if (openAll && Objects.isNull(userDetailsDTO.getCarProduction())){ +// log.info("资质匹配筛选, 配置[满足所有]-车产为空, 匹配不通过, 结束匹配, 用户id-渠道id-渠道名称-产品id:{}", userInfo); +// return false; +// } +// +// //判断结果置默认 +// result = false; +// String infoByCode = CustomerCarProductionType.getInfoByCode(userDetailsDTO.getCarProduction()); +// if (Objects.nonNull(userDetailsDTO.getCarProduction())) { +// if (userDetailsDTO.getCarProduction().equals(CustomerCarProductionType.HAVE_CAR.getCode())) { +// result = true; +// } +// +// //条件为 满足一个即可, 恰巧现在就有满足的, 则返回true(通过) +// if (openOne && result) { +// log.info("资质匹配筛选, 配置[满足其一]-车产:{}, 匹配通过, 结束匹配, 用户id-渠道id-渠道名称-产品id:{}", userDetailsDTO.getCarProduction() + "-" + infoByCode, userInfo); +// return result; +// } +// } +// +// //条件为 满足全部, 恰巧现在这个不满足, 则返回false(不通过) +// if (openAll && !result) { +// log.info("资质匹配筛选, 配置[满足所有]-车产:{}, 匹配不通过, 结束匹配, 用户id-渠道id-渠道名称-产品id:{}", userDetailsDTO.getCarProduction() + "-" + infoByCode, userInfo); +// return false; +// } +// } +// +// //房产 +// if (productLimit.getHaveMortgageRoom() || productLimit.getHaveFullRoom()) { +// if (openAll && Objects.isNull(userDetailsDTO.getEstate())){ +// log.info("资质匹配筛选, 配置[满足所有]-房产为空, 匹配不通过, 结束匹配, 用户id-渠道id-渠道名称-产品id:{}", userInfo); +// return false; +// } +// +// //判断结果置默认 +// result = false; +// String infoByCode = CustomerEstateType.getInfoByCode(userDetailsDTO.getEstate()); +// if (Objects.nonNull(userDetailsDTO.getEstate())) { +// if (productLimit.getHaveMortgageRoom()){ +// if (userDetailsDTO.getEstate().equals(CustomerEstateType.HAVE_PROPERTY.getCode())){ +// result = true; +// } +// } +// +// if (productLimit.getHaveFullRoom()){ +// if (userDetailsDTO.getEstate().equals(CustomerEstateType.FULL_PAYMENT_FOR_HOUSING.getCode())){ +// result = true; +// } +// } +// +// //条件为 满足一个即可, 恰巧现在就有满足的, 则返回true(通过) +// if (openOne && result) { +//// log.info("资质匹配筛选, 配置[满足其一]-房产:{}, 匹配通过, 结束匹配, 用户id-渠道id-渠道名称-产品id:{}", userDetailsDTO.getEstate() + "-" + infoByCode, userInfo); +// return result; +// } +// } +// +// //条件为 满足全部, 恰巧现在这个不满足, 则返回false(不通过) +// if (openAll && !result) { +// log.info("资质匹配筛选, 配置[满足所有]-房产:{}, 匹配不通过, 结束匹配, 用户id-渠道id-渠道名称-产品id:{}", userDetailsDTO.getEstate() + "-" + infoByCode, userInfo); +// return false; +// } +// } +// +// //保单 +// if (productLimit.getPolicyLessThanOneYear() || productLimit.getPolicyPaymentForOneYear() || productLimit.getPolicyPaymentForTwoYear()) { +// if (openAll && Objects.isNull(userDetailsDTO.getPersonalInsurance())){ +// log.info("资质匹配筛选, 配置[满足所有]-保单为空, 匹配不通过, 结束匹配, 用户id-渠道id-渠道名称-产品id:{}", userInfo); +// return false; +// } +// +// //判断结果置默认 +// result = false; +// String infoByCode = CustomerInsurancePolicyType.getInfoByCode(userDetailsDTO.getPersonalInsurance()); +// if (Objects.nonNull(userDetailsDTO.getPersonalInsurance())) { +// if (productLimit.getPolicyLessThanOneYear()) { +// if (userDetailsDTO.getPersonalInsurance().equals(CustomerInsurancePolicyType.POLICY_LESS_THAN_ONE_YEAR.getCode())) { +// result = true; +// } +// } +// +// if (productLimit.getPolicyPaymentForOneYear()) { +// if (userDetailsDTO.getPersonalInsurance().equals(CustomerInsurancePolicyType.POLICY_PAYMENT_FOR_ONE_YEAR.getCode())) { +// result = true; +// } +// } +// +// if (productLimit.getPolicyPaymentForTwoYear()) { +// if (userDetailsDTO.getPersonalInsurance().equals(CustomerInsurancePolicyType.POLICY_PAYMENT_FOR_TWO_YEAR.getCode())) { +// result = true; +// } +// } +// +// //条件为 满足一个即可, 恰巧现在就有满足的, 则返回true(通过) +// if (openOne && result) { +// log.info("资质匹配筛选, 配置[满足其一]-保单:{}, 匹配通过, 结束匹配, 用户id-渠道id-渠道名称-产品id:{}", userDetailsDTO.getPersonalInsurance() + "-" + infoByCode, userInfo); +// return result; +// } +// } +// +// //条件为 满足全部, 恰巧现在这个不满足, 则返回false(不通过) +// if (openAll && !result) { +// log.info("资质匹配筛选, 配置[满足所有]-保单:{}, 匹配不通过, 结束匹配, 用户id-渠道id-渠道名称-产品id:{}", userDetailsDTO.getPersonalInsurance() + "-" + infoByCode, userInfo); +// return false; +// } +// } +// +// //芝麻分 +// if (Objects.nonNull(productLimit.getSesame())){ +// if (openAll && Objects.isNull(userDetailsDTO.getSesame())){ +// log.info("资质匹配筛选, 配置[满足所有]-芝麻分为空, 匹配不通过, 结束匹配, 用户id-渠道id-渠道名称-产品id:{}", userInfo); +// return false; +// } +// +// //判断结果置默认 +// result = false; +// if (Objects.nonNull(userDetailsDTO.getSesame())) { +// if (userDetailsDTO.getSesame() >= productLimit.getSesame()){ +// result = true; +// } +// +// //条件为 满足一个即可, 恰巧现在就有满足的, 则返回true(通过) +// if (openOne && result) { +// log.info("资质匹配筛选, 配置[满足其一]-芝麻分:{}, 匹配通过, 结束匹配, 用户id-渠道id-渠道名称-产品id:{}", userDetailsDTO.getSesame(), userInfo); +// return result; +// } +// } +// +// //条件为 满足全部, 恰巧现在这个不满足, 则返回false(不通过) +// if (openAll && !result) { +// log.info("资质匹配筛选, 配置[满足所有]-芝麻分:{}, 匹配不通过, 结束匹配, 用户id-渠道id-渠道名称-产品id:{}", userDetailsDTO.getSesame(), userInfo); +// return false; +// } +// } +// +// //职业 +// if (productLimit.getOfficeWorker() || +// productLimit.getCivilServant() || +// productLimit.getPrivateOwners() || +// productLimit.getSmallPrivateBusiness() || +// productLimit.getOtherOccupations()) { +// +// if (openAll && Objects.isNull(userDetailsDTO.getProfessionalIdentity())){ +// log.info("资质匹配筛选, 配置[满足所有]-职业为空, 匹配不通过, 结束匹配, 用户id-渠道id-渠道名称-产品id:{}", userInfo); +// return false; +// } +// +// //判断结果置默认 +// result = false; +// String infoByCode = CustomerProfessionalIdentityType.getInfoByCode(userDetailsDTO.getProfessionalIdentity()); +// if (Objects.nonNull(userDetailsDTO.getProfessionalIdentity())) { +// if (productLimit.getOfficeWorker()){ +// if (userDetailsDTO.getProfessionalIdentity().equals(CustomerProfessionalIdentityType.OFFICE_WORKER.getCode())) { +// result = true; +// } +// } +// +// if (productLimit.getCivilServant()){ +// if (userDetailsDTO.getProfessionalIdentity().equals(CustomerProfessionalIdentityType.CIVIL_SERVANT.getCode())) { +// result = true; +// } +// } +// +// if (productLimit.getPrivateOwners()){ +// if (userDetailsDTO.getProfessionalIdentity().equals(CustomerProfessionalIdentityType.PRIVATE_OWNERS.getCode())) { +// result = true; +// } +// } +// +// if (productLimit.getSmallPrivateBusiness()){ +// if (userDetailsDTO.getProfessionalIdentity().equals(CustomerProfessionalIdentityType.SMALL_PRIVATE_BUSINESS.getCode())) { +// result = true; +// } +// } +// +// if (productLimit.getOtherOccupations()){ +// if (userDetailsDTO.getProfessionalIdentity().equals(CustomerProfessionalIdentityType.OTHER_OCCUPATIONS.getCode())) { +// result = true; +// } +// } +// +// //条件为 满足一个即可, 恰巧现在就有满足的, 则返回true(通过) +// if (openOne && result) { +// log.info("资质匹配筛选, 配置[满足其一]-职业:{}, 匹配通过, 结束匹配, 用户id-渠道id-渠道名称-产品id:{}", userDetailsDTO.getProfessionalIdentity() + "-" + infoByCode, userInfo); +// return result; +// } +// } +// +// //条件为 满足全部, 恰巧现在这个不满足, 则返回false(不通过) +// if (openAll && !result) { +// log.info("资质匹配筛选, 配置[满足所有]-职业:{}, 匹配不通过, 结束匹配, 用户id-渠道id-渠道名称-产品id:{}", userDetailsDTO.getProfessionalIdentity() + "-" + infoByCode, userInfo); +// return false; +// } +// } +// +// //学历 字典映射 1: "初中及以下,2: "高中",3: "中专",4: "大专",5: "本科",6: "研究生及以上" +// if (productLimit.getJuniorMiddleSchool() || +// productLimit.getSeniorMiddleSchool() || +// productLimit.getMiddleSchool() || +// productLimit.getCollege() || +// productLimit.getUndergraduate() || +// productLimit.getPostgraduate()) { +// +// if (openAll && Objects.isNull(userDetailsDTO.getEducation())){ +// log.info("资质匹配筛选, 配置[满足所有]-学历为空, 匹配不通过, 结束匹配, 用户id-渠道id-渠道名称-产品id:{}", userInfo); +// return false; +// } +// +// //判断结果置默认 +// result = false; +// String infoByCode = getEducationByCode(userDetailsDTO.getEducation()); +// if (Objects.nonNull(userDetailsDTO.getEducation())) { +// if (productLimit.getJuniorMiddleSchool() && userDetailsDTO.getEducation() == 1) { //初中 +// result = true; +// } +// +// if (productLimit.getSeniorMiddleSchool() && userDetailsDTO.getEducation() == 2) { //高中 +// result = true; +// } +// +// if (productLimit.getMiddleSchool() && userDetailsDTO.getEducation() == 3) { //中专 +// result = true; +// } +// +// if (productLimit.getCollege() && userDetailsDTO.getEducation() == 4) { //大专 +// result = true; +// } +// +// if (productLimit.getUndergraduate() && userDetailsDTO.getEducation() == 5) { //本科 +// result = true; +// } +// +// if (productLimit.getPostgraduate() && userDetailsDTO.getEducation() == 6) { //研究生 +// result = true; +// } +// +// //条件为 满足一个即可, 恰巧现在就有满足的, 则返回true(通过) +// if (openOne && result) { +// log.info("资质匹配筛选, 配置[满足其一]-学历:{}, 匹配通过, 结束匹配, 用户id-渠道id-渠道名称-产品id:{}", userDetailsDTO.getEducation() + "-" + infoByCode, userInfo); +// return result; +// } +// } +// +// //条件为 满足全部, 恰巧现在这个不满足, 则返回false(不通过) +// if (openAll && !result) { +// log.info("资质匹配筛选, 配置[满足所有]-学历:{}, 匹配不通过, 结束匹配, 用户id-渠道id-渠道名称-产品id:{}", userDetailsDTO.getEducation() + "-" + infoByCode, userInfo); +// return false; +// } +// } +// +// //白条可用额度 字典映射 1: 无额度,2: 2000以下,3: 2000-10000,4: 大于10000 +// if (productLimit.getBaiTiaoLevelOne() || +// productLimit.getBaiTiaoLevelTwo() || +// productLimit.getBaiTiaoLevelThree()) { +// +// if (openAll && Objects.isNull(userDetailsDTO.getBaiTiaoQuota())){ +// log.info("资质匹配筛选, 配置[满足所有]-白条为空, 匹配不通过, 结束匹配, 用户id-渠道id-渠道名称-产品id:{}", userInfo); +// return false; +// } +// +// //判断结果置默认 +// result = false; +// String infoByCode = getBaiTiaoByCode(userDetailsDTO.getBaiTiaoQuota()); +// if (Objects.nonNull(userDetailsDTO.getBaiTiaoQuota())) { +// if (productLimit.getBaiTiaoLevelOne() && userDetailsDTO.getBaiTiaoQuota() == 2) { //2000以下 +// result = true; +// } +// +// if (productLimit.getBaiTiaoLevelTwo() && userDetailsDTO.getBaiTiaoQuota() == 3) { //2000-10000 +// result = true; +// } +// +// if (productLimit.getBaiTiaoLevelThree() && userDetailsDTO.getBaiTiaoQuota() == 4) { //大于10000 +// result = true; +// } +// +// //条件为 满足一个即可, 恰巧现在就有满足的, 则返回true(通过) +// if (openOne && result) { +// log.info("资质匹配筛选, 配置[满足其一]-白条:{}, 匹配通过, 结束匹配, 用户id-渠道id-渠道名称-产品id:{}", userDetailsDTO.getBaiTiaoQuota() + "-" + infoByCode, userInfo); +// return result; +// } +// } +// +// //条件为 满足全部, 恰巧现在这个不满足, 则返回false(不通过) +// if (openAll && !result) { +// log.info("资质匹配筛选, 配置[满足所有]-白条:{}, 匹配不通过, 结束匹配, 用户id-渠道id-渠道名称-产品id:{}", userDetailsDTO.getBaiTiaoQuota() + "-" + infoByCode, userInfo); +// return false; +// } +// } +// +// //花呗可用额度 字典映射 1: 无额度,2: 2000以下,3: 2000-10000,4: 大于10000 +// if (productLimit.getHuaBeiLevelOne() || +// productLimit.getHuaBeiLevelTwo() || +// productLimit.getHuaBeiLevelThree()) { +// +// if (openAll && Objects.isNull(userDetailsDTO.getHuaBeiQuota())){ +// log.info("资质匹配筛选, 配置[满足所有]-花呗为空, 匹配不通过, 结束匹配, 用户id-渠道id-渠道名称-产品id:{}", userInfo); +// return false; +// } +// +// //判断结果置默认 +// result = false; +// String infoByCode = getBaiTiaoByCode(userDetailsDTO.getHuaBeiQuota()); +// if (Objects.nonNull(userDetailsDTO.getHuaBeiQuota())) { +// if (productLimit.getHuaBeiLevelOne() && userDetailsDTO.getHuaBeiQuota() == 2) { //2000以下 +// result = true; +// } +// +// if (productLimit.getHuaBeiLevelTwo() && userDetailsDTO.getHuaBeiQuota() == 3) { //2000-10000 +// result = true; +// } +// +// if (productLimit.getHuaBeiLevelThree() && userDetailsDTO.getHuaBeiQuota() == 4) { //大于10000 +// result = true; +// } +// +// //条件为 满足一个即可, 恰巧现在就有满足的, 则返回true(通过) +// if (openOne && result) { +// log.info("资质匹配筛选, 配置[满足其一]-花呗:{}, 匹配通过, 结束匹配, 用户id-渠道id-渠道名称-产品id:{}", userDetailsDTO.getHuaBeiQuota() + "-" + infoByCode, userInfo); +// return result; +// } +// } +// +// //条件为 满足全部, 恰巧现在这个不满足, 则返回false(不通过) +// if (openAll && !result) { +// log.info("资质匹配筛选, 配置[满足所有]-花呗:{}, 匹配不通过, 结束匹配, 用户id-渠道id-渠道名称-产品id:{}", userDetailsDTO.getHuaBeiQuota() + "-" + infoByCode, userInfo); +// return false; +// } +// } +// +// //满足其一, 但结果为false, 则不通过 +// if (openOne && !result){ +//// log.info("资质匹配筛选, 配置[满足其一]-未匹配成功, 匹配不通过, 结束匹配, 用户id-渠道id-渠道名称-产品id:{}", userInfo); +// return result; +// } +// +// if (openAll && result){ +// log.info("资质匹配筛选, 配置[满足所有]-匹配成功, 匹配通过, 结束匹配, 用户id-渠道id-渠道名称-产品id:{}", userInfo); +// return result; +// } +// +// log.info("资质匹配筛选, 此行日志我觉得不会输出, 用户id-渠道id-渠道名称-产品id:{}", userInfo); + return true; + } +} diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/web/controller/BaseController.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/web/controller/BaseController.java index 6eff642f..e0b4e54e 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/web/controller/BaseController.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/web/controller/BaseController.java @@ -129,6 +129,17 @@ public class BaseController return rows > 0 ? AjaxResult.success() : AjaxResult.error(); } + /** + * 响应返回结果 + * + * @param rows 影响行数 + * @return 操作结果 + */ + protected AjaxResult toAjax(Long rows) + { + return rows > 0 ? AjaxResult.success() : AjaxResult.error(); + } + /** * 响应返回结果 * diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/web/domain/BaseEntity.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/web/domain/BaseEntity.java index 1327c9bc..0e4778dd 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/web/domain/BaseEntity.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/web/domain/BaseEntity.java @@ -4,6 +4,8 @@ import java.io.Serializable; import java.util.Date; import java.util.HashMap; import java.util.Map; + +import com.baomidou.mybatisplus.annotation.TableField; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; @@ -19,9 +21,11 @@ public class BaseEntity implements Serializable /** 搜索值 */ @JsonIgnore + @TableField(exist = false) private String searchValue; /** 创建者 */ + @TableField(exist = false) private String createBy; /** 创建时间 */ @@ -29,6 +33,7 @@ public class BaseEntity implements Serializable private Date createTime; /** 更新者 */ + @TableField(exist = false) private String updateBy; /** 更新时间 */ @@ -40,6 +45,7 @@ public class BaseEntity implements Serializable /** 请求参数 */ @JsonInclude(JsonInclude.Include.NON_EMPTY) + @TableField(exist = false) private Map params; public String getSearchValue() diff --git a/ruoyi-common/ruoyi-common-redis/src/main/java/com/ruoyi/common/redis/service/CustomerTokenService.java b/ruoyi-common/ruoyi-common-redis/src/main/java/com/ruoyi/common/redis/service/CustomerTokenService.java new file mode 100644 index 00000000..aa50a84c --- /dev/null +++ b/ruoyi-common/ruoyi-common-redis/src/main/java/com/ruoyi/common/redis/service/CustomerTokenService.java @@ -0,0 +1,391 @@ +package com.ruoyi.common.redis.service; + +import cn.hutool.core.util.RandomUtil; +import cn.hutool.core.util.StrUtil; +import com.ruoyi.common.core.constant.RedisConstant; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; + +import javax.servlet.http.HttpServletRequest; +import java.util.Objects; +import java.util.concurrent.TimeUnit; + +/** + * Created with IntelliJ IDEA. + * + * @Author: + * @Date: 18点29分 + * @Description: 用户token管理 + */ + +@Slf4j +@Component +@RequiredArgsConstructor +public class CustomerTokenService { + + private final RedisService redisService; + /** + * token过期时间 + */ + private static final Long EXPIRE_TIME = 30 * 24 * 60 * 60L; + + /** + * 随机生成128位的token,包含数字、大小写字母 + * + * @param customerId 用户id + * @param phone 手机号 + * @param deviceType 设备类型 + * @param channelId 渠道id + * @return token + */ + public String generateToken(Long customerId, String phone, String deviceType, Long channelId) { + //获取到老的token + String oldToken = redisService.getCacheObject(RedisConstant.APP_CUSTOMER_KEY + customerId); + if (StringUtils.hasText(oldToken)) { + //删除老的token + this.refreshToken(oldToken); + } + String newToken = null; + boolean exit = true; + while (exit) { + newToken = RandomUtil.randomString(128); + if (!redisService.hasKey(RedisConstant.APP_CUSTOMER_USERNAME_KEY + newToken)) { + exit = false; + } + } + redisService.setCacheObject(RedisConstant.APP_CUSTOMER_USERNAME_KEY + newToken, phone, EXPIRE_TIME, TimeUnit.SECONDS); + redisService.setCacheObject(RedisConstant.APP_CUSTOMER_KEY + customerId, newToken, EXPIRE_TIME, TimeUnit.SECONDS); + redisService.setCacheObject(RedisConstant.APP_CUSTOMER_CHANNEL_KEY + newToken, channelId, EXPIRE_TIME, TimeUnit.SECONDS); + redisService.setCacheObject(RedisConstant.APP_CUSTOMER_TOKEN_KEY + newToken, customerId, EXPIRE_TIME, TimeUnit.SECONDS); + redisService.setCacheObject(RedisConstant.APP_DEVICE_IDENTIFICATION + newToken, deviceType.toString(), EXPIRE_TIME, TimeUnit.SECONDS); + return newToken; + } + + /** + * 判断token是否过期 + * + * @param token token + * @return true:过期,false:未过期 + */ + public boolean isExpire(String token) { + String customerId = redisService.getCacheObject(RedisConstant.APP_CUSTOMER_TOKEN_KEY + token) + StrUtil.EMPTY; + String originalToken = redisService.getCacheObject(RedisConstant.APP_CUSTOMER_KEY + customerId); + String username = redisService.getCacheObject(RedisConstant.APP_CUSTOMER_USERNAME_KEY + token) + StrUtil.EMPTY; + return StringUtils.isEmpty(customerId) || StringUtils.isEmpty(originalToken) || !originalToken.equals(token) || !StringUtils.hasText(username); + } + + /** + * 刷新token有效期 + * + * @param token token + * @param booleans 是否需要退出登录 + */ + public void refreshToken(String token, Boolean... booleans) { + boolean logOut = isLogOut(booleans); + Long customerId = redisService.getCacheObject(RedisConstant.APP_CUSTOMER_TOKEN_KEY + token); + if (Objects.isNull(customerId) && logOut) { + new Exception("登录已过期,请重新登录"); + } + redisService.expire(RedisConstant.APP_CUSTOMER_USERNAME_KEY + token, EXPIRE_TIME, TimeUnit.SECONDS); + redisService.expire(RedisConstant.APP_CUSTOMER_KEY + customerId, EXPIRE_TIME, TimeUnit.SECONDS); + redisService.expire(RedisConstant.APP_CUSTOMER_CHANNEL_KEY + token, EXPIRE_TIME, TimeUnit.SECONDS); + redisService.expire(RedisConstant.APP_CUSTOMER_TOKEN_KEY + token, EXPIRE_TIME, TimeUnit.SECONDS); + redisService.expire(RedisConstant.APP_DEVICE_IDENTIFICATION + token, EXPIRE_TIME, TimeUnit.SECONDS); + } + + /** + * 根据用户id刷新token有效期 + * + * @param customerId 用户id + * @param booleans 是否需要退出登录 + * @return token + */ + public String refreshToken(Long customerId, Boolean... booleans) { + boolean logOut = isLogOut(booleans); + String token = redisService.getCacheObject(RedisConstant.APP_CUSTOMER_KEY + customerId); + if (StringUtils.isEmpty(token) && logOut) { + new Exception("登录已过期,请重新登录"); + } + this.refreshToken(token); + return token; + } + + /** + * 刷新token有效期 + * + * @param request 请求 + */ + public void refreshToken(HttpServletRequest request) { + String token = getToken(request); + this.refreshToken(token); + } + + /** + * 移除token + * + * @param token token + * @param booleans 是否需要退出登录 + */ + public void removeToken(String token, Boolean... booleans) { + boolean logOut = isLogOut(booleans); + Long customerId = redisService.getCacheObject(RedisConstant.APP_CUSTOMER_TOKEN_KEY + token); + if (Objects.isNull(customerId) && logOut) { + new Exception("登录已过期,请重新登录"); + } + redisService.deleteObject(RedisConstant.APP_CUSTOMER_KEY + customerId); + redisService.deleteObject(RedisConstant.APP_CUSTOMER_TOKEN_KEY + token); + redisService.deleteObject(RedisConstant.APP_CUSTOMER_USERNAME_KEY + token); + redisService.deleteObject(RedisConstant.APP_CUSTOMER_CHANNEL_KEY + token); + redisService.deleteObject(RedisConstant.APP_DEVICE_IDENTIFICATION + token); + } + + /** + * 根据用户id移除token + * + * @param customerId 用户id + */ + public void removeToken(Long customerId) { + String token = redisService.getCacheObject(RedisConstant.APP_CUSTOMER_KEY + customerId); + this.removeToken(token); + } + + /** + * 根据HttpServletRequest获取token + * + * @param request HttpServletRequest + * @param booleans 是否需要退出登录 + * @return token + */ + public String getToken(HttpServletRequest request, Boolean... booleans) { + boolean logOut = isLogOut(booleans); + String token = request.getHeader("Authorization"); + if (StringUtils.isEmpty(token) && logOut) { + String requestURI = request.getRequestURI(); + log.info("登录过期重新登录, requestURI:{}, logOut:{}, token:{}", requestURI, logOut, token); + new Exception("登录已过期,请重新登录"); + } + return token; + } + + /** + * 根据用户id获取到token + * + * @param customerId 用户id + * @return token + */ + public String getToken(Long customerId) { + String token = redisService.getCacheObject(RedisConstant.APP_CUSTOMER_KEY + customerId); + if (StringUtils.isEmpty(token)) { + return null; + } + return token; + } + + /** + * 通过token获取到用户的ID + * + * @param token token + * @param logOut 是否需要退出登录 + * @return 用户ID + */ + public Long getCustomerId(String token, Boolean logOut) { + Long customerId = redisService.getCacheObject(RedisConstant.APP_CUSTOMER_TOKEN_KEY + token); + if (Objects.isNull(customerId) && logOut) { + new Exception("登录已过期,请重新登录"); + } + return customerId; + } + + /** + * 根据HttpServletRequest获取到用户的ID + * + * @param request HttpServletRequest + * @param booleans 是否需要退出登录 + * @return 用户ID + */ + public Long getCustomerId(HttpServletRequest request, Boolean... booleans) { + boolean logOut = isLogOut(booleans); + String token = getToken(request, logOut); + if (StringUtils.isEmpty(token)) { + return null; + } + return getCustomerId(token, logOut); + } + + + /** + * 根据token获取到用户的手机号 未解密 + * + * @param token token + * @param booleans 是否需要退出登录 + * @return 手机号 + */ + public String getPhone(String token, Boolean... booleans) { + boolean logOut = isLogOut(booleans); + String phone = redisService.getCacheObject(RedisConstant.APP_CUSTOMER_USERNAME_KEY + token); + if (Objects.isNull(phone) && logOut) { + new Exception("登录已过期,请重新登录"); + } + return phone; + } + + /** + * 根据用户ID获取手机号码 + * + * @param customerId 用户ID + * @param booleans 是否需要退出登录 + * @return 手机号 + */ + public String getPhone(Long customerId, Boolean... booleans) { + String token = redisService.getCacheObject(RedisConstant.APP_CUSTOMER_KEY + customerId); + if (Objects.isNull(token) && isLogOut(booleans)) { + new Exception("登录已过期,请重新登录"); + } + String phone = getPhone(token); +// try { +// phone = EncryptUtil.AESdecode(phone, redisService.getAppEncrypted()); +// }catch (Exception e) { +// return phone; +// } + + return phone; + } + + /** + * 根据HttpServletRequest获取到用户的手机号 + * + * @param request HttpServletRequest + * @return 手机号 + */ + public String getPhone(HttpServletRequest request) { + String token = getToken(request); + return getPhone(token); + } + + /** + * 根据token获取到用户的渠道ID + * + * @param token token + * @param booleans 是否需要退出登录 + * @return 渠道ID + */ + public Long getChannelId(String token, Boolean... booleans) { + Long channelId = redisService.getCacheObject(RedisConstant.APP_CUSTOMER_CHANNEL_KEY + token); + if (Objects.isNull(channelId) && isLogOut(booleans)) { + new Exception("登录已过期,请重新登录"); + } + return channelId; + } + + /** + * 根据HttpServletRequest获取到用户的渠道ID + * + * @param request HttpServletRequest + * @return 渠道ID + */ + public Long getChannelId(HttpServletRequest request, Boolean... booleans) { + String token = getToken(request,booleans); + return getChannelId(token,booleans); + } + + /** + * 根据用户ID获取渠道ID + * + * @param customerId 用户ID + * @param booleans 是否需要退出登录 + * @return 渠道ID + */ + public Long getChannelId(Long customerId, Boolean... booleans) { + String token = redisService.getCacheObject(RedisConstant.APP_CUSTOMER_KEY + customerId); + if (Objects.isNull(token) && isLogOut(booleans)) { + new Exception("登录已过期,请重新登录"); + } + Long channelId = redisService.getCacheObject(RedisConstant.APP_CUSTOMER_CHANNEL_KEY + token); + if (Objects.isNull(channelId) && isLogOut(booleans)) { + new Exception("登录已过期,请重新登录"); + } + return channelId; + } + + /** + * 更新渠道 + * @param customerId 用户ID + * @param channelId 渠道ID + */ + public void setChannelId(Long customerId,Long channelId) { + String token = getToken(customerId); + redisService.setCacheObject(RedisConstant.APP_CUSTOMER_CHANNEL_KEY + token, channelId, EXPIRE_TIME, TimeUnit.SECONDS); + } + + /** + * 根据token获取设备类型 + * + * @param token token + * @param booleans 是否需要退出登录 + * @return 设备类型 + */ + public String getDeviceType(String token, Boolean... booleans) { + String deviceType = redisService.getCacheObject(RedisConstant.APP_DEVICE_IDENTIFICATION + token); + if (Objects.isNull(deviceType) && isLogOut(booleans)) { + new Exception("登录已过期,请重新登录"); + } + return deviceType; + } + + /** + * 根据HttpServletRequest获取设备类型 + * + * @param request HttpServletRequest + * @return 设备类型 + */ + public String getDeviceType(HttpServletRequest request,Boolean... booleans) { + String token = getToken(request,booleans); + return getDeviceType(token,booleans); + } + + /** + * 根据HttpServletRequest获取设备类型 + * + * @param request HttpServletRequest + * @return 设备类型 + */ + public String getDeviceTypeStr(HttpServletRequest request) { + String token = getToken(request); + return getDeviceType(token); + } + + /** + * 根据用户ID获取设备类型 + * + * @param customerId 用户ID + * @param booleans 是否需要退出登录 + * @return 设备类型 + */ + public String getDeviceType(Long customerId, Boolean... booleans) { + String token = redisService.getCacheObject(RedisConstant.APP_CUSTOMER_KEY + customerId); + if (Objects.isNull(token) && isLogOut(booleans)) { + new Exception("登录已过期,请重新登录"); + } + String deviceType = redisService.getCacheObject(RedisConstant.APP_DEVICE_IDENTIFICATION + token); + if (!StringUtils.hasText(deviceType)) { + deviceType = "ANDROID"; + } + return deviceType; + } + + /** + * 是否需要退出登录 + * + * @param booleans 参数值 + * @return 是否需要退出登录 + */ + public Boolean isLogOut(Boolean... booleans) { + if (booleans == null || booleans.length == 0) { + return true; + } + return booleans[0]; + } + +} diff --git a/ruoyi-common/ruoyi-common-redis/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/ruoyi-common/ruoyi-common-redis/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports index 1ef6ccaf..a7693a07 100644 --- a/ruoyi-common/ruoyi-common-redis/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ b/ruoyi-common/ruoyi-common-redis/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -1,2 +1,3 @@ com.ruoyi.common.redis.configure.RedisConfig com.ruoyi.common.redis.service.RedisService +com.ruoyi.common.redis.service.CustomerTokenService diff --git a/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/service/TokenService.java b/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/service/TokenService.java index 29717928..2d8e32c6 100644 --- a/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/service/TokenService.java +++ b/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/service/TokenService.java @@ -4,6 +4,8 @@ import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit; import javax.servlet.http.HttpServletRequest; + +import com.ruoyi.common.core.constant.RedisConstant; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -42,6 +44,11 @@ public class TokenService private final static Long MILLIS_MINUTE_TEN = CacheConstants.REFRESH_TIME * MILLIS_MINUTE; + /** + * token过期时间 + */ + private static final Long EXPIRE_TIME = 30 * 24 * 60 * 60L; + /** * 创建令牌 */ @@ -69,6 +76,40 @@ public class TokenService return rspMap; } + /** + * 创建令牌 + */ + public String createTokenApp(Long customerId,Long channelId) + { + String token = IdUtils.fastUUID(); +// Long userId = loginUser.getSysUser().getUserId(); +// String userName = loginUser.getSysUser().getUserName(); +// loginUser.setToken(token); +// loginUser.setUserid(userId); +// loginUser.setUsername(userName); +// loginUser.setIpaddr(IpUtils.getIpAddr()); +// refreshToken(loginUser); + + // Jwt存储信息 + Map claimsMap = new HashMap(); + claimsMap.put(SecurityConstants.USER_KEY, token); + claimsMap.put(SecurityConstants.DETAILS_USER_ID, customerId); + claimsMap.put(SecurityConstants.DETAILS_USERNAME, "userName"); + + // 接口返回信息 + Map rspMap = new HashMap(); + String token1 = JwtUtils.createToken(claimsMap); + rspMap.put("access_token", token1); + rspMap.put("expires_in", expireTime); + + redisService.setCacheObject(RedisConstant.APP_CUSTOMER_USERNAME_KEY + token1, customerId, EXPIRE_TIME, TimeUnit.SECONDS); + redisService.setCacheObject(RedisConstant.APP_CUSTOMER_KEY + customerId, token1, EXPIRE_TIME, TimeUnit.SECONDS); + redisService.setCacheObject(RedisConstant.APP_CUSTOMER_CHANNEL_KEY + token1, channelId, EXPIRE_TIME, TimeUnit.SECONDS); + redisService.setCacheObject(RedisConstant.APP_CUSTOMER_TOKEN_KEY + token1, customerId, EXPIRE_TIME, TimeUnit.SECONDS); + redisService.setCacheObject( CacheConstants.LOGIN_TOKEN_KEY+token,customerId,EXPIRE_TIME,TimeUnit.SECONDS); + return token1; + } + /** * 获取用户身份信息 * diff --git a/ruoyi-common/ruoyi-common-sms/pom.xml b/ruoyi-common/ruoyi-common-sms/pom.xml new file mode 100644 index 00000000..eb3915b2 --- /dev/null +++ b/ruoyi-common/ruoyi-common-sms/pom.xml @@ -0,0 +1,59 @@ + + + + com.ruoyi + ruoyi-common + 3.6.4 + + 4.0.0 + + ruoyi-common-sms + + + ruoyi-common-sms 短信模块 + + + + + + org.springframework.boot + spring-boot-starter-web + + + + org.projectlombok + lombok + + + + org.junit.jupiter + junit-jupiter-api + 5.7.0 + test + + + org.junit.jupiter + junit-jupiter-engine + 5.7.0 + test + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + + + + + \ No newline at end of file diff --git a/ruoyi-common/ruoyi-common-sms/src/main/java/com/ruoyi/common/sms/XunDaYunXinAutoConfiguration.java b/ruoyi-common/ruoyi-common-sms/src/main/java/com/ruoyi/common/sms/XunDaYunXinAutoConfiguration.java new file mode 100644 index 00000000..14ada60c --- /dev/null +++ b/ruoyi-common/ruoyi-common-sms/src/main/java/com/ruoyi/common/sms/XunDaYunXinAutoConfiguration.java @@ -0,0 +1,24 @@ +package com.ruoyi.common.sms; + +import com.ruoyi.common.sms.component.SmsComponent; +import com.ruoyi.common.sms.properties.XunDaYunXinProperties; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.client.RestTemplate; + +@Configuration +@EnableConfigurationProperties(XunDaYunXinProperties.class) +public class XunDaYunXinAutoConfiguration { + + @Bean + public SmsComponent smsComponent() { + return new SmsComponent(); + } + + @Bean + public RestTemplate restTemplate() { + return new RestTemplate(); + } +} diff --git a/ruoyi-common/ruoyi-common-sms/src/main/java/com/ruoyi/common/sms/component/SmsComponent.java b/ruoyi-common/ruoyi-common-sms/src/main/java/com/ruoyi/common/sms/component/SmsComponent.java new file mode 100644 index 00000000..43e83526 --- /dev/null +++ b/ruoyi-common/ruoyi-common-sms/src/main/java/com/ruoyi/common/sms/component/SmsComponent.java @@ -0,0 +1,145 @@ +package com.ruoyi.common.sms.component; + +import com.ruoyi.common.sms.entity.response.SmsEntity; +import com.ruoyi.common.sms.entity.response.SmsResponse; +import com.ruoyi.common.sms.properties.XunDaYunXinProperties; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.web.client.RestTemplate; + +import java.util.*; + +@Slf4j +public class SmsComponent { + @Autowired + private XunDaYunXinProperties properties; + + @Autowired + private RestTemplate restTemplate; + + /** + * 点对点 + * + * @param mobileContentKvp 号码内容键值对 示例 {"15100000000":"【测试】test1","15100000001":"【测试】test2"} + * @return SmsResponse + */ + public SmsResponse sendP2PMsg(Map mobileContentKvp) { + Map extraParams = new HashMap<>(); + + for (Map.Entry entry : mobileContentKvp.entrySet()) { + String oldValue = entry.getValue(); + String newValue = replaceCode(properties.getTemplate(), oldValue); + entry.setValue(newValue); + } + extraParams.put("mobileContentKvp", mobileContentKvp); + return sendSmsRequest("p2p", extraParams, new ParameterizedTypeReference() { + }); + } + + + /** + * 发送群发信息 + * + * @param mobile 电话号码按照,分割 示例 "15100000000,15100000001" + * @param content 内容 一般为验证码 + * @return SmsResponse + */ + public SmsResponse sendGroupMsg(String mobile, String content) { + Map extraParams = new HashMap<>(); + extraParams.put("mobile", removeDuplicates(mobile)); + extraParams.put("content", replaceCode(properties.getTemplate(), content)); + return sendSmsRequest("send", extraParams, new ParameterizedTypeReference>() { + }); + } + + + public SmsResponse checkBalance() { + String url = properties.getBaseUrl() + "/smsv2"; + Map params = new HashMap<>(); + params.put("action", "balance"); + params.put("account", properties.getAccount()); + params.put("password", properties.getPassword()); + HttpEntity> requestEntity = new HttpEntity<>(params); + ResponseEntity> responseEntity = restTemplate.exchange( + url, + HttpMethod.POST, + requestEntity, + new ParameterizedTypeReference>() { + } + ); + return responseEntity.getBody(); + } + + /** + * 发送短信请求的通用方法,适用于不同的短信操作。 + * + * @param action 短信操作的类型,例如 "p2p"、"send" "balance"。 + * @param extraParams 附加的请求参数,具体取决于短信操作的需求。可以为 null。 + * @param responseType 返回值的泛型类型,用于指定响应的具体类型。 + * @param 响应体中泛型的类型参数。 + * @return 包含响应结果的 SmsResponse 对象,响应体中可能包含不同类型的数据。 + */ + private T sendSmsRequest(String action, Map extraParams, ParameterizedTypeReference responseType) { + // 拼接请求的 URL 地址 + String url = properties.getBaseUrl() + "/smsv2"; + + // 创建请求参数 Map,并填充必需的账户信息和操作类型 + Map params = new HashMap<>(); + params.put("action", action); // 设置请求的操作类型,如发送短信或查询余额 + params.put("account", properties.getAccount()); // 设置账户名 + params.put("password", properties.getPassword()); // 设置密码 + params.put("extno", properties.getExtno()); // 虚拟接入码 + + // 如果有额外的参数,则将它们添加到请求参数中 + if (extraParams != null) { + params.putAll(extraParams); + } + // 构建 HttpEntity 实体,包含请求参数 + HttpEntity> requestEntity = new HttpEntity<>(params); + + // 使用 RestTemplate 的 exchange 方法发送 POST 请求,并指定返回的泛型类型 + ResponseEntity responseEntity = restTemplate.exchange( + url, // 请求 URL + HttpMethod.POST, // HTTP 方法类型为 POST + requestEntity, // 请求体包含请求参数 + responseType // 指定返回类型的泛型引用,用于保留泛型信息 + ); + + // 返回响应体(根据调用方法传入的类型) + return responseEntity.getBody(); + } + + + /** + * 相同号码去重 + * + * @param input 字符串电话号码 逗号分隔符分割 + * @return String 去重之后的手机电话号码 + */ + private String removeDuplicates(String input) { + // 使用 LinkedHashSet 保持插入顺序并去重 + Set uniqueSet = new LinkedHashSet<>(Arrays.asList(input.split(","))); + if (uniqueSet.size() >= 1000) { + throw new IllegalArgumentException("群发不建议超过1000个电话号码"); + } + // 将去重后的集合转换回字符串 + return String.join(",", uniqueSet); + } + + /** + * 模板替换占位符 + * + * @param template 模板 + * @param code 实际值 + * @return 替换之后的模板 + */ + public String replaceCode(String template, String code) { + return template.replace("{code}", code); + } + + +} diff --git a/ruoyi-common/ruoyi-common-sms/src/main/java/com/ruoyi/common/sms/entity/package-info.java b/ruoyi-common/ruoyi-common-sms/src/main/java/com/ruoyi/common/sms/entity/package-info.java new file mode 100644 index 00000000..b9279f72 --- /dev/null +++ b/ruoyi-common/ruoyi-common-sms/src/main/java/com/ruoyi/common/sms/entity/package-info.java @@ -0,0 +1 @@ +package com.ruoyi.common.sms.entity; \ No newline at end of file diff --git a/ruoyi-common/ruoyi-common-sms/src/main/java/com/ruoyi/common/sms/entity/request/package-info.java b/ruoyi-common/ruoyi-common-sms/src/main/java/com/ruoyi/common/sms/entity/request/package-info.java new file mode 100644 index 00000000..e5e92bf2 --- /dev/null +++ b/ruoyi-common/ruoyi-common-sms/src/main/java/com/ruoyi/common/sms/entity/request/package-info.java @@ -0,0 +1 @@ +package com.ruoyi.common.sms.entity.request; \ No newline at end of file diff --git a/ruoyi-common/ruoyi-common-sms/src/main/java/com/ruoyi/common/sms/entity/response/SmsEntity.java b/ruoyi-common/ruoyi-common-sms/src/main/java/com/ruoyi/common/sms/entity/response/SmsEntity.java new file mode 100644 index 00000000..d6ea9a76 --- /dev/null +++ b/ruoyi-common/ruoyi-common-sms/src/main/java/com/ruoyi/common/sms/entity/response/SmsEntity.java @@ -0,0 +1,32 @@ +package com.ruoyi.common.sms.entity.response; + +public class SmsEntity { + private String mid; + private String mobile; + private int result; + + // Getters and Setters + public String getMid() { + return mid; + } + + public void setMid(String mid) { + this.mid = mid; + } + + public String getMobile() { + return mobile; + } + + public void setMobile(String mobile) { + this.mobile = mobile; + } + + public int getResult() { + return result; + } + + public void setResult(int result) { + this.result = result; + } +} diff --git a/ruoyi-common/ruoyi-common-sms/src/main/java/com/ruoyi/common/sms/entity/response/SmsResponse.java b/ruoyi-common/ruoyi-common-sms/src/main/java/com/ruoyi/common/sms/entity/response/SmsResponse.java new file mode 100644 index 00000000..81927c34 --- /dev/null +++ b/ruoyi-common/ruoyi-common-sms/src/main/java/com/ruoyi/common/sms/entity/response/SmsResponse.java @@ -0,0 +1,12 @@ +package com.ruoyi.common.sms.entity.response; + +import lombok.Data; + +import java.util.List; + +@Data +public class SmsResponse { + private Integer status; + private Integer balance; + private List list; +} diff --git a/ruoyi-common/ruoyi-common-sms/src/main/java/com/ruoyi/common/sms/properties/XunDaYunXinProperties.java b/ruoyi-common/ruoyi-common-sms/src/main/java/com/ruoyi/common/sms/properties/XunDaYunXinProperties.java new file mode 100644 index 00000000..d277f006 --- /dev/null +++ b/ruoyi-common/ruoyi-common-sms/src/main/java/com/ruoyi/common/sms/properties/XunDaYunXinProperties.java @@ -0,0 +1,40 @@ +package com.ruoyi.common.sms.properties; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * 迅达云信短信 配置类 + */ +@Data +@ConfigurationProperties(prefix = "xundayunxin") +public class XunDaYunXinProperties { + /** + * 请求地址 + */ + private String baseUrl = "http://47.96.236.136:7862/"; + /** + * 账号 + */ + private String account = "932425"; + /** + * 密码 + */ + private String password = "alDE77Gmo"; + + /** + * 虚拟接入码 + */ + private String extno = "10690367"; + + /** + * 是否启用手机号加密 + */ + private boolean encryptionEnabled; + + /** + * 短信模板 + */ + private String template = "【信用秒租】验证码为:{code},您正在登录信用秒租,请在3分钟内完成验证,如非本人操作,请忽略本短信。"; + +} diff --git a/ruoyi-common/ruoyi-common-sms/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/ruoyi-common/ruoyi-common-sms/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000..7d5434ba --- /dev/null +++ b/ruoyi-common/ruoyi-common-sms/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1,2 @@ +com.ruoyi.common.sms.XunDaYunXinAutoConfiguration +com.ruoyi.common.sms.component.SmsComponent \ No newline at end of file diff --git a/ruoyi-gateway/src/main/java/com/ruoyi/gateway/RuoYiGatewayApplication.java b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/RuoYiGatewayApplication.java index c6f7db68..e0ea309b 100644 --- a/ruoyi-gateway/src/main/java/com/ruoyi/gateway/RuoYiGatewayApplication.java +++ b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/RuoYiGatewayApplication.java @@ -15,15 +15,6 @@ public class RuoYiGatewayApplication public static void main(String[] args) { SpringApplication.run(RuoYiGatewayApplication.class, args); - System.out.println("(♥◠‿◠)ノ゙ 若依网关启动成功 ლ(´ڡ`ლ)゙ \n" + - " .-------. ____ __ \n" + - " | _ _ \\ \\ \\ / / \n" + - " | ( ' ) | \\ _. / ' \n" + - " |(_ o _) / _( )_ .' \n" + - " | (_,_).' __ ___(_ o _)' \n" + - " | |\\ \\ | || |(_,_)' \n" + - " | | \\ `' /| `-' / \n" + - " | | \\ / \\ / \n" + - " ''-' `'-' `-..-' "); + System.out.println("(♥◠‿◠)ノ゙ 租研舍网关启动成功 ლ(´ڡ`ლ)゙ \n"); } } diff --git a/ruoyi-gateway/src/main/resources/bootstrap.yml b/ruoyi-gateway/src/main/resources/bootstrap.yml index b6dc98ae..d08317f9 100644 --- a/ruoyi-gateway/src/main/resources/bootstrap.yml +++ b/ruoyi-gateway/src/main/resources/bootstrap.yml @@ -14,10 +14,12 @@ spring: nacos: discovery: # 服务注册地址 - server-addr: 127.0.0.1:8848 + server-addr: 47.109.135.151:8848 + namespace: b8ad3fd2-18ea-4cdf-a82c-4ce483392b1a config: # 配置中心地址 - server-addr: 127.0.0.1:8848 + server-addr: 47.109.135.151:8848 + namespace: b8ad3fd2-18ea-4cdf-a82c-4ce483392b1a # 配置文件格式 file-extension: yml # 共享配置 @@ -28,12 +30,12 @@ spring: eager: true transport: # 控制台地址 - dashboard: 127.0.0.1:8718 + dashboard: 47.109.135.151:8718 # nacos配置持久化 datasource: ds1: nacos: - server-addr: 127.0.0.1:8848 + server-addr: 47.109.135.151:8848 dataId: sentinel-ruoyi-gateway groupId: DEFAULT_GROUP data-type: json diff --git a/ruoyi-modules/pom.xml b/ruoyi-modules/pom.xml index 22c84bdd..6a6c18a1 100644 --- a/ruoyi-modules/pom.xml +++ b/ruoyi-modules/pom.xml @@ -13,6 +13,7 @@ ruoyi-gen ruoyi-job ruoyi-file + ruoyi-btc ruoyi-modules diff --git a/ruoyi-modules/ruoyi-btc/pom.xml b/ruoyi-modules/ruoyi-btc/pom.xml new file mode 100644 index 00000000..44c4b088 --- /dev/null +++ b/ruoyi-modules/ruoyi-btc/pom.xml @@ -0,0 +1,88 @@ + + + + com.ruoyi + ruoyi-modules + 3.6.4 + + 4.0.0 + + ruoyi-modules-btc + + + ruoyi-modules-btc三方业务服务 + + + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-sentinel + + + + + org.springframework.boot + spring-boot-starter-actuator + + + + + org.springframework.boot + spring-boot-starter-web + + + + + + com.ruoyi + ruoyi-api-system + + + org.projectlombok + lombok + + + com.ruoyi + ruoyi-common-redis + + + com.ruoyi + ruoyi-common-security + + + + + + ${project.artifactId} + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + + + \ No newline at end of file diff --git a/ruoyi-modules/ruoyi-btc/src/main/java/com/ruoyi/btc/RuoYiBtcApplication.java b/ruoyi-modules/ruoyi-btc/src/main/java/com/ruoyi/btc/RuoYiBtcApplication.java new file mode 100644 index 00000000..338bdd45 --- /dev/null +++ b/ruoyi-modules/ruoyi-btc/src/main/java/com/ruoyi/btc/RuoYiBtcApplication.java @@ -0,0 +1,22 @@ +package com.ruoyi.btc; + +import com.ruoyi.common.security.annotation.EnableRyFeignClients; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; + +/** + * 三方调用服务 + * + * @author ruoyi + */ +@EnableRyFeignClients +@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class }) +public class RuoYiBtcApplication +{ + public static void main(String[] args) + { + SpringApplication.run(RuoYiBtcApplication.class, args); + System.out.println("(♥◠‿◠)ノ゙ 三方业务服务模块启动成功 ლ(´ڡ`ლ)゙ \n"); + } +} diff --git a/ruoyi-modules/ruoyi-btc/src/main/java/com/ruoyi/btc/config/Config.java b/ruoyi-modules/ruoyi-btc/src/main/java/com/ruoyi/btc/config/Config.java new file mode 100644 index 00000000..34fcdca3 --- /dev/null +++ b/ruoyi-modules/ruoyi-btc/src/main/java/com/ruoyi/btc/config/Config.java @@ -0,0 +1,16 @@ +package com.ruoyi.btc.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ConfigurationProperties(prefix = "system") +@Data +public class Config { + + /** + * 加密密钥 + */ + private String AESkey; +} diff --git a/ruoyi-modules/ruoyi-btc/src/main/java/com/ruoyi/btc/controller/PublicAllController.java b/ruoyi-modules/ruoyi-btc/src/main/java/com/ruoyi/btc/controller/PublicAllController.java new file mode 100644 index 00000000..2851d210 --- /dev/null +++ b/ruoyi-modules/ruoyi-btc/src/main/java/com/ruoyi/btc/controller/PublicAllController.java @@ -0,0 +1,43 @@ +package com.ruoyi.btc.controller; + +import com.ruoyi.btc.domain.ComPublicHalfDto; +import com.ruoyi.btc.service.ISysPublicAllService; +import com.ruoyi.btc.service.ISysPublicHalfService; +import com.ruoyi.common.core.web.domain.AjaxResult; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.*; + +/** + * 半流程API接口写这里 + * + * @author z + */ +@RestController +@Slf4j +@RequestMapping("/all/api") +@RequiredArgsConstructor +public class PublicAllController { + private final ISysPublicAllService sysPublicAllService; + + /** + * 通用半流程撞库 + */ + @PostMapping("check") + public AjaxResult upload(@RequestBody ComPublicHalfDto comPublicHalfDto) + { + sysPublicAllService.check(comPublicHalfDto); + return null; + } + + /** + * 通用半流程撞库 + */ + @PostMapping("input") + public AjaxResult input(@RequestBody ComPublicHalfDto comPublicHalfDto) + { + sysPublicAllService.input(comPublicHalfDto); + return null; + } + +} \ No newline at end of file diff --git a/ruoyi-modules/ruoyi-btc/src/main/java/com/ruoyi/btc/controller/PublicHalfController.java b/ruoyi-modules/ruoyi-btc/src/main/java/com/ruoyi/btc/controller/PublicHalfController.java new file mode 100644 index 00000000..31edb903 --- /dev/null +++ b/ruoyi-modules/ruoyi-btc/src/main/java/com/ruoyi/btc/controller/PublicHalfController.java @@ -0,0 +1,50 @@ +package com.ruoyi.btc.controller; + +import com.ruoyi.btc.domain.ComPublicHalfDto; +import com.ruoyi.btc.service.ISysPublicHalfService; +import com.ruoyi.common.core.web.domain.AjaxResult; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.*; + +/** + * 半流程API接口写这里 + * + * @author z + */ +@RestController +@Slf4j +@RequestMapping("/half/api") +@RequiredArgsConstructor +public class PublicHalfController{ + private final ISysPublicHalfService sysPublicHalfService; + + /** + * 通用半流程撞库 + */ + @PostMapping("/check") + public AjaxResult upload(@RequestBody ComPublicHalfDto comPublicHalfDto) + { + return sysPublicHalfService.check(comPublicHalfDto); + } + + /** + * 通用半流程撞库 + */ + @PostMapping("/input") + public AjaxResult input(@RequestBody ComPublicHalfDto comPublicHalfDto) + { + return sysPublicHalfService.input(comPublicHalfDto); + } + + + /** + * 通用半流程撞库 + */ + @GetMapping("/checkOrder") + public AjaxResult checkOrder(String phoneMd5,String channelSign) + { + + return sysPublicHalfService.checkOrder(phoneMd5,channelSign); + } +} \ No newline at end of file diff --git a/ruoyi-modules/ruoyi-btc/src/main/java/com/ruoyi/btc/domain/ComPublicHalfDto.java b/ruoyi-modules/ruoyi-btc/src/main/java/com/ruoyi/btc/domain/ComPublicHalfDto.java new file mode 100644 index 00000000..8c0a92d8 --- /dev/null +++ b/ruoyi-modules/ruoyi-btc/src/main/java/com/ruoyi/btc/domain/ComPublicHalfDto.java @@ -0,0 +1,13 @@ +package com.ruoyi.btc.domain; + +import lombok.Data; + +@Data +public class ComPublicHalfDto { + + //参数实体类 + private String data; + //渠道标识 + private String channelSignature; + +} diff --git a/ruoyi-modules/ruoyi-btc/src/main/java/com/ruoyi/btc/domain/CustomerInfoDto.java b/ruoyi-modules/ruoyi-btc/src/main/java/com/ruoyi/btc/domain/CustomerInfoDto.java new file mode 100644 index 00000000..77eeac28 --- /dev/null +++ b/ruoyi-modules/ruoyi-btc/src/main/java/com/ruoyi/btc/domain/CustomerInfoDto.java @@ -0,0 +1,51 @@ +package com.ruoyi.btc.domain; + +import lombok.Data; + +@Data +public class CustomerInfoDto { + //手机号码(Md5) + private String phoneMd5; + //手机号 + private String phone; + //性别 0 男 1 女 + private Integer sex; + //手机号码(Md5) + private String nameMd5; + //姓名 + private String name; + //年龄 + private Integer age; + //手身份证md5 + private String idCardMd5; + //身份证好 + private String idCard; + //所在城市 + private String city; + //所在城市代码 + private Integer cityCode; + //本地社保 + private Integer socialSecurity; + //本地公积金 + private Integer accumulationFund; + //名下车产 + private Integer car; + //名下房产 + private Integer hourse; + //个人保险 + private Integer guarantee; + //芝麻分 + private Integer zhiMa; + //职业身份 + private Integer career; + //信用卡(1无 2有 + private Integer creditCard; + //学历 + private Integer education; + //月收入 + private Integer monthlyIncome; + //ip地址 + private String ip; + //渠道标识 + private String channelSignature; +} diff --git a/ruoyi-modules/ruoyi-btc/src/main/java/com/ruoyi/btc/service/ISysPublicAllService.java b/ruoyi-modules/ruoyi-btc/src/main/java/com/ruoyi/btc/service/ISysPublicAllService.java new file mode 100644 index 00000000..d9535498 --- /dev/null +++ b/ruoyi-modules/ruoyi-btc/src/main/java/com/ruoyi/btc/service/ISysPublicAllService.java @@ -0,0 +1,27 @@ +package com.ruoyi.btc.service; + +import com.ruoyi.btc.domain.ComPublicHalfDto; +import com.ruoyi.common.core.web.domain.AjaxResult; + +/** + * 文件上传接口 + * + * @author ruoyi + */ +public interface ISysPublicAllService +{ + + /** + * 半流程通用撞库接口 + * @param comPublicHalfDto + */ + AjaxResult check(ComPublicHalfDto comPublicHalfDto); + + /** + * 半流程通用进件 + * @param comPublicHalfDto + */ + AjaxResult input(ComPublicHalfDto comPublicHalfDto); + + +} diff --git a/ruoyi-modules/ruoyi-btc/src/main/java/com/ruoyi/btc/service/ISysPublicHalfService.java b/ruoyi-modules/ruoyi-btc/src/main/java/com/ruoyi/btc/service/ISysPublicHalfService.java new file mode 100644 index 00000000..7cff70fa --- /dev/null +++ b/ruoyi-modules/ruoyi-btc/src/main/java/com/ruoyi/btc/service/ISysPublicHalfService.java @@ -0,0 +1,33 @@ +package com.ruoyi.btc.service; + +import com.ruoyi.btc.domain.ComPublicHalfDto; +import com.ruoyi.common.core.web.domain.AjaxResult; +import org.springframework.web.bind.annotation.RequestParam; + +/** + * 文件上传接口 + * + * @author ruoyi + */ +public interface ISysPublicHalfService +{ + + /** + * 半流程通用撞库接口 + * @param comPublicHalfDto + */ + AjaxResult check(ComPublicHalfDto comPublicHalfDto); + + /** + * 半流程通用进件 + * @param comPublicHalfDto + */ + AjaxResult input(ComPublicHalfDto comPublicHalfDto); + + /** + * 渠道查询订单是否成功 + * @param + */ + AjaxResult checkOrder(String phoneMd5, String channelSign); + +} diff --git a/ruoyi-modules/ruoyi-btc/src/main/java/com/ruoyi/btc/service/impl/SysPublicAllServiceImpl.java b/ruoyi-modules/ruoyi-btc/src/main/java/com/ruoyi/btc/service/impl/SysPublicAllServiceImpl.java new file mode 100644 index 00000000..c0fff93f --- /dev/null +++ b/ruoyi-modules/ruoyi-btc/src/main/java/com/ruoyi/btc/service/impl/SysPublicAllServiceImpl.java @@ -0,0 +1,251 @@ +package com.ruoyi.btc.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollectionUtil; +import com.alibaba.fastjson.JSONObject; +import com.ruoyi.btc.domain.ComPublicHalfDto; +import com.ruoyi.btc.domain.CustomerInfoDto; +import com.ruoyi.btc.service.ISysPublicAllService; +import com.ruoyi.common.core.constant.CacheConstants; +import com.ruoyi.common.core.constant.SecurityConstants; +import com.ruoyi.common.core.domain.GetSumDto; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.core.domain.http.Channel; +import com.ruoyi.common.core.domain.http.Customer; +import com.ruoyi.common.core.domain.http.CustomerApplyLog; +import com.ruoyi.common.core.domain.http.Merchant; +import com.ruoyi.common.core.utils.SecureUtils; +import com.ruoyi.common.core.utils.StringUtils; +import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.common.redis.service.RedisService; +import com.ruoyi.system.api.RemoteCustomerApplyLogService; +import com.ruoyi.system.api.RemoteCustomerService; +import com.ruoyi.system.api.RemoteMerchantService; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 本地文件存储 + * + * @author ruoyi + */ +@Service +@RequiredArgsConstructor +public class SysPublicAllServiceImpl implements ISysPublicAllService +{ + private final RemoteCustomerService remoteCustomerService; + private final RemoteMerchantService remoteMerchantService; + private final RemoteCustomerApplyLogService remoteCustomerApplyLogService; + private final RedisService redisService; + + /** + * 半流程通用撞库 + * @param comPublicHalfDto + */ + @Override + public AjaxResult check(ComPublicHalfDto comPublicHalfDto) { + //校验 IP地址是否正常 渠道标识是否存在 数据是否为空 + + if (StringUtils.isEmpty(comPublicHalfDto.getChannelSignature())){ + return AjaxResult.error("渠道标识不能未空"); + } + Channel channel = redisService.getCacheObject(CacheConstants.CHANNEL_SIGN + comPublicHalfDto.getChannelSignature()); + if (channel==null||channel.getId()==null){ + return AjaxResult.error("渠道不存在"); + } + if (StringUtils.isEmpty(comPublicHalfDto.getData())){ + return AjaxResult.error("加密数据不能为空"); + } + //解密为customerInfoDto + String s = SecureUtils.AesUtil.AesDecode(comPublicHalfDto.getData(), comPublicHalfDto.getChannelSignature()); + if (s==null){ + return AjaxResult.error("解密异常"); + } + CustomerInfoDto customerInfoDto = JSONObject.parseObject(s, CustomerInfoDto.class); + //校验数据必传参数是否未传 + String checkData = checkData(customerInfoDto); + if (checkData!=null){ + return AjaxResult.error(checkData); + } + //转化字段未数据库中资质字段 并保存 用户未实名状态 一并保存用户申请记录 未申请状态 + Customer customer = new Customer(); + BeanUtil.copyProperties(customerInfoDto,customer); + customer.setChannelId(channel.getId()); + customer.setActurlName(customerInfoDto.getNameMd5()); + customer.setFirstLoginTime(new Date()); + customer.setLastLoginTime(new Date()); + customer.setIsAuth(false); + customer.setStatus(2); + R customerInfoByPhoneMd5 = remoteCustomerService.getCustomerInfoByPhoneMd5(customerInfoDto.getPhoneMd5(), SecurityConstants.INNER); + if (customerInfoByPhoneMd5.getCode()==200){ + remoteCustomerService.updateByPhoneMd5(customer,SecurityConstants.INNER); + }else { + remoteCustomerService.add(customer,SecurityConstants.INNER); + } + //TODO 暂时不做 目前下游暂时不需要 匹配资质 造轮子 返回多个符合的商户 + List merchants = matchMerchant(customer); + //结束返回上游结果 + Map re = new HashMap<>(); + if (merchants.size()>0){ + re.put("data",true); + return AjaxResult.success(re); + } + re.put("data",false); + return AjaxResult.success(re); + } + + /** + * 获取前筛符合的商户 + * @param customer + */ + private List matchMerchant(Customer customer) { + R> listR = remoteMerchantService.merchantList(SecurityConstants.INNER); + if (listR.getCode()!=200){ + return new ArrayList<>(); + } + List merchants = new ArrayList<>(); + for (Merchant merchant:listR.getData()) { + //限量判定 + GetSumDto dto = new GetSumDto(); + dto.setMerchantId(merchant.getId()); + R sum = remoteCustomerApplyLogService.sum(dto, SecurityConstants.INNER); + if (merchant.getLimitType()==1&&merchant.getLimitNum()<=sum.getData()){ + continue; + } + + if (customer.getAge()merchant.getAgeLimitEnd()){ + continue; + } + if (merchant.getChannelLimitType()==1||merchant.getChannelLimitType()==2){ + + List list = Arrays.asList(merchant.getChannelLimit().split(",")).stream().map(val->Long.parseLong(val)).collect(Collectors.toList()); + if (merchant.getChannelLimitType()==1&& !list.contains(customer.getChannelId())){ + continue; + } + if (merchant.getChannelLimitType()==2&& list.contains(customer.getChannelId())){ + continue; + } + } + merchants.add(merchant); + } + return merchants; + } + + /** + * 校验参数 + * @param customerInfoDto + */ + private String checkData(CustomerInfoDto customerInfoDto) { + if (customerInfoDto.getAge()==null){ + return "年龄不能为空"; + } + if (StringUtils.isEmpty(customerInfoDto.getPhoneMd5())){ + return "手机号MD5不能为空"; + } + if (StringUtils.isEmpty(customerInfoDto.getCity())){ + return "城市不能为空"; + } + if (customerInfoDto.getCityCode()==null){ + return "城市编码不能为空"; + } + if (customerInfoDto.getSocialSecurity()==null){ + return "本地社保不能为空"; + } + if (customerInfoDto.getAccumulationFund()==null){ + return "本地公积金不能为空"; + } + if (customerInfoDto.getCar()==null){ + return "车产不能为空"; + } + if (customerInfoDto.getHourse()==null){ + return "房产不能为空"; + } + if (customerInfoDto.getGuarantee()==null){ + return "房产不能为空"; + } + if (customerInfoDto.getZhiMa()==null){ + return "芝麻分不能为空"; + } + if (customerInfoDto.getCareer()==null){ + return "职业不能为空"; + } + if (customerInfoDto.getCreditCard()==null){ + return "信用卡不能为空"; + } + if (customerInfoDto.getEducation()==null){ + return "学历不能为空"; + } + if (customerInfoDto.getMonthlyIncome()==null){ + return "月收入不能为空"; + } + return null; + } + + /** + * 半流程通用进件 + * @param comPublicHalfDto + */ + @Override + public AjaxResult input(ComPublicHalfDto comPublicHalfDto) { + //校验 IP地址是否正常 渠道标识是否存在 数据是否为空 + if (StringUtils.isEmpty(comPublicHalfDto.getChannelSignature())){ + return AjaxResult.error("渠道标识不能未空"); + } + Channel channel = redisService.getCacheObject(CacheConstants.CHANNEL_SIGN + comPublicHalfDto.getChannelSignature()); + if (channel==null||channel.getId()==null){ + return AjaxResult.error("渠道不存在"); + } + if (StringUtils.isEmpty(comPublicHalfDto.getData())){ + return AjaxResult.error("加密数据不能为空"); + } + //解密为customerInfoDto + String s = SecureUtils.AesUtil.AesDecode(comPublicHalfDto.getData(), comPublicHalfDto.getChannelSignature()); + if (s==null){ + return AjaxResult.error("解密异常"); + } + CustomerInfoDto customerInfoDto = JSONObject.parseObject(s, CustomerInfoDto.class); + //校验数据必传参数是否未传 + String checkData = checkData(customerInfoDto); + //转化字段未数据库中资质字段 更新 用户实名状态 一并保存用户申请记录 已申请 + if (checkData!=null){ + return AjaxResult.error(checkData); + } + //转化字段未数据库中资质字段 并保存 用户未实名状态 一并保存用户申请记录 未申请状态 + Customer customer = new Customer(); + BeanUtil.copyProperties(customerInfoDto,customer); + customer.setChannelId(channel.getId()); + customer.setActurlName(customerInfoDto.getName()); + customer.setFirstLoginTime(new Date()); + customer.setLastLoginTime(new Date()); + customer.setIsAuth(true); + customer.setStatus(1); + R customerInfoByPhoneMd5 = remoteCustomerService.getCustomerInfoByPhoneMd5(customerInfoDto.getPhoneMd5(), SecurityConstants.INNER); + if (customerInfoByPhoneMd5.getCode()==200){ + remoteCustomerService.updateByPhoneMd5(customer,SecurityConstants.INNER); + }else { + return AjaxResult.error("今日未撞库"); + } + //匹配资质 造轮子 返回多个符合的商户 + List merchants = matchMerchant(customer); + //TODO 取排序第一的 + + //返回渠道绑定的注册页拼接token + Map result = new HashMap<>(); + Map map = new HashMap<>(); + + //TODO 下游是H5承接不了上游全流程 暂时不做 + CustomerApplyLog customerApplyLog = new CustomerApplyLog(); + customerApplyLog.setCustomerId(customerInfoByPhoneMd5.getData().getId()); + customerApplyLog.setChannelId(channel.getId()); + customerApplyLog.setMerchantId(merchants.get(0).getId()); + customerApplyLog.setOrderStatus(0l); + remoteCustomerApplyLogService.add(customerApplyLog); + //返回上游信息 + return AjaxResult.success(result); + } + + +} diff --git a/ruoyi-modules/ruoyi-btc/src/main/java/com/ruoyi/btc/service/impl/SysPublicHalfServiceImpl.java b/ruoyi-modules/ruoyi-btc/src/main/java/com/ruoyi/btc/service/impl/SysPublicHalfServiceImpl.java new file mode 100644 index 00000000..58d245e0 --- /dev/null +++ b/ruoyi-modules/ruoyi-btc/src/main/java/com/ruoyi/btc/service/impl/SysPublicHalfServiceImpl.java @@ -0,0 +1,328 @@ +package com.ruoyi.btc.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollectionUtil; +import com.alibaba.fastjson.JSONObject; +import com.ruoyi.btc.config.Config; +import com.ruoyi.btc.domain.ComPublicHalfDto; +import com.ruoyi.btc.domain.CustomerInfoDto; +import com.ruoyi.btc.service.ISysPublicHalfService; +import com.ruoyi.common.core.constant.CacheConstants; +import com.ruoyi.common.core.constant.RedisConstant; +import com.ruoyi.common.core.constant.SecurityConstants; +import com.ruoyi.common.core.domain.GetSumDto; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.core.domain.http.Channel; +import com.ruoyi.common.core.domain.http.Customer; +import com.ruoyi.common.core.domain.http.Merchant; +import com.ruoyi.common.core.utils.EncryptUtil; +import com.ruoyi.common.core.utils.ProbitUtil; +import com.ruoyi.common.core.utils.SecureUtils; +import com.ruoyi.common.core.utils.StringUtils; +import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.common.redis.service.RedisService; +import com.ruoyi.system.api.RemoteCustomerApplyLogService; +import com.ruoyi.system.api.RemoteCustomerService; +import com.ruoyi.system.api.RemoteMerchantService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import java.util.*; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +/** + * 本地文件存储 + * + * @author ruoyi + */ +@Service +@RequiredArgsConstructor +@Slf4j +public class SysPublicHalfServiceImpl implements ISysPublicHalfService +{ + private final RemoteCustomerService remoteCustomerService; + private final RemoteMerchantService remoteMerchantService; + private final RemoteCustomerApplyLogService remoteCustomerApplyLogService; + private final RedisService redisService; + private final Config config; + + /** + * 半流程通用撞库 + * @param comPublicHalfDto + */ + @Override + public AjaxResult check(ComPublicHalfDto comPublicHalfDto) { + //校验 IP地址是否正常 渠道标识是否存在 数据是否为空 + if (StringUtils.isEmpty(comPublicHalfDto.getChannelSignature())){ + return AjaxResult.error("渠道标识不能未空"); + } + Channel channel = redisService.getCacheObject(CacheConstants.CHANNEL_SIGN + comPublicHalfDto.getChannelSignature()); + if (channel==null||channel.getId()==null){ + return AjaxResult.error("渠道不存在"); + } + if (StringUtils.isEmpty(comPublicHalfDto.getData())){ + return AjaxResult.error("加密数据不能为空"); + } + + //解密为customerInfoDto + String s = SecureUtils.AesUtil.AesDecode(comPublicHalfDto.getData(), comPublicHalfDto.getChannelSignature()); + if (s==null){ + return AjaxResult.error("解密异常"); + } + CustomerInfoDto customerInfoDto = JSONObject.parseObject(s, CustomerInfoDto.class); + //撞库幂等性校验 暂时不加 +// Boolean aBoolean = redisService.hasKey(RedisConstant.HIT_CHECK_CACHE+customerInfoDto.getPhoneMd5()+":"+comPublicHalfDto.getChannelSignature()); +// if (aBoolean){ +// return AjaxResult.error("手机号:"+customerInfoDto.getPhoneMd5()+"请勿重复撞库"); +// } +// redisService.setCacheObject(RedisConstant.HIT_CHECK_CACHE+customerInfoDto.getPhoneMd5(),1,60*3l, TimeUnit.SECONDS); + log.info("渠道:{},撞库手机号:{}",channel.getChannelName(),customerInfoDto.getPhoneMd5()); + //校验数据必传参数是否未传 + String checkData = checkData(customerInfoDto); + if (checkData!=null){ + return AjaxResult.error(checkData); + } + //转化字段未数据库中资质字段 并保存 用户未实名状态 一并保存用户申请记录 未申请状态 + Customer customer = new Customer(); + BeanUtil.copyProperties(customerInfoDto,customer); + customer.setChannelId(channel.getId()); + customer.setActurlName(customerInfoDto.getNameMd5()); + customer.setFirstLoginTime(new Date()); + customer.setLastLoginTime(new Date()); + customer.setIsAuth(false); + customer.setStatus(2); + customer.setPhoneMd5(customerInfoDto.getPhoneMd5()); + R customerInfoByPhoneMd5 = remoteCustomerService.getCustomerInfoByPhoneMd5(customerInfoDto.getPhoneMd5(), SecurityConstants.INNER); + log.info("渠道:{},是否查询到用户:{}",channel.getChannelName(),customerInfoByPhoneMd5.getCode()); + if (customerInfoByPhoneMd5.getCode()==200){ + remoteCustomerService.updateByPhoneMd5(customer,SecurityConstants.INNER); + }else { + remoteCustomerService.add(customer,SecurityConstants.INNER); + } + //TODO 暂时不做 目前下游暂时不需要 匹配资质 造轮子 返回多个符合的商户 + List merchants = matchMerchant(customer); + //结束返回上游结果 + Map re = new HashMap<>(); + if (merchants.size()>0){ + re.put("data",true); + return AjaxResult.success(re); + } + re.put("data",false); + return AjaxResult.success(re); + } + + /** + * 获取前筛符合的商户 + * @param customer + */ + private List matchMerchant(Customer customer) { + R> listR = remoteMerchantService.merchantList(SecurityConstants.INNER); + if (listR.getCode()!=200){ + return new ArrayList<>(); + } + List merchants = new ArrayList<>(); + for (Merchant merchant:listR.getData()) { + //限量判定 + GetSumDto dto = new GetSumDto(); + dto.setMerchantId(merchant.getId()); + R sum = remoteCustomerApplyLogService.sum(dto, SecurityConstants.INNER); + if (merchant.getLimitType()==1&&merchant.getLimitNum()<=sum.getData()){ + continue; + } + + if (customer.getAge()merchant.getAgeLimitEnd()){ + continue; + } + if (merchant.getChannelLimitType()==1||merchant.getChannelLimitType()==2){ + + List list = Arrays.asList(merchant.getChannelLimit().split(",")).stream().map(val->Long.parseLong(val)).collect(Collectors.toList()); + if (merchant.getChannelLimitType()==1&& !list.contains(customer.getChannelId())){ + continue; + } + if (merchant.getChannelLimitType()==2&& list.contains(customer.getChannelId())){ + continue; + } + } + merchants.add(merchant); + } + return merchants; + } + + /** + * 校验参数 + * @param customerInfoDto + */ + private String checkData(CustomerInfoDto customerInfoDto) { + if (customerInfoDto.getAge()==null){ + return "年龄不能为空"; + } + if (StringUtils.isEmpty(customerInfoDto.getPhoneMd5())){ + return "手机号MD5不能为空"; + } + if (StringUtils.isEmpty(customerInfoDto.getCity())){ + return "城市不能为空"; + } + if (customerInfoDto.getCityCode()==null){ + return "城市编码不能为空"; + } + if (customerInfoDto.getSocialSecurity()==null){ + return "本地社保不能为空"; + } + if (customerInfoDto.getAccumulationFund()==null){ + return "本地公积金不能为空"; + } + if (customerInfoDto.getCar()==null){ + return "车产不能为空"; + } + if (customerInfoDto.getHourse()==null){ + return "房产不能为空"; + } + if (customerInfoDto.getGuarantee()==null){ + return "房产不能为空"; + } + if (customerInfoDto.getZhiMa()==null){ + return "芝麻分不能为空"; + } + if (customerInfoDto.getCareer()==null){ + return "职业不能为空"; + } + if (customerInfoDto.getCreditCard()==null){ + return "信用卡不能为空"; + } + if (customerInfoDto.getEducation()==null){ + return "学历不能为空"; + } + if (customerInfoDto.getMonthlyIncome()==null){ + return "月收入不能为空"; + } + return null; + } + + /** + * 半流程通用进件 + * @param comPublicHalfDto + */ + @Override + public AjaxResult input(ComPublicHalfDto comPublicHalfDto) { + //校验 IP地址是否正常 渠道标识是否存在 数据是否为空 + if (StringUtils.isEmpty(comPublicHalfDto.getChannelSignature())){ + return AjaxResult.error("渠道标识不能未空"); + } + Channel channel = redisService.getCacheObject(CacheConstants.CHANNEL_SIGN + comPublicHalfDto.getChannelSignature()); + if (channel==null||channel.getId()==null){ + return AjaxResult.error("渠道不存在"); + } + if (StringUtils.isEmpty(comPublicHalfDto.getData())){ + return AjaxResult.error("加密数据不能为空"); + } + //解密为customerInfoDto + String s = SecureUtils.AesUtil.AesDecode(comPublicHalfDto.getData(), comPublicHalfDto.getChannelSignature()); + if (s==null){ + return AjaxResult.error("解密异常"); + } + CustomerInfoDto customerInfoDto = JSONObject.parseObject(s, CustomerInfoDto.class); + log.info("渠道:{},进件手机号:{}",channel.getChannelName(),customerInfoDto.getPhone()); + //校验数据必传参数是否未传 + String checkData = checkData(customerInfoDto); + //转化字段未数据库中资质字段 更新 用户实名状态 一并保存用户申请记录 已申请 + if (checkData!=null){ + return AjaxResult.error(checkData); + } + //转化字段未数据库中资质字段 并保存 用户未实名状态 一并保存用户申请记录 未申请状态 + Customer customer = new Customer(); + BeanUtil.copyProperties(customerInfoDto,customer); + customer.setChannelId(channel.getId()); + customer.setActurlName(customerInfoDto.getName()); + customer.setFirstLoginTime(new Date()); + customer.setLastLoginTime(new Date()); + customer.setIsAuth(true); + customer.setStatus(1); + R customerInfoByPhoneMd5 = remoteCustomerService.getCustomerInfoByPhoneMd5(customerInfoDto.getPhoneMd5(), SecurityConstants.INNER); + if (customerInfoByPhoneMd5.getCode()==200){ + customer.setPhone(EncryptUtil.AESencode(customer.getPhone(), config.getAESkey())); + customer.setIdCard(EncryptUtil.AESencode(customer.getIdCard(),config.getAESkey())); + customer.setActurlName(EncryptUtil.AESencode(customer.getActurlName(),config.getAESkey())); + remoteCustomerService.updateByPhoneMd5(customer,SecurityConstants.INNER); + }else { + remoteCustomerService.add(customer,SecurityConstants.INNER); + } + //匹配资质 造轮子 返回多个符合的商户 + List merchants = matchMerchant(customer); + //TODO 取排序第一的 + //返回渠道绑定的注册页拼接token + Map result = new HashMap<>(); + Map map = new HashMap<>(); + if (CollectionUtil.isEmpty(merchants)){ + map.put("url",""); + map.put("regist",false); + result.put("data",map); + return AjaxResult.success(result); + } + String url = channel.getHtmlLocation()+"?sign="+channel.getChannelSign() + "&token="+remoteCustomerService.getCustomerToken(customer.getPhone(),channel.getId() ); + map.put("url",url); + map.put("regist",true); + result.put("data",map); + //CustomerApplyLog customerApplyLog = new CustomerApplyLog(); +// customerApplyLog.setCustomerId(customerInfoByPhoneMd5.getData().getId()); +// customerApplyLog.setChannelId(channel.getId()); +// customerApplyLog.setOrderStatus(0l); + //+"&orderNo="+ LocalDateTimeUtils.getStringFromLocalDateTime() + //remoteCustomerApplyLogService.add(customerApplyLog); + //返回上游信息 + return AjaxResult.success(result); + } + + /** + * 渠道查询订单是否成功 + * @param comPublicHalfDto + */ + @Override + public AjaxResult checkOrder(String phoneMd5, String channelSign) { + //根据手机号MD5渠道标识 查询是否成功 + R customerInfoByPhoneMd5 = remoteCustomerService.getCustomerInfoByPhoneMd5(phoneMd5, SecurityConstants.INNER); + Channel channel = redisService.getCacheObject(CacheConstants.CHANNEL_ID + customerInfoByPhoneMd5.getData().getChannelId()); + R booleanR = remoteCustomerApplyLogService.customerApply(customerInfoByPhoneMd5.getData().getId(), SecurityConstants.INNER); + //失败直接失败 + if (!booleanR.getData()){ + return AjaxResult.success("用户未申请","false"); + } + //成功抽奖 按扣量比抽 + //成功数 + double succ = channel.getScore()*0.01; + //扣量数 + double socre = 1-(channel.getScore()*0.01); + List drow = new ArrayList<>(); + drow.add(succ); + drow.add(socre); + int draw = ProbitUtil.draw(drow); + //返回是否成功 + return draw==0?AjaxResult.success("用户已申请",true):AjaxResult.success("用户未申请","false"); + } + + public static void main(String[] args) { + CustomerInfoDto customerInfoDto = new CustomerInfoDto(); + customerInfoDto.setPhoneMd5("331d17d1ca8a091410e3238fab16a863"); + customerInfoDto.setPhone("15205600635"); + customerInfoDto.setSex(0); + customerInfoDto.setNameMd5("331d17d1ca8a091410e3238fab16a863"); + customerInfoDto.setName("朱三"); + customerInfoDto.setAge(18); + customerInfoDto.setIdCardMd5("331d17d1ca8a091410e3238fab16a863"); + customerInfoDto.setIdCard("341202199306023511"); + customerInfoDto.setCity("重庆"); + customerInfoDto.setCityCode(1000); + customerInfoDto.setSocialSecurity(1); + customerInfoDto.setAccumulationFund(1); + customerInfoDto.setCar(1); + customerInfoDto.setHourse(1); + customerInfoDto.setGuarantee(1); + customerInfoDto.setZhiMa(600); + customerInfoDto.setCareer(1); + customerInfoDto.setCreditCard(1); + customerInfoDto.setEducation(1); + customerInfoDto.setMonthlyIncome(5000); + System.out.println(JSONObject.toJSONString(customerInfoDto)); + } +} diff --git a/ruoyi-modules/ruoyi-btc/src/main/resources/banner.txt b/ruoyi-modules/ruoyi-btc/src/main/resources/banner.txt new file mode 100644 index 00000000..27cacb9c --- /dev/null +++ b/ruoyi-modules/ruoyi-btc/src/main/resources/banner.txt @@ -0,0 +1,10 @@ +Spring Boot Version: ${spring-boot.version} +Spring Application Name: ${spring.application.name} + _ __ _ _ + (_) / _|(_)| | + _ __ _ _ ___ _ _ _ ______ | |_ _ | | ___ +| '__|| | | | / _ \ | | | || ||______|| _|| || | / _ \ +| | | |_| || (_) || |_| || | | | | || || __/ +|_| \__,_| \___/ \__, ||_| |_| |_||_| \___| + __/ | + |___/ \ No newline at end of file diff --git a/ruoyi-modules/ruoyi-btc/src/main/resources/bootstrap.yml b/ruoyi-modules/ruoyi-btc/src/main/resources/bootstrap.yml new file mode 100644 index 00000000..ab6bb0f6 --- /dev/null +++ b/ruoyi-modules/ruoyi-btc/src/main/resources/bootstrap.yml @@ -0,0 +1,27 @@ +# Tomcat +server: + port: 9301 + +# Spring +spring: + application: + # 应用名称 + name: ruoyi-btc + profiles: + # 环境配置 + active: dev + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: 47.109.135.151:8848 + namespace: b8ad3fd2-18ea-4cdf-a82c-4ce483392b1a + config: + # 配置中心地址 + server-addr: 47.109.135.151:8848 + namespace: b8ad3fd2-18ea-4cdf-a82c-4ce483392b1a + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-configs: + - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} diff --git a/ruoyi-modules/ruoyi-btc/src/main/resources/logback.xml b/ruoyi-modules/ruoyi-btc/src/main/resources/logback.xml new file mode 100644 index 00000000..ed6c17d3 --- /dev/null +++ b/ruoyi-modules/ruoyi-btc/src/main/resources/logback.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + ${log.pattern} + + + + + + ${log.path}/info.log + + + + ${log.path}/info.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + + INFO + + ACCEPT + + DENY + + + + + ${log.path}/error.log + + + + ${log.path}/error.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + + ERROR + + ACCEPT + + DENY + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/RuoYiFileApplication.java b/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/RuoYiFileApplication.java index cc6fdd08..6eb513e6 100644 --- a/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/RuoYiFileApplication.java +++ b/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/RuoYiFileApplication.java @@ -15,15 +15,6 @@ public class RuoYiFileApplication public static void main(String[] args) { SpringApplication.run(RuoYiFileApplication.class, args); - System.out.println("(♥◠‿◠)ノ゙ 文件服务模块启动成功 ლ(´ڡ`ლ)゙ \n" + - " .-------. ____ __ \n" + - " | _ _ \\ \\ \\ / / \n" + - " | ( ' ) | \\ _. / ' \n" + - " |(_ o _) / _( )_ .' \n" + - " | (_,_).' __ ___(_ o _)' \n" + - " | |\\ \\ | || |(_,_)' \n" + - " | | \\ `' /| `-' / \n" + - " | | \\ / \\ / \n" + - " ''-' `'-' `-..-' "); + System.out.println("(♥◠‿◠)ノ゙ 文件服务模块启动成功 ლ(´ڡ`ლ)゙ \n"); } } diff --git a/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/config/MinioConfig.java b/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/config/MinioConfig.java index ee3e14c2..29beea08 100644 --- a/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/config/MinioConfig.java +++ b/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/config/MinioConfig.java @@ -1,82 +1,82 @@ -package com.ruoyi.file.config; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import io.minio.MinioClient; - -/** - * Minio 配置信息 - * - * @author ruoyi - */ -@Configuration -@ConfigurationProperties(prefix = "minio") -public class MinioConfig -{ - /** - * 服务地址 - */ - private String url; - - /** - * 用户名 - */ - private String accessKey; - - /** - * 密码 - */ - private String secretKey; - - /** - * 存储桶名称 - */ - private String bucketName; - - public String getUrl() - { - return url; - } - - public void setUrl(String url) - { - this.url = url; - } - - public String getAccessKey() - { - return accessKey; - } - - public void setAccessKey(String accessKey) - { - this.accessKey = accessKey; - } - - public String getSecretKey() - { - return secretKey; - } - - public void setSecretKey(String secretKey) - { - this.secretKey = secretKey; - } - - public String getBucketName() - { - return bucketName; - } - - public void setBucketName(String bucketName) - { - this.bucketName = bucketName; - } - - @Bean - public MinioClient getMinioClient() - { - return MinioClient.builder().endpoint(url).credentials(accessKey, secretKey).build(); - } -} +package com.ruoyi.file.config; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import io.minio.MinioClient; + +/** + * Minio 配置信息 + * + * @author ruoyi + */ +@Configuration +@ConfigurationProperties(prefix = "minio") +public class MinioConfig +{ + /** + * 服务地址 + */ + private String url; + + /** + * 用户名 + */ + private String accessKey; + + /** + * 密码 + */ + private String secretKey; + + /** + * 存储桶名称 + */ + private String bucketName; + + public String getUrl() + { + return url; + } + + public void setUrl(String url) + { + this.url = url; + } + + public String getAccessKey() + { + return accessKey; + } + + public void setAccessKey(String accessKey) + { + this.accessKey = accessKey; + } + + public String getSecretKey() + { + return secretKey; + } + + public void setSecretKey(String secretKey) + { + this.secretKey = secretKey; + } + + public String getBucketName() + { + return bucketName; + } + + public void setBucketName(String bucketName) + { + this.bucketName = bucketName; + } + + @Bean + public MinioClient getMinioClient() + { + return MinioClient.builder().endpoint(url).credentials(accessKey, secretKey).build(); + } +} diff --git a/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/config/ResourcesConfig.java b/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/config/ResourcesConfig.java index 3bca6686..80036702 100644 --- a/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/config/ResourcesConfig.java +++ b/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/config/ResourcesConfig.java @@ -1,50 +1,50 @@ -package com.ruoyi.file.config; - -import java.io.File; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.config.annotation.CorsRegistry; -import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; - -/** - * 通用映射配置 - * - * @author ruoyi - */ -@Configuration -public class ResourcesConfig implements WebMvcConfigurer -{ - /** - * 上传文件存储在本地的根路径 - */ - @Value("${file.path}") - private String localFilePath; - - /** - * 资源映射路径 前缀 - */ - @Value("${file.prefix}") - public String localFilePrefix; - - @Override - public void addResourceHandlers(ResourceHandlerRegistry registry) - { - /** 本地文件上传路径 */ - registry.addResourceHandler(localFilePrefix + "/**") - .addResourceLocations("file:" + localFilePath + File.separator); - } - - /** - * 开启跨域 - */ - @Override - public void addCorsMappings(CorsRegistry registry) { - // 设置允许跨域的路由 - registry.addMapping(localFilePrefix + "/**") - // 设置允许跨域请求的域名 - .allowedOrigins("*") - // 设置允许的方法 - .allowedMethods("GET"); - } +package com.ruoyi.file.config; + +import java.io.File; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +/** + * 通用映射配置 + * + * @author ruoyi + */ +@Configuration +public class ResourcesConfig implements WebMvcConfigurer +{ + /** + * 上传文件存储在本地的根路径 + */ + @Value("${file.path}") + private String localFilePath; + + /** + * 资源映射路径 前缀 + */ + @Value("${file.prefix}") + public String localFilePrefix; + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) + { + /** 本地文件上传路径 */ + registry.addResourceHandler(localFilePrefix + "/**") + .addResourceLocations("file:" + localFilePath + File.separator); + } + + /** + * 开启跨域 + */ + @Override + public void addCorsMappings(CorsRegistry registry) { + // 设置允许跨域的路由 + registry.addMapping(localFilePrefix + "/**") + // 设置允许跨域请求的域名 + .allowedOrigins("*") + // 设置允许的方法 + .allowedMethods("GET"); + } } \ No newline at end of file diff --git a/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/controller/SysFileController.java b/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/controller/SysFileController.java index 318db416..45f86b06 100644 --- a/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/controller/SysFileController.java +++ b/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/controller/SysFileController.java @@ -1,48 +1,48 @@ -package com.ruoyi.file.controller; - -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.RestController; -import org.springframework.web.multipart.MultipartFile; -import com.ruoyi.common.core.domain.R; -import com.ruoyi.common.core.utils.file.FileUtils; -import com.ruoyi.file.service.ISysFileService; -import com.ruoyi.system.api.domain.SysFile; - -/** - * 文件请求处理 - * - * @author ruoyi - */ -@RestController -public class SysFileController -{ - private static final Logger log = LoggerFactory.getLogger(SysFileController.class); - - @Autowired - private ISysFileService sysFileService; - - /** - * 文件上传请求 - */ - @PostMapping("upload") - public R upload(MultipartFile file) - { - try - { - // 上传并返回访问地址 - String url = sysFileService.uploadFile(file); - SysFile sysFile = new SysFile(); - sysFile.setName(FileUtils.getName(url)); - sysFile.setUrl(url); - return R.ok(sysFile); - } - catch (Exception e) - { - log.error("上传文件失败", e); - return R.fail(e.getMessage()); - } - } +package com.ruoyi.file.controller; + +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.RestController; +import org.springframework.web.multipart.MultipartFile; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.core.utils.file.FileUtils; +import com.ruoyi.file.service.ISysFileService; +import com.ruoyi.system.api.domain.SysFile; + +/** + * 文件请求处理 + * + * @author ruoyi + */ +@RestController +public class SysFileController +{ + private static final Logger log = LoggerFactory.getLogger(SysFileController.class); + + @Autowired + private ISysFileService sysFileService; + + /** + * 文件上传请求 + */ + @PostMapping("upload") + public R upload(MultipartFile file) + { + try + { + // 上传并返回访问地址 + String url = sysFileService.uploadFile(file); + SysFile sysFile = new SysFile(); + sysFile.setName(FileUtils.getName(url)); + sysFile.setUrl(url); + return R.ok(sysFile); + } + catch (Exception e) + { + log.error("上传文件失败", e); + return R.fail(e.getMessage()); + } + } } \ No newline at end of file diff --git a/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/service/FastDfsSysFileServiceImpl.java b/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/service/FastDfsSysFileServiceImpl.java index 989edb71..0f85449b 100644 --- a/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/service/FastDfsSysFileServiceImpl.java +++ b/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/service/FastDfsSysFileServiceImpl.java @@ -1,46 +1,46 @@ -package com.ruoyi.file.service; - -import java.io.InputStream; -import com.alibaba.nacos.common.utils.IoUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Service; -import org.springframework.web.multipart.MultipartFile; -import com.github.tobato.fastdfs.domain.fdfs.StorePath; -import com.github.tobato.fastdfs.service.FastFileStorageClient; -import com.ruoyi.common.core.utils.file.FileTypeUtils; - -/** - * FastDFS 文件存储 - * - * @author ruoyi - */ -@Service -public class FastDfsSysFileServiceImpl implements ISysFileService -{ - /** - * 域名或本机访问地址 - */ - @Value("${fdfs.domain}") - public String domain; - - @Autowired - private FastFileStorageClient storageClient; - - /** - * FastDfs文件上传接口 - * - * @param file 上传的文件 - * @return 访问地址 - * @throws Exception - */ - @Override - public String uploadFile(MultipartFile file) throws Exception - { - InputStream inputStream = file.getInputStream(); - StorePath storePath = storageClient.uploadFile(inputStream, file.getSize(), - FileTypeUtils.getExtension(file), null); - IoUtils.closeQuietly(inputStream); - return domain + "/" + storePath.getFullPath(); - } -} +package com.ruoyi.file.service; + +import java.io.InputStream; +import com.alibaba.nacos.common.utils.IoUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; +import com.github.tobato.fastdfs.domain.fdfs.StorePath; +import com.github.tobato.fastdfs.service.FastFileStorageClient; +import com.ruoyi.common.core.utils.file.FileTypeUtils; + +/** + * FastDFS 文件存储 + * + * @author ruoyi + */ +@Service +public class FastDfsSysFileServiceImpl implements ISysFileService +{ + /** + * 域名或本机访问地址 + */ + @Value("${fdfs.domain}") + public String domain; + + @Autowired + private FastFileStorageClient storageClient; + + /** + * FastDfs文件上传接口 + * + * @param file 上传的文件 + * @return 访问地址 + * @throws Exception + */ + @Override + public String uploadFile(MultipartFile file) throws Exception + { + InputStream inputStream = file.getInputStream(); + StorePath storePath = storageClient.uploadFile(inputStream, file.getSize(), + FileTypeUtils.getExtension(file), null); + IoUtils.closeQuietly(inputStream); + return domain + "/" + storePath.getFullPath(); + } +} diff --git a/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/service/ISysFileService.java b/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/service/ISysFileService.java index 5a353489..c95e6f25 100644 --- a/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/service/ISysFileService.java +++ b/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/service/ISysFileService.java @@ -1,20 +1,20 @@ -package com.ruoyi.file.service; - -import org.springframework.web.multipart.MultipartFile; - -/** - * 文件上传接口 - * - * @author ruoyi - */ -public interface ISysFileService -{ - /** - * 文件上传接口 - * - * @param file 上传的文件 - * @return 访问地址 - * @throws Exception - */ - public String uploadFile(MultipartFile file) throws Exception; -} +package com.ruoyi.file.service; + +import org.springframework.web.multipart.MultipartFile; + +/** + * 文件上传接口 + * + * @author ruoyi + */ +public interface ISysFileService +{ + /** + * 文件上传接口 + * + * @param file 上传的文件 + * @return 访问地址 + * @throws Exception + */ + public String uploadFile(MultipartFile file) throws Exception; +} diff --git a/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/service/LocalSysFileServiceImpl.java b/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/service/LocalSysFileServiceImpl.java index c0e20681..8e1b317e 100644 --- a/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/service/LocalSysFileServiceImpl.java +++ b/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/service/LocalSysFileServiceImpl.java @@ -1,50 +1,53 @@ -package com.ruoyi.file.service; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Primary; -import org.springframework.stereotype.Service; -import org.springframework.web.multipart.MultipartFile; -import com.ruoyi.file.utils.FileUploadUtils; - -/** - * 本地文件存储 - * - * @author ruoyi - */ -@Primary -@Service -public class LocalSysFileServiceImpl implements ISysFileService -{ - /** - * 资源映射路径 前缀 - */ - @Value("${file.prefix}") - public String localFilePrefix; - - /** - * 域名或本机访问地址 - */ - @Value("${file.domain}") - public String domain; - - /** - * 上传文件存储在本地的根路径 - */ - @Value("${file.path}") - private String localFilePath; - - /** - * 本地文件上传接口 - * - * @param file 上传的文件 - * @return 访问地址 - * @throws Exception - */ - @Override - public String uploadFile(MultipartFile file) throws Exception - { - String name = FileUploadUtils.upload(localFilePath, file); - String url = domain + localFilePrefix + name; - return url; - } -} +package com.ruoyi.file.service; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; +import com.ruoyi.file.utils.FileUploadUtils; + +/** + * 本地文件存储 + * + * @author ruoyi + */ +@Primary +@Service +@Slf4j +public class LocalSysFileServiceImpl implements ISysFileService +{ + /** + * 资源映射路径 前缀 + */ + @Value("${file.prefix}") + public String localFilePrefix; + + /** + * 域名或本机访问地址 + */ + @Value("${file.domain}") + public String domain; + + /** + * 上传文件存储在本地的根路径 + */ + @Value("${file.path}") + private String localFilePath; + + /** + * 本地文件上传接口 + * + * @param file 上传的文件 + * @return 访问地址 + * @throws Exception + */ + @Override + public String uploadFile(MultipartFile file) throws Exception + { + String name = FileUploadUtils.upload(localFilePath, file); + String url = domain + localFilePrefix + name; + + return url; + } +} diff --git a/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/service/MinioSysFileServiceImpl.java b/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/service/MinioSysFileServiceImpl.java index 4a0b6c4b..f53d86f9 100644 --- a/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/service/MinioSysFileServiceImpl.java +++ b/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/service/MinioSysFileServiceImpl.java @@ -1,49 +1,49 @@ -package com.ruoyi.file.service; - -import java.io.InputStream; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.web.multipart.MultipartFile; -import com.alibaba.nacos.common.utils.IoUtils; -import com.ruoyi.file.config.MinioConfig; -import com.ruoyi.file.utils.FileUploadUtils; -import io.minio.MinioClient; -import io.minio.PutObjectArgs; - -/** - * Minio 文件存储 - * - * @author ruoyi - */ -@Service -public class MinioSysFileServiceImpl implements ISysFileService -{ - @Autowired - private MinioConfig minioConfig; - - @Autowired - private MinioClient client; - - /** - * Minio文件上传接口 - * - * @param file 上传的文件 - * @return 访问地址 - * @throws Exception - */ - @Override - public String uploadFile(MultipartFile file) throws Exception - { - String fileName = FileUploadUtils.extractFilename(file); - InputStream inputStream = file.getInputStream(); - PutObjectArgs args = PutObjectArgs.builder() - .bucket(minioConfig.getBucketName()) - .object(fileName) - .stream(inputStream, file.getSize(), -1) - .contentType(file.getContentType()) - .build(); - client.putObject(args); - IoUtils.closeQuietly(inputStream); - return minioConfig.getUrl() + "/" + minioConfig.getBucketName() + "/" + fileName; - } -} +package com.ruoyi.file.service; + +import java.io.InputStream; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; +import com.alibaba.nacos.common.utils.IoUtils; +import com.ruoyi.file.config.MinioConfig; +import com.ruoyi.file.utils.FileUploadUtils; +import io.minio.MinioClient; +import io.minio.PutObjectArgs; + +/** + * Minio 文件存储 + * + * @author ruoyi + */ +@Service +public class MinioSysFileServiceImpl implements ISysFileService +{ + @Autowired + private MinioConfig minioConfig; + + @Autowired + private MinioClient client; + + /** + * Minio文件上传接口 + * + * @param file 上传的文件 + * @return 访问地址 + * @throws Exception + */ + @Override + public String uploadFile(MultipartFile file) throws Exception + { + String fileName = FileUploadUtils.extractFilename(file); + InputStream inputStream = file.getInputStream(); + PutObjectArgs args = PutObjectArgs.builder() + .bucket(minioConfig.getBucketName()) + .object(fileName) + .stream(inputStream, file.getSize(), -1) + .contentType(file.getContentType()) + .build(); + client.putObject(args); + IoUtils.closeQuietly(inputStream); + return minioConfig.getUrl() + "/" + minioConfig.getBucketName() + "/" + fileName; + } +} diff --git a/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/utils/FileUploadUtils.java b/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/utils/FileUploadUtils.java index b53c3fa3..6ae02049 100644 --- a/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/utils/FileUploadUtils.java +++ b/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/utils/FileUploadUtils.java @@ -1,185 +1,185 @@ -package com.ruoyi.file.utils; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Paths; -import java.util.Objects; -import org.apache.commons.io.FilenameUtils; -import org.springframework.web.multipart.MultipartFile; -import com.ruoyi.common.core.exception.file.FileException; -import com.ruoyi.common.core.exception.file.FileNameLengthLimitExceededException; -import com.ruoyi.common.core.exception.file.FileSizeLimitExceededException; -import com.ruoyi.common.core.exception.file.InvalidExtensionException; -import com.ruoyi.common.core.utils.DateUtils; -import com.ruoyi.common.core.utils.StringUtils; -import com.ruoyi.common.core.utils.file.FileTypeUtils; -import com.ruoyi.common.core.utils.file.MimeTypeUtils; -import com.ruoyi.common.core.utils.uuid.Seq; - -/** - * 文件上传工具类 - * - * @author ruoyi - */ -public class FileUploadUtils -{ - /** - * 默认大小 50M - */ - public static final long DEFAULT_MAX_SIZE = 50 * 1024 * 1024L; - - /** - * 默认的文件名最大长度 100 - */ - public static final int DEFAULT_FILE_NAME_LENGTH = 100; - - /** - * 根据文件路径上传 - * - * @param baseDir 相对应用的基目录 - * @param file 上传的文件 - * @return 文件名称 - * @throws IOException - */ - public static final String upload(String baseDir, MultipartFile file) throws IOException - { - try - { - return upload(baseDir, file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION); - } - catch (FileException fe) - { - throw new IOException(fe.getDefaultMessage(), fe); - } - catch (Exception e) - { - throw new IOException(e.getMessage(), e); - } - } - - /** - * 文件上传 - * - * @param baseDir 相对应用的基目录 - * @param file 上传的文件 - * @param allowedExtension 上传文件类型 - * @return 返回上传成功的文件名 - * @throws FileSizeLimitExceededException 如果超出最大大小 - * @throws FileNameLengthLimitExceededException 文件名太长 - * @throws IOException 比如读写文件出错时 - * @throws InvalidExtensionException 文件校验异常 - */ - public static final String upload(String baseDir, MultipartFile file, String[] allowedExtension) - throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException, - InvalidExtensionException - { - int fileNamelength = Objects.requireNonNull(file.getOriginalFilename()).length(); - if (fileNamelength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH) - { - throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH); - } - - assertAllowed(file, allowedExtension); - - String fileName = extractFilename(file); - - String absPath = getAbsoluteFile(baseDir, fileName).getAbsolutePath(); - file.transferTo(Paths.get(absPath)); - return getPathFileName(fileName); - } - - /** - * 编码文件名 - */ - public static final String extractFilename(MultipartFile file) - { - return StringUtils.format("{}/{}_{}.{}", DateUtils.datePath(), - FilenameUtils.getBaseName(file.getOriginalFilename()), Seq.getId(Seq.uploadSeqType), FileTypeUtils.getExtension(file)); - } - - private static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException - { - File desc = new File(uploadDir + File.separator + fileName); - - if (!desc.exists()) - { - if (!desc.getParentFile().exists()) - { - desc.getParentFile().mkdirs(); - } - } - return desc.isAbsolute() ? desc : desc.getAbsoluteFile(); - } - - private static final String getPathFileName(String fileName) throws IOException - { - String pathFileName = "/" + fileName; - return pathFileName; - } - - /** - * 文件大小校验 - * - * @param file 上传的文件 - * @throws FileSizeLimitExceededException 如果超出最大大小 - * @throws InvalidExtensionException 文件校验异常 - */ - public static final void assertAllowed(MultipartFile file, String[] allowedExtension) - throws FileSizeLimitExceededException, InvalidExtensionException - { - long size = file.getSize(); - if (size > DEFAULT_MAX_SIZE) - { - throw new FileSizeLimitExceededException(DEFAULT_MAX_SIZE / 1024 / 1024); - } - - String fileName = file.getOriginalFilename(); - String extension = FileTypeUtils.getExtension(file); - if (allowedExtension != null && !isAllowedExtension(extension, allowedExtension)) - { - if (allowedExtension == MimeTypeUtils.IMAGE_EXTENSION) - { - throw new InvalidExtensionException.InvalidImageExtensionException(allowedExtension, extension, - fileName); - } - else if (allowedExtension == MimeTypeUtils.FLASH_EXTENSION) - { - throw new InvalidExtensionException.InvalidFlashExtensionException(allowedExtension, extension, - fileName); - } - else if (allowedExtension == MimeTypeUtils.MEDIA_EXTENSION) - { - throw new InvalidExtensionException.InvalidMediaExtensionException(allowedExtension, extension, - fileName); - } - else if (allowedExtension == MimeTypeUtils.VIDEO_EXTENSION) - { - throw new InvalidExtensionException.InvalidVideoExtensionException(allowedExtension, extension, - fileName); - } - else - { - throw new InvalidExtensionException(allowedExtension, extension, fileName); - } - } - } - - /** - * 判断MIME类型是否是允许的MIME类型 - * - * @param extension 上传文件类型 - * @param allowedExtension 允许上传文件类型 - * @return true/false - */ - public static final boolean isAllowedExtension(String extension, String[] allowedExtension) - { - for (String str : allowedExtension) - { - if (str.equalsIgnoreCase(extension)) - { - return true; - } - } - return false; - } +package com.ruoyi.file.utils; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Paths; +import java.util.Objects; +import org.apache.commons.io.FilenameUtils; +import org.springframework.web.multipart.MultipartFile; +import com.ruoyi.common.core.exception.file.FileException; +import com.ruoyi.common.core.exception.file.FileNameLengthLimitExceededException; +import com.ruoyi.common.core.exception.file.FileSizeLimitExceededException; +import com.ruoyi.common.core.exception.file.InvalidExtensionException; +import com.ruoyi.common.core.utils.DateUtils; +import com.ruoyi.common.core.utils.StringUtils; +import com.ruoyi.common.core.utils.file.FileTypeUtils; +import com.ruoyi.common.core.utils.file.MimeTypeUtils; +import com.ruoyi.common.core.utils.uuid.Seq; + +/** + * 文件上传工具类 + * + * @author ruoyi + */ +public class FileUploadUtils +{ + /** + * 默认大小 50M + */ + public static final long DEFAULT_MAX_SIZE = 50 * 1024 * 1024L; + + /** + * 默认的文件名最大长度 100 + */ + public static final int DEFAULT_FILE_NAME_LENGTH = 100; + + /** + * 根据文件路径上传 + * + * @param baseDir 相对应用的基目录 + * @param file 上传的文件 + * @return 文件名称 + * @throws IOException + */ + public static final String upload(String baseDir, MultipartFile file) throws IOException + { + try + { + return upload(baseDir, file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION); + } + catch (FileException fe) + { + throw new IOException(fe.getDefaultMessage(), fe); + } + catch (Exception e) + { + throw new IOException(e.getMessage(), e); + } + } + + /** + * 文件上传 + * + * @param baseDir 相对应用的基目录 + * @param file 上传的文件 + * @param allowedExtension 上传文件类型 + * @return 返回上传成功的文件名 + * @throws FileSizeLimitExceededException 如果超出最大大小 + * @throws FileNameLengthLimitExceededException 文件名太长 + * @throws IOException 比如读写文件出错时 + * @throws InvalidExtensionException 文件校验异常 + */ + public static final String upload(String baseDir, MultipartFile file, String[] allowedExtension) + throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException, + InvalidExtensionException + { + int fileNamelength = Objects.requireNonNull(file.getOriginalFilename()).length(); + if (fileNamelength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH) + { + throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH); + } + + assertAllowed(file, allowedExtension); + + String fileName = extractFilename(file); + + String absPath = getAbsoluteFile(baseDir, fileName).getAbsolutePath(); + file.transferTo(Paths.get(absPath)); + return getPathFileName(fileName); + } + + /** + * 编码文件名 + */ + public static final String extractFilename(MultipartFile file) + { + return StringUtils.format("{}/{}_{}.{}", DateUtils.datePath(), + FilenameUtils.getBaseName(file.getOriginalFilename()), Seq.getId(Seq.uploadSeqType), FileTypeUtils.getExtension(file)); + } + + private static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException + { + File desc = new File(uploadDir + File.separator + fileName); + + if (!desc.exists()) + { + if (!desc.getParentFile().exists()) + { + desc.getParentFile().mkdirs(); + } + } + return desc.isAbsolute() ? desc : desc.getAbsoluteFile(); + } + + private static final String getPathFileName(String fileName) throws IOException + { + String pathFileName = "/" + fileName; + return pathFileName; + } + + /** + * 文件大小校验 + * + * @param file 上传的文件 + * @throws FileSizeLimitExceededException 如果超出最大大小 + * @throws InvalidExtensionException 文件校验异常 + */ + public static final void assertAllowed(MultipartFile file, String[] allowedExtension) + throws FileSizeLimitExceededException, InvalidExtensionException + { + long size = file.getSize(); + if (size > DEFAULT_MAX_SIZE) + { + throw new FileSizeLimitExceededException(DEFAULT_MAX_SIZE / 1024 / 1024); + } + + String fileName = file.getOriginalFilename(); + String extension = FileTypeUtils.getExtension(file); + if (allowedExtension != null && !isAllowedExtension(extension, allowedExtension)) + { + if (allowedExtension == MimeTypeUtils.IMAGE_EXTENSION) + { + throw new InvalidExtensionException.InvalidImageExtensionException(allowedExtension, extension, + fileName); + } + else if (allowedExtension == MimeTypeUtils.FLASH_EXTENSION) + { + throw new InvalidExtensionException.InvalidFlashExtensionException(allowedExtension, extension, + fileName); + } + else if (allowedExtension == MimeTypeUtils.MEDIA_EXTENSION) + { + throw new InvalidExtensionException.InvalidMediaExtensionException(allowedExtension, extension, + fileName); + } + else if (allowedExtension == MimeTypeUtils.VIDEO_EXTENSION) + { + throw new InvalidExtensionException.InvalidVideoExtensionException(allowedExtension, extension, + fileName); + } + else + { + throw new InvalidExtensionException(allowedExtension, extension, fileName); + } + } + } + + /** + * 判断MIME类型是否是允许的MIME类型 + * + * @param extension 上传文件类型 + * @param allowedExtension 允许上传文件类型 + * @return true/false + */ + public static final boolean isAllowedExtension(String extension, String[] allowedExtension) + { + for (String str : allowedExtension) + { + if (str.equalsIgnoreCase(extension)) + { + return true; + } + } + return false; + } } \ No newline at end of file diff --git a/ruoyi-modules/ruoyi-file/src/main/resources/bootstrap.yml b/ruoyi-modules/ruoyi-file/src/main/resources/bootstrap.yml index 55ff4112..fc025647 100644 --- a/ruoyi-modules/ruoyi-file/src/main/resources/bootstrap.yml +++ b/ruoyi-modules/ruoyi-file/src/main/resources/bootstrap.yml @@ -14,10 +14,12 @@ spring: nacos: discovery: # 服务注册地址 - server-addr: 127.0.0.1:8848 + server-addr: 47.109.135.151:8848 + namespace: b8ad3fd2-18ea-4cdf-a82c-4ce483392b1a config: # 配置中心地址 - server-addr: 127.0.0.1:8848 + server-addr: 47.109.135.151:8848 + namespace: b8ad3fd2-18ea-4cdf-a82c-4ce483392b1a # 配置文件格式 file-extension: yml # 共享配置 diff --git a/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/RuoYiGenApplication.java b/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/RuoYiGenApplication.java index 248ee76d..730f79e6 100644 --- a/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/RuoYiGenApplication.java +++ b/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/RuoYiGenApplication.java @@ -18,15 +18,6 @@ public class RuoYiGenApplication public static void main(String[] args) { SpringApplication.run(RuoYiGenApplication.class, args); - System.out.println("(♥◠‿◠)ノ゙ 代码生成模块启动成功 ლ(´ڡ`ლ)゙ \n" + - " .-------. ____ __ \n" + - " | _ _ \\ \\ \\ / / \n" + - " | ( ' ) | \\ _. / ' \n" + - " |(_ o _) / _( )_ .' \n" + - " | (_,_).' __ ___(_ o _)' \n" + - " | |\\ \\ | || |(_,_)' \n" + - " | | \\ `' /| `-' / \n" + - " | | \\ / \\ / \n" + - " ''-' `'-' `-..-' "); + System.out.println("(♥◠‿◠)ノ゙ 代码生成模块启动成功 ლ(´ڡ`ლ)゙ \n"); } } diff --git a/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/util/GenUtils.java b/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/util/GenUtils.java index 2c1c5317..70aabeb0 100644 --- a/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/util/GenUtils.java +++ b/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/util/GenUtils.java @@ -215,7 +215,7 @@ public class GenUtils */ public static String replaceText(String text) { - return RegExUtils.replaceAll(text, "(?:表|若依)", ""); + return RegExUtils.replaceAll(text, "(?:表|租研舍)", ""); } /** diff --git a/ruoyi-modules/ruoyi-gen/src/main/resources/bootstrap.yml b/ruoyi-modules/ruoyi-gen/src/main/resources/bootstrap.yml index 0ef5a457..82f5eac8 100644 --- a/ruoyi-modules/ruoyi-gen/src/main/resources/bootstrap.yml +++ b/ruoyi-modules/ruoyi-gen/src/main/resources/bootstrap.yml @@ -14,10 +14,12 @@ spring: nacos: discovery: # 服务注册地址 - server-addr: 127.0.0.1:8848 + server-addr: 47.109.135.151:8848 + namespace: b8ad3fd2-18ea-4cdf-a82c-4ce483392b1a config: # 配置中心地址 - server-addr: 127.0.0.1:8848 + server-addr: 47.109.135.151:8848 + namespace: b8ad3fd2-18ea-4cdf-a82c-4ce483392b1a # 配置文件格式 file-extension: yml # 共享配置 diff --git a/ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/RuoYiJobApplication.java b/ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/RuoYiJobApplication.java index a5869e62..210f35c2 100644 --- a/ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/RuoYiJobApplication.java +++ b/ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/RuoYiJobApplication.java @@ -18,15 +18,6 @@ public class RuoYiJobApplication public static void main(String[] args) { SpringApplication.run(RuoYiJobApplication.class, args); - System.out.println("(♥◠‿◠)ノ゙ 定时任务模块启动成功 ლ(´ڡ`ლ)゙ \n" + - " .-------. ____ __ \n" + - " | _ _ \\ \\ \\ / / \n" + - " | ( ' ) | \\ _. / ' \n" + - " |(_ o _) / _( )_ .' \n" + - " | (_,_).' __ ___(_ o _)' \n" + - " | |\\ \\ | || |(_,_)' \n" + - " | | \\ `' /| `-' / \n" + - " | | \\ / \\ / \n" + - " ''-' `'-' `-..-' "); + System.out.println("(♥◠‿◠)ノ゙ 定时任务模块启动成功 ლ(´ڡ`ლ)゙ \n"); } } diff --git a/ruoyi-modules/ruoyi-job/src/main/resources/bootstrap.yml b/ruoyi-modules/ruoyi-job/src/main/resources/bootstrap.yml index b86f8c9e..955c5fe1 100644 --- a/ruoyi-modules/ruoyi-job/src/main/resources/bootstrap.yml +++ b/ruoyi-modules/ruoyi-job/src/main/resources/bootstrap.yml @@ -14,10 +14,12 @@ spring: nacos: discovery: # 服务注册地址 - server-addr: 127.0.0.1:8848 + server-addr: 47.109.135.151:8848 + namespace: b8ad3fd2-18ea-4cdf-a82c-4ce483392b1a config: # 配置中心地址 - server-addr: 127.0.0.1:8848 + server-addr: 47.109.135.151:8848 + namespace: b8ad3fd2-18ea-4cdf-a82c-4ce483392b1a # 配置文件格式 file-extension: yml # 共享配置 diff --git a/ruoyi-modules/ruoyi-system/pom.xml b/ruoyi-modules/ruoyi-system/pom.xml index 0d9795a7..9af35a97 100644 --- a/ruoyi-modules/ruoyi-system/pom.xml +++ b/ruoyi-modules/ruoyi-system/pom.xml @@ -71,6 +71,22 @@ ruoyi-common-swagger + + com.baomidou + mybatis-plus-boot-starter + + + + org.springframework.boot + spring-boot-starter-test + + + + com.ruoyi + ruoyi-common-sms + 3.6.4 + + diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/RuoYiSystemApplication.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/RuoYiSystemApplication.java index 3f33217c..1963f0cc 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/RuoYiSystemApplication.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/RuoYiSystemApplication.java @@ -1,9 +1,14 @@ package com.ruoyi.system; +import org.apache.tomcat.util.http.LegacyCookieProcessor; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import com.ruoyi.common.security.annotation.EnableCustomConfig; import com.ruoyi.common.security.annotation.EnableRyFeignClients; +import org.springframework.boot.web.embedded.tomcat.TomcatContextCustomizer; +import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; +import org.springframework.boot.web.server.WebServerFactoryCustomizer; +import org.springframework.context.annotation.Bean; /** * 系统模块 @@ -18,15 +23,14 @@ public class RuoYiSystemApplication public static void main(String[] args) { SpringApplication.run(RuoYiSystemApplication.class, args); - System.out.println("(♥◠‿◠)ノ゙ 系统模块启动成功 ლ(´ڡ`ლ)゙ \n" + - " .-------. ____ __ \n" + - " | _ _ \\ \\ \\ / / \n" + - " | ( ' ) | \\ _. / ' \n" + - " |(_ o _) / _( )_ .' \n" + - " | (_,_).' __ ___(_ o _)' \n" + - " | |\\ \\ | || |(_,_)' \n" + - " | | \\ `' /| `-' / \n" + - " | | \\ / \\ / \n" + - " ''-' `'-' `-..-' "); + System.out.println("(♥◠‿◠)ノ゙ 系统模块启动成功 ლ(´ڡ`ლ)゙ \n"); } + + @Bean + public WebServerFactoryCustomizer cookieProcessorCustomizer() { + return tomcatServletWebServerFactory -> tomcatServletWebServerFactory.addContextCustomizers((TomcatContextCustomizer) context -> { + context.setCookieProcessor(new LegacyCookieProcessor()); + }); + } + } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/config/SystemConfig.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/config/SystemConfig.java new file mode 100644 index 00000000..2d0ea6eb --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/config/SystemConfig.java @@ -0,0 +1,23 @@ +package com.ruoyi.system.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * Minio 配置信息 + * + * @author ruoyi + */ +@Configuration +@ConfigurationProperties(prefix = "system") +@Data +public class SystemConfig +{ + /** + * 加密密钥 + */ + private String AESkey; + +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/ChannelController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/ChannelController.java new file mode 100644 index 00000000..3901de0e --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/ChannelController.java @@ -0,0 +1,109 @@ +package com.ruoyi.system.controller; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import com.ruoyi.common.log.annotation.Log; +import com.ruoyi.common.log.enums.BusinessType; +import com.ruoyi.common.security.annotation.RequiresPermissions; +import com.ruoyi.common.core.domain.http.Channel; +import com.ruoyi.system.service.IChannelService; +import com.ruoyi.common.core.web.controller.BaseController; +import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.common.core.utils.poi.ExcelUtil; +import com.ruoyi.common.core.web.page.TableDataInfo; + +/** + * 渠道配置Controller + * + * @author ruoyi + * @date 2024-09-15 + */ +@RestController +@RequestMapping("/channel") +public class ChannelController extends BaseController +{ + @Autowired + private IChannelService channelService; + + /** + * 查询渠道配置列表 + */ + @RequiresPermissions("system:channel:list") + @GetMapping("/list") + public TableDataInfo list(Channel channel) + { + startPage(); + List list = channelService.selectChannelList(channel); + return getDataTable(list); + } + + /** + * 导出渠道配置列表 + */ + @RequiresPermissions("system:channel:export") + @Log(title = "渠道配置", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, Channel channel) + { + List list = channelService.selectChannelList(channel); + ExcelUtil util = new ExcelUtil(Channel.class); + util.exportExcel(response, list, "渠道配置数据"); + } + + /** + * 获取渠道配置详细信息 + */ + @RequiresPermissions("system:channel:query") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(channelService.selectChannelById(id)); + } + + /** + * 新增渠道配置 + */ + @RequiresPermissions("system:channel:add") + @Log(title = "渠道配置", businessType = BusinessType.INSERT) + @RequestMapping(value = "/add", method = RequestMethod.POST) + public AjaxResult add(@RequestBody Channel channel) + { + return toAjax(channelService.insertChannel(channel)); + } + + /** + * 修改渠道配置 + */ + @RequiresPermissions("system:channel:edit") + @Log(title = "渠道配置", businessType = BusinessType.UPDATE) + @RequestMapping(value = "/edit", method = RequestMethod.POST) + public AjaxResult edit(@RequestBody Channel channel) + { + return toAjax(channelService.updateChannel(channel)); + } + + /** + * 删除渠道配置 + */ + @RequiresPermissions("system:channel:remove") + @Log(title = "渠道配置", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(channelService.deleteChannelByIds(ids)); + } + + /** + * 根据渠道标识获取渠道类型 + * @param sign + * @return + */ + @GetMapping("/getChannelBySign") + public AjaxResult getChannelBySign(@RequestParam("sign")String sign){ + return channelService.getChannelBySign(sign); + } + + +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/CommonController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/CommonController.java new file mode 100644 index 00000000..3cff17e4 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/CommonController.java @@ -0,0 +1,46 @@ +package com.ruoyi.system.controller; + +import com.ruoyi.common.core.domain.http.Channel; +import com.ruoyi.common.core.utils.poi.ExcelUtil; +import com.ruoyi.common.core.web.controller.BaseController; +import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.common.core.web.page.TableDataInfo; +import com.ruoyi.common.log.annotation.Log; +import com.ruoyi.common.log.enums.BusinessType; +import com.ruoyi.common.security.annotation.RequiresPermissions; +import com.ruoyi.system.service.IChannelService; +import com.ruoyi.system.service.ICommonService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.List; + +/** + * 渠道配置Controller + * + * @author ruoyi + * @date 2024-09-15 + */ +@RestController +@RequestMapping("/common") +public class CommonController extends BaseController +{ + @Autowired + private ICommonService commonService; + + + /** + * H5发送验证码 + * @param phone 手机号码 + * @return AjaxResult + */ + @GetMapping("/sendSms") + public AjaxResult sendSms(@RequestParam("phone")String phone, HttpServletRequest request){ + String header = request.getHeader("x-sms-source"); + return commonService.sendSms(phone,header); + } + + +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/CustomerApplyLogController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/CustomerApplyLogController.java new file mode 100644 index 00000000..3b90ee9d --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/CustomerApplyLogController.java @@ -0,0 +1,135 @@ +package com.ruoyi.system.controller; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; + +import com.ruoyi.common.core.constant.SecurityConstants; +import com.ruoyi.common.core.domain.GetSumDto; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.system.domain.dto.ApplyCallback; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import com.ruoyi.common.log.annotation.Log; +import com.ruoyi.common.log.enums.BusinessType; +import com.ruoyi.common.security.annotation.RequiresPermissions; +import com.ruoyi.common.core.domain.http.CustomerApplyLog; +import com.ruoyi.system.service.ICustomerApplyLogService; +import com.ruoyi.common.core.web.controller.BaseController; +import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.common.core.utils.poi.ExcelUtil; +import com.ruoyi.common.core.web.page.TableDataInfo; + +/** + * 客户申请记录Controller + * + * @author ruoyi + * @date 2024-09-15 + */ +@RestController +@RequestMapping("/log") +public class CustomerApplyLogController extends BaseController +{ + @Autowired + private ICustomerApplyLogService customerApplyLogService; + + /** + * 查询客户申请记录列表 + */ + @RequiresPermissions("system:log:list") + @GetMapping("/list") + public TableDataInfo list(CustomerApplyLog customerApplyLog) + { + startPage(); + List list = customerApplyLogService.selectCustomerApplyLogList(customerApplyLog); + return getDataTable(list); + } + + /** + * 获取商户今日已申请数 + * + * + * @param getSumDto + * @param source 请求来源 + * @return 结果 + */ + @PostMapping("/sum") + public R sum(@RequestBody GetSumDto getSumDto, @RequestHeader(SecurityConstants.FROM_SOURCE) String source){ + return R.ok(customerApplyLogService.getApplySum(getSumDto.getMerchantId())); + } + + /** + * 获取用户今日是否是否已申请 + * + * + * @param customerID + * @param source 请求来源 + * @return 结果 + */ + @GetMapping("/customerApply") + public R customerApply(@RequestParam("customerID") Long customerID,@RequestHeader(SecurityConstants.FROM_SOURCE) String source){ + return customerApplyLogService.getCustomerApply(customerID); + } + /** + * 导出客户申请记录列表 + */ + @RequiresPermissions("system:log:export") + @Log(title = "客户申请记录", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, CustomerApplyLog customerApplyLog) + { + List list = customerApplyLogService.selectCustomerApplyLogList(customerApplyLog); + ExcelUtil util = new ExcelUtil(CustomerApplyLog.class); + util.exportExcel(response, list, "客户申请记录数据"); + } + + /** + * 获取客户申请记录详细信息 + */ + @RequiresPermissions("system:log:query") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(customerApplyLogService.selectCustomerApplyLogById(id)); + } + + /** + * 新增客户申请记录 + */ + @RequiresPermissions("system:log:add") + @Log(title = "客户申请记录", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody CustomerApplyLog customerApplyLog) + { + return toAjax(customerApplyLogService.insertCustomerApplyLog(customerApplyLog)); + } + + /** + * 修改客户申请记录 + */ + @RequiresPermissions("system:log:edit") + @Log(title = "客户申请记录", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody CustomerApplyLog customerApplyLog) + { + return toAjax(customerApplyLogService.updateCustomerApplyLog(customerApplyLog)); + } + + /** + * 删除客户申请记录 + */ + @RequiresPermissions("system:log:remove") + @Log(title = "客户申请记录", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(customerApplyLogService.deleteCustomerApplyLogByIds(ids)); + } + + /** + * 下游数据回调 + */ + @PostMapping("/applyCallback") + public AjaxResult applyCallback(@RequestBody ApplyCallback applyCallback){ + return customerApplyLogService.applyCallBack(applyCallback); + } +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/CustomerController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/CustomerController.java new file mode 100644 index 00000000..e9f2a604 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/CustomerController.java @@ -0,0 +1,184 @@ +package com.ruoyi.system.controller; + +import java.util.List; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import com.ruoyi.common.core.constant.SecurityConstants; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.system.service.IMerchantService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import com.ruoyi.common.log.annotation.Log; +import com.ruoyi.common.log.enums.BusinessType; +import com.ruoyi.common.security.annotation.RequiresPermissions; +import com.ruoyi.common.core.domain.http.Customer; +import com.ruoyi.system.service.ICustomerService; +import com.ruoyi.common.core.web.controller.BaseController; +import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.common.core.utils.poi.ExcelUtil; +import com.ruoyi.common.core.web.page.TableDataInfo; + +/** + * 客户信息Controller + * + * @author ruoyi + * @date 2024-09-15 + */ +@RestController +@RequestMapping("/customer") +public class CustomerController extends BaseController +{ + @Autowired + private ICustomerService customerService; + + @Autowired + private IMerchantService merchantService; + + /** + * 查询客户信息列表 + */ + @RequiresPermissions("system:customer:list") + @GetMapping("/list") + public TableDataInfo list(Customer customer) + { + startPage(); + List list = customerService.selectCustomerList(customer); + return getDataTable(list); + } + + /** + * 导出客户信息列表 + */ + @RequiresPermissions("system:customer:export") + @Log(title = "客户信息", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, Customer customer) + { + List list = customerService.selectCustomerList(customer); + ExcelUtil util = new ExcelUtil(Customer.class); + util.exportExcel(response, list, "客户信息数据"); + } + + /** + * 获取客户信息详细信息 + */ + @RequiresPermissions("system:customer:query") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(customerService.selectCustomerById(id)); + } + + /** + * 通过手机号MD5查询用户信息 + * + * @param phoneMD5 用户名 + * @return 结果 + */ + @GetMapping("/getByMd5") + public R getCustomerInfoByPhoneMd5(@RequestParam("phoneMD5")String phoneMD5){ + return customerService.selectByPhoneMd5(phoneMD5); + } + + /** + * 通过手机号MD5更新用户信息 + * + * @param customer 用户 + * @return 结果 + */ + @PostMapping("/updateByPhoneMd5") + public R updateByPhoneMd5(@RequestBody Customer customer ,@RequestHeader(SecurityConstants.FROM_SOURCE) String source){ + return customerService.updateByPhoneMd5(customer); + } + + /** + * 新增客户信息 + * @return + */ + @PostMapping("/addNewCustomer") + public R add(@RequestBody Customer customer,@RequestHeader(SecurityConstants.FROM_SOURCE) String source){ + boolean save = customerService.save(customer); + if (save){ + return R.ok(); + } + return R.fail(); + } + /** + * 新增客户信息 + */ + @RequiresPermissions("system:customer:add") + @Log(title = "客户信息", businessType = BusinessType.INSERT) + @RequestMapping(value = "/add", method = RequestMethod.POST) + public AjaxResult add(@RequestBody Customer customer) + { + return toAjax(customerService.insertCustomer(customer)); + } + + /** + * 修改客户信息 + */ + @RequiresPermissions("system:customer:edit") + @Log(title = "客户信息", businessType = BusinessType.UPDATE) + @RequestMapping(value = "/edit", method = RequestMethod.POST) + public AjaxResult edit(@RequestBody Customer customer) + { + return toAjax(customerService.updateCustomer(customer)); + } + + /** + * 删除客户信息 + */ + @RequiresPermissions("system:customer:remove") + @Log(title = "客户信息", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(customerService.deleteCustomerByIds(ids)); + } + + /** + * 获取用户token + * @param phone + * @return + */ + @GetMapping("/getCustomerToken") + public String getCustomerToken(@RequestParam("phone") String phone,@RequestParam("channelId")Long channelId) { + return customerService.getCustomerToken(phone); + } + + + /** + * H5用户登录 + */ + @GetMapping("/customerLogin") + public AjaxResult customerLogin(@RequestParam("phone")String phone,@RequestParam("code")Integer code,HttpServletRequest request){ + return customerService.customerLogin(phone,code,request); + } + + /** + * H5保存用户留资信息 + */ + @PostMapping("/saveCustomerInfo") + public AjaxResult saveCustomerInfo(@RequestBody Customer customer, HttpServletRequest request){ + return customerService.saveCustomerInfo(customer,request); + } + + + + /** + * 获取商户下渠道列表 + * @return + */ + @RequestMapping(value = "/getAllMerchantList", method = RequestMethod.GET) + public AjaxResult getAllMerchantList() + { + return success(merchantService.findAllMerchantList()); + } + + + @PostMapping("/v1/saveCustomerInfo") + public AjaxResult v1SaveCustomerInfo(@RequestBody Customer customer, HttpServletRequest request){ + return customerService.v1SaveCustomerInfo(customer,request); + } +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/MerchantController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/MerchantController.java new file mode 100644 index 00000000..01e2c0a9 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/MerchantController.java @@ -0,0 +1,157 @@ +package com.ruoyi.system.controller; + +import java.util.List; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import com.ruoyi.common.core.constant.SecurityConstants; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.system.domain.dto.ApplyCallback; +import com.ruoyi.system.service.IChannelService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import com.ruoyi.common.log.annotation.Log; +import com.ruoyi.common.log.enums.BusinessType; +import com.ruoyi.common.security.annotation.RequiresPermissions; +import com.ruoyi.common.core.domain.http.Merchant; +import com.ruoyi.system.service.IMerchantService; +import com.ruoyi.common.core.web.controller.BaseController; +import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.common.core.utils.poi.ExcelUtil; +import com.ruoyi.common.core.web.page.TableDataInfo; + +/** + * 商户Controller + * + * @author ruoyi + * @date 2024-09-15 + */ +@RestController +@RequestMapping("/merchant") +public class MerchantController extends BaseController +{ + @Autowired + private IMerchantService merchantService; + + @Autowired + private IChannelService channelService; + + /** + * 查询商户列表 + */ + @RequiresPermissions("system:merchant:list") + @GetMapping("/list") + public TableDataInfo list(Merchant merchant) + { + startPage(); + List list = merchantService.selectMerchantList(merchant); + return getDataTable(list); + } + + /** + * 获取合适的产品 + * + * @return 结果 + */ + @GetMapping("/merchantList") + public R> merchantList(){ + return merchantService.getMerchantList(); + } + + /** + * 导出商户列表 + */ + @RequiresPermissions("system:merchant:export") + @Log(title = "商户", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, Merchant merchant) + { + List list = merchantService.selectMerchantList(merchant); + ExcelUtil util = new ExcelUtil(Merchant.class); + util.exportExcel(response, list, "商户数据"); + } + + /** + * 获取商户详细信息 + */ + @RequiresPermissions("system:merchant:query") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(merchantService.selectMerchantById(id)); + } + + /** + * 获取商户下渠道列表 + * @return + */ + @GetMapping("/getMerchantChannelList") + public AjaxResult getMerchantChannelList() + { + return success(channelService.findAllChannelList()); + } + + + /** + * 新增商户 + */ + @RequiresPermissions("system:merchant:add") + @Log(title = "商户", businessType = BusinessType.INSERT) + @RequestMapping(value = "/add", method = RequestMethod.POST) + public AjaxResult add(@RequestBody Merchant merchant) + { + return toAjax(merchantService.insertMerchant(merchant)); + } + + /** + * 修改商户 + */ + @RequiresPermissions("system:merchant:edit") + @Log(title = "商户", businessType = BusinessType.UPDATE) + @RequestMapping(value = "/edit", method = RequestMethod.POST) + public AjaxResult edit(@RequestBody Merchant merchant) + { + return toAjax(merchantService.updateMerchant(merchant)); + } + + /** + * 删除商户 + */ + @RequiresPermissions("system:merchant:remove") + @Log(title = "商户", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(merchantService.deleteMerchantByIds(ids)); + } + + + /** + * 获取合适的产品 + */ + @GetMapping("/getMatchMerchant") + public AjaxResult getMatchMerchantList(HttpServletRequest request){ + return merchantService.getMatchMerchantList(request); + } + + /** + * H5申请商户 + */ + @GetMapping("/h5applyMerchant") + public AjaxResult H5applyMerchant(@RequestParam("merchantId") String merchantId,HttpServletRequest request){ + return merchantService.H5applyMerchant(Long.valueOf(merchantId),request); + } + + @GetMapping("/getMatchMerchantNew") + public AjaxResult getMatchMerchantNew(){ + return merchantService.getMatchMerchantNew(); + } + + + @GetMapping("/v1/getMatchMerchant") + public AjaxResult V1GetMatchMerchant(HttpServletRequest request){ + return merchantService.V1GetMatchMerchant(request); + } + + +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/ApplyCallback.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/ApplyCallback.java new file mode 100644 index 00000000..3e50a26d --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/ApplyCallback.java @@ -0,0 +1,11 @@ +package com.ruoyi.system.domain.dto; + +import lombok.Data; + +@Data +public class ApplyCallback { + + private String sign; + + private String Data; +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/ApplyCallbackDto.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/ApplyCallbackDto.java new file mode 100644 index 00000000..a00cb9ef --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/ApplyCallbackDto.java @@ -0,0 +1,23 @@ +package com.ruoyi.system.domain.dto; + +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class ApplyCallbackDto { + + + //订单号 + private String orderNo; + + //md5 + private String md5; + + //订单价格 + private BigDecimal price; + + //订单状态 + private Integer orderStatus; + +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/MerchantListDto.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/MerchantListDto.java new file mode 100644 index 00000000..466fd550 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/MerchantListDto.java @@ -0,0 +1,19 @@ +package com.ruoyi.system.domain.dto; + +import lombok.Data; + +@Data +public class MerchantListDto { + + //商户名 + private String merchantName; + + //商户跳转地址 + private String merchantUrl; + + //商户描述 + private String merchantDescribe; + + //商户ID + private Long merchantId; +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/ChannelMapper.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/ChannelMapper.java new file mode 100644 index 00000000..07560c50 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/ChannelMapper.java @@ -0,0 +1,69 @@ +package com.ruoyi.system.mapper; + +import java.util.List; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.common.core.domain.http.Channel; + +/** + * 渠道配置Mapper接口 + * + * @author ruoyi + * @date 2024-09-15 + */ +public interface ChannelMapper extends BaseMapper +{ + /** + * 查询渠道配置 + * + * @param id 渠道配置主键 + * @return 渠道配置 + */ + public Channel selectChannelById(Long id); + + /** + * 查询渠道配置列表 + * + * @param channel 渠道配置 + * @return 渠道配置集合 + */ + public List selectChannelList(Channel channel); + + /** + * 新增渠道配置 + * + * @param channel 渠道配置 + * @return 结果 + */ + public int insertChannel(Channel channel); + + /** + * 修改渠道配置 + * + * @param channel 渠道配置 + * @return 结果 + */ + public int updateChannel(Channel channel); + + /** + * 删除渠道配置 + * + * @param id 渠道配置主键 + * @return 结果 + */ + public int deleteChannelById(Long id); + + /** + * 批量删除渠道配置 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteChannelByIds(Long[] ids); + + /** + * 查询渠道配置列表 + * @return 渠道配置集合 + */ + public List findAllChannelList(); +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/CustomerApplyLogMapper.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/CustomerApplyLogMapper.java new file mode 100644 index 00000000..d5e81e50 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/CustomerApplyLogMapper.java @@ -0,0 +1,63 @@ +package com.ruoyi.system.mapper; + +import java.util.List; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.common.core.domain.http.CustomerApplyLog; + +/** + * 客户申请记录Mapper接口 + * + * @author ruoyi + * @date 2024-09-15 + */ +public interface CustomerApplyLogMapper extends BaseMapper +{ + /** + * 查询客户申请记录 + * + * @param id 客户申请记录主键 + * @return 客户申请记录 + */ + public CustomerApplyLog selectCustomerApplyLogById(Long id); + + /** + * 查询客户申请记录列表 + * + * @param customerApplyLog 客户申请记录 + * @return 客户申请记录集合 + */ + public List selectCustomerApplyLogList(CustomerApplyLog customerApplyLog); + + /** + * 新增客户申请记录 + * + * @param customerApplyLog 客户申请记录 + * @return 结果 + */ + public int insertCustomerApplyLog(CustomerApplyLog customerApplyLog); + + /** + * 修改客户申请记录 + * + * @param customerApplyLog 客户申请记录 + * @return 结果 + */ + public int updateCustomerApplyLog(CustomerApplyLog customerApplyLog); + + /** + * 删除客户申请记录 + * + * @param id 客户申请记录主键 + * @return 结果 + */ + public int deleteCustomerApplyLogById(Long id); + + /** + * 批量删除客户申请记录 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteCustomerApplyLogByIds(Long[] ids); +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/CustomerMapper.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/CustomerMapper.java new file mode 100644 index 00000000..bcd9eab5 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/CustomerMapper.java @@ -0,0 +1,63 @@ +package com.ruoyi.system.mapper; + +import java.util.List; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.common.core.domain.http.Customer; + +/** + * 客户信息Mapper接口 + * + * @author ruoyi + * @date 2024-09-15 + */ +public interface CustomerMapper extends BaseMapper +{ + /** + * 查询客户信息 + * + * @param id 客户信息主键 + * @return 客户信息 + */ + public Customer selectCustomerById(Long id); + + /** + * 查询客户信息列表 + * + * @param customer 客户信息 + * @return 客户信息集合 + */ + public List selectCustomerList(Customer customer); + + /** + * 新增客户信息 + * + * @param customer 客户信息 + * @return 结果 + */ + public int insertCustomer(Customer customer); + + /** + * 修改客户信息 + * + * @param customer 客户信息 + * @return 结果 + */ + public int updateCustomer(Customer customer); + + /** + * 删除客户信息 + * + * @param id 客户信息主键 + * @return 结果 + */ + public int deleteCustomerById(Long id); + + /** + * 批量删除客户信息 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteCustomerByIds(Long[] ids); +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/MerchantMapper.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/MerchantMapper.java new file mode 100644 index 00000000..f7296b0d --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/MerchantMapper.java @@ -0,0 +1,71 @@ +package com.ruoyi.system.mapper; + +import java.util.List; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.common.core.domain.http.Customer; +import com.ruoyi.common.core.domain.http.Merchant; + +/** + * 商户Mapper接口 + * + * @author ruoyi + * @date 2024-09-15 + */ +public interface MerchantMapper extends BaseMapper +{ + /** + * 查询商户 + * + * @param id 商户主键 + * @return 商户 + */ + public Merchant selectMerchantById(Long id); + + /** + * 查询商户列表 + * + * @param merchant 商户 + * @return 商户集合 + */ + public List selectMerchantList(Merchant merchant); + + /** + * 新增商户 + * + * @param merchant 商户 + * @return 结果 + */ + public int insertMerchant(Merchant merchant); + + /** + * 修改商户 + * + * @param merchant 商户 + * @return 结果 + */ + public int updateMerchant(Merchant merchant); + + /** + * 删除商户 + * + * @param id 商户主键 + * @return 结果 + */ + public int deleteMerchantById(Long id); + + /** + * 批量删除商户 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteMerchantByIds(Long[] ids); + + /** + * 获取商户列表 + * @return + */ + public List findAllMerchantList(); + + } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/process/ProcessHandler.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/process/ProcessHandler.java new file mode 100644 index 00000000..5ae449f0 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/process/ProcessHandler.java @@ -0,0 +1,12 @@ +package com.ruoyi.system.process; + +import com.ruoyi.common.core.web.domain.AjaxResult; + +/** + *根据流程类型 执行不同的处理器 + */ +public interface ProcessHandler { + + + AjaxResult invoke(); +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/process/enums/ProcessHandlerEnum.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/process/enums/ProcessHandlerEnum.java new file mode 100644 index 00000000..c2c53f2b --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/process/enums/ProcessHandlerEnum.java @@ -0,0 +1,36 @@ +package com.ruoyi.system.process.enums; + +import com.ruoyi.common.core.exception.ServiceException; + +public enum ProcessHandlerEnum { + + H5_HANDLER("H5_HANDLER", "H5Handler"), + HALF_HANDLER("HALF_HANDLER", "HalfHandler"); + final String code; + + final String name; + + public String getCode() { + return code; + } + + public String getName() { + return name; + } + + ProcessHandlerEnum(String code, String name) { + this.code = code; + this.name = name; + } + + public static String getNameByCode(String code) { + ProcessHandlerEnum[] processHandlerEnums = values(); + for (ProcessHandlerEnum processHandlerEnum : processHandlerEnums) { + if (processHandlerEnum.getCode().equals(code)) { + return processHandlerEnum.getName(); + } + } + String msg = String.format("请检查对应的流程处理器是否实现,编码为:%s", code); + throw new ServiceException(msg, 500); + } +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/process/handler/H5Handler.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/process/handler/H5Handler.java new file mode 100644 index 00000000..e7bbf24c --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/process/handler/H5Handler.java @@ -0,0 +1,14 @@ +package com.ruoyi.system.process.handler; + +import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.system.process.ProcessHandler; +import org.springframework.stereotype.Component; + +@Component(value = "H5Handler") +public class H5Handler implements ProcessHandler { + @Override + public AjaxResult invoke() { + return null; + + } +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/process/handler/HalfHandler.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/process/handler/HalfHandler.java new file mode 100644 index 00000000..a20a6877 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/process/handler/HalfHandler.java @@ -0,0 +1,13 @@ +package com.ruoyi.system.process.handler; + +import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.system.process.ProcessHandler; +import org.springframework.stereotype.Component; + +@Component(value = "HalfHandler") +public class HalfHandler implements ProcessHandler { + @Override + public AjaxResult invoke() { + return null; + } +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/process/package-info.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/process/package-info.java new file mode 100644 index 00000000..b5f86171 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/process/package-info.java @@ -0,0 +1 @@ +package com.ruoyi.system.process; \ No newline at end of file diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/IChannelService.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/IChannelService.java new file mode 100644 index 00000000..83ebbc13 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/IChannelService.java @@ -0,0 +1,75 @@ +package com.ruoyi.system.service; + +import java.util.List; +import com.ruoyi.common.core.domain.http.Channel; +import com.ruoyi.common.core.web.domain.AjaxResult; + +/** + * 渠道配置Service接口 + * + * @author ruoyi + * @date 2024-09-15 + */ +public interface IChannelService +{ + /** + * 查询渠道配置 + * + * @param id 渠道配置主键 + * @return 渠道配置 + */ + public Channel selectChannelById(Long id); + + /** + * 查询渠道配置列表 + * + * @param channel 渠道配置 + * @return 渠道配置集合 + */ + public List selectChannelList(Channel channel); + + /** + * 新增渠道配置 + * + * @param channel 渠道配置 + * @return 结果 + */ + public long insertChannel(Channel channel); + + /** + * 修改渠道配置 + * + * @param channel 渠道配置 + * @return 结果 + */ + public int updateChannel(Channel channel); + + /** + * 批量删除渠道配置 + * + * @param ids 需要删除的渠道配置主键集合 + * @return 结果 + */ + public int deleteChannelByIds(Long[] ids); + + /** + * 删除渠道配置信息 + * + * @param id 渠道配置主键 + * @return 结果 + */ + public int deleteChannelById(Long id); + + /** + * 获取所有的渠道列表 + * @return + */ + public List findAllChannelList(); + + /** + * 根据渠道标识获取渠道 + * @param sign + * @return + */ + AjaxResult getChannelBySign(String sign); +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ICommonService.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ICommonService.java new file mode 100644 index 00000000..e2a04094 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ICommonService.java @@ -0,0 +1,24 @@ +package com.ruoyi.system.service; + +import com.ruoyi.common.core.domain.http.Channel; +import com.ruoyi.common.core.web.domain.AjaxResult; + +import java.util.List; + +/** + * 渠道配置Service接口 + * + * @author ruoyi + * @date 2024-09-15 + */ +public interface ICommonService +{ + + + /** + * H5发送验证码 + * @param phone + * @return + */ + AjaxResult sendSms(String phone,String smsSource); +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ICustomerApplyLogService.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ICustomerApplyLogService.java new file mode 100644 index 00000000..8dd4788f --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ICustomerApplyLogService.java @@ -0,0 +1,87 @@ +package com.ruoyi.system.service; + +import java.util.List; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.core.domain.http.CustomerApplyLog; +import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.system.domain.dto.ApplyCallback; + +/** + * 客户申请记录Service接口 + * + * @author ruoyi + * @date 2024-09-15 + */ +public interface ICustomerApplyLogService extends IService +{ + /** + * 查询客户申请记录 + * + * @param id 客户申请记录主键 + * @return 客户申请记录 + */ + public CustomerApplyLog selectCustomerApplyLogById(Long id); + + /** + * 查询客户申请记录列表 + * + * @param customerApplyLog 客户申请记录 + * @return 客户申请记录集合 + */ + public List selectCustomerApplyLogList(CustomerApplyLog customerApplyLog); + + /** + * 新增客户申请记录 + * + * @param customerApplyLog 客户申请记录 + * @return 结果 + */ + public int insertCustomerApplyLog(CustomerApplyLog customerApplyLog); + + /** + * 修改客户申请记录 + * + * @param customerApplyLog 客户申请记录 + * @return 结果 + */ + public int updateCustomerApplyLog(CustomerApplyLog customerApplyLog); + + /** + * 批量删除客户申请记录 + * + * @param ids 需要删除的客户申请记录主键集合 + * @return 结果 + */ + public int deleteCustomerApplyLogByIds(Long[] ids); + + /** + * 删除客户申请记录信息 + * + * @param id 客户申请记录主键 + * @return 结果 + */ + public int deleteCustomerApplyLogById(Long id); + + /** + * 获取当日商户已申请数 + * @param merchantId + * @return + */ + Integer getApplySum(Long merchantId); + + /** + * 获取用户今日是否是否已申请 + * @param customerID + * @return + */ + R getCustomerApply(Long customerID); + + /** + * 申请回调 + * @param applyCallback + * @return + */ + AjaxResult applyCallBack(ApplyCallback applyCallback); +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ICustomerService.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ICustomerService.java new file mode 100644 index 00000000..17d3bf69 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ICustomerService.java @@ -0,0 +1,114 @@ +package com.ruoyi.system.service; + +import java.util.List; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.core.domain.http.Customer; +import com.ruoyi.common.core.web.domain.AjaxResult; + +import javax.servlet.http.HttpServletRequest; + +/** + * 客户信息Service接口 + * + * @author ruoyi + * @date 2024-09-15 + */ +public interface ICustomerService extends IService +{ + /** + * 查询客户信息 + * + * @param id 客户信息主键 + * @return 客户信息 + */ + public Customer selectCustomerById(Long id); + + /** + * 查询客户信息列表 + * + * @param customer 客户信息 + * @return 客户信息集合 + */ + public List selectCustomerList(Customer customer); + + /** + * 新增客户信息 + * + * @param customer 客户信息 + * @return 结果 + */ + public int insertCustomer(Customer customer); + + /** + * 修改客户信息 + * + * @param customer 客户信息 + * @return 结果 + */ + public int updateCustomer(Customer customer); + + /** + * 批量删除客户信息 + * + * @param ids 需要删除的客户信息主键集合 + * @return 结果 + */ + public int deleteCustomerByIds(Long[] ids); + + /** + * 删除客户信息信息 + * + * @param id 客户信息主键 + * @return 结果 + */ + public int deleteCustomerById(Long id); + + /** + * 根据手机好MD5查询用户 + * @param phoneMD5 + * @return + */ + R selectByPhoneMd5(String phoneMD5); + + /** + * 通过手机号更新用户信息 + * @param customer + * @return + */ + R updateByPhoneMd5(Customer customer); + + /** + * 获取用户tooken + * @param phone + * @return + */ + String getCustomerToken(String phone); + + /** + * 注册并返回token + * @param phone + * @return + */ + public String registAndretrunToken(String phone,Long channelId); + + /** + * h5用户登录 + * @param phone + * @param code + * @param request + * @return + */ + AjaxResult customerLogin(String phone, Integer code,HttpServletRequest request); + + /** + * 保存用户留资信息 + * @param customer + * @param request + * @return + */ + AjaxResult saveCustomerInfo(Customer customer, HttpServletRequest request); + + AjaxResult v1SaveCustomerInfo(Customer customer, HttpServletRequest request); +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/IMerchantService.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/IMerchantService.java new file mode 100644 index 00000000..e6b7e877 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/IMerchantService.java @@ -0,0 +1,98 @@ +package com.ruoyi.system.service; + +import java.util.List; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.core.domain.http.Customer; +import com.ruoyi.common.core.domain.http.Merchant; +import com.ruoyi.common.core.web.domain.AjaxResult; + +import javax.servlet.http.HttpServletRequest; + +/** + * 商户Service接口 + * + * @author ruoyi + * @date 2024-09-15 + */ +public interface IMerchantService extends IService +{ + /** + * 查询商户 + * + * @param id 商户主键 + * @return 商户 + */ + public Merchant selectMerchantById(Long id); + + /** + * 查询商户列表 + * + * @param merchant 商户 + * @return 商户集合 + */ + public List selectMerchantList(Merchant merchant); + + /** + * 新增商户 + * + * @param merchant 商户 + * @return 结果 + */ + public int insertMerchant(Merchant merchant); + + /** + * 修改商户 + * + * @param merchant 商户 + * @return 结果 + */ + public int updateMerchant(Merchant merchant); + + /** + * 批量删除商户 + * + * @param ids 需要删除的商户主键集合 + * @return 结果 + */ + public int deleteMerchantByIds(Long[] ids); + + /** + * 删除商户信息 + * + * @param id 商户主键 + * @return 结果 + */ + public int deleteMerchantById(Long id); + + /** + * 获取基本合适的商户 + * @return + */ + R> getMerchantList(); + + /** + * H5获取合适产品 + * @param request + * @return + */ + AjaxResult getMatchMerchantList(HttpServletRequest request); + /** + * 获取所有的商户列表 + * @return + */ + public List findAllMerchantList(); + + /** + * H5申请订单 + * @param merchantId + * @param request + * @return + */ + AjaxResult H5applyMerchant(Long merchantId, HttpServletRequest request); + + AjaxResult getMatchMerchantNew(); + + AjaxResult V1GetMatchMerchant(HttpServletRequest request); +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ChannelServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ChannelServiceImpl.java new file mode 100644 index 00000000..f33685b0 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ChannelServiceImpl.java @@ -0,0 +1,164 @@ +package com.ruoyi.system.service.impl; + +import java.util.List; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.ruoyi.common.core.constant.CacheConstants; +import com.ruoyi.common.core.utils.DateUtils; +import com.ruoyi.common.core.utils.StringUtils; +import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.common.redis.service.RedisService; +import com.ruoyi.system.mapper.ChannelMapper; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.RandomStringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.Cacheable; +import org.springframework.stereotype.Service; +import com.ruoyi.common.core.domain.http.Channel; +import com.ruoyi.system.service.IChannelService; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.PostConstruct; + +/** + * 渠道配置Service业务层处理 + * + * @author ruoyi + * @date 2024-09-15 + */ +@Service +@Slf4j +public class ChannelServiceImpl implements IChannelService +{ + @Autowired + private ChannelMapper channelMapper; + @Autowired + private RedisService redisService; + + @PostConstruct + public void init(){ + log.info("初始化渠道数据开始"); + List channels = channelMapper.selectList(new LambdaQueryWrapper()); + for (Channel channel:channels) { + redisService.deleteObject(CacheConstants.CHANNEL_ID+channel.getId()); + redisService.setCacheObject(CacheConstants.CHANNEL_ID+channel.getId(),channel); + redisService.deleteObject(CacheConstants.CHANNEL_SIGN+channel.getChannelSign()); + redisService.setCacheObject(CacheConstants.CHANNEL_SIGN+channel.getChannelSign(),channel); + } + } + + /** + * 查询渠道配置 + * + * @param id 渠道配置主键 + * @return 渠道配置 + */ + @Override + public Channel selectChannelById(Long id) + { + return channelMapper.selectChannelById(id); + } + + /** + * 查询渠道配置列表 + * + * @param channel 渠道配置 + * @return 渠道配置 + */ + @Override + public List selectChannelList(Channel channel) + { + return channelMapper.selectChannelList(channel); + } + + /** + * 新增渠道配置 + * + * @param channel 渠道配置 + * @return 结果 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public long insertChannel(Channel channel) + { + if (StringUtils.isEmpty(channel.getChannelSign())) { + channel.setChannelSign(RandomStringUtils.random(16, true, false)); + } + channel.setCreateTime(DateUtils.getNowDate()); + channel.setUpdateTime(DateUtils.getNowDate()); + long i = channelMapper.insertChannel(channel); + //新增插入缓存 + Channel channelById = channelMapper.selectChannelById(i); + redisService.setCacheObject(CacheConstants.CHANNEL_ID+i,channelById); + redisService.setCacheObject(CacheConstants.CHANNEL_SIGN+channel.getChannelSign(),channelById); + return i; + } + + /** + * 修改渠道配置 + * + * @param channel 渠道配置 + * @return 结果 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public int updateChannel(Channel channel) + { + channel.setUpdateTime(DateUtils.getNowDate()); + int i = channelMapper.updateChannel(channel); + + Channel channelById = channelMapper.selectChannelById(channel.getId()); + redisService.deleteObject(CacheConstants.CHANNEL_ID+channel.getId()); + redisService.deleteObject(CacheConstants.CHANNEL_SIGN+channel.getChannelSign()); + redisService.setCacheObject(CacheConstants.CHANNEL_ID+channel.getId(),channelById); + redisService.setCacheObject(CacheConstants.CHANNEL_SIGN+channel.getChannelSign(),channelById); + return i; + } + + /** + * 批量删除渠道配置 + * + * @param ids 需要删除的渠道配置主键 + * @return 结果 + */ + @Override + public int deleteChannelByIds(Long[] ids) + { + return channelMapper.deleteChannelByIds(ids); + } + + /** + * 删除渠道配置信息 + * + * @param id 渠道配置主键 + * @return 结果 + */ + @Override + public int deleteChannelById(Long id) + { + return channelMapper.deleteChannelById(id); + } + + /** + * 获取所有的渠道列表 + * @return + */ + //@Cacheable(value = "channel",key = "'channel:all'") + public List findAllChannelList(){ + return channelMapper.findAllChannelList(); + } + + /** + * 根据渠道标识获取渠道 + * @param sign + * @return + */ + @Override + public AjaxResult getChannelBySign(String sign) { + Channel channel = channelMapper.selectOne(new LambdaQueryWrapper().eq(Channel::getChannelSign, sign)); + if (channel==null||channel.getChannelSign()==null){ + return AjaxResult.error("渠道异常"); + } + return AjaxResult.success("获取成功",channel.getChannelType()); + } +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CommonServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CommonServiceImpl.java new file mode 100644 index 00000000..0232f8e9 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CommonServiceImpl.java @@ -0,0 +1,102 @@ +package com.ruoyi.system.service.impl; + +import com.ruoyi.common.core.constant.RedisConstant; +import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.common.redis.service.RedisService; +import com.ruoyi.common.sms.component.SmsComponent; +import com.ruoyi.system.service.ICommonService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Service; + +import java.security.SecureRandom; +import java.util.*; +import java.util.concurrent.TimeUnit; + +/** + * 渠道配置Service业务层处理 + * + * @author ruoyi + * @date 2024-09-15 + */ +@Service +public class CommonServiceImpl implements ICommonService { + @Autowired + private RedisService redisService; + + @Autowired + private SmsComponent smsComponent; + + + @Autowired + private Environment environment; + + + @Override + public AjaxResult sendSms(String phone, String smsSource) { + if (StringUtils.isEmpty(phone)) { + return AjaxResult.error("手机号未空"); + } + if (phone.length() != 11) { + return AjaxResult.error("手机号长度异常"); + } + //正式环境发送验证码 pc4位 h5注册页6位 + String code; + + // 判断是否为正式环境 + if (isProductionProfileActive()) { + //正式环境操作 + code = smsSource.equalsIgnoreCase("h5") ? generateCode(6) : generateCode(4); + // 发送短信 + Map params = new HashMap<>(); + params.put(phone, code); + smsComponent.sendP2PMsg(params); + } else { + // 非正式环境直接设置固定验证码 + code = smsSource.equalsIgnoreCase("h5") ? "123456" : "1234"; + } + //放入缓存 3分钟 + redisService.setCacheObject(RedisConstant.H5_LOGIN_CACHE + phone, code, 3 * 60L, TimeUnit.SECONDS); + return AjaxResult.success("发送成功"); + } + + /** + * 判断当前活跃环境是否是 正式环境 + * if (isProductionProfileActive()) { + * // 进行与生产环境相关的逻辑处理 + * } else { + * // 进行非生产环境的处理 + * } + * + * @return + */ + public boolean isProductionProfileActive() { + // 获取当前应用的活跃环境 + String[] activeProfiles = environment.getActiveProfiles(); + + // 定义线上环境列表 + List proList = new ArrayList<>(Arrays.asList("prod", "pro")); + + // 检查活跃环境是否包含在 proList 中 + for (String profile : activeProfiles) { + if (proList.contains(profile)) { + return true; // 如果有活跃环境在 proList 中,返回 true + } + } + return false; // 如果没有匹配的环境,返回 false + } + + /** + * 定义生成验证码的方法 + * + * @param length 验证码长度 + * @return + */ + private String generateCode(int length) { + SecureRandom secureRandom = new SecureRandom(); + int bound = (int) Math.pow(10, length); + int min = bound / 10; + return String.valueOf(secureRandom.nextInt(bound - min) + min); + } +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CustomerApplyLogServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CustomerApplyLogServiceImpl.java new file mode 100644 index 00000000..ebb6b15e --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CustomerApplyLogServiceImpl.java @@ -0,0 +1,179 @@ +package com.ruoyi.system.service.impl; + +import java.util.List; + +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.IService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.core.utils.DateUtils; +import com.ruoyi.common.core.utils.LocalDateTimeUtils; +import com.ruoyi.common.core.utils.SecureUtils; +import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.system.domain.dto.ApplyCallback; +import com.ruoyi.system.domain.dto.ApplyCallbackDto; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.system.mapper.CustomerApplyLogMapper; +import com.ruoyi.common.core.domain.http.CustomerApplyLog; +import com.ruoyi.system.service.ICustomerApplyLogService; +import org.springframework.util.StringUtils; + +/** + * 客户申请记录Service业务层处理 + * + * @author ruoyi + * @date 2024-09-15 + */ +@Service +@Slf4j +public class CustomerApplyLogServiceImpl extends ServiceImpl implements IService,ICustomerApplyLogService +{ + @Autowired + private CustomerApplyLogMapper customerApplyLogMapper; + + /** + * 查询客户申请记录 + * + * @param id 客户申请记录主键 + * @return 客户申请记录 + */ + @Override + public CustomerApplyLog selectCustomerApplyLogById(Long id) + { + return customerApplyLogMapper.selectCustomerApplyLogById(id); + } + + /** + * 查询客户申请记录列表 + * + * @param customerApplyLog 客户申请记录 + * @return 客户申请记录 + */ + @Override + public List selectCustomerApplyLogList(CustomerApplyLog customerApplyLog) + { + return customerApplyLogMapper.selectCustomerApplyLogList(customerApplyLog); + } + + /** + * 新增客户申请记录 + * + * @param customerApplyLog 客户申请记录 + * @return 结果 + */ + @Override + public int insertCustomerApplyLog(CustomerApplyLog customerApplyLog) + { + customerApplyLog.setCreateTime(DateUtils.getNowDate()); + return customerApplyLogMapper.insertCustomerApplyLog(customerApplyLog); + } + + /** + * 修改客户申请记录 + * + * @param customerApplyLog 客户申请记录 + * @return 结果 + */ + @Override + public int updateCustomerApplyLog(CustomerApplyLog customerApplyLog) + { + customerApplyLog.setUpdateTime(DateUtils.getNowDate()); + return customerApplyLogMapper.updateCustomerApplyLog(customerApplyLog); + } + + /** + * 批量删除客户申请记录 + * + * @param ids 需要删除的客户申请记录主键 + * @return 结果 + */ + @Override + public int deleteCustomerApplyLogByIds(Long[] ids) + { + return customerApplyLogMapper.deleteCustomerApplyLogByIds(ids); + } + + /** + * 删除客户申请记录信息 + * + * @param id 客户申请记录主键 + * @return 结果 + */ + @Override + public int deleteCustomerApplyLogById(Long id) + { + return customerApplyLogMapper.deleteCustomerApplyLogById(id); + } + + /** + * 获取当日商户已申请数 + * @param merchantId + * @return + */ + @Override + public Integer getApplySum(Long merchantId) { + Long aLong = customerApplyLogMapper.selectCount( + new LambdaQueryWrapper() + .eq(CustomerApplyLog::getMerchantId, merchantId) + .eq(CustomerApplyLog::getOrderStatus, 0) + .ge(CustomerApplyLog::getCreateTime, LocalDateTimeUtils.getDateFromLocalDateTime(LocalDateTimeUtils.getTodayStartTime())) + .le(CustomerApplyLog::getCreateTime, LocalDateTimeUtils.getDateFromLocalDateTime(LocalDateTimeUtils.getTodayEndTime()))); + return aLong.intValue(); + } + + /** + * 获取用户今日是否已申请 + * @param customerID + * @return + */ + @Override + public R getCustomerApply(Long customerID) { + Long aLong = customerApplyLogMapper.selectCount( + new LambdaQueryWrapper() + .isNotNull(CustomerApplyLog::getMerchantId) + .eq(CustomerApplyLog::getOrderStatus, 20) + .ge(CustomerApplyLog::getCreateTime, LocalDateTimeUtils.getDateFromLocalDateTime(LocalDateTimeUtils.getTodayStartTime())) + .le(CustomerApplyLog::getCreateTime, LocalDateTimeUtils.getDateFromLocalDateTime(LocalDateTimeUtils.getTodayEndTime()))); + return R.ok(aLong>0); + } + + /** + * 申请回调 + */ + @Override + public AjaxResult applyCallBack(ApplyCallback applyCallback) { + String s = SecureUtils.AesUtil.AesDecode(applyCallback.getData(), applyCallback.getSign()); + if (StringUtils.isEmpty(s)){ + return AjaxResult.error("解密异常"); + } + ApplyCallbackDto applyCallbackDto; + try { + applyCallbackDto = JSONObject.parseObject(s, ApplyCallbackDto.class); + log.info("渠道:{},回调数据:{}",applyCallback.getSign(),applyCallbackDto); + } catch (Exception e) { + e.printStackTrace(); + return AjaxResult.error("数据转换异常"); + } + try { + CustomerApplyLog customerApplyLog = customerApplyLogMapper.selectOne(new LambdaQueryWrapper().eq(CustomerApplyLog::getOrderNo, applyCallbackDto.getOrderNo())); + if (applyCallbackDto.getOrderStatus()!=null) { + customerApplyLog.setOrderStatus(applyCallbackDto.getOrderStatus().longValue()); + } + if (applyCallbackDto.getPrice()!=null){ + if (customerApplyLog.getPrice()==null){ + customerApplyLog.setPrice(applyCallbackDto.getPrice()); + }else { + customerApplyLog.setPrice(customerApplyLog.getPrice().add(applyCallbackDto.getPrice())); + } + } + customerApplyLogMapper.updateById(customerApplyLog); + } catch (Exception e) { + e.printStackTrace(); + return AjaxResult.error("数据异常"); + } + return AjaxResult.success("回调成功"); + } +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CustomerServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CustomerServiceImpl.java new file mode 100644 index 00000000..a565529f --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CustomerServiceImpl.java @@ -0,0 +1,282 @@ +package com.ruoyi.system.service.impl; + +import java.util.*; + +import cn.hutool.core.util.IdcardUtil; +import cn.hutool.crypto.digest.MD5; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.baomidou.mybatisplus.extension.service.IService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.common.core.constant.CacheConstants; +import com.ruoyi.common.core.constant.RedisConstant; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.core.domain.http.Channel; +import com.ruoyi.common.core.utils.DateUtils; +import com.ruoyi.common.core.utils.EncryptUtil; +import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.common.redis.service.CustomerTokenService; +import com.ruoyi.common.redis.service.RedisService; +import com.ruoyi.common.security.service.TokenService; +import com.ruoyi.system.config.SystemConfig; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import com.ruoyi.system.mapper.CustomerMapper; +import com.ruoyi.common.core.domain.http.Customer; +import com.ruoyi.system.service.ICustomerService; +import org.springframework.util.StringUtils; + +import javax.servlet.http.HttpServletRequest; + +/** + * 客户信息Service业务层处理 + * + * @author ruoyi + * @date 2024-09-15 + */ +@Service +@RequiredArgsConstructor +@Slf4j +public class CustomerServiceImpl extends ServiceImpl implements IService,ICustomerService { + private final CustomerMapper customerMapper; + private final SystemConfig systemConfig; + private final CustomerTokenService customerTokenService; + private final RedisService redisService; + private final TokenService tokenService; + + /** + * 查询客户信息 + * + * @param id 客户信息主键 + * @return 客户信息 + */ + @Override + public Customer selectCustomerById(Long id) + { + return customerMapper.selectCustomerById(id); + } + + /** + * 查询客户信息列表 + * + * @param customer 客户信息 + * @return 客户信息 + */ + @Override + public List selectCustomerList(Customer customer) + { + return customerMapper.selectCustomerList(customer); + } + + /** + * 新增客户信息 + * + * @param customer 客户信息 + * @return 结果 + */ + @Override + public int insertCustomer(Customer customer) + { + customer.setCreateTime(DateUtils.getNowDate()); + return customerMapper.insertCustomer(customer); + } + + /** + * 修改客户信息 + * + * @param customer 客户信息 + * @return 结果 + */ + @Override + public int updateCustomer(Customer customer) + { + customer.setUpdateTime(DateUtils.getNowDate()); + return customerMapper.updateCustomer(customer); + } + + /** + * 批量删除客户信息 + * + * @param ids 需要删除的客户信息主键 + * @return 结果 + */ + @Override + public int deleteCustomerByIds(Long[] ids) + { + return customerMapper.deleteCustomerByIds(ids); + } + + /** + * 删除客户信息信息 + * + * @param id 客户信息主键 + * @return 结果 + */ + @Override + public int deleteCustomerById(Long id) + { + return customerMapper.deleteCustomerById(id); + } + + /** + * 通过手机号MD5查询 + * @param phoneMD5 + * @return + */ + @Override + public R selectByPhoneMd5(String phoneMD5) { + Customer one = getOne(new LambdaQueryWrapper().eq(Customer::getPhoneMd5, phoneMD5)); + if (one==null||one.getId()==null){ + return R.fail(); + } + return R.ok(one); + } + + /** + * 通过手机号更新用户信息 + * @param customer + * @return + */ + @Override + public R updateByPhoneMd5(Customer customer) { + int update = customerMapper.update(customer, new UpdateWrapper().lambda().eq(Customer::getPhoneMd5, customer.getPhoneMd5())); + if (update>0){ + return R.ok(); + } + return R.fail(); + } + + @Override + public String getCustomerToken(String phone) { + log.info("获取用户token,手机号:{}", phone); + Customer customer = this.getOne(new LambdaQueryWrapper().eq(Customer::getPhone, phone)); + log.info("获取用户token,用户信息:{}", customer); + //获取到用户登陆的token + String token = customerTokenService.getToken(customer.getId()); + if (StringUtils.isEmpty(token)) { + //生成一个长60的token + //token = customerTokenService.generateToken(customer.getId(), customer.getPhone(), "ANDROID", customer.getChannelId()); + token = tokenService.createTokenApp(customer.getId(),customer.getChannelId()); + } + return token; + } + + /** + * 注册并返回token + * @param phone + * @return + */ + public String registAndretrunToken(String phone,Long channelId){ + Customer customer = new Customer(); + customer.setChannelId(channelId); + customer.setPhone(EncryptUtil.AESencode(phone, systemConfig.getAESkey())); + customer.setPhoneMd5(MD5.create().digestHex(phone).toLowerCase(Locale.ROOT)); + customer.setIsAuth(false); + customer.setFirstLoginTime(new Date()); + customer.setLastLoginTime(new Date()); + customer.setStatus(1); + customer.setCreateTime(new Date()); + customerMapper.insert(customer); + String token = customerTokenService.getToken(customer.getId()); + if (StringUtils.isEmpty(token)) { + //生成一个长60的token + //token = customerTokenService.generateToken(customer.getId(), customer.getPhone(), "ANDROID", customer.getChannelId()); + token = tokenService.createTokenApp(customer.getId(),channelId); + } + return token; + } + + /** + * H5用户登陆 + * @param phone + * @param code + * @param request + * @return + */ + @Override + public AjaxResult customerLogin(String phone, Integer code, HttpServletRequest request) { + String sign = request.getHeader("sign"); + if (StringUtils.isEmpty(sign)){ + return AjaxResult.error("渠道标识不存在"); + } + Channel channel = redisService.getCacheObject(CacheConstants.CHANNEL_SIGN+sign); + Boolean aBoolean = redisService.hasKey(RedisConstant.H5_LOGIN_CACHE + phone); + if (!aBoolean){ + return AjaxResult.error("验证码不存在"); + } + int cacheCode = redisService.getCacheObject(RedisConstant.H5_LOGIN_CACHE + phone); + if (cacheCode!=code){ + return AjaxResult.success("验证码错误"); + } + String customerToken = registAndretrunToken(phone,channel.getId()); + + return AjaxResult.success("登录成功",customerToken); + } + + /** + * 保存用户留资信息 + * @param customer + * @param request + * @return + */ + @Override + public AjaxResult saveCustomerInfo(Customer customer, HttpServletRequest request) { + String authorization = request.getHeader("Authorization"); + Long customerId = customerTokenService.getCustomerId(authorization, false); + String sign = request.getHeader("sign"); + if (StringUtils.isEmpty(sign)){ + return AjaxResult.error("渠道标识不存在"); + } + Channel channel = redisService.getCacheObject(CacheConstants.CHANNEL_SIGN+sign); + if (customerId==null){ + return AjaxResult.error("用户不存在或未登录"); + } + if (StringUtils.isEmpty(customer.getIdCard())){ + return AjaxResult.error("身份证好不能为空"); + } + boolean validCard = IdcardUtil.isValidCard(customer.getIdCard()); + if (validCard){ + return AjaxResult.error("身份证号码异常"); + } + if (StringUtils.isEmpty(customer.getActurlName())){ + return AjaxResult.error("姓名不能为空"); + } + int ageByIdCard = IdcardUtil.getAgeByIdCard(customer.getIdCard()); + customer.setAge(ageByIdCard); + int genderByIdCard = IdcardUtil.getGenderByIdCard(customer.getIdCard()); + customer.setSex(genderByIdCard==0?1:0); + customer.setId(customerId); + customer.setChannelId(channel.getId()); + customer.setIsAuth(true); + customer.setStatus(1); + updateById(customer); + return AjaxResult.success("保存成功"); + } + + @Override + public AjaxResult v1SaveCustomerInfo(Customer customer, HttpServletRequest request) { + String authorization = request.getHeader("Authorization"); + Long customerId = customerTokenService.getCustomerId(authorization, false); + String sign = request.getHeader("sign"); + if (StringUtils.isEmpty(sign)) { + return AjaxResult.error("渠道标识不存在"); + } + Channel channel = redisService.getCacheObject(CacheConstants.CHANNEL_SIGN + sign); + if (customerId == null) { + return AjaxResult.error("用户不存在或未登录"); + } + + if (StringUtils.isEmpty(customer.getActurlName())) { + return AjaxResult.error("姓名不能为空"); + } + customer.setId(customerId); + customer.setChannelId(channel.getId()); + customer.setIsAuth(true); + customer.setStatus(1); + updateById(customer); + return AjaxResult.success("保存成功"); + } + + +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/MerchantServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/MerchantServiceImpl.java new file mode 100644 index 00000000..396e70bb --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/MerchantServiceImpl.java @@ -0,0 +1,288 @@ +package com.ruoyi.system.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.IService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.common.core.constant.RedisConstant; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.core.domain.http.Customer; +import com.ruoyi.common.core.domain.http.CustomerApplyLog; +import com.ruoyi.common.core.domain.http.Merchant; +import com.ruoyi.common.core.utils.DateUtils; +import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.common.redis.service.CustomerTokenService; +import com.ruoyi.common.redis.service.RedisService; +import com.ruoyi.system.domain.dto.MerchantListDto; +import com.ruoyi.system.mapper.CustomerMapper; +import com.ruoyi.system.mapper.MerchantMapper; +import com.ruoyi.system.service.ICustomerApplyLogService; +import com.ruoyi.system.service.IMerchantService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import javax.servlet.http.HttpServletRequest; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.List; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +/** + * 商户Service业务层处理 + * + * @author ruoyi + * @date 2024-09-15 + */ +@Service +@RequiredArgsConstructor +@Slf4j +public class MerchantServiceImpl extends ServiceImpl implements IService,IMerchantService +{ + private final MerchantMapper merchantMapper; + private final CustomerTokenService customerTokenService; + private final ICustomerApplyLogService customerApplyLogService; + private final CustomerMapper customerMapper; + private final RedisService redisService; + + /** + * 查询商户 + * + * @param id 商户主键 + * @return 商户 + */ + @Override + public Merchant selectMerchantById(Long id) + { + return merchantMapper.selectMerchantById(id); + } + + /** + * 查询商户列表 + * + * @param merchant 商户 + * @return 商户 + */ + @Override + public List selectMerchantList(Merchant merchant) + { + return merchantMapper.selectMerchantList(merchant); + } + + /** + * 新增商户 + * + * @param merchant 商户 + * @return 结果 + */ + @Override + public int insertMerchant(Merchant merchant) + { + merchant.setCreateTime(DateUtils.getNowDate()); + return merchantMapper.insertMerchant(merchant); + } + + /** + * 修改商户 + * + * @param merchant 商户 + * @return 结果 + */ + @Override + public int updateMerchant(Merchant merchant) + { + merchant.setUpdateTime(DateUtils.getNowDate()); + return merchantMapper.updateMerchant(merchant); + } + + /** + * 批量删除商户 + * + * @param ids 需要删除的商户主键 + * @return 结果 + */ + @Override + public int deleteMerchantByIds(Long[] ids) + { + return merchantMapper.deleteMerchantByIds(ids); + } + + /** + * 删除商户信息 + * + * @param id 商户主键 + * @return 结果 + */ + @Override + public int deleteMerchantById(Long id) + { + return merchantMapper.deleteMerchantById(id); + } + + /** + * 获取基本合适的商户 + * @return + */ + @Override + public R> getMerchantList() { + List merchants = merchantMapper.selectList(new LambdaQueryWrapper().eq(Merchant::getStatus, true)); + if (CollectionUtil.isEmpty(merchants)){ + return R.fail(); + } + return R.ok(merchants); + } + + public List findAllMerchantList(){ + return merchantMapper.findAllMerchantList(); + } + + @Override + public AjaxResult getMatchMerchantList(HttpServletRequest request) { + String authorization = request.getHeader("Authorization"); + Long customerId = customerTokenService.getCustomerId(authorization, false); + if (customerId==null){ + return AjaxResult.error("用户不存在或未登录"); + } + log.info("H5打开页面:{}",customerId); + Customer customer = customerMapper.selectById(customerId); + List merchants = matchMerchant(customer); + List merchantListDtos = new ArrayList<>(); + for (Merchant merchant:merchants) { + MerchantListDto merchantListDto = new MerchantListDto(); + merchantListDto.setMerchantName(merchant.getMerchantName()); + merchantListDto.setMerchantDescribe(merchant.getMerchantDescribe()); + merchantListDto.setMerchantUrl(merchant.getHitUrl()); + merchantListDto.setMerchantId(merchant.getId()); + merchantListDtos.add(merchantListDto); + } + return AjaxResult.success(merchantListDtos); + } + + @Override + public AjaxResult H5applyMerchant(Long merchantId, HttpServletRequest request) { + //获取用户 + String authorization = request.getHeader("Authorization"); + Long customerId = customerTokenService.getCustomerId(authorization, false); + Boolean aBoolean = redisService.hasKey(RedisConstant.H5_APPLY_CHECK + customerId); + if (aBoolean){ + return AjaxResult.error("请勿重复点击"); + } + log.info("H5申请用户:{}",customerId); + Customer customer = customerMapper.selectById(customerId); + Merchant merchant = merchantMapper.selectById(merchantId); + redisService.setCacheObject(RedisConstant.H5_APPLY_CHECK+customerId,1,10l, TimeUnit.SECONDS); + //生成订单号 + String orderNo = System.currentTimeMillis()+""+merchantId+""+customerId; + //记录申请订单 + CustomerApplyLog customerApplyLog = new CustomerApplyLog(); + customerApplyLog.setCustomerId(customerId); + customerApplyLog.setMerchantId(merchantId); + customerApplyLog.setChannelId(customer.getChannelId()); + customerApplyLog.setOrderStatus(0l); + customerApplyLog.setOrderNo(orderNo); + customerApplyLog.setCreateTime(new Date()); + customerApplyLogService.save(customerApplyLog); + return AjaxResult.success("点击成功","orderNo="+orderNo+"&sign="+merchant.getChannelSign()); + } + + /** + * 获取前筛符合的商户 + * @param customer + */ + private List matchMerchant(Customer customer) { + R> listR = getMerchantList(); + if (listR.getCode()!=200){ + return new ArrayList<>(); + } + List merchants = new ArrayList<>(); + for (Merchant merchant:listR.getData()) { + //限量判定 + Integer sum = customerApplyLogService.getApplySum(merchant.getId()); + if (merchant.getLimitType()!=null&&merchant.getLimitType()==1&&merchant.getLimitNum()<=sum){ + continue; + } + + if (merchant.getAgeLimitStart()!=null&&merchant.getAgeLimitEnd()!=null&&(customer.getAge()merchant.getAgeLimitEnd())){ + continue; + } + if (merchant.getChannelLimitType()!=null&&(merchant.getChannelLimitType()==1||merchant.getChannelLimitType()==2)){ + + List list = Arrays.asList(merchant.getChannelLimit().split(",")).stream().map(val->Long.parseLong(val)).collect(Collectors.toList()); + if (merchant.getChannelLimitType()==1&& !list.contains(customer.getChannelId())){ + continue; + } + if (merchant.getChannelLimitType()==2&& list.contains(customer.getChannelId())){ + continue; + } + } + merchants.add(merchant); + } + return merchants; + } + + + @Override + public AjaxResult getMatchMerchantNew() { + List merchantLists = matchMerchantNew(); + List results = new ArrayList<>(); + for (Merchant merchant : merchantLists) { + MerchantListDto merchantListDto = new MerchantListDto(); + merchantListDto.setMerchantName(merchant.getMerchantName()); + merchantListDto.setMerchantDescribe(merchant.getMerchantDescribe()); + merchantListDto.setMerchantUrl(merchant.getHitUrl()); + merchantListDto.setMerchantId(merchant.getId()); + results.add(merchantListDto); + } + return AjaxResult.success(results); + } + + @Override + public AjaxResult V1GetMatchMerchant(HttpServletRequest request) { + + String authorization = request.getHeader("Authorization"); + Long customerId = customerTokenService.getCustomerId(authorization, false); + if (customerId==null){ + return AjaxResult.error("用户不存在或未登录"); + } + Customer customer = customerMapper.selectById(customerId); + List merchants = matchMerchant(customer); + List merchantListDtos = new ArrayList<>(); + for (Merchant merchant:merchants) { + MerchantListDto merchantListDto = new MerchantListDto(); + merchantListDto.setMerchantName(merchant.getMerchantName()); + merchantListDto.setMerchantDescribe(merchant.getMerchantDescribe()); + merchantListDto.setMerchantUrl(merchant.getHitUrl()); + merchantListDto.setMerchantId(merchant.getId()); + merchantListDtos.add(merchantListDto); + } + return AjaxResult.success(merchantListDtos); + } + + + private List getMerchantLists() { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper().eq(Merchant::getStatus, true); + List merchants = merchantMapper.selectList(queryWrapper); + return CollectionUtils.isEmpty(merchants) ? new ArrayList<>() : merchants; + } + + private List matchMerchantNew() { + List merchantLists = getMerchantLists(); + if (CollectionUtils.isEmpty(merchantLists)) { + return merchantLists; + } + List merchants = new ArrayList<>(); + for (Merchant merchant : merchantLists) { + //限量判定 + Integer sum = customerApplyLogService.getApplySum(merchant.getId()); + if (merchant.getLimitType() != null && merchant.getLimitType() == 1 && merchant.getLimitNum() <= sum) { + continue; + } + merchants.add(merchant); + } + return merchants; + } +} diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/bootstrap.yml b/ruoyi-modules/ruoyi-system/src/main/resources/bootstrap.yml index 40ab7816..17605768 100644 --- a/ruoyi-modules/ruoyi-system/src/main/resources/bootstrap.yml +++ b/ruoyi-modules/ruoyi-system/src/main/resources/bootstrap.yml @@ -14,10 +14,12 @@ spring: nacos: discovery: # 服务注册地址 - server-addr: 127.0.0.1:8848 + server-addr: 47.109.135.151:8848 + namespace: b8ad3fd2-18ea-4cdf-a82c-4ce483392b1a config: # 配置中心地址 - server-addr: 127.0.0.1:8848 + server-addr: 47.109.135.151:8848 + namespace: b8ad3fd2-18ea-4cdf-a82c-4ce483392b1a # 配置文件格式 file-extension: yml # 共享配置 diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/ChannelMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/ChannelMapper.xml new file mode 100644 index 00000000..f48c126a --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/ChannelMapper.xml @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + select id, channel_name, channel_sign,channel_type, score, html_name, html_location, ips, period, create_time, update_time, remark from channel + + + select id, channel_name, channel_sign from channel + + + + + + + insert into channel + + channel_name, + channel_sign, + channel_type, + score, + html_name, + html_location, + ips, + period, + create_time, + update_time, + remark, + + + #{channelName}, + #{channelSign}, + #{channelType}, + #{score}, + #{htmlName}, + #{htmlLocation}, + #{ips}, + #{period}, + #{createTime}, + #{updateTime}, + #{remark}, + + + + + update channel + + channel_name = #{channelName}, + channel_sign = #{channelSign}, + channel_type = #{channelType}, + score = #{score}, + html_name = #{htmlName}, + html_location = #{htmlLocation}, + ips = #{ips}, + period = #{period}, + create_time = #{createTime}, + update_time = #{updateTime}, + remark = #{remark}, + + where id = #{id} + + + + delete from channel where id = #{id} + + + + delete from channel where id in + + #{id} + + + + + \ No newline at end of file diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/CustomerApplyLogMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/CustomerApplyLogMapper.xml new file mode 100644 index 00000000..dffcc6a3 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/CustomerApplyLogMapper.xml @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + select id, customer_id, merchant_id, channel_id, order_status, price, create_time, update_time, remark from customer_apply_log + + + + + + + + insert into customer_apply_log + + customer_id, + merchant_id, + channel_id, + order_status, + price, + create_time, + update_time, + remark, + + + #{customerId}, + #{merchantId}, + #{channelId}, + #{orderStatus}, + #{price}, + #{createTime}, + #{updateTime}, + #{remark}, + + + + + update customer_apply_log + + customer_id = #{customerId}, + merchant_id = #{merchantId}, + channel_id = #{channelId}, + order_status = #{orderStatus}, + price = #{price}, + create_time = #{createTime}, + update_time = #{updateTime}, + remark = #{remark}, + + where id = #{id} + + + + delete from customer_apply_log where id = #{id} + + + + delete from customer_apply_log where id in + + #{id} + + + \ No newline at end of file diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/CustomerMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/CustomerMapper.xml new file mode 100644 index 00000000..2a2af287 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/CustomerMapper.xml @@ -0,0 +1,184 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select id, channel_id, age, sex, name, acturl_name, phone, phone_md5, is_auth, city, city_code, first_login_time, last_login_time, last_login_ip, status, social_security, car, guarantee_slip, education, accumulation_fund, hourse, career, hua_bei, bai_tiao, zhi_ma, income, create_time, update_time from customer + + + + + + + + insert into customer + + channel_id, + age, + sex, + name, + acturl_name, + phone, + phone_md5, + is_auth, + city, + city_code, + first_login_time, + last_login_time, + last_login_ip, + status, + social_security, + car, + guarantee_slip, + education, + accumulation_fund, + hourse, + career, + hua_bei, + bai_tiao, + zhi_ma, + income, + create_time, + update_time, + + + #{channelId}, + #{age}, + #{sex}, + #{name}, + #{acturlName}, + #{phone}, + #{phoneMd5}, + #{isAuth}, + #{city}, + #{cityCode}, + #{firstLoginTime}, + #{lastLoginTime}, + #{lastLoginIp}, + #{status}, + #{socialSecurity}, + #{car}, + #{guaranteeSlip}, + #{education}, + #{accumulationFund}, + #{hourse}, + #{career}, + #{huaBei}, + #{baiTiao}, + #{zhiMa}, + #{income}, + #{createTime}, + #{updateTime}, + + + + + update customer + + channel_id = #{channelId}, + age = #{age}, + sex = #{sex}, + name = #{name}, + acturl_name = #{acturlName}, + phone = #{phone}, + phone_md5 = #{phoneMd5}, + is_auth = #{isAuth}, + city = #{city}, + city_code = #{cityCode}, + first_login_time = #{firstLoginTime}, + last_login_time = #{lastLoginTime}, + last_login_ip = #{lastLoginIp}, + status = #{status}, + social_security = #{socialSecurity}, + car = #{car}, + guarantee_slip = #{guaranteeSlip}, + education = #{education}, + accumulation_fund = #{accumulationFund}, + hourse = #{hourse}, + career = #{career}, + hua_bei = #{huaBei}, + bai_tiao = #{baiTiao}, + zhi_ma = #{zhiMa}, + income = #{income}, + create_time = #{createTime}, + update_time = #{updateTime}, + + where id = #{id} + + + + delete from customer where id = #{id} + + + + delete from customer where id in + + #{id} + + + \ No newline at end of file diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/MerchantMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/MerchantMapper.xml new file mode 100644 index 00000000..efdc36d7 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/MerchantMapper.xml @@ -0,0 +1,340 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select id, merchant_type, merchant_name, merchant_describe, merchant_company, logo, status, limit_num, limit_type,is_balance_monitoring,balance_monitoring,ispass, customer_info_filter_type,channel_limit_type,channel_limit,period,hit_url,regist_url,age_limit_start, age_limit_end, phone_limit,label,merchant_auth, social_security_no, social_security_low, social_security_high, car_no, car_have, guarantee_slip_low, guarantee_slip_centre, guarantee_slip_high, education_middle, education_high_school, education_polytechnic, education_junior_college, education_undergraduate_course, education_postgraduate, accumulation_fund_low, accumulation_fund_high, hourse_no, hourse_full_payment, hourse_mortgaging, office_worker, civil_servant, private_property_owners, self_employed_person, other_occupations, hua_bei_low, hua_bei_middle, hua_bei_high, bai_tiao_low, bai_tiao_middle, bai_tiao_high, zhi_ma, create_time, update_time, remark from merchant + + + select id, merchant_name from merchant + + + + + + + + insert into merchant + + merchant_type, + merchant_name, + merchant_describe, + merchant_company, + logo, + status, + limit_num, + limit_type, + is_balance_monitoring, + balance_monitoring, + ispass, + customer_info_filter_type, + channel_limit_type, + channel_limit, + period, + hit_url, + regist_url, + age_limit_start, + age_limit_end, + phone_limit, + label, + merchant_auth, + social_security_no, + social_security_low, + social_security_high, + car_no, + car_have, + guarantee_slip_low, + guarantee_slip_centre, + guarantee_slip_high, + education_middle, + education_high_school, + education_polytechnic, + education_junior_college, + education_undergraduate_course, + education_postgraduate, + accumulation_fund_low, + accumulation_fund_high, + hourse_no, + hourse_full_payment, + hourse_mortgaging, + office_worker, + civil_servant, + private_property_owners, + self_employed_person, + other_occupations, + hua_bei_low, + hua_bei_middle, + hua_bei_high, + bai_tiao_low, + bai_tiao_middle, + bai_tiao_high, + zhi_ma, + create_time, + update_time, + remark, + + + #{merchantType}, + #{merchantName}, + #{merchantDescribe}, + #{merchantCompany}, + #{logo}, + #{status}, + #{limitNum}, + #{limitType}, + #{isBalanceMonitoring}, + #{balanceMonitoring}, + #{ispass}, + #{customerInfoFilterType}, + #{channelLimitType}, + #{channelLimit}, + #{period}, + #{hitUrl}, + #{registUrl}, + #{ageLimitStart}, + #{ageLimitEnd}, + #{phoneLimit}, + #{label}, + #{merchantAuth}, + #{socialSecurityNo}, + #{socialSecurityLow}, + #{socialSecurityHigh}, + #{carNo}, + #{carHave}, + #{guaranteeSlipLow}, + #{guaranteeSlipCentre}, + #{guaranteeSlipHigh}, + #{educationMiddle}, + #{educationHighSchool}, + #{educationPolytechnic}, + #{educationJuniorCollege}, + #{educationUndergraduateCourse}, + #{educationPostgraduate}, + #{accumulationFundLow}, + #{accumulationFundHigh}, + #{hourseNo}, + #{hourseFullPayment}, + #{hourseMortgaging}, + #{officeWorker}, + #{civilServant}, + #{privatePropertyOwners}, + #{selfEmployedPerson}, + #{otherOccupations}, + #{huaBeiLow}, + #{huaBeiMiddle}, + #{huaBeiHigh}, + #{baiTiaoLow}, + #{baiTiaoMiddle}, + #{baiTiaoHigh}, + #{zhiMa}, + #{createTime}, + #{updateTime}, + #{remark}, + + + + + update merchant + + merchant_type = #{merchantType}, + merchant_name = #{merchantName}, + merchant_describe = #{merchantDescribe}, + merchant_company = #{merchantCompany}, + logo = #{logo}, + status = #{status}, + limit_num = #{limitNum}, + limit_type = #{limitType}, + is_balance_monitoring = #{isBalanceMonitoring}, + balance_monitoring = #{balanceMonitoring}, + ispass = #{ispass}, + customer_info_filter_type = #{customerInfoFilterType}, + channel_limit_type = #{channelLimitType}, + channel_limit = #{channelLimit}, + period = #{period}, + hit_url = #{hitUrl}, + regist_url = #{registUrl}, + age_limit_start = #{ageLimitStart}, + age_limit_end = #{ageLimitEnd}, + phone_limit = #{phoneLimit}, + label = #{label}, + merchant_auth = #{merchantAuth}, + social_security_no = #{socialSecurityNo}, + social_security_low = #{socialSecurityLow}, + social_security_high = #{socialSecurityHigh}, + car_no = #{carNo}, + car_have = #{carHave}, + guarantee_slip_low = #{guaranteeSlipLow}, + guarantee_slip_centre = #{guaranteeSlipCentre}, + guarantee_slip_high = #{guaranteeSlipHigh}, + education_middle = #{educationMiddle}, + education_high_school = #{educationHighSchool}, + education_polytechnic = #{educationPolytechnic}, + education_junior_college = #{educationJuniorCollege}, + education_undergraduate_course = #{educationUndergraduateCourse}, + education_postgraduate = #{educationPostgraduate}, + accumulation_fund_low = #{accumulationFundLow}, + accumulation_fund_high = #{accumulationFundHigh}, + hourse_no = #{hourseNo}, + hourse_full_payment = #{hourseFullPayment}, + hourse_mortgaging = #{hourseMortgaging}, + office_worker = #{officeWorker}, + civil_servant = #{civilServant}, + private_property_owners = #{privatePropertyOwners}, + self_employed_person = #{selfEmployedPerson}, + other_occupations = #{otherOccupations}, + hua_bei_low = #{huaBeiLow}, + hua_bei_middle = #{huaBeiMiddle}, + hua_bei_high = #{huaBeiHigh}, + bai_tiao_low = #{baiTiaoLow}, + bai_tiao_middle = #{baiTiaoMiddle}, + bai_tiao_high = #{baiTiaoHigh}, + zhi_ma = #{zhiMa}, + create_time = #{createTime}, + update_time = #{updateTime}, + remark = #{remark}, + + where id = #{id} + + + + delete from merchant where id = #{id} + + + + delete from merchant where id in + + #{id} + + + + + \ No newline at end of file diff --git a/ruoyi-modules/ruoyi-system/src/test/java/com/ruoyi/system/RuoYiSystemApplicationTest.java b/ruoyi-modules/ruoyi-system/src/test/java/com/ruoyi/system/RuoYiSystemApplicationTest.java new file mode 100644 index 00000000..db1ef545 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/test/java/com/ruoyi/system/RuoYiSystemApplicationTest.java @@ -0,0 +1,48 @@ +package com.ruoyi.system; + +import cn.hutool.json.JSONUtil; +import com.ruoyi.common.sms.component.SmsComponent; +import com.ruoyi.common.sms.entity.response.SmsResponse; +import org.assertj.core.util.Maps; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; + +import java.util.HashMap; +import java.util.Map; + +import static cn.hutool.extra.spring.SpringUtil.getActiveProfile; + +@SpringBootTest +public class RuoYiSystemApplicationTest { + + @Autowired + SmsComponent smsComponent; + + @Test + public void testGroupMsg(){ + + String mobile = "15826189779,15826189779,17382317154"; + String content = "123456"; + + SmsResponse groupMsg = smsComponent.sendGroupMsg(mobile, content); + System.out.println(JSONUtil.toJsonStr(groupMsg)); + } + + @Test + public void testP2pMsg(){ + + String content = "123456"; + Map params = new HashMap<>(); + params.put("15826189779", content); + SmsResponse sendP2PMsg = smsComponent.sendP2PMsg(params); + System.out.println(JSONUtil.toJsonStr(sendP2PMsg)); + } + + @Test + public void getActivePro(){ + + String activeProfile = getActiveProfile(); + System.out.println(activeProfile); + } +} diff --git a/ruoyi-ui/.env.development b/ruoyi-ui/.env.development index 18b2a3ed..a31fa681 100644 --- a/ruoyi-ui/.env.development +++ b/ruoyi-ui/.env.development @@ -1,11 +1,11 @@ -# 页面标题 -VUE_APP_TITLE = 若依管理系统 - -# 开发环境配置 -ENV = 'development' - -# 若依管理系统/开发环境 -VUE_APP_BASE_API = '/dev-api' - -# 路由懒加载 -VUE_CLI_BABEL_TRANSPILE_MODULES = true +# 页面标题 +VUE_APP_TITLE = 未信用秒租管理系统 + +# 开发环境配置 +ENV = 'development' + +# 未信用秒租管理系统/开发环境 +VUE_APP_BASE_API = '/dev-api' + +# 路由懒加载 +VUE_CLI_BABEL_TRANSPILE_MODULES = true diff --git a/ruoyi-ui/.env.production b/ruoyi-ui/.env.production index cb064ec8..28d5a46c 100644 --- a/ruoyi-ui/.env.production +++ b/ruoyi-ui/.env.production @@ -1,8 +1,8 @@ -# 页面标题 -VUE_APP_TITLE = 若依管理系统 - -# 生产环境配置 -ENV = 'production' - -# 若依管理系统/生产环境 -VUE_APP_BASE_API = '/prod-api' +# 页面标题 +VUE_APP_TITLE = 未信用秒租管理系统 + +# 生产环境配置 +ENV = 'production' + +# 未信用秒租管理系统/生产环境 +VUE_APP_BASE_API = 'http://124.222.144.55:80/dev-api' diff --git a/ruoyi-ui/.env.staging b/ruoyi-ui/.env.staging index a47af9a2..e3095cb5 100644 --- a/ruoyi-ui/.env.staging +++ b/ruoyi-ui/.env.staging @@ -1,10 +1,10 @@ -# 页面标题 -VUE_APP_TITLE = 若依管理系统 - -NODE_ENV = production - -# 测试环境配置 -ENV = 'staging' - -# 若依管理系统/测试环境 -VUE_APP_BASE_API = '/stage-api' +# 页面标题 +VUE_APP_TITLE = 未信用秒租管理系统 + +NODE_ENV = production + +# 测试环境配置 +ENV = 'staging' + +# 未信用秒租管理系统/测试环境 +VUE_APP_BASE_API = '/stage-api' diff --git a/ruoyi-ui/package.json b/ruoyi-ui/package.json index de15c3ae..49cb60f2 100644 --- a/ruoyi-ui/package.json +++ b/ruoyi-ui/package.json @@ -1,90 +1,90 @@ -{ - "name": "ruoyi", - "version": "3.6.4", - "description": "若依管理系统", - "author": "若依", - "license": "MIT", - "scripts": { - "dev": "vue-cli-service serve", - "build:prod": "vue-cli-service build", - "build:stage": "vue-cli-service build --mode staging", - "preview": "node build/index.js --preview", - "lint": "eslint --ext .js,.vue src" - }, - "husky": { - "hooks": { - "pre-commit": "lint-staged" - } - }, - "lint-staged": { - "src/**/*.{js,vue}": [ - "eslint --fix", - "git add" - ] - }, - "keywords": [ - "vue", - "admin", - "dashboard", - "element-ui", - "boilerplate", - "admin-template", - "management-system" - ], - "repository": { - "type": "git", - "url": "https://gitee.com/y_project/RuoYi-Cloud.git" - }, - "dependencies": { - "@riophae/vue-treeselect": "0.4.0", - "axios": "0.28.1", - "clipboard": "2.0.8", - "core-js": "3.37.1", - "echarts": "5.4.0", - "element-ui": "2.15.14", - "file-saver": "2.0.5", - "fuse.js": "6.4.3", - "highlight.js": "9.18.5", - "js-beautify": "1.13.0", - "js-cookie": "3.0.1", - "jsencrypt": "3.0.0-rc.1", - "nprogress": "0.2.0", - "quill": "1.3.7", - "screenfull": "5.0.2", - "sortablejs": "1.10.2", - "vue": "2.6.12", - "vue-count-to": "1.0.13", - "vue-cropper": "0.5.5", - "vue-meta": "2.4.0", - "vue-router": "3.4.9", - "vuedraggable": "2.24.3", - "vuex": "3.6.0" - }, - "devDependencies": { - "@vue/cli-plugin-babel": "4.4.6", - "@vue/cli-plugin-eslint": "4.4.6", - "@vue/cli-service": "4.4.6", - "babel-eslint": "10.1.0", - "babel-plugin-dynamic-import-node": "2.3.3", - "chalk": "4.1.0", - "compression-webpack-plugin": "6.1.2", - "connect": "3.6.6", - "eslint": "7.15.0", - "eslint-plugin-vue": "7.2.0", - "lint-staged": "10.5.3", - "runjs": "4.4.2", - "sass": "1.32.13", - "sass-loader": "10.1.1", - "script-ext-html-webpack-plugin": "2.1.5", - "svg-sprite-loader": "5.1.1", - "vue-template-compiler": "2.6.12" - }, - "engines": { - "node": ">=8.9", - "npm": ">= 3.0.0" - }, - "browserslist": [ - "> 1%", - "last 2 versions" - ] -} +{ + "name": "ruoyi", + "version": "3.6.4", + "description": "未信用秒租管理系统", + "author": "未信用秒租", + "license": "MIT", + "scripts": { + "dev": "vue-cli-service serve", + "build:prod": "vue-cli-service build", + "build:stage": "vue-cli-service build --mode staging", + "preview": "node build/index.js --preview", + "lint": "eslint --ext .js,.vue src" + }, + "husky": { + "hooks": { + "pre-commit": "lint-staged" + } + }, + "lint-staged": { + "src/**/*.{js,vue}": [ + "eslint --fix", + "git add" + ] + }, + "keywords": [ + "vue", + "admin", + "dashboard", + "element-ui", + "boilerplate", + "admin-template", + "management-system" + ], + "repository": { + "type": "git", + "url": "https://gitee.com/y_project/RuoYi-Cloud.git" + }, + "dependencies": { + "@riophae/vue-treeselect": "0.4.0", + "axios": "0.28.1", + "clipboard": "2.0.8", + "core-js": "3.37.1", + "echarts": "5.4.0", + "element-ui": "2.15.14", + "file-saver": "2.0.5", + "fuse.js": "6.4.3", + "highlight.js": "9.18.5", + "js-beautify": "1.13.0", + "js-cookie": "3.0.1", + "jsencrypt": "3.0.0-rc.1", + "nprogress": "0.2.0", + "quill": "1.3.7", + "screenfull": "5.0.2", + "sortablejs": "1.10.2", + "vue": "2.6.12", + "vue-count-to": "1.0.13", + "vue-cropper": "0.5.5", + "vue-meta": "2.4.0", + "vue-router": "3.4.9", + "vuedraggable": "2.24.3", + "vuex": "3.6.0" + }, + "devDependencies": { + "@vue/cli-plugin-babel": "4.4.6", + "@vue/cli-plugin-eslint": "4.4.6", + "@vue/cli-service": "4.4.6", + "babel-eslint": "10.1.0", + "babel-plugin-dynamic-import-node": "2.3.3", + "chalk": "4.1.0", + "compression-webpack-plugin": "6.1.2", + "connect": "3.6.6", + "eslint": "7.15.0", + "eslint-plugin-vue": "7.2.0", + "lint-staged": "10.5.3", + "runjs": "4.4.2", + "sass": "1.32.13", + "sass-loader": "10.1.1", + "script-ext-html-webpack-plugin": "2.1.5", + "svg-sprite-loader": "5.1.1", + "vue-template-compiler": "2.6.12" + }, + "engines": { + "node": ">=8.9", + "npm": ">= 3.0.0" + }, + "browserslist": [ + "> 1%", + "last 2 versions" + ] +} diff --git a/ruoyi-ui/src/api/system/channel.js b/ruoyi-ui/src/api/system/channel.js new file mode 100644 index 00000000..e9ba50d8 --- /dev/null +++ b/ruoyi-ui/src/api/system/channel.js @@ -0,0 +1,44 @@ +import request from "@/utils/request"; + +// 查询渠道配置列表 +export function listChannel(query) { + return request({ + url: "/system/channel/list", + method: "get", + params: query, + }); +} + +// 查询渠道配置详细 +export function getChannel(id) { + return request({ + url: "/system/channel/" + id, + method: "get", + }); +} + +// 新增渠道配置 +export function addChannel(data) { + return request({ + url: "/system/channel/add", + method: "post", + data: data, + }); +} + +// 修改渠道配置 +export function updateChannel(data) { + return request({ + url: "/system/channel/edit", + method: "post", + data: data, + }); +} + +// 删除渠道配置 +export function delChannel(id) { + return request({ + url: "/system/channel/" + id, + method: "delete", + }); +} diff --git a/ruoyi-ui/src/api/system/customer.js b/ruoyi-ui/src/api/system/customer.js new file mode 100644 index 00000000..960f33e7 --- /dev/null +++ b/ruoyi-ui/src/api/system/customer.js @@ -0,0 +1,60 @@ +import request from "@/utils/request"; + +// 查询客户信息列表 +export function listCustomer(query) { + return request({ + url: "/system/customer/list", + method: "get", + params: query, + }); +} + +// 查询客户信息详细 +export function getCustomer(id) { + return request({ + url: "/system/customer/" + id, + method: "get", + }); +} + +// 新增客户信息 +export function addCustomer(data) { + return request({ + url: "/system/customer", + method: "post", + data: data, + }); +} + +// 修改客户信息 +export function updateCustomer(data) { + return request({ + url: "/system/customer", + method: "put", + data: data, + }); +} + +// 删除客户信息 +export function delCustomer(id) { + return request({ + url: "/system/customer/" + id, + method: "delete", + }); +} + +// 获取商户(机构)的列表 +export function getAllMerchantList() { + return request({ + url: "/system/customer/getAllMerchantList", + method: "get", + }); +} + +//获取渠道 +export function getMerchantChannelList() { + return request({ + url: "/system/merchant/getMerchantChannelList", + method: "get", + }); +} diff --git a/ruoyi-ui/src/api/system/log.js b/ruoyi-ui/src/api/system/log.js new file mode 100644 index 00000000..3ad4cd4a --- /dev/null +++ b/ruoyi-ui/src/api/system/log.js @@ -0,0 +1,44 @@ +import request from '@/utils/request' + +// 查询客户申请记录列表 +export function listLog(query) { + return request({ + url: '/system/log/list', + method: 'get', + params: query + }) +} + +// 查询客户申请记录详细 +export function getLog(id) { + return request({ + url: '/system/log/' + id, + method: 'get' + }) +} + +// 新增客户申请记录 +export function addLog(data) { + return request({ + url: '/system/log', + method: 'post', + data: data + }) +} + +// 修改客户申请记录 +export function updateLog(data) { + return request({ + url: '/system/log', + method: 'put', + data: data + }) +} + +// 删除客户申请记录 +export function delLog(id) { + return request({ + url: '/system/log/' + id, + method: 'delete' + }) +} diff --git a/ruoyi-ui/src/api/system/merchant.js b/ruoyi-ui/src/api/system/merchant.js new file mode 100644 index 00000000..4a0c9b86 --- /dev/null +++ b/ruoyi-ui/src/api/system/merchant.js @@ -0,0 +1,52 @@ +import request from "@/utils/request"; + +// 查询商户列表 +export function listMerchant(query) { + return request({ + url: "/system/merchant/list", + method: "get", + params: query, + }); +} + +// 查询商户详细 +export function getMerchant(id) { + return request({ + url: "/system/merchant/" + id, + method: "get", + }); +} + +// 新增商户 +export function addMerchant(data) { + return request({ + url: "/system/merchant/add", + method: "post", + data: data, + }); +} + +// 修改商户 +export function updateMerchant(data) { + return request({ + url: "/system/merchant/edit", + method: "post", + data: data, + }); +} + +// 删除商户 +export function delMerchant(id) { + return request({ + url: "/system/merchant/" + id, + method: "delete", + }); +} + +// 获取商户(机构)的列表 +export function getAllMerchantList() { + return request({ + url: "/system/customer/getAllMerchantList", + method: "get", + }); +} diff --git a/ruoyi-ui/src/permission.js b/ruoyi-ui/src/permission.js index 4d3df609..74007962 100644 --- a/ruoyi-ui/src/permission.js +++ b/ruoyi-ui/src/permission.js @@ -1,58 +1,62 @@ -import router from './router' -import store from './store' -import { Message } from 'element-ui' -import NProgress from 'nprogress' -import 'nprogress/nprogress.css' -import { getToken } from '@/utils/auth' -import { isRelogin } from '@/utils/request' +import router from "./router"; +import store from "./store"; +import { Message } from "element-ui"; +import NProgress from "nprogress"; +import "nprogress/nprogress.css"; +import { getToken } from "@/utils/auth"; +import { isRelogin } from "@/utils/request"; -NProgress.configure({ showSpinner: false }) +NProgress.configure({ showSpinner: false }); -const whiteList = ['/login', '/register'] +const whiteList = ["/login", "/register"]; +// const whiteList = ["/login", "/register", "/channel", "/merchant", "/customer"]; router.beforeEach((to, from, next) => { - NProgress.start() + NProgress.start(); if (getToken()) { - to.meta.title && store.dispatch('settings/setTitle', to.meta.title) + to.meta.title && store.dispatch("settings/setTitle", to.meta.title); /* has token*/ - if (to.path === '/login') { - next({ path: '/' }) - NProgress.done() + if (to.path === "/login") { + next({ path: "/" }); + NProgress.done(); } else if (whiteList.indexOf(to.path) !== -1) { - next() + next(); } else { if (store.getters.roles.length === 0) { - isRelogin.show = true + isRelogin.show = true; // 判断当前用户是否已拉取完user_info信息 - store.dispatch('GetInfo').then(() => { - isRelogin.show = false - store.dispatch('GenerateRoutes').then(accessRoutes => { - // 根据roles权限生成可访问的路由表 - router.addRoutes(accessRoutes) // 动态添加可访问路由表 - next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 - }) - }).catch(err => { - store.dispatch('LogOut').then(() => { - Message.error(err) - next({ path: '/' }) - }) + store + .dispatch("GetInfo") + .then(() => { + isRelogin.show = false; + store.dispatch("GenerateRoutes").then((accessRoutes) => { + // 根据roles权限生成可访问的路由表 + router.addRoutes(accessRoutes); // 动态添加可访问路由表 + next({ ...to, replace: true }); // hack方法 确保addRoutes已完成 + }); }) + .catch((err) => { + store.dispatch("LogOut").then(() => { + Message.error(err); + next({ path: "/" }); + }); + }); } else { - next() + next(); } } } else { // 没有token if (whiteList.indexOf(to.path) !== -1) { // 在免登录白名单,直接进入 - next() + next(); } else { - next(`/login?redirect=${encodeURIComponent(to.fullPath)}`) // 否则全部重定向到登录页 - NProgress.done() + next(`/login?redirect=${encodeURIComponent(to.fullPath)}`); // 否则全部重定向到登录页 + NProgress.done(); } } -}) +}); router.afterEach(() => { - NProgress.done() -}) + NProgress.done(); +}); diff --git a/ruoyi-ui/src/router/index.js b/ruoyi-ui/src/router/index.js index 38b85b9e..8b5a22d2 100644 --- a/ruoyi-ui/src/router/index.js +++ b/ruoyi-ui/src/router/index.js @@ -1,10 +1,10 @@ -import Vue from 'vue' -import Router from 'vue-router' +import Vue from "vue"; +import Router from "vue-router"; -Vue.use(Router) +Vue.use(Router); /* Layout */ -import Layout from '@/layout' +import Layout from "@/layout"; /** * Note: 路由配置项 @@ -31,153 +31,185 @@ import Layout from '@/layout' // 公共路由 export const constantRoutes = [ { - path: '/redirect', + path: "/redirect", component: Layout, hidden: true, children: [ { - path: '/redirect/:path(.*)', - component: () => import('@/views/redirect') - } - ] + path: "/redirect/:path(.*)", + component: () => import("@/views/redirect"), + }, + ], }, + // { + // path: "/channel", + // name: "渠道管理", + // component: Layout, + // meta: { + // title: "渠道管理", + // }, + // component: () => import("@/views/channel/index"), + // }, + // { + // path: "/merchant", + // name: "商户管理", + // component: Layout, + // meta: { + // title: "商户管理", + // }, + // component: () => import("@/views/merchant/index"), + // }, + // { + // path: "/customer", + // name: "用户管理", + // component: Layout, + // meta: { + // title: "用户管理", + // }, + // component: () => import("@/views/customer/index"), + // }, { - path: '/login', - component: () => import('@/views/login'), - hidden: true + path: "/index", + component: () => import("@/views/index_v1"), + hidden: true, }, { - path: '/register', - component: () => import('@/views/register'), - hidden: true + path: "/login", + component: () => import("@/views/login"), + hidden: true, }, { - path: '/404', - component: () => import('@/views/error/404'), - hidden: true + path: "/register", + component: () => import("@/views/register"), + hidden: true, }, { - path: '/401', - component: () => import('@/views/error/401'), - hidden: true + path: "/404", + component: () => import("@/views/error/404"), + hidden: true, + }, + { + path: "/401", + component: () => import("@/views/error/401"), + hidden: true, }, { - path: '', + path: "", component: Layout, - redirect: 'index', - children: [ - { - path: 'index', - component: () => import('@/views/index'), - name: 'Index', - meta: { title: '首页', icon: 'dashboard', affix: true } - } - ] + redirect: "system/user", + // children: [ + // { + // path: "index", + // component: () => import("@/views/index_v1"), + // name: "Index", + // meta: { title: "首页", icon: "dashboard", affix: true }, + // }, + // ], }, { - path: '/user', + path: "/user", component: Layout, hidden: true, - redirect: 'noredirect', + redirect: "noredirect", children: [ { - path: 'profile', - component: () => import('@/views/system/user/profile/index'), - name: 'Profile', - meta: { title: '个人中心', icon: 'user' } - } - ] - } -] + path: "profile", + component: () => import("@/views/system/user/profile/index"), + name: "Profile", + meta: { title: "个人中心", icon: "user" }, + }, + ], + }, +]; // 动态路由,基于用户权限动态去加载 export const dynamicRoutes = [ { - path: '/system/user-auth', + path: "/system/user-auth", component: Layout, hidden: true, - permissions: ['system:user:edit'], + permissions: ["system:user:edit"], children: [ { - path: 'role/:userId(\\d+)', - component: () => import('@/views/system/user/authRole'), - name: 'AuthRole', - meta: { title: '分配角色', activeMenu: '/system/user' } - } - ] + path: "role/:userId(\\d+)", + component: () => import("@/views/system/user/authRole"), + name: "AuthRole", + meta: { title: "分配角色", activeMenu: "/system/user" }, + }, + ], }, { - path: '/system/role-auth', + path: "/system/role-auth", component: Layout, hidden: true, - permissions: ['system:role:edit'], + permissions: ["system:role:edit"], children: [ { - path: 'user/:roleId(\\d+)', - component: () => import('@/views/system/role/authUser'), - name: 'AuthUser', - meta: { title: '分配用户', activeMenu: '/system/role' } - } - ] + path: "user/:roleId(\\d+)", + component: () => import("@/views/system/role/authUser"), + name: "AuthUser", + meta: { title: "分配用户", activeMenu: "/system/role" }, + }, + ], }, { - path: '/system/dict-data', + path: "/system/dict-data", component: Layout, hidden: true, - permissions: ['system:dict:list'], + permissions: ["system:dict:list"], children: [ { - path: 'index/:dictId(\\d+)', - component: () => import('@/views/system/dict/data'), - name: 'Data', - meta: { title: '字典数据', activeMenu: '/system/dict' } - } - ] + path: "index/:dictId(\\d+)", + component: () => import("@/views/system/dict/data"), + name: "Data", + meta: { title: "字典数据", activeMenu: "/system/dict" }, + }, + ], }, { - path: '/monitor/job-log', + path: "/monitor/job-log", component: Layout, hidden: true, - permissions: ['monitor:job:list'], + permissions: ["monitor:job:list"], children: [ { - path: 'index/:jobId(\\d+)', - component: () => import('@/views/monitor/job/log'), - name: 'JobLog', - meta: { title: '调度日志', activeMenu: '/monitor/job' } - } - ] + path: "index/:jobId(\\d+)", + component: () => import("@/views/monitor/job/log"), + name: "JobLog", + meta: { title: "调度日志", activeMenu: "/monitor/job" }, + }, + ], }, { - path: '/tool/gen-edit', + path: "/tool/gen-edit", component: Layout, hidden: true, - permissions: ['tool:gen:edit'], + permissions: ["tool:gen:edit"], children: [ { - path: 'index/:tableId(\\d+)', - component: () => import('@/views/tool/gen/editTable'), - name: 'GenEdit', - meta: { title: '修改生成配置', activeMenu: '/tool/gen' } - } - ] - } -] + path: "index/:tableId(\\d+)", + component: () => import("@/views/tool/gen/editTable"), + name: "GenEdit", + meta: { title: "修改生成配置", activeMenu: "/tool/gen" }, + }, + ], + }, +]; // 防止连续点击多次路由报错 let routerPush = Router.prototype.push; let routerReplace = Router.prototype.replace; // push Router.prototype.push = function push(location) { - return routerPush.call(this, location).catch(err => err) -} + return routerPush.call(this, location).catch((err) => err); +}; // replace Router.prototype.replace = function push(location) { - return routerReplace.call(this, location).catch(err => err) -} + return routerReplace.call(this, location).catch((err) => err); +}; export default new Router({ - mode: 'history', // 去掉url中的# + mode: "history", // 去掉url中的# scrollBehavior: () => ({ y: 0 }), - routes: constantRoutes -}) + routes: constantRoutes, +}); diff --git a/ruoyi-ui/src/views/channel/index.vue b/ruoyi-ui/src/views/channel/index.vue new file mode 100644 index 00000000..e3996432 --- /dev/null +++ b/ruoyi-ui/src/views/channel/index.vue @@ -0,0 +1,534 @@ + + + diff --git a/ruoyi-ui/src/views/customer/index.vue b/ruoyi-ui/src/views/customer/index.vue new file mode 100644 index 00000000..e17321ed --- /dev/null +++ b/ruoyi-ui/src/views/customer/index.vue @@ -0,0 +1,482 @@ + + + diff --git a/ruoyi-ui/src/views/index.vue b/ruoyi-ui/src/views/index.vue index 610d6c31..a1c6cf4c 100644 --- a/ruoyi-ui/src/views/index.vue +++ b/ruoyi-ui/src/views/index.vue @@ -1,991 +1,1008 @@ - - - - - - + + + + + diff --git a/ruoyi-ui/src/views/log/index.vue b/ruoyi-ui/src/views/log/index.vue new file mode 100644 index 00000000..cc4a39db --- /dev/null +++ b/ruoyi-ui/src/views/log/index.vue @@ -0,0 +1,297 @@ + + + diff --git a/ruoyi-ui/src/views/login.vue b/ruoyi-ui/src/views/login.vue index 773f52c0..7fff7826 100644 --- a/ruoyi-ui/src/views/login.vue +++ b/ruoyi-ui/src/views/login.vue @@ -1,219 +1,252 @@ - - - - - + + + + + diff --git a/ruoyi-ui/src/views/merchant/index.vue b/ruoyi-ui/src/views/merchant/index.vue new file mode 100644 index 00000000..5977a887 --- /dev/null +++ b/ruoyi-ui/src/views/merchant/index.vue @@ -0,0 +1,917 @@ + + + + + diff --git a/ruoyi-ui/src/views/register.vue b/ruoyi-ui/src/views/register.vue index 63511c0d..a333cae9 100644 --- a/ruoyi-ui/src/views/register.vue +++ b/ruoyi-ui/src/views/register.vue @@ -1,210 +1,263 @@ - - - - - + + + + + diff --git a/ruoyi-ui/vue.config.js b/ruoyi-ui/vue.config.js index 1766cf87..06b80296 100644 --- a/ruoyi-ui/vue.config.js +++ b/ruoyi-ui/vue.config.js @@ -1,130 +1,130 @@ -'use strict' -const path = require('path') - -function resolve(dir) { - return path.join(__dirname, dir) -} - -const CompressionPlugin = require('compression-webpack-plugin') - -const name = process.env.VUE_APP_TITLE || '若依管理系统' // 网页标题 - -const port = process.env.port || process.env.npm_config_port || 80 // 端口 - -// vue.config.js 配置说明 -//官方vue.config.js 参考文档 https://cli.vuejs.org/zh/config/#css-loaderoptions -// 这里只列一部分,具体配置参考文档 -module.exports = { - // 部署生产环境和开发环境下的URL。 - // 默认情况下,Vue CLI 会假设你的应用是被部署在一个域名的根路径上 - // 例如 https://www.ruoyi.vip/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.ruoyi.vip/admin/,则设置 baseUrl 为 /admin/。 - publicPath: process.env.NODE_ENV === "production" ? "/" : "/", - // 在npm run build 或 yarn build 时 ,生成文件的目录名称(要和baseUrl的生产环境路径一致)(默认dist) - outputDir: 'dist', - // 用于放置生成的静态资源 (js、css、img、fonts) 的;(项目打包之后,静态资源会放在这个文件夹下) - assetsDir: 'static', - // 是否开启eslint保存检测,有效值:ture | false | 'error' - lintOnSave: process.env.NODE_ENV === 'development', - // 如果你不需要生产环境的 source map,可以将其设置为 false 以加速生产环境构建。 - productionSourceMap: false, - // webpack-dev-server 相关配置 - devServer: { - host: '0.0.0.0', - port: port, - open: true, - proxy: { - // detail: https://cli.vuejs.org/config/#devserver-proxy - [process.env.VUE_APP_BASE_API]: { - target: `http://localhost:8080`, - changeOrigin: true, - pathRewrite: { - ['^' + process.env.VUE_APP_BASE_API]: '' - } - } - }, - disableHostCheck: true - }, - css: { - loaderOptions: { - sass: { - sassOptions: { outputStyle: "expanded" } - } - } - }, - configureWebpack: { - name: name, - resolve: { - alias: { - '@': resolve('src') - } - }, - plugins: [ - // http://doc.ruoyi.vip/ruoyi-vue/other/faq.html#使用gzip解压缩静态文件 - new CompressionPlugin({ - cache: false, // 不启用文件缓存 - test: /\.(js|css|html|jpe?g|png|gif|svg)?$/i, // 压缩文件格式 - filename: '[path][base].gz[query]', // 压缩后的文件名 - algorithm: 'gzip', // 使用gzip压缩 - minRatio: 0.8, // 压缩比例,小于 80% 的文件不会被压缩 - deleteOriginalAssets: false // 压缩后删除原文件 - }) - ], - }, - chainWebpack(config) { - config.plugins.delete('preload') // TODO: need test - config.plugins.delete('prefetch') // TODO: need test - - // set svg-sprite-loader - config.module - .rule('svg') - .exclude.add(resolve('src/assets/icons')) - .end() - config.module - .rule('icons') - .test(/\.svg$/) - .include.add(resolve('src/assets/icons')) - .end() - .use('svg-sprite-loader') - .loader('svg-sprite-loader') - .options({ - symbolId: 'icon-[name]' - }) - .end() - - config.when(process.env.NODE_ENV !== 'development', config => { - config - .plugin('ScriptExtHtmlWebpackPlugin') - .after('html') - .use('script-ext-html-webpack-plugin', [{ - // `runtime` must same as runtimeChunk name. default is `runtime` - inline: /runtime\..*\.js$/ - }]) - .end() - - config.optimization.splitChunks({ - chunks: 'all', - cacheGroups: { - libs: { - name: 'chunk-libs', - test: /[\\/]node_modules[\\/]/, - priority: 10, - chunks: 'initial' // only package third parties that are initially dependent - }, - elementUI: { - name: 'chunk-elementUI', // split elementUI into a single package - test: /[\\/]node_modules[\\/]_?element-ui(.*)/, // in order to adapt to cnpm - priority: 20 // the weight needs to be larger than libs and app or it will be packaged into libs or app - }, - commons: { - name: 'chunk-commons', - test: resolve('src/components'), // can customize your rules - minChunks: 3, // minimum common number - priority: 5, - reuseExistingChunk: true - } - } - }) - config.optimization.runtimeChunk('single') - }) - } -} +"use strict"; +const path = require("path"); + +function resolve(dir) { + return path.join(__dirname, dir); +} + +const CompressionPlugin = require("compression-webpack-plugin"); + +const name = process.env.VUE_APP_TITLE || "未信用秒租管理系统"; // 网页标题 + +const port = process.env.port || process.env.npm_config_port || 80; // 端口 + +// vue.config.js 配置说明 +//官方vue.config.js 参考文档 https://cli.vuejs.org/zh/config/#css-loaderoptions +// 这里只列一部分,具体配置参考文档 +module.exports = { + // 部署生产环境和开发环境下的URL。 + // 默认情况下,Vue CLI 会假设你的应用是被部署在一个域名的根路径上 + // 例如 https://www.ruoyi.vip/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.ruoyi.vip/admin/,则设置 baseUrl 为 /admin/。 + publicPath: process.env.NODE_ENV === "production" ? "/" : "/", + // 在npm run build 或 yarn build 时 ,生成文件的目录名称(要和baseUrl的生产环境路径一致)(默认dist) + outputDir: "dist", + // 用于放置生成的静态资源 (js、css、img、fonts) 的;(项目打包之后,静态资源会放在这个文件夹下) + assetsDir: "static", + // 是否开启eslint保存检测,有效值:ture | false | 'error' + lintOnSave: process.env.NODE_ENV === "development", + // 如果你不需要生产环境的 source map,可以将其设置为 false 以加速生产环境构建。 + productionSourceMap: false, + // webpack-dev-server 相关配置 + devServer: { + host: "localhost", + port: 81, + open: true, + proxy: { + // detail: https://cli.vuejs.org/config/#devserver-proxy + [process.env.VUE_APP_BASE_API]: { + target: `http://r6a2wb.natappfree.cc`, + // target: `http://124.222.144.55/dev-api`, + changeOrigin: true, + pathRewrite: { + ["^" + process.env.VUE_APP_BASE_API]: "", + }, + }, + }, + disableHostCheck: true, + }, + css: { + loaderOptions: { + sass: { + sassOptions: { outputStyle: "expanded" }, + }, + }, + }, + configureWebpack: { + name: name, + resolve: { + alias: { + "@": resolve("src"), + }, + }, + plugins: [ + // http://doc.ruoyi.vip/ruoyi-vue/other/faq.html#使用gzip解压缩静态文件 + new CompressionPlugin({ + cache: false, // 不启用文件缓存 + test: /\.(js|css|html|jpe?g|png|gif|svg)?$/i, // 压缩文件格式 + filename: "[path][base].gz[query]", // 压缩后的文件名 + algorithm: "gzip", // 使用gzip压缩 + minRatio: 0.8, // 压缩比例,小于 80% 的文件不会被压缩 + deleteOriginalAssets: false, // 压缩后删除原文件 + }), + ], + }, + chainWebpack(config) { + config.plugins.delete("preload"); // TODO: need test + config.plugins.delete("prefetch"); // TODO: need test + + // set svg-sprite-loader + config.module.rule("svg").exclude.add(resolve("src/assets/icons")).end(); + config.module + .rule("icons") + .test(/\.svg$/) + .include.add(resolve("src/assets/icons")) + .end() + .use("svg-sprite-loader") + .loader("svg-sprite-loader") + .options({ + symbolId: "icon-[name]", + }) + .end(); + + config.when(process.env.NODE_ENV !== "development", (config) => { + config + .plugin("ScriptExtHtmlWebpackPlugin") + .after("html") + .use("script-ext-html-webpack-plugin", [ + { + // `runtime` must same as runtimeChunk name. default is `runtime` + inline: /runtime\..*\.js$/, + }, + ]) + .end(); + + config.optimization.splitChunks({ + chunks: "all", + cacheGroups: { + libs: { + name: "chunk-libs", + test: /[\\/]node_modules[\\/]/, + priority: 10, + chunks: "initial", // only package third parties that are initially dependent + }, + elementUI: { + name: "chunk-elementUI", // split elementUI into a single package + test: /[\\/]node_modules[\\/]_?element-ui(.*)/, // in order to adapt to cnpm + priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app + }, + commons: { + name: "chunk-commons", + test: resolve("src/components"), // can customize your rules + minChunks: 3, // minimum common number + priority: 5, + reuseExistingChunk: true, + }, + }, + }); + config.optimization.runtimeChunk("single"); + }); + }, +}; diff --git a/ruoyi-visual/ruoyi-monitor/src/main/resources/bootstrap.yml b/ruoyi-visual/ruoyi-monitor/src/main/resources/bootstrap.yml index 13d90cd7..41be8c9c 100644 --- a/ruoyi-visual/ruoyi-monitor/src/main/resources/bootstrap.yml +++ b/ruoyi-visual/ruoyi-monitor/src/main/resources/bootstrap.yml @@ -14,10 +14,10 @@ spring: nacos: discovery: # 服务注册地址 - server-addr: 127.0.0.1:8848 + server-addr: 47.109.135.151:8848 config: # 配置中心地址 - server-addr: 127.0.0.1:8848 + server-addr: 47.109.135.151:8848 # 配置文件格式 file-extension: yml # 共享配置 diff --git a/sql/ry_20240629.sql b/sql/ry_20240629.sql index a9b89d48..ee93d839 100644 --- a/sql/ry_20240629.sql +++ b/sql/ry_20240629.sql @@ -25,16 +25,16 @@ create table sys_dept ( -- ---------------------------- -- 初始化-部门表数据 -- ---------------------------- -insert into sys_dept values(100, 0, '0', '若依科技', 0, '若依', '15888888888', 'ry@qq.com', '0', '0', 'admin', sysdate(), '', null); -insert into sys_dept values(101, 100, '0,100', '深圳总公司', 1, '若依', '15888888888', 'ry@qq.com', '0', '0', 'admin', sysdate(), '', null); -insert into sys_dept values(102, 100, '0,100', '长沙分公司', 2, '若依', '15888888888', 'ry@qq.com', '0', '0', 'admin', sysdate(), '', null); -insert into sys_dept values(103, 101, '0,100,101', '研发部门', 1, '若依', '15888888888', 'ry@qq.com', '0', '0', 'admin', sysdate(), '', null); -insert into sys_dept values(104, 101, '0,100,101', '市场部门', 2, '若依', '15888888888', 'ry@qq.com', '0', '0', 'admin', sysdate(), '', null); -insert into sys_dept values(105, 101, '0,100,101', '测试部门', 3, '若依', '15888888888', 'ry@qq.com', '0', '0', 'admin', sysdate(), '', null); -insert into sys_dept values(106, 101, '0,100,101', '财务部门', 4, '若依', '15888888888', 'ry@qq.com', '0', '0', 'admin', sysdate(), '', null); -insert into sys_dept values(107, 101, '0,100,101', '运维部门', 5, '若依', '15888888888', 'ry@qq.com', '0', '0', 'admin', sysdate(), '', null); -insert into sys_dept values(108, 102, '0,100,102', '市场部门', 1, '若依', '15888888888', 'ry@qq.com', '0', '0', 'admin', sysdate(), '', null); -insert into sys_dept values(109, 102, '0,100,102', '财务部门', 2, '若依', '15888888888', 'ry@qq.com', '0', '0', 'admin', sysdate(), '', null); +insert into sys_dept values(100, 0, '0', '租研舍科技', 0, '租研舍', '15888888888', 'ry@qq.com', '0', '0', 'admin', sysdate(), '', null); +insert into sys_dept values(101, 100, '0,100', '深圳总公司', 1, '租研舍', '15888888888', 'ry@qq.com', '0', '0', 'admin', sysdate(), '', null); +insert into sys_dept values(102, 100, '0,100', '长沙分公司', 2, '租研舍', '15888888888', 'ry@qq.com', '0', '0', 'admin', sysdate(), '', null); +insert into sys_dept values(103, 101, '0,100,101', '研发部门', 1, '租研舍', '15888888888', 'ry@qq.com', '0', '0', 'admin', sysdate(), '', null); +insert into sys_dept values(104, 101, '0,100,101', '市场部门', 2, '租研舍', '15888888888', 'ry@qq.com', '0', '0', 'admin', sysdate(), '', null); +insert into sys_dept values(105, 101, '0,100,101', '测试部门', 3, '租研舍', '15888888888', 'ry@qq.com', '0', '0', 'admin', sysdate(), '', null); +insert into sys_dept values(106, 101, '0,100,101', '财务部门', 4, '租研舍', '15888888888', 'ry@qq.com', '0', '0', 'admin', sysdate(), '', null); +insert into sys_dept values(107, 101, '0,100,101', '运维部门', 5, '租研舍', '15888888888', 'ry@qq.com', '0', '0', 'admin', sysdate(), '', null); +insert into sys_dept values(108, 102, '0,100,102', '市场部门', 1, '租研舍', '15888888888', 'ry@qq.com', '0', '0', 'admin', sysdate(), '', null); +insert into sys_dept values(109, 102, '0,100,102', '财务部门', 2, '租研舍', '15888888888', 'ry@qq.com', '0', '0', 'admin', sysdate(), '', null); -- ---------------------------- @@ -67,8 +67,8 @@ create table sys_user ( -- ---------------------------- -- 初始化-用户信息表数据 -- ---------------------------- -insert into sys_user values(1, 103, 'admin', '若依', '00', 'ry@163.com', '15888888888', '1', '', '$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2', '0', '0', '127.0.0.1', sysdate(), 'admin', sysdate(), '', null, '管理员'); -insert into sys_user values(2, 105, 'ry', '若依', '00', 'ry@qq.com', '15666666666', '1', '', '$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2', '0', '0', '127.0.0.1', sysdate(), 'admin', sysdate(), '', null, '测试员'); +insert into sys_user values(1, 103, 'admin', '租研舍', '00', 'ry@163.com', '15888888888', '1', '', '$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2', '0', '0', '127.0.0.1', sysdate(), 'admin', sysdate(), '', null, '管理员'); +insert into sys_user values(2, 105, 'ry', '租研舍', '00', 'ry@qq.com', '15666666666', '1', '', '$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2', '0', '0', '127.0.0.1', sysdate(), 'admin', sysdate(), '', null, '测试员'); -- ---------------------------- @@ -163,7 +163,7 @@ create table sys_menu ( insert into sys_menu values('1', '系统管理', '0', '1', 'system', null, '', '', 1, 0, 'M', '0', '0', '', 'system', 'admin', sysdate(), '', null, '系统管理目录'); insert into sys_menu values('2', '系统监控', '0', '2', 'monitor', null, '', '', 1, 0, 'M', '0', '0', '', 'monitor', 'admin', sysdate(), '', null, '系统监控目录'); insert into sys_menu values('3', '系统工具', '0', '3', 'tool', null, '', '', 1, 0, 'M', '0', '0', '', 'tool', 'admin', sysdate(), '', null, '系统工具目录'); -insert into sys_menu values('4', '若依官网', '0', '4', 'http://ruoyi.vip', null, '', '', 0, 0, 'M', '0', '0', '', 'guide', 'admin', sysdate(), '', null, '若依官网地址'); +insert into sys_menu values('4', '租研舍官网', '0', '4', 'http://ruoyi.vip', null, '', '', 0, 0, 'M', '0', '0', '', 'guide', 'admin', sysdate(), '', null, '租研舍官网地址'); -- 二级菜单 insert into sys_menu values('100', '用户管理', '1', '1', 'user', 'system/user/index', '', '', 1, 0, 'C', '0', '0', 'system:user:list', 'user', 'admin', sysdate(), '', null, '用户管理菜单'); insert into sys_menu values('101', '角色管理', '1', '2', 'role', 'system/role/index', '', '', 1, 0, 'C', '0', '0', 'system:role:list', 'peoples', 'admin', sysdate(), '', null, '角色管理菜单'); @@ -632,8 +632,8 @@ create table sys_notice ( -- ---------------------------- -- 初始化-公告信息表数据 -- ---------------------------- -insert into sys_notice values('1', '温馨提醒:2018-07-01 若依新版本发布啦', '2', '新版本内容', '0', 'admin', sysdate(), '', null, '管理员'); -insert into sys_notice values('2', '维护通知:2018-07-01 若依系统凌晨维护', '1', '维护内容', '0', 'admin', sysdate(), '', null, '管理员'); +insert into sys_notice values('1', '温馨提醒:2018-07-01 租研舍新版本发布啦', '2', '新版本内容', '0', 'admin', sysdate(), '', null, '管理员'); +insert into sys_notice values('2', '维护通知:2018-07-01 租研舍系统凌晨维护', '1', '维护内容', '0', 'admin', sysdate(), '', null, '管理员'); -- ---------------------------- diff --git a/sql/ry_config_20240902.sql b/sql/ry_config_20240902.sql index 6b061277..c98f0094 100644 --- a/sql/ry_config_20240902.sql +++ b/sql/ry_config_20240902.sql @@ -36,7 +36,7 @@ insert into config_info(id, data_id, group_id, content, md5, gmt_create, gmt_mod (1,'application-dev.yml','DEFAULT_GROUP','spring:\n autoconfigure:\n exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure\n\n# feign 配置\nfeign:\n sentinel:\n enabled: true\n okhttp:\n enabled: true\n httpclient:\n enabled: false\n client:\n config:\n default:\n connectTimeout: 10000\n readTimeout: 10000\n compression:\n request:\n enabled: true\n min-request-size: 8192\n response:\n enabled: true\n\n# 暴露监控端点\nmanagement:\n endpoints:\n web:\n exposure:\n include: \'*\'\n','9928f41dfb10386ad38b3254af5692e0','2020-05-20 12:00:00','2024-08-29 12:14:45','nacos','0:0:0:0:0:0:0:1','','','通用配置','null','null','yaml','',''), (2,'ruoyi-gateway-dev.yml','DEFAULT_GROUP','spring:\n redis:\n host: localhost\n port: 6379\n password: \n cloud:\n gateway:\n discovery:\n locator:\n lowerCaseServiceId: true\n enabled: true\n routes:\n # 认证中心\n - id: ruoyi-auth\n uri: lb://ruoyi-auth\n predicates:\n - Path=/auth/**\n filters:\n # 验证码处理\n - CacheRequestFilter\n - ValidateCodeFilter\n - StripPrefix=1\n # 代码生成\n - id: ruoyi-gen\n uri: lb://ruoyi-gen\n predicates:\n - Path=/code/**\n filters:\n - StripPrefix=1\n # 定时任务\n - id: ruoyi-job\n uri: lb://ruoyi-job\n predicates:\n - Path=/schedule/**\n filters:\n - StripPrefix=1\n # 系统模块\n - id: ruoyi-system\n uri: lb://ruoyi-system\n predicates:\n - Path=/system/**\n filters:\n - StripPrefix=1\n # 文件服务\n - id: ruoyi-file\n uri: lb://ruoyi-file\n predicates:\n - Path=/file/**\n filters:\n - StripPrefix=1\n\n# 安全配置\nsecurity:\n # 验证码\n captcha:\n enabled: true\n type: math\n # 防止XSS攻击\n xss:\n enabled: true\n excludeUrls:\n - /system/notice\n\n # 不校验白名单\n ignore:\n whites:\n - /auth/logout\n - /auth/login\n - /auth/register\n - /*/v2/api-docs\n - /*/v3/api-docs\n - /csrf\n\n# springdoc配置\nspringdoc:\n webjars:\n # 访问前缀\n prefix:\n','4d329eb08a941a8dd9d26f542c6ac6c5','2020-05-14 14:17:55','2024-09-02 12:13:50','nacos','0:0:0:0:0:0:0:1','','','网关模块','null','null','yaml','',''), (3,'ruoyi-auth-dev.yml','DEFAULT_GROUP','spring:\n redis:\n host: localhost\n port: 6379\n password: \n','a03e7632a0a74520eeb4fbedd6d82d97','2020-11-20 00:00:00','2024-09-02 12:13:58','nacos','0:0:0:0:0:0:0:1','','','认证中心','null','null','yaml','',''), -(4,'ruoyi-monitor-dev.yml','DEFAULT_GROUP','# spring\nspring:\n security:\n user:\n name: ruoyi\n password: 123456\n boot:\n admin:\n ui:\n title: 若依服务状态监控\n','6f122fd2bfb8d45f858e7d6529a9cd44','2020-11-20 00:00:00','2024-08-29 12:15:11','nacos','0:0:0:0:0:0:0:1','','','监控中心','null','null','yaml','',''), +(4,'ruoyi-monitor-dev.yml','DEFAULT_GROUP','# spring\nspring:\n security:\n user:\n name: ruoyi\n password: 123456\n boot:\n admin:\n ui:\n title: 租研舍服务状态监控\n','6f122fd2bfb8d45f858e7d6529a9cd44','2020-11-20 00:00:00','2024-08-29 12:15:11','nacos','0:0:0:0:0:0:0:1','','','监控中心','null','null','yaml','',''), (5,'ruoyi-system-dev.yml','DEFAULT_GROUP','# spring配置\nspring:\n redis:\n host: localhost\n port: 6379\n password: \n datasource:\n druid:\n stat-view-servlet:\n enabled: true\n loginUsername: ruoyi\n loginPassword: 123456\n dynamic:\n druid:\n initial-size: 5\n min-idle: 5\n maxActive: 20\n maxWait: 60000\n connectTimeout: 30000\n socketTimeout: 60000\n timeBetweenEvictionRunsMillis: 60000\n minEvictableIdleTimeMillis: 300000\n validationQuery: SELECT 1 FROM DUAL\n testWhileIdle: true\n testOnBorrow: false\n testOnReturn: false\n poolPreparedStatements: true\n maxPoolPreparedStatementPerConnectionSize: 20\n filters: stat,slf4j\n connectionProperties: druid.stat.mergeSql\\=true;druid.stat.slowSqlMillis\\=5000\n datasource:\n # 主库数据源\n master:\n driver-class-name: com.mysql.cj.jdbc.Driver\n url: jdbc:mysql://localhost:3306/ry-cloud?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8\n username: root\n password: password\n # 从库数据源\n # slave:\n # username: \n # password: \n # url: \n # driver-class-name: \n\n# mybatis配置\nmybatis:\n # 搜索指定包别名\n typeAliasesPackage: com.ruoyi.system\n # 配置mapper的扫描,找到所有的mapper.xml映射文件\n mapperLocations: classpath:mapper/**/*.xml\n\n# springdoc配置\nspringdoc:\n gatewayUrl: http://localhost:8080/${spring.application.name}\n api-docs:\n # 是否开启接口文档\n enabled: true\n info:\n # 标题\n title: \'系统模块接口文档\'\n # 描述\n description: \'系统模块接口描述\'\n # 作者信息\n contact:\n name: RuoYi\n url: https://ruoyi.vip\n','786c7daf4543411fc65c3e48dfb15243','2020-11-20 00:00:00','2024-09-02 12:14:33','nacos','0:0:0:0:0:0:0:1','','','系统模块','null','null','yaml','',''), (6,'ruoyi-gen-dev.yml','DEFAULT_GROUP','# spring配置\nspring:\n redis:\n host: localhost\n port: 6379\n password: \n datasource:\n driver-class-name: com.mysql.cj.jdbc.Driver\n url: jdbc:mysql://localhost:3306/ry-cloud?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8\n username: root\n password: password\n\n# mybatis配置\nmybatis:\n # 搜索指定包别名\n typeAliasesPackage: com.ruoyi.gen.domain\n # 配置mapper的扫描,找到所有的mapper.xml映射文件\n mapperLocations: classpath:mapper/**/*.xml\n\n# springdoc配置\nspringdoc:\n gatewayUrl: http://localhost:8080/${spring.application.name}\n api-docs:\n # 是否开启接口文档\n enabled: true\n info:\n # 标题\n title: \'代码生成接口文档\'\n # 描述\n description: \'代码生成接口描述\'\n # 作者信息\n contact:\n name: RuoYi\n url: https://ruoyi.vip\n\n# 代码生成\ngen:\n # 作者\n author: ruoyi\n # 默认生成包路径 system 需改成自己的模块名称 如 system monitor tool\n packageName: com.ruoyi.system\n # 自动去除表前缀,默认是false\n autoRemovePre: false\n # 表前缀(生成类名不会包含表前缀,多个用逗号分隔)\n tablePrefix: sys_\n','14d41dda290bf445b7ed06c5667e8e88','2020-11-20 00:00:00','2024-09-02 12:14:48','nacos','0:0:0:0:0:0:0:1','','','代码生成','null','null','yaml','',''), (7,'ruoyi-job-dev.yml','DEFAULT_GROUP','# spring配置\nspring:\n redis:\n host: localhost\n port: 6379\n password: \n datasource:\n driver-class-name: com.mysql.cj.jdbc.Driver\n url: jdbc:mysql://localhost:3306/ry-cloud?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8\n username: root\n password: password\n\n# mybatis配置\nmybatis:\n # 搜索指定包别名\n typeAliasesPackage: com.ruoyi.job.domain\n # 配置mapper的扫描,找到所有的mapper.xml映射文件\n mapperLocations: classpath:mapper/**/*.xml\n\n# springdoc配置\nspringdoc:\n gatewayUrl: http://localhost:8080/${spring.application.name}\n api-docs:\n # 是否开启接口文档\n enabled: true\n info:\n # 标题\n title: \'定时任务接口文档\'\n # 描述\n description: \'定时任务接口描述\'\n # 作者信息\n contact:\n name: RuoYi\n url: https://ruoyi.vip\n','f78483f845777335b9ed4a9f84758848','2020-11-20 00:00:00','2024-09-02 12:14:56','nacos','0:0:0:0:0:0:0:1','','','定时任务','null','null','yaml','',''),