package com.whyc.service; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.whyc.mapper.StationPowerRelationMapper; import com.whyc.pojo.db_batt.StationPowerRelation; import org.springframework.stereotype.Service; import javax.annotation.Resource; @Service public class StationPowerRelationService { @Resource private StationPowerRelationMapper mapper; public void add(int stationId, int powerId) { StationPowerRelation relation = new StationPowerRelation(); relation.setStationId(stationId); relation.setPowerId(powerId); //获取最大num //int num = mapper.getMaxNum(); //relation.setNum(num+1); mapper.insert(relation); } public void deleteByPowerId(int powerId) { UpdateWrapper update = Wrappers.update(); update.eq("pinf_id",powerId); mapper.delete(update); } }