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


import com.schisandra.auth.infra.basic.dao.SchisandraAuthRolePermissionDao;
import com.schisandra.auth.infra.basic.entity.SchisandraAuthRolePermission;
import com.schisandra.auth.infra.basic.entity.table.SchisandraAuthRolePermissionTableDef;
import com.schisandra.auth.infra.basic.service.SchisandraAuthRolePermissionService;
import org.springframework.stereotype.Service;

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

/**
 * 表服务实现类
 *
 * @author landaiqing
 * @since 2024-06-02 00:14:38
 */
@Service("SchisandraAuthRolePermissionService")
public class SchisandraAuthRolePermissionServiceImpl implements SchisandraAuthRolePermissionService {

    @Resource
    private SchisandraAuthRolePermissionDao schisandraAuthRolePermissionDao;

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

    /**
     * 新增数据
     *
     * @param schisandraAuthRolePermission 实例对象
     * @return 实例对象
     */
    @Override
    public int insert(SchisandraAuthRolePermission schisandraAuthRolePermission) {
        return this.schisandraAuthRolePermissionDao.insert(schisandraAuthRolePermission, true);
    }

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

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

    @Override
    public List<SchisandraAuthRolePermission> queryByRoleId(SchisandraAuthRolePermission schisandraAuthRolePermission) {
        return schisandraAuthRolePermissionDao.selectListByCondition(SchisandraAuthRolePermissionTableDef.SCHISANDRA_AUTH_ROLE_PERMISSION.ROLE_ID.eq(schisandraAuthRolePermission.getRoleId()));
    }


}
