package org.springblade.modules.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.modules.system.entity.Menu;
import org.springblade.modules.system.entity.UserClickMenuRecord;
import org.springblade.modules.system.mapper.UserClickMenuRecordMapper;
import org.springblade.modules.system.service.IUserClickMenuRecordService;
import org.springblade.modules.system.vo.UserClickMenuRecordVo;
import org.springframework.stereotype.Service;

import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

@Service
public class UserClickMenuRecordServiceImpl extends ServiceImpl<UserClickMenuRecordMapper, UserClickMenuRecord> implements IUserClickMenuRecordService {


    @Override
    public List<UserClickMenuRecordVo> getTopMenu(Long userId,Integer strips) {
        List<UserClickMenuRecordVo> userClickMenuRecordVos = baseMapper.selectTopMenu(userId, strips);
        return userClickMenuRecordVos.stream().sorted(Comparator.comparing(UserClickMenuRecordVo::getClickNum).reversed())
                .collect(Collectors.toList());
    }
}
