xiaoyong931011
2022-10-10 d1c4c4b56f065d28cadf90370e0709294cfcdbc4
src/main/java/cc/mrbird/febs/dapp/service/impl/DappSystemServiceImpl.java
@@ -1,6 +1,7 @@
package cc.mrbird.febs.dapp.service.impl;
import cc.mrbird.febs.common.contants.AppContants;
import cc.mrbird.febs.common.entity.FebsResponse;
import cc.mrbird.febs.common.utils.LoginUserUtil;
import cc.mrbird.febs.common.utils.RedisUtils;
import cc.mrbird.febs.dapp.chain.ChainEnum;
@@ -21,8 +22,10 @@
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -925,4 +928,58 @@
        });
        return list;
    }
    @Override
    public List<DataDictionaryCustom> findDataDicByType(String type) {
        return dataDictionaryCustomMapper.selectDicByType(type);
    }
    @Override
    public void levelSystemSetting(Map<String, Object> map) {
        for (Map.Entry<String, Object> entry : map.entrySet()) {
            if (entry.getValue() instanceof String) {
                dataDictionaryCustomMapper.updateDicValueByTypeAndCode(null, entry.getKey(), (String) entry.getValue());
            } else {
                List<LinkedHashMap<String, Object>> value = (List<LinkedHashMap<String, Object>>) entry.getValue();
                for (LinkedHashMap<String, Object> dic : value) {
                    String type = (String) dic.get("type");
                    String code = (String) dic.get("code");
                    String dataValue = (String) dic.get("value");
                    dataDictionaryCustomMapper.updateDicValueByTypeAndCode(type, code, dataValue);
                }
            }
        }
    }
    @Override
    @Transactional
    public FebsResponse enableOnHook(Long id) {
        DataDictionaryCustom dataDictionaryCustom = dataDictionaryCustomMapper.selectById(id);
        if (ObjectUtil.isEmpty(dataDictionaryCustom)) {
            return new FebsResponse().fail().message("网络繁忙,请刷新当前页面");
        }
        String type = dataDictionaryCustom.getType();
        String code = dataDictionaryCustom.getCode();
        String dicValue = dataDictionaryCustom.getValue();
        cn.hutool.json.JSONObject jsonObject = JSONUtil.parseObj(dicValue);
        jsonObject.set("state",1);
        dataDictionaryCustomMapper.updateDicValueByTypeAndCode(type, code, jsonObject.toString());
        return new FebsResponse().success();
    }
    @Override
    public FebsResponse disableOnHook(Long id) {
        DataDictionaryCustom dataDictionaryCustom = dataDictionaryCustomMapper.selectById(id);
        if (ObjectUtil.isEmpty(dataDictionaryCustom)) {
            return new FebsResponse().fail().message("网络繁忙,请刷新当前页面");
        }
        String type = dataDictionaryCustom.getType();
        String code = dataDictionaryCustom.getCode();
        String dicValue = dataDictionaryCustom.getValue();
        cn.hutool.json.JSONObject jsonObject = JSONUtil.parseObj(dicValue);
        jsonObject.set("state",2);
        dataDictionaryCustomMapper.updateDicValueByTypeAndCode(type, code, jsonObject.toString());
        return new FebsResponse().success();
    }
}