-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ef26fe5
commit 3b1320c
Showing
11 changed files
with
59 additions
and
78 deletions.
There are no files selected for viewing
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
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
1 change: 0 additions & 1 deletion
1
...s-history/src/main/java/com/zhangjiashuai/yyetshistory/controller/ResourceController.java
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
27 changes: 21 additions & 6 deletions
27
...s-history/src/main/java/com/zhangjiashuai/yyetshistory/repository/ResourceRepository.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,38 @@ | ||
package com.zhangjiashuai.yyetshistory.repository; | ||
|
||
import cn.hutool.core.collection.ListUtil; | ||
import cn.hutool.db.PageResult; | ||
import com.zhangjiashuai.yyetshistory.entity.ResourceDO; | ||
|
||
import java.util.List; | ||
|
||
public interface ResourceRepository { | ||
|
||
int DEFAULT_PAGE_SIZE = 20; | ||
|
||
ResourceDO findById(long id); | ||
|
||
List<ResourceDO> findByName(String name); | ||
List<ResourceDO> findByNameLike(String name); | ||
|
||
ResourceDO findOneByName(String name); | ||
|
||
List<ResourceDO> findAll(); | ||
|
||
PageResult<ResourceDO> selectPage(String name, int pageNo); | ||
|
||
PageResult<ResourceDO> selectPage(String name, int pageNo, int pageSize); | ||
|
||
long countByNameLike(String name); | ||
int countByNameLike(String name); | ||
|
||
default PageResult<ResourceDO> selectPage(String name, int pageNo) { | ||
return selectPage(name, pageNo, DEFAULT_PAGE_SIZE); | ||
} | ||
|
||
default PageResult<ResourceDO> selectPage(String name, int pageNo, int pageSize) { | ||
int count = countByNameLike(name); | ||
PageResult<ResourceDO> pageResult = new PageResult<>(pageNo, pageSize, count); | ||
if(count == 0) { | ||
return pageResult; | ||
} | ||
List<ResourceDO> list = findByNameLike(name); | ||
List<ResourceDO> pageList = ListUtil.page(pageNo - 1, pageSize, list); | ||
pageResult.addAll(pageList); | ||
return pageResult; | ||
} | ||
} |
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
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
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
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
This file was deleted.
Oops, something went wrong.
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
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