| | |
| | | package com.panzhihua.service_community.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | |
| | | import com.panzhihua.common.model.vos.community.ComActActivityVO; |
| | | import com.panzhihua.common.model.vos.community.ComActDynVO; |
| | | import com.panzhihua.service_community.dao.ComActDynDAO; |
| | | import com.panzhihua.service_community.dao.ComActDynUserDAO; |
| | | import com.panzhihua.service_community.model.dos.ComActDynDO; |
| | | import com.panzhihua.service_community.model.dos.ComActDynUserDO; |
| | | import com.panzhihua.service_community.service.ComActDynService; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @program: springcloud_k8s_panzhihuazhihuishequ |
| | |
| | | public class ComActDynServiceImpl extends ServiceImpl<ComActDynDAO, ComActDynDO> implements ComActDynService { |
| | | @Resource |
| | | private ComActDynDAO comActDynDAO; |
| | | @Resource |
| | | private ComActDynUserDAO comActDynUserDAO; |
| | | /** |
| | | * 分页查询社区动态 |
| | | * |
| | |
| | | * @return 详情 |
| | | */ |
| | | @Override |
| | | public R detailDynamic(String id) { |
| | | public R detailDynamic(Long id) { |
| | | ComActDynDO comActDynDO = this.getById(id); |
| | | if (ObjectUtils.isEmpty(comActDynDO)) { |
| | | return R.fail("社区动态不存在"); |
| | | } |
| | | Integer count = comActDynUserDAO.selectCount(new QueryWrapper<ComActDynUserDO>().lambda().eq(ComActDynUserDO::getDynId, id)); |
| | | ComActDynVO comActDynVO=new ComActDynVO(); |
| | | BeanUtils.copyProperties(comActDynDO,comActDynVO); |
| | | comActDynVO.setReadNum(count); |
| | | return R.ok(comActDynVO); |
| | | } |
| | | |
| | | /** |
| | | * 新增社区动态浏览记录 |
| | | * |
| | | * @param id 动态主键 |
| | | * @param userId 登录用户id |
| | | * @return 新增结果 |
| | | */ |
| | | @Override |
| | | public R addDynamicUser(Long id, Long userId) { |
| | | ComActDynUserDO comActDynUserDO = comActDynUserDAO.selectOne(new QueryWrapper<ComActDynUserDO>().lambda().eq(ComActDynUserDO::getDynId, id).eq(ComActDynUserDO::getUserId, userId)); |
| | | if (ObjectUtils.isEmpty(comActDynUserDO)) { |
| | | comActDynUserDO=new ComActDynUserDO(); |
| | | comActDynUserDO.setCreateAt(new Date()); |
| | | comActDynUserDO.setDynId(id); |
| | | comActDynUserDO.setUserId(userId); |
| | | int insert = comActDynUserDAO.insert(comActDynUserDO); |
| | | if (insert>0) { |
| | | return R.ok(); |
| | | } |
| | | return R.fail(); |
| | | }else{ |
| | | return R.ok(); |
| | | } |
| | | |
| | | } |
| | | } |