package com.zcxk.service;


import com.zcxk.dao.UserRoleMapper;
import com.zcxk.entity.UserRoleEntity;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import javax.annotation.Resource;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Arrays;
/**
 *
 * 用户角色Service接口
 * @author: WYY
 * @date 2020-10-24 18:26
 */
@Service
public class UserRoleService extends ServiceImpl<UserRoleMapper,UserRoleEntity> {

	@Resource
	private UserRoleMapper userRoleMapper;

	/**
	 * 查列表
	 */
	public List<UserRoleEntity> findList(UserRoleEntity userRoleEntity) {
		return userRoleMapper.findList(userRoleEntity);
	}

	/**
	 * 批量删除
	 */
	@Transactional(rollbackFor = Exception.class)
	public boolean delUserRoleByIds(Long[] ids) {
		return this.removeByIds(Arrays.asList(ids));

	}

	/**
	 * 单个删除
	 */
	public boolean delUserRoleById(Long id) {
		return this.removeById(id);
	}

	/**
	 * 保存
	 */
	public boolean addUserRole(UserRoleEntity userRole) {
		if (this.save(userRole)) {
			return true;
		}
		return false;
	}

	/**
	 * 修改根居ID
	 */
	public boolean updateUserRoleById(UserRoleEntity userRole) {
		if (this.updateById(userRole)) {
			return true;
		}
		return false;
	}

	/**
	 * 根居ID获取对象
	 */
	public UserRoleEntity findUserRoleById(Long id) {
		return userRoleMapper.findUserRoleById(id);
	}
}
