package com.hw.dms.service.impl;

import java.util.List;
import com.hw.common.core.utils.DateUtils;
import com.hw.common.security.utils.SecurityUtils;
import com.hw.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hw.dms.mapper.DmsBaseInspectProjectMapper;
import com.hw.dms.domain.DmsBaseInspectProject;
import com.hw.dms.service.IDmsBaseInspectProjectService;

/**
 * 巡检项目信息Service业务层处理
 *
 * @author Open Platform
 * @date 2024-01-17
 */
@Service
public class DmsBaseInspectProjectServiceImpl implements IDmsBaseInspectProjectService
{
    @Autowired
    private DmsBaseInspectProjectMapper dmsBaseInspectProjectMapper;

    /**
     * 查询巡检项目信息
     *
     * @param inspectProjectId 巡检项目信息主键
     * @return 巡检项目信息
     */
    @Override
    public DmsBaseInspectProject selectDmsBaseInspectProjectByInspectProjectId(Long inspectProjectId)
    {
        return dmsBaseInspectProjectMapper.selectDmsBaseInspectProjectByInspectProjectId(inspectProjectId);
    }

    /**
     * 查询巡检项目信息列表
     *
     * @param dmsBaseInspectProject 巡检项目信息
     * @return 巡检项目信息
     */
    @Override
    public List<DmsBaseInspectProject> selectDmsBaseInspectProjectList(DmsBaseInspectProject dmsBaseInspectProject)
    {
        return dmsBaseInspectProjectMapper.selectDmsBaseInspectProjectList(dmsBaseInspectProject);
    }

    /**
     * 新增巡检项目信息
     *
     * @param dmsBaseInspectProject 巡检项目信息
     * @return 结果
     */
    @Override
    public int insertDmsBaseInspectProject(DmsBaseInspectProject dmsBaseInspectProject)
    {
        if (dmsBaseInspectProject.getInspectType()==null){
            dmsBaseInspectProject.setInspectType("1");
        }
        LoginUser user = SecurityUtils.getLoginUser();
        dmsBaseInspectProject.setIsFlag("1");
        dmsBaseInspectProject.setCreateBy(user.getUsername());
        dmsBaseInspectProject.setCreateTime(DateUtils.getNowDate());
        return dmsBaseInspectProjectMapper.insertDmsBaseInspectProject(dmsBaseInspectProject);
    }

    /**
     * 修改巡检项目信息
     *
     * @param dmsBaseInspectProject 巡检项目信息
     * @return 结果
     */
    @Override
    public int updateDmsBaseInspectProject(DmsBaseInspectProject dmsBaseInspectProject)
    {
        LoginUser user = SecurityUtils.getLoginUser();
        dmsBaseInspectProject.setUpdateBy(user.getUsername());
        dmsBaseInspectProject.setUpdateTime(DateUtils.getNowDate());
        return dmsBaseInspectProjectMapper.updateDmsBaseInspectProject(dmsBaseInspectProject);
    }

    /**
     * 批量删除巡检项目信息
     *
     * @param inspectProjectIds 需要删除的巡检项目信息主键
     * @return 结果
     */
    @Override
    public int deleteDmsBaseInspectProjectByInspectProjectIds(Long[] inspectProjectIds)
    {
        return dmsBaseInspectProjectMapper.deleteDmsBaseInspectProjectByInspectProjectIds(inspectProjectIds);
    }

    /**
     * 删除巡检项目信息信息
     *
     * @param inspectProjectId 巡检项目信息主键
     * @return 结果
     */
    @Override
    public int deleteDmsBaseInspectProjectByInspectProjectId(Long inspectProjectId)
    {
        return dmsBaseInspectProjectMapper.deleteDmsBaseInspectProjectByInspectProjectId(inspectProjectId);
    }
}
