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


import com.schisandra.auth.infra.basic.dao.SchisandraAuthSocialUserMapperDao;
import com.schisandra.auth.infra.basic.entity.SchisandraAuthSocialUserMapper;
import com.schisandra.auth.infra.basic.entity.table.SchisandraAuthSocialUserMapperTableDef;
import com.schisandra.auth.infra.basic.service.SchisandraAuthSocialUserMapperService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 表服务实现类
 *
 * @author landaiqing
 * @since 2024-05-23 20:13:10
 */
@Service("SchisandraAuthSocialUserMapperService")
public class SchisandraAuthSocialUserMapperServiceImpl implements SchisandraAuthSocialUserMapperService {

    @Resource
    private SchisandraAuthSocialUserMapperDao schisandraAuthSocialUserMapperDao;

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

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

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

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

    /**
     * 条件查询
     *
     * @param schisandraAuthSocialUserMapper 条件
     * @return 实例对象
     */
    @Override
    public SchisandraAuthSocialUserMapper queryBySocialUserId(SchisandraAuthSocialUserMapper schisandraAuthSocialUserMapper) {

        return schisandraAuthSocialUserMapperDao.selectOneByCondition(SchisandraAuthSocialUserMapperTableDef.SCHISANDRA_AUTH_SOCIAL_USER_MAPPER.SOCIAL_USER_ID.eq(schisandraAuthSocialUserMapper.getSocialUserId()));

    }

    @Override
    public int insertAuthSocialUserMapperByOauth(SchisandraAuthSocialUserMapper schisandraAuthSocialUserMapper) {
        return schisandraAuthSocialUserMapperDao.insert(schisandraAuthSocialUserMapper, true);
    }

}
