package com.fjs.scenic.service.system.impl;

import com.fjs.scenic.entity.system.RolePermission;
import com.fjs.scenic.mapper.system.RolePermissionMapper;
import com.fjs.scenic.service.common.impl.BaseServiceImpl;
import com.fjs.scenic.service.system.RolePermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RolePermissionServiceImpl extends BaseServiceImpl<RolePermission> implements RolePermissionService {

    @Autowired
    private RolePermissionMapper rolePermissionMapper;

    @Override
    public int adds(List<RolePermission> rolePermissionList) {
        return rolePermissionMapper.adds(rolePermissionList);
    }

    @Override
    public List<RolePermission> selectByRoleId(Integer id) {
        return rolePermissionMapper.selectByRoleId(id);
    }

    @Override
    public int updates(List<RolePermission> rolePermissionList) {
        rolePermissionMapper.delByRoleId(rolePermissionList.get(0).getRoleId());
        return rolePermissionMapper.adds(rolePermissionList);
    }

    @Override
    public int delByRoleId(int id) {
        return rolePermissionMapper.delByRoleId(id);
    }
}
