| | |
| | | package com.whyc.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.whyc.mapper.EnvironmentThresholdMapper; |
| | | import com.whyc.pojo.db_fire_robot.EnvironmentThreshold; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | public void add(EnvironmentThreshold threshold) { |
| | | mapper.insert(threshold); |
| | | } |
| | | |
| | | public void addOrUpdate(EnvironmentThreshold threshold) { |
| | | QueryWrapper<EnvironmentThreshold> query = Wrappers.query(); |
| | | query.last(" limit 1"); |
| | | EnvironmentThreshold thresholdInDB = mapper.selectOne(query); |
| | | if (thresholdInDB ==null) { |
| | | mapper.insert(threshold); |
| | | }else{ |
| | | threshold.setId(thresholdInDB.getId()); |
| | | mapper.updateById(threshold); |
| | | } |
| | | } |
| | | } |