From 72d8e3cde4863e15a6c284f3d7ccd0c304512af9 Mon Sep 17 00:00:00 2001
From: linzhijie <19970921lzj>
Date: 星期一, 12 四月 2021 16:43:30 +0800
Subject: [PATCH] 新增

---
 src/main/java/com/ots/framework/web/controller/BaseController.java                   |  115 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/main/resources/static/downloadTemplates/ReportTemplates/waterDropDarkBlue_V2.png |    0 
 src/main/resources/static/downloadTemplates/ReportTemplates/Bar1_V2.png              |    0 
 src/main/resources/static/downloadTemplates/ReportTemplates/Bar2_V2.png              |    0 
 4 files changed, 115 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/ots/framework/web/controller/BaseController.java b/src/main/java/com/ots/framework/web/controller/BaseController.java
new file mode 100644
index 0000000..7f88ce7
--- /dev/null
+++ b/src/main/java/com/ots/framework/web/controller/BaseController.java
@@ -0,0 +1,115 @@
+package com.ots.framework.web.controller;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import com.ots.common.utils.DateUtils;
+import com.ots.common.utils.StringUtils;
+import com.ots.common.utils.security.ShiroUtils;
+import com.ots.common.utils.sql.SqlUtil;
+import com.ots.framework.web.domain.AjaxResult;
+import com.ots.framework.web.domain.AjaxResult.Type;
+import com.ots.framework.web.page.PageDomain;
+import com.ots.framework.web.page.TableDataInfo;
+import com.ots.framework.web.page.TableSupport;
+import com.ots.project.system.user.domain.User;
+import org.springframework.web.bind.WebDataBinder;
+import org.springframework.web.bind.annotation.InitBinder;
+import java.beans.PropertyEditorSupport;
+import java.util.Date;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class BaseController {
+    
+    @InitBinder
+    public void initBinder(WebDataBinder binder) {
+        
+        binder.registerCustomEditor(Date.class, new PropertyEditorSupport() {
+            @Override
+            public void setAsText(String text) {
+                setValue(DateUtils.parseDate(text));
+            }
+        });
+    }
+    
+    protected void startPage() {
+        PageDomain pageDomain = TableSupport.buildPageRequest();
+        Integer pageNum = pageDomain.getPageNum();
+        Integer pageSize = pageDomain.getPageSize();
+        if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) {
+            String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
+            PageHelper.startPage(pageNum, pageSize, orderBy);
+        }
+    }
+    
+    @SuppressWarnings({"rawtypes", "unchecked"})
+    protected TableDataInfo getDataTable(List<?> list) {
+        TableDataInfo rspData = new TableDataInfo();
+        rspData.setCode(0);
+        rspData.setRows(list);
+        rspData.setTotal(new PageInfo(list).getTotal());
+        return rspData;
+    }
+    
+    protected AjaxResult toAjax(int rows) {
+        return rows > 0 ? success() : error();
+    }
+    
+    protected AjaxResult toAjax(boolean result) {
+        return result ? success() : error();
+    }
+    
+    public AjaxResult success() {
+        return AjaxResult.success();
+    }
+    
+    public AjaxResult error() {
+        return AjaxResult.error();
+    }
+    
+    public AjaxResult success(String message) {
+        return AjaxResult.success(message);
+    }
+    
+    public AjaxResult error(String message) {
+        return AjaxResult.error(message);
+    }
+    
+    public AjaxResult error(Type type, String message) {
+        return new AjaxResult(type, message);
+    }
+    
+    public String redirect(String url) {
+        return StringUtils.format("redirect:{}", url);
+    }
+    public User getSysUser() {
+        return ShiroUtils.getSysUser();
+    }
+    public void setSysUser(User user) {
+        ShiroUtils.setSysUser(user);
+    }
+    public Long getUserId() {
+        return getSysUser().getUserId();
+    }
+    public String getLoginName() {
+        return getSysUser().getLoginName();
+    }
+    public static void main(String[] args) {
+        String line = "xxxxx";
+        System.out.println(getJson(line, "time_slot_list"));
+    }
+    public static String getJson(String json, String key) {
+        String pattern = key + "\": \\{[^}]*\\}";
+        
+        Pattern r = Pattern.compile(pattern);
+        
+        Matcher m = r.matcher(json);
+        if (m.find()) {
+            String group = m.group(0);
+            group = group.replace(key + "\":", key + "\":[");
+            group += "]";
+            return json.replaceAll(pattern, group);
+        }
+        return json;
+    }
+}
diff --git a/src/main/resources/static/downloadTemplates/ReportTemplates/Bar1_V2.png b/src/main/resources/static/downloadTemplates/ReportTemplates/Bar1_V2.png
new file mode 100644
index 0000000..00eeb15
--- /dev/null
+++ b/src/main/resources/static/downloadTemplates/ReportTemplates/Bar1_V2.png
Binary files differ
diff --git a/src/main/resources/static/downloadTemplates/ReportTemplates/Bar2_V2.png b/src/main/resources/static/downloadTemplates/ReportTemplates/Bar2_V2.png
new file mode 100644
index 0000000..66c5343
--- /dev/null
+++ b/src/main/resources/static/downloadTemplates/ReportTemplates/Bar2_V2.png
Binary files differ
diff --git a/src/main/resources/static/downloadTemplates/ReportTemplates/waterDropDarkBlue_V2.png b/src/main/resources/static/downloadTemplates/ReportTemplates/waterDropDarkBlue_V2.png
new file mode 100644
index 0000000..bc7ffcf
--- /dev/null
+++ b/src/main/resources/static/downloadTemplates/ReportTemplates/waterDropDarkBlue_V2.png
Binary files differ

--
Gitblit v1.9.1