41 lines
1.3 KiB
Java
41 lines
1.3 KiB
Java
package com.gunshi.project.hsz.service;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.gunshi.project.hsz.mapper.BroadcastStationMapper;
|
|
import com.gunshi.project.hsz.model.BroadcastStation;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
/**
|
|
* 描述: 广播预警站
|
|
* author: xusan
|
|
* date: 2024-09-25 10:19:15
|
|
*/
|
|
@Service
|
|
@Slf4j
|
|
@Transactional(rollbackFor = Exception.class)
|
|
public class BroadcastStationService extends ServiceImpl<BroadcastStationMapper, BroadcastStation>
|
|
{
|
|
|
|
public BroadcastStation saveData(BroadcastStation dto) {
|
|
dto.setId(IdWorker.getId());
|
|
QueryWrapper<BroadcastStation> queryWrapper = new QueryWrapper<>();
|
|
queryWrapper.orderBy(true, false, "order_index");
|
|
BroadcastStation lastOne = super.getOne(queryWrapper, false);
|
|
int order = 0;
|
|
if (lastOne == null) {
|
|
order = 1;
|
|
} else {
|
|
order = lastOne.getOrderIndex() + 1;
|
|
}
|
|
dto.setOrderIndex(order);
|
|
this.save(dto);
|
|
return dto;
|
|
}
|
|
}
|
|
|
|
|