From 4df0355c0fd05ca7b17d74d05614c83926fcfdb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=8D=9A?= Date: Fri, 18 Oct 2024 16:36:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=AF=81=E4=B9=A6=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/TenPersonCertServiceImpl.java | 38 +++++++++++++++++++ .../impl/TenPersonTrainServiceImpl.java | 38 +++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenPersonCertServiceImpl.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenPersonTrainServiceImpl.java diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenPersonCertServiceImpl.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenPersonCertServiceImpl.java new file mode 100644 index 0000000..063b5b3 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenPersonCertServiceImpl.java @@ -0,0 +1,38 @@ +package net.shapelight.modules.ten.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import net.shapelight.common.utils.MyBeanUtils; +import net.shapelight.modules.ten.entity.TenPersonCert; +import net.shapelight.modules.ten.entity.TenPersonEntity; +import net.shapelight.modules.ten.service.TenPersonCertService; +import net.shapelight.modules.ten.dao.TenPersonCertDao; +import org.springframework.stereotype.Service; + +/** +* @author zhangbo +* @description 针对表【ten_person_cert】的数据库操作Service实现 +* @createDate 2024-10-16 19:43:27 +*/ +@Service +public class TenPersonCertServiceImpl extends ServiceImpl implements TenPersonCertService{ + + /** + * 可以根据其他字段批量更新或新增 + * + * @param entity 对象 + * @param fieldName 字段名称 + * @return 操作结果 + */ + public void saveOrUpdateByField(TenPersonCert entity, String fieldName) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq(fieldName, MyBeanUtils.getFieldValueByName(entity,fieldName)); + TenPersonCert existEntity = this.getOne(queryWrapper); + + if (existEntity == null) { + this.save(entity); + } else { + this.updateById(entity); + } + } +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenPersonTrainServiceImpl.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenPersonTrainServiceImpl.java new file mode 100644 index 0000000..7ec3b2c --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenPersonTrainServiceImpl.java @@ -0,0 +1,38 @@ +package net.shapelight.modules.ten.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import net.shapelight.common.utils.MyBeanUtils; +import net.shapelight.modules.ten.entity.TenPersonTrain; +import net.shapelight.modules.ten.service.TenPersonTrainService; +import net.shapelight.modules.ten.dao.TenPersonTrainDao; +import org.springframework.stereotype.Service; + +/** +* @author zhangbo +* @description 针对表【ten_person_train】的数据库操作Service实现 +* @createDate 2024-10-16 19:50:29 +*/ +@Service +public class TenPersonTrainServiceImpl extends ServiceImpl +implements TenPersonTrainService{ + + /** + * 可以根据其他字段批量更新或新增 + * + * @param entity 对象 + * @param fieldName 字段名称 + * @return 操作结果 + */ + public void saveOrUpdateByField(TenPersonTrain entity, String fieldName) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq(fieldName, MyBeanUtils.getFieldValueByName(entity,fieldName)); + TenPersonTrain existEntity = this.getOne(queryWrapper); + + if (existEntity == null) { + this.save(entity); + } else { + this.updateById(entity); + } + } +}