| | |
| | | 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.*; |
| | | import com.doumee.dao.business.model.*; |
| | |
| | | import com.doumee.dao.web.dto.shop.ShopSimpleDTO; |
| | | import com.doumee.dao.system.model.SystemUser; |
| | | import com.doumee.dao.web.request.ActivityPageListRequest; |
| | | import com.doumee.dao.web.request.goods.ArticleRequest; |
| | | import com.doumee.service.business.*; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import org.apache.commons.collections4.MapUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.jsoup.Jsoup; |
| | | import org.jsoup.nodes.Document; |
| | | import org.jsoup.nodes.Element; |
| | | import org.jsoup.select.Elements; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.ApplicationEventPublisher; |
| | |
| | | |
| | | @Resource |
| | | private ApplicationEventPublisher applicationEventPublisher; |
| | | @Autowired |
| | | private ZanMapper zanMapper; |
| | | @Autowired |
| | | private CollectMapper collectMapper; |
| | | |
| | | |
| | | @Override |
| | |
| | | @Override |
| | | public void deleteById(Integer id) { |
| | | Activity activity = new Activity(); |
| | | activity.setIsdeleted(Constants.ZERO); |
| | | activity.setIsdeleted(Constants.ONE); |
| | | activity.setId(id); |
| | | activityMapper.updateById(activity); |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public ActivityProbeShopDTO getActivityProbeShopDTO(Integer activityId, Integer memberId) { |
| | | |
| | |
| | | }*/ |
| | | |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public PageData<Activity> getArticlePage(PageWrap<ArticleRequest> pageWrap) { |
| | | String basePath = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode(); |
| | | String activityPath = basePath + systemDictDataBiz.queryByCode(Constants.OSS, Constants.ACTIVITY_FILE).getCode(); |
| | | ArticleRequest model = pageWrap.getModel(); |
| | | IPage<Activity> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); |
| | | MPJLambdaWrapper<Activity> queryWrapper = new MPJLambdaWrapper<>(); |
| | | queryWrapper.selectAll(Activity.class) |
| | | .selectAs(Labels::getName,Activity::getLablesName) |
| | | .selectAs(Labels::getParam,Activity::getParam) |
| | | .leftJoin(Labels.class,Labels::getId,Activity::getLabelId) |
| | | .eq(Activity::getIsdeleted,Constants.ZERO) |
| | | .eq(Objects.nonNull(model.getLabelId()),Activity::getLabelId,model.getLabelId()) |
| | | .eq(Objects.nonNull(model.getBrandId()),Activity::getBrandId,model.getBrandId()) |
| | | .like(StringUtils.isNotBlank(model.getInfo()),Activity::getContent,model.getInfo()) |
| | | .orderByDesc(Labels::getId) |
| | | ; |
| | | queryWrapper.orderByDesc(Activity::getCreateDate); |
| | | IPage<Activity> activityIPage = activityJoinMapper.selectJoinPage(page, Activity.class, queryWrapper); |
| | | for (Activity activity:activityIPage.getRecords()) { |
| | | if(StringUtils.isNotBlank(activity.getImgurl())){ |
| | | activity.setImgurlfull(activityPath + activity.getImgurl()); |
| | | } |
| | | //富文本内容 读取富文本 |
| | | if(Constants.equalsInteger(activity.getContentType(),Constants.ZERO)){ |
| | | activity.setContentInfo( |
| | | this.getContentInfo(activity.getContent()) |
| | | ); |
| | | } |
| | | } |
| | | return PageData.from(activityIPage); |
| | | } |
| | | |
| | | |
| | | public String getContentInfo(String html){ |
| | | Document doc = Jsoup.parse(html); |
| | | Elements paragraphs = doc.select("p"); // 获取所有<p>标签 |
| | | String content = ""; |
| | | for (Element paragraph : paragraphs) { |
| | | content = content + paragraph.text(); |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public Activity getArticleInfo(Integer id,Integer memberId) { |
| | | Activity activity = activityJoinMapper.selectJoinOne(Activity.class, |
| | | new MPJLambdaWrapper<Activity>().selectAll(Activity.class) |
| | | .selectAs(Labels::getName,Activity::getLablesName) |
| | | .selectAs(Labels::getParam,Activity::getParam) |
| | | .leftJoin(Labels.class,Labels::getId,Activity::getLabelId) |
| | | .eq(Activity::getIsdeleted,Constants.ZERO) |
| | | .eq(Activity::getId,id) |
| | | .orderByDesc(Labels::getId) |
| | | .last(" limit 1 ") |
| | | ); |
| | | if (Objects.isNull(activity)) { |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | if(StringUtils.isNotBlank(activity.getImgurl())){ |
| | | String basePath = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode(); |
| | | String activityPath = basePath + systemDictDataBiz.queryByCode(Constants.OSS, Constants.ACTIVITY_FILE).getCode(); |
| | | activity.setImgurlfull(basePath + activityPath + activity.getImgurl()); |
| | | } |
| | | activityMapper.update(new UpdateWrapper<Activity>().lambda() |
| | | .setSql(" LOOKNUM = ifnull(LOOKNUM,0) + 1 ") |
| | | .eq(Activity::getId,id) |
| | | ); |
| | | if(Objects.nonNull(memberId)){ |
| | | |
| | | activity.setCollectStatus(collectMapper.selectCount(new QueryWrapper<Collect>().lambda() |
| | | .eq(Collect::getMemberId,memberId) |
| | | .eq(Collect::getObjId,id) |
| | | .eq(Collect::getObjType,Constants.ZERO) |
| | | )>Constants.ZERO?Constants.ONE:Constants.ZERO); |
| | | |
| | | activity.setZanStatus(zanMapper.selectCount(new QueryWrapper<Zan>().lambda() |
| | | .eq(Zan::getMemberId,memberId) |
| | | .eq(Zan::getObjId,id) |
| | | .eq(Zan::getObjType,Constants.ZERO) |
| | | )>Constants.ZERO?Constants.ONE:Constants.ZERO); |
| | | |
| | | } |
| | | return activity; |
| | | } |
| | | |
| | | |
| | | |
| | | } |