admin
2021-09-30 1a1a315efb1b5dc294013126f35819e36565040c
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
package org.yeshi.utils.generater.vo;
 
import org.yeshi.utils.StringUtil;
import org.yeshi.utils.generater.entity.BaseData;
import org.yeshi.utils.generater.entity.ClassInfo;
 
import java.util.ArrayList;
import java.util.List;
 
public class ServiceInfoVO extends BaseData {
    private ClassInfo service;
    private ClassInfo dao;
    //方法列表
    private List<ServiceMetodInfoVO> metodInfoList;
 
 
    public static class Builder {
        private Class entity;
        private String packageName;
        private ClassInfo dao;
        private ClassInfo service;
        private ClassInfo query;
 
 
        public Builder setEntity(Class entity) {
            this.entity = entity;
            return this;
        }
 
        public Builder setPackageName(String packageName) {
            this.packageName = packageName;
            return this;
        }
 
        public Builder setDao(ClassInfo dao) {
            this.dao = dao;
            return this;
        }
 
        public Builder setService(ClassInfo service) {
            this.service = service;
            return this;
        }
 
        public Builder setQuery(ClassInfo query) {
            this.query = query;
            return this;
        }
 
 
        public ServiceInfoVO build() throws Exception {
            ServiceInfoVO serviceData = new ServiceInfoVO();
            serviceData.setDao(dao);
            serviceData.setService(service);
            serviceData.setEntity(new ClassInfo(entity.getSimpleName(), entity.getName()));
            serviceData.setPackageName(packageName);
            //设置接口
            List<ServiceMetodInfoVO> metodInfoVOList = new ArrayList<>();
            /*******添加方法开始*******/
            List<String> params = null;
            ServiceMetodInfoVO metodInfo = null;
            //list方法
            params = new ArrayList<>();
            params.add(query.getName() + " " + StringUtil.firstCharToLower(query.getName()));
            params.add("int page");
            params.add("int pageSize");
            metodInfo = new ServiceMetodInfoVO("public", String.format("List<%s>", serviceData.getEntity().getName()), "list", StringUtil.concat(params, ","));
            metodInfoVOList.add(metodInfo);
            //count方法
            params = new ArrayList<>();
            params.add(query.getName() + " " + StringUtil.firstCharToLower(query.getName()));
            metodInfo = new ServiceMetodInfoVO("public", "long", "count", StringUtil.concat(params, ","));
            metodInfoVOList.add(metodInfo);
            //get方法
            params = new ArrayList<>();
            params.add("String id");
            metodInfo = new ServiceMetodInfoVO("public", serviceData.getEntity().getName(), "get", StringUtil.concat(params, ","));
            metodInfoVOList.add(metodInfo);
            //add方法
            params = new ArrayList<>();
            params.add(serviceData.getEntity().getName() + " " + StringUtil.firstCharToLower(serviceData.getEntity().getName()));
            metodInfo = new ServiceMetodInfoVO("public", "void", "add", StringUtil.concat(params, ","));
            metodInfoVOList.add(metodInfo);
            //update方法
            params = new ArrayList<>();
            params.add(serviceData.getEntity().getName() + " " + StringUtil.firstCharToLower(serviceData.getEntity().getName()));
            metodInfo = new ServiceMetodInfoVO("public", "void", "update", StringUtil.concat(params, ","));
            metodInfoVOList.add(metodInfo);
            //delete方法
            params = new ArrayList<>();
            params.add("List<String> idList");
            metodInfo = new ServiceMetodInfoVO("public", String.format("void", serviceData.getEntity().getName()), "delete", StringUtil.concat(params, ","));
            metodInfoVOList.add(metodInfo);
 
            /*******添加方法结束*******/
 
 
            return serviceData;
        }
 
    }
 
    public ClassInfo getService() {
        return service;
    }
 
    public void setService(ClassInfo service) {
        this.service = service;
    }
 
    public ClassInfo getDao() {
        return dao;
    }
 
    public void setDao(ClassInfo dao) {
        this.dao = dao;
    }
 
    public List<ServiceMetodInfoVO> getMetodInfoList() {
        return metodInfoList;
    }
 
    public void setMetodInfoList(List<ServiceMetodInfoVO> metodInfoList) {
        this.metodInfoList = metodInfoList;
    }
 
 
}