package com.ankaibei.workFlow.webadmin.ankaibei.api;

import com.ankaibei.workFlow.webadmin.ankaibei.entity.ProjectTeamInfoEntity;
import com.ankaibei.workFlow.webadmin.ankaibei.entity.UserInfoEntity;
import com.ankaibei.workFlow.webadmin.ankaibei.service.ProjectTeamService;
import com.ankaibei.workFlow.webadmin.ankaibei.vo.ProjectInfoVo;
import com.ankaibei.workFlow.webadmin.ankaibei.vo.ProjectTeamInfoVo;
import com.ankaibei.workFlow.webadmin.ankaibei.vo.ResMsg;
import com.ankaibei.workFlow.webadmin.ankaibei.vo.UserInfoVo;
import org.springframework.stereotype.Service;

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

/**
 * @author lwq
 * @version 1.0
 * @description:
 * @date 2022/9/13 10:24
 */
@Service
public class ProjectTeamServiceApi implements ProjectTeamApi{

    @Resource
    private ProjectTeamService projectTeamService;

    @Override
    public ResMsg findProjectTeamAll(ProjectTeamInfoVo projectTeamInfoVo) {

        ProjectTeamInfoEntity projectTeamInfoEntity = this.copyProperties(projectTeamInfoVo, ProjectTeamInfoEntity.class);
        return projectTeamService.findProjectTeamAll(projectTeamInfoVo.getPageIndex(),projectTeamInfoVo.getPageSize(),projectTeamInfoEntity);
    }

    @Override
    public ResMsg findProjectTeamUser(UserInfoVo userInfoVo) {
        return projectTeamService.findProjectTeamUser(userInfoVo.getPageIndex(),userInfoVo.getPageSize(),userInfoVo.getProjectTeamId());
    }

    @Override
    public ResMsg updateProjectTeam(ProjectTeamInfoVo projectTeamInfoVo) {
        ProjectTeamInfoEntity projectTeamInfoEntity = this.copyProperties(projectTeamInfoVo, ProjectTeamInfoEntity.class);
        return projectTeamService.updateProjectTeam(projectTeamInfoEntity);
    }

    @Override
    public boolean deleteBatchUser(List<UserInfoVo> userInfoVos) {
        List<UserInfoEntity> userInfoEntities = this.copyProperties(userInfoVos, UserInfoEntity.class);
        return projectTeamService.deleteBatchUser(userInfoEntities);
    }

    @Override
    public ResMsg addUser(UserInfoVo userInfoVo) {
        UserInfoEntity userInfoEntity = this.copyProperties(userInfoVo, UserInfoEntity.class);
        return projectTeamService.addUser(userInfoEntity);
    }

    @Override
    public ResMsg updateUser(UserInfoVo userInfoVo) {
        UserInfoEntity userInfoEntity = this.copyProperties(userInfoVo, UserInfoEntity.class);
        return projectTeamService.updateUser(userInfoEntity);
    }

    @Override
    public ResMsg findById(Long userId) {
        return projectTeamService.findById(userId);
    }

    @Override
    public ResMsg findPrincipal() {

        return projectTeamService.findPrincipal();
    }
    @Override
    public ResMsg findTeamUser(ProjectTeamInfoEntity projectTeamInfoEntity) {

        return projectTeamService.findTeamUser(projectTeamInfoEntity);
    }

    @Override
    public ResMsg addProjectTeam(ProjectTeamInfoVo projectTeamInfoVo) {

        ProjectTeamInfoEntity projectTeamInfoEntity = this.copyProperties(projectTeamInfoVo, ProjectTeamInfoEntity.class);
        return projectTeamService.addProjectTeam(projectTeamInfoEntity,projectTeamInfoVo.getUserIds());
    }

    @Override
    public ResMsg addProjectTeamUser(ProjectTeamInfoVo projectTeamInfoVo) {
        ProjectTeamInfoEntity projectTeamInfoEntity = this.copyProperties(projectTeamInfoVo, ProjectTeamInfoEntity.class);
        return projectTeamService.addProjectTeamUser(projectTeamInfoEntity,projectTeamInfoVo.getUserIds());
    }

    @Override
    public ResMsg removeUser(ProjectTeamInfoVo projectTeamInfoVo) {
        ProjectTeamInfoEntity projectTeamInfoEntity = this.copyProperties(projectTeamInfoVo, ProjectTeamInfoEntity.class);
        return projectTeamService.removeUser(projectTeamInfoEntity,projectTeamInfoVo.getUserIds());
    }

    @Override
    public ResMsg findUserProject(Long userId) {

        return projectTeamService.findUserProject(userId);
    }

    @Override
    public boolean deleteBatch(List<ProjectTeamInfoVo> projectTeamInfoVos) {
        List<ProjectTeamInfoEntity> projectTeamInfoEntities = this.copyProperties(projectTeamInfoVos, ProjectTeamInfoEntity.class);
        return projectTeamService.deleteBatch(projectTeamInfoEntities);
    }

}
