提交 | 用户 | 时间
|
58d006
|
1 |
package com.mandi.fendan.service.impl; |
A |
2 |
|
|
3 |
import java.util.HashMap; |
|
4 |
import java.util.List; |
|
5 |
import java.util.Map; |
|
6 |
import java.util.UUID; |
|
7 |
|
|
8 |
import javax.annotation.Resource; |
|
9 |
|
|
10 |
import org.apache.commons.lang3.StringUtils; |
|
11 |
import org.springframework.stereotype.Service; |
|
12 |
|
|
13 |
import com.mandi.dao.common.Daomethod; |
|
14 |
import com.mandi.dao.common.ObjectResult; |
|
15 |
import com.mandi.dao.common.PageRequest; |
|
16 |
import com.mandi.dao.common.PageResult; |
|
17 |
import com.mandi.fendan.mapper.Fd_SystemconfigMapper; |
|
18 |
import com.mandi.fendan.persist.Fd_Systemconfig; |
|
19 |
import com.mandi.fendan.service.Ifd_systemconfigService; |
|
20 |
@Service |
|
21 |
public class Fd_SystemconfigService implements Ifd_systemconfigService { |
|
22 |
@Resource |
|
23 |
private Fd_SystemconfigMapper fdm; |
|
24 |
@Override |
|
25 |
public ObjectResult<Fd_Systemconfig> getFd_Systemconfig(String id) { |
|
26 |
ObjectResult<Fd_Systemconfig> or = new ObjectResult<Fd_Systemconfig>(); |
|
27 |
if(StringUtils.isBlank(id)){ |
|
28 |
or.setCode(1); |
|
29 |
or.setErrmsg("查询编号不能为空"); |
|
30 |
}else{ |
|
31 |
Fd_Systemconfig fsf = fdm.get(id); |
|
32 |
or.setCode(0); |
|
33 |
or.setItem(fsf); |
|
34 |
} |
|
35 |
|
|
36 |
return or; |
|
37 |
} |
|
38 |
|
|
39 |
@Override |
|
40 |
public ObjectResult<Fd_Systemconfig> saveFd_Systemconfig(Fd_Systemconfig fsf) throws Exception { |
|
41 |
ObjectResult<Fd_Systemconfig> or = new ObjectResult<Fd_Systemconfig>(); |
|
42 |
if(fsf==null){ |
|
43 |
or.setCode(1); |
|
44 |
or.setErrmsg("对象不能为空"); |
|
45 |
}else{ |
|
46 |
|
|
47 |
// if(fsf.getId()!=null){ |
|
48 |
Fd_Systemconfig fsfg = fdm.get(fsf.getId()); |
|
49 |
if(fsfg==null){ |
|
50 |
fsf.setId(UUID.randomUUID()+""); |
|
51 |
int insert = fdm.insert(fsf); |
|
52 |
if(insert>0){ |
|
53 |
or.setCode(0); |
|
54 |
or.setItem(fsf); |
|
55 |
}else{ |
|
56 |
or.setCode(1); |
|
57 |
or.setErrmsg("保存失败"); |
|
58 |
} |
|
59 |
}else{ |
|
60 |
int update = fdm.update(fsf); |
|
61 |
or.setCode(0); |
|
62 |
or.setItem(fsf); |
|
63 |
} |
|
64 |
// }else{ |
|
65 |
// or.setCode(1); |
|
66 |
// or.setErrmsg("对象主键不能为空"); |
|
67 |
// } |
|
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
|
72 |
} |
|
73 |
return or; |
|
74 |
} |
|
75 |
|
|
76 |
@Override |
|
77 |
public ObjectResult<Boolean> delFd_Systemconfig(String id) throws Exception { |
|
78 |
// TODO Auto-generated method stub |
|
79 |
return null; |
|
80 |
} |
|
81 |
|
|
82 |
@Override |
|
83 |
public PageResult<Fd_Systemconfig> getlist(String name, PageRequest pr) { |
|
84 |
|
|
85 |
PageResult<Fd_Systemconfig> prr=new PageResult<Fd_Systemconfig>(); |
|
86 |
Map<String, Object> map = new HashMap<String,Object>(); |
|
87 |
map.put("pagesize", pr.getPageSize()); |
|
88 |
map.put("page", pr.getStart()); |
|
89 |
map.put("name", name); |
|
90 |
List<Fd_Systemconfig> list; |
|
91 |
if(pr.isNeedPages()) |
|
92 |
{ |
|
93 |
int pages=fdm.getPages(map); |
|
94 |
pages=Daomethod.countpages(pages, pr.getPageSize()); |
|
95 |
prr.setPages(pages); |
|
96 |
list=fdm.getList(map); |
|
97 |
}else{ |
|
98 |
list=fdm.getList1(map); |
|
99 |
} |
|
100 |
|
|
101 |
prr.setCode(0); |
|
102 |
prr.setList(list); |
|
103 |
return prr; |
|
104 |
} |
|
105 |
|
|
106 |
} |