This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RestController | |
public class EmployeeController { | |
@Autowired | |
private EmployeeRepository repository; | |
@GetMapping("/employees") | |
public List<Employee> getAllEmployees() { | |
return repository.findAll(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface EmployeeRepository extends JpaRepository<Employee, Long> { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Entity | |
public class Employee { | |
@Id | |
@GeneratedValue(strategy = GenerationType.IDENTITY) | |
private Long id; | |
private String name; | |
private String role; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import androidx.compose.Composable | |
import androidx.ui.core.Text | |
import androidx.ui.foundation.Image | |
@Composable | |
fun SimpleImage(source: Any) { | |
Image(source = source) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import androidx.compose.Composable | |
import androidx.ui.core.Text | |
import androidx.ui.material.TextField | |
@Composable | |
fun SimpleTextField(onValueChange: (String) -> Unit) { | |
var text by state { "" } | |
TextField(value = text, onValueChange = { text = it; onValueChange(it) }) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import androidx.compose.Composable | |
import androidx.ui.core.Text | |
import androidx.ui.material.Button | |
@Composable | |
fun SimpleButton(onClick: () -> Unit) { | |
Button(text = "Click me", onClick = onClick) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import androidx.compose.Composable | |
import androidx.ui.core.Text | |
import androidx.ui.core.dp | |
import androidx.ui.core.setContent | |
import androidx.ui.foundation.VerticalScroller | |
import androidx.ui.graphics.Color | |
import androidx.ui.layout.Column | |
import androidx.ui.layout.Spacing | |
import androidx.ui.material.MaterialTheme | |
import androidx.ui.material.Surface |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import androidx.compose.Composable | |
import androidx.ui.core.Text | |
import androidx.ui.core.setContent | |
import androidx.ui.engine.geometry.Rect | |
import androidx.ui.engine.geometry.size | |
import androidx.ui.graphics.Color | |
import androidx.ui.layout.Container | |
import androidx.ui.material.MaterialTheme | |
import androidx.ui.material.surface.Surface | |
import androidx.ui.tooling.preview.Preview |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Call<ResponseBody> call = chatGPTAPI.sendRequest("Hello, how are you?", 100, 0.5f); | |
call.enqueue(new Callback<ResponseBody>() { | |
@Override | |
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) { | |
if (response.isSuccessful()) { | |
try { | |
// Use response.body() to access the response from the API | |
String responseString = response.body().string(); | |
// Do something with the response | |
} catch (IOException e) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import retrofit2.Retrofit; | |
import retrofit2.converter.gson.GsonConverterFactory; | |
Retrofit retrofit = new Retrofit.Builder() | |
.baseUrl("https://api.openai.com") | |
.addConverterFactory(GsonConverterFactory.create()) | |
.build(); | |
ChatGPTAPI chatGPTAPI = retrofit.create(ChatGPTAPI.class); |
NewerOlder