package cn.hnthyy.thmz.service.impl.thmz;

import cn.hnthyy.thmz.entity.thmz.Role;
import cn.hnthyy.thmz.mapper.thmz.RoleMapper;
import cn.hnthyy.thmz.service.thmz.RoleService;
import cn.hnthyy.thmz.vo.RoleVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;

@Service
public class RoleServiceImpl implements RoleService {
    @SuppressWarnings("all")
    @Autowired
    private RoleMapper roleMapper;

    @Override
    public List<RoleVo> queryAllRole() {
        return roleMapper.selectAll();
    }

    @Override
    public Role queryById(Long id) {
        return roleMapper.selectById(id);
    }

    @Override
    public List<Role> queryByIds(List<Long> ids) {
        return roleMapper.selectByIds(ids);
    }

    @Override
    public int saveRole(Role role) {
        role.setUpdateTime(new Date());
        if(role.getId()==null){
            role.setCreateTime(new Date());
            return roleMapper.insertRole(role);
        }
        return roleMapper.updateRole(role);
    }


    @Override
    public int removeById(Long id) {
        return roleMapper.deleteById(id);
    }

    @Override
    public int modifyRole(Role role) {
        return roleMapper.updateRole(role);
    }
}
