forked from liweijie/education
教室编号生成调整
This commit is contained in:
+22
@@ -2,6 +2,7 @@ package com.roomroot.jwgl.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.roomroot.common.utils.StringUtils;
|
||||
import com.roomroot.jwgl.entity.JSB;
|
||||
import com.roomroot.jwgl.mapper.ClassRoomMapper;
|
||||
import com.roomroot.jwgl.service.ClassRoomService;
|
||||
@@ -26,9 +27,30 @@ public class ClassRoomServiceImpl implements ClassRoomService {
|
||||
public void add(JSB jsb) {
|
||||
jsb.setId(UuidUtil.getUUID());
|
||||
jsb.setDelFlag(0);
|
||||
// 教室编号为非空列:留空时按现有最大数字编号 +1 自动生成
|
||||
if (StringUtils.isEmpty(jsb.getJsbh())) {
|
||||
jsb.setJsbh(nextJsbh());
|
||||
} else {
|
||||
jsb.setJsbh(jsb.getJsbh().trim());
|
||||
}
|
||||
jsbMapper.insert(jsb);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下一个教室编号(纯数字编号中取最大值 +1)
|
||||
*/
|
||||
private String nextJsbh() {
|
||||
String maxJsbh = jsbMapper.selectMaxJsbh();
|
||||
if (StringUtils.isEmpty(maxJsbh)) {
|
||||
return "1";
|
||||
}
|
||||
try {
|
||||
return String.valueOf(Integer.parseInt(maxJsbh.trim()) + 1);
|
||||
} catch (NumberFormatException e) {
|
||||
return "1";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(String id) {
|
||||
JSB jsb = getById(id);
|
||||
|
||||
Reference in New Issue
Block a user