1
2
3
4
5 package gboat2.example.action;
6
7 import gboat2.base.bridge.GboatAppContext;
8 import gboat2.base.bridge.util.json.JsonUtil;
9 import gboat2.base.core.web.BaseActionSupport;
10 import gboat2.base.core.web.JsonResult;
11 import gboat2.example.business.IExampleUserBusiness;
12 import gboat2.web.model.Group;
13
14 import java.io.IOException;
15 import java.net.URL;
16 import java.util.ArrayList;
17 import java.util.Date;
18 import java.util.LinkedHashMap;
19 import java.util.List;
20 import java.util.Map;
21
22 import org.apache.commons.io.IOUtils;
23 import org.apache.commons.lang3.StringUtils;
24 import org.springframework.beans.factory.annotation.Autowired;
25
26
27
28
29
30
31
32
33 public class ExampleAction extends BaseActionSupport {
34
35 private static final long serialVersionUID = 1L;
36
37 private String forward;
38 private String resource;
39 private Map<String, String> accordionMap;
40
41 private List<Group> groups;
42
43 private Date date;
44 private Date time;
45 private Date dateTime;
46 private boolean agree;
47
48 @Autowired
49 private IExampleUserBusiness euBusiness;
50
51 @Override
52 public String execute() {
53 System.out.println("ExampleAction 中的 exampleBusiness=" + euBusiness + ", getBelonRoleNames 返回:" + euBusiness.getBelonRoleNames());
54 return StringUtils.defaultIfBlank(forward, "index");
55 }
56
57 @Override
58 public String ajaxSave() {
59 System.out.println("Form 提交的日期:" + date);
60 System.out.println("Form 提交的时间:" + time);
61 System.out.println("Form 提交的日期+时间:" + dateTime);
62 return null;
63 }
64
65
66
67
68
69 public void loadDataFromResource() {
70 Object result = null;
71 if(StringUtils.isBlank(resource)) {
72 result = JsonResult.createFailure("参数 resource 不能为空");
73 } else{
74 URL url = getClass().getClassLoader().getResource("static/gboat2.example/" + StringUtils.removeStart(resource, "/"));
75 if(url == null) {
76 result = JsonResult.createFailure("静态资源文件 [ " + resource + " ] 不存在!");
77 } else {
78 if(StringUtils.endsWithIgnoreCase(resource, ".json")) {
79 result = JsonUtil.fromURL(url);
80 } else {
81 try {
82 result = IOUtils.toString(url);
83 } catch (IOException e) {
84 result = JsonResult.createFailure(e.getMessage());
85 }
86 }
87 }
88 }
89 GboatAppContext.output(result);
90 }
91
92
93
94
95
96 public String accordion() {
97 accordionMap = new LinkedHashMap<String, String>();
98 accordionMap.put("Section 1",
99 "Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate.");
100 accordionMap.put( "Section 2",
101 "Sed non urna. Donec et ante. Phasellus eu ligula. Vestibulum sit amet purus. Vivamus hendrerit, dolor at aliquet laoreet, mauris turpis porttitor velit, faucibus interdum tellus libero ac justo. Vivamus non quam. In suscipit faucibus urna.");
102 accordionMap.put("Section 3",
103 "Nam enim risus, molestie et, porta ac, aliquam ac, risus. Quisque lobortis. Phasellus pellentesque purus in massa. Aenean in pede. Phasellus ac libero ac tellus pellentesque semper. Sed ac felis. Sed commodo, magna quis lacinia ornare, quam ante aliquam nisi, eu iaculis leo purus venenatis dui.");
104 accordionMap.put("Section 4",
105 "Cras dictum. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aenean lacinia mauris vel est. Suspendisse eu nisl. Nullam ut libero. Integer dignissim consequat lectus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.");
106 return "jqueryui/accordion";
107 }
108
109 public String catagoryQuery() {
110 String[] datas = new String[]{
111 "", "全部",
112 "ff8080813878e535013878f0c1ac0047", "招标人组",
113 "ff8080813878e535013878f1184b004b", "投标人组",
114 "ff8080813878e535013878f170cf004f", "招标办组",
115 "4028c3ec3893d04d013893d6a337001a", "资格预审",
116 "4028817d3c04e0d6013c0505131c0009", "区县监管员组",
117 "4028c42d38c2ab2d0138c2b0902f001b", "管理员组",
118 "ff80808138ef494f0138ef875447009c", "开评标管理组",
119 "4028c3ec39241a6a01392426ff260035", "交易中心组",
120 "40288fff46199b3f014619a1bcf40011", "招标办用户组"
121 };
122
123 groups = new ArrayList<Group>(9);
124 for (int i=0; i < datas.length; i+=2) {
125 Group g = new Group();
126 g.setGroupId(datas[i]);
127 g.setGroupName(datas[i+1]);
128 groups.add(g);
129 }
130
131 return "catagory-query";
132 }
133
134 public void setForward(String forward) {
135 this.forward = forward;
136 }
137
138 public void setResource(String resource) {
139 this.resource = resource;
140 }
141
142 public Map<String, String> getAccordionMap() {
143 return accordionMap;
144 }
145
146 public Date getDate() {
147 if(date == null) {
148 date = new Date();
149 }
150 return date;
151 }
152
153 public void setDate(Date date) {
154 this.date = date;
155 }
156
157 public Date getTime() {
158 if(time == null) {
159 time = new Date();
160 }
161 return time;
162 }
163
164 public void setTime(Date time) {
165 this.time = time;
166 }
167
168 public Date getDateTime() {
169 if(dateTime == null) {
170 dateTime = new Date();
171 }
172 return dateTime;
173 }
174
175 public void setDateTime(Date dateTime) {
176 this.dateTime = dateTime;
177 }
178
179 public boolean isAgree() {
180 return agree;
181 }
182
183 public void setAgree(boolean agree) {
184 this.agree = agree;
185 }
186
187 public List<Group> getGroups() {
188 return groups;
189 }
190
191 }