package com.persagy.dye.service.impl;

import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
import com.persagy.common.utils.DateUtil;
import com.persagy.db.service.impl.SuperServiceImpl;
import com.persagy.dye.constant.DyeConstant;
import com.persagy.dye.mapper.DyeRuleCustomMapper;
import com.persagy.dye.pojo.dto.DyeRuleCustom;
import com.persagy.dye.service.IDyeRuleCustomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * 染色规则自定义表
 *
 * @author yangwanyi
 * @version v1.0.0
 * @company persagy
 * @date 2021-10-25 15:58:56
 */
@Service
public class DyeRuleCustomServiceImpl extends SuperServiceImpl<DyeRuleCustomMapper, DyeRuleCustom> implements IDyeRuleCustomService {

    @Autowired
    private DyeRuleCustomMapper dyeRuleCustomMapper;

    /**
     * 根据主键逻辑删除染色规则自定义表信息
     *
     * @param dyeRuleCustomId 染色规则自定义表主键
     * @param updateUserId    修改人ID
     * @return boolean
     */
    @Override
    public boolean deleteDyeRuleCustomById(String dyeRuleCustomId, String updateUserId) {
        DyeRuleCustom dyeRuleCustom = this.dyeRuleCustomMapper.selectById(dyeRuleCustomId);
        if (dyeRuleCustom == null) {
            throw new RuntimeException("要删除的主键为" + dyeRuleCustomId + "的染色规则自定义表数据不存在");
        }
        dyeRuleCustom.setUpdateTime(DateUtil.format(new Date(), DateUtil.FORMAT_DATE_YYYY_MM_DD_HH_MM_SS));
        dyeRuleCustom.setUpdateUserId(updateUserId);
        dyeRuleCustom.setIsDelete(DyeConstant.DELETED);
        return SqlHelper.retBool(this.dyeRuleCustomMapper.updateById(dyeRuleCustom));
    }
}
