Search in sources :

Example 1 with StoreCollection

use of cn.lili.modules.member.entity.dos.StoreCollection in project lilishop by lilishop.

the class StoreCollectionServiceImpl method deleteStoreCollection.

@Override
@Transactional(rollbackFor = Exception.class)
public boolean deleteStoreCollection(String storeId) {
    QueryWrapper<StoreCollection> queryWrapper = new QueryWrapper();
    queryWrapper.eq("member_id", UserContext.getCurrentUser().getId());
    queryWrapper.eq("store_id", storeId);
    storeService.updateStoreCollectionNum(new CollectionDTO(storeId, -1));
    return this.remove(queryWrapper);
}
Also used : QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) CollectionDTO(cn.lili.modules.member.entity.dto.CollectionDTO) StoreCollection(cn.lili.modules.member.entity.dos.StoreCollection) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with StoreCollection

use of cn.lili.modules.member.entity.dos.StoreCollection in project lilishop by lilishop.

the class StoreCollectionServiceImpl method addStoreCollection.

@Override
@Transactional(rollbackFor = Exception.class)
public StoreCollection addStoreCollection(String storeId) {
    if (this.getOne(new LambdaUpdateWrapper<StoreCollection>().eq(StoreCollection::getMemberId, UserContext.getCurrentUser().getId()).eq(StoreCollection::getStoreId, storeId)) == null) {
        StoreCollection storeCollection = new StoreCollection(UserContext.getCurrentUser().getId(), storeId);
        this.save(storeCollection);
        storeService.updateStoreCollectionNum(new CollectionDTO(storeId, 1));
        return storeCollection;
    }
    throw new ServiceException(ResultCode.USER_COLLECTION_EXIST);
}
Also used : LambdaUpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper) ServiceException(cn.lili.common.exception.ServiceException) CollectionDTO(cn.lili.modules.member.entity.dto.CollectionDTO) StoreCollection(cn.lili.modules.member.entity.dos.StoreCollection) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

StoreCollection (cn.lili.modules.member.entity.dos.StoreCollection)2 CollectionDTO (cn.lili.modules.member.entity.dto.CollectionDTO)2 Transactional (org.springframework.transaction.annotation.Transactional)2 ServiceException (cn.lili.common.exception.ServiceException)1 QueryWrapper (com.baomidou.mybatisplus.core.conditions.query.QueryWrapper)1 LambdaUpdateWrapper (com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper)1