package com.ruoyi.ibs.grid.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.ibs.grid.domain.dto.GridTeamBuildDTO;
import com.ruoyi.ibs.grid.domain.entity.GridTeamBuild;
import com.ruoyi.ibs.grid.domain.entity.RegionUserRelate;
import com.ruoyi.ibs.grid.domain.vo.GridTeamBuildListVO;
import com.ruoyi.ibs.grid.mapper.GridTeamBuildMapper;
import com.ruoyi.ibs.grid.mapper.RegionGridMapper;
import com.ruoyi.ibs.grid.mapper.RegionUserRelateMapper;
import com.ruoyi.ibs.grid.service.GridTeamBuildService;
import com.ruoyi.system.mapper.SysDeptMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

@Service
public class GridTeamBuildServiceImpl implements GridTeamBuildService {

    @Resource
    private GridTeamBuildMapper gridTeamBuildMapper;

    /**
     * 根据条件查询网格队伍建设列表
     */
    @Override
    public List<GridTeamBuildListVO> getGridTeamBuildList(GridTeamBuildDTO gridTeamBuildDTO) {
        return gridTeamBuildMapper.selectGridTeamBuildList(gridTeamBuildDTO);
    }

    /**
     * 新增网格队伍建设
     */
    @Override
    public int addGridTeamBuild(GridTeamBuild gridTeamBuild) {
        gridTeamBuild.setCreateBy(SecurityUtils.getUsername());
        gridTeamBuild.setCreateTime(new Date());
        return gridTeamBuildMapper.insert(gridTeamBuild);
    }

    /**
     * 修改网格队伍建设
     */
    @Override
    public int updateGridTeamBuild(GridTeamBuild gridTeamBuild) {
        gridTeamBuild.setUpdateBy(SecurityUtils.getUsername());
        gridTeamBuild.setUpdateTime(new Date());
        return gridTeamBuildMapper.updateById(gridTeamBuild);
    }

    @Override
    public int deleteById(Long id) {
        return gridTeamBuildMapper.deleteById(id);
    }

}
