package com.test.test.service.impl;

import com.test.common.utils.DateUtils;
import com.test.test.domain.TestProject;
import com.test.test.domain.qo.TestProjectListQO;
import com.test.test.mapper.TestProjectMapper;
import com.test.test.service.ITestProjectService;
import jakarta.annotation.Resource;
import java.util.List;
import org.springframework.stereotype.Service;

/**
 * 需求实现类
 */
@Service
public class TestProjectServiceImpl implements ITestProjectService {
    // 0正常，1删除
    private static final String DEL_FLAG = "0";

    // 状态： 0未开始，1进行中，2已完成，3已终止
    private static final String STATUS = "0";

    @Resource
    private TestProjectMapper testProjectMapper;

    /**
     * 查询需求列表
     * @param qo
     * @return TestProject
     */
    @Override
    public List<TestProject> selectTestProjectList(TestProjectListQO qo) {
        return testProjectMapper.selectTestProjectList(qo);
    }

    /**
     * 新增需求
     * @param testProject
     * @return
     */
    @Override
    public int insertTestProject(TestProject testProject) {
        testProject.setStatus(STATUS);
        testProject.setCreateTime(DateUtils.getNowDate());
        testProject.setDelFlag(DEL_FLAG);
        return testProjectMapper.insertTestProject(testProject);
    }

    /**
     * 删除需求
     * @param id
     * @return
     */
    @Override
    public int deleteTestProjectById(Long id) {
        return testProjectMapper.deleteTestProjectById(id);
    }

    /**
     * 根据id查询需求详情
     * @param id
     * @return
     */
    @Override
    public TestProject selectTestProjectById(Long id) {
        return testProjectMapper.selectTestProjectById(id);
    }

    /**
     * 修改需求
     * @param testProject
     * @return int
     */
    @Override
    public int updateTestProject(TestProject testProject) {
        testProject.setUpdateTime(DateUtils.getNowDate());
        return testProjectMapper.updateTestProject(testProject);
    }
}
