package gov.sdgs.ssm.service.impl;
import com.github.pagehelper.PageHelper;
import gov.sdgs.ssm.model.PageModel;
import gov.sdgs.ssm.service.BaseService;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Param;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.List;
/**
* 描述:基本base接口,CRUD泛型接口实现类,抽象类只能被继承<br>
*
*/
public class BaseServiceImpl<Mapper, Record, Example> implements BaseService<Mapper, Record, Example> {
@Override
public int countByExample(Mapper mapper, Example example) {
int res = 0;
try {
Method method = mapper.getClass().getDeclaredMethod("countByExample", example.getClass());
Object result = method.invoke(mapper, example);
res = Integer.parseInt(String.valueOf(result));
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
return res;
}
@Override
public int deleteByExample(Mapper mapper, Example example) {
int res = 0;
try {
Method method = mapper.getClass().getDeclaredMethod("deleteByExample", example.getClass());
Object result = method.invoke(mapper, example);
res = Integer.parseInt(String.valueOf(result));
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
return res;
}
@Override
public int deleteByPrimaryKey(Mapper mapper, String id) {
int res = 0;
try {
Method method = mapper.getClass().getDeclaredMethod("deleteByPrimaryKey", id.getClass());
Object result = method.invoke(mapper, id);
return Integer.parseInt(String.valueOf(result));
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
return res;
}
@Override
public int insert(Mapper mapper, Record record) {
int res = 0;
try {
Method method = mapper.getClass().getDeclaredMethod("insert", record.getClass());
Object result = method.invoke(mapper, record);
res = Integer.parseInt(String.valueOf(result));
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
return res;
}
@Override
public int insertSelective(Mapper mapper, Record record) {
int res = 0;
try {
Method method = mapper.getClass().getDeclaredMethod("insertSelective", record.getClass());
Object result = method.invoke(mapper, record);
res = Integer.parseInt(String.valueOf(result));
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
return res;
}
@SuppressWarnings("unchecked")
@Override
public List<Record> selectByExampleWithBLOBs(Mapper mapper, Example example) {
List<Record> list = null;
try {
Method method = mapper.getClass().getDeclaredMethod("selectByExampleWithBLOBs", example.getClass());
Object result = method.invoke(mapper, example);
list = (List<Record>) result;
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
return list;
}
@SuppressWarnings("unchecked")
@Override
public List<Record> selectByExample(Mapper mapper, Example example) {
List<Record> list = null;
try {
Method method = mapper.getClass().getDeclaredMethod("selectByExample", example.getClass());
Object result = method.invoke(mapper, example);
list = (List<Record>) result;
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
return list;
}
@SuppressWarnings("unchecked")
@Override
public PageModel<Record> selectByExampleWithBLOBsForStartPage(Mapper mapper, Example example, Integer pageNum,
Integer pageSize) {
PageModel<Record> pageModel = null;
try {
Method method = mapper.getClass().getDeclaredMethod("selectByExampleWithBLOBs", example.getClass());
PageHelper.startPage(pageNum, pageSize);
Object result = method.invoke(mapper, example);
pageModel = new PageModel<>((List<Record>) result);
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
return pageModel;
}
@SuppressWarnings("unchecked")
@Override
public PageModel<Record> selectByExampleForStartPage(Mapper mapper, Example example, Integer pageNum,
Integer pageSize) {
PageModel<Record> pageModel = null;
try {
Method method = mapper.getClass().getDeclaredMethod("selectByExample", example.getClass());
PageHelper.startPage(pageNum, pageSize);
Object result = method.invoke(mapper, example);
pageModel = new PageModel<>((List<Record>) result);
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
return pageModel;
}
@SuppressWarnings("unchecked")
@Override
public PageModel<Record> selectByExampleWithBLOBsForOffsetPage(Mapper mapper, Example example, Integer offset,
Integer limit) {
PageModel<Record> pageModel = null;
try {
Method method = mapper.getClass().getDeclaredMethod("selectByExampleWithBLOBs", example.getClass());
PageHelper.offsetPage(offset, limit);
Object result = method.invoke(mapper, example);
pageModel = new PageModel<>((List<Record>) result);
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
return pageModel;
}
@SuppressWarnings("unchecked")
@Override
public PageModel<Record> selectByExampleForOffsetPage(Mapper mapper, Example example, Integer offset,
Integer limit) {
PageModel<Record> pageModel = null;
try {
Method method = mapper.getClass().getDeclaredMethod("selectByExample", example.getClass());
PageHelper.offsetPage(offset, limit);
Object result = method.invoke(mapper, example);
pageModel = new PageModel<>((List<Record>) result);
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
return pageModel;
}
@SuppressWarnings("unchecked")
@Override
public Record selectFirstByExample(Mapper mapper, Example example) {
Record res = null;
try {
Method method = mapper.getClass().getDeclaredMethod("selectByExample", example.getClass());
List<Record> result = (List<Record>) method.invoke(mapper, example);
if (null != result && result.size() > 0) {
res = result.get(0);
}
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
return res;
}
@SuppressWarnings("unchecked")
@Override
public Record selectFirstByExampleWithBLOBs(Mapper mapper, Example example) {
Record res = null;
try {
Method method = mapper.getClass().getDeclaredMethod("selectByExampleWithBLOBs", example.getClass());
List<Record> result = (List<Record>) method.invoke(mapper, example);
if (null != result && result.size() > 0) {
res = result.get(0);
}
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
没有合适的资源?快使用搜索试试~ 我知道了~
ssm-base.rar_SSM-1029
共94个文件
class:21个
xml:19个
java:18个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 168 浏览量
2022-09-21
00:04:37
上传
评论
收藏 86KB RAR 举报
温馨提示
基于springmvc的整合 mybatics入门必学
资源推荐
资源详情
资源评论
收起资源包目录
ssm-base.rar (94个子文件)
ssm-base
pom.xml 7KB
target
test-classes
m2e-wtp
web-resources
META-INF
maven
gov.sdgs
demo
pom.xml 7KB
pom.properties 214B
MANIFEST.MF 111B
classes
META-INF
maven
gov.sdgs
ssm-base
pom.xml 7KB
pom.properties 217B
MANIFEST.MF 111B
gov
sdgs
ssm
model
PageModel.class 3KB
MsgModel.class 1KB
support
BaseSupport.class 6KB
controller
SupportController.class 6KB
BaseController.class 2KB
service
BaseService.class 2KB
CustomService.class 1KB
MapperService.class 2KB
impl
CustomServiceImpl.class 4KB
BaseServiceImpl.class 12KB
MapperServiceImpl.class 11KB
.settings
org.eclipse.m2e.core.prefs 90B
org.eclipse.wst.common.project.facet.core.xml 172B
org.eclipse.core.resources.prefs 191B
org.eclipse.wst.common.component 320B
org.eclipse.wst.validation.prefs 50B
org.eclipse.jdt.core.prefs 430B
src
test
resources
java
main
resources
java
META-INF
MANIFEST.MF 39B
gov
sdgs
ssm
model
PageModel.java 4KB
MsgModel.java 4KB
support
BaseSupport.java 8KB
controller
SupportController.java 6KB
BaseController.java 3KB
service
CustomService.java 4KB
MapperService.java 4KB
impl
MapperServiceImpl.java 12KB
BaseServiceImpl.java 12KB
CustomServiceImpl.java 6KB
BaseService.java 4KB
.project 1KB
ssm
pom.xml 7KB
target
test-classes
gov
sdgs
test
DemoTest.class 816B
m2e-wtp
web-resources
META-INF
maven
gov.sdgs
ssm
pom.xml 7KB
pom.properties 202B
MANIFEST.MF 111B
classes
spring-mvc.xml 5KB
gov
sdgs
app1
demo
pojo
TDemo.class 882B
TDemoExample$Criteria.class 3KB
TDemoExample.class 2KB
TDemoExample$Criterion.class 2KB
TDemoExample$GeneratedCriteria.class 6KB
mapper
TDemoMapper.xml 5KB
TDemoMapper.class 843B
TDemoMapperCustom.xml 810B
controller
DemoController.class 6KB
service
TDemoService.class 322B
impl
TDemoServiceImpl.class 876B
jdbc.properties 300B
log4j.properties 936B
applicationContext.xml 4KB
generatorConfig.xml 2KB
.settings
org.eclipse.m2e.core.prefs 90B
org.eclipse.wst.jsdt.ui.superType.name 6B
org.eclipse.wst.common.project.facet.core.xml 346B
org.eclipse.core.resources.prefs 296B
org.eclipse.wst.common.component 1KB
org.eclipse.wst.common.project.facet.core.prefs.xml 321B
org.eclipse.wst.jsdt.ui.superType.container 49B
org.eclipse.wst.validation.prefs 50B
.jsdtscope 639B
org.eclipse.jdt.core.prefs 736B
src
test
resources
java
gov
sdgs
test
DemoTest.java 648B
main
webapp
WEB-INF
web.xml 2KB
views
insert.jsp 366B
hello.jsp 359B
delete.jsp 366B
index.jsp 355B
select.jsp 366B
selectRecord.jsp 372B
update.jsp 366B
query.jsp 359B
resources
spring-mvc.xml 5KB
jdbc.properties 300B
log4j.properties 936B
mybatis
applicationContext.xml 4KB
generatorConfig.xml 2KB
java
gov
sdgs
app1
demo
pojo
TDemoExample.java 9KB
TDemo.java 407B
mapper
TDemoMapper.xml 5KB
TDemoMapperCustom.xml 810B
TDemoMapper.java 667B
controller
DemoController.java 4KB
service
TDemoService.java 242B
impl
TDemoServiceImpl.java 570B
.project 1KB
.classpath 2KB
.classpath 1KB
共 94 条
- 1
资源评论
我虽横行却不霸道
- 粉丝: 72
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功