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;
|
}
|
|
}
|