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.DyeRuleDefaultMapper;
import com.persagy.dye.pojo.dto.DyeRuleDefault;
import com.persagy.dye.service.IDyeRuleDefaultService;
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 DyeRuleDefaultServiceImpl extends SuperServiceImpl<DyeRuleDefaultMapper, DyeRuleDefault> implements IDyeRuleDefaultService {

    @Autowired
    private DyeRuleDefaultMapper dyeRuleDefaultMapper;

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