From 4eee7b8ced089101a239d6819310f36c1aec46a7 Mon Sep 17 00:00:00 2001 From: lihengming <89921218@qq.com> Date: Fri, 30 Jun 2017 13:26:16 +0800 Subject: [PATCH] update > optimize code annotation --- src/main/java/com/company/project/core/AbstractService.java | 4 ++-- src/main/java/com/company/project/core/Service.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/company/project/core/AbstractService.java b/src/main/java/com/company/project/core/AbstractService.java index 1d69764..35dbf82 100644 --- a/src/main/java/com/company/project/core/AbstractService.java +++ b/src/main/java/com/company/project/core/AbstractService.java @@ -49,10 +49,10 @@ public abstract class AbstractService implements Service { } @Override - public T findBy(String property, Object value) throws TooManyResultsException { + public T findBy(String fieldName, Object value) throws TooManyResultsException { try { T model = modelClass.newInstance(); - Field field = modelClass.getDeclaredField(property); + Field field = modelClass.getDeclaredField(fieldName); field.setAccessible(true); field.set(model, value); return mapper.selectOne(model); diff --git a/src/main/java/com/company/project/core/Service.java b/src/main/java/com/company/project/core/Service.java index f5ba6aa..5fec7ca 100644 --- a/src/main/java/com/company/project/core/Service.java +++ b/src/main/java/com/company/project/core/Service.java @@ -15,7 +15,7 @@ public interface Service { void deleteByIds(String ids);//批量刪除 eg:ids -> “1,2,3,4” void update(T model);//更新 T findById(Integer id);//通过ID查找 - T findBy(String property, Object value) throws TooManyResultsException; //通过某个成员属性查找,value需符合unique约束 + T findBy(String fieldName, Object value) throws TooManyResultsException; //通过Model中某个成员变量名称(非数据表中column的名称)查找,value需符合unique约束 List findByIds(String ids);//通过多个ID查找//eg:ids -> “1,2,3,4” List findByCondition(Condition condition);//根据条件查找 List findAll();//获取所有