mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-26 17:21:53 +08:00
promotion:code review 秒杀的代码
This commit is contained in:
parent
aee5f39a77
commit
0b9ddddd18
@ -12,6 +12,7 @@ import javax.validation.constraints.NotEmpty;
|
|||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
// TODO halfninety:检查下所有的 VO,需要保证 example 都写了哈。
|
||||||
@ApiModel("管理后台 - 秒杀活动创建 Request VO")
|
@ApiModel("管理后台 - 秒杀活动创建 Request VO")
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@ -25,6 +26,7 @@ public class SeckillActivityCreateReqVO extends SeckillActivityBaseVO {
|
|||||||
@NotNull(message = "排序不能为空")
|
@NotNull(message = "排序不能为空")
|
||||||
private Integer sort;
|
private Integer sort;
|
||||||
|
|
||||||
|
// TODO halfninety:直接使用数组接口。timeIds,
|
||||||
@ApiModelProperty(value = "秒杀时段id", required = true)
|
@ApiModelProperty(value = "秒杀时段id", required = true)
|
||||||
@NotBlank(message = "参与场次不能为空")
|
@NotBlank(message = "参与场次不能为空")
|
||||||
private String timeId;
|
private String timeId;
|
||||||
|
@ -20,6 +20,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
|
// TODO @halfninety:controller 可以都放在 seckill 包下;vo 下分成 actvity 和 time
|
||||||
@Api(tags = "管理后台 - 秒杀时段")
|
@Api(tags = "管理后台 - 秒杀时段")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/promotion/seckill-time")
|
@RequestMapping("/promotion/seckill-time")
|
||||||
@ -65,11 +66,13 @@ public class SeckillTimeController {
|
|||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
@ApiOperation("获得所有秒杀时段列表")
|
@ApiOperation("获得所有秒杀时段列表")
|
||||||
// @PreAuthorize("@ss.hasPermission('promotion:seckill-time:query')")
|
// @PreAuthorize("@ss.hasPermission('promotion:seckill-time:query')")
|
||||||
|
// TODO @halfninety:权限为啥注释掉呀?
|
||||||
public CommonResult<List<SeckillTimeRespVO>> getSeckillTimeList() {
|
public CommonResult<List<SeckillTimeRespVO>> getSeckillTimeList() {
|
||||||
List<SeckillTimeDO> list = seckillTimeService.getSeckillTimeList();
|
List<SeckillTimeDO> list = seckillTimeService.getSeckillTimeList();
|
||||||
return success(SeckillTimeConvert.INSTANCE.convertList(list));
|
return success(SeckillTimeConvert.INSTANCE.convertList(list));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO @halfninety:不用的,可以删除掉
|
||||||
// @GetMapping("/page")
|
// @GetMapping("/page")
|
||||||
// @ApiOperation("获得秒杀时段分页")
|
// @ApiOperation("获得秒杀时段分页")
|
||||||
// @PreAuthorize("@ss.hasPermission('promotion:seckill-time:query')")
|
// @PreAuthorize("@ss.hasPermission('promotion:seckill-time:query')")
|
||||||
|
@ -59,6 +59,7 @@ public class SeckillActivityDO extends BaseDO {
|
|||||||
/**
|
/**
|
||||||
* 秒杀时段 id
|
* 秒杀时段 id
|
||||||
*/
|
*/
|
||||||
|
// TODO @halfninety 可以使用 List 存储;看下别的模块怎么做的哈
|
||||||
private String timeId;
|
private String timeId;
|
||||||
/**
|
/**
|
||||||
* 付款订单数
|
* 付款订单数
|
||||||
@ -68,6 +69,7 @@ public class SeckillActivityDO extends BaseDO {
|
|||||||
* 付款人数
|
* 付款人数
|
||||||
*/
|
*/
|
||||||
private Integer userCount;
|
private Integer userCount;
|
||||||
|
// TODO @halfninety 使用 Long 哈。单位是分
|
||||||
/**
|
/**
|
||||||
* 订单实付金额,单位:分
|
* 订单实付金额,单位:分
|
||||||
*/
|
*/
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
package cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckilltime;
|
package cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckilltime;
|
||||||
|
|
||||||
import java.time.LocalTime;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckilltime.SeckillTimeDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckilltime.SeckillTimeDO;
|
||||||
@ -10,6 +7,10 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||||||
import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
|
import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.time.LocalTime;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 秒杀时段 Mapper
|
* 秒杀时段 Mapper
|
||||||
*
|
*
|
||||||
@ -17,16 +18,22 @@ import org.apache.ibatis.annotations.Mapper;
|
|||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface SeckillTimeMapper extends BaseMapperX<SeckillTimeDO> {
|
public interface SeckillTimeMapper extends BaseMapperX<SeckillTimeDO> {
|
||||||
|
|
||||||
|
// @TODO halfninety:){ 之间要有空格哈
|
||||||
default List<SeckillTimeDO> selectListWithTime(LocalTime time){
|
default List<SeckillTimeDO> selectListWithTime(LocalTime time){
|
||||||
|
// TODO @halfninety:mapper 层,不做空判断,业务上面自己的保证
|
||||||
if (time == null) {
|
if (time == null) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
// TODO @halfninety:在 BaseMapperX 上,可以封装一个 2 个字段的检索哈
|
||||||
return selectList(new LambdaQueryWrapper<SeckillTimeDO>()
|
return selectList(new LambdaQueryWrapper<SeckillTimeDO>()
|
||||||
.le(SeckillTimeDO::getStartTime,time)
|
.le(SeckillTimeDO::getStartTime,time)
|
||||||
.ge(SeckillTimeDO::getEndTime,time));
|
.ge(SeckillTimeDO::getEndTime,time));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO @halfninety:selectListByXXX,使用 By 作为查询条件。
|
||||||
default List<SeckillTimeDO> selectListWithTime(LocalTime startTime, LocalTime endTime){
|
default List<SeckillTimeDO> selectListWithTime(LocalTime startTime, LocalTime endTime){
|
||||||
|
// TODO @halfninety:mapper 层,不做空判断,业务上面自己的保证
|
||||||
if (startTime == null && endTime == null) {
|
if (startTime == null && endTime == null) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
@ -35,6 +42,7 @@ public interface SeckillTimeMapper extends BaseMapperX<SeckillTimeDO> {
|
|||||||
.le(SeckillTimeDO::getEndTime,endTime));
|
.le(SeckillTimeDO::getEndTime,endTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO @halfninety:updateActivityCount + 和 -,可以执使用一个方法实现哈。多传递一个参数
|
||||||
default void sekillActivityCountAdd(List<Long> ids){
|
default void sekillActivityCountAdd(List<Long> ids){
|
||||||
if (CollUtil.isEmpty(ids)){
|
if (CollUtil.isEmpty(ids)){
|
||||||
return;
|
return;
|
||||||
|
@ -31,7 +31,7 @@ import static java.util.Arrays.asList;
|
|||||||
/**
|
/**
|
||||||
* 秒杀活动 Service 实现类
|
* 秒杀活动 Service 实现类
|
||||||
*
|
*
|
||||||
* @author 芋道源码
|
* @author 芋道源码 // TODO @halfninety:作者改成你自己哈
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@Validated
|
@Validated
|
||||||
@ -39,7 +39,6 @@ public class SeckillActivityServiceImpl implements SeckillActivityService {
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private SeckillActivityMapper seckillActivityMapper;
|
private SeckillActivityMapper seckillActivityMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private SeckillProductMapper seckillProductMapper;
|
private SeckillProductMapper seckillProductMapper;
|
||||||
|
|
||||||
@ -48,32 +47,40 @@ public class SeckillActivityServiceImpl implements SeckillActivityService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long createSeckillActivity(SeckillActivityCreateReqVO createReqVO) {
|
public Long createSeckillActivity(SeckillActivityCreateReqVO createReqVO) {
|
||||||
|
// TODO @halfninety:多余的变量,需要删除
|
||||||
List<Integer> statuses = asList(PromotionActivityStatusEnum.WAIT.getStatus(), PromotionActivityStatusEnum.RUN.getStatus());
|
List<Integer> statuses = asList(PromotionActivityStatusEnum.WAIT.getStatus(), PromotionActivityStatusEnum.RUN.getStatus());
|
||||||
// 校验商品是否冲突
|
// 校验商品是否冲突
|
||||||
validateSeckillActivityProductConflicts(null, createReqVO.getProducts());
|
validateSeckillActivityProductConflicts(null, createReqVO.getProducts());
|
||||||
// 更新秒杀时段的秒杀活动数量
|
|
||||||
seckillTimeService.sekillActivityCountAdd(StrUtils.splitToLong(createReqVO.getTimeId(),","));
|
// TODO halfninety:要校验下,秒杀时间段存在
|
||||||
// 插入秒杀活动
|
// 插入秒杀活动
|
||||||
SeckillActivityDO seckillActivity = SeckillActivityConvert.INSTANCE.convert(createReqVO)
|
SeckillActivityDO seckillActivity = SeckillActivityConvert.INSTANCE.convert(createReqVO)
|
||||||
.setStatus(PromotionUtils.calculateActivityStatus(createReqVO.getStartTime(), createReqVO.getEndTime()));
|
.setStatus(PromotionUtils.calculateActivityStatus(createReqVO.getStartTime(), createReqVO.getEndTime()));
|
||||||
seckillActivityMapper.insert(seckillActivity);
|
seckillActivityMapper.insert(seckillActivity);
|
||||||
// 插入商品
|
// 插入商品
|
||||||
|
// TODO @halfninety:是不是写成一个 convertList,通过 default 来处理下;这样可读性更好哈
|
||||||
List<SeckillProductDO> productDOS = CollectionUtils.convertList(createReqVO.getProducts(),
|
List<SeckillProductDO> productDOS = CollectionUtils.convertList(createReqVO.getProducts(),
|
||||||
product -> SeckillActivityConvert.INSTANCE.convert(product).setActivityId(seckillActivity.getId()));
|
product -> SeckillActivityConvert.INSTANCE.convert(product).setActivityId(seckillActivity.getId()));
|
||||||
seckillProductMapper.insertBatch(productDOS);
|
seckillProductMapper.insertBatch(productDOS);
|
||||||
|
|
||||||
|
// TODO halfninety:最后在更新秒杀时间段的商品数量哈。【我已经改了】一般先做核心的逻辑,在做附件的逻辑。
|
||||||
|
// 更新秒杀时段的秒杀活动数量
|
||||||
|
seckillTimeService.sekillActivityCountAdd(StrUtils.splitToLong(createReqVO.getTimeId(),","));
|
||||||
return seckillActivity.getId();
|
return seckillActivity.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateSeckillActivity(SeckillActivityUpdateReqVO updateReqVO) {
|
public void updateSeckillActivity(SeckillActivityUpdateReqVO updateReqVO) {
|
||||||
// 校验存在
|
// 校验存在
|
||||||
SeckillActivityDO seckillActivity = this.validateSeckillActivityExists(updateReqVO.getId());
|
SeckillActivityDO seckillActivity = validateSeckillActivityExists(updateReqVO.getId());
|
||||||
if (PromotionActivityStatusEnum.CLOSE.getStatus().equals(seckillActivity.getStatus())) {
|
if (PromotionActivityStatusEnum.CLOSE.getStatus().equals(seckillActivity.getStatus())) {
|
||||||
throw exception(SECKILL_ACTIVITY_UPDATE_FAIL_STATUS_CLOSED);
|
throw exception(SECKILL_ACTIVITY_UPDATE_FAIL_STATUS_CLOSED);
|
||||||
}
|
}
|
||||||
// 校验商品是否冲突
|
// 校验商品是否冲突
|
||||||
validateSeckillActivityProductConflicts(updateReqVO.getId(), updateReqVO.getProducts());
|
validateSeckillActivityProductConflicts(updateReqVO.getId(), updateReqVO.getProducts());
|
||||||
|
|
||||||
// 更新秒杀时段的秒杀活动数量
|
// 更新秒杀时段的秒杀活动数量
|
||||||
|
// TODO @halfninety:可以直接传递 seckillActivity 进去,不用重复查询;
|
||||||
updateSeckillTimeActivityCount(updateReqVO.getId(), updateReqVO.getTimeId());
|
updateSeckillTimeActivityCount(updateReqVO.getId(), updateReqVO.getTimeId());
|
||||||
// 更新活动
|
// 更新活动
|
||||||
SeckillActivityDO updateObj = SeckillActivityConvert.INSTANCE.convert(updateReqVO)
|
SeckillActivityDO updateObj = SeckillActivityConvert.INSTANCE.convert(updateReqVO)
|
||||||
@ -83,6 +90,7 @@ public class SeckillActivityServiceImpl implements SeckillActivityService {
|
|||||||
updateSeckillProduct(updateReqVO);
|
updateSeckillProduct(updateReqVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO @halfninety:注释写全哈;
|
||||||
/**
|
/**
|
||||||
* 更新秒杀时段的秒杀活动数量
|
* 更新秒杀时段的秒杀活动数量
|
||||||
*
|
*
|
||||||
@ -95,12 +103,15 @@ public class SeckillActivityServiceImpl implements SeckillActivityService {
|
|||||||
SeckillActivityDO seckillActivityDO = seckillActivityMapper.selectById(id);
|
SeckillActivityDO seckillActivityDO = seckillActivityMapper.selectById(id);
|
||||||
List<Long> existsTimeIds = StrUtils.splitToLong(seckillActivityDO.getTimeId(), ",");
|
List<Long> existsTimeIds = StrUtils.splitToLong(seckillActivityDO.getTimeId(), ",");
|
||||||
// 需要减少的时间段
|
// 需要减少的时间段
|
||||||
|
// TODO @halfninety:可以使用 CollUtil.filterNew()
|
||||||
List<Long> reduceIds = existsTimeIds.stream()
|
List<Long> reduceIds = existsTimeIds.stream()
|
||||||
.filter(existsTimeId -> !updateTimeIds.contains(existsTimeId))
|
.filter(existsTimeId -> !updateTimeIds.contains(existsTimeId))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
// 需要添加的时间段
|
// 需要添加的时间段
|
||||||
|
// TODO @halfninety:IDEA 一般会有告警提示,下面可以 lambada 表达式优化下;通过 command + 回车
|
||||||
updateTimeIds.removeIf(updateTimeId -> existsTimeIds.contains(updateTimeId));
|
updateTimeIds.removeIf(updateTimeId -> existsTimeIds.contains(updateTimeId));
|
||||||
// 更新减少时间段和增加时间段
|
// 更新减少时间段和增加时间段
|
||||||
|
// TODO @halfninety:判断非空才操作
|
||||||
seckillTimeService.sekillActivityCountAdd(updateTimeIds);
|
seckillTimeService.sekillActivityCountAdd(updateTimeIds);
|
||||||
seckillTimeService.sekillActivityCountReduce(reduceIds);
|
seckillTimeService.sekillActivityCountReduce(reduceIds);
|
||||||
}
|
}
|
||||||
@ -111,9 +122,11 @@ public class SeckillActivityServiceImpl implements SeckillActivityService {
|
|||||||
private void updateSeckillProduct(SeckillActivityUpdateReqVO updateReqVO) {
|
private void updateSeckillProduct(SeckillActivityUpdateReqVO updateReqVO) {
|
||||||
List<SeckillProductDO> seckillProductDOS = seckillProductMapper.selectListByActivityId(updateReqVO.getId());
|
List<SeckillProductDO> seckillProductDOS = seckillProductMapper.selectListByActivityId(updateReqVO.getId());
|
||||||
List<SeckillActivityBaseVO.Product> products = updateReqVO.getProducts();
|
List<SeckillActivityBaseVO.Product> products = updateReqVO.getProducts();
|
||||||
|
// TODO halfninety:下面这段,其实可以放到注释哈
|
||||||
// 对后台查出的数据和前台查出的数据进行遍历,
|
// 对后台查出的数据和前台查出的数据进行遍历,
|
||||||
// 1. 对前台数据进行遍历:如果不存在于后台的 sku 中需要新增
|
// 1. 对前台数据进行遍历:如果不存在于后台的 sku 中需要新增
|
||||||
// 2. 对后台数据进行遍历:如果不存在于前台的 sku 中需要删除
|
// 2. 对后台数据进行遍历:如果不存在于前台的 sku 中需要删除
|
||||||
|
|
||||||
// 计算需要删除的数据
|
// 计算需要删除的数据
|
||||||
List<Long> deleteIds = CollectionUtils.convertList(seckillProductDOS, SeckillProductDO::getId,
|
List<Long> deleteIds = CollectionUtils.convertList(seckillProductDOS, SeckillProductDO::getId,
|
||||||
seckillProductDO -> products.stream()
|
seckillProductDO -> products.stream()
|
||||||
@ -121,6 +134,7 @@ public class SeckillActivityServiceImpl implements SeckillActivityService {
|
|||||||
if (CollUtil.isNotEmpty(deleteIds)) {
|
if (CollUtil.isNotEmpty(deleteIds)) {
|
||||||
seckillProductMapper.deleteBatchIds(deleteIds);
|
seckillProductMapper.deleteBatchIds(deleteIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算需要新增的数据
|
// 计算需要新增的数据
|
||||||
List<SeckillProductDO> newSeckillProductDOs = CollectionUtils.convertList(products,
|
List<SeckillProductDO> newSeckillProductDOs = CollectionUtils.convertList(products,
|
||||||
product -> SeckillActivityConvert.INSTANCE.convert(product).setActivityId(updateReqVO.getId()));
|
product -> SeckillActivityConvert.INSTANCE.convert(product).setActivityId(updateReqVO.getId()));
|
||||||
@ -158,7 +172,6 @@ public class SeckillActivityServiceImpl implements SeckillActivityService {
|
|||||||
if (CollUtil.isNotEmpty(seckillActivityDOS)) {
|
if (CollUtil.isNotEmpty(seckillActivityDOS)) {
|
||||||
throw exception(SECKILL_ACTIVITY_SPU_CONFLICTS);
|
throw exception(SECKILL_ACTIVITY_SPU_CONFLICTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -3,33 +3,30 @@ package cn.iocoder.yudao.module.promotion.service.seckill.seckilltime;
|
|||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckilltime.vo.SeckillTimeCreateReqVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckilltime.vo.SeckillTimeCreateReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckilltime.vo.SeckillTimeUpdateReqVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckilltime.vo.SeckillTimeUpdateReqVO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.convert.seckill.seckilltime.SeckillTimeConvert;
|
||||||
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckilltime.SeckillTimeDO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckilltime.SeckillTimeMapper;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
import java.util.*;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckilltime.SeckillTimeDO;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.promotion.convert.seckill.seckilltime.SeckillTimeConvert;
|
|
||||||
import cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckilltime.SeckillTimeMapper;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*;
|
import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.SECKILL_TIME_CONFLICTS;
|
||||||
|
import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.SECKILL_TIME_NOT_EXISTS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 秒杀时段 Service 实现类
|
* 秒杀时段 Service 实现类
|
||||||
*
|
*
|
||||||
* @author 芋道源码
|
* @author 芋道源码 // TODO @halfninety:作者改成你自己哈
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@Validated
|
@Validated
|
||||||
public class SeckillTimeServiceImpl implements SeckillTimeService {
|
public class SeckillTimeServiceImpl implements SeckillTimeService {
|
||||||
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private SeckillTimeMapper seckillTimeMapper;
|
private SeckillTimeMapper seckillTimeMapper;
|
||||||
|
|
||||||
@ -93,7 +90,6 @@ public class SeckillTimeServiceImpl implements SeckillTimeService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SeckillTimeDO getSeckillTime(Long id) {
|
public SeckillTimeDO getSeckillTime(Long id) {
|
||||||
return seckillTimeMapper.selectById(id);
|
return seckillTimeMapper.selectById(id);
|
||||||
@ -104,6 +100,7 @@ public class SeckillTimeServiceImpl implements SeckillTimeService {
|
|||||||
return seckillTimeMapper.selectList();
|
return seckillTimeMapper.selectList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO @halfninety:updateActivityCount + 和 -,可以执使用一个方法实现哈。多传递一个参数
|
||||||
@Override
|
@Override
|
||||||
public void sekillActivityCountAdd(List<Long> ids) {
|
public void sekillActivityCountAdd(List<Long> ids) {
|
||||||
seckillTimeMapper.sekillActivityCountAdd(ids);
|
seckillTimeMapper.sekillActivityCountAdd(ids);
|
||||||
|
@ -8,5 +8,6 @@
|
|||||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||||
-->
|
-->
|
||||||
|
<!-- TODO halfninety:不用的话,可以删除掉哈。 -->
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
@ -8,5 +8,6 @@
|
|||||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||||
-->
|
-->
|
||||||
|
<!-- TODO halfninety:不用的话,可以删除掉哈。 -->
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
@ -30,7 +30,7 @@ spring:
|
|||||||
multi-statement-allow: true
|
multi-statement-allow: true
|
||||||
dynamic: # 多数据源配置
|
dynamic: # 多数据源配置
|
||||||
druid: # Druid 【连接池】相关的全局配置
|
druid: # Druid 【连接池】相关的全局配置
|
||||||
initial-size: 1 # 初始连接数
|
initial-size: 5 # 初始连接数
|
||||||
min-idle: 10 # 最小连接池数量
|
min-idle: 10 # 最小连接池数量
|
||||||
max-active: 20 # 最大连接池数量
|
max-active: 20 # 最大连接池数量
|
||||||
max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒
|
max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒
|
||||||
@ -45,40 +45,40 @@ spring:
|
|||||||
datasource:
|
datasource:
|
||||||
master:
|
master:
|
||||||
name: ruoyi-vue-pro
|
name: ruoyi-vue-pro
|
||||||
url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.master.name}?allowMultiQueries=true&useUnicode=true&useSSL=false&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
|
url: jdbc:mysql://139.9.196.247:3307/${spring.datasource.dynamic.datasource.master.name}?allowMultiQueries=true&useUnicode=true&useSSL=false&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
|
||||||
# url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT # MySQL Connector/J 5.X 连接的示例
|
# url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT # MySQL Connector/J 5.X 连接的示例
|
||||||
# url: jdbc:postgresql://127.0.0.1:5432/${spring.datasource.dynamic.datasource.slave.name} # PostgreSQL 连接的示例
|
# url: jdbc:postgresql://127.0.0.1:5432/${spring.datasource.dynamic.datasource.slave.name} # PostgreSQL 连接的示例
|
||||||
# url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例
|
# url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例
|
||||||
# url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=${spring.datasource.dynamic.datasource.master.name} # SQLServer 连接的示例
|
# url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=${spring.datasource.dynamic.datasource.master.name} # SQLServer 连接的示例
|
||||||
username: root
|
username: root
|
||||||
password: 123456
|
password: ${RUOYI_VUE_PRO}
|
||||||
# username: sa
|
# username: sa
|
||||||
# password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W
|
# password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W
|
||||||
slave: # 模拟从库,可根据自己需要修改
|
slave: # 模拟从库,可根据自己需要修改
|
||||||
name: ruoyi-vue-pro
|
name: ruoyi-vue-pro
|
||||||
url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.master.name}?allowMultiQueries=true&useUnicode=true&useSSL=false&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
|
url: jdbc:mysql://139.9.196.247:3307/${spring.datasource.dynamic.datasource.master.name}?allowMultiQueries=true&useUnicode=true&useSSL=false&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
|
||||||
# url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT # MySQL Connector/J 5.X 连接的示例
|
# url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT # MySQL Connector/J 5.X 连接的示例
|
||||||
# url: jdbc:postgresql://127.0.0.1:5432/${spring.datasource.dynamic.datasource.slave.name} # PostgreSQL 连接的示例
|
# url: jdbc:postgresql://127.0.0.1:5432/${spring.datasource.dynamic.datasource.slave.name} # PostgreSQL 连接的示例
|
||||||
# url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例
|
# url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例
|
||||||
# url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=${spring.datasource.dynamic.datasource.slave.name} # SQLServer 连接的示例
|
# url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=${spring.datasource.dynamic.datasource.slave.name} # SQLServer 连接的示例
|
||||||
username: root
|
username: root
|
||||||
password: 123456
|
password: ${RUOYI_VUE_PRO}
|
||||||
# username: sa
|
# username: sa
|
||||||
# password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W
|
# password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W
|
||||||
|
|
||||||
# Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优
|
# Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优
|
||||||
redis:
|
redis:
|
||||||
host: 127.0.0.1 # 地址
|
host: 139.9.196.247 # 地址
|
||||||
port: 6379 # 端口
|
port: 6379 # 端口
|
||||||
database: 0 # 数据库索引
|
database: 0 # 数据库索引
|
||||||
# password: 123456 # 密码,建议生产环境开启
|
password: 123456 # 密码,建议生产环境开启
|
||||||
|
|
||||||
--- #################### 定时任务相关配置 ####################
|
--- #################### 定时任务相关配置 ####################
|
||||||
|
|
||||||
# Quartz 配置项,对应 QuartzProperties 配置类
|
# Quartz 配置项,对应 QuartzProperties 配置类
|
||||||
spring:
|
spring:
|
||||||
quartz:
|
quartz:
|
||||||
auto-startup: true # 本地开发环境,尽量不要开启 Job
|
auto-startup: false # 本地开发环境,尽量不要开启 Job
|
||||||
scheduler-name: schedulerName # Scheduler 名字。默认为 schedulerName
|
scheduler-name: schedulerName # Scheduler 名字。默认为 schedulerName
|
||||||
job-store-type: jdbc # Job 存储器类型。默认为 memory 表示内存,可选 jdbc 使用数据库。
|
job-store-type: jdbc # Job 存储器类型。默认为 memory 表示内存,可选 jdbc 使用数据库。
|
||||||
wait-for-jobs-to-complete-on-shutdown: true # 应用关闭时,是否等待定时任务执行完成。默认为 false ,建议设置为 true
|
wait-for-jobs-to-complete-on-shutdown: true # 应用关闭时,是否等待定时任务执行完成。默认为 false ,建议设置为 true
|
||||||
|
Loading…
Reference in New Issue
Block a user