登录(修改)
parent
dad078badb
commit
7fbd4c722c
|
@ -0,0 +1,15 @@
|
|||
package com.mall.common.constant;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* RabbitMQ常量类
|
||||
* @Author: lzh
|
||||
* @CreateTime: 2024-04-23 19:34
|
||||
* @Description: TODO
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Data
|
||||
public class RabbitConstants {
|
||||
public static final String SEND_CODE_BY_PHONE = "send_code_by_phone";
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.mall.common.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @Author: lzh
|
||||
* @CreateTime: 2024-05-02 11:00
|
||||
* @Description: TODO
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class AAA {
|
||||
private String name;
|
||||
private Integer age;
|
||||
private BigDecimal price;
|
||||
private String sex;
|
||||
private String address;
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package com.mall.common.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 品牌实体类
|
||||
* @Author: lzh
|
||||
* @CreateTime: 2024-04-25 11:56
|
||||
* @Description: TODO
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Brand {
|
||||
/**
|
||||
* 品牌id
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 品牌名
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 品牌logo
|
||||
*/
|
||||
private String logo;
|
||||
/**
|
||||
* 显示状态[0-不显示;1-显示]
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 检索首字母
|
||||
*/
|
||||
private String firstLetter;
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
package com.mall.common.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* sku实体类
|
||||
* @Author: lzh
|
||||
* @CreateTime: 2024-04-25 11:09
|
||||
* @Description: TODO
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Sku {
|
||||
/**
|
||||
* skuId
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* spuId
|
||||
*/
|
||||
private Long spuId;
|
||||
/**
|
||||
* sku名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 所属分类id
|
||||
*/
|
||||
private Long categoryId;
|
||||
/**
|
||||
* 品牌id
|
||||
*/
|
||||
private Long brandId;
|
||||
/**
|
||||
* 默认图片
|
||||
*/
|
||||
private String defaultImage;
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
private String title;
|
||||
/**
|
||||
* 副标题
|
||||
*/
|
||||
private String subtitle;
|
||||
/**
|
||||
* 价格
|
||||
*/
|
||||
private BigDecimal price;
|
||||
/**
|
||||
* 活动价格
|
||||
*/
|
||||
private BigDecimal activityPrice;
|
||||
/**
|
||||
* 重量(克)
|
||||
*/
|
||||
private Integer weight;
|
||||
/**
|
||||
* 库存
|
||||
*/
|
||||
private Integer inventory;
|
||||
/**
|
||||
* 库存限制量
|
||||
*/
|
||||
private Integer inventoryRestrict;
|
||||
/**
|
||||
* 秒杀id(0未开启秒杀)
|
||||
*/
|
||||
private Long spikesId;
|
||||
/**
|
||||
* 砍价id(0未开启砍价)
|
||||
*/
|
||||
private Long bargainId;
|
||||
/**
|
||||
* 拼团id(0未开启拼团)
|
||||
*/
|
||||
private Long groupId;
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.mall.common.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 秒杀商品图片对象
|
||||
* @Author: lzh
|
||||
* @CreateTime: 2024-04-25 11:53
|
||||
* @Description: TODO
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class SkuImages {
|
||||
private Long id;
|
||||
private Long skuId;
|
||||
private String url;
|
||||
private Integer sort;
|
||||
private Integer defaultStatus;
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
package com.mall.common.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 秒杀场次
|
||||
* @Author: lzh
|
||||
* @CreateTime: 2024-04-25 11:24
|
||||
* @Description: TODO
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Spikes {
|
||||
/**
|
||||
* 秒杀id
|
||||
*/
|
||||
private Long spikesId;
|
||||
/**
|
||||
* 商品主图
|
||||
*/
|
||||
private String spikesImg;
|
||||
/**
|
||||
* 轮播图
|
||||
*/
|
||||
private String spikesManyImg;
|
||||
/**
|
||||
* 商品标题
|
||||
*/
|
||||
private String spikesTitle;
|
||||
/**
|
||||
* 秒杀活动简介
|
||||
*/
|
||||
private String spikesThings;
|
||||
/**
|
||||
* 单位
|
||||
*/
|
||||
private String spikesUnit;
|
||||
/**
|
||||
* 当天参与活动次数
|
||||
*/
|
||||
private Integer spikesNum;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
private Date endTime;
|
||||
/**
|
||||
* 状态(0已开启1为开启)
|
||||
*/
|
||||
private Integer spikesState;
|
||||
/**
|
||||
* 0未删除1已删除
|
||||
*/
|
||||
private Integer isDelete;
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package com.mall.common.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* spu实体类
|
||||
* @Author: lzh
|
||||
* @CreateTime: 2024-04-25 11:33
|
||||
* @Description: TODO
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Spu {
|
||||
/**
|
||||
* 商品id
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 商品名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 所属分类id
|
||||
*/
|
||||
private Long categoryId;
|
||||
/**
|
||||
* 品牌id
|
||||
*/
|
||||
private Long brandId;
|
||||
/**
|
||||
* 上架状态[0 - 下架,1 - 上架]
|
||||
*/
|
||||
private Integer publishStatus;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
package com.mall.common.domain.request;
|
||||
|
||||
import com.mall.common.domain.Sku;
|
||||
import com.mall.common.domain.Spu;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* Sku 接参
|
||||
* @Author: lzh
|
||||
* @CreateTime: 2024-04-28 20:08
|
||||
* @Description: TODO
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class SkuRequest {
|
||||
/**
|
||||
* skuId
|
||||
*/
|
||||
private Long skuId;
|
||||
/**
|
||||
* spuId
|
||||
*/
|
||||
private Long spuId;
|
||||
/**
|
||||
* sku名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 所属分类id
|
||||
*/
|
||||
private Long categoryId;
|
||||
/**
|
||||
* 品牌id
|
||||
*/
|
||||
private Long brandId;
|
||||
/**
|
||||
* 默认图片
|
||||
*/
|
||||
private String defaultImage;
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
private String title;
|
||||
/**
|
||||
* 副标题
|
||||
*/
|
||||
private String subtitle;
|
||||
/**
|
||||
* 价格
|
||||
*/
|
||||
private BigDecimal price;
|
||||
/**
|
||||
* 活动价格
|
||||
*/
|
||||
private BigDecimal activityPrice;
|
||||
/**
|
||||
* 重量(克)
|
||||
*/
|
||||
private Integer weight;
|
||||
/**
|
||||
* 库存
|
||||
*/
|
||||
private Integer inventory;
|
||||
/**
|
||||
* 库存限制量
|
||||
*/
|
||||
private Integer inventoryRestrict;
|
||||
/**
|
||||
* 秒杀id(0未开启秒杀)
|
||||
*/
|
||||
private Long spikesId;
|
||||
/**
|
||||
* 砍价id(0未开启砍价)
|
||||
*/
|
||||
private Long bargainId;
|
||||
/**
|
||||
* 拼团id(0未开启拼团)
|
||||
*/
|
||||
private Long groupId;
|
||||
|
||||
private Spu spu;
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
package com.mall.common.domain.vo;
|
||||
|
||||
import com.mall.common.domain.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 秒杀信息vo
|
||||
* @Author: lzh
|
||||
* @CreateTime: 2024-04-25 11:51
|
||||
* @Description: TODO
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class SeckillVo {
|
||||
|
||||
/**
|
||||
* 秒杀id
|
||||
*/
|
||||
private Long spikesId;
|
||||
/**
|
||||
* 商品主图
|
||||
*/
|
||||
private String spikesImg;
|
||||
/**
|
||||
* 轮播图
|
||||
*/
|
||||
private String spikesManyImg;
|
||||
/**
|
||||
* 商品标题
|
||||
*/
|
||||
private String spikesTitle;
|
||||
/**
|
||||
* 秒杀活动简介
|
||||
*/
|
||||
private String spikesThings;
|
||||
/**
|
||||
* 单位
|
||||
*/
|
||||
private String spikesUnit;
|
||||
/**
|
||||
* 当天参与活动次数
|
||||
*/
|
||||
private Integer spikesNum;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
private Date endTime;
|
||||
/**
|
||||
* 状态(0已开启1为开启)
|
||||
*/
|
||||
private Integer spikesState;
|
||||
/**
|
||||
* 0未删除1已删除
|
||||
*/
|
||||
private Integer isDelete;
|
||||
|
||||
// 以下为扩展属性
|
||||
/**
|
||||
* 商品sku列表
|
||||
*/
|
||||
private List<Sku> skuList;
|
||||
|
||||
@Data
|
||||
public static class Sku{
|
||||
private Long skuId;
|
||||
private BigDecimal activityPrice;
|
||||
private Integer inventoryRestrict;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package com.mall.common.domain.vo;
|
||||
|
||||
import com.mall.common.domain.Brand;
|
||||
import com.mall.common.domain.Sku;
|
||||
import com.mall.common.domain.Spu;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* @Author: lzh
|
||||
* @CreateTime: 2024-04-28 15:34
|
||||
* @Description: TODO
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class SkuVo {
|
||||
/**
|
||||
* spuId
|
||||
*/
|
||||
private Long spuId;
|
||||
/**
|
||||
* 分类id
|
||||
*/
|
||||
private Long categoryId;
|
||||
/**
|
||||
* 品牌id
|
||||
*/
|
||||
private Long brandId;
|
||||
|
||||
private List<Sku> skuList;
|
||||
|
||||
private List<Spu> spuList;
|
||||
|
||||
private List<Brand> brandList;
|
||||
|
||||
private Integer PageNum=1;
|
||||
private Integer PageSize=10;
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package com.mall.common.redis;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.data.redis.core.BoundSetOperations;
|
||||
import org.springframework.data.redis.core.HashOperations;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
|
|
|
@ -46,6 +46,11 @@
|
|||
<artifactId>alipay-sdk-java</artifactId>
|
||||
<version>4.34.0.ALL</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper</artifactId>
|
||||
<version>6.0.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package com.mall.client;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
/**
|
||||
* 客户端启动类
|
||||
* @Author: lzh
|
||||
* @CreateTime: 2024-04-25 10:56
|
||||
* @Description: TODO
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@EnableScheduling
|
||||
@MapperScan("com.mall.client.mapper")
|
||||
@ComponentScan(basePackages = "com.mall")
|
||||
public class ClientApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ClientApplication.class, args);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.mall.client.controller;
|
||||
|
||||
import com.mall.client.service.BrandService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 品牌
|
||||
* @Author: lzh
|
||||
* @CreateTime: 2024-04-25 14:09
|
||||
* @Description: TODO
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@RestController
|
||||
public class BrandController {
|
||||
@Autowired
|
||||
private BrandService brandService;
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
package com.mall.client.controller;
|
||||
|
||||
import com.mall.client.service.SkuService;
|
||||
import com.mall.common.domain.UserInfo;
|
||||
import com.mall.common.domain.request.SkuRequest;
|
||||
import com.mall.common.domain.vo.SkuVo;
|
||||
import com.mall.common.result.Result;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 商品sku
|
||||
* @Author: lzh
|
||||
* @CreateTime: 2024-04-25 11:42
|
||||
* @Description: TODO
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@RestController
|
||||
public class SkuController {
|
||||
@Autowired
|
||||
private SkuService skuService;
|
||||
|
||||
/**
|
||||
* 商品
|
||||
* @param skuVo
|
||||
* @return result
|
||||
*/
|
||||
@PostMapping("select/sku/seckill")
|
||||
public Result selectSku(@RequestBody SkuVo skuVo) {
|
||||
Result result = skuService.selectSku(skuVo);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加商品
|
||||
* @param skuRequest
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("insert/sku")
|
||||
public Result insertSku(@RequestBody SkuRequest skuRequest) {
|
||||
return skuService.insertSku(skuRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品详情(回显)
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("infoSku/{id}")
|
||||
public Result infoSku(@PathVariable Long id) {
|
||||
return skuService.infoSku(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改商品信息
|
||||
*/
|
||||
@PostMapping("update/sku")
|
||||
public Result updateSku(@RequestBody SkuRequest skuRequest) {
|
||||
return skuService.updateSku(skuRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取登录人信息
|
||||
*/
|
||||
@GetMapping("info")
|
||||
public Result<UserInfo> info() {
|
||||
Result<UserInfo> result = skuService.info();
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.mall.client.controller;
|
||||
|
||||
import com.mall.client.service.SkuImagesService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 图片
|
||||
* @Author: lzh
|
||||
* @CreateTime: 2024-04-25 14:02
|
||||
* @Description: TODO
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@RestController
|
||||
public class SkuImagesController {
|
||||
@Autowired
|
||||
private SkuImagesService skuImageSService;
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package com.mall.client.controller;
|
||||
|
||||
import com.mall.client.service.SpikesService;
|
||||
import com.mall.common.domain.vo.SeckillVo;
|
||||
import com.mall.common.result.Result;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 秒杀场次
|
||||
* @Author: lzh
|
||||
* @CreateTime: 2024-04-25 11:01
|
||||
* @Description: TODO
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@RestController
|
||||
public class SpikesController {
|
||||
@Autowired
|
||||
private SpikesService spikesService;
|
||||
|
||||
/**
|
||||
* 秒杀商品查询
|
||||
* @param seckillVo
|
||||
* @return result
|
||||
*/
|
||||
@PostMapping("select/spikes")
|
||||
public Result selectSpikes(SeckillVo seckillVo) {
|
||||
return spikesService.selectSpikes(seckillVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 秒杀商品添加
|
||||
* @param seckillVo
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("insert/spikes")
|
||||
public Result insertSpikes(SeckillVo seckillVo) {
|
||||
return spikesService.insertSpikes(seckillVo);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.mall.client.controller;
|
||||
|
||||
import com.mall.client.service.SpuService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 商品spu
|
||||
* @Author: lzh
|
||||
* @CreateTime: 2024-04-25 11:35
|
||||
* @Description: TODO
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@RestController
|
||||
public class SpuController {
|
||||
@Autowired
|
||||
private SpuService spuService;
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.mall.client.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mall.common.domain.Brand;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 品牌Mapper接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface BrandMapper extends BaseMapper<Brand> {
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.mall.client.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mall.common.domain.SkuImages;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 图片Mapper接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface SkuImagesMapper extends BaseMapper<SkuImages> {
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.mall.client.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mall.common.domain.Sku;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* skuMapper接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface SkuMapper extends BaseMapper<Sku> {
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.mall.client.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mall.common.domain.Spikes;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 秒杀场次Mapper接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface SpikesMapper extends BaseMapper<Spikes> {
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.mall.client.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mall.common.domain.Spu;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* spuMapper接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface SpuMapper extends BaseMapper<Spu> {
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package com.mall.client.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.mall.common.domain.Brand;
|
||||
|
||||
/**
|
||||
* 品牌Service接口
|
||||
*/
|
||||
public interface BrandService extends IService<Brand> {
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package com.mall.client.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.mall.common.domain.SkuImages;
|
||||
|
||||
/**
|
||||
* 图片Service接口
|
||||
*/
|
||||
public interface SkuImagesService extends IService<SkuImages> {
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.mall.client.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.mall.common.domain.Sku;
|
||||
import com.mall.common.domain.UserInfo;
|
||||
import com.mall.common.domain.request.SkuRequest;
|
||||
import com.mall.common.domain.vo.SkuVo;
|
||||
import com.mall.common.result.Result;
|
||||
|
||||
/**
|
||||
* SkuService接口
|
||||
*/
|
||||
public interface SkuService extends IService<Sku> {
|
||||
Result selectSku(SkuVo skuVo);
|
||||
|
||||
Result<UserInfo> info();
|
||||
|
||||
Result insertSku(SkuRequest skuRequest);
|
||||
|
||||
Result infoSku(Long id);
|
||||
|
||||
Result updateSku(SkuRequest skuRequest);
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.mall.client.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.mall.common.domain.Spikes;
|
||||
import com.mall.common.domain.vo.SeckillVo;
|
||||
import com.mall.common.result.Result;
|
||||
|
||||
/**
|
||||
* 秒杀场次Service接口
|
||||
*/
|
||||
public interface SpikesService extends IService<Spikes> {
|
||||
Result selectSpikes(SeckillVo seckillVo);
|
||||
|
||||
Result insertSpikes(SeckillVo seckillVo);
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package com.mall.client.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.mall.common.domain.Spu;
|
||||
/**
|
||||
* SpuService接口
|
||||
*/
|
||||
public interface SpuService extends IService<Spu> {
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.mall.client.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mall.client.mapper.BrandMapper;
|
||||
import com.mall.client.service.BrandService;
|
||||
import com.mall.common.domain.Brand;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 品牌业务实现类
|
||||
* @Author: lzh
|
||||
* @CreateTime: 2024-04-25 14:10
|
||||
* @Description: TODO
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Service
|
||||
public class BrandServiceImpl extends ServiceImpl<BrandMapper, Brand> implements BrandService {
|
||||
@Autowired
|
||||
private BrandMapper brandMapper;
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.mall.client.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mall.client.mapper.SkuImagesMapper;
|
||||
import com.mall.client.service.SkuImagesService;
|
||||
import com.mall.common.domain.SkuImages;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 图片业务实现类
|
||||
* @Author: lzh
|
||||
* @CreateTime: 2024-04-25 14:03
|
||||
* @Description: TODO
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Service
|
||||
public class SkuImageServiceImpl extends ServiceImpl<SkuImagesMapper, SkuImages> implements SkuImagesService {
|
||||
@Autowired
|
||||
private SkuImagesMapper skuImagesMapper;
|
||||
}
|
|
@ -0,0 +1,157 @@
|
|||
package com.mall.client.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.mall.client.mapper.SkuMapper;
|
||||
import com.mall.client.service.*;
|
||||
import com.mall.common.constant.TokenConstants;
|
||||
import com.mall.common.domain.*;
|
||||
import com.mall.common.domain.request.SkuRequest;
|
||||
import com.mall.common.domain.vo.SkuVo;
|
||||
import com.mall.common.redis.RedisCache;
|
||||
import com.mall.common.result.Result;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import static com.fasterxml.jackson.databind.util.ClassUtil.name;
|
||||
|
||||
/**
|
||||
* sku业务实现类
|
||||
* @Author: lzh
|
||||
* @CreateTime: 2024-04-25 11:44
|
||||
* @Description: TODO
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Service
|
||||
public class SkuServiceImpl extends ServiceImpl<SkuMapper, Sku> implements SkuService {
|
||||
@Autowired
|
||||
private SkuMapper skuMapper;
|
||||
|
||||
@Autowired
|
||||
private SpikesService spikesService;
|
||||
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
|
||||
@Autowired
|
||||
private BrandService brandService;
|
||||
|
||||
@Autowired
|
||||
private SpuService spuService;
|
||||
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
@Override
|
||||
public Result selectSku(SkuVo skuVo) {
|
||||
PageHelper.startPage(skuVo.getPageNum(),skuVo.getPageSize());
|
||||
List<Sku> skuList = this.list();
|
||||
PageInfo<Sku> skuPageInfo = new PageInfo<>(skuList);
|
||||
|
||||
skuPageInfo.getList().forEach(sku -> {
|
||||
LambdaQueryWrapper<Brand> brandLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
brandLambdaQueryWrapper.eq(Brand::getId,sku.getBrandId());
|
||||
List<Brand> brandList = this.brandService.list(brandLambdaQueryWrapper);
|
||||
skuVo.setBrandList(brandList);
|
||||
|
||||
LambdaQueryWrapper<Spu> spuLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
spuLambdaQueryWrapper.eq(Spu::getId,sku.getSpuId());
|
||||
List<Spu> spuList = this.spuService.list(spuLambdaQueryWrapper);
|
||||
skuVo.setSpuList(spuList);
|
||||
});
|
||||
skuVo.setSkuList(skuPageInfo.getList());
|
||||
return Result.success(skuVo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<UserInfo> info() {
|
||||
String token = request.getHeader(TokenConstants.LOGIN_TOKEN_KEY);
|
||||
UserInfo userInfo = redisCache.getCacheObject(TokenConstants.LOGIN_TOKEN_KEY + token);
|
||||
return Result.success(userInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result insertSku(SkuRequest skuRequest) {
|
||||
Spu spu = Spu.builder()
|
||||
.categoryId(skuRequest.getCategoryId())
|
||||
.brandId(skuRequest.getBrandId())
|
||||
.name(skuRequest.getName())
|
||||
.createTime(new Date())
|
||||
.updateTime(new Date())
|
||||
.build();
|
||||
spuService.save(spu);
|
||||
|
||||
Long spuId = spu.getId();
|
||||
Sku sku = Sku.builder()
|
||||
.spuId(spuId)
|
||||
.name(skuRequest.getName())
|
||||
.categoryId(skuRequest.getCategoryId())
|
||||
.brandId(skuRequest.getBrandId())
|
||||
.defaultImage(skuRequest.getDefaultImage())
|
||||
.title(skuRequest.getTitle())
|
||||
.subtitle(skuRequest.getSubtitle())
|
||||
.price(skuRequest.getPrice())
|
||||
.weight(skuRequest.getWeight())
|
||||
.inventory(skuRequest.getInventory())
|
||||
.build();
|
||||
this.save(sku);
|
||||
return Result.success(true,"添加商品成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result infoSku(Long id) {
|
||||
Sku sku = this.getById(id);
|
||||
this.infoSpu(sku.getSpuId());
|
||||
return Result.success(sku,"商品Sku回显");
|
||||
}
|
||||
|
||||
public Result infoSpu(Long spuId){
|
||||
Spu spu = spuService.getById(spuId);
|
||||
return Result.success(spu,"商品Spu回显");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result updateSku(SkuRequest skuRequest) {
|
||||
Sku sku = Sku.builder()
|
||||
.id(skuRequest.getSkuId())
|
||||
.name(skuRequest.getName())
|
||||
.categoryId(skuRequest.getCategoryId())
|
||||
.brandId(skuRequest.getBrandId())
|
||||
.defaultImage(skuRequest.getDefaultImage())
|
||||
.title(skuRequest.getTitle())
|
||||
.subtitle(skuRequest.getSubtitle())
|
||||
.price(skuRequest.getPrice())
|
||||
.activityPrice(skuRequest.getPrice())
|
||||
.weight(skuRequest.getWeight())
|
||||
.inventory(skuRequest.getInventory())
|
||||
.build();
|
||||
this.updateById(sku);
|
||||
|
||||
Spu spu = Spu.builder()
|
||||
.categoryId(skuRequest.getCategoryId())
|
||||
.brandId(skuRequest.getBrandId())
|
||||
.name(skuRequest.getName())
|
||||
.updateTime(new Date())
|
||||
.build();
|
||||
this.spuService.updateById(spu);
|
||||
|
||||
if (skuRequest.getSpikesId() != null) {
|
||||
Spikes spikes = Spikes.builder()
|
||||
.spikesId(skuRequest.getSpikesId())
|
||||
.spikesTitle(skuRequest.getTitle())
|
||||
.spikesUnit(skuRequest.getSubtitle())
|
||||
.spikesManyImg(skuRequest.getDefaultImage())
|
||||
.spikesImg(skuRequest.getDefaultImage())
|
||||
.spikesThings(skuRequest.getSubtitle())
|
||||
.build();
|
||||
this.spikesService.updateById(spikes);
|
||||
}
|
||||
return Result.success(true,"修改成功");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
package com.mall.client.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mall.client.mapper.SpikesMapper;
|
||||
import com.mall.client.service.SkuService;
|
||||
import com.mall.client.service.SpikesService;
|
||||
import com.mall.common.domain.Sku;
|
||||
import com.mall.common.domain.Spikes;
|
||||
import com.mall.common.domain.vo.SeckillVo;
|
||||
import com.mall.common.redis.RedisCache;
|
||||
import com.mall.common.result.Result;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 秒杀场次业务实现类
|
||||
* @Author: lzh
|
||||
* @CreateTime: 2024-04-25 11:05
|
||||
* @Description: TODO
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Service
|
||||
public class SpikesServiceImpl extends ServiceImpl<SpikesMapper, Spikes> implements SpikesService {
|
||||
@Autowired
|
||||
private SpikesMapper spikesMapper;
|
||||
|
||||
@Autowired
|
||||
private SkuService skuService;
|
||||
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
@Override
|
||||
public Result selectSpikes(SeckillVo seckillVo) {
|
||||
if (redisCache.hasKey(seckillVo.getSpikesId().toString())) {
|
||||
return Result.error("秒杀活动已结束");
|
||||
}
|
||||
//从redis中获取秒杀活动信息
|
||||
Spikes spikes = redisCache.getCacheObject(seckillVo.getSpikesId().toString());
|
||||
return Result.success(spikes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result insertSpikes(SeckillVo seckillVo) {
|
||||
if (redisCache.hasKey(seckillVo.getSpikesId().toString())) {
|
||||
return Result.error("秒杀活动已存在");
|
||||
}
|
||||
|
||||
Spikes spikes = Spikes.builder()
|
||||
.spikesTitle(seckillVo.getSpikesTitle())
|
||||
.spikesUnit(seckillVo.getSpikesUnit())
|
||||
.spikesNum(seckillVo.getSpikesNum())
|
||||
.spikesState(seckillVo.getSpikesState())
|
||||
.spikesImg(seckillVo.getSpikesImg())
|
||||
.spikesManyImg(seckillVo.getSpikesManyImg())
|
||||
.spikesThings(seckillVo.getSpikesThings())
|
||||
.endTime(seckillVo.getEndTime())
|
||||
.build();
|
||||
this.save(spikes);
|
||||
|
||||
skuService.updateById(
|
||||
(Sku) seckillVo.getSkuList().stream().map(sku ->
|
||||
Sku.builder()
|
||||
.id(sku.getSkuId())
|
||||
.spikesId(spikes.getSpikesId())
|
||||
.activityPrice(sku.getActivityPrice())
|
||||
.inventoryRestrict(sku.getInventoryRestrict())
|
||||
.build()
|
||||
).collect(Collectors.toList())
|
||||
);
|
||||
return Result.success(200,"添加秒杀信息成功");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.mall.client.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mall.client.mapper.SpuMapper;
|
||||
import com.mall.client.service.SpuService;
|
||||
import com.mall.common.domain.Spu;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* spu业务实现类
|
||||
* @Author: lzh
|
||||
* @CreateTime: 2024-04-25 11:36
|
||||
* @Description: TODO
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Service
|
||||
public class SpuServiceImpl extends ServiceImpl<SpuMapper, Spu> implements SpuService {
|
||||
@Autowired
|
||||
private SpuMapper spuMapper;
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
package com.mall.client.sync;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.mall.client.service.SkuService;
|
||||
import com.mall.client.service.SpikesService;
|
||||
import com.mall.common.domain.Sku;
|
||||
import com.mall.common.domain.Spikes;
|
||||
import com.mall.common.domain.vo.SeckillVo;
|
||||
import com.mall.common.redis.RedisCache;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Component
|
||||
public class TimingDepositSeckill {
|
||||
@Autowired
|
||||
private SkuService skuService;
|
||||
@Autowired
|
||||
private SpikesService spikesService;
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
//每天的0点执行,将秒杀的数据存入redis中
|
||||
@Scheduled(cron = "0 0 0 * * ?")
|
||||
public void timingDepositSeckill() {
|
||||
ArrayList<SeckillVo> seckillList = new ArrayList<>();
|
||||
|
||||
List<Spikes> list = spikesService.list();
|
||||
|
||||
//判断秒杀活动时间是否 大于或等于 当前时间 是 就放入redis
|
||||
for (Spikes spikes : list) {
|
||||
SeckillVo seckillVo = new SeckillVo();
|
||||
//判断活动时间是否 大于或等于 当前时间 是 就放入redis
|
||||
if (spikes.getCreateTime().getTime() >= System.currentTimeMillis()) {
|
||||
|
||||
LambdaQueryWrapper<Sku> skuLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
//查询条件根据sku中的spikesId
|
||||
skuLambdaQueryWrapper.eq(Sku::getSpikesId,seckillVo.getSpikesId());
|
||||
|
||||
//查询sku开启秒杀的信息
|
||||
List<Sku> skuList = skuService.list(skuLambdaQueryWrapper);
|
||||
|
||||
//秒杀的商品信息存入
|
||||
seckillVo.setSkuList(skuList);
|
||||
|
||||
//秒杀的基本信息
|
||||
seckillVo.setSpikesId(spikes.getSpikesId());
|
||||
seckillVo.setSpikesImg(spikes.getSpikesImg());
|
||||
seckillVo.setSpikesManyImg(spikes.getSpikesManyImg());
|
||||
seckillVo.setSpikesThings(spikes.getSpikesThings());
|
||||
seckillVo.setSpikesTitle(spikes.getSpikesTitle());
|
||||
seckillVo.setCreateTime(spikes.getCreateTime());
|
||||
seckillVo.setEndTime(spikes.getEndTime());
|
||||
}
|
||||
seckillList.add(seckillVo);
|
||||
}
|
||||
for (SeckillVo seckillVo : seckillList) {
|
||||
//判断信息是否大于当天时间 如果大于不予处理
|
||||
if (seckillVo.getCreateTime().getTime() > System.currentTimeMillis() + 24 * 60 * 60 * 1000) {
|
||||
continue;
|
||||
}
|
||||
//将秒杀的数据 存入redis中 并设置过期时间 为 秒杀活动 结束的时间 减去 凌晨
|
||||
redisCache.setCacheObject("seckill:"+seckillVo.getSpikesId(),seckillVo,seckillVo.getEndTime().getTime()-System.currentTimeMillis(), TimeUnit.MILLISECONDS);
|
||||
//如果redis中信息已经删除 将Spikes中的isDelete 修改为1 (在是今天的活动的前提下)
|
||||
// if (redisCache.getCacheObject("seckill:"+seckillVo.getSpikesId()) == null) {
|
||||
// spikesService.update().eq("spikes_id",seckillVo.getSpikesId()).set("is_delete",1).update();
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue