package com.example.service.impl; import com.example.dao.WzUserDao; import com.example.entity.OtnAreaEntity; import com.example.entity.WzUserEntity; import com.example.service.WzOtnAreaService; import com.example.service.WzUserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; import java.util.Map; @Service public class WzUserServiceImpl implements WzUserService { @Autowired private WzUserDao wzUserDao; @Autowired private WzOtnAreaService otnAreaService; @Override public List queryList(Map map) { if(map.get("city")!=null&&!map.get("city").toString().equals("全省")&&!map.get("city").toString().equals("")){ OtnAreaEntity city = otnAreaService.queryObjectById(map.get("city").toString()); map.put("city",city.getName()); } if(map.get("city")!=null&&map.get("city").toString().equals("全省")){ map.remove("city"); } if(map.get("city")!=null&&map.get("city").toString().equals("")){ map.remove("city"); } if(map.get("county")!=null&&!map.get("county").toString().equals("区县")&&!map.get("county").toString().equals("")){ OtnAreaEntity city = otnAreaService.queryObjectById(map.get("county").toString()); map.put("county",city.getName()); } if(map.get("county")!=null&&map.get("county").toString().equals("区县")){ map.remove("county"); } if(map.get("county")!=null&&map.get("county").toString().equals("")){ map.remove("county"); } return wzUserDao.queryList(map); } @Override public int queryTotal(Map map) { if(map.get("city")!=null&&!map.get("city").toString().equals("全省")&&!map.get("city").toString().equals("")){ OtnAreaEntity city = otnAreaService.queryObjectById(map.get("city").toString()); map.put("city",city.getName()); } if(map.get("city")!=null&&map.get("city").toString().equals("全省")){ map.remove("city"); } if(map.get("city")!=null&&map.get("city").toString().equals("")){ map.remove("city"); } if(map.get("county")!=null&&!map.get("county").toString().equals("区县")&&!map.get("county").toString().equals("")){ OtnAreaEntity city = otnAreaService.queryObjectById(map.get("county").toString()); map.put("county",city.getName()); } if(map.get("county")!=null&&map.get("county").toString().equals("区县")){ map.remove("county"); } if(map.get("county")!=null&&map.get("county").toString().equals("")){ map.remove("county"); } return wzUserDao.queryTotal(map); } @Override public int save(WzUserEntity userEntity) { if(userEntity.getCity()!=null&&!userEntity.getCity().equals("全省")&&!userEntity.getCity().equals("")){ OtnAreaEntity city = otnAreaService.queryObjectById(userEntity.getCity()); userEntity.setCity(city.getName()); } if(userEntity.getCounty()!=null&&!userEntity.getCounty().equals("区县")&&!userEntity.getCounty().equals("")){ OtnAreaEntity city = otnAreaService.queryObjectById(userEntity.getCounty()); userEntity.setCounty(city.getName()); } return wzUserDao.save(userEntity); } }