feat:增加美食朋友圈功能

This commit is contained in:
2025-06-25 16:27:02 +08:00
parent 78d24cf559
commit 5a29a2146e
36 changed files with 570 additions and 218 deletions

View File

@@ -0,0 +1,53 @@
package com.cxx.food.service.impl;
import com.cxx.food.dao.MomentDao;
import com.cxx.food.dto.CommentDto;
import com.cxx.food.dto.MomentDto;
import com.cxx.food.entity.Comment;
import com.cxx.food.entity.Moment;
import com.cxx.food.mapper.CommentMapper;
import com.cxx.food.mapper.MomentMapper;
import com.cxx.food.service.MomentService;
import com.cxx.framework.web.CustomException;
import jakarta.annotation.Resource;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class MomentServiceImpl implements MomentService {
@Resource
private MomentDao momentDao;
@Resource
private MomentMapper momentMapper;
@Resource
private CommentMapper commentMapper;
@Override
public Boolean addMoment(MomentDto momentDto) {
Moment moment = new Moment();
BeanUtils.copyProperties(momentDto, moment);
return momentMapper.insert(moment) == 1;
}
@Override
public List<MomentDto> queryMoment() {
// TODO 只能查询好友的朋友圈
return momentDao.queryMoment();
}
@Override
public Boolean addComment(Long momentId, CommentDto commentDto) {
if (momentMapper.selectById(momentId) == null) {
throw new CustomException("该朋友圈不存在");
}
Comment comment = new Comment();
BeanUtils.copyProperties(commentDto, comment);
comment.setMomentId(momentId);
return commentMapper.insert(comment) == 1;
}
}