package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.IssuerMapper;
import com.ruoyi.system.domain.Issuer;
import com.ruoyi.system.service.IIssuerService;

/**
 * 发行方Service业务层处理
 *
 * @author ruoyi
 * @date 2023-02-14
 */
@Service
public class IssuerServiceImpl implements IIssuerService
{
    @Autowired
    private IssuerMapper issuerMapper;

    /**
     * 查询发行方
     *
     * @param id 发行方主键
     * @return 发行方
     */
    @Override
    public Issuer selectIssuerById(Long id)
    {
        return issuerMapper.selectIssuerById(id);
    }

    @Override
    public Long selectIssuerByIdForIssuerName(String issuerName) {
        return issuerMapper.selectIssuerByIdForIssuerName(issuerName);
    }

    /**
     * 查询发行方列表
     *
     * @param issuer 发行方
     * @return 发行方
     */
    @Override
    public List<Issuer> selectIssuerList(Issuer issuer)
    {
        return issuerMapper.selectIssuerList(issuer);
    }

    /**
     * 新增发行方
     *
     * @param issuer 发行方
     * @return 结果
     */
    @Override
    public int insertIssuer(Issuer issuer)
    {
        issuer.setCreateTime(DateUtils.getNowDate());
        return issuerMapper.insertIssuer(issuer);
    }

    /**
     * 修改发行方
     *
     * @param issuer 发行方
     * @return 结果
     */
    @Override
    public int updateIssuer(Issuer issuer)
    {
        issuer.setUpdateTime(DateUtils.getNowDate());
        return issuerMapper.updateIssuer(issuer);
    }

    /**
     * 批量删除发行方
     *
     * @param ids 需要删除的发行方主键
     * @return 结果
     */
    @Override
    public int deleteIssuerByIds(Long[] ids)
    {
        return issuerMapper.deleteIssuerByIds(ids);
    }

    /**
     * 删除发行方信息
     *
     * @param id 发行方主键
     * @return 结果
     */
    @Override
    public int deleteIssuerById(Long id)
    {
        return issuerMapper.deleteIssuerById(id);
    }

    /**
     * 根据发行方名字搜索发行方列表
     * @param issuerName
     * @return
     */
    @Override
    public List<Issuer> selectByIssuerName(String issuerName) {
        if (issuerName != null) {
            return issuerMapper.selectByIssuerName(issuerName);
        }
        Issuer issuer = new Issuer();
        return issuerMapper.selectIssuerList(issuer);
    }
}
