hjg
2023-11-17 3780c5e65b05bf23020810798babc6d20311fa79
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
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;
    }
 
}