package com.boman.web.core.service.grid.impl;


import com.boman.common.core.utils.DateUtils;
import com.boman.domain.dto.AjaxResult;
import com.boman.web.core.domain.GridInfo;
import com.boman.web.core.mapper.GridInfoMapper;
import com.boman.web.core.service.grid.IGridInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 网格信息Service业务层处理
 * 
 * @author boman
 * @date 2022-01-19
 */
@Service
public class GridInfoServiceImpl implements IGridInfoService
{
    @Autowired
    private GridInfoMapper gridInfoMapper;

    /**
     * 查询网格信息
     * 
     * @param id 网格信息主键
     * @return 网格信息
     */
    @Override
    public GridInfo selectGridInfoById(Long id)
    {
        return gridInfoMapper.selectGridInfoById(id);
    }

    /**
     * 查询网格信息列表
     * 
     * @param gridInfo 网格信息
     * @return 网格信息
     */
    @Override
    public List<GridInfo> selectGridInfoList(GridInfo gridInfo)
    {
        return gridInfoMapper.selectGridInfoList(gridInfo);
    }

    /**
     * 新增网格信息
     * 
     * @param gridInfo 网格信息
     * @return 结果
     */
    @Override
    public int insertGridInfo(GridInfo gridInfo)
    {
        gridInfo.setCreateTime(DateUtils.getNowDate());
        return gridInfoMapper.insertGridInfo(gridInfo);
    }

    /**
     * 修改网格信息
     * 
     * @param gridInfo 网格信息
     * @return 结果
     */
    @Override
    public int updateGridInfo(GridInfo gridInfo)
    {
        gridInfo.setUpdateTime(DateUtils.getNowDate());
        return gridInfoMapper.updateGridInfo(gridInfo);
    }

    /**
     * 批量删除网格信息
     * 
     * @param ids 需要删除的网格信息主键
     * @return 结果
     */
    @Override
    public int deleteGridInfoByIds(Long[] ids)
    {
        return gridInfoMapper.deleteGridInfoByIds(ids);
    }

    /**
     * 删除网格信息信息
     * 
     * @param id 网格信息主键
     * @return 结果
     */
    @Override
    public int deleteGridInfoById(Long id)
    {
        return gridInfoMapper.deleteGridInfoById(id);
    }

    /**
     * 网格信息下拉菜单
     * @param gridInfo
     * @return
     */
    @Override
    public AjaxResult treeSelect(GridInfo gridInfo) {
        List<GridInfo> gridInfos = gridInfoMapper.treeSelect(gridInfo);
        return AjaxResult.success(gridInfos);
    }
}
