package com.ruoyi.generator.service;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.ruoyi.generator.mapper.SysProjectStructureMapper;
import com.ruoyi.generator.domain.SysProjectStructure;
import com.ruoyi.generator.service.ISysProjectStructureService;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;

/**
 * 项目结构节点Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-05-14
 */
@Service
public class SysProjectStructureServiceImpl implements ISysProjectStructureService 
{
    @Autowired
    private SysProjectStructureMapper sysProjectStructureMapper;

    /**
     * 查询项目结构节点
     * 
     * @param nodeId 项目结构节点主键
     * @return 项目结构节点
     */
    @Override
    public SysProjectStructure selectSysProjectStructureByNodeId(Long nodeId)
    {
        return sysProjectStructureMapper.selectSysProjectStructureByNodeId(nodeId);
    }

    /**
     * 查询项目结构节点列表
     * 
     * @param sysProjectStructure 项目结构节点
     * @return 项目结构节点
     */
    @Override
    public List<SysProjectStructure> selectSysProjectStructureList(SysProjectStructure sysProjectStructure)
    {
        return sysProjectStructureMapper.selectSysProjectStructureList(sysProjectStructure);
    }

    /**
     * 新增项目结构节点
     * 
     * @param sysProjectStructure 项目结构节点
     * @return 结果
     */
    @Override
    @Transactional
    public int insertSysProjectStructure(SysProjectStructure sysProjectStructure)
    {
        sysProjectStructure.setCreateBy(SecurityUtils.getUsername());
        sysProjectStructure.setCreateTime(DateUtils.getNowDate());
        return sysProjectStructureMapper.insertSysProjectStructure(sysProjectStructure);
    }

    /**
     * 修改项目结构节点
     * 
     * @param sysProjectStructure 项目结构节点
     * @return 结果
     */
    @Override
    @Transactional
    public int updateSysProjectStructure(SysProjectStructure sysProjectStructure)
    {
        sysProjectStructure.setUpdateBy(SecurityUtils.getUsername());
        sysProjectStructure.setUpdateTime(DateUtils.getNowDate());
        return sysProjectStructureMapper.updateSysProjectStructure(sysProjectStructure);
    }

    /**
     * 批量删除项目结构节点
     * 
     * @param nodeIds 需要删除的项目结构节点主键
     * @return 结果
     */
    @Override
    @Transactional
    public int deleteSysProjectStructureByNodeIds(Long[] nodeIds)
    {
        return sysProjectStructureMapper.deleteSysProjectStructureByNodeIds(nodeIds);
    }

    /**
     * 删除项目结构节点信息
     * 
     * @param nodeId 项目结构节点主键
     * @return 结果
     */
    @Override
    @Transactional
    public int deleteSysProjectStructureByNodeId(Long nodeId)
    {
        return sysProjectStructureMapper.deleteSysProjectStructureByNodeId(nodeId);
    }

    @Override
    public List<SysProjectStructure> selectProjectStructureListByModule(Long projectId, Long templateId) {
        return sysProjectStructureMapper.selectProjectStructureListByModule(projectId, templateId);
    }
}
