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