From 5f54043ab34fedc2015dce265cc7b2b2ec7864f4 Mon Sep 17 00:00:00 2001 From: tangzh Date: Fri, 11 Jul 2025 17:40:48 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- eladmin-web/.env.production | 4 +- eladmin-web/package.json | 2 +- .../front/service/impl/WeChatServiceImpl.java | 13 +- .../main/resources/config/application-dev.yml | 18 ++- .../resources/config/application-local.yml | 133 ++++++++++++++++++ .../src/main/resources/config/application.yml | 25 ++-- .../src/main/resources/logback-spring.xml | 121 ++++++++++++++++ 7 files changed, 288 insertions(+), 28 deletions(-) create mode 100644 eladmin/eladmin-system/src/main/resources/config/application-local.yml create mode 100644 eladmin/eladmin-system/src/main/resources/logback-spring.xml diff --git a/eladmin-web/.env.production b/eladmin-web/.env.production index 66da123..46ad91f 100644 --- a/eladmin-web/.env.production +++ b/eladmin-web/.env.production @@ -2,6 +2,6 @@ ENV = 'production' # 如果使用 Nginx 代理后端接口,那么此处需要改为 '/',文件查看 Docker 部署篇,Nginx 配置 # 接口地址,注意协议,如果你没有配置 ssl,需要将 https 改为 http -VUE_APP_BASE_API = 'https://eladmin.vip' +VUE_APP_BASE_API = 'http://121.37.139.13:8080' # 如果接口是 http 形式, wss 需要改为 ws -VUE_APP_WS_API = 'wss://eladmin.vip' +VUE_APP_WS_API = 'ws://121.37.139.13:8080' diff --git a/eladmin-web/package.json b/eladmin-web/package.json index 91a56b6..6b36c81 100644 --- a/eladmin-web/package.json +++ b/eladmin-web/package.json @@ -6,7 +6,7 @@ "license": "Apache-2.0", "scripts": { "dev": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve", - "build:prod": "vue-cli-service build", + "build:prod": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service build", "build:stage": "vue-cli-service build --mode staging", "preview": "node build/index.js --preview", "lint": "eslint --ext .js,.vue src", diff --git a/eladmin/eladmin-system/src/main/java/me/zhengjie/modules/front/service/impl/WeChatServiceImpl.java b/eladmin/eladmin-system/src/main/java/me/zhengjie/modules/front/service/impl/WeChatServiceImpl.java index 92c070c..7e7296e 100644 --- a/eladmin/eladmin-system/src/main/java/me/zhengjie/modules/front/service/impl/WeChatServiceImpl.java +++ b/eladmin/eladmin-system/src/main/java/me/zhengjie/modules/front/service/impl/WeChatServiceImpl.java @@ -2,7 +2,9 @@ package me.zhengjie.modules.front.service.impl; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; +import lombok.extern.slf4j.Slf4j; import me.zhengjie.config.properties.FileProperties; import me.zhengjie.exception.BadRequestException; import me.zhengjie.modules.front.domain.dto.LoginVo; @@ -16,8 +18,6 @@ import me.zhengjie.modules.system.domain.BusUser; import me.zhengjie.modules.system.mapper.BusUserMapper; import me.zhengjie.modules.system.service.BusUserService; import me.zhengjie.utils.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -29,11 +29,10 @@ import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.Random; +@Slf4j @Service public class WeChatServiceImpl implements WeChatService { - private final Logger logger = LoggerFactory.getLogger(WeChatServiceImpl.class); - @Value("${weChat.appId}") private String appId; @@ -66,8 +65,9 @@ public class WeChatServiceImpl implements WeChatService { @Override public LoginVo authorizeLogin(String code, HttpServletRequest request) { LoginVo loginVo = new LoginVo(); - WeChatMiniAuthorizeVo response = new WeChatMiniAuthorizeVo(); //miniAuthCode(code); - response.setOpenId("123456"); + WeChatMiniAuthorizeVo response = miniAuthCode(code); + // WeChatMiniAuthorizeVo response = new WeChatMiniAuthorizeVo(); + // response.setOpenId("123456"); String openId = response.getOpenId(); String type = "login"; BusUser BusUser = BusUserMapper.getUserByOpenId(openId); @@ -101,6 +101,7 @@ public class WeChatServiceImpl implements WeChatService { private WeChatMiniAuthorizeVo miniAuthCode(String code) { String url = StrUtil.format(WECHAT_MINI_SNS_AUTH_CODE2SESSION_URL, appId, secret, code); JSONObject data = restTemplateUtil.getData(url); + log.info("<<< miniAuthCode:{}", JSON.toJSONString(data)); if (ObjectUtil.isNull(data)) { throw new BadRequestException("微信平台接口异常,没任何数据返回!"); } diff --git a/eladmin/eladmin-system/src/main/resources/config/application-dev.yml b/eladmin/eladmin-system/src/main/resources/config/application-dev.yml index 57ec454..bc983ce 100644 --- a/eladmin/eladmin-system/src/main/resources/config/application-dev.yml +++ b/eladmin/eladmin-system/src/main/resources/config/application-dev.yml @@ -1,12 +1,15 @@ +server: + port: 8080 + #配置数据源 spring: datasource: druid: db-type: com.alibaba.druid.pool.DruidDataSource driverClassName: com.p6spy.engine.spy.P6SpyDriver - url: jdbc:p6spy:mysql://localhost:3306/totus-online?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false + url: jdbc:p6spy:mysql://121.37.139.13:3306/totus-online?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false username: root - password: root + password: minxianrui # 初始连接数,建议设置为与最小空闲连接数相同 initial-size: 20 # 最小空闲连接数,保持足够的空闲连接以应对请求 @@ -51,6 +54,13 @@ spring: config: multi-statement-allow: true + redis: + #数据库索引 + database: 1 + host: 127.0.0.1 + port: 6379 + password: + # 登录相关配置 login: # 是否限制单用户登录 @@ -113,8 +123,8 @@ file: path: ~/file/ avatar: ~/avatar/ linux: - path: /home/eladmin/file/ - avatar: /home/eladmin/avatar/ + path: /www/wwwroot/online/upload/file/ + avatar: /www/wwwroot/online/upload/avatar/ windows: path: /eladmin/eladmin-upload/file/ avatar: /eladmin/eladmin-upload/avatar/ diff --git a/eladmin/eladmin-system/src/main/resources/config/application-local.yml b/eladmin/eladmin-system/src/main/resources/config/application-local.yml new file mode 100644 index 0000000..f230a18 --- /dev/null +++ b/eladmin/eladmin-system/src/main/resources/config/application-local.yml @@ -0,0 +1,133 @@ +server: + port: 8000 + +#配置数据源 +spring: + datasource: + druid: + db-type: com.alibaba.druid.pool.DruidDataSource + driverClassName: com.p6spy.engine.spy.P6SpyDriver + url: jdbc:p6spy:mysql://localhost:3306/totus-online?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false + username: root + password: root + # 初始连接数,建议设置为与最小空闲连接数相同 + initial-size: 20 + # 最小空闲连接数,保持足够的空闲连接以应对请求 + min-idle: 20 + # 最大连接数,根据并发需求适当增加 + max-active: 50 + # 获取连接超时时间(毫秒),调整以满足响应时间要求 + max-wait: 3000 + # 启用KeepAlive机制,保持长连接 + keep-alive: true + # 连接有效性检测间隔时间(毫秒),定期检查连接的健康状态 + time-between-eviction-runs-millis: 60000 + # 连接在池中最小生存时间(毫秒),确保连接在池中至少存在一段时间 + min-evictable-idle-time-millis: 300000 + # 连接在池中最大生存时间(毫秒),防止连接在池中停留过长 + max-evictable-idle-time-millis: 900000 + # 指明连接是否被空闲连接回收器(如果有)进行检验.如果检测失败,则连接将被从池中去除 + test-while-idle: true + # 指明是否在从池中取出连接前进行检验,如果检验失败, 则从池中去除连接并尝试取出另一个 + test-on-borrow: true + # 是否在归还到池中前进行检验 + test-on-return: false + # 停用 com_ping 探活机制 + use-ping-method: false + # 检测连接是否有效 + validation-query: SELECT 1 + # 配置监控统计 + webStatFilter: + enabled: true + stat-view-servlet: + enabled: true + url-pattern: /druid/* + reset-enable: false + filter: + stat: + enabled: true + # 记录慢SQL + log-slow-sql: true + slow-sql-millis: 2000 + merge-sql: true + wall: + config: + multi-statement-allow: true + + redis: + #数据库索引 + database: 1 + host: 127.0.0.1 + port: 6379 + password: + +# 登录相关配置 +login: + # 是否限制单用户登录 + single-login: false + # Redis用户登录缓存配置 + user-cache: + # 存活时间/秒 + idle-time: 21600 + # 验证码 + code: + # 验证码类型配置 查看 LoginProperties 类 + code-type: arithmetic + # 登录图形验证码有效时间/分钟 + expiration: 2 + # 验证码高度 + width: 111 + # 验证码宽度 + height: 36 + # 内容长度 + length: 2 + # 字体名称,为空则使用默认字体 + font-name: + # 字体大小 + font-size: 25 + +#jwt +jwt: + header: Authorization + # 令牌前缀 + token-start-with: Bearer + # 必须使用最少88位的Base64对该令牌进行编码 + base64-secret: ZmQ0ZGI5NjQ0MDQwY2I4MjMxY2Y3ZmI3MjdhN2ZmMjNhODViOTg1ZGE0NTBjMGM4NDA5NzYxMjdjOWMwYWRmZTBlZjlhNGY3ZTg4Y2U3YTE1ODVkZDU5Y2Y3OGYwZWE1NzUzNWQ2YjFjZDc0NGMxZWU2MmQ3MjY1NzJmNTE0MzI= + # 令牌过期时间 此处单位/毫秒 ,默认4小时,可在此网站生成 https://www.convertworld.com/zh-hans/time/milliseconds.html + token-validity-in-seconds: 14400000 + # 在线用户key + online-key: "online_token:" + # 验证码 + code-key: "captcha_code:" + # token 续期检查时间范围(默认30分钟,单位毫秒),在token即将过期的一段时间内用户操作了,则给用户的token续期 + detect: 1800000 + # 续期时间范围,默认1小时,单位毫秒 + renew: 3600000 + +#是否允许生成代码,生产环境设置为false +generator: + enabled: true + +#是否开启 swagger-ui +swagger: + enabled: true + +# 微信信息配置 +weChat: + appId: wx583d0c321ef43dfe + secret: 1b5eca11a1058361b0f14c5933ef6bd6 + +# 文件存储路径 +file: + mac: + path: ~/file/ + avatar: ~/avatar/ + linux: + path: /home/eladmin/file/ + avatar: /home/eladmin/avatar/ + windows: + path: /eladmin/eladmin-upload/file/ + avatar: /eladmin/eladmin-upload/avatar/ + # 文件大小 /M + maxSize: 100 + avatarMaxSize: 5 diff --git a/eladmin/eladmin-system/src/main/resources/config/application.yml b/eladmin/eladmin-system/src/main/resources/config/application.yml index 95cdc87..622b138 100644 --- a/eladmin/eladmin-system/src/main/resources/config/application.yml +++ b/eladmin/eladmin-system/src/main/resources/config/application.yml @@ -1,5 +1,4 @@ server: - port: 8000 http2: # 启用 HTTP/2 支持,提升传输效率 enabled: true @@ -28,15 +27,7 @@ spring: redis: repositories: enabled: false -# pid: -# file: /自行指定位置/eladmin.pid - redis: - #数据库索引 - database: ${REDIS_DB:1} - host: ${REDIS_HOST:127.0.0.1} - port: ${REDIS_PORT:6379} - password: ${REDIS_PWD:} #连接超时时间 timeout: 5000 # 连接池配置 @@ -62,15 +53,19 @@ task: # 队列容量 queue-capacity: 50 -#七牛云 -qiniu: - # 文件大小 /M - max-size: 15 - #邮箱验证码有效时间/秒 code: expiration: 300 #密码加密传输,前端公钥加密,后端私钥解密 rsa: - private_key: MIIBUwIBADANBgkqhkiG9w0BAQEFAASCAT0wggE5AgEAAkEA0vfvyTdGJkdbHkB8mp0f3FE0GYP3AYPaJF7jUd1M0XxFSE2ceK3k2kw20YvQ09NJKk+OMjWQl9WitG9pB6tSCQIDAQABAkA2SimBrWC2/wvauBuYqjCFwLvYiRYqZKThUS3MZlebXJiLB+Ue/gUifAAKIg1avttUZsHBHrop4qfJCwAI0+YRAiEA+W3NK/RaXtnRqmoUUkb59zsZUBLpvZgQPfj1MhyHDz0CIQDYhsAhPJ3mgS64NbUZmGWuuNKp5coY2GIj/zYDMJp6vQIgUueLFXv/eZ1ekgz2Oi67MNCk5jeTF2BurZqNLR3MSmUCIFT3Q6uHMtsB9Eha4u7hS31tj1UWE+D+ADzp59MGnoftAiBeHT7gDMuqeJHPL4b+kC+gzV4FGTfhR9q3tTbklZkD2A== \ No newline at end of file + private_key: MIIBUwIBADANBgkqhkiG9w0BAQEFAASCAT0wggE5AgEAAkEA0vfvyTdGJkdbHkB8mp0f3FE0GYP3AYPaJF7jUd1M0XxFSE2ceK3k2kw20YvQ09NJKk+OMjWQl9WitG9pB6tSCQIDAQABAkA2SimBrWC2/wvauBuYqjCFwLvYiRYqZKThUS3MZlebXJiLB+Ue/gUifAAKIg1avttUZsHBHrop4qfJCwAI0+YRAiEA+W3NK/RaXtnRqmoUUkb59zsZUBLpvZgQPfj1MhyHDz0CIQDYhsAhPJ3mgS64NbUZmGWuuNKp5coY2GIj/zYDMJp6vQIgUueLFXv/eZ1ekgz2Oi67MNCk5jeTF2BurZqNLR3MSmUCIFT3Q6uHMtsB9Eha4u7hS31tj1UWE+D+ADzp59MGnoftAiBeHT7gDMuqeJHPL4b+kC+gzV4FGTfhR9q3tTbklZkD2A== + +logging: + level: + io.swagger.*: error + me.zhengjie: debug + org.springframework.boot.autoconfigure: ERROR + config: classpath:logback-spring.xml + file: + path: ./online_log \ No newline at end of file diff --git a/eladmin/eladmin-system/src/main/resources/logback-spring.xml b/eladmin/eladmin-system/src/main/resources/logback-spring.xml new file mode 100644 index 0000000..36cd2ce --- /dev/null +++ b/eladmin/eladmin-system/src/main/resources/logback-spring.xml @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + + + + ${CONSOLE_LOG_PATTERN} + UTF-8 + + + + debug + + + + + + + ${log.path}/log_debug.log + + + + [%d{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] [%level] [%X{TRADE_ID}] [%logger{50}.%method] - %msg%n + UTF-8 + + + + + ${log.path}/info/log-debug-%d{yyyy-MM-dd}.%i.log + + + 20MB + + + 30 + + + + debug + ACCEPT + DENY + + + + + + + ${log.path}/log_info.log + + + + [%d{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] [%level] [%X{TRADE_ID}] [%logger{50}.%method] - %msg%n + UTF-8 + + + + ${log.path}/info/log-info-%d{yyyy-MM-dd}.%i.log + + + 20MB + + + 30 + + + + info + ACCEPT + DENY + + + + + + + ${log.path}/log_error.log + + + [%d{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] [%level] [%X{TRADE_ID}] [%logger{50}.%method] - %msg%n + UTF-8 + + + + ${log.path}/info/log-error-%d{yyyy-MM-dd}.%i.log + + + 20MB + + 30 + + + + error + ACCEPT + DENY + + + + + + + + + + + + + \ No newline at end of file