package com.ruoyi.project.service.impl;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.project.domain.ProjectStaff;
import com.ruoyi.project.mapper.ProjectStaffMapper;
import com.ruoyi.project.mapper.ProjectTaskMapper;
import com.ruoyi.project.service.ProjectStaffService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ProjectStaffServiceImpl implements ProjectStaffService {
    @Autowired
    private ProjectStaffMapper projectStaffMapper;
    @Autowired
    private ProjectTaskMapper projectTaskMapper;
    @Override
    public AjaxResult addStaff(ProjectStaff in) {
        int i = projectStaffMapper.insertSelective(in);
        projectTaskMapper.updateStaffName(in.getPid());
        return AjaxResult.success();
    }

    @Override
    public AjaxResult deleteStaff(ProjectStaff in) {
        int i = projectStaffMapper.deleteByPrimaryKey(in.getId());
        if (i>0){
            projectTaskMapper.updateStaffName(in.getPid());
            return AjaxResult.success();
        }
        return AjaxResult.error("编号不存在");
    }
}
