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

import com.schisandra.auth.infra.basic.dao.SchisandraAuthRoleDao;
import com.schisandra.auth.infra.basic.entity.SchisandraAuthRole;
import com.schisandra.auth.infra.basic.entity.table.SchisandraAuthRoleTableDef;
import com.schisandra.auth.infra.basic.service.SchisandraAuthRoleService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * (SchisandraAuthRole)表服务实现类
 *
 * @author makejava
 * @since 2024-03-22 21:35:31
 */


@Service("schisandraAuthRoleService")
public class SchisandraAuthRoleServiceImpl implements SchisandraAuthRoleService {
    @Resource
    private SchisandraAuthRoleDao schisandraAuthRoleDao;

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


    /**
     * 新增数据
     *
     * @param schisandraAuthRole 实例对象
     * @return int
     */
    @Override
    public int insert(SchisandraAuthRole schisandraAuthRole) {
        return this.schisandraAuthRoleDao.insert(schisandraAuthRole);

    }

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

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

    @Override
    public SchisandraAuthRole queryByRoleId(Long code) {
        return schisandraAuthRoleDao.selectOneByCondition(SchisandraAuthRoleTableDef.SCHISANDRA_AUTH_ROLE.ID.eq(code));
    }
}
