添加购物车

master
rouchen 2024-04-10 19:51:01 +08:00
parent bef7a05ae6
commit 7bad69d731
97 changed files with 534 additions and 461 deletions

View File

@ -22,12 +22,12 @@ public abstract class AtomicSequenceCacheAbs<K> implements AtomicSequenceCache<K
@Override @Override
public Long get (K key) { public Long get (K key) {
Long cacheValue = this.redisService.getCacheObject(encode(key)); Long cacheValue = this.redisService.getCacheObject(encode(key));
if (cacheValue == null ){ if (cacheValue == null){
Long data = getData(key); Long data = getData(key);
cacheValue = data == null ? 0L : data; cacheValue = data == null ? 0L : data;
this.redisService.setCacheObject(encode(key), cacheValue); this.redisService.setCacheObject(encode(key), cacheValue);
} }
return redisService.increment(encode(key), cacheValue); return cacheValue;
} }
/** /**

View File

@ -4,10 +4,7 @@ import com.muyu.common.cache.HashCache;
import com.muyu.common.redis.service.RedisService; import com.muyu.common.redis.service.RedisService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import java.util.Arrays; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function; import java.util.function.Function;
/** /**
@ -22,7 +19,9 @@ public abstract class HashCacheAbs<K, HK, HV> implements HashCache<K, HK, HV> {
/** /**
* *
*
* @param key ID * @param key ID
*
* @return * @return
*/ */
@Override @Override
@ -166,14 +165,14 @@ public abstract class HashCacheAbs<K, HK, HV> implements HashCache<K, HK, HV> {
} }
/** /**
* reidshashKey * redishashKey
* @param key redis *
* @param key redis
* @param hashKey hash * @param hashKey hash
* @return
*/ */
@Override @Override
public boolean hasKey(K key, HK hashKey) { public boolean hasKey (K key, HK hashKey) {
return redisService.hasKey(encode(key),encodeHashKey(hashKey)); return redisService.hashKey(encode(key), encodeHashKey(hashKey));
} }
/** /**

View File

@ -1,37 +1,20 @@
package com.muyu.product.cache; package com.muyu.product.cache;
import com.muyu.common.cache.HashCache;
import com.muyu.common.cache.abs.CacheAbs; import com.muyu.common.cache.abs.CacheAbs;
import com.muyu.common.core.text.Convert; import com.muyu.common.core.text.Convert;
import com.muyu.product.cache.datasource.ProjectInfoData; import com.muyu.product.cache.datasource.ProjectInfoData;
import com.muyu.product.domain.ProjectInfo; import com.muyu.product.domain.ProjectInfo;
import com.muyu.product.domain.ProjectSkuInfo;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
/** /**
* @author yangle * @author DongZl
* @description: * @description:
* @Date 2024-3-27 03:30 * @Date 2024-3-27 03:30
*/ */
@Component @Component
public class ProjectInfoCache extends CacheAbs<Long, ProjectInfo> { public class ProjectInfoCache extends CacheAbs<Long, ProjectInfo> {
public static void main (String[] args) {
Long projectId = 10L;
HashCache<Long, Long, ProjectSkuInfo> hashCache = null;
List<ProjectSkuInfo> projectSkuInfoList = new ArrayList<>(){{
add(new ProjectSkuInfo());
add(new ProjectSkuInfo());
}};
hashCache.put(projectId, projectSkuInfoList, ProjectSkuInfo::getProjectId);
Long[] longArr = new Long[]{10L,11L,12L,13L,14L,15L};
hashCache.get(projectId, longArr);
}
@Autowired @Autowired
private ProjectInfoData projectInfoData; private ProjectInfoData projectInfoData;

View File

@ -11,7 +11,7 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
/** /**
* @author yangle * @author DongZl
* @description: sku * @description: sku
* @Date 2024-3-29 03:06 * @Date 2024-3-29 03:06
*/ */

View File

@ -8,7 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
/** /**
* @author yangle * @author DongZl
* @description: SKU * @description: SKU
* @Date 2024-3-29 03:06 * @Date 2024-3-29 03:06
*/ */

View File

@ -7,43 +7,23 @@ import com.muyu.product.cache.model.RuleCacheModel;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
/** /**
* RuleInfoCache * @author DongZl
* * @description:
* @author LeYang * @Date 2024/4/7 8:29
* on 2024/4/8
*/ */
public class RuleInfoCache extends CacheAbs<Long, RuleCacheModel> {
public class RuleInfoCache extends CacheAbs<Long, RuleCacheModel> {
@Autowired @Autowired
private RuleCacheData ruleCacheData; private RuleCacheData ruleCacheData;
/** /**
* * key
* @param key ID *
* @return * @return key
*/ */
@Override @Override
public RuleCacheModel getData(Long key) { public String keyPre () {
return ruleCacheData.getRulerCacheModel(key); return "rule:info:";
}
/**
*
* @return
*/
@Override
public RuleCacheModel defaultValue() {
return new RuleCacheModel();
}
/**
*
* @return key
*/
@Override
public String keyPre() {
return "rule:info";
} }
/** /**
@ -52,7 +32,29 @@ public class RuleInfoCache extends CacheAbs<Long, RuleCacheModel> {
* @return ID * @return ID
*/ */
@Override @Override
public Long decode(String redisKey) { public Long decode (String redisKey) {
return Convert.toLong(redisKey.replace(keyPre(), "")); return Convert.toLong(redisKey.replace(keyPre(), ""));
} }
/**
*
*
* @param key ID
*
* @return
*/
@Override
public RuleCacheModel getData (Long key) {
return ruleCacheData.getRuleCacheModel(key);
}
/**
*
*/
@Override
public RuleCacheModel defaultValue () {
return new RuleCacheModel();
}
} }

View File

@ -3,7 +3,7 @@ package com.muyu.product.cache.datasource;
import com.muyu.product.domain.ProjectInfo; import com.muyu.product.domain.ProjectInfo;
/** /**
* @author yangle * @author DongZl
* @description: * @description:
* @Date 2024-3-27 03:34 * @Date 2024-3-27 03:34
*/ */

View File

@ -5,7 +5,7 @@ import com.muyu.product.domain.ProjectSkuInfo;
import java.util.Map; import java.util.Map;
/** /**
* @author yangle * @author DongZl
* @description: SKU * @description: SKU
* @Date 2024-4-1 11:35 * @Date 2024-4-1 11:35
*/ */

View File

@ -3,7 +3,7 @@ package com.muyu.product.cache.datasource;
import com.muyu.product.cache.key.SkuStockKey; import com.muyu.product.cache.key.SkuStockKey;
/** /**
* @author yangle * @author DongZl
* @description: SKU * @description: SKU
* @Date 2024-4-2 10:52 * @Date 2024-4-2 10:52
*/ */

View File

@ -3,14 +3,11 @@ package com.muyu.product.cache.datasource;
import com.muyu.product.cache.model.RuleCacheModel; import com.muyu.product.cache.model.RuleCacheModel;
/** /**
* RuleCacheData * @author DongZl
* * @description:
* @author LeYang * @Date 2024/4/7 8:31
* on 2024/4/8
*/ */
public interface RuleCacheData { public interface RuleCacheData {
public RuleCacheModel getRulerCacheModel(Long ruleId); public RuleCacheModel getRuleCacheModel(Long ruleId);
} }

View File

@ -1,24 +1,14 @@
package com.muyu.product.cache.datasource.impl; package com.muyu.product.cache.datasource.impl;
import com.muyu.common.core.domain.Result; import com.muyu.common.core.domain.Result;
import com.muyu.product.cache.datasource.ProjectInfoData; import com.muyu.product.cache.datasource.ProjectInfoData;
import com.muyu.product.cache.datasource.ProjectSkuData;
import com.muyu.product.domain.ProjectInfo; import com.muyu.product.domain.ProjectInfo;
import com.muyu.product.domain.ProjectSkuInfo;
import com.muyu.product.remote.RemoteProjectInfoService; import com.muyu.product.remote.RemoteProjectInfoService;
import com.muyu.product.remote.RemoteProjectSkuService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/** /**
* @author yangle * @author DongZl
* @description: * @description:
* @Date 2024-3-27 03:37 * @Date 2024-3-27 03:37
*/ */

View File

@ -1,12 +1,8 @@
package com.muyu.product.cache.datasource.impl; package com.muyu.product.cache.datasource.impl;
import com.muyu.common.core.domain.Result; import com.muyu.common.core.domain.Result;
import com.muyu.product.cache.datasource.ProjectInfoData;
import com.muyu.product.cache.datasource.ProjectSkuData; import com.muyu.product.cache.datasource.ProjectSkuData;
import com.muyu.product.domain.ProjectInfo;
import com.muyu.product.domain.ProjectSkuInfo; import com.muyu.product.domain.ProjectSkuInfo;
import com.muyu.product.remote.RemoteProjectInfoService;
import com.muyu.product.remote.RemoteProjectSkuService; import com.muyu.product.remote.RemoteProjectSkuService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -17,7 +13,7 @@ import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
* @author yangle * @author DongZl
* @description: SKU * @description: SKU
* @Date 2024-4-1 11:38 * @Date 2024-4-1 11:38
*/ */

View File

@ -1,6 +1,5 @@
package com.muyu.product.cache.datasource.impl; package com.muyu.product.cache.datasource.impl;
import com.muyu.common.core.domain.Result; import com.muyu.common.core.domain.Result;
import com.muyu.product.cache.datasource.ProjectSkuStockData; import com.muyu.product.cache.datasource.ProjectSkuStockData;
import com.muyu.product.cache.key.SkuStockKey; import com.muyu.product.cache.key.SkuStockKey;
@ -12,7 +11,7 @@ import org.springframework.stereotype.Service;
import java.util.Objects; import java.util.Objects;
/** /**
* @author yangle * @author DongZl
* @description: sku * @description: sku
* @Date 2024-4-2 10:53 * @Date 2024-4-2 10:53
*/ */

View File

@ -13,10 +13,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import java.util.List; import java.util.List;
/** /**
* RuleCacheDataImpl * @author DongZl
* * @description:
* @author LeYang * @Date 2024/4/7 8:32
* on 2024/4/8
*/ */
public class RuleCacheDataRemoteImpl implements RuleCacheData { public class RuleCacheDataRemoteImpl implements RuleCacheData {
@ -26,10 +25,8 @@ public class RuleCacheDataRemoteImpl implements RuleCacheData {
@Autowired @Autowired
private RemoteRuleAttrService remoteRuleAttrService; private RemoteRuleAttrService remoteRuleAttrService;
@Override @Override
public RuleCacheModel getRulerCacheModel(Long ruleId) { public RuleCacheModel getRuleCacheModel (Long ruleId) {
Result<RuleInfo> ruleInfoResult = remoteRuleService.getInfo(ruleId); Result<RuleInfo> ruleInfoResult = remoteRuleService.getInfo(ruleId);
Result<List<RuleAttrInfo>> ruleAttrResult = remoteRuleAttrService.getInfoByRuleId(ruleId); Result<List<RuleAttrInfo>> ruleAttrResult = remoteRuleAttrService.getInfoByRuleId(ruleId);
if (Result.isError(ruleInfoResult) || Result.isError(ruleAttrResult)) { if (Result.isError(ruleInfoResult) || Result.isError(ruleAttrResult)) {

View File

@ -6,7 +6,7 @@ import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
/** /**
* @author yangle * @author DongZl
* @description: SKUKey * @description: SKUKey
* @Date 2024-4-2 10:41 * @Date 2024-4-2 10:41
*/ */

View File

@ -10,16 +10,16 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
/** /**
* * @author DongZl
* * @description:
* @author LeYang * @Date 2024/4/7 8:41
* on 2024/4/8
*/ */
@Data @Data
@Builder @Builder
@AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor
public class RuleAttrCacheModel { public class RuleAttrCacheModel {
/** /**
* *
*/ */
@ -28,15 +28,12 @@ public class RuleAttrCacheModel {
/** /**
* *
*/ */
private List<String> attrValueList; private List<String> attrValueList;
public static RuleAttrCacheModel ruleAttrBuild(RuleAttrInfo ruleAttrInfo){ public static RuleAttrCacheModel ruleAttrBuild (RuleAttrInfo ruleAttrInfo) {
return RuleAttrCacheModel.builder() return RuleAttrCacheModel.builder()
.attrName(ruleAttrInfo.getName()) .attrName(ruleAttrInfo.getName())
.attrValueList(Arrays.stream(ruleAttrInfo.getAttrValue().split(",")).toList()) .attrValueList(Arrays.stream(ruleAttrInfo.getAttrValue().split(",")).toList())
.build(); .build();
} }
} }

View File

@ -8,20 +8,21 @@ import lombok.NoArgsConstructor;
import java.util.List; import java.util.List;
/** /**
* RuleCacheModel * @author DongZl
* * @description:
* @author LeYang * @Date 2024/4/7 8:27
* on 2024/4/8
*/ */
@Data @Data
@Builder @Builder
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class RuleCacheModel { public class RuleCacheModel {
/** /**
* *
*/ */
private String ruleName; private String ruleName;
/** /**
* *
*/ */

View File

@ -4,18 +4,15 @@ import com.muyu.common.core.constant.ServiceNameConstants;
import com.muyu.common.core.domain.Result; import com.muyu.common.core.domain.Result;
import com.muyu.product.domain.ProjectInfo; import com.muyu.product.domain.ProjectInfo;
import com.muyu.product.remote.factory.RemoteProjectInfoFactory; import com.muyu.product.remote.factory.RemoteProjectInfoFactory;
import com.muyu.product.remote.factory.RemoteProjectSkuFactory;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
/** /**
* * @author DongZl
* * @description:
* @author LeYang * @Date 2024-4-7 10:58
* on 2024/4/8
*/ */
@FeignClient( @FeignClient(
contextId = "remoteProjectInfoService", contextId = "remoteProjectInfoService",
value = ServiceNameConstants.PRODUCT_SERVICE, value = ServiceNameConstants.PRODUCT_SERVICE,
@ -26,7 +23,7 @@ public interface RemoteProjectInfoService {
/** /**
* *
*/ */
@GetMapping(value = "/{id}") @GetMapping(value = "/{id}")
public Result<ProjectInfo> getInfo(@PathVariable("id") Long id); public Result<ProjectInfo> getInfo(@PathVariable("id") Long id) ;
} }

View File

@ -11,10 +11,9 @@ import org.springframework.web.bind.annotation.PathVariable;
import java.util.List; import java.util.List;
/** /**
* RemoteProjectSkuService * @author DongZl
* * @description:
* @author LeYang * @Date 2024-4-7 10:58
* on 2024/4/7
*/ */
@FeignClient( @FeignClient(
contextId = "remoteProjectSkuService", contextId = "remoteProjectSkuService",
@ -23,21 +22,21 @@ import java.util.List;
path = "/sku" path = "/sku"
) )
public interface RemoteProjectSkuService { public interface RemoteProjectSkuService {
/** /**
* IDskusku * IDSKUSKU
* @param projectId id * @param projectId ID
* @param projectSku sku * @param projectSku SKU
* @return sku * @return SKU
*/ */
@GetMapping("/info/{projectId}/{projectSku}") @GetMapping("/info/{projectId}/{projectSku}")
public Result<ProjectSkuInfo> getInfoByProjectIdAndSku(@PathVariable("projectId") Long projectId, public Result<ProjectSkuInfo> getInfoByProjectIdAndSku(@PathVariable("projectId") Long projectId,
@PathVariable("projectSku") String projectSku); @PathVariable("projectSku") String projectSku);
/** /**
* IDSKU * IDSKUSKU
* @param projectId ID * @param projectId ID
* @return SKU * @return SKU
*/ */
@GetMapping("/list/{projectId}") @GetMapping("/list/{projectId}")
public Result<List<ProjectSkuInfo>> listByProjectId(@PathVariable("projectId")Long projectId); public Result<List<ProjectSkuInfo>> listByProjectId(@PathVariable("projectId") Long projectId);
} }

View File

@ -2,8 +2,12 @@ package com.muyu.product.remote;
import com.muyu.common.core.constant.ServiceNameConstants; import com.muyu.common.core.constant.ServiceNameConstants;
import com.muyu.common.core.domain.Result; import com.muyu.common.core.domain.Result;
import com.muyu.product.domain.ProjectSkuInfo;
import com.muyu.product.domain.RuleAttrInfo; import com.muyu.product.domain.RuleAttrInfo;
import com.muyu.product.remote.factory.RemoteProjectSkuFactory;
import com.muyu.product.remote.factory.RemoteRuleAttrFactory; import com.muyu.product.remote.factory.RemoteRuleAttrFactory;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
@ -11,10 +15,9 @@ import org.springframework.web.bind.annotation.PathVariable;
import java.util.List; import java.util.List;
/** /**
* * @author DongZl
* * @description:
* @author LeYang * @Date 2024-4-7 10:58
* on 2024/4/8
*/ */
@FeignClient( @FeignClient(
contextId = "remoteRuleAttrService", contextId = "remoteRuleAttrService",
@ -23,6 +26,9 @@ import java.util.List;
path = "/ruleAttr" path = "/ruleAttr"
) )
public interface RemoteRuleAttrService { public interface RemoteRuleAttrService {
/**
*
*/
@GetMapping(value = "/list/ruleId/{ruleId}") @GetMapping(value = "/list/ruleId/{ruleId}")
public Result<List<RuleAttrInfo>> getInfoByRuleId(@PathVariable("id") Long id); public Result<List<RuleAttrInfo>> getInfoByRuleId(@PathVariable("ruleId") Long id);
} }

View File

@ -2,17 +2,20 @@ package com.muyu.product.remote;
import com.muyu.common.core.constant.ServiceNameConstants; import com.muyu.common.core.constant.ServiceNameConstants;
import com.muyu.common.core.domain.Result; import com.muyu.common.core.domain.Result;
import com.muyu.product.domain.ProjectSkuInfo;
import com.muyu.product.domain.RuleInfo; import com.muyu.product.domain.RuleInfo;
import com.muyu.product.remote.factory.RemoteProjectSkuFactory;
import com.muyu.product.remote.factory.RemoteRuleFactory; import com.muyu.product.remote.factory.RemoteRuleFactory;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
/** /**
* * @author DongZl
* * @description:
* @author LeYang * @Date 2024-4-7 10:58
* on 2024/4/8
*/ */
@FeignClient( @FeignClient(
contextId = "remoteRuleService", contextId = "remoteRuleService",
@ -22,8 +25,8 @@ import org.springframework.web.bind.annotation.PathVariable;
) )
public interface RemoteRuleService { public interface RemoteRuleService {
/** /**
* *
*/ */
@GetMapping(value = "/{id}") @GetMapping(value = "/{id}")
public Result<RuleInfo> getInfo(@PathVariable("id") Long id ); public Result<RuleInfo> getInfo(@PathVariable("id") Long id);
} }

View File

@ -2,29 +2,30 @@ package com.muyu.product.remote.factory;
import com.muyu.common.core.domain.Result; import com.muyu.common.core.domain.Result;
import com.muyu.product.domain.ProjectInfo; import com.muyu.product.domain.ProjectInfo;
import com.muyu.product.domain.RuleInfo;
import com.muyu.product.remote.RemoteProjectInfoService; import com.muyu.product.remote.RemoteProjectInfoService;
import com.muyu.product.remote.RemoteRuleService;
import org.springframework.cloud.openfeign.FallbackFactory; import org.springframework.cloud.openfeign.FallbackFactory;
/** /**
* RemoteProjectInfoFactory * @author DongZl
* * @description:
* @author LeYang * @Date 2024-4-7 10:59
* on 2024/4/8
*/ */
public class RemoteProjectInfoFactory implements FallbackFactory<RemoteProjectInfoService> { public class RemoteProjectInfoFactory implements FallbackFactory<RemoteProjectInfoService> {
@Override @Override
public RemoteProjectInfoService create(Throwable cause) { public RemoteProjectInfoService create (Throwable cause) {
return new RemoteProjectInfoService() { return new RemoteProjectInfoService() {
/**
* /**
* @param id *
* @return *
*/ * @param id
@Override */
public Result<ProjectInfo> getInfo(Long id) { @Override
return Result.error(cause.getMessage()); public Result<ProjectInfo> getInfo (Long id) {
} return Result.error(cause.getMessage());
}; }
};
} }
} }

View File

@ -5,31 +5,31 @@ import com.muyu.product.domain.ProjectSkuInfo;
import com.muyu.product.remote.RemoteProjectSkuService; import com.muyu.product.remote.RemoteProjectSkuService;
import org.springframework.cloud.openfeign.FallbackFactory; import org.springframework.cloud.openfeign.FallbackFactory;
import java.rmi.Remote;
import java.util.List; import java.util.List;
/** /**
* RemoteProjectSkuFactory * @author DongZl
* * @description:
* @author LeYang * @Date 2024-4-7 10:59
* on 2024/4/7
*/ */
public class RemoteProjectSkuFactory implements FallbackFactory<RemoteProjectSkuService> { public class RemoteProjectSkuFactory implements FallbackFactory<RemoteProjectSkuService> {
@Override @Override
public RemoteProjectSkuService create(Throwable cause) { public RemoteProjectSkuService create (Throwable cause) {
return new RemoteProjectSkuService() { return new RemoteProjectSkuService() {
@Override @Override
public Result<ProjectSkuInfo> getInfoByProjectIdAndSku(Long projectId, String projectSku) { public Result<ProjectSkuInfo> getInfoByProjectIdAndSku (Long projectId, String projectSku) {
return Result.error(cause.getMessage()); return Result.error(cause.getMessage());
} }
/** /**
* IDskusku * IDSKUSKU
*
* @param projectId ID * @param projectId ID
* @return sku *
* @return SKU
*/ */
@Override @Override
public Result<List<ProjectSkuInfo>> listByProjectId(Long projectId) { public Result<List<ProjectSkuInfo>> listByProjectId (Long projectId) {
return Result.error(cause.getMessage()); return Result.error(cause.getMessage());
} }
}; };

View File

@ -1,29 +1,32 @@
package com.muyu.product.remote.factory; package com.muyu.product.remote.factory;
import com.muyu.common.core.domain.Result; import com.muyu.common.core.domain.Result;
import com.muyu.product.domain.ProjectSkuInfo;
import com.muyu.product.domain.RuleAttrInfo; import com.muyu.product.domain.RuleAttrInfo;
import com.muyu.product.remote.RemoteProjectSkuService;
import com.muyu.product.remote.RemoteRuleAttrService; import com.muyu.product.remote.RemoteRuleAttrService;
import com.muyu.product.remote.RemoteRuleService;
import org.springframework.cloud.openfeign.FallbackFactory; import org.springframework.cloud.openfeign.FallbackFactory;
import java.util.List; import java.util.List;
/** /**
* RemoteRuleAttrFactory * @author DongZl
* * @description:
* @author LeYang * @Date 2024-4-7 10:59
* on 2024/4/8
*/ */
public class RemoteRuleAttrFactory implements FallbackFactory<RemoteRuleAttrService> { public class RemoteRuleAttrFactory implements FallbackFactory<RemoteRuleAttrService> {
@Override @Override
public RemoteRuleAttrService create(Throwable cause) { public RemoteRuleAttrService create (Throwable cause) {
return new RemoteRuleAttrService() { return new RemoteRuleAttrService() {
/** /**
* *
*
* @param id * @param id
* @return
*/ */
@Override @Override
public Result<List<RuleAttrInfo>> getInfoByRuleId(Long id) { public Result<List<RuleAttrInfo>> getInfoByRuleId (Long id) {
return Result.error(cause.getMessage()); return Result.error(cause.getMessage());
} }
}; };

View File

@ -1,28 +1,29 @@
package com.muyu.product.remote.factory; package com.muyu.product.remote.factory;
import com.muyu.common.core.domain.Result; import com.muyu.common.core.domain.Result;
import com.muyu.product.domain.ProjectSkuInfo;
import com.muyu.product.domain.RuleInfo; import com.muyu.product.domain.RuleInfo;
import com.muyu.product.remote.RemoteProjectSkuService;
import com.muyu.product.remote.RemoteRuleService; import com.muyu.product.remote.RemoteRuleService;
import org.springframework.cloud.openfeign.FallbackFactory; import org.springframework.cloud.openfeign.FallbackFactory;
/** /**
* * @author DongZl
* * @description:
* @author LeYang * @Date 2024-4-7 10:59
* on 2024/4/8
*/ */
public class RemoteRuleFactory implements FallbackFactory<RemoteRuleService> { public class RemoteRuleFactory implements FallbackFactory<RemoteRuleService> {
@Override @Override
public RemoteRuleService create(Throwable cause) { public RemoteRuleService create (Throwable cause) {
return new RemoteRuleService() { return new RemoteRuleService() {
/** /**
* *
*
* @param id * @param id
* @return
*/ */
@Override @Override
public Result<RuleInfo> getInfo(Long id) { public Result<RuleInfo> getInfo (Long id) {
return Result.error(cause.getMessage()); return Result.error(cause.getMessage());
} }
}; };

View File

@ -1,4 +1,4 @@
com.muyu.product.remote.factory.RemoteRuleFactory
com.muyu.product.remote.factory.RemoteRuleAttrFactory
com.muyu.product.remote.factory.RemoteProjectInfoFactory
com.muyu.product.remote.factory.RemoteProjectSkuFactory com.muyu.product.remote.factory.RemoteProjectSkuFactory
com.muyu.product.remote.factory.RemoteRuleAttrFactory
com.muyu.product.remote.factory.RemoteRuleFactory
com.muyu.product.remote.factory.RemoteProjectInfoFactory

View File

@ -5,10 +5,9 @@ import com.muyu.common.security.annotation.EnableMyFeignClients;
import com.muyu.common.swagger.annotation.EnableCustomSwagger2; import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
/** /**
* @author yangle * @author DongZl
* @description: * @description:
* @Date 2024-2-26 04:07 * @Date 2024-2-26 04:07
*/ */

View File

@ -8,7 +8,7 @@ import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
/** /**
* @author yangle * @author DongZl
* @description: * @description:
* @Date 2024-3-27 03:37 * @Date 2024-3-27 03:37
*/ */

View File

@ -13,7 +13,7 @@ import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
* @author yangle * @author DongZl
* @description: SKU * @description: SKU
* @Date 2024-4-1 11:38 * @Date 2024-4-1 11:38
*/ */

View File

@ -9,7 +9,7 @@ import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
/** /**
* @author yangle * @author DongZl
* @description: sku * @description: sku
* @Date 2024-4-2 10:53 * @Date 2024-4-2 10:53
*/ */

View File

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

View File

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

View File

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

View File

@ -36,7 +36,7 @@ import com.muyu.product.service.CategoryInfoService;
/** /**
* Controller * Controller
* *
* @author yangle * @author DongZeLiang
* @date 2024-02-27 * @date 2024-02-27
*/ */
@Api(tags = "品类信息") @Api(tags = "品类信息")
@ -116,20 +116,18 @@ public class CategoryInfoController extends BaseController {
categoryInfoService.util(id,categoryInfoEditReq); categoryInfoService.util(id,categoryInfoEditReq);
return toAjax(categoryInfoService.updateById(CategoryInfo.editBuild(id,categoryInfoEditReq))); return toAjax(categoryInfoService.updateById(CategoryInfo.editBuild(id,categoryInfoEditReq)));
} }
/** /**
* *
*/ */
@RequiresPermissions("product:category:remove") @RequiresPermissions("product:category:remove")
@Log(title = "品类信息", businessType = BusinessType.DELETE) @Log(title = "品类信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}") @DeleteMapping("/{ids}")
@ApiOperation("删除品类信息") @ApiOperation("删除品类信息")
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4") @ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4")
public Result<String> remove(@PathVariable List<Long> ids) { public Result<String> remove(@PathVariable List<Long> ids) {
categoryInfoService.removeBatchById(ids);
return toAjax(categoryInfoService.removeBatchByIds(ids)); return toAjax(categoryInfoService.removeBatchByIds(ids));
}
}
/** /**
* ID * ID
* @param categoryId ID * @param categoryId ID

View File

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

View File

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

View File

@ -4,13 +4,17 @@ import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.muyu.product.cache.ProjectInfoCache;
import com.muyu.product.domain.AsProductAttributeInfo; import com.muyu.product.domain.AsProductAttributeInfo;
import com.muyu.product.domain.ProjectSkuInfo; 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.model.ProjectAddModel;
import com.muyu.product.domain.resp.ProjectDetailResp; import com.muyu.product.domain.resp.ProjectDetailResp;
import com.muyu.product.service.AsProductAttributeInfoService; import com.muyu.product.service.AsProductAttributeInfoService;
import com.muyu.product.service.ProjectSkuInfoService; import com.muyu.product.service.ProjectSkuInfoService;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import org.apache.commons.lang3.SystemUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
@ -36,7 +40,7 @@ import com.muyu.common.core.web.page.TableDataInfo;
/** /**
* Controller * Controller
* *
* @author yangle * @author DongZeLiang
* @date 2024-02-27 * @date 2024-02-27
*/ */
@Api(tags = "商品信息") @Api(tags = "商品信息")
@ -49,7 +53,8 @@ public class ProjectInfoController extends BaseController {
private AsProductAttributeInfoService asProductAttributeInfoService; private AsProductAttributeInfoService asProductAttributeInfoService;
@Autowired @Autowired
private ProjectSkuInfoService projectSkuInfoService; private ProjectSkuInfoService projectSkuInfoService;
@Autowired
private ProjectInfoCache projectInfoCache;
/** /**
* *
*/ */
@ -92,14 +97,16 @@ public class ProjectInfoController extends BaseController {
@GetMapping(value = "/cache/{id}") @GetMapping(value = "/cache/{id}")
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class) @ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
public Result<ProjectInfo> getCacheInfo(@PathVariable("id") Long id) { public Result<ProjectInfo> getCacheInfo(@PathVariable("id") Long id) {
return Result.success(projectInfoService.getById(id)); return Result.success(projectInfoCache.get(id));
} }
// @Autowired
// private ProjectInfoCache projectInfoCache;
// @ApiOperation("获取商品信息详细信息") // @ApiOperation("获取商品信息详细信息")
// @RequiresPermissions("product:info:query") // @RequiresPermissions("product:info:query")
// @GetMapping(value = "/{id}") // @GetMapping(value = "/{id}")
// @ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class) // @ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
// public Result<ProjectInfo> getInfo(@PathVariable("id") Long id) { // public Result<ProjectInfo> getInfo(@PathVariable("id") Long id) {
// return Result.success(projectInfoService.get(id)); // return Result.success(projectInfoCache.get(id));
// } // }
/** /**
@ -114,6 +121,7 @@ public class ProjectInfoController extends BaseController {
LambdaQueryWrapper<AsProductAttributeInfo> asProductAttributeInfoLambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<AsProductAttributeInfo> asProductAttributeInfoLambdaQueryWrapper = new LambdaQueryWrapper<>();
asProductAttributeInfoLambdaQueryWrapper.eq(AsProductAttributeInfo::getProductId, id); asProductAttributeInfoLambdaQueryWrapper.eq(AsProductAttributeInfo::getProductId, id);
List<AsProductAttributeInfo> list = asProductAttributeInfoService.list(asProductAttributeInfoLambdaQueryWrapper); List<AsProductAttributeInfo> list = asProductAttributeInfoService.list(asProductAttributeInfoLambdaQueryWrapper);
ProjectInfo projectInfo = projectInfoService.getById(id); ProjectInfo projectInfo = projectInfoService.getById(id);
LambdaQueryWrapper<ProjectSkuInfo> projectSkuInfoLambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<ProjectSkuInfo> projectSkuInfoLambdaQueryWrapper = new LambdaQueryWrapper<>();
projectSkuInfoLambdaQueryWrapper.eq(ProjectSkuInfo::getProjectId,id); projectSkuInfoLambdaQueryWrapper.eq(ProjectSkuInfo::getProjectId,id);
@ -159,8 +167,4 @@ public class ProjectInfoController extends BaseController {
projectInfoService.del(ids); projectInfoService.del(ids);
return toAjax(projectInfoService.removeBatchByIds(ids)); return toAjax(projectInfoService.removeBatchByIds(ids));
} }
} }

View File

@ -1,6 +1,5 @@
package com.muyu.product.controller; package com.muyu.product.controller;
import java.util.Date;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@ -30,7 +29,7 @@ import com.muyu.common.core.web.page.TableDataInfo;
/** /**
* SKUController * SKUController
* *
* @author yangle * @author DongZeLiang
* @date 2024-02-27 * @date 2024-02-27
*/ */
@Api(tags = "商品SKU") @Api(tags = "商品SKU")
@ -55,12 +54,13 @@ public class ProjectSkuInfoController extends BaseController {
/** /**
* IDSKU * IDSKU
* @param projectId ID * @param projectId ID
* @return SKU * @return SKU
*/ */
@GetMapping("/list/{projectId}") @GetMapping("/list/{projectId}")
public Result<List<ProjectSkuInfo>> listByProjectId(@PathVariable("projectId")Long projectId){ public Result<List<ProjectSkuInfo>> listByProjectId(@PathVariable("projectId") Long projectId){
return Result.success(projectSkuInfoService.listByProjectId(projectId)); return Result.success(projectSkuInfoService.listByProjectId(projectId));
} }
/** /**
* SKU * SKU
*/ */
@ -85,17 +85,11 @@ public class ProjectSkuInfoController extends BaseController {
return Result.success(projectSkuInfoService.getById(id)); return Result.success(projectSkuInfoService.getById(id));
} }
/** @GetMapping("/info/{projectId}/{projectSku}")
* IDskusku public Result<ProjectSkuInfo> getInfoByProjectIdAndSku(@PathVariable("projectId") Long projectId,
* @param projectId id @PathVariable("projectSku") String projectSku){
* @param projectSku sku return Result.success(projectSkuInfoService.getInfoByProjectIdAndSku(projectId,projectSku));
* @return }
*/
@GetMapping("/info/{projectId}/{projectSku}")
public Result<ProjectSkuInfo> getInfoByProjectIdAndSku(@PathVariable("projectId")Long projectId,
@PathVariable("projectSku") String projectSku){
return Result.success(projectSkuInfoService.getInfoByProjectIdAndSku(projectId, projectSku));
};
/** /**
* SKU * SKU
*/ */

View File

@ -29,7 +29,7 @@ import com.muyu.common.core.web.page.TableDataInfo;
/** /**
* Controller * Controller
* *
* @author yangle * @author Leyang
* @date 2024-02-27 * @date 2024-02-27
*/ */
@Api(tags = "规格详情") @Api(tags = "规格详情")
@ -75,6 +75,14 @@ public class RuleAttrInfoController extends BaseController {
return Result.success(ruleAttrInfoService.getById(id)); return Result.success(ruleAttrInfoService.getById(id));
} }
/**
*
*/
@GetMapping(value = "/list/ruleId/{ruleId}")
public Result<List<RuleAttrInfo>> getInfoByRuleId(@PathVariable("ruleId") Long ruleId){
return Result.success(ruleAttrInfoService.getInfoByRuleId(ruleId));
}
/** /**
* *
*/ */
@ -102,7 +110,7 @@ public class RuleAttrInfoController extends BaseController {
*/ */
@RequiresPermissions("product:ruleAttr:remove") @RequiresPermissions("product:ruleAttr:remove")
@Log(title = "规格详情", businessType = BusinessType.DELETE) @Log(title = "规格详情", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}") @DeleteMapping("/{ids}")
@ApiOperation("删除规格详情") @ApiOperation("删除规格详情")
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4") @ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4")
public Result<String> remove(@PathVariable List<Long> ids) { public Result<String> remove(@PathVariable List<Long> ids) {

View File

@ -6,7 +6,6 @@ import javax.servlet.http.HttpServletResponse;
import com.muyu.common.core.text.Convert; import com.muyu.common.core.text.Convert;
import com.muyu.product.domain.model.RuleInfoAddModel; import com.muyu.product.domain.model.RuleInfoAddModel;
import com.muyu.product.domain.resp.RuleInfoResp; import com.muyu.product.domain.resp.RuleInfoResp;
import com.muyu.product.service.RuleAttrInfoService;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
@ -33,7 +32,7 @@ import com.muyu.common.core.web.page.TableDataInfo;
/** /**
* Controller * Controller
* *
* @author yangle * @author DongZeLiang
* @date 2024-02-27 * @date 2024-02-27
*/ */
@Api(tags = "商品规格") @Api(tags = "商品规格")
@ -82,9 +81,6 @@ public class RuleInfoController extends BaseController {
return Result.success(ruleInfoService.getById(id)); return Result.success(ruleInfoService.getById(id));
} }
@Autowired
private RuleAttrInfoService ruleAttrInfoService;
/** /**
* *
*/ */

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -9,7 +9,7 @@ import org.apache.ibatis.annotations.Mapper;
/** /**
* Mapper * Mapper
* *
* @author yangle * @author DongZeLiang
* @date 2024-02-27 * @date 2024-02-27
*/ */
@Mapper @Mapper

View File

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

View File

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

View File

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

View File

@ -10,7 +10,7 @@ import org.apache.ibatis.annotations.Mapper;
/** /**
* SKUMapper * SKUMapper
* *
* @author yangle * @author DongZeLiang
* @date 2024-02-27 * @date 2024-02-27
*/ */
@Mapper @Mapper

View File

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

View File

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

View File

@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
/** /**
* Service * Service
* *
* @author yangle * @author DongZeLiang
* @date 2024-02-27 * @date 2024-02-27
*/ */
public interface AsAttributeGroupService extends IService<AsAttributeGroup> { public interface AsAttributeGroupService extends IService<AsAttributeGroup> {

View File

@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
/** /**
* Service * Service
* *
* @author yangle * @author DongZeLiang
* @date 2024-02-27 * @date 2024-02-27
*/ */
public interface AsBrandProjectService extends IService<AsBrandProject> { public interface AsBrandProjectService extends IService<AsBrandProject> {

View File

@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
/** /**
* Service * Service
* *
* @author yangle * @author DongZeLiang
* @date 2024-02-27 * @date 2024-02-27
*/ */
public interface AsCategoryAttributeGroupService extends IService<AsCategoryAttributeGroup> { public interface AsCategoryAttributeGroupService extends IService<AsCategoryAttributeGroup> {

View File

@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
/** /**
* Service * Service
* *
* @author yangle * @author DongZeLiang
* @date 2024-02-27 * @date 2024-02-27
*/ */
public interface AsCategoryAttributeService extends IService<AsCategoryAttribute> { public interface AsCategoryAttributeService extends IService<AsCategoryAttribute> {

View File

@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
/** /**
* Service * Service
* *
* @author yangle * @author DongZeLiang
* @date 2024-02-27 * @date 2024-02-27
*/ */
public interface AsCategoryBrandService extends IService<AsCategoryBrand> { public interface AsCategoryBrandService extends IService<AsCategoryBrand> {

View File

@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
/** /**
* Service * Service
* *
* @author yangle * @author DongZeLiang
* @date 2024-02-27 * @date 2024-02-27
*/ */
public interface AsProductAttributeInfoService extends IService<AsProductAttributeInfo> { public interface AsProductAttributeInfoService extends IService<AsProductAttributeInfo> {

View File

@ -13,7 +13,7 @@ import com.muyu.product.domain.resp.AttributeGroupPageResp;
/** /**
* Service * Service
* *
* @author yangle * @author DongZeLiang
* @date 2024-02-27 * @date 2024-02-27
*/ */
public interface AttributeGroupService extends IService<AttributeGroup> { public interface AttributeGroupService extends IService<AttributeGroup> {

View File

@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
/** /**
* Service * Service
* *
* @author yangle * @author DongZeLiang
* @date 2024-02-27 * @date 2024-02-27
*/ */
public interface AttributeInfoService extends IService<AttributeInfo> { public interface AttributeInfoService extends IService<AttributeInfo> {

View File

@ -8,7 +8,7 @@ import com.muyu.product.domain.req.BrandInfoEditReq;
/** /**
* Service * Service
* *
* @author yangle * @author DongZeLiang
* @date 2024-02-27 * @date 2024-02-27
*/ */
public interface BrandInfoService extends IService<BrandInfo> { public interface BrandInfoService extends IService<BrandInfo> {

View File

@ -15,7 +15,7 @@ import com.muyu.product.domain.resp.CategoryParentCommonElementResp;
/** /**
* Service * Service
* *
* @author yangle * @author DongZeLiang
* @date 2024-02-27 * @date 2024-02-27
*/ */
public interface CategoryInfoService extends IService<CategoryInfo> { public interface CategoryInfoService extends IService<CategoryInfo> {
@ -69,7 +69,6 @@ public interface CategoryInfoService extends IService<CategoryInfo> {
*/ */
CategoryCommonElementResp getTemplateAttributeByCateGoryId (Long cateGoryId); CategoryCommonElementResp getTemplateAttributeByCateGoryId (Long cateGoryId);
Boolean removeBatchById(List<Long> ids);
void util(Long id, CategoryInfoEditReq categoryInfoEditReq); void util(Long id, CategoryInfoEditReq categoryInfoEditReq);

View File

@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
/** /**
* Service * Service
* *
* @author yangle * @author DongZeLiang
* @date 2024-02-27 * @date 2024-02-27
*/ */
public interface CommentInfoService extends IService<CommentInfo> { public interface CommentInfoService extends IService<CommentInfo> {

View File

@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
/** /**
* Service * Service
* *
* @author yangle * @author DongZeLiang
* @date 2024-02-27 * @date 2024-02-27
*/ */
public interface CommentLikeInfoService extends IService<CommentLikeInfo> { public interface CommentLikeInfoService extends IService<CommentLikeInfo> {

View File

@ -12,7 +12,7 @@ import com.muyu.product.domain.resp.ProjectDetailResp;
/** /**
* Service * Service
* *
* @author yangle * @author DongZeLiang
* @date 2024-02-27 * @date 2024-02-27
*/ */
public interface ProjectInfoService extends IService<ProjectInfo> { public interface ProjectInfoService extends IService<ProjectInfo> {

View File

@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
/** /**
* SKUService * SKUService
* *
* @author yangle * @author DongZeLiang
* @date 2024-02-27 * @date 2024-02-27
*/ */
public interface ProjectSkuInfoService extends IService<ProjectSkuInfo> { public interface ProjectSkuInfoService extends IService<ProjectSkuInfo> {
@ -19,13 +19,7 @@ public interface ProjectSkuInfoService extends IService<ProjectSkuInfo> {
*/ */
public List<ProjectSkuInfo> list(ProjectSkuInfo projectSkuInfo); public List<ProjectSkuInfo> list(ProjectSkuInfo projectSkuInfo);
ProjectSkuInfo getInfoByProjectIdAndSku(Long projectId,String projectSku); ProjectSkuInfo getInfoByProjectIdAndSku(Long projectId, String projectSku);
/**
* Idsku
* @param projectId Id
* @return SKU
*/
List<ProjectSkuInfo> listByProjectId(Long projectId); List<ProjectSkuInfo> listByProjectId(Long projectId);
} }

View File

@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
/** /**
* Service * Service
* *
* @author yangle * @author DongZeLiang
* @date 2024-02-27 * @date 2024-02-27
*/ */
public interface RuleAttrInfoService extends IService<RuleAttrInfo> { public interface RuleAttrInfoService extends IService<RuleAttrInfo> {
@ -19,10 +19,5 @@ public interface RuleAttrInfoService extends IService<RuleAttrInfo> {
*/ */
public List<RuleAttrInfo> list(RuleAttrInfo ruleAttrInfo); public List<RuleAttrInfo> list(RuleAttrInfo ruleAttrInfo);
/**
* ruleId
* @param ruleId Id
* @return id
*/
List<RuleAttrInfo> getInfoByRuleId(Long ruleId); List<RuleAttrInfo> getInfoByRuleId(Long ruleId);
} }

View File

@ -3,18 +3,16 @@ package com.muyu.product.service;
import java.util.List; import java.util.List;
import com.muyu.common.core.web.page.TableDataInfo; import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.product.domain.RuleAttrInfo;
import com.muyu.product.domain.RuleInfo; import com.muyu.product.domain.RuleInfo;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.product.domain.model.RuleInfoAddModel; import com.muyu.product.domain.model.RuleInfoAddModel;
import com.muyu.product.domain.req.RuleInfoQueryReq; import com.muyu.product.domain.req.RuleInfoQueryReq;
import com.muyu.product.domain.resp.RuleInfoResp; import com.muyu.product.domain.resp.RuleInfoResp;
import org.apache.tomcat.util.digester.Rule;
/** /**
* Service * Service
* *
* @author yangle * @author DongZeLiang
* @date 2024-02-27 * @date 2024-02-27
*/ */
public interface RuleInfoService extends IService<RuleInfo> { public interface RuleInfoService extends IService<RuleInfo> {
@ -34,5 +32,4 @@ public interface RuleInfoService extends IService<RuleInfo> {
public boolean save(RuleInfoAddModel ruleInfoAddModel); public boolean save(RuleInfoAddModel ruleInfoAddModel);
TableDataInfo<RuleInfoResp> queryList (RuleInfoQueryReq ruleInfoQueryReq); TableDataInfo<RuleInfoResp> queryList (RuleInfoQueryReq ruleInfoQueryReq);
} }

View File

@ -14,7 +14,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
/** /**
* Service * Service
* *
* @author yangle * @author DongZeLiang
* @date 2024-02-27 * @date 2024-02-27
*/ */
@Slf4j @Slf4j

View File

@ -14,7 +14,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
/** /**
* Service * Service
* *
* @author yangle * @author DongZeLiang
* @date 2024-02-27 * @date 2024-02-27
*/ */
@Slf4j @Slf4j

View File

@ -14,7 +14,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
/** /**
* Service * Service
* *
* @author yangle * @author DongZeLiang
* @date 2024-02-27 * @date 2024-02-27
*/ */
@Slf4j @Slf4j

View File

@ -14,7 +14,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
/** /**
* Service * Service
* *
* @author yangle * @author DongZeLiang
* @date 2024-02-27 * @date 2024-02-27
*/ */
@Slf4j @Slf4j

View File

@ -14,7 +14,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
/** /**
* Service * Service
* *
* @author yangle * @author DongZeLiang
* @date 2024-02-27 * @date 2024-02-27
*/ */
@Slf4j @Slf4j

View File

@ -14,7 +14,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
/** /**
* Service * Service
* *
* @author yangle * @author DongZeLiang
* @date 2024-02-27 * @date 2024-02-27
*/ */
@Slf4j @Slf4j

View File

@ -26,7 +26,7 @@ import java.util.stream.Stream;
/** /**
* Service * Service
* *
* @author yangle * @author DongZeLiang
* @date 2024-02-27 * @date 2024-02-27
*/ */
@Slf4j @Slf4j

View File

@ -18,7 +18,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
/** /**
* Service * Service
* *
* @author yangle * @author DongZeLiang
* @date 2024-02-27 * @date 2024-02-27
*/ */
@Slf4j @Slf4j

View File

@ -17,7 +17,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
/** /**
* Service * Service
* *
* @author yangle * @author DongZeLiang
* @date 2024-02-27 * @date 2024-02-27
*/ */
@Slf4j @Slf4j

View File

@ -33,7 +33,7 @@ import java.util.stream.Stream;
/** /**
* Service * Service
* *
* @author yangle * @author DongZeLiang
* @date 2024-02-27 * @date 2024-02-27
*/ */
@Slf4j @Slf4j
@ -352,7 +352,6 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
if (asCategoryAttributeList != null && !asCategoryAttributeList.isEmpty()){ if (asCategoryAttributeList != null && !asCategoryAttributeList.isEmpty()){
List<Long> templateAttributeIdList = asCategoryAttributeList.stream() List<Long> templateAttributeIdList = asCategoryAttributeList.stream()
.map(AsCategoryAttribute::getAttributeId) .map(AsCategoryAttribute::getAttributeId)
.filter(templateAttributeId -> !attributeIdSet.contains(templateAttributeId))
.toList(); .toList();
templateAttributeModelList = attributeInfoService.listByIds(templateAttributeIdList).stream() templateAttributeModelList = attributeInfoService.listByIds(templateAttributeIdList).stream()
.map(AttributeInfo::buildTemplateModel) .map(AttributeInfo::buildTemplateModel)
@ -378,33 +377,7 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
.build(); .build();
} }
@Autowired
private AsCategoryAttributeGroupMapper asCategoryAttributeGroupMapper;
@Autowired
private AsCategoryAttributeMapper asCategoryAttributeMapper;
@Autowired
private AsCategoryBrandMapper asCategoryBrandMapper;
/**
*
* @param ids
* @return
*/
@Override
public Boolean removeBatchById(List<Long> ids) {
//删除品类属性组中间表
LambdaQueryWrapper<AsCategoryAttributeGroup> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.in(AsCategoryAttributeGroup::getAttributeGroupId, ids);
asCategoryAttributeGroupMapper.delete(lambdaQueryWrapper);
//删除品类属性中间表
LambdaQueryWrapper<AsCategoryAttribute> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(AsCategoryAttribute::getAttributeId, ids);
asCategoryAttributeMapper.delete(queryWrapper);
//删除品类品牌中间
LambdaQueryWrapper<AsCategoryBrand> asCategoryBrandLambdaQueryWrapper = new LambdaQueryWrapper<>();
asCategoryBrandLambdaQueryWrapper.in(AsCategoryBrand::getBrandId, ids);
asCategoryBrandMapper.delete(asCategoryBrandLambdaQueryWrapper);
return true;
}
@Override @Override
public void util(Long id, CategoryInfoEditReq categoryInfoEditReq) { public void util(Long id, CategoryInfoEditReq categoryInfoEditReq) {
@ -413,7 +386,7 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
List<AsCategoryAttribute> list = asCategoryAttributeService.list(asCategoryAttribute); List<AsCategoryAttribute> list = asCategoryAttributeService.list(asCategoryAttribute);
ArrayList<Long> longs = new ArrayList<>(); ArrayList<Long> longs = new ArrayList<>();
for (AsCategoryAttribute categoryAttribute : list) { for (AsCategoryAttribute categoryAttribute : list) {
longs.add(categoryAttribute.getId()); longs.add(categoryAttribute.getId());
} }
asCategoryAttributeService.removeBatchByIds(longs); asCategoryAttributeService.removeBatchByIds(longs);
List<Long> attributeGroupIdList = categoryInfoEditReq.getAttributeGroupIdList(); List<Long> attributeGroupIdList = categoryInfoEditReq.getAttributeGroupIdList();
@ -434,4 +407,3 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
} }
} }

View File

@ -14,7 +14,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
/** /**
* Service * Service
* *
* @author yangle * @author DongZeLiang
* @date 2024-02-27 * @date 2024-02-27
*/ */
@Slf4j @Slf4j

View File

@ -14,7 +14,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
/** /**
* Service * Service
* *
* @author yangle * @author DongZeLiang
* @date 2024-02-27 * @date 2024-02-27
*/ */
@Slf4j @Slf4j

View File

@ -25,7 +25,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
/** /**
* Service * Service
* *
* @author yangle * @author DongZeLiang
* @date 2024-02-27 * @date 2024-02-27
*/ */
@Slf4j @Slf4j

View File

@ -14,7 +14,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
/** /**
* SKUService * SKUService
* *
* @author yangle * @author DongZeLiang
* @date 2024-02-27 * @date 2024-02-27
*/ */
@Slf4j @Slf4j
@ -59,24 +59,19 @@ public class ProjectSkuInfoServiceImpl extends ServiceImpl<ProjectSkuInfoMapper,
return list(queryWrapper); return list(queryWrapper);
} }
/**
* Id skusku
* @param projectId id
* @param projectSku sku
* @return sku
*/
@Override @Override
public ProjectSkuInfo getInfoByProjectIdAndSku(Long projectId, String projectSku) { public ProjectSkuInfo getInfoByProjectIdAndSku(Long projectId, String projectSku) {
LambdaQueryWrapper<ProjectSkuInfo> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<ProjectSkuInfo> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(ProjectSkuInfo::getProjectId, projectId); queryWrapper.eq(ProjectSkuInfo::getProjectId,projectId);
queryWrapper.eq(ProjectSkuInfo::getSku, projectSku); queryWrapper.eq(ProjectSkuInfo::getSku,projectSku);
return this.getOne(queryWrapper); return this.getOne(queryWrapper);
} }
@Override @Override
public List<ProjectSkuInfo> listByProjectId(Long projectId) { public List<ProjectSkuInfo> listByProjectId(Long projectId) {
LambdaQueryWrapper<ProjectSkuInfo> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<ProjectSkuInfo> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(ProjectSkuInfo::getProjectId, projectId); queryWrapper.eq(ProjectSkuInfo::getProjectId,projectId);
return this.list(queryWrapper); return this.list(queryWrapper);
} }
} }

View File

@ -14,7 +14,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
/** /**
* Service * Service
* *
* @author yangle * @author DongZeLiang
* @date 2024-02-27 * @date 2024-02-27
*/ */
@Slf4j @Slf4j
@ -44,13 +44,18 @@ public class RuleAttrInfoServiceImpl extends ServiceImpl<RuleAttrInfoMapper, Rul
queryWrapper.eq(RuleAttrInfo::getAttrValue, ruleAttrInfo.getAttrValue()); queryWrapper.eq(RuleAttrInfo::getAttrValue, ruleAttrInfo.getAttrValue());
} }
return list(queryWrapper); return list(queryWrapper);
} }
@Override @Override
public List<RuleAttrInfo> getInfoByRuleId(Long ruleId) { public List<RuleAttrInfo> getInfoByRuleId(Long ruleId) {
LambdaQueryWrapper<RuleAttrInfo> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<RuleAttrInfo> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(RuleAttrInfo::getRuleId, ruleId); queryWrapper.eq(RuleAttrInfo::getRuleId,ruleId);
return this.list(queryWrapper); return this.list(queryWrapper);
} }
} }

View File

@ -30,7 +30,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
/** /**
* Service * Service
* *
* @author yangle * @author DongZeLiang
* @date 2024-02-27 * @date 2024-02-27
*/ */
@Slf4j @Slf4j
@ -102,6 +102,4 @@ public class RuleInfoServiceImpl extends ServiceImpl<RuleInfoMapper, RuleInfo>
.total(isPage ? new PageInfo<>(list).getTotal() : 0) .total(isPage ? new PageInfo<>(list).getTotal() : 0)
.build(); .build();
} }
} }

View File

@ -10,12 +10,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="groupId" column="group_id" /> <result property="groupId" column="group_id" />
<result property="createBy" column="create_by" /> <result property="createBy" column="create_by" />
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time" />
<result property="updataBy" column="updata_by" /> <result property="updateBy" column="update_by" />
<result property="updataTime" column="updata_time" /> <result property="updateTime" column="update_time" />
<result property="remark" column="remark" /> <result property="remark" column="remark" />
</resultMap> </resultMap>
<sql id="selectAttributeInfoVo"> <sql id="selectAttributeInfoVo">
select id, name, group_id, create_by, create_time, updata_by, updata_time, remark from attribute_info select id, name, group_id, create_by, create_time, update_time, update_time, remark from attribute_info
</sql> </sql>
</mapper> </mapper>

View File

@ -13,20 +13,23 @@ import org.springframework.stereotype.Component;
import java.util.Map; import java.util.Map;
/** /**
* * @author yangle
* * @description:
* @author LeYang * @Date 2024-4-2 11:23
* on 2024/4/2
*/ */
@Component @Component
public class CartCache extends HashCacheAbs<Long, CartHashKey , CartInfo> { public class CartCache extends HashCacheAbs<Long, CartHashKey, CartInfo> {
@Autowired
private CartData cartData;
@Autowired
private CartData cartData;
/**
* key
* @return key
*/
@Override @Override
public String keyPre() { public String keyPre () {
return "cart:info"; return "cart:info:";
} }
/** /**
@ -35,17 +38,29 @@ public class CartCache extends HashCacheAbs<Long, CartHashKey , CartInfo> {
* @return ID * @return ID
*/ */
@Override @Override
public Long decode(String redisKey) { public Long decode (String redisKey) {
return Convert.toLong(redisKey.replace(keyPre(),"")); return Convert.toLong(redisKey.replace(keyPre(), ""));
}
/**
*
*
* @param hashKey ID
*
* @return
*/
@Override
public String encodeHashKey (CartHashKey hashKey) {
return hashKey.getProjectId()+":"+hashKey.getProjectSku();
} }
/** /**
* *
* @param redisHashKey * @param redisHashKey
* @return ID * @return ID
*/ */
@Override @Override
public CartHashKey decodeHashKey(String redisHashKey) { public CartHashKey decodeHashKey (String redisHashKey) {
String[] split = redisHashKey.split(":"); String[] split = redisHashKey.split(":");
return CartHashKey.builder() return CartHashKey.builder()
.projectId(Convert.toLong(split[0])) .projectId(Convert.toLong(split[0]))
@ -59,30 +74,34 @@ public class CartCache extends HashCacheAbs<Long, CartHashKey , CartInfo> {
* @return * @return
*/ */
@Override @Override
public Map<CartHashKey, CartInfo> getData(Long key) { public Map<CartHashKey, CartInfo> getData (Long key) {
return cartData.getData(key); return cartData.getData(key);
} }
/** /**
* hashhash * hashhash
* @param key *
* @param key
* @param hashKey hash * @param hashKey hash
* @return *
* @return hash
*/ */
@Override @Override
public CartInfo getData(Long key, CartHashKey hashKey) { public CartInfo getData (Long key, CartHashKey hashKey) {
return cartData.getData(key,hashKey); return cartData.getData(key, hashKey);
}
/**
*
*/
@Override
public Map<CartHashKey, CartInfo> defaultValue () {
throw new ServiceException("购物车无数据", Result.SUCCESS);
} }
@Override @Override
public Map<CartHashKey, CartInfo> defaultValue() { public CartInfo defaultHashValue () {
throw new ServiceException("购物车无数据",Result.SUCCESS); throw new ServiceException("购物车无数据", Result.SUCCESS);
} }
@Override
public CartInfo defaultHashValue() {
throw new ServiceException("购物车无数据",Result.SUCCESS);
}
} }

View File

@ -5,13 +5,10 @@ import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.util.ArrayList;
/** /**
* HashKey * @author yangle
* * @description: HashKey
* @author LeYang * @Date 2024-4-2 11:25
* on 2024/4/2
*/ */
@Data @Data
@Builder @Builder
@ -22,10 +19,10 @@ public class CartHashKey {
/** /**
* ID * ID
*/ */
private Long projectId; private Long projectId;
/** /**
* sku * SKU
*/ */
private String projectSku; private String projectSku;
} }

View File

@ -6,24 +6,26 @@ import com.muyu.shop.cart.domain.CartInfo;
import java.util.Map; import java.util.Map;
/** /**
* CartData * @author yangle
* * @description:
* @author LeYang * @Date 2024-4-2 11:49
* on 2024/4/2
*/ */
public interface CartData { public interface CartData {
/**
* hash
* @param key
* @return
*/
public Map<CartHashKey, CartInfo> getData(Long key);
/** /**
* hashhash * hash
* @param key * @param key
* @param cartHashKey hash * @return
*/
public Map<CartHashKey, CartInfo> getData (Long key);
/**
* hashhash
*
* @param key
* @param hashKey hash
*
* @return hash * @return hash
*/ */
public CartInfo getData(Long key,CartHashKey cartHashKey); public CartInfo getData (Long key, CartHashKey hashKey);
} }

View File

@ -32,6 +32,10 @@ public class CartSkuModel {
* ID * ID
*/ */
private Long projectId; private Long projectId;
/**
* sku
*/
private String projectSku;
/** /**
* *
*/ */

View File

@ -22,25 +22,15 @@ import com.muyu.common.core.web.domain.BaseEntity;
public class CartInfoSaveReq extends BaseEntity { public class CartInfoSaveReq extends BaseEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** 商品 */ /** 商品 */
@ApiModelProperty(name = "商品", value = "商品", required = true) @ApiModelProperty(name = "商品", value = "商品", required = true)
private Long projectId; private Long projectId;
/** sku */ /** SKU */
@ApiModelProperty(name = "SKU", value = "SKU", required = true)
@ApiModelProperty(name = "sku", value = "sku", required = true)
private String projectSku; private String projectSku;
/** 数量 */ /** 数量 */
@ApiModelProperty(name = "数量", value = "数量", required = true) @ApiModelProperty(name = "数量", value = "数量", required = true)
private Long num; private Long num;
} }

View File

@ -4,7 +4,7 @@ import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.muyu.product.domain.ProjectSkuInfo; import com.muyu.product.domain.ProjectSkuInfo;
import com.muyu.shop.cart.domain.req.CartDetailResp; import com.muyu.shop.cart.domain.req.*;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
@ -22,9 +22,6 @@ import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType; import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.annotation.RequiresPermissions; import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.shop.cart.domain.CartInfo; import com.muyu.shop.cart.domain.CartInfo;
import com.muyu.shop.cart.domain.req.CartInfoQueryReq;
import com.muyu.shop.cart.domain.req.CartInfoSaveReq;
import com.muyu.shop.cart.domain.req.CartInfoEditReq;
import com.muyu.shop.cart.service.CartInfoService; import com.muyu.shop.cart.service.CartInfoService;
import com.muyu.common.core.web.page.TableDataInfo; import com.muyu.common.core.web.page.TableDataInfo;
@ -36,7 +33,7 @@ import com.muyu.common.core.web.page.TableDataInfo;
*/ */
@Api(tags = "购物车") @Api(tags = "购物车")
@RestController @RestController
@RequestMapping("/info") @RequestMapping("/Info")
public class CartInfoController extends BaseController { public class CartInfoController extends BaseController {
@Autowired @Autowired
private CartInfoService cartInfoService; private CartInfoService cartInfoService;
@ -45,7 +42,7 @@ public class CartInfoController extends BaseController {
* *
*/ */
@ApiOperation("获取购物车列表") @ApiOperation("获取购物车列表")
@RequiresPermissions("shopCart:info:list") @RequiresPermissions("shopCart:Info:list")
@GetMapping("/list") @GetMapping("/list")
public Result<TableDataInfo<CartInfo>> list(CartInfoQueryReq cartInfoQueryReq) { public Result<TableDataInfo<CartInfo>> list(CartInfoQueryReq cartInfoQueryReq) {
startPage(); startPage();
@ -57,7 +54,7 @@ public class CartInfoController extends BaseController {
* *
*/ */
@ApiOperation("导出购物车列表") @ApiOperation("导出购物车列表")
@RequiresPermissions("shopCart:info:export") @RequiresPermissions("shopCart:Info:export")
@Log(title = "购物车", businessType = BusinessType.EXPORT) @Log(title = "购物车", businessType = BusinessType.EXPORT)
@PostMapping("/export") @PostMapping("/export")
public void export(HttpServletResponse response, CartInfo cartInfo) { public void export(HttpServletResponse response, CartInfo cartInfo) {
@ -70,13 +67,14 @@ public class CartInfoController extends BaseController {
* *
*/ */
@ApiOperation("获取购物车详细信息") @ApiOperation("获取购物车详细信息")
@RequiresPermissions("shopCart:info:query") @RequiresPermissions("shopCart:Info:query")
@GetMapping(value = "/{id}") @GetMapping(value = "/{id}")
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class) @ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
public Result<CartInfo> getInfo(@PathVariable("id") Long id) { public Result<CartInfo> getInfo(@PathVariable("id") Long id) {
return Result.success(cartInfoService.getById(id)); return Result.success(cartInfoService.getById(id));
} }
@GetMapping("/detail") @GetMapping("/detail")
public Result<CartDetailResp> detail(){ public Result<CartDetailResp> detail(){
return Result.success(cartInfoService.detail()); return Result.success(cartInfoService.detail());
@ -85,7 +83,7 @@ public class CartInfoController extends BaseController {
/** /**
* *
*/ */
@RequiresPermissions("shopCart:info:add") @RequiresPermissions("shopCart:Info:add")
@Log(title = "购物车", businessType = BusinessType.INSERT) @Log(title = "购物车", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
@ApiOperation("新增购物车") @ApiOperation("新增购物车")
@ -96,7 +94,7 @@ public class CartInfoController extends BaseController {
/** /**
* *
*/ */
@RequiresPermissions("shopCart:info:edit") @RequiresPermissions("shopCart:Info:edit")
@Log(title = "购物车", businessType = BusinessType.UPDATE) @Log(title = "购物车", businessType = BusinessType.UPDATE)
@PutMapping("/{id}") @PutMapping("/{id}")
@ApiOperation("修改购物车") @ApiOperation("修改购物车")
@ -104,15 +102,48 @@ public class CartInfoController extends BaseController {
return toAjax(cartInfoService.updateById(CartInfo.editBuild(id,cartInfoEditReq))); return toAjax(cartInfoService.updateById(CartInfo.editBuild(id,cartInfoEditReq)));
} }
/**
*
* @param cartInfoIsSelectedUpdReqList
* @return
*/
@PostMapping("/selected")
public Result<String> cartInfoIsSelected(@RequestBody List<CartInfoIsSelectedUpdReq> cartInfoIsSelectedUpdReqList){
cartInfoService.cartInfoIsSelected(cartInfoIsSelectedUpdReqList);
return Result.success();
}
/**
*
* @param cartInfoEditNumReq
* @return
*/
@PostMapping("/num")
public Result<String> cartInfoEditNum(@RequestBody CartInfoEditNumReq cartInfoEditNumReq){
cartInfoService.CartInfoEditNum(cartInfoEditNumReq);
return Result.success();
}
/** /**
* *
*/ */
@RequiresPermissions("shopCart:info:remove") @RequiresPermissions("shopCart:Info:remove")
@Log(title = "购物车", businessType = BusinessType.DELETE) @Log(title = "购物车", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}") @DeleteMapping("/{ids}")
@ApiOperation("删除购物车") @ApiOperation("删除购物车")
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4") @ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4")
public Result<String> remove(@PathVariable List<Long> ids) { public Result<String> removeByIds(@PathVariable List<Long> ids) {
return toAjax(cartInfoService.removeBatchByIds(ids)); return toAjax(cartInfoService.removeBatchByIds(ids));
} }
/**
*
*/
@RequiresPermissions("shopCart:Info:remove")
@DeleteMapping("/remove")
@ApiOperation("删除购物车")
public Result<String> remove(@RequestBody List<RemoveCartProjectReq> removeCartProjectReqList) {
cartInfoService.removeByRemoveCartProjectList(removeCartProjectReqList);
return Result.success();
}
} }

View File

@ -4,6 +4,9 @@ import java.util.List;
import com.muyu.shop.cart.domain.CartInfo; import com.muyu.shop.cart.domain.CartInfo;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.shop.cart.domain.req.CartDetailResp; import com.muyu.shop.cart.domain.req.CartDetailResp;
import com.muyu.shop.cart.domain.req.CartInfoEditNumReq;
import com.muyu.shop.cart.domain.req.CartInfoIsSelectedUpdReq;
import com.muyu.shop.cart.domain.req.RemoveCartProjectReq;
/** /**
* Service * Service
@ -29,4 +32,10 @@ public interface CartInfoService extends IService<CartInfo> {
CartDetailResp detail(); CartDetailResp detail();
void CartInfoEditNum(CartInfoEditNumReq cartInfoEditNumReq);
void removeByRemoveCartProjectList(List<RemoveCartProjectReq> removeCartProjectReqs);
void cartInfoIsSelected(List<CartInfoIsSelectedUpdReq> cartInfoIsSelectedUpdReqList);
} }

View File

@ -5,9 +5,11 @@ import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.muyu.common.core.exception.ServiceException; import com.muyu.common.core.exception.ServiceException;
import com.muyu.common.core.text.Convert; import com.muyu.common.core.text.Convert;
import com.muyu.common.core.utils.ObjUtils; import com.muyu.common.core.utils.ObjUtils;
import com.muyu.common.core.utils.ServletUtils;
import com.muyu.common.security.utils.SecurityUtils; import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.product.cache.ProjectInfoCache; import com.muyu.product.cache.ProjectInfoCache;
import com.muyu.product.cache.ProjectSkuCache; import com.muyu.product.cache.ProjectSkuCache;
@ -24,6 +26,9 @@ import com.muyu.shop.cart.domain.model.CartSkuModel;
import com.muyu.shop.cart.domain.model.SkuRuleModel; import com.muyu.shop.cart.domain.model.SkuRuleModel;
import com.muyu.shop.cart.domain.model.StatisticsCartModel; import com.muyu.shop.cart.domain.model.StatisticsCartModel;
import com.muyu.shop.cart.domain.req.CartDetailResp; import com.muyu.shop.cart.domain.req.CartDetailResp;
import com.muyu.shop.cart.domain.req.CartInfoEditNumReq;
import com.muyu.shop.cart.domain.req.CartInfoIsSelectedUpdReq;
import com.muyu.shop.cart.domain.req.RemoveCartProjectReq;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.SystemUtils; import org.apache.commons.lang3.SystemUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -33,6 +38,7 @@ import com.muyu.shop.cart.domain.CartInfo;
import com.muyu.shop.cart.service.CartInfoService; import com.muyu.shop.cart.service.CartInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.transaction.annotation.Transactional;
/** /**
* Service * Service
@ -47,6 +53,18 @@ public class CartInfoServiceImpl extends ServiceImpl<CartInfoMapper, CartInfo>
@Autowired @Autowired
private CartCache cartCache; private CartCache cartCache;
@Autowired
private ProjectSkuCache projectSkuCache;
@Autowired
private ProjectInfoCache projectInfoCache;
@Autowired
private ProjectSkuStockCache projectSkuStockCache;
@Autowired
private RuleInfoCache ruleInfoCache;
/** /**
* *
* *
@ -77,20 +95,22 @@ public class CartInfoServiceImpl extends ServiceImpl<CartInfoMapper, CartInfo>
if (ObjUtils.notNull(cartInfo.getIsSelected())){ if (ObjUtils.notNull(cartInfo.getIsSelected())){
queryWrapper.eq(CartInfo::getIsSelected, cartInfo.getIsSelected()); queryWrapper.eq(CartInfo::getIsSelected, cartInfo.getIsSelected());
} }
return list(queryWrapper); return list(queryWrapper);
} }
@Autowired
private ProjectSkuStockCache projectSkuStockCache;
/** /**
* *
* @param cartInfo *
* @return * @param cartInfo
*
* @return
*/ */
@Override @Override
public boolean add(CartInfo cartInfo) { public boolean add (CartInfo cartInfo) {
Long userId = SecurityUtils.getUserId(); Long userId = SecurityUtils.getUserId();
CartHashKey cartHashKey = CartHashKey.builder() CartHashKey cartHashKey = CartHashKey.builder()
.projectId(cartInfo.getUserId()) .projectId(cartInfo.getProjectId())
.projectSku(cartInfo.getProjectSku()) .projectSku(cartInfo.getProjectSku())
.build(); .build();
SkuStockKey skuStockKey = SkuStockKey.builder() SkuStockKey skuStockKey = SkuStockKey.builder()
@ -98,68 +118,72 @@ private ProjectSkuStockCache projectSkuStockCache;
.sku(cartInfo.getProjectSku()) .sku(cartInfo.getProjectSku())
.build(); .build();
Long skuStock = Convert.toLong(projectSkuStockCache.get(skuStockKey), -1L); Long skuStock = Convert.toLong(projectSkuStockCache.get(skuStockKey), -1L);
if (cartCache.hasKey(userId, cartHashKey)) { if (cartCache.hasKey(userId, cartHashKey)){
//取出来修改 // 取出来修改
CartInfo cartInfoCache = cartCache.get(userId, cartHashKey); CartInfo cartInfoCache = cartCache.get(userId, cartHashKey);
cartInfoCache.setNum(cartInfoCache.getNum()+ cartInfo.getNum()); cartInfoCache.setNum( cartInfoCache.getNum() + cartInfo.getNum());
if (skuStock<cartInfoCache.getNum()){ if (skuStock < cartInfoCache.getNum()){
throw new ServiceException("当前库存不足"); throw new ServiceException("当前库存不足");
} }
LambdaQueryWrapper<CartInfo> queryWrapper = new LambdaQueryWrapper<>(); LambdaUpdateWrapper<CartInfo> updateWrapper = new LambdaUpdateWrapper<>();
queryWrapper.eq(CartInfo::getNum,cartInfoCache.getNum()); updateWrapper.set(CartInfo::getNum, cartInfoCache.getNum());
queryWrapper.eq(CartInfo::getId, cartInfoCache.getId()); updateWrapper.eq(CartInfo::getId, cartInfoCache.getId());
this.update(queryWrapper); this.update(updateWrapper);
this.cartCache.put(userId, cartHashKey,cartInfoCache); this.cartCache.put(userId, cartHashKey, cartInfoCache);
}else { }else {
//存进去 // 存进去
if (skuStock < cartInfo.getNum()){ if (skuStock < cartInfo.getNum()){
throw new ServiceException("当前库存不足"); throw new ServiceException("当前库存不足");
} }
cartInfo.setIsSelected("Y");
cartInfo.setUserId(userId); cartInfo.setUserId(userId);
cartInfo.setCreateBy(SecurityUtils.getUsername()); cartInfo.setCreateBy(SecurityUtils.getUsername());
cartInfo.setCreateTime(new Date()); cartInfo.setCreateTime(new Date());
this.save(cartInfo); this.save(cartInfo);
this.cartCache.put(userId, cartHashKey,cartInfo); this.cartCache.put(userId, cartHashKey, cartInfo);
} }
return true; return true;
} }
@Autowired
private ProjectSkuCache projectSkuCache;
@Autowired
private ProjectInfoCache projectInfoCache;
@Autowired
private RuleInfoCache ruleInfoCache;
@Override
public CartDetailResp detail() {
Long userId = SecurityUtils.getUserId();
List<CartInfo> cacheToList = this.cartCache.getToList(userId);
List<CartSkuModel> cartSkuModelList = cacheToList.stream() /**
*
*
* @return
*/
@Override
public CartDetailResp detail () {
Long userId = SecurityUtils.getUserId();
List<CartInfo> cartInfoList = cartCache.getToList(userId);
// CartInfo -> CartSkuModel
List<CartSkuModel> cartSkuModelList = cartInfoList.stream()
.map(cartInfo -> { .map(cartInfo -> {
ProjectSkuInfo projectSkuInfo = ProjectSkuInfo projectSkuInfo
projectSkuCache.get(cartInfo.getProjectId(), cartInfo.getProjectSku()); = projectSkuCache.get(cartInfo.getProjectId(), cartInfo.getProjectSku());
ProjectInfo projectInfo = projectInfoCache.get(cartInfo.getProjectId()); ProjectInfo projectInfo
= projectInfoCache.get(cartInfo.getProjectId());
Long stock = projectSkuStockCache.get( Long stock = projectSkuStockCache.get(
SkuStockKey.builder() SkuStockKey.builder()
.projectId(cartInfo.getProjectId()) .projectId(cartInfo.getProjectId())
.sku(cartInfo.getProjectSku()) .sku(cartInfo.getProjectSku())
.build() .build()
); );
RuleCacheModel ruleInfoCacheData = ruleInfoCache.getData(projectInfo.getRuleId()); // RuleCache
List<RuleAttrCacheModel> ruleAttrModelList = ruleInfoCacheData.getRuleAttrModelList(); RuleCacheModel ruleInfoCacheModel = ruleInfoCache.getData(projectInfo.getRuleId());
List<RuleAttrCacheModel> ruleAttrModelList = ruleInfoCacheModel.getRuleAttrModelList();
List<SkuRuleModel> ruleModelList = new ArrayList<>(); List<SkuRuleModel> ruleModelList = new ArrayList<>();
String projectSku = cartInfo.getProjectSku(); String projectSku = cartInfo.getProjectSku();
String[] skuArr = projectSku.split("-"); String[] skuArr = projectSku.split("-");
for (int index = 0; index < skuArr.length; index++) { for (int index = 0 ; index < skuArr.length ; index++) {
ruleModelList.add( ruleModelList.add(
SkuRuleModel.builder(). SkuRuleModel.builder()
ruleName(ruleAttrModelList.get(index).getAttrName()) .ruleName(ruleAttrModelList.get(index).getAttrName())
.ruleValue(skuArr[index]) .ruleValue(skuArr[index])
.build() .build()
); );
} }
return CartSkuModel.builder() return CartSkuModel.builder()
.projectId(cartInfo.getProjectId()) .projectId(cartInfo.getProjectId())
.projectSku(cartInfo.getProjectSku())
.name(projectInfo.getName()) .name(projectInfo.getName())
.image(projectSkuInfo.getImage()) .image(projectSkuInfo.getImage())
.stock(stock) .stock(stock)
@ -171,35 +195,107 @@ private ProjectSkuCache projectSkuCache;
.isSelected(cartInfo.getIsSelected()) .isSelected(cartInfo.getIsSelected())
.build(); .build();
}).toList(); }).toList();
List<CartSkuModel> cartSkuList = new ArrayList<>();
StatisticsCartModel statisticsCartModel = StatisticsCartModel.builder() StatisticsCartModel statisticsCartModel = StatisticsCartModel.builder()
.total(cartSkuModelList.stream() .total(
.mapToLong(CartSkuModel::getNum) cartSkuModelList.stream()
.sum() .filter(cartSkuModel -> cartSkuModel.getStock() > 0)
.mapToLong(CartSkuModel::getNum)
.sum()
) )
.selectTotal( .selectTotal(
cartSkuModelList.stream() cartSkuModelList.stream()
.filter(cartSkuModel -> "Y".equals(cartSkuModel.getIsSelected())) .filter(cartSkuModel -> "Y".equals(cartSkuModel.getIsSelected()))
.filter(cartSkuModel -> cartSkuModel.getStock() > 0)
.mapToLong(CartSkuModel::getNum) .mapToLong(CartSkuModel::getNum)
.sum() .sum()
) )
.priceTotal( .priceTotal(
cartSkuModelList.stream() cartSkuModelList.stream()
.filter(cartSkuModel -> "Y".equals(cartSkuModel.getIsSelected())) .filter(cartSkuModel -> "Y".equals(cartSkuModel.getIsSelected()))
.filter(cartSkuModel -> cartSkuModel.getStock() > 0)
.map(CartSkuModel::getSubtotal) .map(CartSkuModel::getSubtotal)
.reduce(BigDecimal.ZERO, BigDecimal::add) .reduce(BigDecimal.ZERO, BigDecimal::add)
) )
.actualTotal( .actualTotal(
cartSkuModelList.stream() cartSkuModelList.stream()
.filter(cartSkuModel -> "Y".equals(cartSkuModel.getIsSelected())) .filter(cartSkuModel -> "Y".equals(cartSkuModel.getIsSelected()))
.filter(cartSkuModel -> cartSkuModel.getStock() > 0)
.map(CartSkuModel::getSubtotal) .map(CartSkuModel::getSubtotal)
.reduce(BigDecimal.ZERO, BigDecimal::add) .reduce(BigDecimal.ZERO, BigDecimal::add)
).build(); )
.build();
return CartDetailResp.builder() return CartDetailResp.builder()
.cartSkuList(cartSkuModelList) .cartSkuList(cartSkuModelList)
.statisticsCart(statisticsCartModel) .statisticsCart(statisticsCartModel)
.build(); .build();
} }
/**
*
*
* @param cartInfoIsSelectedUpdReqList
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void cartInfoIsSelected (List<CartInfoIsSelectedUpdReq> cartInfoIsSelectedUpdReqList) {
for (CartInfoIsSelectedUpdReq cartInfoIsSelectedUpdReq : cartInfoIsSelectedUpdReqList) {
LambdaUpdateWrapper<CartInfo> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.set(CartInfo::getIsSelected, cartInfoIsSelectedUpdReq.getIsSelected());
updateWrapper.eq(CartInfo::getProjectId, cartInfoIsSelectedUpdReq.getProjectId());
updateWrapper.eq(CartInfo::getProjectSku, cartInfoIsSelectedUpdReq.getProjectSku());
this.update(updateWrapper);
CartHashKey cartHashKey = CartHashKey.builder()
.projectId(cartInfoIsSelectedUpdReq.getProjectId())
.projectSku(cartInfoIsSelectedUpdReq.getProjectSku())
.build();
Long userId = SecurityUtils.getUserId();
CartInfo cartInfo = this.cartCache.get(userId, cartHashKey);
cartInfo.setIsSelected(cartInfoIsSelectedUpdReq.getIsSelected());
this.cartCache.put(userId, cartHashKey, cartInfo);
}
}
@Override
public void CartInfoEditNum (CartInfoEditNumReq cartInfoEditNumReq) {
LambdaUpdateWrapper<CartInfo> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.set(CartInfo::getIsSelected, cartInfoEditNumReq.getNum());
updateWrapper.eq(CartInfo::getProjectId, cartInfoEditNumReq.getProjectId());
updateWrapper.eq(CartInfo::getProjectSku, cartInfoEditNumReq.getProjectSku());
this.update(updateWrapper);
Long userId = SecurityUtils.getUserId();
CartHashKey cartHashKey = CartHashKey.builder()
.projectId(cartInfoEditNumReq.getProjectId())
.projectSku(cartInfoEditNumReq.getProjectSku())
.build();
CartInfo cartInfo = this.cartCache.get(userId, cartHashKey);
cartInfo.setNum(cartInfoEditNumReq.getNum());
this.cartCache.put(userId, cartHashKey, cartInfo);
}
/**
*
*
* @param removeCartProjectReqList
*
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void removeByRemoveCartProjectList (List<RemoveCartProjectReq> removeCartProjectReqList) {
this.removeByIds(
removeCartProjectReqList.stream()
.map(RemoveCartProjectReq::getCartInfoId)
.toList()
);
Long userId = SecurityUtils.getUserId();
removeCartProjectReqList.stream()
.map(removeCartProjectReq -> CartHashKey.builder()
.projectId(removeCartProjectReq.getProjectId())
.projectSku(removeCartProjectReq.getProjectSku())
.build()
).forEach(hk -> this.cartCache.remove(userId, hk));
}
} }