guyue
2025-07-02 0a99c3a898976f64b53ca05751514bac8500ad60
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package com.linghu.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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;
 
/**
 * @author xy
 * @description 针对表【type】的数据库操作Service实现
 * @createDate 2025-07-02 16:32:19
 */
@Service
public class TypeServiceImpl extends ServiceImpl<TypeMapper, Type>
        implements TypeService {
 
    @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() {
        LambdaQueryWrapper<Type> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Type::getDelFlag, 0);
        return this.list(queryWrapper);
    }
}