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
74
75
76
77
package com.mzl.flower.service.payment;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mzl.flower.config.security.SecurityUtils;
import com.mzl.flower.dto.request.payment.FeeServiceCreateDTO;
import com.mzl.flower.dto.request.payment.FeeServiceUpdateDTO;
import com.mzl.flower.dto.response.payment.FeeServiceDTO;
import com.mzl.flower.entity.payment.FeeService;
import com.mzl.flower.mapper.payment.FeeServiceMapper;
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.ArrayList;
import java.util.List;
 
@Slf4j
@Service
@Transactional
public class FeeServiceService extends BaseService {
 
    @Autowired
    private FeeServiceMapper feeServiceMapper;
 
    public Long addConfig(FeeServiceCreateDTO dto){
        FeeService g = new FeeService();
 
        BeanUtils.copyProperties(dto, g);
        g.create(SecurityUtils.getUserId());
 
        feeServiceMapper.insert(g);
 
        return g.getId();
    }
 
    public Long updateConfig(FeeServiceUpdateDTO dto){
        Long id = dto.getId();
        FeeService g = feeServiceMapper.selectById(id);
 
        BeanUtils.copyProperties(dto, g);
        g.update(SecurityUtils.getUserId());
 
        feeServiceMapper.updateById(g);
 
        return id;
    }
 
    public FeeServiceDTO getConfig(Long id){
        FeeServiceDTO dto = new FeeServiceDTO();
        FeeService d = feeServiceMapper.selectById(id);
        BeanUtils.copyProperties(d, dto);
 
        return dto;
    }
 
    public List<FeeServiceDTO> selectConfigList(){
        List<FeeServiceDTO> ls = new ArrayList<>();
        List<FeeService> ll = feeServiceMapper.selectList(new QueryWrapper<FeeService>().orderByAsc("lower_num"));
        if(ll != null && ll.size() > 0){
            for(FeeService pl : ll){
                FeeServiceDTO dto = new FeeServiceDTO();
                BeanUtils.copyProperties(pl, dto);
                ls.add(dto);
            }
        }
 
        return ls;
    }
 
    public void deleteConfig(Long id){
        feeServiceMapper.deleteById(id);
    }
 
}