Commit 8de48b09 authored by 李丛阳's avatar 李丛阳

完善rows page

parent 85f09dc1
......@@ -19,6 +19,10 @@ public class PaginationController<T> extends ResponseController {
protected static final String PAGINATIONKEY = "pagination";
protected static final int INIT_PAGE = 1;
protected static final int INIT_ROWS = 10;
public PaginationController() {
}
......@@ -32,10 +36,9 @@ public class PaginationController<T> extends ResponseController {
}
@ModelAttribute
private void setPagnationAttribute(HttpServletRequest request, Integer rows, Integer page, String sort, String order) {
PageUtil _paginationUtility;
private void setPagnationAttribute(HttpServletRequest request, Integer rows, Integer page, String sort) {
PageUtil _paginationUtility = new PageUtil();
if(rows != null && page != null && sort != null ) {
_paginationUtility = new PageUtil();
_paginationUtility.setPageNum(page.intValue());
_paginationUtility.setPageSize(rows.intValue());
_paginationUtility.setOrderBy(sort);
......@@ -43,15 +46,18 @@ public class PaginationController<T> extends ResponseController {
}
else if(rows != null && page != null) {
_paginationUtility = new PageUtil();
_paginationUtility.setPageNum(page.intValue());
_paginationUtility.setPageSize(rows.intValue());
request.setAttribute(PAGINATIONKEY, _paginationUtility);
} else if(sort != null && order != null) {
_paginationUtility = new PageUtil();
_paginationUtility.setOrderBy(sort + " " + order);
request.setAttribute(PAGINATIONKEY, _paginationUtility);
} else if(sort != null) {
_paginationUtility.setOrderBy(sort);
}
else{
_paginationUtility.setPageNum(INIT_ROWS);
_paginationUtility.setPageSize(INIT_PAGE);
}
request.setAttribute(PAGINATIONKEY, _paginationUtility);
}
......
......@@ -29,7 +29,7 @@ import java.util.List;
* Created by ${author} on ${.now}.
*/
@RestController
@RequestMapping("${table.mappingPath!}")
@RequestMapping("${table.entityName?lower_case}")
public class ${table.entityName}Controller extends PaginationController<${table.entityName}> {
@Autowired
......
......@@ -20,8 +20,8 @@ public interface ${table.entityName}Repository extends BaseMapper<${table.entity
*
*/
@Select("<script>select * from ${table.tableName} where 1=1 "
+ "<if test=\"delFlag !=null and delFlag != '' \">and del_flag = ${r'#{delFlag}'} </if>' "
+ "<if test=\"flag !=null and flag != '' \">and flag = ${r'#{flag}'} </if>' "
+ "<if test=\"delFlag !=null and delFlag != '' \">and del_flag = ${r'#{delFlag}'} </if> "
+ "<if test=\"flag !=null and flag != '' \">and flag = ${r'#{flag}'} </if> "
+ "</script>")
@ResultMap(value = "BaseResultMap" )
List<${table.entityName}> query${table.entityName}s(${table.entityName} ${table.entityName?uncap_first});
......
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