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); + } + } +}