feat(新增): 秒杀场次管理,SeckillSku管理
This commit is contained in:
parent
a80af36879
commit
2fa9b39d14
|
@ -59,7 +59,7 @@ public class CodeGet {
|
|||
private static StrategyConfig getStrategyConfig() {
|
||||
StrategyConfig strategy = new StrategyConfig();
|
||||
// TODO 要生成的表
|
||||
strategy.setInclude("seckill", "seckill_sku", "seckill_sku_notice", "sku_info");
|
||||
strategy.setInclude("seckill_time");
|
||||
strategy.setNaming(NamingStrategy.underline_to_camel);// 数据库表映射到实体的命名策略
|
||||
strategy.setColumnNaming(NamingStrategy.underline_to_camel);// 数据库表字段映射到实体的命名策略
|
||||
strategy.setEntityLombokModel(true); // lombok 模型 @Accessors(chain = true) setter链式操作
|
||||
|
|
|
@ -1,20 +1,75 @@
|
|||
package com.atguigu.ssyx.activity.controller;
|
||||
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.atguigu.ssyx.activity.service.SecKillSkuService;
|
||||
import com.atguigu.ssyx.common.result.Result;
|
||||
import com.atguigu.ssyx.model.activity.SeckillSku;
|
||||
import com.atguigu.ssyx.vo.activity.SeckillSkuVo;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 秒杀活动商品关联 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author bunny
|
||||
* @since 2024-04-06
|
||||
*/
|
||||
import java.util.List;
|
||||
|
||||
@Api(value = "SeckillSku管理", tags = "SeckillSku管理")
|
||||
@RestController
|
||||
@RequestMapping("/activity/seckill-sku")
|
||||
@RequestMapping(value = "/admin/activity/seckillSku")
|
||||
public class SecKillSkuController {
|
||||
@Autowired
|
||||
private SecKillSkuService secKillSkuService;
|
||||
|
||||
@ApiOperation(value = "获取分页列表")
|
||||
@GetMapping("{page}/{limit}")
|
||||
public Result<IPage<SeckillSku>> index(
|
||||
@ApiParam(name = "page", value = "当前页码", required = true)
|
||||
@PathVariable Long page,
|
||||
@ApiParam(name = "limit", value = "每页记录数", required = true)
|
||||
@PathVariable Long limit,
|
||||
@ApiParam(name = "seckillSkuQueryVo", value = "查询对象", required = false)
|
||||
SeckillSkuVo seckillSkuVo
|
||||
) {
|
||||
Page<SeckillSku> pageParam = new Page<>();
|
||||
IPage<SeckillSku> pageModel = secKillSkuService.selectPage(pageParam, seckillSkuVo);
|
||||
return Result.success(pageModel);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取")
|
||||
@GetMapping("get/{id}")
|
||||
public Result<SeckillSku> get(@PathVariable Long id) {
|
||||
SeckillSku seckillSku = secKillSkuService.getById(id);
|
||||
return Result.success(seckillSku);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "新增")
|
||||
@PostMapping("save")
|
||||
public Result<SeckillSku> save(@RequestBody List<SeckillSku> seckillSkuList) {
|
||||
secKillSkuService.saveBatch(seckillSkuList);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改")
|
||||
@PutMapping("update")
|
||||
public Result<SeckillSku> updateById(@RequestBody SeckillSku seckillSku) {
|
||||
secKillSkuService.updateById(seckillSku);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除")
|
||||
@DeleteMapping("remove/{id}")
|
||||
public Result<SeckillSku> remove(@PathVariable Long id) {
|
||||
secKillSkuService.removeById(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "根据id列表删除")
|
||||
@DeleteMapping("batchRemove")
|
||||
public Result<SeckillSku> batchRemove(@RequestBody List<Long> ids) {
|
||||
secKillSkuService.removeByIds(ids);
|
||||
return Result.success();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
package com.atguigu.ssyx.activity.controller;
|
||||
|
||||
|
||||
import com.atguigu.ssyx.activity.service.SeckillTimeService;
|
||||
import com.atguigu.ssyx.common.result.Result;
|
||||
import com.atguigu.ssyx.model.activity.SeckillTime;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Api(value = "秒杀场次管理", tags = "秒杀场次管理")
|
||||
@RestController
|
||||
@RequestMapping(value = "/admin/activity/seckillTime")
|
||||
public class SeckillTimeController {
|
||||
@Resource
|
||||
private SeckillTimeService seckillTimeService;
|
||||
|
||||
@ApiOperation(value = "获取分页列表")
|
||||
@GetMapping()
|
||||
public Result<List<SeckillTime>> index() {
|
||||
return Result.success(seckillTimeService.list());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取")
|
||||
@GetMapping("get/{id}")
|
||||
public Result<SeckillTime> get(@PathVariable Long id) {
|
||||
SeckillTime seckillSession = seckillTimeService.getById(id);
|
||||
return Result.success(seckillSession);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "新增")
|
||||
@PostMapping("save")
|
||||
public Result save(@RequestBody SeckillTime seckillSession) {
|
||||
seckillTimeService.save(seckillSession);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改")
|
||||
@PutMapping("update")
|
||||
public Result<SeckillTime> updateById(@RequestBody SeckillTime seckillSession) {
|
||||
seckillTimeService.updateById(seckillSession);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除")
|
||||
@DeleteMapping("remove/{id}")
|
||||
public Result<SeckillTime> remove(@PathVariable Long id) {
|
||||
seckillTimeService.removeById(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "根据id列表删除")
|
||||
@DeleteMapping("batchRemove")
|
||||
public Result<SeckillTime> batchRemove(@RequestBody List<Long> idList) {
|
||||
seckillTimeService.removeByIds(idList);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "更新状态")
|
||||
@PostMapping("updateStatus/{id}/{status}")
|
||||
public Result<SeckillTime> updateStatus(@PathVariable Long id, @PathVariable Integer status) {
|
||||
seckillTimeService.updateStatus(id, status);
|
||||
return Result.success();
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ package com.atguigu.ssyx.activity.mapper;
|
|||
|
||||
import com.atguigu.ssyx.model.activity.SeckillSku;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
@ -11,6 +12,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||
* @author bunny
|
||||
* @since 2024-04-06
|
||||
*/
|
||||
@Mapper
|
||||
public interface SecKillSkuMapper extends BaseMapper<SeckillSku> {
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
package com.atguigu.ssyx.activity.mapper;
|
||||
|
||||
import com.atguigu.ssyx.model.activity.SeckillTime;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
|
||||
public interface SeckillTimeMapper extends BaseMapper<SeckillTime> {
|
||||
|
||||
}
|
|
@ -1,6 +1,9 @@
|
|||
package com.atguigu.ssyx.activity.service;
|
||||
|
||||
import com.atguigu.ssyx.model.activity.SeckillSku;
|
||||
import com.atguigu.ssyx.vo.activity.SeckillSkuVo;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
|
@ -13,4 +16,12 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
*/
|
||||
public interface SecKillSkuService extends IService<SeckillSku> {
|
||||
|
||||
/**
|
||||
* * 获取分页列表
|
||||
*
|
||||
* @param pageParam 当前页码信息
|
||||
* @param vo 查询对象
|
||||
* @return 分页结果
|
||||
*/
|
||||
IPage<SeckillSku> selectPage(Page<SeckillSku> pageParam, SeckillSkuVo vo);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
package com.atguigu.ssyx.activity.service;
|
||||
|
||||
import com.atguigu.ssyx.model.activity.SeckillTime;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
public interface SeckillTimeService extends IService<SeckillTime> {
|
||||
|
||||
/**
|
||||
* * 更新状态
|
||||
*
|
||||
* @param id 当前Id
|
||||
* @param status 当前状态
|
||||
*/
|
||||
void updateStatus(Long id, Integer status);
|
||||
}
|
|
@ -25,14 +25,14 @@ public class SeckillServiceImpl extends ServiceImpl<SecKillMapper, Seckill> impl
|
|||
/**
|
||||
* * 获取分页列表
|
||||
*
|
||||
* @param pageParam 分页参数
|
||||
* @param seckillQueryVo 秒杀信息
|
||||
* @param pageParam 分页参数
|
||||
* @param vo 秒杀信息
|
||||
* @return 分页结果
|
||||
*/
|
||||
@Override
|
||||
public IPage<Seckill> selectPage(Page<Seckill> pageParam, SeckillQueryVo seckillQueryVo) {
|
||||
Integer status = seckillQueryVo.getStatus();
|
||||
String title = seckillQueryVo.getTitle();
|
||||
public IPage<Seckill> selectPage(Page<Seckill> pageParam, SeckillQueryVo vo) {
|
||||
Integer status = vo.getStatus();
|
||||
String title = vo.getTitle();
|
||||
LambdaQueryWrapper<Seckill> wrapper = new LambdaQueryWrapper<>();
|
||||
if (!StringUtils.isEmpty(status)) {
|
||||
wrapper.eq(Seckill::getStatus, status);
|
||||
|
|
|
@ -3,7 +3,11 @@ package com.atguigu.ssyx.activity.service.impl;
|
|||
import com.atguigu.ssyx.activity.mapper.SecKillSkuMapper;
|
||||
import com.atguigu.ssyx.activity.service.SecKillSkuService;
|
||||
import com.atguigu.ssyx.model.activity.SeckillSku;
|
||||
import com.atguigu.ssyx.vo.activity.SeckillSkuVo;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
|
@ -16,5 +20,18 @@ import org.springframework.stereotype.Service;
|
|||
*/
|
||||
@Service
|
||||
public class SeckillSkuServiceImpl extends ServiceImpl<SecKillSkuMapper, SeckillSku> implements SecKillSkuService {
|
||||
@Autowired
|
||||
private SecKillSkuMapper seckillSkuMapper;
|
||||
|
||||
/**
|
||||
* * 获取分页列表
|
||||
*
|
||||
* @param pageParam 当前页码信息
|
||||
* @param vo 查询对象
|
||||
* @return 分页结果
|
||||
*/
|
||||
@Override
|
||||
public IPage<SeckillSku> selectPage(Page<SeckillSku> pageParam, SeckillSkuVo vo) {
|
||||
return page(pageParam);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
package com.atguigu.ssyx.activity.service.impl;
|
||||
|
||||
import com.atguigu.ssyx.activity.mapper.SeckillTimeMapper;
|
||||
import com.atguigu.ssyx.activity.service.SeckillTimeService;
|
||||
import com.atguigu.ssyx.model.activity.SeckillTime;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
@Service
|
||||
public class SeckillTimeServiceImpl extends ServiceImpl<SeckillTimeMapper, SeckillTime> implements SeckillTimeService {
|
||||
|
||||
/**
|
||||
* * 更新状态
|
||||
*
|
||||
* @param id 当前Id
|
||||
* @param status 当前状态
|
||||
*/
|
||||
@Override
|
||||
public void updateStatus(Long id, Integer status) {
|
||||
SeckillTime seckillTime = new SeckillTime();
|
||||
seckillTime.setStatus(status);
|
||||
seckillTime.setId(id);
|
||||
updateById(seckillTime);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.atguigu.ssyx.activity.mapper.SeckillTimeMapper">
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue