czt
2024-06-25 69270bd602eea005351e46089a00fe6604c21c08
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
package com.fzzy.api.view.pr;
 
import com.bstek.dorado.annotation.DataProvider;
import com.bstek.dorado.annotation.DataResolver;
import com.bstek.dorado.annotation.Expose;
import com.fzzy.api.entity.ApiConfs;
import com.fzzy.api.entity.ApiTrigger;
import com.fzzy.api.view.repository.ApiConfsRep;
 
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
 
/**
 * @author vince
 */
@Component
public class ApiConfsPR {
    @Autowired
    private ApiConfsRep apiConfsRep;
 
    /**
     * apiConfsPR#listAll
     *
     * @return
     * 
     * ${dorado.getDataProvider("apiConfsPR#listAll").getResult()}
     */
    @DataProvider
    public List<ApiConfs> listAll() {
        
        List<ApiConfs> list = apiConfsRep.findAll();
        
        if(null == list) return list;
        
        Random random = new Random();
        for (ApiConfs apiConfs : list) {
            apiConfs.setGrade(random.nextInt( 100 - 90 )  + 90);
        }
    
   
        return list;
    }
 
    /**
     * apiConfsPR#updateSave
     *
     * @param entity
     */
    @DataResolver
    public void updateSave(ApiConfs entity) {
        ApiConfs data = new ApiConfs();
        BeanUtils.copyProperties(entity, data);
        apiConfsRep.save(data);
    }
 
    /**
     * apiConfsPR#delData
     *
     * @param data
     */
    @Expose
    public String delData(ApiConfs data) {
 
        ApiConfs data2 = new ApiConfs();
        BeanUtils.copyProperties(data, data2);
 
        apiConfsRep.delete(data2);
        return null;
    }
 
    /**
     * 推送方式、同步方式
     * <p>
     * ${dorado.getDataProvider("apiConfsPR#triggerType").getResult()}
     *
     * @return
     */
    @DataProvider
    public List<ApiTrigger> triggerType() {
        List<ApiTrigger> list = new ArrayList<ApiTrigger>();
        list.add(new ApiTrigger(ApiConfs.SYNC_PUSH_AUTO, "自动"));
        list.add(new ApiTrigger(ApiConfs.SYNC_PUSH_HAND, "手动"));
        return list;
    }
 
    /**
     * 执行时间-天,周日为第一天
     * <p>
     * ${dorado.getDataProvider("apiConfsPR#triggerDay").getResult()}
     *
     * @return
     */
    @DataProvider
    public List<ApiTrigger> triggerDay() {
        List<ApiTrigger> list = new ArrayList<ApiTrigger>();
        list.add(new ApiTrigger(ApiConfs.TIME_ALL, "每天"));
        list.add(new ApiTrigger("2", "周一"));
        list.add(new ApiTrigger("3", "周二"));
        list.add(new ApiTrigger("4", "周三"));
        list.add(new ApiTrigger("5", "周四"));
        list.add(new ApiTrigger("6", "周五"));
        list.add(new ApiTrigger("7", "周六"));
        list.add(new ApiTrigger("1", "周末"));
        return list;
    }
 
    /**
     * 执行时间-时
     * <p>
     * ${dorado.getDataProvider("apiConfsPR#triggerHour").getResult()}
     *
     * @return
     */
    @DataProvider
    public List<ApiTrigger> triggerHour() {
        List<ApiTrigger> list = new ArrayList<ApiTrigger>();
        list.add(new ApiTrigger(ApiConfs.TIME_ALL, "每小时"));
        for (int i = 0; i < 24; i++) {
            list.add(new ApiTrigger(i + "", i + "点"));
        }
        return list;
    }
 
    /**
     * 执行时间-分钟
     * <p>
     * ${dorado.getDataProvider("apiConfsPR#triggerMinute").getResult()}
     *
     * @return
     */
    @DataProvider
    public List<ApiTrigger> triggerMinute() {
        List<ApiTrigger> list = new ArrayList<ApiTrigger>();
        list.add(new ApiTrigger("0", "0分"));
        list.add(new ApiTrigger("30", "30分"));
        return list;
    }
 
}