| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import com.doumee.biz.system.SystemDictDataBiz; |
| | | 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.RichTextProcessor; |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.dao.business.ActivityMapper; |
| | | import com.doumee.dao.business.ArticleMapper; |
| | | import com.doumee.dao.business.CollectMapper; |
| | | import com.doumee.dao.business.model.Collect; |
| | | import com.doumee.dao.business.GoodsMapper; |
| | | import com.doumee.dao.business.model.*; |
| | | import com.doumee.dao.web.dto.CollectDTO; |
| | | import com.doumee.dao.web.request.CollectSaveRequest; |
| | | import com.doumee.service.business.CollectService; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | 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.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | @Autowired |
| | | private CollectMapper collectMapper; |
| | | |
| | | @Autowired |
| | | private GoodsMapper goodsMapper; |
| | | |
| | | @Autowired |
| | | private ActivityMapper activityMapper; |
| | | |
| | | @Autowired |
| | | private SystemDictDataBiz systemDictDataBiz; |
| | | @Override |
| | | public Integer create(Collect collect,Integer memberId) { |
| | | |
| | | Collect target = new Collect(); |
| | | target.setCreateDate(new Date()); |
| | | target.setEditDate(new Date()); |
| | |
| | | }).collect(Collectors.toMap(s -> s.getObjId(), s -> s)); |
| | | return collect; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public void saveCollect(CollectSaveRequest request, Integer memberId){ |
| | | if(collectMapper.selectCount(new QueryWrapper<Collect>().lambda() |
| | | .eq(Collect::getMemberId,memberId) |
| | | .eq(Collect::getObjType,request.getType()) |
| | | .eq(Collect::getObjId,request.getObjId()) |
| | | )<= Constants.ZERO){ |
| | | Collect target = new Collect(); |
| | | target.setCreateDate(new Date()); |
| | | target.setEditDate(new Date()); |
| | | target.setMemberId(memberId); |
| | | target.setObjId(request.getObjId()); |
| | | target.setObjType(request.getType()); |
| | | collectMapper.insert(target); |
| | | }; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public List<Collect> myCollect(Integer memberId,Integer type){ |
| | | List<Collect> collectList = new ArrayList<>(); |
| | | if(Constants.equalsInteger(type,Constants.ZERO)){ |
| | | collectList = collectMapper.selectJoinList(Collect.class,new MPJLambdaWrapper<Collect>() |
| | | .selectAll(Collect.class) |
| | | .selectAs(Goods::getName,Collect::getName) |
| | | .selectAs(Goods::getPrice,Collect::getPrice) |
| | | .selectAs(Goods::getImgurl,Collect::getImgurl) |
| | | .select(" ifnull(( select min(gs.PRICE) from goods_sku gs where gs.GOODS_ID = t1.id ),0) ", Collect::getLinePrice) |
| | | .leftJoin(Goods.class,Goods::getId,Collect::getObjId) |
| | | .eq(Collect::getIsdeleted,Constants.ZERO) |
| | | .eq(Collect::getMemberId,memberId) |
| | | .eq(Collect::getObjType,type) |
| | | .orderByDesc(Collect::getId) |
| | | ); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(collectList)){ |
| | | String preFixPath = systemDictDataBiz.getPreFixPath(Constants.RESOURCE_PATH, Constants.GOODS_FILE); |
| | | collectList.forEach(s->s.setImgurl(preFixPath+s.getImgurl())); |
| | | } |
| | | }else{ |
| | | collectList = collectMapper.selectJoinList(Collect.class,new MPJLambdaWrapper<Collect>() |
| | | .selectAll(Collect.class) |
| | | .selectAs(Activity::getName,Collect::getName) |
| | | .selectAs(Activity::getCreateDate,Collect::getReleaseDate) |
| | | .selectAs(Activity::getLooknum,Collect::getReadNum) |
| | | .selectAs(Activity::getImgurl,Collect::getImgurl) |
| | | .selectAs(Labels::getName,Collect::getLabelName) |
| | | .selectAs(Activity::getContent,Collect::getContent) |
| | | .leftJoin(Activity.class,Activity::getId,Collect::getObjId) |
| | | .leftJoin(Labels.class,Labels::getId,Activity::getLabelId) |
| | | .eq(Collect::getIsdeleted,Constants.ZERO) |
| | | .eq(Collect::getMemberId,memberId) |
| | | .eq(Collect::getObjType,type) |
| | | .orderByDesc(Collect::getId) |
| | | ); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(collectList)){ |
| | | String preFixPath = systemDictDataBiz.getPreFixPath(Constants.RESOURCE_PATH, Constants.ACTIVITY_FILE); |
| | | collectList.forEach(s->s.setImgurl(preFixPath+s.getImgurl())); |
| | | collectList.stream().filter(s-> StringUtils.isNotBlank(s.getContent())).forEach(s->s.setContent(RichTextProcessor.extractPlainTextFromHtml(s.getContent()))); |
| | | } |
| | | } |
| | | return collectList; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |