mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-08-15 18:51:54 +08:00
秒杀时段相关
This commit is contained in:
@@ -0,0 +1,99 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.seckilltime;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckilltime.vo.*;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.seckilltime.SeckillTimeDO;
|
||||
import cn.iocoder.yudao.module.promotion.convert.seckilltime.SeckillTimeConvert;
|
||||
import cn.iocoder.yudao.module.promotion.service.seckilltime.SeckillTimeService;
|
||||
|
||||
@Api(tags = "管理后台 - 秒杀时段")
|
||||
@RestController
|
||||
@RequestMapping("/promotion/seckill-time")
|
||||
@Validated
|
||||
public class SeckillTimeController {
|
||||
|
||||
@Resource
|
||||
private SeckillTimeService seckillTimeService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@ApiOperation("创建秒杀时段")
|
||||
@PreAuthorize("@ss.hasPermission('promotion:seckill-time:create')")
|
||||
public CommonResult<Long> createSeckillTime(@Valid @RequestBody SeckillTimeCreateReqVO createReqVO) {
|
||||
return success(seckillTimeService.createSeckillTime(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@ApiOperation("更新秒杀时段")
|
||||
@PreAuthorize("@ss.hasPermission('promotion:seckill-time:update')")
|
||||
public CommonResult<Boolean> updateSeckillTime(@Valid @RequestBody SeckillTimeUpdateReqVO updateReqVO) {
|
||||
seckillTimeService.updateSeckillTime(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@ApiOperation("删除秒杀时段")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class)
|
||||
@PreAuthorize("@ss.hasPermission('promotion:seckill-time:delete')")
|
||||
public CommonResult<Boolean> deleteSeckillTime(@RequestParam("id") Long id) {
|
||||
seckillTimeService.deleteSeckillTime(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@ApiOperation("获得秒杀时段")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
|
||||
@PreAuthorize("@ss.hasPermission('promotion:seckill-time:query')")
|
||||
public CommonResult<SeckillTimeRespVO> getSeckillTime(@RequestParam("id") Long id) {
|
||||
SeckillTimeDO seckillTime = seckillTimeService.getSeckillTime(id);
|
||||
return success(SeckillTimeConvert.INSTANCE.convert(seckillTime));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("获得所有秒杀时段列表")
|
||||
// @PreAuthorize("@ss.hasPermission('promotion:seckill-time:query')")
|
||||
public CommonResult<List<SeckillTimeRespVO>> getSeckillTimeList() {
|
||||
List<SeckillTimeDO> list = seckillTimeService.getSeckillTimeList();
|
||||
return success(SeckillTimeConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
|
||||
// @GetMapping("/page")
|
||||
// @ApiOperation("获得秒杀时段分页")
|
||||
// @PreAuthorize("@ss.hasPermission('promotion:seckill-time:query')")
|
||||
// public CommonResult<PageResult<SeckillTimeRespVO>> getSeckillTimePage(@Valid SeckillTimePageReqVO pageVO) {
|
||||
// PageResult<SeckillTimeDO> pageResult = seckillTimeService.getSeckillTimePage(pageVO);
|
||||
// return success(SeckillTimeConvert.INSTANCE.convertPage(pageResult));
|
||||
// }
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@ApiOperation("导出秒杀时段 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('promotion:seckill-time:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportSeckillTimeExcel(@Valid SeckillTimeExportReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<SeckillTimeDO> list = seckillTimeService.getSeckillTimeList(exportReqVO);
|
||||
// 导出 Excel
|
||||
List<SeckillTimeExcelVO> datas = SeckillTimeConvert.INSTANCE.convertList02(list);
|
||||
ExcelUtils.write(response, "秒杀时段.xls", "数据", SeckillTimeExcelVO.class, datas);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.seckilltime.vo;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalTime;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
import javax.validation.constraints.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
/**
|
||||
* 秒杀时段 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
@Data
|
||||
public class SeckillTimeBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "秒杀时段名称", required = true)
|
||||
@NotNull(message = "秒杀时段名称不能为空")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "开始时间点", required = true)
|
||||
@NotNull(message = "开始时间点不能为空")
|
||||
private LocalTime startTime;
|
||||
|
||||
@ApiModelProperty(value = "结束时间点", required = true)
|
||||
@NotNull(message = "结束时间点不能为空")
|
||||
private LocalTime endTime;
|
||||
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.seckilltime.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@ApiModel("管理后台 - 秒杀时段创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class SeckillTimeCreateReqVO extends SeckillTimeBaseVO {
|
||||
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.seckilltime.vo;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalTime;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
|
||||
/**
|
||||
* 秒杀时段 Excel VO
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Data
|
||||
public class SeckillTimeExcelVO {
|
||||
|
||||
@ExcelProperty("编号")
|
||||
private Long id;
|
||||
|
||||
@ExcelProperty("秒杀时段名称")
|
||||
private String name;
|
||||
|
||||
@ExcelProperty("开始时间点")
|
||||
private LocalTime startTime;
|
||||
|
||||
@ExcelProperty("结束时间点")
|
||||
private LocalTime endTime;
|
||||
|
||||
@ExcelProperty("商品数量")
|
||||
private Integer productCount;
|
||||
|
||||
@ExcelProperty("创建时间")
|
||||
private Date createTime;
|
||||
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.seckilltime.vo;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalTime;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@ApiModel(value = "管理后台 - 秒杀时段 Excel 导出 Request VO", description = "参数和 SeckillTimePageReqVO 是一致的")
|
||||
@Data
|
||||
public class SeckillTimeExportReqVO {
|
||||
|
||||
@ApiModelProperty(value = "秒杀时段名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "开始时间点")
|
||||
private LocalTime[] startTime;
|
||||
|
||||
@ApiModelProperty(value = "结束时间点")
|
||||
private LocalTime[] endTime;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private Date[] createTime;
|
||||
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.seckilltime.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalTime;
|
||||
|
||||
@ApiModel("管理后台 - 秒杀时段分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class SeckillTimePageReqVO extends PageParam {
|
||||
|
||||
@ApiModelProperty(value = "秒杀时段名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "开始时间点")
|
||||
@DateTimeFormat(pattern = "HH:mm:ss")
|
||||
private LocalTime startTime;
|
||||
|
||||
@ApiModelProperty(value = "结束时间点")
|
||||
@DateTimeFormat(pattern = "HH:mm:ss")
|
||||
private LocalTime endTime;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// @ApiModelProperty(value = "创建时间")
|
||||
// @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
// private Date[] createTime;
|
||||
|
||||
}
|
@@ -0,0 +1,22 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.seckilltime.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
@ApiModel("管理后台 - 秒杀时段 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class SeckillTimeRespVO extends SeckillTimeBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "编号", required = true)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "商品数量", required = true)
|
||||
private Integer productCount;
|
||||
|
||||
@ApiModelProperty(value = "创建时间", required = true)
|
||||
private Date createTime;
|
||||
|
||||
}
|
@@ -0,0 +1,4 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.seckilltime.vo;
|
||||
|
||||
public class SeckillTimeSimpleRespVO {
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.seckilltime.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@ApiModel("管理后台 - 秒杀时段更新 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class SeckillTimeUpdateReqVO extends SeckillTimeBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "编号", required = true)
|
||||
@NotNull(message = "编号不能为空")
|
||||
private Long id;
|
||||
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
package cn.iocoder.yudao.module.promotion.convert.seckilltime;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckilltime.vo.*;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.seckilltime.SeckillTimeDO;
|
||||
|
||||
/**
|
||||
* 秒杀时段 Convert
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface SeckillTimeConvert {
|
||||
|
||||
SeckillTimeConvert INSTANCE = Mappers.getMapper(SeckillTimeConvert.class);
|
||||
|
||||
SeckillTimeDO convert(SeckillTimeCreateReqVO bean);
|
||||
|
||||
SeckillTimeDO convert(SeckillTimeUpdateReqVO bean);
|
||||
|
||||
SeckillTimeRespVO convert(SeckillTimeDO bean);
|
||||
|
||||
List<SeckillTimeRespVO> convertList(List<SeckillTimeDO> list);
|
||||
|
||||
PageResult<SeckillTimeRespVO> convertPage(PageResult<SeckillTimeDO> page);
|
||||
|
||||
List<SeckillTimeExcelVO> convertList02(List<SeckillTimeDO> list);
|
||||
}
|
@@ -0,0 +1,47 @@
|
||||
package cn.iocoder.yudao.module.promotion.dal.dataobject.seckilltime;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalTime;
|
||||
import java.util.*;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 秒杀时段 DO
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@TableName("promotion_seckill_time")
|
||||
@KeySequence("promotion_seckill_time_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SeckillTimeDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 秒杀时段名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 开始时间点
|
||||
*/
|
||||
private LocalTime startTime;
|
||||
/**
|
||||
* 结束时间点
|
||||
*/
|
||||
private LocalTime endTime;
|
||||
/**
|
||||
* 商品数量
|
||||
*/
|
||||
private Integer productCount;
|
||||
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
package cn.iocoder.yudao.module.promotion.dal.mysql.seckilltime;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.seckilltime.SeckillTimeDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckilltime.vo.*;
|
||||
|
||||
/**
|
||||
* 秒杀时段 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface SeckillTimeMapper extends BaseMapperX<SeckillTimeDO> {
|
||||
|
||||
// default PageResult<SeckillTimeDO> selectPage(SeckillTimePageReqVO reqVO) {
|
||||
// return selectPage(reqVO, new LambdaQueryWrapperX<SeckillTimeDO>()
|
||||
// .likeIfPresent(SeckillTimeDO::getName, reqVO.getName())
|
||||
// .geIfPresent(SeckillTimeDO::getStartTime, reqVO.getStartTime())
|
||||
// .leIfPresent(SeckillTimeDO::getEndTime, reqVO.getEndTime())
|
||||
//// .betweenIfPresent(SeckillTimeDO::getStartTime, reqVO.getStartTime())
|
||||
//// .betweenIfPresent(SeckillTimeDO::getEndTime, reqVO.getEndTime())
|
||||
//// .betweenIfPresent(SeckillTimeDO::getCreateTime, reqVO.getCreateTime())
|
||||
// .orderByDesc(SeckillTimeDO::getId));
|
||||
// }
|
||||
|
||||
default List<SeckillTimeDO> selectList(SeckillTimeExportReqVO reqVO) {
|
||||
return selectList(new LambdaQueryWrapperX<SeckillTimeDO>()
|
||||
.likeIfPresent(SeckillTimeDO::getName, reqVO.getName())
|
||||
.betweenIfPresent(SeckillTimeDO::getStartTime, reqVO.getStartTime())
|
||||
.betweenIfPresent(SeckillTimeDO::getEndTime, reqVO.getEndTime())
|
||||
.betweenIfPresent(SeckillTimeDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(SeckillTimeDO::getId));
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,69 @@
|
||||
package cn.iocoder.yudao.module.promotion.service.seckilltime;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckilltime.vo.*;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.seckilltime.SeckillTimeDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
/**
|
||||
* 秒杀时段 Service 接口
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface SeckillTimeService {
|
||||
|
||||
/**
|
||||
* 创建秒杀时段
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createSeckillTime(@Valid SeckillTimeCreateReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新秒杀时段
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateSeckillTime(@Valid SeckillTimeUpdateReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除秒杀时段
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteSeckillTime(Long id);
|
||||
|
||||
/**
|
||||
* 获得秒杀时段
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 秒杀时段
|
||||
*/
|
||||
SeckillTimeDO getSeckillTime(Long id);
|
||||
|
||||
/**
|
||||
* 获得所有秒杀时段列表
|
||||
*
|
||||
* @return 所有秒杀时段列表
|
||||
*/
|
||||
List<SeckillTimeDO> getSeckillTimeList();
|
||||
|
||||
// /**
|
||||
// * 获得秒杀时段分页
|
||||
// *
|
||||
// * @param pageReqVO 分页查询
|
||||
// * @return 秒杀时段分页
|
||||
// */
|
||||
// PageResult<SeckillTimeDO> getSeckillTimePage(SeckillTimePageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得秒杀时段列表, 用于 Excel 导出
|
||||
*
|
||||
* @param exportReqVO 查询条件
|
||||
* @return 秒杀时段列表
|
||||
*/
|
||||
List<SeckillTimeDO> getSeckillTimeList(SeckillTimeExportReqVO exportReqVO);
|
||||
|
||||
}
|
@@ -0,0 +1,82 @@
|
||||
package cn.iocoder.yudao.module.promotion.service.seckilltime;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckilltime.vo.*;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.seckilltime.SeckillTimeDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import cn.iocoder.yudao.module.promotion.convert.seckilltime.SeckillTimeConvert;
|
||||
import cn.iocoder.yudao.module.promotion.dal.mysql.seckilltime.SeckillTimeMapper;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 秒杀时段 Service 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class SeckillTimeServiceImpl implements SeckillTimeService {
|
||||
|
||||
@Resource
|
||||
private SeckillTimeMapper seckillTimeMapper;
|
||||
|
||||
@Override
|
||||
public Long createSeckillTime(SeckillTimeCreateReqVO createReqVO) {
|
||||
// 插入
|
||||
SeckillTimeDO seckillTime = SeckillTimeConvert.INSTANCE.convert(createReqVO);
|
||||
seckillTimeMapper.insert(seckillTime);
|
||||
// 返回
|
||||
return seckillTime.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSeckillTime(SeckillTimeUpdateReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
this.validateSeckillTimeExists(updateReqVO.getId());
|
||||
// 更新
|
||||
SeckillTimeDO updateObj = SeckillTimeConvert.INSTANCE.convert(updateReqVO);
|
||||
seckillTimeMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteSeckillTime(Long id) {
|
||||
// 校验存在
|
||||
this.validateSeckillTimeExists(id);
|
||||
// 删除
|
||||
seckillTimeMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateSeckillTimeExists(Long id) {
|
||||
if (seckillTimeMapper.selectById(id) == null) {
|
||||
throw exception(SECKILL_TIME_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SeckillTimeDO getSeckillTime(Long id) {
|
||||
return seckillTimeMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SeckillTimeDO> getSeckillTimeList() {
|
||||
return seckillTimeMapper.selectList();
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public PageResult<SeckillTimeDO> getSeckillTimePage(SeckillTimePageReqVO pageReqVO) {
|
||||
// return seckillTimeMapper.selectPage(pageReqVO);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public List<SeckillTimeDO> getSeckillTimeList(SeckillTimeExportReqVO exportReqVO) {
|
||||
return seckillTimeMapper.selectList(exportReqVO);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
<?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="cn.iocoder.yudao.module.promotion.dal.mysql.seckilltime.SeckillTimeMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
</mapper>
|
Reference in New Issue
Block a user