package com.ylx.massage.service.impl;

import java.util.List;
import com.ylx.massage.domain.vo.MaTechnicianAppAddVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ylx.massage.mapper.MaTechnicianMapper;
import com.ylx.massage.domain.MaTechnician;
import com.ylx.massage.service.IMaTechnicianService;
import org.springframework.transaction.annotation.Transactional;

/**
 * 技师Service业务层处理
 *
 * @author ylx
 * @date 2024-03-22
 */
@Service
public class MaTechnicianServiceImpl implements IMaTechnicianService
{
    @Autowired
    private MaTechnicianMapper maTechnicianMapper;




    /**
     * 查询技师
     *
     * @param id 技师主键
     * @return 技师
     */
    @Override
    public MaTechnician selectMaTechnicianById(Long id)
    {
        return maTechnicianMapper.selectMaTechnicianById(id);
    }

    /**
     * 查询技师列表
     *
     * @param maTechnician 技师
     * @return 技师
     */
    @Override
    public List<MaTechnician> selectMaTechnicianList(MaTechnician maTechnician)
    {
        return maTechnicianMapper.selectMaTechnicianList(maTechnician);
    }

    /**
     * 新增技师
     *
     * @param maTechnicianAppAddVo 技师
     * @return 结果
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int insertMaTechnician(MaTechnicianAppAddVo maTechnicianAppAddVo)
    {
        int i = 0;
        MaTechnician maTechnician = new MaTechnician();
        BeanUtils.copyProperties(maTechnicianAppAddVo, maTechnician);
        maTechnicianMapper.insertMaTechnician(maTechnician);
        if (!maTechnicianAppAddVo.getProjectIds().isEmpty()) {
//            ArrayList<MaTeProject> objects = Lists.newArrayList();
//            ArrayList<Long> projectIds = maTechnicianAppAddVo.getProjectIds();
//            projectIds.forEach(id->{
//                MaTeProject maTeProject = new MaTeProject();
//                maTeProject.setTeId(maTechnician.getId());
//                maTeProject.setProjectId(id);
//                objects.add(maTeProject);
//            });
//            i = maTeProjectMapper.insertBatch(objects);
        }
        return i;
    }

    /**
     * 修改技师
     *
     * @param  maTechnicianAppAddVo
     * @return 结果
     */
    @Override
    public int updateMaTechnician(MaTechnicianAppAddVo maTechnicianAppAddVo)
    {

        MaTechnician maTechnician = new MaTechnician();
        BeanUtils.copyProperties(maTechnicianAppAddVo, maTechnician);

        return maTechnicianMapper.updateMaTechnician(maTechnician);
    }

    /**
     * 批量删除技师
     *
     * @param ids 需要删除的技师主键
     * @return 结果
     */
    @Override
    public int deleteMaTechnicianByIds(Long[] ids)
    {
        return maTechnicianMapper.deleteMaTechnicianByIds(ids);
    }

    /**
     * 删除技师信息
     *
     * @param id 技师主键
     * @return 结果
     */
    @Override
    public int deleteMaTechnicianById(Long id)
    {
        return maTechnicianMapper.deleteMaTechnicianById(id);
    }
}
