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


import com.schisandra.oss.infra.basic.dao.SchisandraOssMinioDao;
import com.schisandra.oss.infra.basic.entity.SchisandraOssMinio;
import com.schisandra.oss.infra.basic.entity.table.SchisandraOssMinioTableDef;
import com.schisandra.oss.infra.basic.service.SchisandraOssMinioService;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.stereotype.Service;

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

/**
 * 表服务实现类
 *
 * @author landaiqing
 * @since 2024-05-14 19:47:04
 */
@Service("SchisandraOssMinioService")
@EnableAspectJAutoProxy(proxyTargetClass = true)
public class SchisandraOssMinioServiceImpl implements SchisandraOssMinioService {


    @Resource
    private SchisandraOssMinioDao schisandraOssMinioDao;

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

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

    /**
     * 修改数据
     *
     * @param schisandraOssMinio 实例对象
     * @return 实例对象
     */
    @Override
    public int update(SchisandraOssMinio schisandraOssMinio) {

        return this.schisandraOssMinioDao.update(schisandraOssMinio, true);

    }

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


    @Override
    public SchisandraOssMinio getMinioConfig(Long userId) {
        return schisandraOssMinioDao.selectOneByCondition(SchisandraOssMinioTableDef.SCHISANDRA_OSS_MINIO.USER_ID.eq(userId));
    }

    @Override
    public List<SchisandraOssMinio> getAllMinioInfo() {
        return schisandraOssMinioDao.selectAll();
    }

}
