puhanshu
2022-01-12 10cc0db30a1be5377e4c09bce349014a667849b6
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
package com.panzhihua.service_community.service.impl;
 
import static java.util.Objects.nonNull;
 
import java.util.ArrayList;
import java.util.List;
 
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.community.microCommercialStreet.McsConfigVO;
import com.panzhihua.service_community.dao.McsConfigDAO;
import com.panzhihua.service_community.entity.McsConfig;
import com.panzhihua.service_community.service.McsConfigService;
 
/**
 * (McsConfig)表服务实现类
 *
 * @author makejava
 * @since 2021-12-28 14:37:07
 */
@Service("mcsConfigService")
public class McsConfigServiceImpl extends ServiceImpl<McsConfigDAO, McsConfig> implements McsConfigService {
 
    /**
     * 获取所有数字商业街配置
     * @return
     */
    @Override
    public R getAllMcsConfig() {
        List<McsConfig> mcsConfigs = this.baseMapper.selectList(null);
        List<McsConfigVO> configList = new ArrayList<>();
        if (!mcsConfigs.isEmpty()) {
            mcsConfigs.forEach(e -> {
                McsConfigVO configVO = new McsConfigVO();
                BeanUtils.copyProperties(e, configVO);
                configList.add(configVO);
            });
        }
        return R.ok(configList);
    }
 
    /**
     * 修改数字商业街配置
     * @param configs
     * @return
     */
    @Override
    public R putMcsConfig(List<McsConfigVO> configs) {
        if (nonNull(configs) && !configs.isEmpty()) {
            List<McsConfig> mcsConfigs = new ArrayList<>();
            configs.forEach(e -> {
                McsConfig mcsConfig = this.baseMapper.selectOne(new QueryWrapper<McsConfig>().lambda().eq(McsConfig::getKey, e.getKey()));
                if (nonNull(mcsConfig)) {
                    mcsConfig.setValue(e.getValue());
                    mcsConfigs.add(mcsConfig);
                }
            });
            if (!mcsConfigs.isEmpty()) {
                this.updateBatchById(mcsConfigs);
            }
        }
        return R.ok();
    }
}