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

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.stm.act.metric.entity.StCaMainMetric;
import org.jeecg.modules.stm.act.metric.mapper.StCaMainMetricMapper;
import org.jeecg.modules.stm.act.metric.service.IStCaMainMetricService;
import org.springframework.stereotype.Service;
import org.jeecg.modules.stm.utils.StmConstans;
import org.jeecg.modules.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);
    }
}
