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
67
68
69
70
71
72
73
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);
    }
 
}