This commit is contained in:
admin
2024-07-25 23:10:53 +08:00
parent 9ae9963ea4
commit 4c5b046107
7 changed files with 48 additions and 22 deletions

View File

@@ -1,6 +1,7 @@
package com.starry.admin.modules.shop.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.starry.admin.common.exception.CustomException;
import com.starry.admin.modules.shop.module.entity.PlayShopArticleInfoEntity;
import com.starry.admin.modules.shop.module.vo.PlayShopArticleInfoAddVo;
import com.starry.admin.modules.shop.module.vo.PlayShopArticleInfoQueryVo;
@@ -14,6 +15,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.Date;
/**
* 店铺文章信息Controller
@@ -40,19 +42,32 @@ public class PlayShopArticleInfoController {
/**
* 新增页轮播列表
* 新增店铺文章信息
*/
//@PreAuthorize("@customSs.hasPermission('shop:articleInfo:add')")
@PostMapping("/create")
public R create(@Validated @RequestBody PlayShopArticleInfoAddVo vo) {
PlayShopArticleInfoEntity entity = ConvertUtil.entityToVo(vo, PlayShopArticleInfoEntity.class);
PlayShopArticleInfoEntity entity1 = playShopArticleInfoService.selectByType(entity.getArticleType());
if (entity.getId() == null) {
if (entity1 != null) {
throw new CustomException("同类型的文章只能存在一个");
}
playShopArticleInfoService.create(entity);
} else {
if (entity1 != null && !entity1.getId().equals(entity.getId())) {
throw new CustomException("同类型的文章只能存在一个");
}
entity.setUpdatedTime(new Date());
playShopArticleInfoService.update(entity);
}
return R.ok();
}
/**
* 修改页轮播状态
* 修改店铺文章信息
*/
//@PreAuthorize("@customSs.hasPermission('shop:articleInfo:update')")
@PostMapping("/handleUpdateState")

View File

@@ -13,6 +13,8 @@ import javax.validation.constraints.NotNull;
@Data
public class PlayShopArticleInfoAddVo {
private String id;
/**
* 文章类型
**/

View File

@@ -17,12 +17,12 @@ public class PlayShopArticleInfoQueryVo extends BasePageEntity {
* 文章ID
**/
private String id;
/**
* 文章类型
*/
private String articleType;
/**
* 文章标题
*/

View File

@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.starry.admin.modules.shop.module.entity.PlayShopArticleInfoEntity;
import com.starry.admin.modules.shop.module.vo.PlayShopArticleInfoQueryVo;
import java.util.List;
/**
* 店铺文章信息Service接口
*
@@ -36,6 +38,14 @@ public interface IPlayShopArticleInfoService extends IService<PlayShopArticleInf
IPage<PlayShopArticleInfoEntity> selectByPage(PlayShopArticleInfoQueryVo vo);
/**
* 查询店铺文章信息列表
*
* @return 店铺文章信息集合
*/
List<PlayShopArticleInfoEntity> selectByList();
/**
* 新增店铺文章信息
*

View File

@@ -7,15 +7,14 @@ 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;
import com.starry.admin.modules.shop.module.vo.PlayShopArticleInfoQueryVo;
import com.starry.admin.modules.shop.service.IPlayShopArticleInfoService;
import com.starry.common.utils.IdUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
/**
* 店铺首页轮播Service业务层处理
@@ -25,8 +24,6 @@ import java.util.Arrays;
*/
@Service
public class PlayShopArticleInfoServiceImpl extends ServiceImpl<PlayShopArticleInfoMapper, PlayShopArticleInfoEntity> implements IPlayShopArticleInfoService {
@Resource
private PlayShopCarouselInfoMapper playCarouselInfoMapper;
@Override
@@ -52,6 +49,12 @@ public class PlayShopArticleInfoServiceImpl extends ServiceImpl<PlayShopArticleI
}
@Override
public List<PlayShopArticleInfoEntity> selectByList() {
return this.baseMapper.selectList(new LambdaQueryWrapper<>());
}
@Override
public IPage<PlayShopArticleInfoEntity> selectByPage(PlayShopArticleInfoQueryVo vo) {
LambdaQueryWrapper<PlayShopArticleInfoEntity> lambdaWrapper = new LambdaQueryWrapper<>();
@@ -101,7 +104,7 @@ public class PlayShopArticleInfoServiceImpl extends ServiceImpl<PlayShopArticleI
*/
@Override
public int deleteByIds(String[] ids) {
return playCarouselInfoMapper.deleteBatchIds(Arrays.asList(ids));
return this.baseMapper.deleteBatchIds(Arrays.asList(ids));
}
/**
@@ -112,6 +115,6 @@ public class PlayShopArticleInfoServiceImpl extends ServiceImpl<PlayShopArticleI
*/
@Override
public int deleteById(String id) {
return playCarouselInfoMapper.deleteById(id);
return this.baseMapper.deleteById(id);
}
}

View File

@@ -5,8 +5,6 @@ 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;
@@ -49,13 +47,12 @@ 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));
@GetMapping(value = "clerk/getArticleList")
public R getArticleList() {
return R.ok(playShopArticleInfoService.selectByList());
}

View File

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