| | |
| | | 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.common.utlis.RichTextUtil; |
| | | 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.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; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @program: springcloud_k8s_panzhihuazhihuishequ |
| | |
| | | * @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 |
| | |
| | | page.setSize(pageSize); |
| | | page.setCurrent(pageNum); |
| | | IPage<ComActDynVO> iPage = comActDynDAO.pageDynamic(page, comActDynVO); |
| | | List<ComActDynVO> records = iPage.getRecords(); |
| | | if (!ObjectUtils.isEmpty(records)) { |
| | | records.forEach(comActDynVO1 -> { |
| | | String content = comActDynVO1.getContent(); |
| | | if (!ObjectUtils.isEmpty(content)) { |
| | | String text = RichTextUtil.getText(content); |
| | | comActDynVO1.setContentText(text); |
| | | } |
| | | }); |
| | | } |
| | | return R.ok(iPage); |
| | | } |
| | | |
| | |
| | | */ |
| | | @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{ |
| | | 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(); |
| | | } |
| | | |
| | | /** |
| | | * 定时任务刷新社区动态置顶状态 |
| | | * |
| | | * @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); |
| | | } |
| | | |
| | | /** |
| | | * 管理后台分页查询社区动态 |
| | | * @param comActDynVO 查询参数 |
| | | * @return 动态集合 |
| | | */ |
| | | @Override |
| | | public R pageDynamicByAdmin(ComActDynVO comActDynVO) { |
| | | Page page = new Page<>(); |
| | | Long pageNum = comActDynVO.getPageNum(); |
| | | Long pageSize = comActDynVO.getPageSize(); |
| | | if (null==pageNum||0==pageNum) { |
| | | pageNum = 1l; |
| | | } |
| | | if (null==pageSize||0==pageSize) { |
| | | pageSize = 10l; |
| | | } |
| | | page.setSize(pageSize); |
| | | page.setCurrent(pageNum); |
| | | IPage<ComActDynVO> iPage = comActDynDAO.pageDynamicByAdmin(page, comActDynVO); |
| | | List<ComActDynVO> records = iPage.getRecords(); |
| | | if (!ObjectUtils.isEmpty(records)) { |
| | | records.forEach(comActDynVO1 -> { |
| | | String content = comActDynVO1.getContent(); |
| | | if (!ObjectUtils.isEmpty(content)) { |
| | | String text = RichTextUtil.getText(content); |
| | | comActDynVO1.setContentText(text); |
| | | } |
| | | }); |
| | | } |
| | | return R.ok(iPage); |
| | | } |
| | | |
| | | |
| | | } |