|
@@ -0,0 +1,56 @@
|
|
|
+package com.bizmatics.mhfire.service.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.bizmatics.common.core.bean.CommonPage;
|
|
|
+import com.bizmatics.mhfire.persistence.mapper.UnitMapper;
|
|
|
+import com.bizmatics.mhfire.service.UnitService;
|
|
|
+import com.bizmatics.mhfire.service.po.UnitPO;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author yq
|
|
|
+ * @date 2021/5/27 13:37
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class UnitServiceImpl implements UnitService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UnitMapper unitMapper;
|
|
|
+ @Override
|
|
|
+ public UnitPO getOne(String id) {
|
|
|
+ Map<String, Object> map = unitMapper.selectOne(id);
|
|
|
+ return enhanceUnitPo(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public CommonPage<UnitPO> page(Integer current, Integer size) {
|
|
|
+ Page<Map<String, Object>> page = new Page<>(current, size);
|
|
|
+ page = unitMapper.page(page);
|
|
|
+ List<UnitPO> unitPOList = new ArrayList<>();
|
|
|
+ page.getRecords().forEach(stringObjectMap -> unitPOList.add(enhanceUnitPo(stringObjectMap)));
|
|
|
+ return new CommonPage<UnitPO>(unitPOList, page.getTotal(), page.getSize(), page.getCurrent());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * map转换为unitpo
|
|
|
+ * @param unitPoMap
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public UnitPO enhanceUnitPo(Map<String,Object> unitPoMap){
|
|
|
+ UnitPO unitPo = new UnitPO();
|
|
|
+ unitPo.setName(unitPoMap.get("单位名称").toString());
|
|
|
+ unitPo.setAddress(unitPoMap.get("单位地址").toString());
|
|
|
+ //TODO 没有找见对应字段
|
|
|
+ unitPo.setPrincipal(unitPoMap.get("单位名称").toString());
|
|
|
+ unitPo.setPhone(unitPoMap.get("单位电话").toString());
|
|
|
+ return unitPo;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|