AI智能工牌的建表语句
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
package com.cst.langchain4jheima;
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.cst.langchain4jheima;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class Langchain4jHeima20250803ApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
package com.cst.langchain4jheima.service;
|
||||
|
||||
/**
|
||||
* Author: 李中华 wx: spllzh email(qq): 28668817@qq.com
|
||||
* Date: 2025/8/5 19:02
|
||||
**/
|
||||
|
||||
|
||||
import com.cst.langchain4jheima.Langchain4jHeima20250803Application;
|
||||
import com.cst.langchain4jheima.pojo.Reservation;
|
||||
|
||||
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;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
|
||||
@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 = ((com.cst.langchain4jheima.service.impl.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 = ((com.cst.langchain4jheima.service.impl.ReservationServiceImpl) reservationService)
|
||||
.getReservationsByPhone("00000000000");
|
||||
|
||||
// 验证查询结果为空
|
||||
assertNotNull(reservations);
|
||||
assertTrue(reservations.isEmpty());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user