购物车缓存 完善1.0

master
rouchen 2024-04-03 08:46:17 +08:00
parent aed910d491
commit 2bfd4882cf
172 changed files with 1812 additions and 271 deletions

View File

@ -1,61 +0,0 @@
package com.muyu.cache;
/**
* CaChe
*
* @author LeYang
* on 2024/3/27
*/
public interface CaChe <K,V> {
/**
* key
* @return key
*/
public String keyPre();
/**
*
* @param key
* @return
*/
public String encode(K key);
/**
*
* @param redisKey
* @return ID
*/
public K decode(String redisKey);
/**
* keyvalue
* @param key
* @return
*/
public V get(K key);
/**
* /
* @param key
* @param value
*/
public void put(K key,V value);
/**
*
* @param key
*/
public void remove(K key);
/**
*
* @param key
*/
public void refreshTime(K key);
/**
*
* @param key
*/
public void refreshDate(K key);
}

View File

@ -0,0 +1,37 @@
package com.muyu.common.cache;
import com.muyu.common.cache.decoration.DecorationKey;
/**
* @author yangle
* @description:
* @Date 2024-4-1 08:07
*/
public interface AtomicSequenceCache<K> extends DecorationKey<K> {
/**
*
* @param key
* @return
*/
public Long get(K key);
/**
*
*/
public Long increment(K key);
/**
*
*/
public Long decrement(K key);
/**
*
*/
public Long increment(K key, Long number);
/**
*
*/
public Long decrement(K key, Long number);
}

View File

@ -0,0 +1,43 @@
package com.muyu.common.cache;
import com.muyu.common.cache.decoration.DecorationKey;
/**
* @author yangle
* @description:
* @Date 2024-3-26 03:25
*/
public interface Cache <K, V> extends DecorationKey<K> {
/**
* Keyvalue
* @param key
* @return
*/
public V get(K key);
/**
* /
* @param key
* @param value
*/
public void put(K key, V value);
/**
*
* @param key
*/
public void remove(K key);
/**
*
* @param key
*/
public void refreshTime (K key);
/**
*
* @param key
*/
public void refreshData (K key);
}

View File

@ -0,0 +1,21 @@
package com.muyu.common.cache;
/**
* GetData
*
* @author LeYang
* on 2024/3/29
*/
public interface GetData<K,V> {
/**
*
* @param key ID
* @return
*/
public abstract V getData(K key);
/**
*
*/
public abstract V defaultValue();
}

View File

@ -0,0 +1,97 @@
package com.muyu.common.cache;
import com.muyu.common.cache.decoration.DecorationKey;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
/**
* @author yangle
* @description: Hash
* @Date 2024-3-29 03:16
*/
public interface HashCache <K, HK, HV> extends DecorationKey<K> {
/**
*
* @param hashKey ID
* @return
*/
public String encodeHashKey(HK hashKey);
/**
*
* @param redisHashKey
* @return ID
*/
public HK decodeHashKey(String redisHashKey);
/**
* Keymap
* @param key
* @return Map
*/
public Map<HK, HV> get(K key);
/**
* hashKeyhashValue
* @param key
* @param hashKey hash
* @return hash
*/
public HV get(K key, HK hashKey);
/**
* hashKeyhashValue
* @param key
* @param hashKeyList hash
* @return hash
*/
public List<HV> get(K key, HK... hashKeyList);
/**
* hash
* @param key
* @return hash
*/
public List<HV> getToList(K key);
/**
*
* @param key redis
* @param map hashMap
*/
public void put(K key, Map<HK, HV> map);
/**
*
* @param key redis
* @param dataList
* @param hashKey hash
*/
public void put(K key, List<HV> dataList, Function<HV, HK> hashKey);
/**
*
* @param key redis
* @param hashKey hash
* @param hashValue hash
*/
public void put(K key, HK hashKey, HV hashValue);
/**
* redis
* @param key hash
*/
public void remove(K key);
/**
* redishash
* @param key redis
* @param hashKey hash
*/
public void remove(K key, HK hashKey);
}

View File

@ -0,0 +1,93 @@
package com.muyu.common.cache.abs;
import com.muyu.common.cache.AtomicSequenceCache;
import com.muyu.common.redis.service.RedisService;
import org.springframework.beans.factory.annotation.Autowired;
/**
* @author yangle
* @description:
* @Date 2024-4-1 08:33
*/
public abstract class AtomicSequenceCacheAbs<K> implements AtomicSequenceCache<K> {
@Autowired
private RedisService redisService;
/**
*
* @param key
* @return
*/
@Override
public Long get (K key) {
return this.redisService.getCacheObject(encode(key));
}
/**
*
* @param key
*/
@Override
public Long increment (K key) {
return this.increment(key, 1L);
}
/**
*
*
* @param key
*/
@Override
public Long decrement (K key) {
return this.decrement(key, 1L);
}
/**
*
*
* @param key
* @param number
*/
@Override
public Long increment (K key, Long number) {
Long numberValue = redisService.getCacheObject(encode(key));
if (numberValue == null){
Long data = getData(key);
data = data == null ? 0L : data;
redisService.setCacheObject(encode(key), data);
}
return redisService.increment(encode(key), number);
}
/**
*
*
* @param key
* @param number
*/
@Override
public Long decrement (K key, Long number) {
Long numberValue = redisService.getCacheObject(encode(key));
if (numberValue == null){
Long data = getData(key);
data = data == null ? 0L : data;
redisService.setCacheObject(encode(key), data);
}
return redisService.decrement(encode(key), number);
}
/**
*
*
* @param key ID
*
* @return
*/
@Override
public String encode (K key) {
return keyPre() + key;
}
public abstract Long getData(K key);
}

View File

@ -1,59 +1,57 @@
package com.muyu.cache.abs;
package com.muyu.common.cache.abs;
import com.muyu.cache.CaChe;
import com.muyu.common.cache.Cache;
import com.muyu.common.redis.service.RedisService;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.concurrent.TimeUnit;
/**
* CacheAbs
*
* @author LeYang
* on 2024/3/27
* @author yangle
* @description:
* @Date 2024-3-27 03:10
*/
public abstract class CacheAbs<K,V> implements CaChe<K,V> {
public abstract class CacheAbs<K, V> implements Cache<K, V> {
@Autowired
private RedisService redisService;
/**
*
* @param key Id
* @return
* @param key ID
* @return
*/
@Override
public String encode(K key) {
return keyPre()+key;
public String encode (K key) {
return keyPre() + key;
}
/**
* keyvalue
* Keyvalue
* @param key
* @return
* @return
*/
@Override
public V get(K key) {
V value= redisService.getCacheObject(encode(key));
public V get (K key) {
V value = redisService.getCacheObject(encode(key));
if (value == null){
value = getData(key);
if (value == null ){
if (value == null){
value = defaultValue();
}
}
this.put(key,value);
this.put(key, value);
return value;
}
/**
* /
* @param key
* @param key
* @param value
*/
@Override
public void put(K key, V value) {
this.redisService.setCacheObject(encode(key), value);
public void put (K key, V value) {
this.redisService.setCacheObject(encode(key), value);
}
/**
@ -61,8 +59,8 @@ public abstract class CacheAbs<K,V> implements CaChe<K,V> {
* @param key
*/
@Override
public void remove(K key) {
this.redisService.deleteObject(encode(key));
public void remove (K key) {
this.redisService.deleteObject(encode(key));
}
/**
@ -70,17 +68,18 @@ public abstract class CacheAbs<K,V> implements CaChe<K,V> {
* @param key
*/
@Override
public void refreshTime(K key) {
this.redisService.expire(encode(key), 60, TimeUnit.SECONDS);
public void refreshTime (K key) {
this.redisService.expire(encode(key), 60, TimeUnit.SECONDS);
}
/**
*
*
* @param key
*/
@Override
public void refreshDate(K key) {
this.put(key,getData(key));
public void refreshData (K key) {
this.put(key, getData(key));
}
/**

View File

@ -0,0 +1,212 @@
package com.muyu.common.cache.abs;
import com.muyu.common.cache.HashCache;
import com.muyu.common.redis.service.RedisService;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
/**
* @author yangle
* @description: hash
* @Date 2024-3-29 07:40
*/
public abstract class HashCacheAbs<K, HK, HV> implements HashCache<K, HK, HV> {
@Autowired
private RedisService redisService;
/**
*
*
* @param key ID
*
* @return
*/
@Override
public String encode (K key) {
return keyPre() + key;
}
/**
*
* @param hashKey ID
* @return
*/
@Override
public String encodeHashKey (HK hashKey) {
return hashKey.toString();
}
/**
* Keymap
* @param key
* @return Map
*/
@Override
public Map<HK, HV> get (K key) {
// 获取为null的情况
Map<String, HV> cacheMap = redisService.getCacheMap(encode(key));
if (cacheMap == null || cacheMap.isEmpty()){
Map<HK, HV> dataMap = getData(key);
if (dataMap != null && !dataMap.isEmpty()){
cacheMap = encodeMap(dataMap);
}else {
cacheMap = encodeMap(defaultValue());
}
redisService.setCacheMap(encode(key), cacheMap);
}
return decodeMap(cacheMap);
}
/**
* hashKeyhashValue
*
* @param key
* @param hashKey hash
*
* @return hash
*/
@Override
public HV get (K key, HK hashKey) {
HV hashValue = redisService.getCacheMapValue(encode(key), encodeHashKey(hashKey));
if (hashValue == null){
HV dataValue = getData(key, hashKey);
hashValue = dataValue != null ? dataValue : defaultHashValue();
put(key, hashKey, hashValue);
}
return hashValue;
}
/**
* hashKeyhashValue
*
* @param key
* @param hashKeyList hash
*
* @return hash
*/
@Override
public List<HV> get (K key, HK... hashKeyList) {
List<String> encodeHashKeyList = Arrays.stream(hashKeyList).map(this::encodeHashKey).toList();
return redisService.getMultiCacheMapValue(encode(key), encodeHashKeyList);
}
/**
* hash
*
* @param key
*
* @return hash
*/
@Override
public List<HV> getToList (K key) {
Map<HK, HV> hkhvMap = get(key);
return hkhvMap.values().stream().toList();
}
/**
*
*
* @param key redis
* @param map hashMap
*/
@Override
public void put (K key, Map<HK, HV> map) {
redisService.setCacheMap(encode(key), encodeMap(map));
}
/**
*
*
* @param key redis
* @param dataList
* @param hashKey hash
*/
@Override
public void put (K key, List<HV> dataList, Function<HV, HK> hashKey) {
Map<HK, HV> dataMap = new HashMap<>();
dataList.forEach((data) -> dataMap.put(hashKey.apply(data), data));
redisService.setCacheMap(encode(key), encodeMap(dataMap));
}
/**
*
*
* @param key redis
* @param hashKey hash
* @param hashValue hash
*/
@Override
public void put (K key, HK hashKey, HV hashValue) {
redisService.setCacheMapValue(encode(key), encodeHashKey(hashKey), hashValue);
}
/**
* redis
*
* @param key hash
*/
@Override
public void remove (K key) {
redisService.deleteObject(encode(key));
}
/**
* redishash
*
* @param key redis
* @param hashKey hash
*/
@Override
public void remove (K key, HK hashKey) {
redisService.deleteCacheMapValue(encode(key), encodeHashKey(hashKey));
}
/**
*
* @param dataMap
* @return
*/
private Map<String, HV> encodeMap(Map<HK, HV> dataMap){
Map<String, HV> encodeDataMap = new HashMap<>();
dataMap.forEach((hashKey, HashValue) -> encodeDataMap.put(encodeHashKey(hashKey), HashValue));
return encodeDataMap;
}
/**
*
* @param encodeDataMap
* @return
*/
private Map<HK, HV> decodeMap(Map<String, HV> encodeDataMap){
Map<HK, HV> dataMap = new HashMap<>();
encodeDataMap.forEach((hashKey, hashValue) -> dataMap.put(decodeHashKey(hashKey), hashValue));
return dataMap;
}
/**
* hash
* @param key
* @return
*/
public abstract Map<HK, HV> getData(K key);
/**
* hashhash
* @param key
* @param hashKey hash
* @return hash
*/
public abstract HV getData(K key, HK hashKey);
/**
*
*/
public abstract Map<HK, HV> defaultValue();
public abstract HV defaultHashValue();
}

View File

@ -0,0 +1,22 @@
package com.muyu.common.cache.abs;
import com.muyu.common.cache.GetData;
/**
* getDataAbs
*
* @author LeYang
* on 2024/4/1
*/
public abstract class getDataAbs<K,V> implements GetData<K,V> {
@Override
public V getData(K key) {
return null;
}
@Override
public V defaultValue() {
return null;
}
}

View File

@ -0,0 +1,30 @@
package com.muyu.common.cache.decoration;
/**
* @author yangle
* @description: Key
* @Date 2024-3-29 03:19
*/
public interface DecorationKey <K>{
/**
* key
* @return key
*/
public String keyPre();
/**
*
* @param key ID
* @return
*/
public String encode(K key);
/**
*
* @param redisKey
* @return ID
*/
public K decode(String redisKey);
}

View File

@ -39,6 +39,9 @@ public class Result<T> implements Serializable {
private T data;
public static <T> Result<T> buildCode(int code,String msg,T data){
return restResult(data,code,msg);
}
public static <T> Result<T> success () {
return restResult(null, SUCCESS, null);
}
@ -93,6 +96,7 @@ public class Result<T> implements Serializable {
return restResult(null, code, msg);
}
private static <T> Result<T> restResult (T data, int code, String msg) {
return Result.<T>builder()
.code(code)

View File

@ -5,7 +5,7 @@ import org.apache.commons.lang3.ObjectUtils;
import java.math.BigDecimal;
/**
* @author DongZl
* @author yangle
* @description:
* @Date 2023-10-9 04:56
*/

View File

@ -229,10 +229,14 @@ public class RedisService {
*
* @return Hash
*/
public <T> List<T> getMultiCacheMapValue (final String key, final Collection<Object> hKeys) {
public <T> List<T> getMultiCacheMapValue (final String key, final Collection<?> hKeys) {
return redisTemplate.opsForHash().multiGet(key, hKeys);
}
public boolean hashKey(final String key,final String hashkey){
return this.redisTemplate.opsForHash().hasKey(key, hashkey);
}
/**
* Hash
*
@ -255,4 +259,24 @@ public class RedisService {
public Collection<String> keys (final String pattern) {
return redisTemplate.keys(pattern);
}
/**
*
* @param key key
* @param number
* @return
*/
public Long decrement(final String key,Long number){
return redisTemplate.opsForValue().decrement(key,number);
}
/**
*
* @param key key
* @param number
* @return
*/
public Long increment(final String key,Long number){
return redisTemplate.opsForValue().increment(key,number);
}
}

View File

@ -6,7 +6,7 @@ import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author DongZl
* @author yangle
* @description:
* @Date 2023-11-12 03:36
*/

View File

@ -16,17 +16,20 @@
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!--缓存基准模块-->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-common-cache</artifactId>
</dependency>
<!--商品模块 common依赖-->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-product-common</artifactId>
</dependency>
</dependencies>
<dependencies>
<!-- 缓存基准模块 -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-common-cache</artifactId>
</dependency>
<!-- 商品模块 common 依赖 -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-product-common</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,88 @@
package com.muyu.product.cache;
import com.muyu.common.cache.abs.HashCacheAbs;
import com.muyu.common.core.text.Convert;
import com.muyu.product.cache.datasource.ProjectSkuData;
import com.muyu.product.domain.ProjectSkuInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
/**
* @author yangle
* @description: sku
* @Date 2024-3-29 03:06
*/
@Component
public class ProjectSkuCache extends HashCacheAbs<Long, String, ProjectSkuInfo> {
@Autowired
private ProjectSkuData projectSkuData;
/**
* key
* @return key
*/
@Override
public String keyPre () {
return "project:sku:";
}
/**
*
* @param redisKey
* @return ID
*/
@Override
public Long decode (String redisKey) {
return Convert.toLong(redisKey.replace(keyPre(), ""));
}
/**
*
* @param redisHashKey
* @return ID
*/
@Override
public String decodeHashKey (String redisHashKey) {
return redisHashKey;
}
/**
* hash
* @param key
* @return
*/
@Override
public Map<String, ProjectSkuInfo> getData (Long key) {
return projectSkuData.getData(key);
}
/**
* hashhash
* @param key
* @param hashKey hash
*
* @return hash
*/
@Override
public ProjectSkuInfo getData (Long key, String hashKey) {
return projectSkuData.getData(key, hashKey);
}
/**
*
*/
@Override
public Map<String, ProjectSkuInfo> defaultValue () {
return new HashMap<>();
}
@Override
public ProjectSkuInfo defaultHashValue () {
return new ProjectSkuInfo();
}
}

View File

@ -0,0 +1,61 @@
package com.muyu.product.cache;
import com.muyu.common.cache.abs.AtomicSequenceCacheAbs;
import com.muyu.common.core.text.Convert;
import com.muyu.product.cache.datasource.ProjectSkuStockData;
import com.muyu.product.cache.key.SkuStockKey;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @author yangle
* @description: SKU
* @Date 2024-3-29 03:06
*/
@Service
public class ProjectSkuStockCache extends AtomicSequenceCacheAbs<SkuStockKey> {
@Autowired
private ProjectSkuStockData projectSkuStockData;
/**
* key
*
* @return key
*/
@Override
public String keyPre () {
return "project:sku:stock:";
}
/**
*
* @param skuStockKey ID
* @return
*/
@Override
public String encode (SkuStockKey skuStockKey) {
return keyPre() + skuStockKey.getProjectId() + ":" + skuStockKey.getSku();
}
@Override
public Long getData (SkuStockKey key) {
return projectSkuStockData.getData(key);
}
/**
*
* @param redisKey
* @return ID
*/
@Override
public SkuStockKey decode (String redisKey) {
String[] split = redisKey.replace(keyPre(), "").split(":");
return SkuStockKey.builder()
.projectId(Convert.toLong(split[0]))
.sku(split[1])
.build();
}
}

View File

@ -1,18 +1,18 @@
package com.muyu.product.cache;
package com.muyu.product.cache.datasource;
import com.muyu.product.domain.ProjectInfo;
/**
* ProjectInfoData
*
* @author LeYang
* on 2024/3/27
* @author yangle
* @description:
* @Date 2024-3-27 03:34
*/
public interface ProjectInfoData {
/**
*
* @param key ID
* @return
*/
public ProjectInfo getData(Long key);
public ProjectInfo getData (Long key);
}

View File

@ -0,0 +1,29 @@
package com.muyu.product.cache.datasource;
import com.muyu.product.domain.ProjectSkuInfo;
import java.util.Map;
/**
* @author yangle
* @description: SKU
* @Date 2024-4-1 11:35
*/
public interface ProjectSkuData {
/**
* hash
* @param projectId ID
* @return
*/
public Map<String, ProjectSkuInfo> getData (Long projectId) ;
/**
* hashhash
* @param projectId ID
* @param projectSku SKU
*
* @return hash
*/
public ProjectSkuInfo getData (Long projectId, String projectSku);
}

View File

@ -0,0 +1,13 @@
package com.muyu.product.cache.datasource;
import com.muyu.product.cache.key.SkuStockKey;
/**
* @author yangle
* @description: SKU
* @Date 2024-4-2 10:52
*/
public interface ProjectSkuStockData {
public Long getData (SkuStockKey key) ;
}

View File

@ -0,0 +1,28 @@
package com.muyu.product.cache.key;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author yangle
* @description: SKUKey
* @Date 2024-4-2 10:41
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class SkuStockKey {
/**
* ID
*/
private Long projectId;
/**
* sku
*/
private String sku;
}

View File

@ -23,5 +23,9 @@
<groupId>com.muyu</groupId>
<artifactId>muyu-common-core</artifactId>
</dependency>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-shop-cart-common</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -15,7 +15,7 @@ import com.muyu.common.core.web.domain.BaseEntity;
/**
* as_attribute_group
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -15,7 +15,7 @@ import com.muyu.common.core.web.domain.BaseEntity;
/**
* as_brand_project
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -16,7 +16,7 @@ import com.muyu.common.core.web.domain.BaseEntity;
/**
* as_category_attribute
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -16,7 +16,7 @@ import com.muyu.common.core.web.domain.BaseEntity;
/**
* as_category_attribute_group
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -16,7 +16,7 @@ import com.muyu.common.core.web.domain.BaseEntity;
/**
* as_category_brand
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -20,7 +20,7 @@ import com.muyu.common.core.web.domain.BaseEntity;
/**
* as_product_attribute_info
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -20,7 +20,7 @@ import com.muyu.common.core.web.domain.BaseEntity;
/**
* attribute_group
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -21,7 +21,7 @@ import com.muyu.common.core.web.domain.BaseEntity;
/**
* attribute_info
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -18,7 +18,7 @@ import com.muyu.common.core.web.domain.BaseEntity;
/**
* brand_info
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -23,7 +23,7 @@ import java.util.function.Supplier;
/**
* category_info
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -18,7 +18,7 @@ import com.muyu.common.core.web.domain.BaseEntity;
/**
* comment_info
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -18,7 +18,7 @@ import com.muyu.common.core.web.domain.BaseEntity;
/**
* comment_like_info
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -22,7 +22,7 @@ import java.util.function.Supplier;
/**
* project_info
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -22,7 +22,7 @@ import com.muyu.common.core.web.domain.BaseEntity;
/**
* SKU project_sku_info
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -22,7 +22,7 @@ import java.util.function.Supplier;
/**
* rule_attr_info
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -22,7 +22,7 @@ import java.util.function.Supplier;
/**
* rule_info
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -1,7 +1,7 @@
package com.muyu.product.domain.base;
/**
* @author DongZl
* @author yangle
* @description: attribute
* @Date 2024-3-1 02:28
*/

View File

@ -14,7 +14,7 @@ import java.util.List;
/**
* @author DongZl
* @author yangle
* @description:
* @Date 2024-2-28 03:16
*/

View File

@ -18,7 +18,7 @@ import java.util.function.Supplier;
/**
* category_info
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -14,7 +14,7 @@ import java.util.List;
/**
* @author DongZl
* @author yangle
* @description:
* @Date 2024-3-4 02:28
*/

View File

@ -12,7 +12,7 @@ import lombok.experimental.SuperBuilder;
import java.util.List;
/**
* @author DongZl
* @author yangle
* @description:
* @Date 2024-3-4 02:33
*/

View File

@ -0,0 +1,47 @@
package com.muyu.product.domain.model;
import com.muyu.common.core.web.domain.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
* ShoppingCardAdd
*
* @author LeYang
* on 2024/3/31
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class ShoppingCardModel extends BaseEntity {
/**
* id
*/
private Integer projectId;
/**
*
*/
private String projectSku;
/**
*
*/
private Integer userId;
/**
*
*/
private Integer num;
/**
*
*/
private Integer isSelected;
}

View File

@ -14,7 +14,7 @@ import java.util.function.Function;
import java.util.function.Supplier;
/**
* @author DongZl
* @author yangle
* @description:
* @Date 2024-3-6 02:29
*/

View File

@ -9,7 +9,7 @@ import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
* @author DongZl
* @author yangle
* @description:
* @Date 2024-3-6 02:30
*/

View File

@ -15,7 +15,7 @@ import com.muyu.common.core.web.domain.BaseEntity;
/**
* attribute_group
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -13,7 +13,7 @@ import com.muyu.common.core.web.domain.BaseEntity;
/**
* attribute_group
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -15,7 +15,7 @@ import com.muyu.common.core.web.domain.BaseEntity;
/**
* attribute_group
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -13,7 +13,7 @@ import com.muyu.common.core.web.domain.BaseEntity;
/**
* attribute_info
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -13,7 +13,7 @@ import com.muyu.common.core.web.domain.BaseEntity;
/**
* attribute_info
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -13,7 +13,7 @@ import com.muyu.common.core.web.domain.BaseEntity;
/**
* attribute_info
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -11,7 +11,7 @@ import com.muyu.common.core.web.domain.BaseEntity;
/**
* brand_info
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -11,7 +11,7 @@ import com.muyu.common.core.web.domain.BaseEntity;
/**
* brand_info
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -11,7 +11,7 @@ import com.muyu.common.core.web.domain.BaseEntity;
/**
* brand_info
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -13,7 +13,7 @@ import java.util.List;
/**
* category_info
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -11,7 +11,7 @@ import com.muyu.common.core.web.domain.TreeEntity;
/**
* category_info
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -13,7 +13,7 @@ import java.util.List;
/**
* category_info
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -11,7 +11,7 @@ import com.muyu.common.core.web.domain.BaseEntity;
/**
* comment_info
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -11,7 +11,7 @@ import com.muyu.common.core.web.domain.BaseEntity;
/**
* comment_info
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -11,7 +11,7 @@ import com.muyu.common.core.web.domain.BaseEntity;
/**
* comment_info
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -11,7 +11,7 @@ import com.muyu.common.core.web.domain.BaseEntity;
/**
* comment_like_info
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -11,7 +11,7 @@ import com.muyu.common.core.web.domain.BaseEntity;
/**
* comment_like_info
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -11,7 +11,7 @@ import com.muyu.common.core.web.domain.BaseEntity;
/**
* comment_like_info
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -16,7 +16,7 @@ import java.util.List;
/**
* project_info
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -11,7 +11,7 @@ import com.muyu.common.core.web.domain.BaseEntity;
/**
* project_info
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -16,7 +16,7 @@ import java.util.List;
/**
* project_info
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -12,7 +12,7 @@ import com.muyu.common.core.web.domain.BaseEntity;
/**
* SKU project_sku_info
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -12,7 +12,7 @@ import com.muyu.common.core.web.domain.BaseEntity;
/**
* SKU project_sku_info
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -12,7 +12,7 @@ import com.muyu.common.core.web.domain.BaseEntity;
/**
* SKU project_sku_info
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -11,7 +11,7 @@ import com.muyu.common.core.web.domain.BaseEntity;
/**
* rule_attr_info
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -11,7 +11,7 @@ import com.muyu.common.core.web.domain.BaseEntity;
/**
* rule_attr_info
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -11,7 +11,7 @@ import com.muyu.common.core.web.domain.BaseEntity;
/**
* rule_attr_info
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -11,7 +11,7 @@ import com.muyu.common.core.web.domain.BaseEntity;
/**
* rule_info
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -11,7 +11,7 @@ import com.muyu.common.core.web.domain.BaseEntity;
/**
* rule_info
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -14,7 +14,7 @@ import java.util.List;
/**
* rule_info
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Data

View File

@ -13,7 +13,7 @@ import java.util.List;
import java.util.function.Function;
/**
* @author DongZl
* @author yangle
* @description:
* @Date 2024-2-28 04:15
*/

View File

@ -9,7 +9,7 @@ import lombok.experimental.SuperBuilder;
import java.util.List;
/**
* @author DongZl
* @author yangle
* @description:
* @Date 2024-3-6 02:25
*/

View File

@ -11,7 +11,7 @@ import lombok.NoArgsConstructor;
import java.util.List;
/**
* @author DongZl
* @author yangle
* @description:
* @Date 2024-3-1 11:02
*/

View File

@ -13,7 +13,7 @@ import java.util.List;
import java.util.function.Function;
/**
* @author DongZl
* @author yangle
* @description:
* @Date 2024-3-4 04:08
*/

View File

@ -0,0 +1,59 @@
package com.muyu.product.domain.resp;
import com.muyu.common.core.web.domain.BaseEntity;
import com.muyu.shop.cart.domain.CartInfo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
* ShoppingCardAdd
*
* @author LeYang
* on 2024/3/31
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class ShoppingCardResp extends BaseEntity {
/**
* id
*/
private Integer projectId;
/**
*
*/
private String projectSku;
/**
*
*/
private Integer userId;
/**
*
*/
private Integer num;
/**
*
*/
private Integer isSelected;
/**
*
*/
private String remark;
/**
*
*/
private String createBy;
}

View File

@ -18,11 +18,12 @@
</properties>
<dependencies>
<!--商品模块 缓存 依赖-->
<!-- 商品模块 缓存 依赖 -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-product-cache</artifactId>
</dependency>
<!-- 商品模块 common 依赖 -->
<dependency>
<groupId>com.muyu</groupId>
@ -89,18 +90,6 @@
<groupId>com.muyu</groupId>
<artifactId>muyu-common-swagger</artifactId>
</dependency>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-product-cache</artifactId>
<version>3.6.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-product-cache</artifactId>
<version>3.6.3</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>

View File

@ -8,7 +8,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
/**
* @author DongZl
* @author yangle
* @description:
* @Date 2024-2-26 04:07
*/

View File

@ -1,18 +1,19 @@
package com.muyu.product.cache;
package com.muyu.product.cache.impl;
import com.muyu.product.cache.datasource.ProjectInfoData;
import com.muyu.product.domain.ProjectInfo;
import com.muyu.product.service.ProjectInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* ProjectInfoDataImpl
*
* @author LeYang
* on 2024/3/27
* @author yangle
* @description:
* @Date 2024-3-27 03:37
*/
@Service
public class ProjectInfoDataImpl implements ProjectInfoData{
public class ProjectInfoDataImpl implements ProjectInfoData {
@Autowired
private ProjectInfoService projectInfoService;
@ -22,7 +23,7 @@ public class ProjectInfoDataImpl implements ProjectInfoData{
* @return
*/
@Override
public ProjectInfo getData(Long key){
public ProjectInfo getData (Long key) {
return projectInfoService.getById(key);
}
}

View File

@ -0,0 +1,52 @@
package com.muyu.product.cache.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.muyu.product.cache.datasource.ProjectSkuData;
import com.muyu.product.domain.ProjectSkuInfo;
import com.muyu.product.service.ProjectSkuInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author yangle
* @description: SKU
* @Date 2024-4-1 11:38
*/
@Service
public class ProjectSkuDataImpl implements ProjectSkuData {
@Autowired
private ProjectSkuInfoService projectSkuInfoService;
/**
* hash
* @param projectId ID
* @return
*/
@Override
public Map<String, ProjectSkuInfo> getData (Long projectId) {
LambdaQueryWrapper<ProjectSkuInfo> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(ProjectSkuInfo::getProjectId, projectId);
List<ProjectSkuInfo> projectSkuInfoList = projectSkuInfoService.list(queryWrapper);
return projectSkuInfoList.stream()
.collect(Collectors.toMap(ProjectSkuInfo::getSku, projectSkuInfo -> projectSkuInfo));
}
/**
* hashhash
* @param projectId ID
* @param projectSku SKU
* @return hash
*/
@Override
public ProjectSkuInfo getData (Long projectId, String projectSku) {
LambdaQueryWrapper<ProjectSkuInfo> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(ProjectSkuInfo::getProjectId, projectId);
queryWrapper.eq(ProjectSkuInfo::getSku, projectSku);
return projectSkuInfoService.getOne(queryWrapper);
}
}

View File

@ -0,0 +1,30 @@
package com.muyu.product.cache.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.muyu.product.cache.datasource.ProjectSkuStockData;
import com.muyu.product.cache.key.SkuStockKey;
import com.muyu.product.domain.ProjectSkuInfo;
import com.muyu.product.service.ProjectSkuInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @author yangle
* @description: sku
* @Date 2024-4-2 10:53
*/
@Service
public class ProjectSkuStockDataImpl implements ProjectSkuStockData {
@Autowired
private ProjectSkuInfoService projectSkuInfoService;
@Override
public Long getData (SkuStockKey key) {
LambdaQueryWrapper<ProjectSkuInfo> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(ProjectSkuInfo::getProjectId, key.getProjectId());
queryWrapper.eq(ProjectSkuInfo::getSku, key.getSku());
ProjectSkuInfo projectSkuInfo = projectSkuInfoService.getOne(queryWrapper);
return projectSkuInfo.getStock();
}
}

View File

@ -31,7 +31,7 @@ import com.muyu.common.core.web.page.TableDataInfo;
/**
* Controller
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Api(tags = "属性组")

View File

@ -29,7 +29,7 @@ import com.muyu.common.core.web.page.TableDataInfo;
/**
* Controller
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Api(tags = "商品属性")

View File

@ -30,7 +30,7 @@ import com.muyu.common.core.web.page.TableDataInfo;
/**
* Controller
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Api(tags = "品牌信息")

View File

@ -36,7 +36,7 @@ import com.muyu.product.service.CategoryInfoService;
/**
* Controller
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Api(tags = "品类信息")

View File

@ -29,7 +29,7 @@ import com.muyu.common.core.web.page.TableDataInfo;
/**
* Controller
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Api(tags = "商品评论")

View File

@ -29,7 +29,7 @@ import com.muyu.common.core.web.page.TableDataInfo;
/**
* Controller
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Api(tags = "评论点赞")

View File

@ -6,14 +6,11 @@ import javax.servlet.http.HttpServletResponse;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.muyu.product.domain.AsProductAttributeInfo;
import com.muyu.product.domain.ProjectSkuInfo;
import com.muyu.product.domain.model.CategoryInfoSaveModel;
import com.muyu.product.domain.model.ProductSkuModel;
import com.muyu.product.domain.model.ProjectAddModel;
import com.muyu.product.domain.resp.ProjectDetailResp;
import com.muyu.product.service.AsProductAttributeInfoService;
import com.muyu.product.service.ProjectSkuInfoService;
import io.swagger.annotations.*;
import org.apache.commons.lang3.SystemUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@ -39,7 +36,7 @@ import com.muyu.common.core.web.page.TableDataInfo;
/**
* Controller
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Api(tags = "商品信息")
@ -162,4 +159,8 @@ public class ProjectInfoController extends BaseController {
projectInfoService.del(ids);
return toAjax(projectInfoService.removeBatchByIds(ids));
}
}

View File

@ -29,7 +29,7 @@ import com.muyu.common.core.web.page.TableDataInfo;
/**
* SKUController
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Api(tags = "商品SKU")

View File

@ -29,7 +29,7 @@ import com.muyu.common.core.web.page.TableDataInfo;
/**
* Controller
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Api(tags = "规格详情")

View File

@ -32,7 +32,7 @@ import com.muyu.common.core.web.page.TableDataInfo;
/**
* Controller
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
@Api(tags = "商品规格")

View File

@ -7,7 +7,7 @@ import com.muyu.product.domain.AsAttributeGroup;
/**
* Mapper
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
public interface AsAttributeGroupMapper extends BaseMapper<AsAttributeGroup> {

View File

@ -7,7 +7,7 @@ import com.muyu.product.domain.AsBrandProject;
/**
* Mapper
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
public interface AsBrandProjectMapper extends BaseMapper<AsBrandProject> {

View File

@ -7,7 +7,7 @@ import com.muyu.product.domain.AsCategoryAttributeGroup;
/**
* Mapper
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
public interface AsCategoryAttributeGroupMapper extends BaseMapper<AsCategoryAttributeGroup> {

View File

@ -7,7 +7,7 @@ import com.muyu.product.domain.AsCategoryAttribute;
/**
* Mapper
*
* @author DongZeLiang
* @author yangle
* @date 2024-02-27
*/
public interface AsCategoryAttributeMapper extends BaseMapper<AsCategoryAttribute> {

Some files were not shown because too many files have changed in this diff Show More