Commit 9444a934 authored by sumet's avatar sumet

late

parent 379320c4
package controllers;
import models.Computer;
import models.Thai;
import play.data.Form;
import play.data.FormFactory;
import play.libs.concurrent.HttpExecutionContext;
......@@ -12,6 +13,8 @@ import repository.ComputerRepository;
import javax.inject.Inject;
import javax.persistence.PersistenceException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletionStage;
......@@ -50,6 +53,12 @@ public class HomeController extends Controller {
return GO_HOME;
}
public Result thai(){
List<Thai> Thailand = new ArrayList<>();
Thailand=Thai.find.all();
return ok(views.html.thai.render(Thailand));
}
/**
* Display the paginated list of computers.
*
......
package models;
import io.ebean.Finder;
import javax.persistence.Entity;
import javax.persistence.Id;
@Entity
public class Thai extends BaseModel {
private static final long serialVersionUID = 1L;
@Id
public Long id;
public String Coun;
public String Prov;
public static final Finder <Long, Thai> find = new Finder<>(Thai.class);
}
\ No newline at end of file
@(thai:List[models.Thai])
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Country Database</title>
<link rel="stylesheet" href="/assets/stylesheets/Sumet.css">
</head>
<body class="background-info">
<nav class="navbar navbar-dark bg-dark">
<a class="navbar-brand" href="#">Country Database</a>
</nav>
<br>
<center><h1>จำนวนจังหวัดทั้งหมด @thai.size จังหวัด</h1></center>
<table border="1" width="600" class="table table-borderless table-dark" align="center">
<thead class="thead color">
<tr align="center">
<th>ID</th>
<th>PROVINCE</th>
<th>COUNTRY</th>
</tr>
</thead>
<tbody>
@for(t <- thai){
<tr align="center">
<td>@t.id</td>
<td>@t.Prov</td>
<td>@t.Coun</td>
</tr>
}
</tbody>
</table>
</body>
</html>
# --- First database schema
# --- !Ups
# --- Created by Ebean DDL
# To stop Ebean DDL generation, remove this comment and start using Evolutions
# --- !Ups
create table company (
id bigint not null,
name varchar(255),
constraint pk_company primary key (id))
;
id bigint auto_increment not null,
name varchar(255),
constraint pk_company primary key (id)
);
create table computer (
id bigint not null,
name varchar(255),
introduced timestamp,
discontinued timestamp,
company_id bigint,
constraint pk_computer primary key (id))
;
create sequence company_seq start with 1000;
create sequence computer_seq start with 1000;
alter table computer add constraint fk_computer_company_1 foreign key (company_id) references company (id) on delete restrict on update restrict;
create index ix_computer_company_1 on computer (company_id);
# --- !Downs
SET REFERENTIAL_INTEGRITY FALSE;
id bigint auto_increment not null,
name varchar(255),
introduced timestamp,
discontinued timestamp,
company_id bigint,
constraint pk_computer primary key (id)
);
create table thai (
id bigint auto_increment not null,
coun varchar(255),
prov varchar(255),
constraint pk_thai primary key (id)
);
alter table computer add constraint fk_computer_company_id foreign key (company_id) references company (id) on delete restrict on update restrict;
create index ix_computer_company_id on computer (company_id);
# --- !Downs
alter table computer drop constraint if exists fk_computer_company_id;
drop index if exists ix_computer_company_id;
drop table if exists company;
drop table if exists computer;
SET REFERENTIAL_INTEGRITY TRUE;
drop sequence if exists company_seq;
drop sequence if exists computer_seq;
drop table if exists thai;
......@@ -5,6 +5,8 @@
# Default path will just redirect to the computer list
GET / controllers.HomeController.index()
GET /thai controllers.HomeController.thai()
# Computers list (look at the default values for pagination parameters)
GET /computers controllers.HomeController.list(p:Int ?= 0, s ?= "name", o ?= "asc", f ?= "")
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment