package com.mandi.fendan.service.impl;
|
|
import java.util.List;
|
import java.util.Map;
|
import java.util.UUID;
|
|
import javax.annotation.Resource;
|
|
import org.apache.commons.lang3.StringUtils;
|
import org.springframework.stereotype.Service;
|
|
import com.mandi.dao.common.Daomethod;
|
import com.mandi.dao.common.ObjectResult;
|
import com.mandi.dao.common.PageRequest;
|
import com.mandi.dao.common.PageResult;
|
import com.mandi.fendan.mapper.Fd_ErpconfigMapper;
|
import com.mandi.fendan.persist.Fd_Erpconfig;
|
import com.mandi.fendan.service.Ifd_erpconfigService;
|
@Service
|
public class Fd_ErpconfigService implements Ifd_erpconfigService {
|
@Resource
|
private Fd_ErpconfigMapper fem;
|
@Override
|
public ObjectResult<Fd_Erpconfig> getFd_Erpconfig(String id) {
|
|
ObjectResult<Fd_Erpconfig> or = new ObjectResult<Fd_Erpconfig>();
|
if(StringUtils.isBlank(id)){
|
or.setCode(1);
|
or.setErrmsg("查询编号不能为空");
|
}else{
|
Fd_Erpconfig fef = fem.get(id);
|
or.setCode(0);
|
or.setItem(fef);
|
}
|
|
return or;
|
}
|
|
@Override
|
public ObjectResult<Fd_Erpconfig> saveFd_Erpconfig(Fd_Erpconfig fe) throws Exception {
|
|
ObjectResult<Fd_Erpconfig> or = new ObjectResult<Fd_Erpconfig>();
|
if(fe==null){
|
or.setCode(1);
|
or.setErrmsg("对象不能为空");
|
}else{
|
|
// if(fe.getId()!=null){
|
Fd_Erpconfig fef = fem.get(fe.getId());
|
if(fef==null){
|
fe.setId(UUID.randomUUID()+"");
|
int insert = fem.insert(fe);
|
if(insert>0){
|
or.setCode(0);
|
or.setItem(fe);
|
}else{
|
or.setCode(1);
|
or.setErrmsg("保存失败");
|
}
|
}else{
|
int update = fem.update(fe);
|
or.setCode(0);
|
or.setItem(fe);
|
}
|
// }else{
|
// or.setCode(1);
|
// or.setErrmsg("对象主键不能为空");
|
// }
|
|
}
|
return or;
|
}
|
|
@Override
|
public ObjectResult<Boolean> delFd_Erpconfig(String id) throws Exception {
|
|
ObjectResult<Boolean> or = new ObjectResult<Boolean>();
|
if(StringUtils.isBlank(id)){
|
or.setCode(1);
|
or.setErrmsg("查询编号不能为空");
|
or.setItem(false);
|
}else{
|
int i = fem.del(id);
|
|
or.setCode(0);
|
or.setItem(true);
|
}
|
|
return or;
|
}
|
|
@Override
|
public PageResult<Fd_Erpconfig> getList(Map<String, Object> map, PageRequest pr) {
|
|
PageResult<Fd_Erpconfig> prr=new PageResult<Fd_Erpconfig>();
|
map.put("pagesize", pr.getPageSize());
|
map.put("page", pr.getStart());
|
List<Fd_Erpconfig> list;
|
if(pr.isNeedPages())
|
{
|
int pages=fem.getPages(map);
|
pages=Daomethod.countpages(pages, pr.getPageSize());
|
prr.setPages(pages);
|
list=fem.getList(map);
|
}else{
|
list=fem.getList1(map);
|
}
|
|
prr.setCode(0);
|
prr.setList(list);
|
return prr;
|
}
|
|
}
|