package cn.lili.modules.lmk.service.impl; import cn.lili.common.security.context.UserContext; import cn.lili.modules.lmk.domain.vo.CollectTypeNumVO; import cn.lili.modules.lmk.domain.vo.SimpleMyThumbsUpVO; import com.baomidou.mybatisplus.core.metadata.IPage; import cn.lili.modules.lmk.domain.entity.ThumbsUpRecord; import cn.lili.modules.lmk.mapper .ThumbsUpRecordMapper; import cn.lili.modules.lmk.service.ThumbsUpRecordService; import cn.lili.base.Result; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import cn.lili.modules.lmk.domain.form.ThumbsUpRecordForm; import cn.lili.modules.lmk.domain.vo.ThumbsUpRecordVO; import cn.lili.modules.lmk.domain.query.ThumbsUpRecordQuery; import org.springframework.stereotype.Service; import lombok.RequiredArgsConstructor; import cn.lili.utils.PageUtil; import org.springframework.beans.BeanUtils; import org.springframework.util.Assert; import java.util.List; import java.util.stream.Collectors; /** * 点赞表 服务实现类 * * @author xp * @since 2025-05-29 */ @Service @RequiredArgsConstructor public class ThumbsUpRecordServiceImpl extends ServiceImpl implements ThumbsUpRecordService { private final ThumbsUpRecordMapper thumbsUpRecordMapper; /** * 批量删除 * @param ids * @return */ @Override public Result remove(List ids) { baseMapper.deleteBatchIds(ids); return Result.ok("删除成功"); } /** * id删除 * @param id * @return */ @Override public Result removeById(String id) { baseMapper.deleteById(id); return Result.ok("删除成功"); } /** * 分页查询 * @param query * @return */ @Override public Result page(ThumbsUpRecordQuery query) { IPage page = PageUtil.getPage(query, ThumbsUpRecordVO.class); baseMapper.getPage(page, query); return Result.ok().data(page.getRecords()).total(page.getTotal()); } /** * 根据id查找 * @param id * @return */ @Override public Result detail(String id) { ThumbsUpRecordVO vo = baseMapper.getById(id); Assert.notNull(vo, "记录不存在"); return Result.ok().data(vo); } /** * 列表 * @return */ @Override public Result all() { List entities = baseMapper.selectList(null); List vos = entities.stream() .map(entity -> ThumbsUpRecordVO.getVoByEntity(entity, null)) .collect(Collectors.toList()); return Result.ok().data(vos); } @Override public List countNumGroupByComment() { return baseMapper.countNumGroupByComment(); } @Override public List countNumGroupByVideo() { return baseMapper.countNumGroupByVideo(); } @Override public List getThumbssByVideoIds(List videoIds) { return baseMapper.getThumbssByVideoIds(videoIds, UserContext.getCurrentUserId()); } }