This commit is contained in:
admin
2024-07-24 09:54:20 +08:00
parent 9463c94832
commit 2740ae64f4
6 changed files with 112 additions and 3 deletions

View File

@@ -20,7 +20,13 @@ public interface IPlayShopArticleInfoService extends IService<PlayShopArticleInf
*/
PlayShopArticleInfoEntity selectById(String id);
/**
* 根据文章类型查询店铺文章
*
* @param type 店铺文章类型
* @return 店铺文章信息
*/
PlayShopArticleInfoEntity selectByType(String type);
/**
* 查询店铺文章信息列表
*

View File

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.starry.admin.common.exception.CustomException;
import com.starry.admin.modules.shop.mapper.PlayShopArticleInfoMapper;
import com.starry.admin.modules.shop.mapper.PlayShopCarouselInfoMapper;
import com.starry.admin.modules.shop.module.entity.PlayShopArticleInfoEntity;
@@ -27,6 +28,14 @@ public class PlayShopArticleInfoServiceImpl extends ServiceImpl<PlayShopArticleI
@Resource
private PlayShopCarouselInfoMapper playCarouselInfoMapper;
@Override
public PlayShopArticleInfoEntity selectByType(String type) {
LambdaQueryWrapper<PlayShopArticleInfoEntity> lambdaWrapper = new LambdaQueryWrapper<>();
lambdaWrapper.eq(PlayShopArticleInfoEntity::getArticleType, type);
return this.baseMapper.selectOne(lambdaWrapper);
}
/**
* 查询店铺首页轮播
*
@@ -35,7 +44,11 @@ public class PlayShopArticleInfoServiceImpl extends ServiceImpl<PlayShopArticleI
*/
@Override
public PlayShopArticleInfoEntity selectById(String id) {
return this.baseMapper.selectById(id);
PlayShopArticleInfoEntity entity = this.baseMapper.selectById(id);
if (entity == null) {
throw new CustomException("对象不存在");
}
return entity;
}

View File

@@ -1,12 +1,19 @@
package com.starry.admin.modules.weichat.controller;
import com.starry.admin.common.aspect.ClerkUserLogin;
import com.starry.admin.modules.shop.module.entity.PlayShopArticleInfoEntity;
import com.starry.admin.modules.shop.module.entity.PlayShopCarouselInfoEntity;
import com.starry.admin.modules.shop.service.IPlayShopArticleInfoService;
import com.starry.admin.modules.shop.service.IPlayShopCarouselInfoService;
import com.starry.admin.modules.weichat.entity.PlayShopArticleInfoQueryVo;
import com.starry.admin.modules.weichat.entity.PlayShopArticleInfoReturnVo;
import com.starry.admin.modules.weichat.entity.PlayShopReadArticleVo;
import com.starry.admin.modules.weichat.entity.shop.ShopHomeCarouseInfoReturnVo;
import com.starry.common.result.R;
import com.starry.common.utils.ConvertUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -14,7 +21,7 @@ import javax.annotation.Resource;
import java.util.List;
/**
* 动态接口
* 店铺接口
*
* @author admin
* @since 2024/5/20 下午11:19
@@ -28,7 +35,12 @@ public class WxShopController {
@Resource
private IPlayShopCarouselInfoService playShopCarouselInfoService;
@Resource
IPlayShopArticleInfoService playShopArticleInfoService;
/**
* 获取首页轮播图
*/
@GetMapping(value = "custom/getShopHomeCarouseInfo")
public R getShopHomeCarouseInfo() {
List<PlayShopCarouselInfoEntity> entities = playShopCarouselInfoService.selectHomeCarouselInfo();
@@ -36,4 +48,28 @@ public class WxShopController {
}
/**
* 获取店铺文章
*/
@ClerkUserLogin
@GetMapping(value = "clerk/getShopArticleInfo")
public R getShopArticleInfo(@RequestBody PlayShopArticleInfoQueryVo vo) {
PlayShopArticleInfoEntity entity = playShopArticleInfoService.selectByType(vo.getType());
return R.ok(ConvertUtil.entityToVo(entity, PlayShopArticleInfoReturnVo.class));
}
/**
* 阅读店铺文章
*/
@ClerkUserLogin
@GetMapping(value = "clerk/readShopArticleInfo")
public R readShopArticleInfo(@RequestBody PlayShopReadArticleVo vo) {
PlayShopArticleInfoEntity entity = playShopArticleInfoService.selectById(vo.getId());
entity.setVisitsNumber(entity.getVisitsNumber() + 1);
playShopArticleInfoService.update(entity);
return R.ok("成功");
}
}

View File

@@ -0,0 +1,16 @@
package com.starry.admin.modules.weichat.entity;
import lombok.Data;
import javax.validation.constraints.NotNull;
/**
* @author admin
* @since 2024/7/24 上午9:36
**/
@Data
public class PlayShopArticleInfoQueryVo {
@NotNull(message = "type不能为空")
private String type;
}

View File

@@ -0,0 +1,22 @@
package com.starry.admin.modules.weichat.entity;
import lombok.Data;
/**
* @author admin
* @since 2024/7/24 上午9:36
**/
@Data
public class PlayShopArticleInfoReturnVo {
private String id;
/**
* 文章标题
**/
private String articleTitle;
/**
* 文章内容
**/
private String articleContent;
}

View File

@@ -0,0 +1,16 @@
package com.starry.admin.modules.weichat.entity;
import lombok.Data;
import javax.validation.constraints.NotNull;
/**
* @author admin
* @since 2024/7/24 上午9:36
**/
@Data
public class PlayShopReadArticleVo {
@NotNull(message = "id不能为空")
private String id;
}