cloudroam
3 天以前 3a819e4f668c15e8b77b188b322470da12bb7a43
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package com.mzl.flower.service.supplier;
 
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mzl.flower.config.exception.ValidationException;
import com.mzl.flower.config.security.SecurityUtils;
import com.mzl.flower.entity.supplier.SupplierType;
import com.mzl.flower.mapper.supplier.SupplierTypeMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import java.util.List;
 
@Service
@Transactional
public class SupplierTypeService {
 
    private final SupplierTypeMapper supplierTypeMapper;
 
    public SupplierTypeService(SupplierTypeMapper supplierTypeMapper) {
        this.supplierTypeMapper = supplierTypeMapper;
    }
 
    public void add(SupplierType dto) {
        dto.create(SecurityUtils.getUserId());
        supplierTypeMapper.insert(dto);
    }
 
 
    public void update(SupplierType dto) {
        if(dto.getId()==null){
            throw new ValidationException("id不能为空");
        }
        dto.update(SecurityUtils.getUserId());
        supplierTypeMapper.updateById(dto);
    }
 
    public void delete(Long id) {
        supplierTypeMapper.deleteById(id);
    }
 
    public SupplierType detail(Long id) {
        return supplierTypeMapper.selectById(id);
    }
 
    public IPage<SupplierType> queryPage(String name, Page page) {
        LambdaQueryWrapper<SupplierType> queryWrapper = new LambdaQueryWrapper<>();
        if(StringUtils.isNotBlank(name)){
            queryWrapper.like(SupplierType::getName,name);
        }
        IPage iPage = supplierTypeMapper.selectPage(page, queryWrapper);
        return iPage;
    }
 
    public List<SupplierType> queryList(String name) {
        LambdaQueryWrapper<SupplierType> queryWrapper = new LambdaQueryWrapper<>();
        if(StringUtils.isNotBlank(name)){
            queryWrapper.like(SupplierType::getName,name);
        }
        List<SupplierType> list = supplierTypeMapper.selectList(queryWrapper);
        return list;
    }
}