MCmsAction.java 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  1. /**
  2. * The MIT License (MIT)
  3. * Copyright (c) 2020 铭软科技(mingsoft.net)
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  5. * this software and associated documentation files (the "Software"), to deal in
  6. * the Software without restriction, including without limitation the rights to
  7. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  8. * the Software, and to permit persons to whom the Software is furnished to do so,
  9. * subject to the following conditions:
  10. * The above copyright notice and this permission notice shall be included in all
  11. * copies or substantial portions of the Software.
  12. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  14. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  15. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  16. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  17. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  18. */
  19. package net.mingsoft.cms.action.web;
  20. import cn.hutool.core.collection.CollUtil;
  21. import cn.hutool.core.collection.CollectionUtil;
  22. import cn.hutool.core.lang.Editor;
  23. import cn.hutool.core.util.ObjectUtil;
  24. import cn.hutool.core.util.PageUtil;
  25. import com.baomidou.mybatisplus.core.toolkit.Wrappers;
  26. import freemarker.core.ParseException;
  27. import freemarker.template.MalformedTemplateNameException;
  28. import freemarker.template.TemplateException;
  29. import freemarker.template.TemplateNotFoundException;
  30. import net.bytebuddy.implementation.bytecode.Throw;
  31. import net.mingsoft.base.constant.Const;
  32. import net.mingsoft.basic.exception.BusinessException;
  33. import net.mingsoft.basic.util.BasicUtil;
  34. import net.mingsoft.basic.util.StringUtil;
  35. import net.mingsoft.cms.bean.CategoryBean;
  36. import net.mingsoft.cms.bean.ContentBean;
  37. import net.mingsoft.cms.biz.ICategoryBiz;
  38. import net.mingsoft.cms.biz.IContentBiz;
  39. import net.mingsoft.cms.constant.e.CategoryTypeEnum;
  40. import net.mingsoft.cms.entity.CategoryEntity;
  41. import net.mingsoft.cms.entity.ContentEntity;
  42. import net.mingsoft.cms.util.CmsParserUtil;
  43. import net.mingsoft.mdiy.bean.PageBean;
  44. import net.mingsoft.mdiy.biz.IModelBiz;
  45. import net.mingsoft.mdiy.biz.IPageBiz;
  46. import net.mingsoft.mdiy.entity.ModelEntity;
  47. import net.mingsoft.mdiy.util.ParserUtil;
  48. import org.apache.commons.lang3.StringUtils;
  49. import org.apache.shiro.util.CollectionUtils;
  50. import org.springframework.beans.factory.annotation.Autowired;
  51. import org.springframework.beans.factory.annotation.Value;
  52. import org.springframework.stereotype.Controller;
  53. import org.springframework.web.bind.annotation.GetMapping;
  54. import org.springframework.web.bind.annotation.RequestMapping;
  55. import org.springframework.web.bind.annotation.RequestMethod;
  56. import org.springframework.web.bind.annotation.ResponseBody;
  57. import javax.servlet.http.HttpServletRequest;
  58. import javax.servlet.http.HttpServletResponse;
  59. import java.io.IOException;
  60. import java.io.UnsupportedEncodingException;
  61. import java.util.ArrayList;
  62. import java.util.HashMap;
  63. import java.util.List;
  64. import java.util.Map;
  65. /**
  66. * 动态生成页面,需要后台配置自定义页数据
  67. *
  68. * @author 铭飞开源团队
  69. * @date 2018年12月17日
  70. */
  71. @Controller("dynamicPageAction")
  72. @RequestMapping("/mcms")
  73. public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
  74. /**
  75. * 自定义页面业务层
  76. */
  77. @Autowired
  78. private IPageBiz pageBiz;
  79. /**
  80. * 文章管理业务处理层
  81. */
  82. @Autowired
  83. private IContentBiz contentBiz;
  84. /**
  85. * 栏目业务层
  86. */
  87. @Autowired
  88. private ICategoryBiz categoryBiz;
  89. /**
  90. * 搜索标签;
  91. */
  92. public static final String SEARCH = "search";
  93. /**
  94. * 自定义模型
  95. */
  96. @Autowired
  97. private IModelBiz modelBiz;
  98. @Value("${ms.diy.html-dir:html}")
  99. private String htmlDir;
  100. /**
  101. * 动态列表页
  102. */
  103. @GetMapping("/index.do")
  104. @ResponseBody
  105. public String index(HttpServletRequest req, HttpServletResponse resp) {
  106. Map map = BasicUtil.assemblyRequestMap();
  107. map.forEach((k, v) -> {
  108. map.put(k, v.toString().replaceAll("('|\"|\\\\)", "\\\\$1"));
  109. });
  110. map.put(ParserUtil.URL, BasicUtil.getUrl());
  111. //动态解析
  112. map.put(ParserUtil.IS_DO, true);
  113. //设置动态请求的模块路径
  114. map.put(ParserUtil.MODEL_NAME, "mcms");
  115. map.put(ParserUtil.HTML,htmlDir);
  116. //解析后的内容
  117. String content = "";
  118. try {
  119. //根据模板路径,参数生成
  120. content = ParserUtil.rendering(ParserUtil.INDEX + ParserUtil.HTM_SUFFIX, map);
  121. } catch (TemplateNotFoundException e) {
  122. e.printStackTrace();
  123. } catch (MalformedTemplateNameException e) {
  124. e.printStackTrace();
  125. } catch (ParseException e) {
  126. e.printStackTrace();
  127. } catch (IOException e) {
  128. e.printStackTrace();
  129. }
  130. return content;
  131. }
  132. /**
  133. * 动态列表页
  134. *
  135. * @param req
  136. * @param resp
  137. */
  138. @ResponseBody
  139. @GetMapping("/list.do")
  140. public String list(HttpServletRequest req, HttpServletResponse resp) {
  141. Map map = BasicUtil.assemblyRequestMap();
  142. map.forEach((k, v) -> {
  143. map.put(k, v.toString().replaceAll("('|\"|\\\\)", "\\\\$1"));
  144. });
  145. //获取栏目编号
  146. int typeId = BasicUtil.getInt(ParserUtil.TYPE_ID, 0);
  147. int size = BasicUtil.getInt("size", 10);
  148. ContentBean contentBean = new ContentBean();
  149. contentBean.setCategoryId(String.valueOf(typeId));
  150. //获取文章总数
  151. List<CategoryBean> columnArticles = contentBiz.queryIdsByCategoryIdForParser(contentBean);
  152. //判断栏目下是否有文章
  153. if (columnArticles.size() == 0) {
  154. return "";
  155. }
  156. //设置分页类
  157. PageBean page = new PageBean();
  158. page.setPageNo(BasicUtil.getPageNo());
  159. int total = PageUtil.totalPage(columnArticles.size(), size);
  160. map.put(ParserUtil.COLUMN, columnArticles.get(0));
  161. //获取总数
  162. page.setTotal(total);
  163. //设置栏目编号
  164. map.put(ParserUtil.TYPE_ID, typeId);
  165. map.put(ParserUtil.URL, BasicUtil.getUrl());
  166. map.put(ParserUtil.PAGE, page);
  167. //动态解析
  168. map.put(ParserUtil.IS_DO, true);
  169. //设置动态请求的模块路径
  170. map.put(ParserUtil.MODEL_NAME, "mcms");
  171. map.put(ParserUtil.HTML, htmlDir);
  172. //解析后的内容
  173. String content = "";
  174. try {
  175. //根据模板路径,参数生成
  176. content = ParserUtil.rendering(columnArticles.get(0).getCategoryListUrl(), map);
  177. } catch (TemplateNotFoundException e) {
  178. e.printStackTrace();
  179. } catch (MalformedTemplateNameException e) {
  180. e.printStackTrace();
  181. } catch (ParseException e) {
  182. e.printStackTrace();
  183. } catch (IOException e) {
  184. e.printStackTrace();
  185. }
  186. return content;
  187. }
  188. /**
  189. * 动态详情页
  190. */
  191. @GetMapping("/view.do")
  192. @ResponseBody
  193. public String view(String orderby, String order, HttpServletRequest req, HttpServletResponse resp) {
  194. //参数文章编号
  195. ContentEntity article = (ContentEntity) contentBiz.getEntity(BasicUtil.getInt(ParserUtil.ID));
  196. if (ObjectUtil.isNull(article)) {
  197. throw new BusinessException(this.getResString("err.empty", this.getResString("id")));
  198. }
  199. if (StringUtils.isNotBlank(order)) {
  200. //防注入
  201. if (!order.toLowerCase().equals("asc") && !order.toLowerCase().equals("desc")) {
  202. throw new BusinessException(this.getResString("err.error", this.getResString("order")));
  203. }
  204. }
  205. orderby = orderby.replaceAll("('|\"|\\\\)", "\\\\$1");
  206. PageBean page = new PageBean();
  207. //用于详情上下页获取当前文章列表对应的分类,根据文章查询只能获取自身分类
  208. String typeId = BasicUtil.getString(ParserUtil.TYPE_ID, article.getCategoryId());
  209. //根据文章编号查询栏目详情模版
  210. CategoryEntity column = (CategoryEntity) categoryBiz.getEntity(Integer.parseInt(typeId));
  211. //解析后的内容
  212. String content = "";
  213. Map map = BasicUtil.assemblyRequestMap();
  214. map.forEach((k, v) -> {
  215. //sql注入过滤
  216. map.put(k, v.toString().replaceAll("('|\"|\\\\)", "\\\\$1"));
  217. });
  218. //动态解析
  219. map.put(ParserUtil.IS_DO, true);
  220. //设置栏目编号
  221. map.put(ParserUtil.TYPE_ID, typeId);
  222. //设置动态请求的模块路径
  223. map.put(ParserUtil.MODEL_NAME, "mcms");
  224. map.put(ParserUtil.URL, BasicUtil.getUrl());
  225. map.put(ParserUtil.PAGE, page);
  226. map.put(ParserUtil.ID, article.getId());
  227. map.put(ParserUtil.HTML,htmlDir);
  228. ContentBean contentBean = new ContentBean();
  229. contentBean.setCategoryId(String.valueOf(typeId));
  230. contentBean.setOrderBy(orderby);
  231. contentBean.setOrder(order);
  232. List<CategoryBean> articleIdList = contentBiz.queryIdsByCategoryIdForParser(contentBean);
  233. Map<Object, Object> contentModelMap = new HashMap<Object, Object>();
  234. ModelEntity contentModel = null;
  235. for (int artId = 0; artId < articleIdList.size(); ) {
  236. //如果不是当前文章则跳过
  237. if (articleIdList.get(artId).getArticleId().equals(article.getId())) {
  238. artId++;
  239. continue;
  240. }
  241. // 文章的栏目路径
  242. String categoryParentId = articleIdList.get(artId).getId();
  243. if (StringUtils.isNotBlank(articleIdList.get(artId).getCategoryParentIds())) {
  244. categoryParentId += ',' + articleIdList.get(artId).getCategoryParentIds();
  245. }
  246. // 文章的栏目模型编号
  247. Integer columnContentModelId = articleIdList.get(artId).getMdiyModelId();
  248. Map<String, Object> parserParams = new HashMap<String, Object>();
  249. parserParams.put(ParserUtil.COLUMN, articleIdList.get(artId));
  250. // 判断当前栏目是否有自定义模型
  251. if (columnContentModelId != null && columnContentModelId > 0) {
  252. // 通过当前栏目的模型编号获取,自定义模型表名
  253. if (contentModelMap.containsKey(columnContentModelId)) {
  254. parserParams.put(ParserUtil.TABLE_NAME, contentModel.getModelTableName());
  255. } else {
  256. // 通过栏目模型编号获取自定义模型实体
  257. contentModel = (ModelEntity) modelBiz.getEntity(columnContentModelId);
  258. // 将自定义模型编号设置为key值
  259. contentModelMap.put(columnContentModelId, contentModel.getModelTableName());
  260. parserParams.put(ParserUtil.TABLE_NAME, contentModel.getModelTableName());
  261. }
  262. }
  263. // 第一篇文章没有上一篇
  264. if (artId > 0) {
  265. CategoryBean preCaBean = articleIdList.get(artId - 1);
  266. page.setPreId(preCaBean.getArticleId());
  267. }
  268. // 最后一篇文章没有下一篇
  269. if (artId + 1 < articleIdList.size()) {
  270. CategoryBean nextCaBean = articleIdList.get(artId + 1);
  271. page.setNextId(nextCaBean.getArticleId());
  272. }
  273. break;
  274. }
  275. try {
  276. //根据模板路径,参数生成
  277. content = ParserUtil.rendering(column.getCategoryUrl(), map);
  278. } catch (TemplateNotFoundException e) {
  279. e.printStackTrace();
  280. } catch (MalformedTemplateNameException e) {
  281. e.printStackTrace();
  282. } catch (ParseException e) {
  283. e.printStackTrace();
  284. } catch (IOException e) {
  285. e.printStackTrace();
  286. }
  287. return content;
  288. }
  289. /**
  290. * 实现前端页面的文章搜索
  291. *
  292. * @param request 搜索id
  293. * @param response
  294. */
  295. @RequestMapping(value = "search")
  296. @ResponseBody
  297. public String search(HttpServletRequest request, HttpServletResponse response) {
  298. //设置分页类
  299. PageBean page = new PageBean();
  300. page.setSize(ParserUtil.getPageSize(SEARCH + ParserUtil.HTM_SUFFIX, 20));
  301. //参数集合,提供给解析使用
  302. Map<String, Object> params = new HashMap<>();
  303. // 读取请求字段
  304. Map<String, Object> field = BasicUtil.assemblyRequestMap();
  305. // 自定义字段集合
  306. Map<String, String> diyFieldName = new HashMap<String, String>();
  307. //记录自定义模型字段名
  308. List filedStr = new ArrayList<>();
  309. // 栏目对应字段的值
  310. List<DiyModelMap> fieldValueList = new ArrayList<DiyModelMap>();
  311. // 当前栏目
  312. CategoryEntity column = null;
  313. // 栏目对应模型
  314. ModelEntity contentModel = null;
  315. //获取栏目信息
  316. String typeId = null;
  317. String categoryIds = BasicUtil.getString("categoryIds");
  318. //List categoryIdList = CollectionUtil.newArrayList();
  319. //当传递了栏目编号,但不是栏目集合
  320. if (StringUtils.isNotBlank(categoryIds) && !categoryIds.contains(",")) {
  321. typeId = categoryIds;
  322. }
  323. // else {
  324. // //取出所有的子栏目
  325. // String[] ids = categoryIds.split(",");
  326. // List<CategoryEntity> categoryList = categoryBiz.list(Wrappers.<CategoryEntity>lambdaQuery().ne(CategoryEntity::getCategoryType, CategoryTypeEnum.LINK.toString()));
  327. //
  328. // categoryIdList = CollectionUtil.newArrayList(ids);
  329. // for(CategoryEntity c:categoryList) {
  330. // if(StringUtils.isNotEmpty(c.getParentids())) {
  331. // for(String id:ids) {
  332. // if(c.getParentids().indexOf(id)>-1) {
  333. // categoryIdList.add(c.getId());
  334. // break;
  335. // }
  336. // }
  337. // }
  338. // }
  339. // }
  340. //重新组织 ID
  341. //categoryIds = StringUtils.join(categoryIdList, ",");
  342. //根据栏目确定自定义模型
  343. if (typeId != null) {
  344. column = (CategoryEntity) categoryBiz.getById(typeId);
  345. // 获取表单类型的id
  346. if (column != null && ObjectUtil.isNotNull(column.getMdiyModelId())) {
  347. contentModel = (ModelEntity) modelBiz.getEntity(column.getMdiyModelId());
  348. if (contentModel != null) {
  349. // 保存自定义模型的数据
  350. Map<String, String> fieldMap = contentModel.getFieldMap();
  351. for (String s : fieldMap.keySet()) {
  352. filedStr.add(fieldMap.get(s));
  353. }
  354. // 设置自定义模型表名,方便解析的时候关联表查询
  355. params.put(ParserUtil.TABLE_NAME, contentModel.getModelTableName());
  356. }
  357. }
  358. // 设置栏目,方便解析的时候关联表查询
  359. params.put(ParserUtil.COLUMN, column);
  360. }
  361. // 处理读取请求字段
  362. if (field != null) {
  363. for (Map.Entry<String, Object> entry : field.entrySet()) {
  364. if (entry != null) {
  365. //空值不处理
  366. if (ObjectUtil.isNull(entry.getValue())) {
  367. continue;
  368. }
  369. // 对值进行安全处理
  370. // 处理由get方法请求中文乱码问题
  371. String value = entry.getValue().toString().replaceAll("('|\"|\\\\)", "\\\\$1");
  372. //Xss过滤
  373. value = clearXss(value);
  374. // 如果是get方法需要将请求地址参数转码
  375. if (request.getMethod().equals(RequestMethod.GET)) {
  376. try {
  377. value = new String(value.getBytes("ISO-8859-1"), Const.UTF8);
  378. } catch (UnsupportedEncodingException e) {
  379. e.printStackTrace();
  380. }
  381. }
  382. // 保存至自定义字段集合
  383. if (StringUtils.isNotBlank(value)) {
  384. diyFieldName.put(entry.getKey(), value);
  385. //判断请求中的是否是自定义模型中的字段
  386. if (filedStr.contains(entry.getKey())) {
  387. //设置自定义模型字段和值
  388. DiyModelMap diyMap = new DiyModelMap();
  389. diyMap.setKey(entry.getKey());
  390. diyMap.setValue(value);
  391. fieldValueList.add(diyMap);
  392. }
  393. }
  394. }
  395. }
  396. }
  397. //添加自定义模型的字段和值
  398. if (fieldValueList.size() > 0) {
  399. params.put("diyModel", fieldValueList);
  400. }
  401. Map<String, Object> searchMap = field;
  402. searchMap.put("categoryIds",categoryIds);
  403. StringBuilder urlParams = new StringBuilder();
  404. searchMap.forEach((k, v) -> {
  405. //sql注入过滤
  406. if (v != null) {
  407. searchMap.put(k, v.toString().replaceAll("('|\"|\\\\)", "\\\\$1"));
  408. searchMap.put(k, clearXss(searchMap.get(k).toString()));
  409. if (!"size".equals(k) && !"pageNo".equals(k)) {
  410. urlParams.append(k).append("=").append(searchMap.get(k)).append("&");
  411. }
  412. }
  413. });
  414. //查询数量
  415. int count = contentBiz.getSearchCount(contentModel, fieldValueList, searchMap, BasicUtil.getApp().getAppId(), categoryIds);
  416. page.setRcount(count);
  417. params.put(SEARCH, searchMap);
  418. //站点编号
  419. if (BasicUtil.getWebsiteApp() != null) {
  420. params.put(ParserUtil.APP_DIR, BasicUtil.getWebsiteApp().getAppDir());
  421. params.put(ParserUtil.URL, BasicUtil.getWebsiteApp().getAppHostUrl());
  422. params.put(ParserUtil.APP_ID, BasicUtil.getWebsiteApp().getAppId());
  423. } else {
  424. params.put(ParserUtil.URL, BasicUtil.getUrl());
  425. params.put(ParserUtil.APP_DIR, BasicUtil.getApp().getAppDir());
  426. }
  427. params.put(ParserUtil.PAGE, page);
  428. params.put(ParserUtil.HTML, htmlDir);
  429. //动态解析
  430. params.put(ParserUtil.IS_DO, false);
  431. //设置动态请求的模块路径
  432. params.put(ParserUtil.MODEL_NAME, "mcms");
  433. searchMap.put("pageNo", 0);
  434. // ParserUtil.read(SEARCH + ParserUtil.HTM_SUFFIX, map, page);
  435. int total = PageUtil.totalPage(count, page.getSize());
  436. int pageNo = BasicUtil.getInt("pageNo", 1);
  437. if (pageNo >= total && total != 0) {
  438. pageNo = total;
  439. }
  440. //获取总数
  441. page.setTotal(total);
  442. page.setPageNo(pageNo);
  443. //设置分页的统一链接
  444. String url = params.get(ParserUtil.URL).toString();
  445. url = url + request.getServletPath() + "?" + urlParams;
  446. String pageNoStr = "size=" + page.getSize() + "&pageNo=";
  447. //下一页
  448. String nextUrl = url + pageNoStr + ((pageNo + 1 > total) ? total : pageNo + 1);
  449. //首页
  450. String indexUrl = url + pageNoStr + 1;
  451. //尾页
  452. String lastUrl = url + pageNoStr + total;
  453. //上一页 当前页为1时,上一页就是1
  454. String preUrl = url + pageNoStr + ((pageNo == 1) ? 1 : pageNo - 1);
  455. page.setIndexUrl(indexUrl);
  456. page.setNextUrl(nextUrl);
  457. page.setPreUrl(preUrl);
  458. page.setLastUrl(lastUrl);
  459. params.put(SEARCH, searchMap);
  460. if (BasicUtil.getWebsiteApp() != null) {
  461. params.put(ParserUtil.APP_DIR, BasicUtil.getWebsiteApp().getAppDir());
  462. }
  463. params.put(ParserUtil.PAGE, page);
  464. params.put(ParserUtil.HTML, htmlDir);
  465. //动态解析
  466. params.put(ParserUtil.IS_DO, false);
  467. //设置动态请求的模块路径
  468. params.put(ParserUtil.MODEL_NAME, "mcms");
  469. //解析后的内容
  470. String content = "";
  471. try {
  472. //根据模板路径,参数生成
  473. content = ParserUtil.rendering(SEARCH + ParserUtil.HTM_SUFFIX, params);
  474. } catch (TemplateNotFoundException e) {
  475. e.printStackTrace();
  476. } catch (MalformedTemplateNameException e) {
  477. e.printStackTrace();
  478. } catch (ParseException e) {
  479. e.printStackTrace();
  480. } catch (IOException e) {
  481. e.printStackTrace();
  482. }
  483. return content;
  484. }
  485. // 清除路径中的转义字符
  486. private String clearXss(String value) {
  487. if (value == null || "".equals(value)) {
  488. return value;
  489. }
  490. value = value.replaceAll("<", "&lt;").replaceAll(">", "&gt;");
  491. value = value.replaceAll("\\(", "&#40;").replace("\\)", "&#41;");
  492. value = value.replaceAll("'", "&#39;");
  493. value = value.replaceAll("eval\\((.*)\\)", "");
  494. value = value.replaceAll("[\\\"\\\'][\\s]*javascript:(.*)[\\\"\\\']",
  495. "\"\"");
  496. value = value.replace("script", "");
  497. return value;
  498. }
  499. /**
  500. * 存储自定义模型字段和接口参数
  501. *
  502. * @author 铭飞开源团队
  503. * @date 2019年3月5日
  504. */
  505. class DiyModelMap {
  506. String key;
  507. Object value;
  508. public String getKey() {
  509. return key;
  510. }
  511. public void setKey(String key) {
  512. this.key = key;
  513. }
  514. public Object getValue() {
  515. return value;
  516. }
  517. public void setValue(Object value) {
  518. this.value = value;
  519. }
  520. }
  521. public static void main(String[] args) {
  522. int[] a = PageUtil.rainbow(20, 30, 5);
  523. for (int _a : a) {
  524. System.out.println(_a);
  525. }
  526. }
  527. }