package com.yx.face.service.impl;

import com.yx.face.boot.restful.ServiceException;
import com.yx.face.dao.AreaCodeDao;
import com.yx.face.dao.PoliceStationDao;
import com.yx.face.model.entity.AreaCode;
import com.yx.face.model.entity.PoliceStation;
import com.yx.face.model.vo.PoliceStationVO;
import com.yx.face.service.PoliceStationService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @description:
 * @ClassName policeStationCodeserviceImpl
 * @Author WXG
 * @Date 2021/10/29 10:03
 */
@Service
public class PoliceStationServiceImpl implements PoliceStationService {
    @Resource
    private PoliceStationDao policeStationDao;
    @Resource
    private AreaCodeDao areaCodeDao;

    @Override
    public List<PoliceStationVO> getList(Integer areaCodeId) {
        AreaCode areaCode = areaCodeDao.selectByPrimaryKey(areaCodeId);
        if(areaCode==null){
            throw  new ServiceException("areaCodeId不存在");
        }
        List<PoliceStationVO> list =  policeStationDao.getList(areaCode.getCode());
        return list;
    }

    @Override
    public PoliceStation getByPoliceStation(String policeStationCode) {
        PoliceStation entity = policeStationDao.getByPoliceStation(policeStationCode);
        return entity;
    }
}
