package com.schisandra.auth.infra.basic.service.impl;

import com.schisandra.auth.infra.basic.dao.SchisandraSmsConfigDao;
import com.schisandra.auth.infra.basic.entity.SchisandraSmsConfig;
import com.schisandra.auth.infra.basic.entity.table.SchisandraSmsConfigTableDef;
import com.schisandra.auth.infra.basic.service.SchisandraSmsConfigService;
import org.springframework.stereotype.Service;

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

/**
 * (SchisandraSmsConfig)表服务实现类
 *
 * @author makejava
 * @since 2024-05-11 15:48:03
 */
@Service("schisandraSmsConfigService")
public class SchisandraSmsConfigServiceImpl implements SchisandraSmsConfigService {
    @Resource
    private SchisandraSmsConfigDao schisandraSmsConfigDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public SchisandraSmsConfig queryById(Integer id) {
        return this.schisandraSmsConfigDao.selectOneById(id);
    }


    /**
     * 新增数据
     *
     * @param schisandraSmsConfig 实例对象
     * @return 实例对象
     */
    @Override
    public int insert(SchisandraSmsConfig schisandraSmsConfig) {
        return schisandraSmsConfigDao.insert(schisandraSmsConfig,true);

    }

    /**
     * 修改数据
     *
     * @param schisandraSmsConfig 实例对象
     * @return 实例对象
     */
    @Override
    public SchisandraSmsConfig update(SchisandraSmsConfig schisandraSmsConfig) {
        this.schisandraSmsConfigDao.update(schisandraSmsConfig);
        return this.queryById(schisandraSmsConfig.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.schisandraSmsConfigDao.deleteById(id) > 0;
    }

    @Override
    public SchisandraSmsConfig queryByConfigId(String configId) {
        return schisandraSmsConfigDao.selectOneByCondition(SchisandraSmsConfigTableDef.SCHISANDRA_SMS_CONFIG.CONFIG_ID.eq(configId));
    }
}
