zm
2020-05-18 a18bfacbf56b401f6e0fdae8710fbca4df8cff77
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
package com.changhong.autoform.service.data.impl;
 
import java.util.List;
import java.util.Map;
 
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import com.changhong.autoform.core.spring.SpringContext;
import com.changhong.autoform.entity.FormData;
import com.changhong.autoform.entity.SelectForm;
import com.changhong.autoform.entity.page.PageResult;
import com.changhong.autoform.mapper.data.DataMapper;
import com.changhong.autoform.service.data.DataService;
 
@Service("dataService")
public class DataServiceImpl implements DataService {
 
 
    @Override
    public int insertData(FormData formData) {
        return getDataMapper()
                .insertData(formData);
    }
 
    @Override
    public int deleteData(FormData formData) {
        return getDataMapper()
                .deleteDate(formData);
    }
 
    @Override
    public int updateData(FormData formData) {
        return getDataMapper()
                .updateDate(formData);
    }
 
    @Override
    public List<Map<String, Object>> selectAll(SelectForm selectForm) {
        return getDataMapper()
                .selectAll(selectForm);
    }
    
    @Override
    public PageResult<Map<String, Object>> selectPage(SelectForm selectForm) {
        // TODO 查询分页数据
        return getDataMapper()
                .selectPage(selectForm);
    }
 
    @Override
    public Map<String, Object> selectOne(SelectForm selectForm) {
        return getDataMapper()
                .selectOne(selectForm);
    }
    
    
    
    private DataMapper getDataMapper(){
        return SpringContext.getBean(DataMapper.class, (key)->{
            return !key.equals("simpleDataMapper");
        });
    }
 
    @Override
    public String getUserName(SelectForm selectForm) {
        return getDataMapper()
                .getUserName(selectForm);
    }
 
 
    @Override
    public Integer impInstertDatas(List<FormData> formDataList) {
        formDataList.stream().forEach(o->getDataMapper()
                .insertData(o));
        return 1;
    }
 
    
    
}