增加系统service

This commit is contained in:
shuzheng 2016-12-18 21:06:01 +08:00
parent f33042a45e
commit dad7e4d2dc
3 changed files with 81 additions and 0 deletions

View File

@ -0,0 +1,16 @@
package com.zheng.upms.service;
/**
* baseService接口
* @author shuzheng
* @date 2016年7月7日 上午9:58:23
*/
public interface BaseService<Mapper> {
/**
* 获取基本操作mapper
* @return
*/
Mapper getMapper();
}

View File

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

View File

@ -0,0 +1,51 @@
package com.zheng.upms.service.impl;
import com.zheng.upms.dao.mapper.UpmsSystemMapper;
import com.zheng.upms.service.UpmsSystemService;
import org.apache.commons.lang.StringUtils;
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;
/**
* 系统service实现
* Created by shuzheng on 2016/12/18.
*/
@Service
@Transactional
public class UpmsSystemServiceImpl implements UpmsSystemService {
private static Logger _log = LoggerFactory.getLogger(UpmsSystemServiceImpl.class);
@Autowired
private UpmsSystemMapper upmsSystemMapper;
@Override
public UpmsSystemMapper getMapper() {
return upmsSystemMapper;
}
// 批量删除
@Override
public int deleteByPrimaryKeys(String ids) {
if (StringUtils.isBlank(ids)) {
return 0;
}
String[] idArray = ids.split("-");
int count = 0;
for (String id : idArray) {
if (StringUtils.isBlank(id)) {
continue;
}
try {
count += upmsSystemMapper.deleteByPrimaryKey(Integer.parseInt(id));
} catch (Exception e) {
e.printStackTrace();
return 0;
}
}
return count;
}
}