package com.xingxi.web.controller.master.product.service.impl;

import com.xingxi.common.enums.EDelFlag;
import com.xingxi.common.utils.DateUtils;
import com.xingxi.common.utils.ShiroUtils;
import com.xingxi.master.product.mapper.ProdPicMapper;
import com.xingxi.web.controller.master.product.domain.ProdPicVo;
import com.xingxi.web.controller.master.product.mapper.ProdPicVoMapper;
import com.xingxi.web.controller.master.product.service.IProdPicVoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 商品标签Service业务层处理
 *
 * @author xingxi
 * @date 2025-03-06
 */
@Service
public class ProdPicVoServiceImpl implements IProdPicVoService {
    @Resource
    private ProdPicVoMapper prodPicVoMapper;
    @Resource
    private ProdPicMapper prodPicMapper;

    /**
     * 查询商品标签列表
     *
     * @param prodPicVo 商品标签
     * @return 商品标签
     */
    @Override
    public List<ProdPicVo> selectProdPicVoList(ProdPicVo prodPicVo) {
        prodPicVo.setDelFlag(EDelFlag.NO.getVal());
        return prodPicVoMapper.selectProdPicVoList(prodPicVo);
    }

    /**
     * 添加商品标签
     *
     * @param prodPicVo 商品标签Vo
     * @return 影响行数
     */
    @Override
    public int addProdPic(ProdPicVo prodPicVo) {
        prodPicVo.setDelFlag(EDelFlag.NO.getVal());
        prodPicVo.setCreateUser(ShiroUtils.getLoginName());
        prodPicVo.setCreateTime(DateUtils.getNowDate());
        return prodPicMapper.insertProdPic(prodPicVo);
    }

    /**
     * 删除商品标签
     *
     * @param prodPicVo 商品标签Vo
     * @return 影响行数
     */
    @Override
    public int logicDeleteProdPicByCondition(ProdPicVo prodPicVo) {
        prodPicVo.setUpdateUser(ShiroUtils.getLoginName());
        prodPicVo.setUpdateTime(DateUtils.getNowDate());
        return prodPicVoMapper.logicDeleteProdPicByCondition(prodPicVo);
    }
}
