package com.hxh.spring.test; import com.alibaba.fastjson.JSONObject; import com.google.gson.Gson; import com.yeshi.buwan.dao.system.DetailSystemConfigDao; import com.yeshi.buwan.dao.system.SystemConfigDao; import com.yeshi.buwan.domain.jump.JumpDetail; import com.yeshi.buwan.domain.jump.JumpTypeEnum; import com.yeshi.buwan.domain.system.DetailSystemConfig; import com.yeshi.buwan.domain.system.SystemConfig; import com.yeshi.buwan.service.inter.system.SystemConfigService; import com.yeshi.buwan.vo.ad.BannerVO; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.web.WebAppConfiguration; import javax.annotation.Resource; import java.math.BigDecimal; import java.math.BigInteger; import java.util.Date; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = {"classpath:spring.xml"}) @WebAppConfiguration public class ConfigTest { @Resource private SystemConfigService systemConfigService; @Resource private SystemConfigDao systemConfigDao; @Resource private DetailSystemConfigDao detailSystemConfigDao; @Test public void addSystemConfig() { SystemConfig systemConfig = new SystemConfig(); // systemConfig.setBeizhu(""); // systemConfig.setKey("iqiyi_update_video_name"); // systemConfig.setName("爱奇艺特殊更新的视频名称"); // systemConfig.setValue("《卧底》,没关系,是青春啊!,山海情(原声版),我的时代,你的时代,你好,安怡"); // systemConfig.setCreateTime(new Date()); // systemConfig.setId(SystemConfig.createId(systemConfig.getKey())); // systemConfigDao.save(systemConfig); // // systemConfig = new SystemConfig(); // systemConfig.setBeizhu(""); // systemConfig.setKey("default_portrait"); // systemConfig.setName("默认头像"); // systemConfig.setValue("https://buwan-1255749512.cos.ap-guangzhou.myqcloud.com/resource/ic_portrait_default.png"); // systemConfig.setCreateTime(new Date()); // systemConfig.setId(SystemConfig.createId(systemConfig.getKey())); // systemConfigDao.save(systemConfig); systemConfig = new SystemConfig(); systemConfig.setBeizhu(""); systemConfig.setKey("miguLiveCategory"); systemConfig.setName("咪咕直播解析分类"); try { String LIVE_CATE = "[{\"name\":\"热门\",\"vomsID\":\"e7716fea6aa1483c80cfc10b7795fcb8\"},{\"name\":\"央视\",\"vomsID\":\"a5f78af9d160418eb679a6dd0429c920\"},{\"name\":\"卫视\",\"vomsID\":\"0847b3f6c08a4ca28f85ba5701268424\"},{\"name\":\"地方\",\"vomsID\":\"855e9adc91b04ea18ef3f2dbd43f495b\"},{\"name\":\"追剧\",\"vomsID\":\"dd5311d848b54c56acba186ff1107236\"},{\"name\":\"影视\",\"vomsID\":\"10b0d04cb23d4ac5945c4bc77c7ac44e\"},{\"name\":\"体育\",\"vomsID\":\"7538163cdac044398cb292ecf75db4e0\"},{\"name\":\"新闻\",\"vomsID\":\"c584f67ad63f4bc983c31de3a9be977c\"},{\"name\":\"教育\",\"vomsID\":\"af72267483d94275995a4498b2799ecd\"},{\"name\":\"娱乐\",\"vomsID\":\"192a12edfef04b5eb616b878f031f32f\"},{\"name\":\"少儿\",\"vomsID\":\"fc2f5b8fd7db43ff88c4243e731ecede\"},{\"name\":\"纪实\",\"vomsID\":\"e1165138bdaa44b9a3138d74af6c6673\"}]"; systemConfig.setValue(LIVE_CATE); } catch (Exception e) { e.printStackTrace(); } systemConfig.setCreateTime(new Date()); systemConfig.setId(SystemConfig.createId(systemConfig.getKey())); systemConfigDao.save(systemConfig); // systemConfig = new SystemConfig(); // systemConfig.setBeizhu(""); // systemConfig.setKey("goldCornRuleUrl"); // systemConfig.setName("影视豆规则"); // try { // systemConfig.setValue("http://www.baidu.com"); // } catch (Exception e) { // e.printStackTrace(); // } // systemConfig.setCreateTime(new Date()); // systemConfig.setId(SystemConfig.createId(systemConfig.getKey())); // systemConfigDao.save(systemConfig); } @Test public void addConfig() { JumpDetail jumpDetail = new JumpDetail(); jumpDetail.setType(JumpTypeEnum.web); jumpDetail.setNeedLogin(true); JSONObject params = new JSONObject(); params.put("url", "http://wwww.baidu.com"); BannerVO bannerVO = new BannerVO(); bannerVO.setJumpDetail(jumpDetail); bannerVO.setParams(params.toString()); bannerVO.setPicture("https://reviveimg.hellorf.com/www/images/b360addb728e079ffb082a161475b14e.png"); bannerVO.setRatio(new BigDecimal("0.1691")); DetailSystemConfig config = new DetailSystemConfig(); config.setKey("mine_page_banner"); config.setValue(new Gson().toJson(bannerVO)); config.setBeizhu("我的页面广告banner"); config.setSystemId(new BigInteger(44 + "")); config.setMinVersion(109); config.setCreatetime(System.currentTimeMillis() + ""); detailSystemConfigDao.save(config); } }