package club.service.impl;
import club.dao.CommentMapper;
import club.pojo.Answer;
import club.dao.PetMapper;
import club.dao.UserMapper;
import club.pojo.Comment;
import club.pojo.Pet;
import club.pojo.User;
import club.service.AnswerService;
import club.pojo.Pet;
import club.pojo.User;
import club.dao.AdminMapper;
import club.pojo.*;
import club.service.CommentService;
import club.service.PetService;
import club.service.UserService;
import club.service.UserService;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Service
@Transactional
public class CommentServiceImpl implements CommentService {
@Resource
private CommentMapper commentMapper;
@Resource
private UserMapper userMapper;
@Resource
private PetMapper petMapper;
@Resource
private AdminMapper adminMapper;
@Resource
private UserService userService;
@Resource
private PetService petService;
@Resource
private AnswerService answerService;
@Override
public PageInfo<Comment> allComment(String userName, Integer pn, Integer pageSize) {
List<User> users = userService.showName(userName);
List<Integer> userIds = new ArrayList<>();
for (User user : users){
userIds.add(user.getId());
}
PageHelper.startPage(pn,pageSize);
EntityWrapper wrapper = new EntityWrapper();
if (users != null){
wrapper.in("userId", userIds);
}
List<Comment> list = commentMapper.selectList(wrapper);
for (Comment comment: list) {
User u = userMapper.selectById(comment.getUserId());
comment.setUser(u);
Pet pet = petMapper.selectById(comment.getPetId());
comment.setPet(pet);
}
PageInfo<Comment> pageInfo = new PageInfo<>(list);
return pageInfo;
}
@Override
public List<Comment> petComments(Integer petId) {
EntityWrapper wrapper = new EntityWrapper();
if (petId != null) {
wrapper.eq("petId", petId);
}
List<Comment> comments = commentMapper.selectList(wrapper);
for (Comment comment : comments){
User user = userService.findById(comment.getUserId());
comment.setUser(user);
Pet pet = petService.findById(comment.getPetId());
comment.setPet(pet);
List<Answer> answers = answerService.answersAboutOneComment(comment.getId());
comment.setAnswer(answers);
}
return comments;
}
@Override
public Integer create(Integer userId, Integer petId, String content) {
Comment comment = new Comment();
comment.setUserId(userId);
comment.setPetId(petId);
comment.setCommentTime(new Date());
comment.setContent(content);
return commentMapper.insert(comment);
}
@Override
public Comment findById(Integer id) {
return commentMapper.selectById(id);
}
@Override
public PageInfo<Comment> all(String userName, Integer pageNum, Integer pageSize) {
PageHelper.startPage(pageNum,pageSize);
EntityWrapper<Comment> wrapper = new EntityWrapper<>();
if(userName!=null&&!"".equals(userName)){
wrapper.like("userName",userName);
}
List<Comment> list = commentMapper.selectList(wrapper);
for(Comment a : list){
Pet pet = petMapper.selectById(a.getPetId());
a.setPet(pet);
User user = userMapper.selectById(a.getUserId());
a.setUser(user);
Admins admins = adminMapper.selectById(a.getAdminsId());
a.setAdmin(admins);
}
PageInfo<Comment> pageInfo = new PageInfo<>(list);
return pageInfo;
}
@Override
public int update(Comment adoptAnimal) {
return commentMapper.updateById(adoptAnimal);
}
@Override
public int delete(Integer id) {
return commentMapper.deleteById(id);
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
毕设 这是一个关于java和spring的项目,是宠物收养网站.zip
共747个文件
jpg:228个
class:84个
png:74个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 68 浏览量
2023-10-24
10:54:58
上传
评论
收藏 37.44MB ZIP 举报
温馨提示
matlab算法,毕设、课设程序,全部源码均已进行严格测试,可以直接运行! matlab算法,毕设、课设程序,全部源码均已进行严格测试,可以直接运行! matlab算法,毕设、课设程序,全部源码均已进行严格测试,可以直接运行! matlab算法,毕设、课设程序,全部源码均已进行严格测试,可以直接运行! matlab算法,毕设、课设程序,全部源码均已进行严格测试,可以直接运行! matlab算法,毕设、课设程序,全部源码均已进行严格测试,可以直接运行! matlab算法,毕设、课设程序,全部源码均已进行严格测试,可以直接运行! matlab算法,毕设、课设程序,全部源码均已进行严格测试,可以直接运行! matlab算法,毕设、课设程序,全部源码均已进行严格测试,可以直接运行! matlab算法,毕设、课设程序,全部源码均已进行严格测试,可以直接运行! matlab算法,毕设、课设程序,全部源码均已进行严格测试,可以直接运行! matlab算法,毕设、课设程序,全部源码均已进行严格测试,可以直接运行! matlab算法,毕设、课设程序,全部源码均已进行严格测试,可以直接运行! matlab算法,毕设、课设程序,全部源码均已进行严格测试,可以直接运行!
资源推荐
资源详情
资源评论
收起资源包目录
毕设 这是一个关于java和spring的项目,是宠物收养网站.zip (747个子文件)
User.class 7KB
User.class 7KB
Pet.class 6KB
Pet.class 6KB
CommentServiceImpl.class 6KB
CommentServiceImpl.class 6KB
Comment.class 6KB
Comment.class 6KB
Admins.class 5KB
Admins.class 5KB
Answer.class 5KB
Answer.class 5KB
AdminController.class 5KB
AdminController.class 5KB
UserController.class 5KB
AdoptAnimalServiceImpl.class 5KB
AdoptAnimalServiceImpl.class 5KB
UserController.class 5KB
Apply.class 5KB
Apply.class 5KB
AdoptAnimal.class 4KB
AdoptAnimal.class 4KB
CommentController.class 4KB
CommentController.class 4KB
UserServiceImpl.class 4KB
UserServiceImpl.class 4KB
Blog.class 4KB
Blog.class 4KB
AdoptAnimalController.class 4KB
AdoptAnimalController.class 4KB
AnswerServiceImpl.class 3KB
AnswerServiceImpl.class 3KB
PetController.class 3KB
PetController.class 3KB
AdminServiceImpl.class 3KB
AdminServiceImpl.class 3KB
PetServiceImpl.class 3KB
PetServiceImpl.class 3KB
BlogServiceImpl.class 3KB
BlogServiceImpl.class 3KB
ApplyController.class 3KB
ApplyController.class 3KB
BlogController.class 3KB
BlogController.class 3KB
ApplyServiceImpl.class 3KB
ApplyServiceImpl.class 3KB
AnswerController.class 2KB
AnswerController.class 2KB
FileLoad.class 2KB
FileLoad.class 2KB
Message.class 2KB
Message.class 2KB
UserService.class 912B
UserService.class 912B
AdoptAnimalService.class 782B
AdoptAnimalService.class 782B
CommentService.class 766B
CommentService.class 766B
AdminService.class 755B
AdminService.class 755B
PetService.class 749B
PetService.class 749B
BlogService.class 709B
BlogService.class 709B
ApplyService.class 566B
ApplyService.class 566B
AnswerService.class 548B
AnswerService.class 548B
AdoptAnimalMapper.class 524B
AdoptAnimalMapper.class 524B
CommentMapper.class 272B
CommentMapper.class 272B
AnswerMapper.class 269B
AnswerMapper.class 269B
AdminMapper.class 267B
AdminMapper.class 267B
ApplyMapper.class 266B
ApplyMapper.class 266B
UserMapper.class 263B
BlogMapper.class 263B
BlogMapper.class 263B
UserMapper.class 263B
PetMapper.class 260B
PetMapper.class 260B
bootstrap.css 143KB
bootstrap.css 143KB
bootstrap.css 124KB
bootstrap.css 124KB
bootstrap.min.css 118KB
bootstrap.min.css 118KB
bootstrap.min.css 118KB
bootstrap.min.css 118KB
base.css 110KB
base.css 110KB
style.css 43KB
style.css 43KB
font-awesome.css 34KB
font-awesome.css 34KB
bootstrap-theme.css 26KB
bootstrap-theme.css 26KB
共 747 条
- 1
- 2
- 3
- 4
- 5
- 6
- 8
资源评论
天天501
- 粉丝: 606
- 资源: 4665
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Servlet和JDBC实现三层架构
- Appium-Inspector-2024.6.1-win
- Screenshot_2024-06-14-21-22-39-202_net.csdn.csdnplus.jpg
- Appium-Server-GUI-windows-1.22.3-4
- 基于C语言+python实现的永磁同步电机矢量控制算法仿真+源码(毕业设计&课程设计&项目开发)
- APKPure_v3.20.05_apkpure.com.apk
- HKJC_AOSBS_PROD_L2.7R2Q_Build8172.apk
- jetson官网下载的官方资料
- 小游戏的java程序开发
- matlab GUI仿真资源.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功