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.DyeBasicMapper;
import com.persagy.dye.pojo.dto.DyeBasic;
import com.persagy.dye.service.IDyeBasicService;
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 DyeBasicServiceImpl extends SuperServiceImpl<DyeBasicMapper, DyeBasic> implements IDyeBasicService {

    @Autowired
    private DyeBasicMapper dyeBasicMapper;

    /**
     * 根据主键逻辑删除染色基础表信息
     *
     * @param dyeBasicId   染色基础表主键
     * @param updateUserId 修改人ID
     * @return boolean
     */
    @Override
    public boolean deleteDyeBasicById(String dyeBasicId, String updateUserId) {
        DyeBasic dyeBasic = this.dyeBasicMapper.selectById(dyeBasicId);
        if (dyeBasic == null) {
            throw new RuntimeException("要删除的主键为" + dyeBasicId + "的染色基础表数据不存在");
        }
        dyeBasic.setUpdateTime(DateUtil.format(new Date(), DateUtil.FORMAT_DATE_YYYY_MM_DD_HH_MM_SS));
        dyeBasic.setUpdateUserId(updateUserId);
        dyeBasic.setIsDelete(DyeConstant.DELETED);
        return SqlHelper.retBool(this.dyeBasicMapper.updateById(dyeBasic));
    }
}
