From e285517df2a3cb206282a41f958c80044422a552 Mon Sep 17 00:00:00 2001 From: guyue <1721849008@qq.com> Date: 星期一, 07 七月 2025 17:51:35 +0800 Subject: [PATCH] 基本增删改 --- src/main/java/com/linghu/service/impl/TypeServiceImpl.java | 40 ++++++++++++---------------------------- 1 files changed, 12 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/linghu/service/impl/TypeServiceImpl.java b/src/main/java/com/linghu/service/impl/TypeServiceImpl.java index d90f3a0..742ef35 100644 --- a/src/main/java/com/linghu/service/impl/TypeServiceImpl.java +++ b/src/main/java/com/linghu/service/impl/TypeServiceImpl.java @@ -1,49 +1,33 @@ package com.linghu.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.linghu.model.entity.Type; import com.linghu.service.TypeService; import com.linghu.mapper.TypeMapper; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import java.util.List; +import javax.annotation.Resource; /** * @author xy * @description 针对表【type】的数据库操作Service实现 - * @createDate 2025-07-02 16:32:19 + * @createDate 2025-07-04 20:10:31 */ @Service public class TypeServiceImpl extends ServiceImpl<TypeMapper, Type> implements TypeService { - + @Resource + private TypeMapper typeMapper; @Override - @Transactional(rollbackFor = Exception.class) - public boolean saveBatch(List<Type> types) { - types.forEach(type -> type.setDelFlag(0)); - return super.saveBatch(types); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public boolean updateBatchById(List<Type> types) { - return super.updateBatchById(types); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public boolean removeBatchByIds(List<Integer> typeIds) { - List<Type> types = this.listByIds(typeIds); - types.forEach(type -> type.setDelFlag(1)); - return this.updateBatchById(types); - } - - @Override - public List<Type> listAllAvailable() { + public Type getTypeByName(String typeName) { + // 查询 LambdaQueryWrapper<Type> queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(Type::getDelFlag, 0); - return this.list(queryWrapper); + queryWrapper.eq(Type::getType_name, typeName); + queryWrapper.eq(Type::getDel_flag, 0); + return typeMapper.selectOne(queryWrapper); + } + } -- Gitblit v1.7.1