| package com.mzl.flower.service.flower; | 
|   | 
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
| 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.dto.request.flower.FlowerTagCreateDTO; | 
| import com.mzl.flower.dto.request.flower.FlowerTagQueryDTO; | 
| import com.mzl.flower.dto.request.flower.FlowerTagUpdateDTO; | 
| import com.mzl.flower.dto.response.flower.FlowerTagDTO; | 
| import com.mzl.flower.entity.flower.FlowerTag; | 
| import com.mzl.flower.mapper.flower.FlowerTagMapper; | 
| import com.mzl.flower.service.BaseService; | 
| import lombok.extern.slf4j.Slf4j; | 
| import org.springframework.beans.BeanUtils; | 
| import org.springframework.beans.factory.annotation.Autowired; | 
| import org.springframework.stereotype.Service; | 
| import org.springframework.transaction.annotation.Transactional; | 
|   | 
| import java.util.List; | 
|   | 
| @Slf4j | 
| @Service | 
| @Transactional | 
| public class FlowerTagService extends BaseService { | 
|   | 
|     @Autowired | 
|     private FlowerTagMapper tagMapper; | 
|   | 
|     public Long addTag(FlowerTagCreateDTO dto){ | 
|         FlowerTag g = new FlowerTag(); | 
|   | 
|         BeanUtils.copyProperties(dto, g); | 
|         g.create(SecurityUtils.getUserId()); | 
|   | 
|         tagMapper.insert(g); | 
|   | 
|         return g.getId(); | 
|     } | 
|   | 
|     public Long updateTag(FlowerTagUpdateDTO dto){ | 
|         Long id = dto.getId(); | 
|         FlowerTag g = tagMapper.selectById(id); | 
|   | 
|         BeanUtils.copyProperties(dto, g); | 
|         g.update(SecurityUtils.getUserId()); | 
|   | 
|         tagMapper.updateById(g); | 
|   | 
|         return id; | 
|     } | 
|   | 
|     public FlowerTagDTO getTag(String id){ | 
|         FlowerTagDTO dto = new FlowerTagDTO(); | 
|         FlowerTag d = tagMapper.selectById(id); | 
|         BeanUtils.copyProperties(d, dto); | 
|   | 
|         return dto; | 
|     } | 
|   | 
|     public Page<FlowerTagDTO> selectTagList(Page page, FlowerTagQueryDTO dto){ | 
|         List<FlowerTagDTO> ls = tagMapper.selectTagList(page, dto); | 
|   | 
|         page.setRecords(ls); | 
|   | 
|         return page; | 
|     } | 
|   | 
|     public void deleteTag(Long id){ | 
|         tagMapper.deleteById(id); | 
|     } | 
|   | 
| } |