MrShi
2025-08-19 ff087240b3dee29ce4e14ad0836e76b9fdf312cf
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
package com.doumee.service.system.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.doumee.core.constants.Constants;
import com.doumee.dao.system.SystemDictDataMapper;
import com.doumee.dao.system.model.SystemDictData;
import com.doumee.dao.system.vo.SystemQrcodeListVO;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.doumee.core.model.PageData;
import com.doumee.core.model.PageWrap;
import com.doumee.dao.system.SystemDictMapper;
import com.doumee.dao.system.dto.QuerySystemDictDTO;
import com.doumee.dao.system.model.SystemDict;
import com.doumee.dao.system.vo.SystemDictListVO;
import com.doumee.service.system.SystemDictService;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
 
import java.util.ArrayList;
import java.util.List;
 
/**
 * 字典Service实现
 * @author  dm
 * @since 2025/03/31 16:44
 */
@Service
public class SystemDictServiceImpl implements SystemDictService {
 
    @Autowired
    private SystemDictMapper systemDictMapper;
    @Autowired
    private SystemDictDataMapper systemDictDataMapper;
 
    @Override
    public Integer create(SystemDict systemDict) {
        systemDictMapper.insert(systemDict);
        return systemDict.getId();
    }
 
    @Override
    public void deleteById(Integer id) {
        SystemDict systemDict = new SystemDict();
        systemDict.setId(id);
        systemDict.setDeleted(Boolean.TRUE);
        this.updateById(systemDict);
    }
 
    @Override
    @Transactional
    public void deleteByIdInBatch(List<Integer> ids) {
        if (CollectionUtils.isEmpty(ids)) return;
        for (Integer id : ids) {
            this.deleteById(id);
        }
    }
 
    @Override
    public void updateById(SystemDict systemDict) {
        systemDictMapper.updateById(systemDict);
    }
 
    @Override
    @Transactional
    public void updateByIdInBatch(List<SystemDict> systemDicts) {
        if (CollectionUtils.isEmpty(systemDicts)) return;
        for (SystemDict systemDict: systemDicts) {
            this.updateById(systemDict);
        }
    }
 
    @Override
    public SystemDict findById(Integer id) {
        return systemDictMapper.selectById(id);
    }
 
    @Override
    public SystemDict findOne(SystemDict systemDict) {
        Wrapper<SystemDict> wrapper = new QueryWrapper<>(systemDict);
        return systemDictMapper.selectOne(wrapper);
    }
 
    @Override
    public List<SystemDict> findList(SystemDict systemDict) {
        Wrapper<SystemDict> wrapper = new QueryWrapper<>(systemDict);
        return systemDictMapper.selectList(wrapper);
    }
  
    @Override
    public PageData<SystemDictListVO> findPage(PageWrap<QuerySystemDictDTO> pageWrap) {
        PageHelper.startPage(pageWrap.getPage(), pageWrap.getCapacity());
        return PageData.from(new PageInfo<>(systemDictMapper.selectManageList(pageWrap.getModel(), pageWrap.getOrderByClause())));
    }
    @Override
    public List<SystemQrcodeListVO> qrcodeList(QuerySystemDictDTO pageWrap) {
        List<SystemQrcodeListVO> list = new ArrayList<>();
        SystemDict dict =systemDictMapper.selectOne(new LambdaQueryWrapper<SystemDict>().
                eq(SystemDict::getCode,Constants.QRCODE_URLS)
                .last("limit 1")) ;
        if(dict!=null){
            List<SystemDictData> dataList = systemDictDataMapper.selectList(new LambdaQueryWrapper<SystemDictData>().
                    eq(SystemDictData::getDictId,dict.getId()))   ;
            if(dataList!=null && dataList.size()>0){
                for(SystemDictData data :dataList){
                    SystemQrcodeListVO t = new SystemQrcodeListVO();
                    t.setId(data.getId()+"");
                    t.setName(data.getRemark());
                    t.setUrl(data.getCode());
                    if(StringUtils.equals(data.getLabel(),Constants.SHE_QRCODES_URL)
                            ||StringUtils.equals(data.getLabel(),Constants.DCA_QRCODES_URL)
                            ||StringUtils.equals(data.getLabel(),Constants.DBH_QRCODES_URL)){
                        list.add(t);
                    }
                }
            }
        }
        return list;
    }
 
    @Override
    public long count(SystemDict systemDict) {
        Wrapper<SystemDict> wrapper = new QueryWrapper<>(systemDict);
        return systemDictMapper.selectCount(wrapper);
    }
}