package com.gk.firework.Service.ServiceImpl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.gk.firework.Domain.DistrictInfo; import com.gk.firework.Domain.Utils.StringUtils; import com.gk.firework.Mapper.DistrictInfoMapper; import com.gk.firework.Service.DistrictService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; @Service("DistrictService") public class DistrictServiceImpl extends ServiceImpl implements DistrictService { @Autowired DistrictInfoMapper districtInfoMapper; @Override public List selectDistrictInfo(String type, String parentcode) { return districtInfoMapper.selectDistrictInfo(type, parentcode); } @Override public DistrictInfo selectInfoByName(String name, Byte type) { DistrictInfo districtInfo = new DistrictInfo(); districtInfo.setName(name); districtInfo.setType(type); QueryWrapper wrapper = new QueryWrapper<> (districtInfo); return districtInfoMapper.selectOne(wrapper); } @Override public DistrictInfo selectInfoByCode(String code, Byte type) { DistrictInfo districtInfo = new DistrictInfo(); districtInfo.setCode(code); districtInfo.setType(type); QueryWrapper wrapper = new QueryWrapper<> (districtInfo); return districtInfoMapper.selectOne(wrapper); } @Override public List selectDistrictByName(String type, String parentname, String parenttype) { return districtInfoMapper.selectDistrictByName(type, parentname, parenttype); } @Override public List selectInfoByParentCode(String s) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(DistrictInfo::getParentcode,s); return districtInfoMapper.selectList(wrapper); } @Override public List selectInfoByParentCodeAndCity(String s, Object city) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(DistrictInfo::getParentcode,s); if (StringUtils.isNotBlank(city.toString())){ wrapper.eq(DistrictInfo::getName,city); } return districtInfoMapper.selectList(wrapper); } }