龚焕茏
2024-04-12 7f950be0d43e4c622dcae5bf97cb470a8379dd66
ycl-server/src/main/java/com/ycl/platform/service/impl/YwThresholdServiceImpl.java
@@ -1,13 +1,20 @@
package com.ycl.platform.service.impl;
import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ycl.platform.domain.entity.YwThreshold;
import com.ycl.platform.domain.form.CarThresholdForm;
import com.ycl.platform.domain.form.FaceThresholdForm;
import com.ycl.platform.domain.form.VideoThresholdForm;
import com.ycl.platform.mapper.YwThresholdMapper;
import com.ycl.platform.service.IYwThresholdService;
import com.ycl.utils.DateUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Objects;
/**
 * 运维阈值Service业务层处理
@@ -16,7 +23,7 @@
 * @date 2024-03-25
 */
@Service
public class YwThresholdServiceImpl implements IYwThresholdService {
public class YwThresholdServiceImpl extends ServiceImpl<YwThresholdMapper, YwThreshold> implements IYwThresholdService {
    @Autowired
    private YwThresholdMapper ywThresholdMapper;
@@ -87,4 +94,37 @@
    public int deleteYwThresholdById(Integer id) {
        return ywThresholdMapper.deleteYwThresholdById(id);
    }
    @Override
    public int editFace(FaceThresholdForm form) {
        YwThreshold ywThreshold = baseMapper.selectById(form.getId());
        if (Objects.isNull(ywThreshold)) {
            throw new RuntimeException("数据不存在");
        }
        BeanUtils.copyProperties(form, ywThreshold);
        ywThreshold.setIndicator(JSON.toJSONString(form));
        return baseMapper.updateById(ywThreshold);
    }
    @Override
    public int editCar(CarThresholdForm form) {
        YwThreshold ywThreshold = baseMapper.selectById(form.getId());
        if (Objects.isNull(ywThreshold)) {
            throw new RuntimeException("数据不存在");
        }
        BeanUtils.copyProperties(form, ywThreshold);
        ywThreshold.setIndicator(JSON.toJSONString(form));
        return baseMapper.updateById(ywThreshold);
    }
    @Override
    public int editVideo(VideoThresholdForm form) {
        YwThreshold ywThreshold = baseMapper.selectById(form.getId());
        if (Objects.isNull(ywThreshold)) {
            throw new RuntimeException("数据不存在");
        }
        BeanUtils.copyProperties(form, ywThreshold);
        ywThreshold.setIndicator(JSON.toJSONString(form));
        return baseMapper.updateById(ywThreshold);
    }
}