package com.mandi.fendan.service.impl;
|
|
import java.util.HashMap;
|
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_SystemconfigMapper;
|
import com.mandi.fendan.persist.Fd_Systemconfig;
|
import com.mandi.fendan.service.Ifd_systemconfigService;
|
@Service
|
public class Fd_SystemconfigService implements Ifd_systemconfigService {
|
@Resource
|
private Fd_SystemconfigMapper fdm;
|
@Override
|
public ObjectResult<Fd_Systemconfig> getFd_Systemconfig(String id) {
|
ObjectResult<Fd_Systemconfig> or = new ObjectResult<Fd_Systemconfig>();
|
if(StringUtils.isBlank(id)){
|
or.setCode(1);
|
or.setErrmsg("查询编号不能为空");
|
}else{
|
Fd_Systemconfig fsf = fdm.get(id);
|
or.setCode(0);
|
or.setItem(fsf);
|
}
|
|
return or;
|
}
|
|
@Override
|
public ObjectResult<Fd_Systemconfig> saveFd_Systemconfig(Fd_Systemconfig fsf) throws Exception {
|
ObjectResult<Fd_Systemconfig> or = new ObjectResult<Fd_Systemconfig>();
|
if(fsf==null){
|
or.setCode(1);
|
or.setErrmsg("对象不能为空");
|
}else{
|
|
// if(fsf.getId()!=null){
|
Fd_Systemconfig fsfg = fdm.get(fsf.getId());
|
if(fsfg==null){
|
fsf.setId(UUID.randomUUID()+"");
|
int insert = fdm.insert(fsf);
|
if(insert>0){
|
or.setCode(0);
|
or.setItem(fsf);
|
}else{
|
or.setCode(1);
|
or.setErrmsg("保存失败");
|
}
|
}else{
|
int update = fdm.update(fsf);
|
or.setCode(0);
|
or.setItem(fsf);
|
}
|
// }else{
|
// or.setCode(1);
|
// or.setErrmsg("对象主键不能为空");
|
// }
|
|
|
|
|
}
|
return or;
|
}
|
|
@Override
|
public ObjectResult<Boolean> delFd_Systemconfig(String id) throws Exception {
|
// TODO Auto-generated method stub
|
return null;
|
}
|
|
@Override
|
public PageResult<Fd_Systemconfig> getlist(String name, PageRequest pr) {
|
|
PageResult<Fd_Systemconfig> prr=new PageResult<Fd_Systemconfig>();
|
Map<String, Object> map = new HashMap<String,Object>();
|
map.put("pagesize", pr.getPageSize());
|
map.put("page", pr.getStart());
|
map.put("name", name);
|
List<Fd_Systemconfig> list;
|
if(pr.isNeedPages())
|
{
|
int pages=fdm.getPages(map);
|
pages=Daomethod.countpages(pages, pr.getPageSize());
|
prr.setPages(pages);
|
list=fdm.getList(map);
|
}else{
|
list=fdm.getList1(map);
|
}
|
|
prr.setCode(0);
|
prr.setList(list);
|
return prr;
|
}
|
|
}
|