package com.ruoyi.system.service.impl;

import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.ForgetPassword;
import com.ruoyi.system.mapper.ForgetPasswordMapper;
import com.ruoyi.system.service.IForgetPasswordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 忘记密码申请Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-11-03
 */
@Service
public class ForgetPasswordServiceImpl implements IForgetPasswordService
{
    @Autowired
    private ForgetPasswordMapper forgetPasswordMapper;

    /**
     * 查询忘记密码申请
     * 
     * @param pId 忘记密码申请ID
     * @return 忘记密码申请
     */
    @Override
    public ForgetPassword selectForgetPasswordById(Long pId)
    {
        return forgetPasswordMapper.selectForgetPasswordById(pId);
    }

    /**
     * 查询忘记密码申请列表
     * 
     * @param forgetPassword 忘记密码申请
     * @return 忘记密码申请
     */
    @Override
    public List<ForgetPassword> selectForgetPasswordList(ForgetPassword forgetPassword)
    {
        return forgetPasswordMapper.selectForgetPasswordList(forgetPassword);
    }

    /**
     * 新增忘记密码申请
     * 
     * @param forgetPassword 忘记密码申请
     * @return 结果
     */
    @Override
    public int insertForgetPassword(ForgetPassword forgetPassword)
    {
        forgetPassword.setCreateTime(DateUtils.getNowDate());
        forgetPassword.setApplyTime(DateUtils.getNowDate());
        return forgetPasswordMapper.insertForgetPassword(forgetPassword);
    }

    /**
     * 修改忘记密码申请
     * 
     * @param forgetPassword 忘记密码申请
     * @return 结果
     */
    @Override
    public int updateForgetPassword(ForgetPassword forgetPassword)
    {
        forgetPassword.setUpdateTime(DateUtils.getNowDate());
        return forgetPasswordMapper.updateForgetPassword(forgetPassword);
    }

    /**
     * 删除忘记密码申请对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteForgetPasswordByIds(String ids)
    {
        return forgetPasswordMapper.deleteForgetPasswordByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除忘记密码申请信息
     * 
     * @param pId 忘记密码申请ID
     * @return 结果
     */
    @Override
    public int deleteForgetPasswordById(Long pId)
    {
        return forgetPasswordMapper.deleteForgetPasswordById(pId);
    }
}
