feat:
1. add favorite module functions
This commit is contained in:
@@ -207,4 +207,17 @@ public class MarketMerchantController {
|
|||||||
return R.data(inventoryService.selectStoreFavoriteList(AuthUtil.getUserId()));
|
return R.data(inventoryService.selectStoreFavoriteList(AuthUtil.getUserId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/add-favorite")
|
||||||
|
@ApiOperationSupport(order = 22)
|
||||||
|
@Operation(summary = "收藏店铺")
|
||||||
|
public R addFavorite(@Valid @RequestBody AddFavoriteRequest request) {
|
||||||
|
return R.status(inventoryService.addFavorite(AuthUtil.getUserId(), request.getId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/del-favorite")
|
||||||
|
@ApiOperationSupport(order = 22)
|
||||||
|
@Operation(summary = "取消收藏")
|
||||||
|
public R deleteFavorite(@Valid @RequestBody DeleteFavoriteRequest request) {
|
||||||
|
return R.status(inventoryService.deleteFavorite(AuthUtil.getUserId(), request.getId()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package org.springblade.modules.api.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class AddFavoriteRequest implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package org.springblade.modules.api.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class DeleteFavoriteRequest implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
}
|
||||||
@@ -70,4 +70,8 @@ public interface IMerchantInventoryService extends BaseService<MerchantInventory
|
|||||||
MerchantProductDetailApiVO getDetailById(Long userId, Long id);
|
MerchantProductDetailApiVO getDetailById(Long userId, Long id);
|
||||||
|
|
||||||
List<MerchantStoreFavoriteApiVO> selectStoreFavoriteList(Long userId);
|
List<MerchantStoreFavoriteApiVO> selectStoreFavoriteList(Long userId);
|
||||||
|
|
||||||
|
boolean addFavorite(Long userId, Long inventoryId);
|
||||||
|
|
||||||
|
boolean deleteFavorite(Long userId, Long favoriteId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,10 +38,7 @@ import org.springblade.modules.market.eums.*;
|
|||||||
import org.springblade.modules.market.mapper.MerchantInventoryMapper;
|
import org.springblade.modules.market.mapper.MerchantInventoryMapper;
|
||||||
import org.springblade.modules.market.pojo.dto.MarketBenefitPointApiDTO;
|
import org.springblade.modules.market.pojo.dto.MarketBenefitPointApiDTO;
|
||||||
import org.springblade.modules.market.pojo.dto.MarketCashCouponApiDTO;
|
import org.springblade.modules.market.pojo.dto.MarketCashCouponApiDTO;
|
||||||
import org.springblade.modules.market.pojo.entity.MarketInfoEntity;
|
import org.springblade.modules.market.pojo.entity.*;
|
||||||
import org.springblade.modules.market.pojo.entity.MerchantInventoryEntity;
|
|
||||||
import org.springblade.modules.market.pojo.entity.MerchantCatalogEntity;
|
|
||||||
import org.springblade.modules.market.pojo.entity.MerchantPayoutAccountEntity;
|
|
||||||
import org.springblade.modules.market.pojo.vo.MerchantInventoryVO;
|
import org.springblade.modules.market.pojo.vo.MerchantInventoryVO;
|
||||||
import org.springblade.modules.market.service.*;
|
import org.springblade.modules.market.service.*;
|
||||||
import org.springblade.modules.system.pojo.entity.User;
|
import org.springblade.modules.system.pojo.entity.User;
|
||||||
@@ -386,6 +383,34 @@ public class MerchantInventoryServiceImpl extends BaseServiceImpl<MerchantInvent
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean addFavorite(Long userId, Long inventoryId) {
|
||||||
|
if(Objects.isNull(userId) || Objects.isNull(inventoryId)){
|
||||||
|
throw new ServiceException("无效参数");
|
||||||
|
}
|
||||||
|
MerchantInventoryEntity inventory = getById(inventoryId);
|
||||||
|
if (Objects.isNull(inventory)){
|
||||||
|
throw new ServiceException("无效商品");
|
||||||
|
}
|
||||||
|
if (favoriteService.hasFavorite(userId, inventory.getUserId())){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
MerchantStoreFavoriteEntity favorite = new MerchantStoreFavoriteEntity();
|
||||||
|
favorite.setUserId(userId);
|
||||||
|
favorite.setMerchantId(inventory.getUserId());
|
||||||
|
favorite.setStoreName(inventory.getStoreName());
|
||||||
|
return favoriteService.save(favorite);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean deleteFavorite(Long userId, Long favoriteId) {
|
||||||
|
return favoriteService.update(Wrappers.lambdaUpdate(MerchantStoreFavoriteEntity.class)
|
||||||
|
.set(MerchantStoreFavoriteEntity::getIsDeleted, 1)
|
||||||
|
.eq(MerchantStoreFavoriteEntity::getId, favoriteId)
|
||||||
|
.eq(MerchantStoreFavoriteEntity::getUserId, userId)
|
||||||
|
.eq(MerchantStoreFavoriteEntity::getIsDeleted, 0));
|
||||||
|
}
|
||||||
|
|
||||||
private String desensitizationByName(String name) {
|
private String desensitizationByName(String name) {
|
||||||
return name.replaceAll("^(.).*$", "$1" + "*".repeat(name.length() - 1));
|
return name.replaceAll("^(.).*$", "$1" + "*".repeat(name.length() - 1));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user