admin
2020-05-20 98b1a0affd69bbe63223c21fdd2c404e8bedfccb
fanli/src/main/java/com/yeshi/fanli/service/impl/msg/MsgConfigServiceImpl.java
@@ -9,7 +9,7 @@
import com.google.gson.Gson;
import com.yeshi.fanli.dto.msg.MsgCommonDTO;
import com.yeshi.fanli.entity.common.Config;
import com.yeshi.fanli.exception.ConfigException;
import com.yeshi.fanli.exception.config.ConfigException;
import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.msg.MsgConfigService;
@@ -54,7 +54,7 @@
         Config config = new Config();
         config.setCreatetime(System.currentTimeMillis() + "");
         config.setKey(KEY_ZHUSHOU);
         config.setName("消息-返利券小助手");
         config.setName("消息-板栗快省小助手");
         config.setValue(new Gson().toJson(dto));
         configService.save(config);
      }
@@ -111,4 +111,46 @@
      return new Gson().fromJson(value.getValue(), MsgCommonDTO.class);
   }
   @Override
   public void addNotifyMsg(MsgCommonDTO dto) throws ConfigException {
      Config value = configService.getConfig(KEY_NOTIFY);
      if (StringUtil.isNullOrEmpty(dto.getContent()) || StringUtil.isNullOrEmpty(dto.getParams())
            || dto.getShow() == null)
         throw new ConfigException(1, "参数不完整");
      if (value != null) {
         MsgCommonDTO old = new Gson().fromJson(value.getValue(), MsgCommonDTO.class);
         old.setStartTime(dto.getStartTime());
         old.setShow(dto.getShow());
         old.setParams(dto.getParams());
         old.setEndTime(dto.getEndTime());
         old.setContent(dto.getContent());
         if (!StringUtil.Md5(dto.getContent() + "#" + dto.getPicture() + "#" + dto.getParams())
               .equalsIgnoreCase(old.getContentMd5())) {
            old.setUpdateTime(new Date());
         }
         old.setPicture(dto.getPicture());
         Config cf = new Config();
         cf.setId(value.getId());
         cf.setValue(new Gson().toJson(old));
         configService.update(cf);
      } else {
         dto.setContentMd5(StringUtil.Md5(dto.getContent() + "#" + dto.getPicture() + "#" + dto.getParams()));
         dto.setUpdateTime(new Date());
         Config config = new Config();
         config.setCreatetime(System.currentTimeMillis() + "");
         config.setKey(KEY_NOTIFY);
         config.setName("消息-大图通知");
         config.setValue(new Gson().toJson(dto));
         configService.save(config);
      }
   }
   @Override
   public MsgCommonDTO getNotifyMsg() {
      Config value = configService.getConfig(KEY_NOTIFY);
      if (value == null)
         return null;
      return new Gson().fromJson(value.getValue(), MsgCommonDTO.class);
   }
}