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();
|
}
|
}
|