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.DmsBaseOutsrcInfoMapper;
import com.hw.dms.domain.DmsBaseOutsrcInfo;
import com.hw.dms.service.IDmsBaseOutsrcInfoService;

/**
 * 外协信息Service业务层处理
 *
 * @author Open Platform
 * @date 2024-01-11
 */
@Service
public class DmsBaseOutsrcInfoServiceImpl implements IDmsBaseOutsrcInfoService
{
    @Autowired
    private DmsBaseOutsrcInfoMapper dmsBaseOutsrcInfoMapper;

    /**
     * 查询外协信息
     *
     * @param outsrcId 外协信息主键
     * @return 外协信息
     */
    @Override
    public DmsBaseOutsrcInfo selectDmsBaseOutsrcInfoByOutsrcId(Long outsrcId)
    {
        return dmsBaseOutsrcInfoMapper.selectDmsBaseOutsrcInfoByOutsrcId(outsrcId);
    }

    /**
     * 查询外协信息列表
     *
     * @param dmsBaseOutsrcInfo 外协信息
     * @return 外协信息
     */
    @Override
    public List<DmsBaseOutsrcInfo> selectDmsBaseOutsrcInfoList(DmsBaseOutsrcInfo dmsBaseOutsrcInfo)
    {
        return dmsBaseOutsrcInfoMapper.selectDmsBaseOutsrcInfoList(dmsBaseOutsrcInfo);
    }

    /**
     * 新增外协信息
     *
     * @param dmsBaseOutsrcInfo 外协信息
     * @return 结果
     */
    @Override
    public int insertDmsBaseOutsrcInfo(DmsBaseOutsrcInfo dmsBaseOutsrcInfo)
    {
        LoginUser user = SecurityUtils.getLoginUser();
        dmsBaseOutsrcInfo.setIsFlag(1l);
        dmsBaseOutsrcInfo.setCreateBy(user.getUsername());
        dmsBaseOutsrcInfo.setCreateTime(DateUtils.getNowDate());
        return dmsBaseOutsrcInfoMapper.insertDmsBaseOutsrcInfo(dmsBaseOutsrcInfo);
    }

    /**
     * 修改外协信息
     *
     * @param dmsBaseOutsrcInfo 外协信息
     * @return 结果
     */
    @Override
    public int updateDmsBaseOutsrcInfo(DmsBaseOutsrcInfo dmsBaseOutsrcInfo)
    {
        LoginUser user = SecurityUtils.getLoginUser();
        dmsBaseOutsrcInfo.setUpdateBy(user.getUsername());
        dmsBaseOutsrcInfo.setUpdateTime(DateUtils.getNowDate());
        return dmsBaseOutsrcInfoMapper.updateDmsBaseOutsrcInfo(dmsBaseOutsrcInfo);
    }

    /**
     * 批量删除外协信息
     *
     * @param outsrcIds 需要删除的外协信息主键
     * @return 结果
     */
    @Override
    public int deleteDmsBaseOutsrcInfoByOutsrcIds(Long[] outsrcIds)
    {
        return dmsBaseOutsrcInfoMapper.deleteDmsBaseOutsrcInfoByOutsrcIds(outsrcIds);
    }

    /**
     * 删除外协信息信息
     *
     * @param outsrcId 外协信息主键
     * @return 结果
     */
    @Override
    public int deleteDmsBaseOutsrcInfoByOutsrcId(Long outsrcId)
    {
        return dmsBaseOutsrcInfoMapper.deleteDmsBaseOutsrcInfoByOutsrcId(outsrcId);
    }
}
