package com.base.biz.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.base.api.model.request.PointListRpcReqDTO;
import com.base.api.model.request.TaskStateNotice;
import com.base.biz.mapper.PointInfoMapper;
import com.base.biz.model.dto.PointDTO;
import com.base.biz.model.dto.request.PointListReqDTO;
import com.base.biz.model.entity.PointInfo;
import com.base.orbit.utils.BizUtils;
import com.base.orbit.web.Result;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

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

@Service
public class PointService extends ServiceImpl<PointInfoMapper, PointInfo> {

    @Resource
    PointInfoMapper pointInfoMapper;

    public List<PointDTO> getPointDTOList(PointListReqDTO req) {
        if (CollectionUtils.isEmpty(req.getParentIds())) {
            return new ArrayList<>();
        }
        List<PointInfo> list = pointInfoMapper.getPointInfoList(req);
        return BizUtils.copyEntityToDto(PointDTO.class, list);
    }

    public void deletePointDTO(PointListRpcReqDTO pointListRpcReqDTO) {
        QueryWrapper<PointInfo> queryWrapper=new QueryWrapper<>();
        queryWrapper.in("id",pointListRpcReqDTO.getId());
        pointInfoMapper.delete(queryWrapper);
    }

    public boolean deleteByIds(List<String> ids) {
        return this.removeByIds(ids);
    }
}
