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

import com.schisandra.system.infra.basic.dao.SchisandraSysOauthDao;
import com.schisandra.system.infra.basic.entity.SchisandraSysOauth;
import com.schisandra.system.infra.basic.entity.table.SchisandraSysOauthTableDef;
import com.schisandra.system.infra.basic.service.SchisandraSysOauthService;
import org.springframework.stereotype.Service;

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

/**
 *  表服务实现类
 *
 * @author landaiqing
 * @since 2024-05-25 23:08:26
 */
@Service("SchisandraSysOauthService")
public class SchisandraSysOauthServiceImpl implements SchisandraSysOauthService {

    @Resource
    private SchisandraSysOauthDao schisandraSysOauthDao;

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

    /**
     * 新增数据
     *
     * @param schisandraSysOauth 实例对象
     * @return 实例对象
     */
    @Override
    public int insert(SchisandraSysOauth schisandraSysOauth) {
        return this.schisandraSysOauthDao.insert(schisandraSysOauth);
    }

    /**
     * 修改数据
     *
     * @param schisandraSysOauth 实例对象
     * @return 实例对象
     */
    @Override
    public int update(SchisandraSysOauth schisandraSysOauth) {
        return this.schisandraSysOauthDao.update(schisandraSysOauth,true);
    }

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

    /**
     * 通过主键删除数据
     *
     * @param type 客户端类型
     * @return 实体
     */
    @Override
    public SchisandraSysOauth getOauthConfigByType(String type) {
        return schisandraSysOauthDao.selectOneByCondition(SchisandraSysOauthTableDef.SCHISANDRA_SYS_OAUTH.CLIENT_TYPE.eq(type));
    }

}
