package com.jeeplus.human.depart.handover.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jeeplus.core.query.QueryWrapperGenerator;
import com.jeeplus.human.depart.handover.domain.*;
import com.jeeplus.human.depart.handover.domain.dto.HandoverProjectDto;
import com.jeeplus.human.depart.handover.mapper.HandoverProjectMapper;
import com.jeeplus.utils.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.*;

/**
 * @author 王强
 * @version 1.0
 * @date 2023-10-27 9:04
 */
@Service
@Transactional
public class HandoverProjectService extends ServiceImpl<HandoverProjectMapper, HandoverProject> {

    public IPage<HandoverProject> findProjectList(Page<HandoverProject> page, HandoverProjectDto handoverProjectDto) throws Exception{
        QueryWrapper<HandoverProjectDto> queryWrapper = QueryWrapperGenerator.buildQueryCondition(handoverProjectDto, HandoverProjectDto.class);
        queryWrapper.eq("a.del_flag",0);
        if(StringUtils.isNotEmpty(handoverProjectDto.getId())){
            queryWrapper.eq("a.handover_id",handoverProjectDto.getId());
        }
        if(StringUtils.isNotEmpty(handoverProjectDto.getType())){
            queryWrapper.eq("a.type",handoverProjectDto.getType());
        }
        // 查询基础信息表
        IPage<HandoverProject> projectList = baseMapper.findProjectList(page, queryWrapper);
        return projectList;
    }

    public String  saveProject(List<HandoverProject> handoverProject) throws Exception {
        saveBatch(handoverProject);
        return "操作成功";
    }



}
