|
@@ -1,13 +1,19 @@
|
|
|
package com.kxs.product.biz.service.impl;
|
|
package com.kxs.product.biz.service.impl;
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.kxs.common.core.constant.CacheConstants;
|
|
import com.kxs.common.core.constant.CacheConstants;
|
|
|
|
|
+import com.kxs.common.core.constant.enums.MachineTypeEnum;
|
|
|
|
|
+import com.kxs.common.security.util.SecurityUtils;
|
|
|
import com.kxs.product.api.model.KxsBrand;
|
|
import com.kxs.product.api.model.KxsBrand;
|
|
|
|
|
+import com.kxs.product.api.model.KxsMachine;
|
|
|
import com.kxs.product.api.vo.kxsapp.brand.BrandListVO;
|
|
import com.kxs.product.api.vo.kxsapp.brand.BrandListVO;
|
|
|
import com.kxs.product.biz.constant.ProductConstants;
|
|
import com.kxs.product.biz.constant.ProductConstants;
|
|
|
import com.kxs.product.biz.mapper.KxsBrandMapper;
|
|
import com.kxs.product.biz.mapper.KxsBrandMapper;
|
|
|
|
|
+import com.kxs.product.biz.mapper.KxsMachineMapper;
|
|
|
import com.kxs.product.biz.service.KxsBrandService;
|
|
import com.kxs.product.biz.service.KxsBrandService;
|
|
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.cache.annotation.CacheEvict;
|
|
import org.springframework.cache.annotation.CacheEvict;
|
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -21,10 +27,13 @@ import java.util.List;
|
|
|
* @since 2023-12-20 10:09:35
|
|
* @since 2023-12-20 10:09:35
|
|
|
*/
|
|
*/
|
|
|
@Service("kxsBrandService")
|
|
@Service("kxsBrandService")
|
|
|
|
|
+@RequiredArgsConstructor
|
|
|
public class KxsBrandServiceImpl extends ServiceImpl<KxsBrandMapper, KxsBrand> implements KxsBrandService {
|
|
public class KxsBrandServiceImpl extends ServiceImpl<KxsBrandMapper, KxsBrand> implements KxsBrandService {
|
|
|
|
|
|
|
|
|
|
+ private final KxsMachineMapper kxsMachineMapper;
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
- @CacheEvict(value = ProductConstants.BRAND_DETAILS, key = "'list'")
|
|
|
|
|
|
|
+// @CacheEvict(value = ProductConstants.BRAND_DETAILS, key = "'list'")
|
|
|
public Boolean sortByList(List<Integer> sorts) {
|
|
public Boolean sortByList(List<Integer> sorts) {
|
|
|
|
|
|
|
|
for (int i = 0; i < sorts.size(); i++) {
|
|
for (int i = 0; i < sorts.size(); i++) {
|
|
@@ -38,10 +47,34 @@ public class KxsBrandServiceImpl extends ServiceImpl<KxsBrandMapper, KxsBrand> i
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- @Cacheable(value = ProductConstants.BRAND_DETAILS, key = "'list'", unless = "#result.isEmpty()")
|
|
|
|
|
|
|
+// @Cacheable(value = ProductConstants.BRAND_DETAILS, key = "'list'", unless = "#result.isEmpty()")
|
|
|
public List<BrandListVO> getSortByList() {
|
|
public List<BrandListVO> getSortByList() {
|
|
|
|
|
|
|
|
- return baseMapper.getSortByList();
|
|
|
|
|
|
|
+ Long userId = SecurityUtils.getUser().getId();
|
|
|
|
|
+
|
|
|
|
|
+ List<BrandListVO> brandList = baseMapper.getSortByList();
|
|
|
|
|
+ for (BrandListVO brandListVO : brandList) {
|
|
|
|
|
+ Long totalCount = kxsMachineMapper.selectCount(Wrappers.<KxsMachine>lambdaQuery()
|
|
|
|
|
+ .eq(KxsMachine::getUserId, userId)
|
|
|
|
|
+ .eq(KxsMachine::getBrandId, brandListVO.getId()));
|
|
|
|
|
+ brandListVO.setTotalMachineCount(totalCount == null ? 0L : totalCount);
|
|
|
|
|
+
|
|
|
|
|
+ Long unBindCount = kxsMachineMapper.selectCount(Wrappers.<KxsMachine>lambdaQuery()
|
|
|
|
|
+ .eq(KxsMachine::getUserId, userId)
|
|
|
|
|
+ .eq(KxsMachine::getBindStatus, MachineTypeEnum.NO_BIND.getType())
|
|
|
|
|
+ .eq(KxsMachine::getBrandId, brandListVO.getId()));
|
|
|
|
|
+ brandListVO.setUnBindCount(unBindCount == null ? 0L : unBindCount);
|
|
|
|
|
+
|
|
|
|
|
+ Long bindCount = kxsMachineMapper.selectCount(Wrappers.<KxsMachine>lambdaQuery()
|
|
|
|
|
+ .eq(KxsMachine::getUserId, userId)
|
|
|
|
|
+ .eq(KxsMachine::getBindStatus, MachineTypeEnum.BIND.getType())
|
|
|
|
|
+ .eq(KxsMachine::getBrandId, brandListVO.getId()));
|
|
|
|
|
+ brandListVO.setBindCount(bindCount == null ? 0L : bindCount);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ return brandList;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|