Commit 7493a709 authored by 杨伊博's avatar 杨伊博

add page limit

parent 5dbce86a
......@@ -62,6 +62,12 @@
</dependency>
<!--util-->
<dependency>
<groupId>com.jf</groupId>
<artifactId>page-mysql</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
......
......@@ -9,7 +9,7 @@ import static org.springframework.boot.SpringApplication.*;
* Created by yangyibo on 17/1/17.
*/
@ComponentScan(basePackages ="com.us.example")
@ComponentScan(basePackages ="com.us.example,com.jf")
@SpringBootApplication
@EnableScheduling
public class Application {
......
package com.us.example.config;
import javax.sql.DataSource;
import com.jf.page.interceptor.PageInterceptor;
import org.apache.ibatis.plugin.Interceptor;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
......@@ -19,6 +21,7 @@ public class MyBatisConfig {
public SqlSessionFactoryBean sqlSessionFactory(ApplicationContext applicationContext) throws Exception {
SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
sessionFactory.setDataSource(dataSource);
sessionFactory.setPlugins(new Interceptor[]{new PageInterceptor()});
sessionFactory.setMapperLocations(applicationContext.getResources("classpath*:mapper/*.xml"));
return sessionFactory;
}
......
......@@ -32,7 +32,7 @@ public class UserController {
/***
* api :localhost:8099/users?id=99
*
* http://localhost:8099/users?limit=2&page=2
* @param request
* @return
*/
......
......@@ -4,6 +4,7 @@ package com.us.example.service.Impl;
import java.util.Date;
import java.util.Map;
import com.jf.page.annotation.Page;
import javafx.scene.input.DataFormat;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
......@@ -30,14 +31,16 @@ public class UserServiceImpl implements UserService {
* @param map
* @return
*/
@Page
@Override
public Object getList(Map<String, Object> map) {
printName();
return userDao.getList(map);
}
//每一秒调用一次 -- 用于测试
@Scheduled(cron = "0/30 * * * * ?")
public void printName() {
@Override
public void printName() {
System.out.println(new Date());
System.out.println("my name is yang ");
}
......
......@@ -17,5 +17,6 @@ public interface UserService {
*/
Object getList(Map<String, Object> map);
void printName();
}
\ No newline at end of file
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