package com.zd.system.service.impl;

import java.util.List;

import com.zd.common.core.utils.StringUtils;
import com.zd.system.api.laboratory.RemoteLaboratoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zd.system.mapper.SysLogoConfigMapper;
import com.zd.system.domain.SysLogoConfig;
import com.zd.system.service.ISysLogoConfigService;

/**
 * logo配置Service业务层处理
 *
 * @author zd
 * @date 2022-05-06
 */
@Service
public class SysLogoConfigServiceImpl implements ISysLogoConfigService
{
    @Autowired
    private SysLogoConfigMapper sysLogoConfigMapper;

    @Autowired
    private RemoteLaboratoryService remoteLaboratoryService;

    /**
     * 查询logo配置
     *
     * @param id logo配置主键
     * @return logo配置
     */
    @Override
    public SysLogoConfig selectSysLogoConfigById(Long id)
    {
        return sysLogoConfigMapper.selectSysLogoConfigById(id);
    }

    /**
     * 查询logo配置列表
     *
     * @param sysLogoConfig logo配置
     * @return logo配置
     */
    @Override
    public List<SysLogoConfig> selectSysLogoConfigList(SysLogoConfig sysLogoConfig)
    {
        return sysLogoConfigMapper.selectSysLogoConfigList(sysLogoConfig);
    }

    /**
     * 新增logo配置
     *
     * @param sysLogoConfig logo配置
     * @return 结果
     */
    @Override
    public int insertSysLogoConfig(SysLogoConfig sysLogoConfig)
    {
        return sysLogoConfigMapper.insertSysLogoConfig(sysLogoConfig);
    }

    /**
     * 修改logo配置
     *
     * @param sysLogoConfig logo配置
     * @return 结果
     */
    @Override
    public int updateSysLogoConfig(SysLogoConfig sysLogoConfig)
    {
        int flag;
        List<SysLogoConfig> sysLogoConfigList = sysLogoConfigMapper.selectSysLogoConfigList(new SysLogoConfig());
        if(sysLogoConfigList.size()>0){
            sysLogoConfig.setId(sysLogoConfigList.get(0).getId());
            flag = sysLogoConfigMapper.updateSysLogoConfig(sysLogoConfig);
        }else{
            flag = sysLogoConfigMapper.insertSysLogoConfig(sysLogoConfig);
        }
        if(flag>0){
            remoteLaboratoryService.logoNotice();
        }
        return flag;
    }

    /**
     * 批量删除logo配置
     *
     * @param ids 需要删除的logo配置主键
     * @return 结果
     */
    @Override
    public int deleteSysLogoConfigByIds(Long[] ids)
    {
        return sysLogoConfigMapper.deleteSysLogoConfigByIds(ids);
    }

    /**
     * 删除logo配置信息
     *
     * @param id logo配置主键
     * @return 结果
     */
    @Override
    public int deleteSysLogoConfigById(Long id)
    {
        return sysLogoConfigMapper.deleteSysLogoConfigById(id);
    }
}
