4 changed files with 128 additions and 0 deletions
@ -0,0 +1,72 @@ |
|||
package bc.mm.mis.core.bean; |
|||
|
|||
import javax.persistence.*; |
|||
|
|||
@Entity |
|||
@Table(name = "country") |
|||
public class Country { |
|||
@Id |
|||
@GeneratedValue(strategy = GenerationType.IDENTITY) |
|||
private Integer id; |
|||
private String code; |
|||
private String name; |
|||
|
|||
@Column(name = "country_code") |
|||
private String countryCode; |
|||
|
|||
private Integer order; |
|||
|
|||
@Column(name = "en_name") |
|||
private String enName; |
|||
|
|||
public Integer getId() { |
|||
return id; |
|||
} |
|||
|
|||
public void setId(Integer id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
public String getCode() { |
|||
return code; |
|||
} |
|||
|
|||
public void setCode(String code) { |
|||
this.code = code; |
|||
} |
|||
|
|||
public String getName() { |
|||
return name; |
|||
} |
|||
|
|||
public void setName(String name) { |
|||
this.name = name; |
|||
} |
|||
|
|||
public String getCountryCode() { |
|||
return countryCode; |
|||
} |
|||
|
|||
public void setCountryCode(String countryCode) { |
|||
this.countryCode = countryCode; |
|||
} |
|||
|
|||
public Integer getOrder() { |
|||
return order; |
|||
} |
|||
|
|||
public void setOrder(Integer order) { |
|||
this.order = order; |
|||
} |
|||
|
|||
public String getEnName() { |
|||
return enName; |
|||
} |
|||
|
|||
public void setEnName(String enName) { |
|||
this.enName = enName; |
|||
} |
|||
|
|||
public Country() { |
|||
} |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
package bc.mm.mis.core.dao; |
|||
|
|||
import bc.mm.mis.core.bean.Country; |
|||
import org.springframework.data.domain.Page; |
|||
import org.springframework.data.domain.Pageable; |
|||
import org.springframework.data.jpa.repository.JpaRepository; |
|||
import org.springframework.stereotype.Repository; |
|||
|
|||
@Repository |
|||
public interface CountryDao extends JpaRepository<Country,Integer> { |
|||
/** |
|||
* 带分页的 |
|||
* @param pageable |
|||
* @return |
|||
*/ |
|||
Page<Country> findAll(Pageable pageable); |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
package bc.mm.mis.core.service; |
|||
|
|||
import bc.mm.mis.core.bean.Country; |
|||
|
|||
import java.util.List; |
|||
|
|||
public interface CountryService { |
|||
/** |
|||
* fenye |
|||
* @param page |
|||
* @param size |
|||
* @return |
|||
*/ |
|||
List<Country> getCountryList(int page, int size); |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
package bc.mm.mis.core.service.impl; |
|||
|
|||
import bc.mm.mis.core.bean.Country; |
|||
import bc.mm.mis.core.dao.CountryDao; |
|||
import bc.mm.mis.core.service.CountryService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.data.domain.Page; |
|||
import org.springframework.data.domain.PageRequest; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Service |
|||
public class CountryServiceImpl implements CountryService { |
|||
@Autowired |
|||
private CountryDao countryDao; |
|||
|
|||
@Override |
|||
public List<Country> getCountryList(int page, int size) { |
|||
PageRequest pageRequest = PageRequest.of(page,size); |
|||
Page<Country> countryPage = countryDao.findAll(pageRequest); |
|||
return countryPage.getContent(); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue