mirror of
https://gitee.com/youlaitech/youlai-mall.git
synced 2024-12-22 12:48:59 +08:00
feat: 添加app首页获取秒杀商品列表接口
This commit is contained in:
parent
127a7d8571
commit
7b31ed03c8
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.youlai.common.result.PageResult;
|
||||
import com.youlai.common.result.Result;
|
||||
import com.youlai.mall.pms.pojo.query.SpuPageQuery;
|
||||
import com.youlai.mall.pms.pojo.vo.SeckillingSpuVO;
|
||||
import com.youlai.mall.pms.pojo.vo.SpuPageVO;
|
||||
import com.youlai.mall.pms.pojo.vo.SpuDetailVO;
|
||||
import com.youlai.mall.pms.service.IPmsSpuService;
|
||||
@ -16,18 +17,20 @@ import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Api(tags = "「移动端」商品信息")
|
||||
@RestController("appSpuController")
|
||||
import java.util.List;
|
||||
|
||||
@Api(tags = "「移动端」商品接口")
|
||||
@RestController
|
||||
@RequestMapping("/app-api/v1/spu")
|
||||
@RequiredArgsConstructor
|
||||
public class SpuController {
|
||||
|
||||
private final IPmsSpuService iPmsSpuService;
|
||||
private final IPmsSpuService spuService;
|
||||
|
||||
@ApiOperation(value = "商品分页列表")
|
||||
@GetMapping("/page")
|
||||
public PageResult listSpuPage(SpuPageQuery queryParams) {
|
||||
IPage<SpuPageVO> result = iPmsSpuService.listSpuPages(queryParams);
|
||||
@GetMapping("/pages")
|
||||
public PageResult listSpuPages(SpuPageQuery queryParams) {
|
||||
IPage<SpuPageVO> result = spuService.listSpuPages(queryParams);
|
||||
return PageResult.success(result);
|
||||
}
|
||||
|
||||
@ -36,8 +39,15 @@ public class SpuController {
|
||||
public Result<SpuDetailVO> getSpuDetail(
|
||||
@ApiParam("商品ID") @PathVariable Long spuId
|
||||
) {
|
||||
SpuDetailVO spuDetailVO = iPmsSpuService.getSpuDetail(spuId);
|
||||
SpuDetailVO spuDetailVO = spuService.getSpuDetail(spuId);
|
||||
return Result.success(spuDetailVO);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取秒杀商品列表")
|
||||
@GetMapping("/seckilling_list")
|
||||
public Result<List<SeckillingSpuVO>> listSeckillingSpu() {
|
||||
List<SeckillingSpuVO> list = spuService.listSeckillingSpu();
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,11 +2,14 @@ package com.youlai.mall.pms.converter;
|
||||
|
||||
import com.youlai.mall.pms.pojo.entity.PmsSpu;
|
||||
import com.youlai.mall.pms.pojo.form.PmsSpuForm;
|
||||
import com.youlai.mall.pms.pojo.vo.SeckillingSpuVO;
|
||||
import org.mapstruct.InheritInverseConfiguration;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.Mappings;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品对象转换器
|
||||
*
|
||||
@ -24,4 +27,8 @@ public interface SpuConverter {
|
||||
@InheritInverseConfiguration(name="form2Entity")
|
||||
PmsSpuForm entity2Form(PmsSpu entity);
|
||||
|
||||
SeckillingSpuVO entity2SeckillingVO(PmsSpu entity);
|
||||
|
||||
List<SeckillingSpuVO> entity2SeckillingVO(List<PmsSpu> entities);
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,29 @@
|
||||
package com.youlai.mall.pms.pojo.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 【应用端】秒杀商品视图对象
|
||||
*
|
||||
* @author <a href="mailto:xianrui0365@163.com">haoxr</a>
|
||||
* @date 2021/8/8
|
||||
*/
|
||||
@ApiModel("商品分页对象")
|
||||
@Data
|
||||
public class SeckillingSpuVO {
|
||||
|
||||
@ApiModelProperty("商品ID")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("商品名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("商品价格(单位:分)")
|
||||
private Long price;
|
||||
|
||||
@ApiModelProperty("图片地址")
|
||||
private String picUrl;
|
||||
|
||||
}
|
@ -5,10 +5,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.youlai.mall.pms.pojo.form.PmsSpuForm;
|
||||
import com.youlai.mall.pms.pojo.entity.PmsSpu;
|
||||
import com.youlai.mall.pms.pojo.query.SpuPageQuery;
|
||||
import com.youlai.mall.pms.pojo.vo.PmsSpuPageVO;
|
||||
import com.youlai.mall.pms.pojo.vo.SpuDetailVO;
|
||||
import com.youlai.mall.pms.pojo.vo.SpuPageVO;
|
||||
import com.youlai.mall.pms.pojo.vo.PmsSpuDetailVO;
|
||||
import com.youlai.mall.pms.pojo.vo.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -66,21 +63,25 @@ public interface IPmsSpuService extends IService<PmsSpu> {
|
||||
/**
|
||||
* 修改商品
|
||||
*
|
||||
* @param spuId 商品ID
|
||||
* @param spuId 商品ID
|
||||
* @param formData
|
||||
* @return
|
||||
*/
|
||||
boolean updateSpuById(Long spuId,PmsSpuForm formData);
|
||||
boolean updateSpuById(Long spuId, PmsSpuForm formData);
|
||||
|
||||
/**
|
||||
* 删除商品
|
||||
* 删除商品
|
||||
*
|
||||
* @param ids 商品ID,多个以英文逗号(,)分割
|
||||
* @return
|
||||
*/
|
||||
boolean removeBySpuIds(String ids);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取秒杀商品列表
|
||||
* TODO
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<SeckillingSpuVO> listSeckillingSpu();
|
||||
}
|
||||
|
@ -298,6 +298,21 @@ public class PmsSpuServiceImpl extends ServiceImpl<PmsSpuMapper, PmsSpu> impleme
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品秒杀接口
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<SeckillingSpuVO> listSeckillingSpu() {
|
||||
List<PmsSpu> entities = this.list(new LambdaQueryWrapper<PmsSpu>()
|
||||
.select(PmsSpu::getId, PmsSpu::getName, PmsSpu::getPicUrl, PmsSpu::getPrice)
|
||||
.orderByDesc(PmsSpu::getCreateTime)
|
||||
);
|
||||
List<SeckillingSpuVO> list = spuConverter.entity2SeckillingVO(entities);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 保存SKU,需要替换提交表单中的临时规格ID
|
||||
|
Loading…
Reference in New Issue
Block a user