CZT
2023-10-07 4676c3c00f3e56ed65c149f4dd2c2697e0f1890c
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
package com.fzzy.api.view.pr;
 
import com.bstek.dorado.annotation.DataProvider;
import com.bstek.dorado.annotation.Expose;
import com.fzzy.api.Constant;
import com.fzzy.api.entity.ApiTrigger;
import com.fzzy.api.utils.ContextUtil;
import com.fzzy.api.view.repository.ApiTriggerRep;
 
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
 
import java.util.List;
 
/**
 * @author Andy
 */
@Component
public class ApiTriggerPR {
 
    @Autowired
    private ApiTriggerRep apiTriggerRep;
 
    /**
     * apiTriggerPR#findParent
     *
     * @return
     */
    @DataProvider
    public List<ApiTrigger> findParent() {
        return apiTriggerRep.findParent();
    }
 
    /**
     * apiTriggerPR#findByParent
     *
     * @param parentCode
     * @return
     */
    @DataProvider
    public List<ApiTrigger> findByParent(String parentCode) {
        return apiTriggerRep.findByParent(parentCode);
    }
 
 
    /**
     * apiTriggerPR#updateSave
     *
     * @param entity
     */
    @Expose
    public ApiTrigger updateSave(ApiTrigger entity) {
 
        if (null == entity.getId()) {
            entity.setId(ContextUtil.getCurTimeMillis());
        }
 
        if (StringUtils.isEmpty(entity.getParentCode())) {
            entity.setParentCode(Constant.DEFAULT_CODE);
        }
 
        if (StringUtils.isEmpty(entity.getVal())) {
            entity.setVal(Constant.YN_Y);
        }
 
        if (StringUtils.isEmpty(entity.getDefaultTag())) {
            entity.setDefaultTag(Constant.YN_N);
        }
 
        // 手动将doradoEntity对象转换为标准Bean对象
        ApiTrigger data = new ApiTrigger();
        BeanUtils.copyProperties(entity, data);
 
        apiTriggerRep.save(data);
 
        return entity;
    }
 
    /**
     * apiTriggerPR#delData
     *
     * @param data
     */
    @Expose
    public String delData(ApiTrigger data) {
        apiTriggerRep.deleteById(data.getId());
        return null;
    }
 
}