Files
smartDriveEE/src/main/java/com/rj/tools/ReservationTool.java
2025-08-07 22:31:05 +08:00

43 lines
1.5 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.rj.tools;
import com.rj.pojo.Reservation;
import com.rj.service.IReservationService;
import dev.langchain4j.agent.tool.P;
import dev.langchain4j.agent.tool.Tool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
/**
* Author: 李中华 wx: spllzh email(qq): 28668817@qq.com
* Date: 2025/8/5 20:36
**/
@Component
public class ReservationTool {
@Autowired
private IReservationService reservationService;
@Tool("根据手机号查询志愿填报预约信息")
public String getReservationsByPhone(String phone) {
return reservationService.getReservationsByPhone(phone).toString();
}
@Tool("保存志愿填报预约信息")
public String saveReservation(String name ,
@P("考生姓名") String gender ,
@P("考生手机号")String phone ,
@P("考生手省份")String province ,
@P("考生预约时间,格式为yyy-MM-dd'T' HH:mm") String datetime) {
Reservation reservation = new Reservation();
reservation.setName(name);
reservation.setGender(gender);
reservation.setPhone(phone);
reservation.setProvince(province);
reservation.setDatetime(LocalDateTime.parse(datetime));
return reservationService.saveReservation(reservation) ? "保存成功" : "保存失败";
}
}