资料内容:
controller层
controller层还有一个类,用于对外提供接口
@RestController
@RequestMapping("/ai")
@CrossOrigin
public class TongYiController {
@Autowired
@Qualifier("tongYiSimpleServiceImpl")
private TongYiService tongYiSimpleService;
1
@GetMapping("/example")
public String completion(
@RequestParam(value = "message", defaultValue = "Tell me a
joke")
String message
) {
return tongYiSimpleService.completion(message);
}
}
service层
service层用于对controller提供服务
public interface TongYiService {
/**
* Hello World example.
*
* @param message conversation content question.
* @return AI answer.
*/
String completion(String message);
}