AI智能工牌的建表语句

This commit is contained in:
spllzh
2025-08-07 22:31:05 +08:00
parent 6dfe402eed
commit 58a131e3c8
26 changed files with 817 additions and 42 deletions

View File

@@ -0,0 +1,31 @@
package com.rj;
import dev.langchain4j.model.openai.OpenAiChatModel;
/**
* Author: 李中华 wx: spllzh email(qq): 28668817@qq.com
* Date: 2025/8/4 9:55
**/
public class AppTest {
public static void main(String[] args) {
System.out.println("Hello World!");
}
public AppTest( String testName )
{
System.out.println( "chatModel Hello World!" );
// 构建chatmodel对象
OpenAiChatModel chatModel = OpenAiChatModel.builder()
.apiKey(System.getenv("DASHSCOPE_API_KEY"))
.baseUrl("https://dashscope.aliyuncs.com/compatible-mode/v1")
.modelName("qwen-plus")
.logRequests(true) // 输出请求大模型的日志
.logResponses(true)
.build();
String chat = chatModel.chat("2008年奥运会哪个国际金牌最多");
System.out.println(chat);
}
}

View File

@@ -0,0 +1,13 @@
package com.rj;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class Langchain4jHeima20250803ApplicationTests {
@Test
void contextLoads() {
}
}

View File

@@ -0,0 +1,80 @@
package com.rj.service;
/**
* Author: 李中华 wx: spllzh email(qq): 28668817@qq.com
* Date: 2025/8/5 19:02
**/
import com.rj.Langchain4jHeima20250803Application;
import com.rj.pojo.Reservation;
import com.rj.service.impl.ReservationServiceImpl;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import static org.junit.jupiter.api.Assertions.*;
import java.time.LocalDateTime;
import java.util.List;
@SpringBootTest(classes = Langchain4jHeima20250803Application.class)
class ReservationServiceTest {
@Autowired
private IReservationService reservationService;
@Test
void testSaveReservation() {
// 创建测试数据
Reservation reservation = new Reservation();
reservation.setName("张三");
reservation.setGender("");
reservation.setPhone("13800138000");
reservation.setProvince("北京市");
reservation.setDatetime(LocalDateTime.now());
// 测试保存功能
boolean result = reservationService.save(reservation);
// 验证保存成功
assertTrue(result);
assertNotNull(reservation.getId());
}
@Test
void testGetReservationsByPhone() {
// 先保存一条测试数据
Reservation reservation = new Reservation();
reservation.setName("李四");
reservation.setGender("");
reservation.setPhone("13900139000");
reservation.setProvince("上海市");
reservation.setDatetime(LocalDateTime.now());
reservationService.save(reservation);
// 测试根据手机号查询功能
List<Reservation> reservations = ((ReservationServiceImpl) reservationService)
.getReservationsByPhone("13900139000");
// 验证查询结果
assertNotNull(reservations);
assertFalse(reservations.isEmpty());
assertEquals("李四", reservations.get(0).getName());
assertEquals("13900139000", reservations.get(0).getPhone());
}
@Test
void testGetReservationsByPhoneWithNoResults() {
// 测试查询不存在的手机号
List<Reservation> reservations = ((ReservationServiceImpl) reservationService)
.getReservationsByPhone("00000000000");
// 验证查询结果为空
assertNotNull(reservations);
assertTrue(reservations.isEmpty());
}
}