zm
2020-05-18 a18bfacbf56b401f6e0fdae8710fbca4df8cff77
commit | author | age
a18bfa 1 package com.changhong.autoform.service.data.impl;
Z 2
3 import java.util.List;
4 import java.util.Map;
5
6 import org.springframework.stereotype.Service;
7 import org.springframework.transaction.annotation.Transactional;
8
9 import com.changhong.autoform.core.spring.SpringContext;
10 import com.changhong.autoform.entity.FormData;
11 import com.changhong.autoform.entity.SelectForm;
12 import com.changhong.autoform.entity.page.PageResult;
13 import com.changhong.autoform.mapper.data.DataMapper;
14 import com.changhong.autoform.service.data.DataService;
15
16 @Service("dataService")
17 public class DataServiceImpl implements DataService {
18
19
20     @Override
21     public int insertData(FormData formData) {
22         return getDataMapper()
23                 .insertData(formData);
24     }
25
26     @Override
27     public int deleteData(FormData formData) {
28         return getDataMapper()
29                 .deleteDate(formData);
30     }
31
32     @Override
33     public int updateData(FormData formData) {
34         return getDataMapper()
35                 .updateDate(formData);
36     }
37
38     @Override
39     public List<Map<String, Object>> selectAll(SelectForm selectForm) {
40         return getDataMapper()
41                 .selectAll(selectForm);
42     }
43     
44     @Override
45     public PageResult<Map<String, Object>> selectPage(SelectForm selectForm) {
46         // TODO 查询分页数据
47         return getDataMapper()
48                 .selectPage(selectForm);
49     }
50
51     @Override
52     public Map<String, Object> selectOne(SelectForm selectForm) {
53         return getDataMapper()
54                 .selectOne(selectForm);
55     }
56     
57     
58     
59     private DataMapper getDataMapper(){
60         return SpringContext.getBean(DataMapper.class, (key)->{
61             return !key.equals("simpleDataMapper");
62         });
63     }
64
65     @Override
66     public String getUserName(SelectForm selectForm) {
67         return getDataMapper()
68                 .getUserName(selectForm);
69     }
70
71
72     @Override
73     public Integer impInstertDatas(List<FormData> formDataList) {
74         formDataList.stream().forEach(o->getDataMapper()
75                 .insertData(o));
76         return 1;
77     }
78
79     
80     
81 }