package com.gtiit.shr.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gtiit.shr.common.Result;
import com.gtiit.shr.entity.vo.PersonInfoVo;
import com.gtiit.shr.mapper.PersonMapper;
import com.gtiit.shr.service.PersonService;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class PersonServiceImpl implements PersonService {
    @Autowired
    private PersonMapper personMapper;


    public int insertBatchPerson(List<PersonInfoVo> personInfoVos) {
        return this.personMapper.insertBatch(personInfoVos);
    }

    public int updateBatchPerson(List<PersonInfoVo> personInfoVos) {
        return this.personMapper.updateBatch(personInfoVos);
    }

    public Result findPage(List<String> shrIds) {
        QueryWrapper<PersonInfoVo> queryWrapper = new QueryWrapper();
        queryWrapper.in("ID", shrIds);
        List<PersonInfoVo> personInfoVos = this.personMapper.selectList(queryWrapper);
        Result result = new Result();
        if (personInfoVos != null && personInfoVos.size() > 0) {
            result.setMessage("员工基本信息查询成功！");
            result.setCode(1);
            result.setFlag(true);
            result.setData(personInfoVos);
        } else {
            result.setMessage("员工基本信息查询失败！");
            result.setCode(0);
            result.setFlag(false);
        }

        return result;
    }
}
