From ada9d2e3f734582a0d9ae8c00a936d8c8ed669d7 Mon Sep 17 00:00:00 2001 From: huanghongfa <18228131219@163.com> Date: 星期五, 15 一月 2021 13:51:44 +0800 Subject: [PATCH] 微心愿详情bug --- springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActDynServiceImpl.java | 67 ++++++++++++++++++++++++++++++++- 1 files changed, 65 insertions(+), 2 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActDynServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActDynServiceImpl.java index f5ac4d7..6539c80 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActDynServiceImpl.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActDynServiceImpl.java @@ -7,16 +7,20 @@ import com.panzhihua.common.model.vos.R; import com.panzhihua.common.model.vos.community.ComActActivityVO; import com.panzhihua.common.model.vos.community.ComActDynVO; +import com.panzhihua.service_community.dao.ComActDAO; import com.panzhihua.service_community.dao.ComActDynDAO; import com.panzhihua.service_community.dao.ComActDynUserDAO; +import com.panzhihua.service_community.model.dos.ComActDO; import com.panzhihua.service_community.model.dos.ComActDynDO; import com.panzhihua.service_community.model.dos.ComActDynUserDO; import com.panzhihua.service_community.service.ComActDynService; +import lombok.extern.slf4j.Slf4j; 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 @@ -24,12 +28,17 @@ * @author: huang.hongfa weixin hhf9596 qq 959656820 * @create: 2020-12-07 14:29 **/ +@Slf4j @Service public class ComActDynServiceImpl extends ServiceImpl<ComActDynDAO, ComActDynDO> implements ComActDynService { @Resource private ComActDynDAO comActDynDAO; @Resource private ComActDynUserDAO comActDynUserDAO; + @Resource + private ComActDAO comActDAO; + + /** * 分页查询社区动态 * @@ -41,10 +50,10 @@ Page page = new Page<>(); Long pageNum = comActDynVO.getPageNum(); Long pageSize = comActDynVO.getPageSize(); - if (ObjectUtils.isEmpty(pageNum)||0==pageNum) { + if (null==pageNum||0==pageNum) { pageNum = 1l; } - if (ObjectUtils.isEmpty(pageSize)||0==pageSize) { + if (null==pageSize||0==pageSize) { pageSize = 10l; } page.setSize(pageSize); @@ -65,10 +74,64 @@ if (ObjectUtils.isEmpty(comActDynDO)) { return R.fail("社区动态不存在"); } + ComActDO comActDO = comActDAO.selectById(comActDynDO.getCommunityId()); Integer count = comActDynUserDAO.selectCount(new QueryWrapper<ComActDynUserDO>().lambda().eq(ComActDynUserDO::getDynId, id)); ComActDynVO comActDynVO=new ComActDynVO(); BeanUtils.copyProperties(comActDynDO,comActDynVO); comActDynVO.setReadNum(count); + comActDynVO.setCommunityName(comActDO.getName()); 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(); + } + + } + + /** + * 定时任务刷新社区动态置顶状态 + * + * @return 刷新结果 + */ + @Override + public R timedTaskDynIstopping() { + int num=comActDynUserDAO.timedTaskDynIstopping(); + log.info("定时任务--一共维护社区动态数量【{}】",num); + return R.ok(num); + } + + /** + * 定时任务刷新社区动态发布状态 + * + * @return 刷新结果 + */ + @Override + public R timedTaskDynStatus() { + int num=comActDynDAO.timedTaskDynStatus(); + log.info("定时任务--一共刷新社区动态发布状态数量【{}】",num); + return R.ok(num); + } + + } -- Gitblit v1.7.1