郑永安
2023-06-19 f65443d8abeaedc9d102324565e8368e7c9d90c8
src/main/java/com/gk/firework/Service/ServiceImpl/DistrictServiceImpl.java
对比新文件
@@ -0,0 +1,66 @@
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<DistrictInfoMapper, DistrictInfo> implements DistrictService {
    @Autowired
    DistrictInfoMapper districtInfoMapper;
    @Override
    public List<DistrictInfo> 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<DistrictInfo> 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<DistrictInfo> wrapper = new QueryWrapper<> (districtInfo);
        return districtInfoMapper.selectOne(wrapper);
    }
    @Override
    public List<DistrictInfo> selectDistrictByName(String type, String parentname, String parenttype) {
        return districtInfoMapper.selectDistrictByName(type, parentname, parenttype);
    }
    @Override
    public List<DistrictInfo> selectInfoByParentCode(String s) {
        LambdaQueryWrapper<DistrictInfo> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(DistrictInfo::getParentcode,s);
        return districtInfoMapper.selectList(wrapper);
    }
    @Override
    public List<DistrictInfo> selectInfoByParentCodeAndCity(String s, Object city) {
        LambdaQueryWrapper<DistrictInfo> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(DistrictInfo::getParentcode,s);
        if (StringUtils.isNotBlank(city.toString())){
            wrapper.eq(DistrictInfo::getName,city);
        }
        return districtInfoMapper.selectList(wrapper);
    }
}