改为BaseService

This commit is contained in:
shuzheng 2016-12-30 18:06:02 +08:00
parent 8639d40120
commit 4c73629873
4 changed files with 111 additions and 25 deletions

View File

@ -1,16 +1,44 @@
package com.zheng.upms.rpc.api;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* baseService接口
* @author shuzheng
* @date 2016年7月7日 上午9:58:23
*/
public interface BaseService<Mapper> {
public interface BaseService<Record, Example> {
/**
* 获取基本操作mapper
* @return
*/
Mapper getMapper();
int countByExample(Example example);
int deleteByExample(Example example);
int deleteByPrimaryKey(Integer id);
int insert(Record record);
int insertSelective(Record record);
List<Record> selectByExampleWithBLOBs(Example example);
List<Record> selectByExample(Example example);
Record selectByPrimaryKey(Integer id);
int updateByExampleSelective(@Param("record") Record record, @Param("example") Example example);
int updateByExampleWithBLOBs(@Param("record") Record record, @Param("example") Example example);
int updateByExample(@Param("record") Record record, @Param("example") Example example);
int updateByPrimaryKeySelective(Record record);
int updateByPrimaryKeyWithBLOBs(Record record);
int updateByPrimaryKey(Record record);
int deleteByPrimaryKeys(String ids);
}

View File

@ -1,16 +1,13 @@
package com.zheng.upms.rpc.api;
import com.zheng.upms.dao.mapper.UpmsSystemMapper;
import com.zheng.upms.dao.model.UpmsSystem;
import com.zheng.upms.dao.model.UpmsSystemExample;
/**
* 系统service接口
* Created by shuzheng on 2016/12/18.
*/
public interface UpmsSystemService extends BaseService<UpmsSystemMapper> {
public interface UpmsSystemService extends BaseService<UpmsSystem, UpmsSystemExample> {
// 批量删除
int deleteByPrimaryKeys(String ids);
String test();
}

View File

@ -1,14 +1,19 @@
package com.zheng.upms.rpc.service.impl;
import com.zheng.upms.dao.mapper.UpmsSystemMapper;
import com.zheng.upms.dao.model.UpmsSystem;
import com.zheng.upms.dao.model.UpmsSystemExample;
import com.zheng.upms.rpc.api.UpmsSystemService;
import org.apache.commons.lang.StringUtils;
import org.apache.ibatis.annotations.Param;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* 系统service实现
* Created by shuzheng on 2016/12/18.
@ -23,13 +28,79 @@ public class UpmsSystemServiceImpl implements UpmsSystemService {
private UpmsSystemMapper upmsSystemMapper;
@Override
public UpmsSystemMapper getMapper() {
return upmsSystemMapper;
public int countByExample(UpmsSystemExample upmsSystemExample) {
return upmsSystemMapper.countByExample(upmsSystemExample);
}
@Override
public int deleteByExample(UpmsSystemExample upmsSystemExample) {
return upmsSystemMapper.deleteByExample(upmsSystemExample);
}
@Override
public int deleteByPrimaryKey(Integer id) {
return upmsSystemMapper.deleteByPrimaryKey(id);
}
@Override
public int insert(UpmsSystem upmsSystem) {
return upmsSystemMapper.insert(upmsSystem);
}
@Override
public int insertSelective(UpmsSystem upmsSystem) {
return upmsSystemMapper.insertSelective(upmsSystem);
}
@Override
public List<UpmsSystem> selectByExampleWithBLOBs(UpmsSystemExample upmsSystemExample) {
return upmsSystemMapper.selectByExample(upmsSystemExample);
}
@Override
public List<UpmsSystem> selectByExample(UpmsSystemExample upmsSystemExample) {
return upmsSystemMapper.selectByExample(upmsSystemExample);
}
@Override
public UpmsSystem selectByPrimaryKey(Integer id) {
return upmsSystemMapper.selectByPrimaryKey(id);
}
@Override
public int updateByExampleSelective(@Param("record") UpmsSystem upmsSystem, @Param("example") UpmsSystemExample upmsSystemExample) {
return upmsSystemMapper.updateByExampleSelective(upmsSystem, upmsSystemExample);
}
@Override
public int updateByExampleWithBLOBs(@Param("record") UpmsSystem upmsSystem, @Param("example") UpmsSystemExample upmsSystemExample) {
return upmsSystemMapper.updateByExample(upmsSystem, upmsSystemExample);
}
@Override
public int updateByExample(@Param("record") UpmsSystem upmsSystem, @Param("example") UpmsSystemExample upmsSystemExample) {
return upmsSystemMapper.updateByExample(upmsSystem, upmsSystemExample);
}
@Override
public int updateByPrimaryKeySelective(UpmsSystem upmsSystem) {
return upmsSystemMapper.updateByPrimaryKeySelective(upmsSystem);
}
@Override
public int updateByPrimaryKeyWithBLOBs(UpmsSystem upmsSystem) {
return upmsSystemMapper.updateByPrimaryKey(upmsSystem);
}
@Override
public int updateByPrimaryKey(UpmsSystem upmsSystem) {
return upmsSystemMapper.updateByPrimaryKey(upmsSystem);
}
// 批量删除
@Override
public int deleteByPrimaryKeys(String ids) {
_log.info("批量删除ids={}", ids);
if (StringUtils.isBlank(ids)) {
return 0;
}
@ -49,9 +120,4 @@ public class UpmsSystemServiceImpl implements UpmsSystemService {
return count;
}
@Override
public String test() {
return "hello world!";
}
}

View File

@ -22,11 +22,6 @@ public class SystemController {
@Autowired
private UpmsSystemService upmsSystemService;
@RequestMapping("/test")
@ResponseBody
public String test() {
return upmsSystemService.test();
}
@RequestMapping("/index")
public String index() {
@ -39,7 +34,7 @@ public class SystemController {
UpmsSystemExample upmsSystemExample = new UpmsSystemExample();
upmsSystemExample.createCriteria()
.andSystemIdGreaterThan(0);
return upmsSystemService.getMapper().selectByExample(upmsSystemExample);
return upmsSystemService.selectByExample(upmsSystemExample);
}
}