|
@@ -1,18 +1,24 @@
|
|
package com.caimei365.user.service.impl;
|
|
package com.caimei365.user.service.impl;
|
|
|
|
|
|
-import com.caimei365.user.components.RedisService;
|
|
|
|
|
|
+import com.caimei365.user.feign.CommodityFeign;
|
|
|
|
+import com.caimei365.user.mapper.ArticleMapper;
|
|
import com.caimei365.user.mapper.BaseMapper;
|
|
import com.caimei365.user.mapper.BaseMapper;
|
|
import com.caimei365.user.mapper.PersonalCenterMapper;
|
|
import com.caimei365.user.mapper.PersonalCenterMapper;
|
|
import com.caimei365.user.mapper.ShopMapper;
|
|
import com.caimei365.user.mapper.ShopMapper;
|
|
import com.caimei365.user.model.ResponseJson;
|
|
import com.caimei365.user.model.ResponseJson;
|
|
|
|
+import com.caimei365.user.model.dto.ShopArticleDto;
|
|
import com.caimei365.user.model.dto.ShopBannerDto;
|
|
import com.caimei365.user.model.dto.ShopBannerDto;
|
|
import com.caimei365.user.model.dto.ShopUpdateDto;
|
|
import com.caimei365.user.model.dto.ShopUpdateDto;
|
|
|
|
+import com.caimei365.user.model.po.ArticlePo;
|
|
import com.caimei365.user.model.po.ShopCertPo;
|
|
import com.caimei365.user.model.po.ShopCertPo;
|
|
import com.caimei365.user.model.po.UserPo;
|
|
import com.caimei365.user.model.po.UserPo;
|
|
import com.caimei365.user.model.vo.*;
|
|
import com.caimei365.user.model.vo.*;
|
|
import com.caimei365.user.service.ShopService;
|
|
import com.caimei365.user.service.ShopService;
|
|
import com.caimei365.user.utils.DateUtil;
|
|
import com.caimei365.user.utils.DateUtil;
|
|
|
|
+import com.caimei365.user.utils.GenerateUtils;
|
|
import com.caimei365.user.utils.ImageUtils;
|
|
import com.caimei365.user.utils.ImageUtils;
|
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
@@ -34,12 +40,14 @@ public class ShopServiceImpl implements ShopService {
|
|
@Value("${caimei.wwwDomain}")
|
|
@Value("${caimei.wwwDomain}")
|
|
private String wwwDomain;
|
|
private String wwwDomain;
|
|
@Resource
|
|
@Resource
|
|
- private RedisService redisService;
|
|
|
|
|
|
+ private CommodityFeign commodityFeign;
|
|
@Resource
|
|
@Resource
|
|
private BaseMapper baseMapper;
|
|
private BaseMapper baseMapper;
|
|
@Resource
|
|
@Resource
|
|
private ShopMapper shopMapper;
|
|
private ShopMapper shopMapper;
|
|
@Resource
|
|
@Resource
|
|
|
|
+ private ArticleMapper articleMapper;
|
|
|
|
+ @Resource
|
|
private PersonalCenterMapper personalCenterMapper;
|
|
private PersonalCenterMapper personalCenterMapper;
|
|
|
|
|
|
|
|
|
|
@@ -400,4 +408,103 @@ public class ShopServiceImpl implements ShopService {
|
|
return ResponseJson.success(result);
|
|
return ResponseJson.success(result);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public ResponseJson<Map<String, Object>> getShopArticleById(Integer articleId) {
|
|
|
|
+ Map<String, Object> map = new HashMap<>(2);
|
|
|
|
+ // 供应商文章
|
|
|
|
+ ShopArticleVo shopArticle = articleMapper.getShopArticleById(articleId);
|
|
|
|
+ // 文章分类列表
|
|
|
|
+ List<ArticleTypeVo> articleTypeList = articleMapper.getArticleTypeList();
|
|
|
|
+ map.put("shopArticle", shopArticle);
|
|
|
|
+ map.put("articleTypeList", articleTypeList);
|
|
|
|
+ return ResponseJson.success(map);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public ResponseJson<Void> saveShopArticle(ShopArticleDto shopArticleDto) {
|
|
|
|
+ // 参数校验
|
|
|
|
+ if (StringUtils.isEmpty(shopArticleDto.getTitle())) {
|
|
|
|
+ return ResponseJson.error("参数异常,文章标题不能为空", null);
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isEmpty(shopArticleDto.getLabel())) {
|
|
|
|
+ return ResponseJson.error("参数异常,文章标签不能为空", null);
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isEmpty(shopArticleDto.getKeyword())) {
|
|
|
|
+ return ResponseJson.error("参数异常,SEO关键词不能为空", null);
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isEmpty(shopArticleDto.getPublisher())) {
|
|
|
|
+ return ResponseJson.error("参数异常,发布人不能为空", null);
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isEmpty(shopArticleDto.getRecommendContent())) {
|
|
|
|
+ return ResponseJson.error("参数异常,推荐语不能为空", null);
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isEmpty(shopArticleDto.getArticleContent())) {
|
|
|
|
+ return ResponseJson.error("参数异常,文章内容不能为空", null);
|
|
|
|
+ }
|
|
|
|
+ if (null == shopArticleDto.getTypeId()) {
|
|
|
|
+ return ResponseJson.error("参数异常,文章分类不能为空", null);
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isEmpty(shopArticleDto.getGuidanceImage())) {
|
|
|
|
+ return ResponseJson.error("参数异常,引导图不能为空", null);
|
|
|
|
+ }
|
|
|
|
+ if (null == shopArticleDto.getStatus()) {
|
|
|
|
+ return ResponseJson.error("参数异常,状态不能为空", null);
|
|
|
|
+ }
|
|
|
|
+ // 保存新增的文章标签
|
|
|
|
+ String articleLabel = shopArticleDto.getLabel();
|
|
|
|
+ String[] labelArr = articleLabel.split(",");
|
|
|
|
+ for (String label : labelArr) {
|
|
|
|
+ Integer dbLabelId = articleMapper.getArticleLabelId(label);
|
|
|
|
+ if (null == dbLabelId) {
|
|
|
|
+ articleMapper.insertArticleLabel(label);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ ArticlePo articlePo = new ArticlePo();
|
|
|
|
+ BeanUtils.copyProperties(shopArticleDto, articlePo);
|
|
|
|
+ // 新增文章标识
|
|
|
|
+ boolean newArticleFlag = null == articlePo.getArticleId() || 0 == articlePo.getArticleId();
|
|
|
|
+ // 保存供应商文章
|
|
|
|
+ if (newArticleFlag) {
|
|
|
|
+ articlePo.setPublishSource(2);
|
|
|
|
+ articlePo.setRecommendStatus(0);
|
|
|
|
+ articlePo.setBasePraise(0);
|
|
|
|
+ articlePo.setBasePv(0);
|
|
|
|
+ articlePo.setPriorityIndex(0);
|
|
|
|
+ articlePo.setAuditStatus(1);
|
|
|
|
+ articleMapper.insertShopArticle(articlePo);
|
|
|
|
+ } else {
|
|
|
|
+ articleMapper.updateShopArticle(articlePo);
|
|
|
|
+ }
|
|
|
|
+ // 更新文章索引
|
|
|
|
+ commodityFeign.updateArticleIndex(articlePo.getArticleId());
|
|
|
|
+ if (newArticleFlag) {
|
|
|
|
+ // 新增文章浏览/点赞记录
|
|
|
|
+ articleMapper.insertArticlePraise(articlePo.getArticleId());
|
|
|
|
+ // 新增文章 百度链接实时推送
|
|
|
|
+ GenerateUtils.pushBaiduLink("https://www.caimei365.com/info/detail-"+articlePo.getArticleId()+"-1.html");
|
|
|
|
+ }
|
|
|
|
+ return ResponseJson.success(null);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public ResponseJson<PageInfo<ShopArticleVo>> getShopArticleList(Integer shopId, int pageNum, int pageSize) {
|
|
|
|
+ if (null == shopId) {
|
|
|
|
+ return ResponseJson.error("参数异常", null);
|
|
|
|
+ }
|
|
|
|
+ PageHelper.startPage(pageNum, pageSize);
|
|
|
|
+ List<ShopArticleVo> articleList = articleMapper.getShopArticleList(shopId);
|
|
|
|
+ PageInfo<ShopArticleVo> pageInfo = new PageInfo<>(articleList);
|
|
|
|
+ return ResponseJson.success(pageInfo);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public ResponseJson<Void> updateArticleStatus(ShopArticleDto shopArticleDto) {
|
|
|
|
+ Integer articleId = shopArticleDto.getArticleId();
|
|
|
|
+ String status = shopArticleDto.getStatus();
|
|
|
|
+ if (null == articleId || null == status) {
|
|
|
|
+ return ResponseJson.error("参数异常", null);
|
|
|
|
+ }
|
|
|
|
+ articleMapper.updateArticleStatus(articleId, status);
|
|
|
|
+ return ResponseJson.success(null);
|
|
|
|
+ }
|
|
}
|
|
}
|