package com.qy.worksheetsystem.service.impl;

import com.qy.worksheetsystem.model.mapper.ProjectMapper;
import com.qy.worksheetsystem.service.ProjectPersonService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

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

/**
 * @author qingwu
 * @date 2024/12/5
 * @apiNote
 */
@Slf4j
@Service
public class ProjectPersonServiceImpl implements ProjectPersonService {

    @Resource
    private ProjectMapper projectMapper;

    @Override
    public List<Map<String, String>> getProjectRoleList() {
        return projectMapper.getProjectRoleList();
    }

    @Override
    public List<Map<String, String>> getProjectListByState(String state, String dateTime) {
        return projectMapper.getProjectListByState(state, dateTime);
    }

    @Override
    public List<Map<String, String>> getProjectManagementByState(String state, String dateTime) {
        return projectMapper.getProjectManagementByState(state, dateTime);
    }

    @Override
    public List<Map<String, String>> getMemberManagementInfoByPerobjectId(String perobjectId) {
        return projectMapper.getMemberManagementInfoByPerobjectId(perobjectId);
    }

    @Override
    public List<Map<String, String>> getPersonAll() {
        return projectMapper.getPersonAll();
    }

    @Override
    public int updateStateByPersonIdAndPerobject(boolean state, String personID, String projectID) {
        String status = "1";
        if (!state) {
            status = "0";
        }
        return projectMapper.updateStateByPersonIdAndPerobject(status, personID, projectID);
    }

    @Override
    public String getMemberManagementID() {
        return projectMapper.getMemberManagementID();
    }

    @Override
    public String getPersonIdBYNumber(String number) {
        return projectMapper.getPersonIdBYNumber(number);
    }

    @Override
    public Map getProjectManagementInfoBYId(String id) {
        return projectMapper.getProjectManagementInfoBYId(id);
    }

    @Override
    public Map addProjectPerson(Map<String, Object> mapParam) {
        Map map = new HashMap();
        int insertNum = projectMapper.addProjectPerson(mapParam);
        if (insertNum != 1) {
            map.put("code", "500");
            map.put("status", insertNum);
            map.put("msg", "新增失败");
        } else {
            map.put("code", "200");
            map.put("status", insertNum);
            map.put("msg", "新增成功");
        }
        return map;
    }

}
