package com.fs.his.service.impl;

import java.util.Collections;
import java.util.List;

import com.fs.common.core.redis.RedisCache;
import com.fs.his.domain.FsCity;
import com.fs.his.vo.CitysAreaVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import com.fs.his.mapper.FsCityMapper;

import com.fs.his.service.IFsCityService;

/**
 * 城市Service业务层处理
 *
 * @author fs
 * @date 2023-06-02
 */
@Service
public class FsCityServiceImpl implements IFsCityService
{
    @Autowired
    private FsCityMapper fsCityMapper;
    @Autowired
    private RedisCache redisCache;

    /**
     * 查询城市
     *
     * @param id 城市主键
     * @return 城市
     */
    @Override
    public FsCity selectFsCityById(Long id)
    {
        return fsCityMapper.selectFsCityById(id);
    }

    /**
     * 查询城市列表
     *
     * @param fsCity 城市
     * @return 城市
     */
    @Override
    public List<FsCity> selectFsCityList(FsCity fsCity)
    {
        return fsCityMapper.selectFsCityList(fsCity);
    }

    /**
     * 新增城市
     *
     * @param fsCity 城市
     * @return 结果
     */
    @Override
    public int insertFsCity(FsCity fsCity)
    {
        return fsCityMapper.insertFsCity(fsCity);
    }

    /**
     * 修改城市
     *
     * @param fsCity 城市
     * @return 结果
     */
    @Override
    public int updateFsCity(FsCity fsCity)
    {
        return fsCityMapper.updateFsCity(fsCity);
    }

    /**
     * 批量删除城市
     *
     * @param ids 需要删除的城市主键
     * @return 结果
     */
    @Override
    public int deleteFsCityByIds(Long[] ids)
    {
        return fsCityMapper.deleteFsCityByIds(ids);
    }

    /**
     * 删除城市信息
     *
     * @param id 城市主键
     * @return 结果
     */
    @Override
    public int deleteFsCityById(Long id)
    {
        return fsCityMapper.deleteFsCityById(id);
    }




    @Override
    public List<FsCity> selectFsCity() {
        return fsCityMapper.selectFsCity();
    }

    @Override
    public List<CitysAreaVO> getCitysArea() {
        List<CitysAreaVO> redisList = redisCache.getCacheObject("city");
        if(redisList != null){
            return redisList;
        }
        List<CitysAreaVO> list = fsCityMapper.getCitysArea();
        redisCache.setCacheObject("city", list);
        return list;
    }


}
