package com.reyun.saas.mob.user.service.impl;

import com.reyun.saas.common.core.AbstractService;
import com.reyun.saas.mob.user.domain.ConfigParam;
import com.reyun.saas.mob.user.service.ConfigParamService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;

@Slf4j
@Service
@Transactional
public class ConfigParamServiceImpl extends AbstractService<ConfigParam> implements ConfigParamService {

    @Override
    public String findByKey(String key) {
        ConfigParam keyParam = this.findBy("keyParam", key);
        return keyParam==null?null:keyParam.getValueParam();
    }

    @Override
    public void updateValueByKey(String key, String randomString) {
        Example example = new Example(ConfigParam.class);
        example.and().andEqualTo("keyParam",key);
        this.mapper.updateByExampleSelective(ConfigParam.builder().valueParam(randomString).build(),example);
    }
}
