添加购物车

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
public Long get (K key) {
Long cacheValue = this.redisService.getCacheObject(encode(key));
if (cacheValue == null ){
if (cacheValue == null){
Long data = getData(key);
cacheValue = data == null ? 0L : data;
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 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.*;
import java.util.function.Function;
/**
@ -22,7 +19,9 @@ public abstract class HashCacheAbs<K, HK, HV> implements HashCache<K, HK, HV> {
/**
*
*
* @param key ID
*
* @return
*/
@Override
@ -166,14 +165,14 @@ public abstract class HashCacheAbs<K, HK, HV> implements HashCache<K, HK, HV> {
}
/**
* reidshashKey
* @param key redis
* redishashKey
*
* @param key redis
* @param hashKey hash
* @return
*/
@Override
public boolean hasKey(K key, HK hashKey) {
return redisService.hasKey(encode(key),encodeHashKey(hashKey));
public boolean hasKey (K key, HK hashKey) {
return redisService.hashKey(encode(key), encodeHashKey(hashKey));
}
/**

View File

@ -1,37 +1,20 @@
package com.muyu.product.cache;
import com.muyu.common.cache.HashCache;
import com.muyu.common.cache.abs.CacheAbs;
import com.muyu.common.core.text.Convert;
import com.muyu.product.cache.datasource.ProjectInfoData;
import com.muyu.product.domain.ProjectInfo;
import com.muyu.product.domain.ProjectSkuInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
/**
* @author yangle
* @author DongZl
* @description:
* @Date 2024-3-27 03:30
*/
@Component
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
private ProjectInfoData projectInfoData;

View File

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

View File

@ -8,7 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @author yangle
* @author DongZl
* @description: SKU
* @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;
/**
* RuleInfoCache
*
* @author LeYang
* on 2024/4/8
* @author DongZl
* @description:
* @Date 2024/4/7 8:29
*/
public class RuleInfoCache extends CacheAbs<Long, RuleCacheModel> {
public class RuleInfoCache extends CacheAbs<Long, RuleCacheModel> {
@Autowired
private RuleCacheData ruleCacheData;
/**
*
* @param key ID
* @return
* key
*
* @return key
*/
@Override
public RuleCacheModel getData(Long key) {
return ruleCacheData.getRulerCacheModel(key);
}
/**
*
* @return
*/
@Override
public RuleCacheModel defaultValue() {
return new RuleCacheModel();
}
/**
*
* @return key
*/
@Override
public String keyPre() {
return "rule:info";
public String keyPre () {
return "rule:info:";
}
/**
@ -52,7 +32,29 @@ public class RuleInfoCache extends CacheAbs<Long, RuleCacheModel> {
* @return ID
*/
@Override
public Long decode(String redisKey) {
public Long decode (String redisKey) {
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;
/**
* @author yangle
* @author DongZl
* @description:
* @Date 2024-3-27 03:34
*/

View File

@ -5,7 +5,7 @@ import com.muyu.product.domain.ProjectSkuInfo;
import java.util.Map;
/**
* @author yangle
* @author DongZl
* @description: SKU
* @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;
/**
* @author yangle
* @author DongZl
* @description: SKU
* @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;
/**
* RuleCacheData
*
* @author LeYang
* on 2024/4/8
* @author DongZl
* @description:
* @Date 2024/4/7 8:31
*/
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;
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.domain.ProjectInfo;
import com.muyu.product.domain.ProjectSkuInfo;
import com.muyu.product.remote.RemoteProjectInfoService;
import com.muyu.product.remote.RemoteProjectSkuService;
import org.springframework.beans.factory.annotation.Autowired;
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:
* @Date 2024-3-27 03:37
*/

View File

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

View File

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

View File

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

View File

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

View File

@ -10,16 +10,16 @@ import java.util.Arrays;
import java.util.List;
/**
*
*
* @author LeYang
* on 2024/4/8
* @author DongZl
* @description:
* @Date 2024/4/7 8:41
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@AllArgsConstructor
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()
.attrName(ruleAttrInfo.getName())
.attrValueList(Arrays.stream(ruleAttrInfo.getAttrValue().split(",")).toList())
.build();
}
}

View File

@ -8,20 +8,21 @@ import lombok.NoArgsConstructor;
import java.util.List;
/**
* RuleCacheModel
*
* @author LeYang
* on 2024/4/8
* @author DongZl
* @description:
* @Date 2024/4/7 8:27
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class RuleCacheModel {
/**
*
*/
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.product.domain.ProjectInfo;
import com.muyu.product.remote.factory.RemoteProjectInfoFactory;
import com.muyu.product.remote.factory.RemoteProjectSkuFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
/**
*
*
* @author LeYang
* on 2024/4/8
* @author DongZl
* @description:
* @Date 2024-4-7 10:58
*/
@FeignClient(
contextId = "remoteProjectInfoService",
value = ServiceNameConstants.PRODUCT_SERVICE,
@ -26,7 +23,7 @@ public interface RemoteProjectInfoService {
/**
*
*/
@GetMapping(value = "/{id}")
public Result<ProjectInfo> getInfo(@PathVariable("id") Long id);
@GetMapping(value = "/{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;
/**
* RemoteProjectSkuService
*
* @author LeYang
* on 2024/4/7
* @author DongZl
* @description:
* @Date 2024-4-7 10:58
*/
@FeignClient(
contextId = "remoteProjectSkuService",
@ -23,21 +22,21 @@ import java.util.List;
path = "/sku"
)
public interface RemoteProjectSkuService {
/**
* IDskusku
* @param projectId id
* @param projectSku sku
* @return sku
* IDSKUSKU
* @param projectId ID
* @param projectSku SKU
* @return SKU
*/
@GetMapping("/info/{projectId}/{projectSku}")
public Result<ProjectSkuInfo> getInfoByProjectIdAndSku(@PathVariable("projectId") Long projectId,
@PathVariable("projectSku") String projectSku);
/**
* IDSKU
* IDSKUSKU
* @param projectId ID
* @return SKU
*/
@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.domain.Result;
import com.muyu.product.domain.ProjectSkuInfo;
import com.muyu.product.domain.RuleAttrInfo;
import com.muyu.product.remote.factory.RemoteProjectSkuFactory;
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.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@ -11,10 +15,9 @@ import org.springframework.web.bind.annotation.PathVariable;
import java.util.List;
/**
*
*
* @author LeYang
* on 2024/4/8
* @author DongZl
* @description:
* @Date 2024-4-7 10:58
*/
@FeignClient(
contextId = "remoteRuleAttrService",
@ -23,6 +26,9 @@ import java.util.List;
path = "/ruleAttr"
)
public interface RemoteRuleAttrService {
/**
*
*/
@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.domain.Result;
import com.muyu.product.domain.ProjectSkuInfo;
import com.muyu.product.domain.RuleInfo;
import com.muyu.product.remote.factory.RemoteProjectSkuFactory;
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.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
/**
*
*
* @author LeYang
* on 2024/4/8
* @author DongZl
* @description:
* @Date 2024-4-7 10:58
*/
@FeignClient(
contextId = "remoteRuleService",
@ -22,8 +25,8 @@ import org.springframework.web.bind.annotation.PathVariable;
)
public interface RemoteRuleService {
/**
*
*
*/
@GetMapping(value = "/{id}")
public Result<RuleInfo> getInfo(@PathVariable("id") Long id );
@GetMapping(value = "/{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.product.domain.ProjectInfo;
import com.muyu.product.domain.RuleInfo;
import com.muyu.product.remote.RemoteProjectInfoService;
import com.muyu.product.remote.RemoteRuleService;
import org.springframework.cloud.openfeign.FallbackFactory;
/**
* RemoteProjectInfoFactory
*
* @author LeYang
* on 2024/4/8
* @author DongZl
* @description:
* @Date 2024-4-7 10:59
*/
public class RemoteProjectInfoFactory implements FallbackFactory<RemoteProjectInfoService> {
@Override
public RemoteProjectInfoService create(Throwable cause) {
return new RemoteProjectInfoService() {
/**
*
* @param id
* @return
*/
@Override
public Result<ProjectInfo> getInfo(Long id) {
return Result.error(cause.getMessage());
}
};
public RemoteProjectInfoService create (Throwable cause) {
return new RemoteProjectInfoService() {
/**
*
*
* @param id
*/
@Override
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 org.springframework.cloud.openfeign.FallbackFactory;
import java.rmi.Remote;
import java.util.List;
/**
* RemoteProjectSkuFactory
*
* @author LeYang
* on 2024/4/7
* @author DongZl
* @description:
* @Date 2024-4-7 10:59
*/
public class RemoteProjectSkuFactory implements FallbackFactory<RemoteProjectSkuService> {
@Override
public RemoteProjectSkuService create(Throwable cause) {
public RemoteProjectSkuService create (Throwable cause) {
return new RemoteProjectSkuService() {
@Override
public Result<ProjectSkuInfo> getInfoByProjectIdAndSku(Long projectId, String projectSku) {
public Result<ProjectSkuInfo> getInfoByProjectIdAndSku (Long projectId, String projectSku) {
return Result.error(cause.getMessage());
}
/**
* IDskusku
* IDSKUSKU
*
* @param projectId ID
* @return sku
*
* @return SKU
*/
@Override
public Result<List<ProjectSkuInfo>> listByProjectId(Long projectId) {
public Result<List<ProjectSkuInfo>> listByProjectId (Long projectId) {
return Result.error(cause.getMessage());
}
};

View File

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

View File

@ -1,28 +1,29 @@
package com.muyu.product.remote.factory;
import com.muyu.common.core.domain.Result;
import com.muyu.product.domain.ProjectSkuInfo;
import com.muyu.product.domain.RuleInfo;
import com.muyu.product.remote.RemoteProjectSkuService;
import com.muyu.product.remote.RemoteRuleService;
import org.springframework.cloud.openfeign.FallbackFactory;
/**
*
*
* @author LeYang
* on 2024/4/8
* @author DongZl
* @description:
* @Date 2024-4-7 10:59
*/
public class RemoteRuleFactory implements FallbackFactory<RemoteRuleService> {
@Override
public RemoteRuleService create(Throwable cause) {
public RemoteRuleService create (Throwable cause) {
return new RemoteRuleService() {
/**
*
*
*
* @param id
* @return
*/
@Override
public Result<RuleInfo> getInfo(Long id) {
public Result<RuleInfo> getInfo (Long id) {
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.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 org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
/**
* @author yangle
* @author DongZl
* @description:
* @Date 2024-2-26 04:07
*/

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -36,7 +36,7 @@ import com.muyu.product.service.CategoryInfoService;
/**
* Controller
*
* @author yangle
* @author DongZeLiang
* @date 2024-02-27
*/
@Api(tags = "品类信息")
@ -116,20 +116,18 @@ public class CategoryInfoController extends BaseController {
categoryInfoService.util(id,categoryInfoEditReq);
return toAjax(categoryInfoService.updateById(CategoryInfo.editBuild(id,categoryInfoEditReq)));
}
/**
*
*/
@RequiresPermissions("product:category:remove")
@Log(title = "品类信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
@DeleteMapping("/{ids}")
@ApiOperation("删除品类信息")
@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) {
categoryInfoService.removeBatchById(ids);
return toAjax(categoryInfoService.removeBatchByIds(ids));
}
}
/**
* ID
* @param categoryId ID

View File

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

View File

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

View File

@ -4,13 +4,17 @@ import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.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;
@ -36,7 +40,7 @@ import com.muyu.common.core.web.page.TableDataInfo;
/**
* Controller
*
* @author yangle
* @author DongZeLiang
* @date 2024-02-27
*/
@Api(tags = "商品信息")
@ -49,7 +53,8 @@ public class ProjectInfoController extends BaseController {
private AsProductAttributeInfoService asProductAttributeInfoService;
@Autowired
private ProjectSkuInfoService projectSkuInfoService;
@Autowired
private ProjectInfoCache projectInfoCache;
/**
*
*/
@ -92,14 +97,16 @@ public class ProjectInfoController extends BaseController {
@GetMapping(value = "/cache/{id}")
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
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("获取商品信息详细信息")
// @RequiresPermissions("product:info:query")
// @GetMapping(value = "/{id}")
// @ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
// 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<>();
asProductAttributeInfoLambdaQueryWrapper.eq(AsProductAttributeInfo::getProductId, id);
List<AsProductAttributeInfo> list = asProductAttributeInfoService.list(asProductAttributeInfoLambdaQueryWrapper);
ProjectInfo projectInfo = projectInfoService.getById(id);
LambdaQueryWrapper<ProjectSkuInfo> projectSkuInfoLambdaQueryWrapper = new LambdaQueryWrapper<>();
projectSkuInfoLambdaQueryWrapper.eq(ProjectSkuInfo::getProjectId,id);
@ -159,8 +167,4 @@ public class ProjectInfoController extends BaseController {
projectInfoService.del(ids);
return toAjax(projectInfoService.removeBatchByIds(ids));
}
}

View File

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

View File

@ -29,7 +29,7 @@ import com.muyu.common.core.web.page.TableDataInfo;
/**
* Controller
*
* @author yangle
* @author Leyang
* @date 2024-02-27
*/
@Api(tags = "规格详情")
@ -75,6 +75,14 @@ public class RuleAttrInfoController extends BaseController {
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")
@Log(title = "规格详情", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
@DeleteMapping("/{ids}")
@ApiOperation("删除规格详情")
@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) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
/**
* SKUService
*
* @author yangle
* @author DongZeLiang
* @date 2024-02-27
*/
public interface ProjectSkuInfoService extends IService<ProjectSkuInfo> {
@ -19,13 +19,7 @@ public interface ProjectSkuInfoService extends IService<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);
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -33,7 +33,7 @@ import java.util.stream.Stream;
/**
* Service
*
* @author yangle
* @author DongZeLiang
* @date 2024-02-27
*/
@Slf4j
@ -352,7 +352,6 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
if (asCategoryAttributeList != null && !asCategoryAttributeList.isEmpty()){
List<Long> templateAttributeIdList = asCategoryAttributeList.stream()
.map(AsCategoryAttribute::getAttributeId)
.filter(templateAttributeId -> !attributeIdSet.contains(templateAttributeId))
.toList();
templateAttributeModelList = attributeInfoService.listByIds(templateAttributeIdList).stream()
.map(AttributeInfo::buildTemplateModel)
@ -378,33 +377,7 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
.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
public void util(Long id, CategoryInfoEditReq categoryInfoEditReq) {
@ -413,7 +386,7 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
List<AsCategoryAttribute> list = asCategoryAttributeService.list(asCategoryAttribute);
ArrayList<Long> longs = new ArrayList<>();
for (AsCategoryAttribute categoryAttribute : list) {
longs.add(categoryAttribute.getId());
longs.add(categoryAttribute.getId());
}
asCategoryAttributeService.removeBatchByIds(longs);
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
*
* @author yangle
* @author DongZeLiang
* @date 2024-02-27
*/
@Slf4j

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -10,12 +10,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="groupId" column="group_id" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updataBy" column="updata_by" />
<result property="updataTime" column="updata_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
</resultMap>
<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>
</mapper>

View File

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

View File

@ -6,24 +6,26 @@ import com.muyu.shop.cart.domain.CartInfo;
import java.util.Map;
/**
* CartData
*
* @author LeYang
* on 2024/4/2
* @author yangle
* @description:
* @Date 2024-4-2 11:49
*/
public interface CartData {
/**
* hash
* @param key
* @return
*/
public Map<CartHashKey, CartInfo> getData(Long key);
/**
* hashhash
* @param key
* @param cartHashKey hash
* hash
* @param key
* @return
*/
public Map<CartHashKey, CartInfo> getData (Long key);
/**
* hashhash
*
* @param key
* @param hashKey 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
*/
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 {
private static final long serialVersionUID = 1L;
/** 商品 */
@ApiModelProperty(name = "商品", value = "商品", required = true)
private Long projectId;
/** sku */
@ApiModelProperty(name = "sku", value = "sku", required = true)
/** SKU */
@ApiModelProperty(name = "SKU", value = "SKU", required = true)
private String projectSku;
/** 数量 */
@ApiModelProperty(name = "数量", value = "数量", required = true)
private Long num;
}

View File

@ -4,7 +4,7 @@ import java.util.List;
import javax.servlet.http.HttpServletResponse;
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 org.springframework.beans.factory.annotation.Autowired;
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.security.annotation.RequiresPermissions;
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.common.core.web.page.TableDataInfo;
@ -36,7 +33,7 @@ import com.muyu.common.core.web.page.TableDataInfo;
*/
@Api(tags = "购物车")
@RestController
@RequestMapping("/info")
@RequestMapping("/Info")
public class CartInfoController extends BaseController {
@Autowired
private CartInfoService cartInfoService;
@ -45,7 +42,7 @@ public class CartInfoController extends BaseController {
*
*/
@ApiOperation("获取购物车列表")
@RequiresPermissions("shopCart:info:list")
@RequiresPermissions("shopCart:Info:list")
@GetMapping("/list")
public Result<TableDataInfo<CartInfo>> list(CartInfoQueryReq cartInfoQueryReq) {
startPage();
@ -57,7 +54,7 @@ public class CartInfoController extends BaseController {
*
*/
@ApiOperation("导出购物车列表")
@RequiresPermissions("shopCart:info:export")
@RequiresPermissions("shopCart:Info:export")
@Log(title = "购物车", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, CartInfo cartInfo) {
@ -70,13 +67,14 @@ public class CartInfoController extends BaseController {
*
*/
@ApiOperation("获取购物车详细信息")
@RequiresPermissions("shopCart:info:query")
@RequiresPermissions("shopCart:Info:query")
@GetMapping(value = "/{id}")
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
public Result<CartInfo> getInfo(@PathVariable("id") Long id) {
return Result.success(cartInfoService.getById(id));
}
@GetMapping("/detail")
public Result<CartDetailResp> 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)
@PostMapping
@ApiOperation("新增购物车")
@ -96,7 +94,7 @@ public class CartInfoController extends BaseController {
/**
*
*/
@RequiresPermissions("shopCart:info:edit")
@RequiresPermissions("shopCart:Info:edit")
@Log(title = "购物车", businessType = BusinessType.UPDATE)
@PutMapping("/{id}")
@ApiOperation("修改购物车")
@ -104,15 +102,48 @@ public class CartInfoController extends BaseController {
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)
@DeleteMapping("/{ids}")
@DeleteMapping("/{ids}")
@ApiOperation("删除购物车")
@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));
}
/**
*
*/
@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.baomidou.mybatisplus.extension.service.IService;
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
@ -29,4 +32,10 @@ public interface CartInfoService extends IService<CartInfo> {
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.List;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.muyu.common.core.exception.ServiceException;
import com.muyu.common.core.text.Convert;
import com.muyu.common.core.utils.ObjUtils;
import com.muyu.common.core.utils.ServletUtils;
import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.product.cache.ProjectInfoCache;
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.StatisticsCartModel;
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 org.apache.commons.lang3.SystemUtils;
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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.transaction.annotation.Transactional;
/**
* Service
@ -47,6 +53,18 @@ public class CartInfoServiceImpl extends ServiceImpl<CartInfoMapper, CartInfo>
@Autowired
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())){
queryWrapper.eq(CartInfo::getIsSelected, cartInfo.getIsSelected());
}
return list(queryWrapper);
}
@Autowired
private ProjectSkuStockCache projectSkuStockCache;
/**
*
* @param cartInfo
* @return
*
* @param cartInfo
*
* @return
*/
@Override
public boolean add(CartInfo cartInfo) {
public boolean add (CartInfo cartInfo) {
Long userId = SecurityUtils.getUserId();
CartHashKey cartHashKey = CartHashKey.builder()
.projectId(cartInfo.getUserId())
.projectId(cartInfo.getProjectId())
.projectSku(cartInfo.getProjectSku())
.build();
SkuStockKey skuStockKey = SkuStockKey.builder()
@ -98,68 +118,72 @@ private ProjectSkuStockCache projectSkuStockCache;
.sku(cartInfo.getProjectSku())
.build();
Long skuStock = Convert.toLong(projectSkuStockCache.get(skuStockKey), -1L);
if (cartCache.hasKey(userId, cartHashKey)) {
//取出来修改
if (cartCache.hasKey(userId, cartHashKey)){
// 取出来修改
CartInfo cartInfoCache = cartCache.get(userId, cartHashKey);
cartInfoCache.setNum(cartInfoCache.getNum()+ cartInfo.getNum());
if (skuStock<cartInfoCache.getNum()){
throw new ServiceException("当前库存不足");
cartInfoCache.setNum( cartInfoCache.getNum() + cartInfo.getNum());
if (skuStock < cartInfoCache.getNum()){
throw new ServiceException("当前库存不足");
}
LambdaQueryWrapper<CartInfo> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(CartInfo::getNum,cartInfoCache.getNum());
queryWrapper.eq(CartInfo::getId, cartInfoCache.getId());
this.update(queryWrapper);
this.cartCache.put(userId, cartHashKey,cartInfoCache);
LambdaUpdateWrapper<CartInfo> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.set(CartInfo::getNum, cartInfoCache.getNum());
updateWrapper.eq(CartInfo::getId, cartInfoCache.getId());
this.update(updateWrapper);
this.cartCache.put(userId, cartHashKey, cartInfoCache);
}else {
//存进去
// 存进去
if (skuStock < cartInfo.getNum()){
throw new ServiceException("当前库存不足");
}
cartInfo.setIsSelected("Y");
cartInfo.setUserId(userId);
cartInfo.setCreateBy(SecurityUtils.getUsername());
cartInfo.setCreateTime(new Date());
this.save(cartInfo);
this.cartCache.put(userId, cartHashKey,cartInfo);
this.cartCache.put(userId, cartHashKey, cartInfo);
}
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 -> {
ProjectSkuInfo projectSkuInfo =
projectSkuCache.get(cartInfo.getProjectId(), cartInfo.getProjectSku());
ProjectInfo projectInfo = projectInfoCache.get(cartInfo.getProjectId());
ProjectSkuInfo projectSkuInfo
= projectSkuCache.get(cartInfo.getProjectId(), cartInfo.getProjectSku());
ProjectInfo projectInfo
= projectInfoCache.get(cartInfo.getProjectId());
Long stock = projectSkuStockCache.get(
SkuStockKey.builder()
.projectId(cartInfo.getProjectId())
.sku(cartInfo.getProjectSku())
.build()
);
RuleCacheModel ruleInfoCacheData = ruleInfoCache.getData(projectInfo.getRuleId());
List<RuleAttrCacheModel> ruleAttrModelList = ruleInfoCacheData.getRuleAttrModelList();
// RuleCache
RuleCacheModel ruleInfoCacheModel = ruleInfoCache.getData(projectInfo.getRuleId());
List<RuleAttrCacheModel> ruleAttrModelList = ruleInfoCacheModel.getRuleAttrModelList();
List<SkuRuleModel> ruleModelList = new ArrayList<>();
String projectSku = cartInfo.getProjectSku();
String[] skuArr = projectSku.split("-");
for (int index = 0; index < skuArr.length; index++) {
for (int index = 0 ; index < skuArr.length ; index++) {
ruleModelList.add(
SkuRuleModel.builder().
ruleName(ruleAttrModelList.get(index).getAttrName())
SkuRuleModel.builder()
.ruleName(ruleAttrModelList.get(index).getAttrName())
.ruleValue(skuArr[index])
.build()
.build()
);
}
return CartSkuModel.builder()
.projectId(cartInfo.getProjectId())
.projectSku(cartInfo.getProjectSku())
.name(projectInfo.getName())
.image(projectSkuInfo.getImage())
.stock(stock)
@ -171,35 +195,107 @@ private ProjectSkuCache projectSkuCache;
.isSelected(cartInfo.getIsSelected())
.build();
}).toList();
List<CartSkuModel> cartSkuList = new ArrayList<>();
StatisticsCartModel statisticsCartModel = StatisticsCartModel.builder()
.total(cartSkuModelList.stream()
.mapToLong(CartSkuModel::getNum)
.sum()
.total(
cartSkuModelList.stream()
.filter(cartSkuModel -> cartSkuModel.getStock() > 0)
.mapToLong(CartSkuModel::getNum)
.sum()
)
.selectTotal(
cartSkuModelList.stream()
.filter(cartSkuModel -> "Y".equals(cartSkuModel.getIsSelected()))
.filter(cartSkuModel -> cartSkuModel.getStock() > 0)
.mapToLong(CartSkuModel::getNum)
.sum()
)
.priceTotal(
cartSkuModelList.stream()
.filter(cartSkuModel -> "Y".equals(cartSkuModel.getIsSelected()))
.filter(cartSkuModel -> cartSkuModel.getStock() > 0)
.map(CartSkuModel::getSubtotal)
.reduce(BigDecimal.ZERO, BigDecimal::add)
)
.actualTotal(
cartSkuModelList.stream()
.filter(cartSkuModel -> "Y".equals(cartSkuModel.getIsSelected()))
.filter(cartSkuModel -> cartSkuModel.getStock() > 0)
.map(CartSkuModel::getSubtotal)
.reduce(BigDecimal.ZERO, BigDecimal::add)
).build();
)
.build();
return CartDetailResp.builder()
.cartSkuList(cartSkuModelList)
.statisticsCart(statisticsCartModel)
.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));
}
}