admin
2021-04-14 759f8df85ddb840682f91bad31e874fa0b58c075
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
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.HomeType;
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.dto.order.PPTVVideoPrice;
import com.yeshi.buwan.job.AdJob;
import com.yeshi.buwan.service.imp.DetailSystemConfigService;
import com.yeshi.buwan.service.inter.system.SystemConfigService;
import com.yeshi.buwan.util.rank.IqiyiRankUtil;
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.io.IOException;
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("videoPrice");
        systemConfig.setName("单片价格");
        try {
            systemConfig.setValue(new Gson().toJson(new PPTVVideoPrice(new BigDecimal("5"), new BigDecimal(3), "6折")));
        } 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);
    }
 
 
}