package com.miaxis.goods.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.miaxis.common.core.domain.Response;
import com.miaxis.goods.domain.GoodsInfo;
import com.miaxis.goods.mapper.GoodsInfoMapper;
import com.miaxis.goods.service.IGoodsInfoService;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 商品Service业务层处理
 *
 * @author miaxis
 * @date 2021-03-11
 */
@Service
@RequiredArgsConstructor
public class GoodsInfoServiceImpl extends ServiceImpl<GoodsInfoMapper, GoodsInfo> implements IGoodsInfoService {

    private final GoodsInfoMapper goodsInfoMapper;

    /**
     * 删除商品
     * @param ids
     * @return
     */
    @Override
    @SneakyThrows
    @Transactional(rollbackFor = Exception.class)
    public Response<Integer> removeGoodsByIds(Long[] ids) {
        for (Long id : ids) {
            this.update(new UpdateWrapper<GoodsInfo>().set("status",1).eq("id",id));
        }
        return Response.success();
    }

}
