Skip to content

Commit 4eee7b8

Browse files
committed
update > optimize code annotation
1 parent 3c530ca commit 4eee7b8

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/main/java/com/company/project/core/AbstractService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ public T findById(Integer id) {
4949
}
5050

5151
@Override
52-
public T findBy(String property, Object value) throws TooManyResultsException {
52+
public T findBy(String fieldName, Object value) throws TooManyResultsException {
5353
try {
5454
T model = modelClass.newInstance();
55-
Field field = modelClass.getDeclaredField(property);
55+
Field field = modelClass.getDeclaredField(fieldName);
5656
field.setAccessible(true);
5757
field.set(model, value);
5858
return mapper.selectOne(model);

src/main/java/com/company/project/core/Service.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public interface Service<T> {
1515
void deleteByIds(String ids);//批量刪除 eg:ids -> “1,2,3,4”
1616
void update(T model);//更新
1717
T findById(Integer id);//通过ID查找
18-
T findBy(String property, Object value) throws TooManyResultsException; //通过某个成员属性查找,value需符合unique约束
18+
T findBy(String fieldName, Object value) throws TooManyResultsException; //通过Model中某个成员变量名称(非数据表中column的名称)查找,value需符合unique约束
1919
List<T> findByIds(String ids);//通过多个ID查找//eg:ids -> “1,2,3,4”
2020
List<T> findByCondition(Condition condition);//根据条件查找
2121
List<T> findAll();//获取所有

0 commit comments

Comments
 (0)