| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import com.dingtalk.api.request.OapiMaterialNewsListRequest; |
| | | import com.doumee.biz.system.SystemDictDataBiz; |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.model.LoginUserInfo; |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.core.utils.DateUtil; |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.dao.business.ActionsMapper; |
| | | import com.doumee.dao.business.MultifileMapper; |
| | | import com.doumee.dao.business.NewsMapper; |
| | | import com.doumee.dao.business.model.Actions; |
| | | import com.doumee.dao.business.model.BjParam; |
| | | import com.doumee.dao.business.model.Multifile; |
| | | import com.doumee.dao.business.model.News; |
| | | import com.doumee.dao.system.model.SystemUser; |
| | | import com.doumee.dao.web.response.DailyUpdatesResponse; |
| | | import com.doumee.service.business.NewsService; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import javax.swing.*; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 资讯和定制服务信息表Service实现 |
| | |
| | | private MultifileMapper multifileMapper; |
| | | @Autowired |
| | | private SystemDictDataBiz systemDictDataBiz; |
| | | @Autowired |
| | | private ActionsMapper actionsMapper; |
| | | |
| | | @Override |
| | | @Transactional |
| | |
| | | param.setCreateDate(new Date()); |
| | | param.setEditDate(param.getCreateDate()); |
| | | param.setPublishUserid(param.getCreator()); |
| | | param.setLookNum(Constants.ZERO); |
| | | param.setDonwloadNum(Constants.ZERO); |
| | | param.setFileType(Constants.formatIntegerNum(param.getFileType())); |
| | | newsMapper.insert(param); |
| | | if(param.getFileList()!=null && param.getFileList().size()>0){ |
| | |
| | | IPage<News> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); |
| | | MPJLambdaWrapper<News> queryWrapper = new MPJLambdaWrapper<>(); |
| | | Utils.MP.blankToNull(pageWrap.getModel()); |
| | | if(Objects.isNull(pageWrap.getModel())){ |
| | | News news = new News(); |
| | | pageWrap.setModel(news); |
| | | } |
| | | pageWrap.getModel().setIsdeleted(Constants.ZERO); |
| | | queryWrapper.leftJoin(SystemUser.class,SystemUser::getId,News::getEditor) |
| | | .selectAll(News.class) |
| | | .selectAs(SystemUser::getRealname,News::getEditorName); |
| | | if (pageWrap.getModel().getId() != null) { |
| | | queryWrapper.eq(News::getId, pageWrap.getModel().getId()); |
| | | } |
| | | if(pageWrap.getModel().getIsPublish()!=null && Constants.equalsInteger(pageWrap.getModel().getIsPublish(),Constants.ONE)){ |
| | | queryWrapper.apply(" now() >= t.PUBLISH_DATE "); |
| | | } |
| | | if (pageWrap.getModel().getCreator() != null) { |
| | | queryWrapper.eq(News::getCreator, pageWrap.getModel().getCreator()); |
| | |
| | | if (pageWrap.getModel().getType() != null) { |
| | | queryWrapper.eq(News::getType, pageWrap.getModel().getType()); |
| | | } |
| | | queryWrapper.orderByDesc(News::getCreateDate); |
| | | |
| | | PageData<News> pageData = PageData.from(newsMapper.selectJoinPage(page, News.class,queryWrapper)); |
| | | if(pageData!=null && pageData.getRecords()!=null && pageData.getRecords().size()>0){ |
| | | |
| | | List<Long> idList = new ArrayList<>(); |
| | | for(News model : pageData.getRecords()){ |
| | | idList.add(model.getId()); |
| | |
| | | for(News model : pageData.getRecords()){ |
| | | setFilelistById(model,files); |
| | | } |
| | | |
| | | } |
| | | return pageData; |
| | | } |
| | |
| | | QueryWrapper<News> wrapper = new QueryWrapper<>(news); |
| | | return newsMapper.selectCount(wrapper); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查询定制服务列表 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<News> getCustomizedNewsList(Integer type,Integer num,Integer fileType){ |
| | | List<News> list = newsMapper.selectList(new QueryWrapper<News>().lambda() |
| | | .eq(News::getIsdeleted,Constants.ZERO) |
| | | .eq(News::getType,type) |
| | | .eq(News::getStatus,Constants.ZERO) |
| | | .eq(Objects.nonNull(fileType),News::getFileType,fileType) |
| | | .last(Objects.nonNull(num),"limit " + num) |
| | | .orderByAsc(News::getSortnum) |
| | | ); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(list)){ |
| | | List<Long> idList = list.stream().map(i->i.getId()).collect(Collectors.toList()); |
| | | List<Multifile> files = dealMultifileList(idList); |
| | | for(News model : list){ |
| | | setFilelistById(model,files); |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public News getCustomizedNewsDetail(Long id){ |
| | | News news = newsMapper.selectById(id); |
| | | if(Objects.isNull(news)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | List<Long> idList = new ArrayList<>(); |
| | | idList.add(id); |
| | | List<Multifile> files = dealMultifileList(idList); |
| | | setFilelistById(news,files); |
| | | //增加浏览量 |
| | | newsMapper.update(new UpdateWrapper<News>().lambda() |
| | | .setSql( " LOOK_NUM = ( LOOK_NUM + 1 ) ").eq(News::getId,id)); |
| | | return news; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 每日上新 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public DailyUpdatesResponse getDailyUpdatesResponse(){ |
| | | DailyUpdatesResponse dailyUpdatesResponse = new DailyUpdatesResponse(); |
| | | dailyUpdatesResponse.setDailyUpdateNum( |
| | | newsMapper.selectCount(new QueryWrapper<News>().lambda() |
| | | .eq(News::getIsdeleted,Constants.ZERO) |
| | | .like(News::getCreateDate, DateUtil.getDateLong(new Date())) |
| | | .apply(" now() >= PUBLISH_DATE ") |
| | | .eq(News::getType,Constants.ZERO) |
| | | )); |
| | | dailyUpdatesResponse.setShareNum( |
| | | actionsMapper.selectCount(new QueryWrapper<Actions>()) |
| | | ); |
| | | List<News> list = newsMapper.selectList(new QueryWrapper<News>().lambda() |
| | | .eq(News::getIsdeleted,Constants.ZERO) |
| | | .eq(News::getType,Constants.ZERO) |
| | | .eq(News::getStatus,Constants.ZERO) |
| | | .eq(News::getFileType,Constants.ZERO) |
| | | .apply(" now() >= PUBLISH_DATE ") |
| | | .last( "limit 3" ) |
| | | .orderByDesc(News::getCreateDate) |
| | | ); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(list)){ |
| | | List<Long> idList = list.stream().map(i->i.getId()).collect(Collectors.toList()); |
| | | List<Multifile> files = dealMultifileList(idList); |
| | | for(News model : list){ |
| | | setFilelistById(model,files); |
| | | } |
| | | } |
| | | dailyUpdatesResponse.setNewsList(list); |
| | | return dailyUpdatesResponse; |
| | | } |
| | | |
| | | @Transactional(rollbackFor = {Exception.class,BusinessException.class}) |
| | | @Override |
| | | public void saveShareRecord(Long id,Long userId){ |
| | | News news = newsMapper.selectById(id); |
| | | if(Objects.isNull(news)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | Actions actions = new Actions(); |
| | | actions.setCreateDate(new Date()); |
| | | actions.setIsDeleted(Constants.ZERO); |
| | | actions.setType(Constants.ZERO); |
| | | actions.setObjId(id); |
| | | actions.setObjType(Constants.ZERO); |
| | | actions.setMemberId(userId); |
| | | actions.setTitle(news.getTitle()); |
| | | actions.setContent(news.getContent()); |
| | | actions.setSubTitle(news.getSubTitle()); |
| | | actionsMapper.insert(actions); |
| | | //增加分享量 |
| | | newsMapper.update(new UpdateWrapper<News>().lambda() |
| | | .setSql( " DONWLOAD_NUM = ( DONWLOAD_NUM + 1 ) ").eq(News::getId,id)); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |