package com.zd.chemical.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.zd.common.core.utils.DateUtils;
import com.zd.common.core.utils.SecurityUtils;
import com.zd.common.security.utils.SaveUtil;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.zd.chemical.mapper.SydSmsLogMapper;
import com.zd.chemical.domain.SydSmsLog;
import com.zd.chemical.service.ISydSmsLogService;

/**
 * 四医大校方短信对接日志Service业务层处理
 *
 * @author liubo
 * @date 2022-09-16
 */
@Service
public class SydSmsLogServiceImpl implements ISydSmsLogService {
    @Autowired
    private SydSmsLogMapper sydSmsLogMapper;

    /**
     * 查询四医大校方短信对接日志
     *
     * @param id 四医大校方短信对接日志主键
     * @return 四医大校方短信对接日志
     */
    @Override
    public SydSmsLog selectSydSmsLogById(Long id) {
        return sydSmsLogMapper.selectSydSmsLogById(id);
    }

    /**
     * 查询四医大校方短信对接日志列表
     *
     * @param sydSmsLog 四医大校方短信对接日志
     * @return 四医大校方短信对接日志
     */
    @Override
    public List<SydSmsLog> selectSydSmsLogList(SydSmsLog sydSmsLog) {
        return sydSmsLogMapper.selectSydSmsLogList(sydSmsLog);
    }

    @Override
    public List<SydSmsLog> getListByIds(List<Long> ids) {
        if (ids.isEmpty()) {
            new ArrayList<>();
        }
        return sydSmsLogMapper.getListByIds(ids);
    }

    /**
     * 新增四医大校方短信对接日志
     *
     * @param sydSmsLog 四医大校方短信对接日志
     * @return 结果
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int insertSydSmsLog(SydSmsLog sydSmsLog) {
        //设置其他公共字段
        SaveUtil.setCommonAttr(sydSmsLog);
        return sydSmsLogMapper.insertSydSmsLog(sydSmsLog);
    }

    /**
     * 修改四医大校方短信对接日志
     *
     * @param sydSmsLog 四医大校方短信对接日志
     * @return 结果
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int updateSydSmsLog(SydSmsLog sydSmsLog) {
        sydSmsLog.setUpdateTime(DateUtils.getNowDate());
        sydSmsLog.setUpdateBy(SecurityUtils.getUsername());
        return sydSmsLogMapper.updateSydSmsLog(sydSmsLog);
    }

    /**
     * 批量删除四医大校方短信对接日志
     *
     * @param ids 需要删除的四医大校方短信对接日志主键
     * @return 结果
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int deleteSydSmsLogByIds(Long[] ids) {
        return sydSmsLogMapper.deleteSydSmsLogByIds(ids);
    }

    /**
     * 删除四医大校方短信对接日志信息
     *
     * @param id 四医大校方短信对接日志主键
     * @return 结果
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int deleteSydSmsLogById(Long id) {
        return sydSmsLogMapper.deleteSydSmsLogById(id);
    }
}
