BaseService增加selectFirstByExampleWithBLOBs公共接口和实现
This commit is contained in:
parent
ae6193d35a
commit
dd92445bdb
|
@ -26,6 +26,8 @@ public interface BaseService<Record, Example> {
|
|||
|
||||
Record selectFirstByExample(Example example);
|
||||
|
||||
Record selectFirstByExampleWithBLOBs(Example example);
|
||||
|
||||
Record selectByPrimaryKey(Integer id);
|
||||
|
||||
int updateByExampleSelective(@Param("record") Record record, @Param("example") Example example);
|
||||
|
|
|
@ -132,6 +132,22 @@ public abstract class BaseServiceImpl<Mapper, Record, Example> implements BaseSe
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Record selectFirstByExampleWithBLOBs(Example example) {
|
||||
try {
|
||||
DynamicDataSource.setDataSource(DataSourceEnum.SLAVE.getName());
|
||||
Method selectByExampleWithBLOBs = mapper.getClass().getDeclaredMethod("selectByExampleWithBLOBs", example.getClass());
|
||||
List<Record> result = (List<Record>) selectByExampleWithBLOBs.invoke(mapper, example);
|
||||
if (null != result && result.size() > 0) {
|
||||
return result.get(0);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
DynamicDataSource.clearDataSource();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Record selectByPrimaryKey(Integer id) {
|
||||
try {
|
||||
|
|
|
@ -50,6 +50,11 @@ public abstract class BaseServiceMock<Mapper, Record, Example> implements BaseSe
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Record selectFirstByExampleWithBLOBs(Example example) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Record selectByPrimaryKey(Integer id) {
|
||||
return null;
|
||||
|
|
Loading…
Reference in New Issue