package com.whyc.service; 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); } }