hjg
2024-02-05 301115d5e96b56cd093eee3fcff2d60a15184162
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
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;
    }
 
}