package org.stm.act.metric.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.common.exception.JeecgBootException;
import org.springframework.stereotype.Service;
import org.stm.act.main.entity.StCaMain;
import org.stm.act.metric.entity.StCaMainMetric;
import org.stm.act.metric.entity.StMetric;
import org.stm.act.metric.mapper.StCaMainMetricMapper;
import org.stm.act.metric.mapper.StMetricMapper;
import org.stm.act.metric.service.IStCaMainMetricService;
import org.stm.utils.StmConstans;
import org.stm.utils.UserUtil;

/**
 * @Author: yzh
 * @Date 2023/3/27 21:53
 * @Description:
 */
@Service
public class StCaMainMetricServiceImpl extends ServiceImpl<StCaMainMetricMapper, StCaMainMetric> implements IStCaMainMetricService {



    @Override
    public boolean save(StCaMainMetric entity) {
        entity.setCreatedUser(UserUtil.getUserCode());
        entity.setValid(StmConstans.DEFAULT_VALID);
        entity.setApproveFlag(StmConstans.DEFAULT_APPROVE_Flag);
        return super.save(entity);
    }

    @Override
    public void removeByMetricNo(String metricNo) {
        QueryWrapper<StCaMainMetric> stCaMainMetricQueryWrapper = new QueryWrapper<>();
        stCaMainMetricQueryWrapper.eq("METRIC_NO",metricNo);
        super.remove(stCaMainMetricQueryWrapper);
    }

    @Override
    public void removeByMetricCaNo(String metricNo, String caNo) {
        QueryWrapper<StCaMainMetric> stCaMainMetricQueryWrapper = new QueryWrapper<>();
        stCaMainMetricQueryWrapper.eq("METRIC_NO",metricNo);
        stCaMainMetricQueryWrapper.eq("CA_NO",caNo);
        super.remove(stCaMainMetricQueryWrapper);
    }
}
