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

import com.schisandra.oss.infra.basic.dao.SchisandraOssAliDao;
import com.schisandra.oss.infra.basic.entity.SchisandraOssAli;
import com.schisandra.oss.infra.basic.entity.table.SchisandraOssAliTableDef;
import com.schisandra.oss.infra.basic.service.SchisandraOssAliService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 表服务实现类
 *
 * @author landaiqing
 * @since 2024-05-14 20:45:32
 */
@Service("SchisandraOssAliService")
public class SchisandraOssAliServiceImpl implements SchisandraOssAliService {

    @Resource
    private SchisandraOssAliDao schisandraOssAliDao;

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

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

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

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


    @Override
    public SchisandraOssAli getAliOssConfig(Long userId) {
        return schisandraOssAliDao.selectOneByCondition(SchisandraOssAliTableDef.SCHISANDRA_OSS_ALI.USER_ID.eq(userId));
    }

}
