This commit is contained in:
ageer
2024-04-01 22:21:29 +08:00
parent cead269b19
commit dea23f13ef
552 changed files with 2144 additions and 154437 deletions

View File

@@ -45,8 +45,6 @@ public class AuthController {
private final SysRegisterService registerService;
private final ISysTenantService tenantService;
/**
* 登录方法
*

View File

@@ -85,6 +85,7 @@ public class CaptchaController {
*
* @param emailRequest 用户邮箱
*/
//@PostMapping("/resource/email/code")
@PostMapping("/resource/email/code")
public R<Void> emailCode(@RequestBody @Valid EmailRequest emailRequest) {
if (!mailProperties.getEnabled()) {

View File

@@ -3,8 +3,8 @@ package com.xmzs.controller;
import com.xmzs.common.chat.domain.request.ChatRequest;
import com.xmzs.common.chat.domain.request.Dall3Request;
import com.xmzs.common.chat.domain.request.MjTaskRequest;
import com.xmzs.common.chat.entity.Tts.TextToSpeech;
import com.xmzs.common.chat.entity.files.UploadFileResponse;
import com.xmzs.common.chat.entity.images.Item;
import com.xmzs.common.chat.entity.whisper.WhisperResponse;
import com.xmzs.common.core.domain.R;
@@ -21,25 +21,15 @@ import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.io.InputStreamResource;
import org.springframework.http.MediaType;
import org.springframework.core.io.Resource;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
import org.springframework.core.io.Resource;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import retrofit2.Response;
/**
* 描述:
*
@@ -64,6 +54,16 @@ public class ChatController {
return ISseService.sseChat(chatRequest);
}
/**
* 上传文件
*/
@PostMapping("/v1/upload")
@ResponseBody
public UploadFileResponse upload(@RequestPart("file") MultipartFile file) {
return ISseService.upload(file);
}
/**
* 语音转文本
*
@@ -94,18 +94,6 @@ public class ChatController {
return R.ok(ISseService.dall3(request));
}
/**
* 扣除mj绘图费用
*
* @return
*/
@PostMapping("/mjTask")
@ResponseBody
public R<String> mjTask(@RequestBody MjTaskRequest mjTaskRequest) {
ISseService.mjTask(mjTaskRequest);
return R.ok();
}
/**
* 聊天记录
*/

View File

@@ -23,7 +23,6 @@ import com.xmzs.system.domain.vo.SysUserVo;
import com.xmzs.system.service.IPaymentOrdersService;
import com.xmzs.system.service.ISysUserService;
import com.xmzs.system.util.OrderNumberGenerator;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
@@ -43,15 +42,16 @@ public class PayController {
private final IPaymentOrdersService paymentOrdersService;
private final PayConfig payConfig;
/**
* 获取支付二维码
*
* @Date 2023/7/3
* @param response
* @return void
**/
@PostMapping("/payUrl")
public R<PaymentOrdersVo> payUrl(HttpServletResponse response, @RequestBody OrderRequest orderRequest) {
public R<PaymentOrdersVo> payUrl(@RequestBody OrderRequest orderRequest) {
LoginUser loginUser = LoginHelper.getLoginUser();
// 创建订单
PaymentOrdersBo paymentOrders = new PaymentOrdersBo();
@@ -115,9 +115,9 @@ public class PayController {
public String returnUrl(PayResponse payResponse) {
// 校验签名
String mdString = "money=" + payResponse.getMoney() + "&name=" + payResponse.getName() +
"&out_trade_no=" + payResponse.getOut_trade_no() + "&pid=" + PayConfig.pid +
"&out_trade_no=" + payResponse.getOut_trade_no() + "&pid=" + payConfig.getPid() +
"&trade_no=" + payResponse.getTrade_no() + "&trade_status=" + payResponse.getTrade_status() +
"&type=" + payResponse.getType() + PayConfig.key;
"&type=" + payResponse.getType() + payConfig.getKey();
String sign = MD5Util.GetMD5Code(mdString);
if(!sign.equals(payResponse.getSign())){
throw new BaseException("校验签名失败!");
@@ -136,10 +136,8 @@ public class PayController {
paymentOrdersVo.setPaymentMethod(payResponse.getType());
BeanUtil.copyProperties(paymentOrdersVo,paymentOrdersBo);
paymentOrdersService.updateByBo(paymentOrdersBo);
SysUserVo sysUserVo = userService.selectUserById(paymentOrdersVo.getUserId());
if(money>9.9){
money = money*2;
}
sysUserVo.setUserBalance(sysUserVo.getUserBalance()+money);
SysUserBo sysUserBo = new SysUserBo();
BeanUtil.copyProperties(sysUserVo,sysUserBo);

View File

@@ -1,7 +1,7 @@
--- # 监控中心配置
spring.boot.admin.client:
# 增加客户端开关
enabled: true
enabled: false
url: http://localhost:9090/admin
instance:
service-host-type: IP
@@ -51,36 +51,36 @@ spring:
# rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
url: jdbc:mysql://127.0.0.1:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
username: ry-vue
password: xxx
password: ry-vue
# 从库数据源
# slave:
# lazy: true
# type: ${spring.datasource.type}
# driverClassName: com.mysql.cj.jdbc.Driver
# url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
# username:
# password:
# oracle:
# type: ${spring.datasource.type}
# driverClassName: oracle.jdbc.OracleDriver
# url: jdbc:oracle:thin:@//localhost:1521/XE
# username: ROOT
# password: root
# hikari:
# connectionTestQuery: SELECT 1 FROM DUAL
# postgres:
# type: ${spring.datasource.type}
# driverClassName: org.postgresql.Driver
# url: jdbc:postgresql://localhost:5432/postgres?useUnicode=true&characterEncoding=utf8&useSSL=true&autoReconnect=true&reWriteBatchedInserts=true
# username: root
# password: root
# sqlserver:
# type: ${spring.datasource.type}
# driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
# url: jdbc:sqlserver://localhost:1433;DatabaseName=tempdb;SelectMethod=cursor;encrypt=false;rewriteBatchedStatements=true
# username: SA
# password: root
# slave:
# lazy: true
# type: ${spring.datasource.type}
# driverClassName: com.mysql.cj.jdbc.Driver
# url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
# username:
# password:
# oracle:
# type: ${spring.datasource.type}
# driverClassName: oracle.jdbc.OracleDriver
# url: jdbc:oracle:thin:@//localhost:1521/XE
# username: ROOT
# password: root
# hikari:
# connectionTestQuery: SELECT 1 FROM DUAL
# postgres:
# type: ${spring.datasource.type}
# driverClassName: org.postgresql.Driver
# url: jdbc:postgresql://localhost:5432/postgres?useUnicode=true&characterEncoding=utf8&useSSL=true&autoReconnect=true&reWriteBatchedInserts=true
# username: root
# password: root
# sqlserver:
# type: ${spring.datasource.type}
# driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
# url: jdbc:sqlserver://localhost:1433;DatabaseName=tempdb;SelectMethod=cursor;encrypt=false;rewriteBatchedStatements=true
# username: SA
# password: root
hikari:
# 最大连接池数量
maxPoolSize: 20

View File

@@ -4,7 +4,7 @@ spring.servlet.multipart.location: /ruoyi/server/temp
--- # 监控中心配置
spring.boot.admin.client:
# 增加客户端开关
enabled: true
enabled: false
url: http://localhost:9090/admin
instance:
service-host-type: IP

View File

@@ -212,27 +212,6 @@ mybatis-encryptor:
# 公私钥 非对称算法的公私钥 如SM2RSA
publicKey:
privateKey:
--- # mail 邮件发送
mail:
enabled: true
host: smtp.163.com
port: 465
# 是否需要用户名密码验证
auth: true
# 发送方遵循RFC-822标准
from: ageerle@163.com
# 用户名注意如果使用foxmail邮箱此处user为qq号
user: ageerle@163.com
# 密码(填写授权码)
pass: xxxx
# 使用 STARTTLS安全连接STARTTLS是对纯文本通信协议的扩展。
starttlsEnable: true
# 使用SSL安全连接
sslEnable: true
# SMTP超时时长单位毫秒缺省值不超时
timeout: 0
# Socket连接超时值单位毫秒缺省值不超时
connectionTimeout: 0
# Swagger配置
swagger:
@@ -313,15 +292,12 @@ management:
--- # websocket
websocket:
enabled: true
enabled: false
# 路径
path: ''
# 设置访问源地址
allowedOrigins: '*'
# chatgpt配置信息
chat:
apiKey: 'sk-xxx'
apiHost: 'https://api.pandarobot.chat/'
# 微信小程序配置信息
wx:
miniapp:
@@ -338,6 +314,8 @@ baidu:
textReview:
apiKey: '' # apiKey
secretKey: '' # secretKey
appKey: xxxxxxxxxxxxxxxxx
secretKey: xxxxxxxxxxxxxxxxxxxxxxx
wechat:
# 是否使用微信 true/false
@@ -353,23 +331,62 @@ keyword:
image: "ai画图"
# ai语音指令(TTS模型 https://platform.openai.com/docs/api-reference/audio)
audio: "ai语音"
mj:
api-secret:
api-secret: 'sk-xx'
task-store:
type: in_memory
timeout: 30d
translate-way: gpt
# proxy:
# host: 127.0.0.1
# port: 10809
# proxy:
# host: 127.0.0.1
# port: 10809
ng-discord:
server: https://discord.pandarobot.chat/
cdn: https://app.pandarobot.chat/
wss: https://gateway.pandarobot.chat/
server: 'https://xxx.pandarobot.chat/'
cdn: 'https://xxx.pandarobot.chat/'
wss: 'https://xxx.pandarobot.chat/'
openai:
gpt-api-url: 'https://api.gptgod.online/'
gpt-api-key: 'xxxxxxx'
gpt-api-url: 'https://api.pandarobot.chat/'
gpt-api-key: 'sk-xx'
accounts:
- guild-id: 'xxxxxx'
channel-id: 'xxxxx'
user-token: 'xxxxxxx'
- guild-id: 'xx'
channel-id: 'xx'
user-token: 'xx'
--- # mail 邮件发送
mail:
enabled: true
host: smtp.163.com
port: 465
# 是否需要用户名密码验证
auth: true
# 发送方遵循RFC-822标准
from: ageerle@163.com
# 用户名注意如果使用foxmail邮箱此处user为qq号
user: ageerle@163.com
# 密码(填写授权码)
pass: TOGXBVPYFVPFRQMQ
# 使用 STARTTLS安全连接STARTTLS是对纯文本通信协议的扩展。
starttlsEnable: true
# 使用SSL安全连接
sslEnable: true
# SMTP超时时长单位毫秒缺省值不超时
timeout: 0
# Socket连接超时值单位毫秒缺省值不超时
connectionTimeout: 0
# chatgpt配置信息
chat:
apiKey: 'sk-xxx'
apiHost: 'https://api.pandarobot.chat/'
# 支付配置信息
pay:
pid: 'xxx'
key: 'xxx'
payUrl: 'https://pay.pandarobot.chat/mapi.php'
notify_url: 'https://www.pandarobot.chat/pay/returnUrl'
return_url: 'https://www.pandarobot.chat/pay/notifyUrl'
type: 'wxpay'
device: 'pc'
sign_type: 'MD5'

View File

@@ -0,0 +1,45 @@
package com.xmzs.test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
/**
* 断言单元测试案例
*
* @author Lion Li
*/
@DisplayName("断言单元测试案例")
public class AssertUnitTest {
@DisplayName("测试 assertEquals 方法")
@Test
public void testAssertEquals() {
Assertions.assertEquals("666", new String("666"));
Assertions.assertNotEquals("666", new String("666"));
}
@DisplayName("测试 assertSame 方法")
@Test
public void testAssertSame() {
Object obj = new Object();
Object obj1 = obj;
Assertions.assertSame(obj, obj1);
Assertions.assertNotSame(obj, obj1);
}
@DisplayName("测试 assertTrue 方法")
@Test
public void testAssertTrue() {
Assertions.assertTrue(true);
Assertions.assertFalse(true);
}
@DisplayName("测试 assertNull 方法")
@Test
public void testAssertNull() {
Assertions.assertNull(null);
Assertions.assertNotNull(null);
}
}

View File

@@ -0,0 +1,70 @@
package com.xmzs.test;
import com.xmzs.common.core.config.RuoYiConfig;
import org.junit.jupiter.api.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import java.util.concurrent.TimeUnit;
/**
* 单元测试案例
*
* @author Lion Li
*/
@SpringBootTest // 此注解只能在 springboot 主包下使用 需包含 main 方法与 yml 配置文件
@DisplayName("单元测试案例")
public class DemoUnitTest {
@Autowired
private RuoYiConfig ruoYiConfig;
@DisplayName("测试 @SpringBootTest @Test @DisplayName 注解")
@Test
public void testTest() {
System.out.println(ruoYiConfig);
}
@Disabled
@DisplayName("测试 @Disabled 注解")
@Test
public void testDisabled() {
System.out.println(ruoYiConfig);
}
@Timeout(value = 2L, unit = TimeUnit.SECONDS)
@DisplayName("测试 @Timeout 注解")
@Test
public void testTimeout() throws InterruptedException {
Thread.sleep(3000);
System.out.println(ruoYiConfig);
}
@DisplayName("测试 @RepeatedTest 注解")
@RepeatedTest(3)
public void testRepeatedTest() {
System.out.println(666);
}
@BeforeAll
public static void testBeforeAll() {
System.out.println("@BeforeAll ==================");
}
@BeforeEach
public void testBeforeEach() {
System.out.println("@BeforeEach ==================");
}
@AfterEach
public void testAfterEach() {
System.out.println("@AfterEach ==================");
}
@AfterAll
public static void testAfterAll() {
System.out.println("@AfterAll ==================");
}
}

View File

@@ -0,0 +1,72 @@
package com.xmzs.test;
import com.xmzs.common.core.enums.UserType;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;
import org.junit.jupiter.params.provider.MethodSource;
import org.junit.jupiter.params.provider.NullSource;
import org.junit.jupiter.params.provider.ValueSource;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;
/**
* 带参数单元测试案例
*
* @author Lion Li
*/
@DisplayName("带参数单元测试案例")
public class ParamUnitTest {
@DisplayName("测试 @ValueSource 注解")
@ParameterizedTest
@ValueSource(strings = {"t1", "t2", "t3"})
public void testValueSource(String str) {
System.out.println(str);
}
@DisplayName("测试 @NullSource 注解")
@ParameterizedTest
@NullSource
public void testNullSource(String str) {
System.out.println(str);
}
@DisplayName("测试 @EnumSource 注解")
@ParameterizedTest
@EnumSource(UserType.class)
public void testEnumSource(UserType type) {
System.out.println(type.getUserType());
}
@DisplayName("测试 @MethodSource 注解")
@ParameterizedTest
@MethodSource("getParam")
public void testMethodSource(String str) {
System.out.println(str);
}
public static Stream<String> getParam() {
List<String> list = new ArrayList<>();
list.add("t1");
list.add("t2");
list.add("t3");
return list.stream();
}
@BeforeEach
public void testBeforeEach() {
System.out.println("@BeforeEach ==================");
}
@AfterEach
public void testAfterEach() {
System.out.println("@AfterEach ==================");
}
}

View File

@@ -0,0 +1,54 @@
package com.xmzs.test;
import org.junit.jupiter.api.*;
import org.springframework.boot.test.context.SpringBootTest;
/**
* 标签单元测试案例
*
* @author Lion Li
*/
@SpringBootTest
@DisplayName("标签单元测试案例")
public class TagUnitTest {
@Tag("dev")
@DisplayName("测试 @Tag dev")
@Test
public void testTagDev() {
System.out.println("dev");
}
@Tag("prod")
@DisplayName("测试 @Tag prod")
@Test
public void testTagProd() {
System.out.println("prod");
}
@Tag("local")
@DisplayName("测试 @Tag local")
@Test
public void testTagLocal() {
System.out.println("local");
}
@Tag("exclude")
@DisplayName("测试 @Tag exclude")
@Test
public void testTagExclude() {
System.out.println("exclude");
}
@BeforeEach
public void testBeforeEach() {
System.out.println("@BeforeEach ==================");
}
@AfterEach
public void testAfterEach() {
System.out.println("@AfterEach ==================");
}
}