| package cc.mrbird.febs.mall.service.impl; | 
|   | 
| import cc.mrbird.febs.common.utils.AppContants; | 
| import cc.mrbird.febs.common.utils.RedisUtils; | 
| import cc.mrbird.febs.mall.entity.AppVersion; | 
| import cc.mrbird.febs.mall.entity.DataDictionaryCustom; | 
| import cc.mrbird.febs.mall.mapper.AppVersionMapper; | 
| import cc.mrbird.febs.mall.mapper.DataDictionaryCustomMapper; | 
| import cc.mrbird.febs.mall.service.ICommonService; | 
| import cn.hutool.core.util.StrUtil; | 
| import com.alibaba.fastjson.JSONObject; | 
| import lombok.RequiredArgsConstructor; | 
| import lombok.extern.slf4j.Slf4j; | 
| import org.springframework.stereotype.Service; | 
|   | 
| import java.util.List; | 
|   | 
| /** | 
|  * @author wzy | 
|  * @date 2021-09-16 | 
|  **/ | 
| @Slf4j | 
| @Service | 
| @RequiredArgsConstructor | 
| public class CommonService implements ICommonService { | 
|     private final RedisUtils redisUtils; | 
|     private final DataDictionaryCustomMapper dataDictionaryCustomMapper; | 
|     private final AppVersionMapper appVersionMapper; | 
|   | 
|     @Override | 
|     public boolean verifyCode(String account, String code) { | 
|         if ("SMS_CODE".equals(code)) { | 
|             return true; | 
|         } | 
|   | 
|         String cacheCode = redisUtils.getString(AppContants.VERIFY_CODE_PREFIX + account); | 
|         if (StrUtil.isBlank(cacheCode)) { | 
|             return false; | 
|         } | 
|         if (code.equals(cacheCode)) { | 
|             redisUtils.del(AppContants.VERIFY_CODE_PREFIX + account); | 
|             return true; | 
|         } else { | 
|             return false; | 
|         } | 
|     } | 
|   | 
|     @Override | 
|     public List<DataDictionaryCustom> findDataDicByType(String type) { | 
|         return dataDictionaryCustomMapper.selectDicByType(type); | 
|     } | 
|   | 
|     @Override | 
|     public List<AppVersion> findAppVersion() { | 
|         return appVersionMapper.selectList(null); | 
|     } | 
|   | 
|     @Override | 
|     public void addDataDic(String type, String code, Object value, String description) { | 
|         DataDictionaryCustom dic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(type, code); | 
|   | 
|         String data = JSONObject.toJSONString(value); | 
|         if (dic != null) { | 
|             dic.setValue(data); | 
|             dataDictionaryCustomMapper.updateById(dic); | 
|             return; | 
|         } | 
|   | 
|         dic = new DataDictionaryCustom(); | 
|         dic.setCode(code); | 
|         dic.setType(type); | 
|         dic.setValue(data); | 
|         dic.setDescription(description); | 
|         dataDictionaryCustomMapper.insert(dic); | 
|     } | 
| } |