From 62772b0413bee2c952e21cf896dbc4c428dd1501 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A3=E5=9C=A3=E5=8D=8E?= <752718920@qq.com> Date: Tue, 12 May 2020 11:08:50 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=99=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=BC=94=E7=A4=BA=E7=94=A8=E6=88=B7=E7=A6=81?= =?UTF-8?q?=E6=AD=A2=E6=93=8D=E4=BD=9C=E7=9A=84=E5=88=A4=E6=96=AD=EF=BC=88?= =?UTF-8?q?=E5=86=8D=E6=AC=A1=E4=BC=98=E5=8C=96=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- erp_web/js/common/common.js | 30 ++++++++++++++----- .../jsh/erp/controller/UserController.java | 24 +++++++++++++++ src/main/resources/application.properties | 2 ++ 3 files changed, 48 insertions(+), 8 deletions(-) diff --git a/erp_web/js/common/common.js b/erp_web/js/common/common.js index 968ad8b0..d862c810 100644 --- a/erp_web/js/common/common.js +++ b/erp_web/js/common/common.js @@ -426,15 +426,29 @@ * 检查当前用户是否是演示用户 */ function checkIsTestUser() { - var res = false; - var loginName = sessionStorage.getItem("loginName"); - if (loginName == "jsh") { - $.messager.alert('提示', '演示用户禁止操作!', 'warning'); - res = true; - } else { - res = false; + var result = false; + var demonstrateOpen = false; + $.ajax({ + type: "get", + url: "/user/getDemonstrateOpen", + dataType: "json", + async: false, //设置为同步 + success: function (res) { + if (res && res.code === 200) { + demonstrateOpen = res.data.demonstrateOpen; + } + } + }); + if(demonstrateOpen) { + var loginName = sessionStorage.getItem("loginName"); + if (loginName == "jsh") { + $.messager.alert('提示', '演示用户禁止操作!', 'warning'); + result = true; + } else { + result = false; + } } - return res; + return result; } /** diff --git a/src/main/java/com/jsh/erp/controller/UserController.java b/src/main/java/com/jsh/erp/controller/UserController.java index a682366d..6a33271e 100644 --- a/src/main/java/com/jsh/erp/controller/UserController.java +++ b/src/main/java/com/jsh/erp/controller/UserController.java @@ -43,6 +43,9 @@ public class UserController { @Value("${manage.roleId}") private Integer manageRoleId; + @Value("${demonstrate.open}") + private boolean demonstrateOpen; + @Resource private UserService userService; @@ -56,6 +59,27 @@ public class UserController { private static final String HTTP = "http://"; private static final String CODE_OK = "200"; + /** + * 是否开启演示状态,默认关闭 + * @param request + * @return + */ + @GetMapping(value = "/getDemonstrateOpen") + public BaseResponseInfo getDemonstrateOpen(HttpServletRequest request) { + BaseResponseInfo res = new BaseResponseInfo(); + try { + Map data = new HashMap(); + data.put("demonstrateOpen", demonstrateOpen); + res.code = 200; + res.data = data; + } catch(Exception e){ + e.printStackTrace(); + res.code = 500; + res.data = "获取失败"; + } + return res; + } + @PostMapping(value = "/login") public BaseResponseInfo login(@RequestParam(value = "loginName", required = false) String loginName, @RequestParam(value = "password", required = false) String password, diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 25f396b7..a3626ea3 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -16,6 +16,8 @@ manage.roleId=10 tenant.userNumLimit=5 #租户允许创建的单据数 tenant.billsNumLimit=200 +#演示模式-默认为false +demonstrate.open=false #插件配置 plugin.runMode=prod plugin.pluginPath=plugins