package com.ruoyi.invest.service.impl;

import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.IdWorker;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.invest.domain.HeartJourney;
import com.ruoyi.invest.domain.dto.HeartJourneyDto;
import com.ruoyi.invest.domain.vo.HeartJourneyVo;
import com.ruoyi.invest.mapper.HeartJourneyMapper;
import com.ruoyi.invest.service.IHeartJourneyService;
import org.springframework.stereotype.Service;

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

/**
 * 心路历程Service业务层处理
 *
 * @author tianyongbao
 * @date 2024-04-09
 */
@Service
public class HeartJourneyServiceImpl implements IHeartJourneyService
{
    @Resource
    private HeartJourneyMapper heartJourneyMapper;

    /**
     * 查询心路历程
     *
     * @param id 心路历程主键
     * @return 心路历程
     */
    @Override
    public HeartJourneyVo selectHeartJourneyById(Long id)
    {
        return heartJourneyMapper.selectHeartJourneyById(id);
    }

    /**
     * 查询心路历程列表
     *
     * @param heartJourneyDto 心路历程
     * @return 心路历程
     */
    @Override
    public List<HeartJourneyVo> selectHeartJourneyList(HeartJourneyDto heartJourneyDto)
    {
        return heartJourneyMapper.selectHeartJourneyList(heartJourneyDto);
    }

    /**
     * 新增心路历程
     *
     * @param heartJourney 心路历程
     * @return 结果
     */
    @Override
    public int insertHeartJourney(HeartJourney heartJourney)
    {
        heartJourney.setCreateBy(SecurityUtils.getUsername());
        heartJourney.setId(IdWorker.getId());
        return heartJourneyMapper.insertHeartJourney(heartJourney);
    }

    /**
     * 修改心路历程
     *
     * @param heartJourney 心路历程
     * @return 结果
     */
    @Override
    public int updateHeartJourney(HeartJourney heartJourney)
    {
        heartJourney.setUpdateBy(SecurityUtils.getUsername());
        heartJourney.setUpdateTime(DateUtils.getNowDate());
        return heartJourneyMapper.updateHeartJourney(heartJourney);
    }

    /**
     * 批量删除心路历程
     *
     * @param ids 需要删除的心路历程主键
     * @return 结果
     */
    @Override
    public int deleteHeartJourneyByIds(Long[] ids)
    {
        return heartJourneyMapper.removeHeartJourneyByIds(ids);
    }

    /**
     * 删除心路历程信息
     *
     * @param id 心路历程主键
     * @return 结果
     */
    @Override
    public int deleteHeartJourneyById(Long id)
    {
        return heartJourneyMapper.removeHeartJourneyById(id);
    }
}
