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