|
@@ -0,0 +1,102 @@
|
|
1
|
+package com.community.huiju.service.impl;
|
|
2
|
+
|
|
3
|
+import com.alibaba.fastjson.JSONObject;
|
|
4
|
+import com.baomidou.mybatisplus.core.conditions.query.EmptyWrapper;
|
|
5
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
6
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
7
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
8
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
9
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
10
|
+import com.community.commom.mode.ResponseBean;
|
|
11
|
+import com.community.huiju.dao.BuildingOwnerInfoMapper;
|
|
12
|
+import com.community.huiju.model.BuildingOwnerInfo;
|
|
13
|
+import com.community.huiju.service.IBuildingOwnerInfoService;
|
|
14
|
+import com.google.common.collect.Lists;
|
|
15
|
+import com.google.common.collect.Maps;
|
|
16
|
+import org.springframework.beans.BeanUtils;
|
|
17
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
18
|
+import org.springframework.stereotype.Service;
|
|
19
|
+
|
|
20
|
+import java.util.List;
|
|
21
|
+import java.util.Map;
|
|
22
|
+
|
|
23
|
+/**
|
|
24
|
+ * <p>
|
|
25
|
+ * 楼栋业主资料信息表 服务实现类
|
|
26
|
+ * </p>
|
|
27
|
+ *
|
|
28
|
+ * @author weiximei
|
|
29
|
+ * @since 2018-12-18
|
|
30
|
+ */
|
|
31
|
+@Service("iBuildingOwnerInfoService")
|
|
32
|
+public class BuildingOwnerInfoServiceImpl extends ServiceImpl<BuildingOwnerInfoMapper, BuildingOwnerInfo> implements IBuildingOwnerInfoService {
|
|
33
|
+
|
|
34
|
+ @Autowired
|
|
35
|
+ private BuildingOwnerInfoMapper buildingOwnerInfoMapper;
|
|
36
|
+
|
|
37
|
+ @Override
|
|
38
|
+ public ResponseBean listQuery(String parameter) {
|
|
39
|
+
|
|
40
|
+ ResponseBean responseBean = new ResponseBean();
|
|
41
|
+
|
|
42
|
+ JSONObject jsonObject = JSONObject.parseObject(parameter);
|
|
43
|
+ BuildingOwnerInfo buildingOwnerInfo = jsonObject.toJavaObject(BuildingOwnerInfo.class);
|
|
44
|
+
|
|
45
|
+ Long pageNum = jsonObject.getLong("pageNum") == null ? 1 : jsonObject.getLong("pageNum");
|
|
46
|
+ Long pageSize = jsonObject.getLong("pageSize") == null ? 10 : jsonObject.getLong("pageSize");
|
|
47
|
+
|
|
48
|
+ Page<BuildingOwnerInfo> page = new Page(pageNum,pageSize);
|
|
49
|
+
|
|
50
|
+ Map<String, Object> map = Maps.newHashMap();
|
|
51
|
+ // 栋
|
|
52
|
+ map.put("building",buildingOwnerInfo.getBuilding());
|
|
53
|
+ // 单元
|
|
54
|
+ map.put("unit",buildingOwnerInfo.getUnit());
|
|
55
|
+ // 楼层
|
|
56
|
+ map.put("level",buildingOwnerInfo.getLevel());
|
|
57
|
+ // 房号
|
|
58
|
+ map.put("room_no",buildingOwnerInfo.getRoomNo());
|
|
59
|
+
|
|
60
|
+ QueryWrapper<BuildingOwnerInfo> queryWrapper = new QueryWrapper<>();
|
|
61
|
+ queryWrapper.allEq(map,false);
|
|
62
|
+ queryWrapper.like(buildingOwnerInfo.getOwnerName() != null,"owner_name",buildingOwnerInfo.getOwnerName());
|
|
63
|
+ // 分页查询
|
|
64
|
+ IPage<BuildingOwnerInfo> infoIPage = buildingOwnerInfoMapper.selectPage(page, queryWrapper);
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+ Map<String, Object> retMap = Maps.newHashMap();
|
|
68
|
+ // 获取数据
|
|
69
|
+ List<BuildingOwnerInfo> list = infoIPage.getRecords();
|
|
70
|
+
|
|
71
|
+ retMap.put("data", list);
|
|
72
|
+ retMap.put("total", infoIPage.getTotal());
|
|
73
|
+ retMap.put("pageNum", infoIPage.getCurrent());
|
|
74
|
+ retMap.put("pageSize", infoIPage.getSize());
|
|
75
|
+
|
|
76
|
+ responseBean.addSuccess(list);
|
|
77
|
+
|
|
78
|
+ return responseBean;
|
|
79
|
+ }
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+ @Override
|
|
83
|
+ public ResponseBean update(String parameter) {
|
|
84
|
+ ResponseBean responseBean = new ResponseBean();
|
|
85
|
+
|
|
86
|
+ BuildingOwnerInfo buildingOwnerInfo = JSONObject.parseObject(parameter, BuildingOwnerInfo.class);
|
|
87
|
+ BuildingOwnerInfo oldBuildingOwnerInfo = buildingOwnerInfoMapper.selectById(buildingOwnerInfo.getId());
|
|
88
|
+ if (null == oldBuildingOwnerInfo) {
|
|
89
|
+ responseBean.addError("数据不存在!");
|
|
90
|
+ return responseBean;
|
|
91
|
+ }
|
|
92
|
+
|
|
93
|
+ BeanUtils.copyProperties(buildingOwnerInfo, oldBuildingOwnerInfo);
|
|
94
|
+ int row = buildingOwnerInfoMapper.updateById(buildingOwnerInfo);
|
|
95
|
+ if (row <= 0) {
|
|
96
|
+ responseBean.addError("更新失败!");
|
|
97
|
+ } else {
|
|
98
|
+ responseBean.addSuccess("更新成功!");
|
|
99
|
+ }
|
|
100
|
+ return responseBean;
|
|
101
|
+ }
|
|
102
|
+}
|