mirror of
https://github.com/chatopera/cosin.git
synced 2025-07-28 12:32:15 +08:00
https://github.com/chatopera/cskefu/issues/701 add user experience plan in sys settings
This commit is contained in:
parent
5864f895d5
commit
7cb9d857a4
@ -18,6 +18,7 @@ package com.chatopera.cc.config;
|
|||||||
|
|
||||||
import com.chatopera.cc.interceptor.CrossInterceptorHandler;
|
import com.chatopera.cc.interceptor.CrossInterceptorHandler;
|
||||||
import com.chatopera.cc.interceptor.LogIntercreptorHandler;
|
import com.chatopera.cc.interceptor.LogIntercreptorHandler;
|
||||||
|
import com.chatopera.cc.interceptor.UserExperiencePlanInterceptorHandler;
|
||||||
import com.chatopera.cc.interceptor.UserInterceptorHandler;
|
import com.chatopera.cc.interceptor.UserInterceptorHandler;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||||
@ -32,6 +33,7 @@ public class CSKeFuWebAppConfigurer
|
|||||||
// 多个拦截器组成一个拦截器链
|
// 多个拦截器组成一个拦截器链
|
||||||
// addPathPatterns 用于添加拦截规则
|
// addPathPatterns 用于添加拦截规则
|
||||||
// excludePathPatterns 用户排除拦截
|
// excludePathPatterns 用户排除拦截
|
||||||
|
registry.addInterceptor(new UserExperiencePlanInterceptorHandler()).addPathPatterns("/**").excludePathPatterns("/im/**","/res/image*","/res/file*","/cs/**","/messenger/webhook/*");
|
||||||
registry.addInterceptor(new UserInterceptorHandler()).addPathPatterns("/**").excludePathPatterns("/login.html","/im/**","/res/image*","/res/file*","/cs/**","/messenger/webhook/*");
|
registry.addInterceptor(new UserInterceptorHandler()).addPathPatterns("/**").excludePathPatterns("/login.html","/im/**","/res/image*","/res/file*","/cs/**","/messenger/webhook/*");
|
||||||
registry.addInterceptor(new CrossInterceptorHandler()).addPathPatterns("/**");
|
registry.addInterceptor(new CrossInterceptorHandler()).addPathPatterns("/**");
|
||||||
registry.addInterceptor(new LogIntercreptorHandler()).addPathPatterns("/**");
|
registry.addInterceptor(new LogIntercreptorHandler()).addPathPatterns("/**");
|
||||||
|
@ -19,7 +19,9 @@ package com.chatopera.cc.controller.admin.config;
|
|||||||
import com.chatopera.cc.basic.Constants;
|
import com.chatopera.cc.basic.Constants;
|
||||||
import com.chatopera.cc.basic.MainContext;
|
import com.chatopera.cc.basic.MainContext;
|
||||||
import com.chatopera.cc.basic.MainUtils;
|
import com.chatopera.cc.basic.MainUtils;
|
||||||
|
import com.chatopera.cc.cache.RedisCommand;
|
||||||
import com.chatopera.cc.controller.Handler;
|
import com.chatopera.cc.controller.Handler;
|
||||||
|
import com.chatopera.cc.interceptor.UserExperiencePlanInterceptorHandler;
|
||||||
import com.chatopera.cc.model.Dict;
|
import com.chatopera.cc.model.Dict;
|
||||||
import com.chatopera.cc.model.Secret;
|
import com.chatopera.cc.model.Secret;
|
||||||
import com.chatopera.cc.model.SysDic;
|
import com.chatopera.cc.model.SysDic;
|
||||||
@ -69,6 +71,8 @@ public class SystemConfigController extends Handler {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private SystemConfigRepository systemConfigRes;
|
private SystemConfigRepository systemConfigRes;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisCommand redisCommand;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SystemMessageRepository systemMessageRes;
|
private SystemMessageRepository systemMessageRes;
|
||||||
@ -127,7 +131,7 @@ public class SystemConfigController extends Handler {
|
|||||||
|
|
||||||
map.addAttribute(
|
map.addAttribute(
|
||||||
"sysMessageList", systemMessageRes.findByMsgtypeAndOrgi(MainContext.SystemMessageType.EMAIL.toString(),
|
"sysMessageList", systemMessageRes.findByMsgtypeAndOrgi(MainContext.SystemMessageType.EMAIL.toString(),
|
||||||
super.getOrgi(request)));
|
super.getOrgi(request)));
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(execute) && execute.equals("false")) {
|
if (StringUtils.isNotBlank(execute) && execute.equals("false")) {
|
||||||
map.addAttribute("execute", execute);
|
map.addAttribute("execute", execute);
|
||||||
@ -135,6 +139,14 @@ public class SystemConfigController extends Handler {
|
|||||||
if (StringUtils.isNotBlank(request.getParameter("msg"))) {
|
if (StringUtils.isNotBlank(request.getParameter("msg"))) {
|
||||||
map.addAttribute("msg", request.getParameter("msg"));
|
map.addAttribute("msg", request.getParameter("msg"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String userExpTelemetrySetting = redisCommand.get(UserExperiencePlanInterceptorHandler.FLAG_KEY);
|
||||||
|
if (StringUtils.isEmpty(userExpTelemetrySetting) || StringUtils.equalsIgnoreCase(userExpTelemetrySetting, UserExperiencePlanInterceptorHandler.USER_EXP_PLAN_ON)) {
|
||||||
|
map.addAttribute("userExpTelemetrySetting", true);
|
||||||
|
} else {
|
||||||
|
map.addAttribute("userExpTelemetrySetting", false);
|
||||||
|
}
|
||||||
|
|
||||||
return request(super.createView("/admin/config/index"));
|
return request(super.createView("/admin/config/index"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,7 +200,8 @@ public class SystemConfigController extends Handler {
|
|||||||
@Menu(type = "admin", subtype = "save", admin = true)
|
@Menu(type = "admin", subtype = "save", admin = true)
|
||||||
public ModelAndView save(
|
public ModelAndView save(
|
||||||
ModelMap map, HttpServletRequest request,
|
ModelMap map, HttpServletRequest request,
|
||||||
@Valid SystemConfig config, BindingResult result,
|
@Valid SystemConfig config,
|
||||||
|
BindingResult result,
|
||||||
@RequestParam(value = "keyfile", required = false) MultipartFile keyfile,
|
@RequestParam(value = "keyfile", required = false) MultipartFile keyfile,
|
||||||
@RequestParam(value = "loginlogo", required = false) MultipartFile loginlogo,
|
@RequestParam(value = "loginlogo", required = false) MultipartFile loginlogo,
|
||||||
@RequestParam(value = "consolelogo", required = false) MultipartFile consolelogo,
|
@RequestParam(value = "consolelogo", required = false) MultipartFile consolelogo,
|
||||||
@ -274,6 +287,11 @@ public class SystemConfigController extends Handler {
|
|||||||
}
|
}
|
||||||
map.addAttribute("msg", msg);
|
map.addAttribute("msg", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 设置用户体验计划开关
|
||||||
|
redisCommand.put(UserExperiencePlanInterceptorHandler.FLAG_KEY, config.getUserExpTelemetrySetting() ? UserExperiencePlanInterceptorHandler.USER_EXP_PLAN_ON : UserExperiencePlanInterceptorHandler.USER_EXP_PLAN_OFF);
|
||||||
|
|
||||||
|
// 保存到数据库
|
||||||
systemConfigRes.save(systemConfig);
|
systemConfigRes.save(systemConfig);
|
||||||
|
|
||||||
MainContext.getCache().putSystemByIdAndOrgi("systemConfig", super.getOrgi(request), systemConfig);
|
MainContext.getCache().putSystemByIdAndOrgi("systemConfig", super.getOrgi(request), systemConfig);
|
||||||
|
@ -0,0 +1,80 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2019-2022 Chatopera Inc, <https://www.chatopera.com>
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.chatopera.cc.interceptor;
|
||||||
|
|
||||||
|
import com.chatopera.cc.basic.MainContext;
|
||||||
|
import com.chatopera.cc.cache.RedisCommand;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户体验计划
|
||||||
|
*/
|
||||||
|
public class UserExperiencePlanInterceptorHandler extends HandlerInterceptorAdapter {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(UserExperiencePlanInterceptorHandler.class);
|
||||||
|
public final static String FLAG_KEY = "cskefu:global:user-experience-plan";
|
||||||
|
private static RedisCommand redis;
|
||||||
|
public static final String USER_EXP_PLAN_ON = "on";
|
||||||
|
public static final String USER_EXP_PLAN_OFF = "off";
|
||||||
|
private static final String USER_EXP_TELEMETRY = "userExpTelemetry";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void postHandle(
|
||||||
|
HttpServletRequest request, HttpServletResponse response, Object arg2,
|
||||||
|
ModelAndView view) {
|
||||||
|
|
||||||
|
if (!request.getMethod().equals("GET")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (view == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String flag = getRedis().get(FLAG_KEY);
|
||||||
|
if (StringUtils.isEmpty(flag)) {
|
||||||
|
// flag is empty, add init value
|
||||||
|
flag = USER_EXP_PLAN_ON;
|
||||||
|
getRedis().put(FLAG_KEY, USER_EXP_PLAN_ON);
|
||||||
|
}
|
||||||
|
|
||||||
|
// logger.info("flag {}", flag);
|
||||||
|
if (StringUtils.equalsIgnoreCase(USER_EXP_PLAN_OFF, flag)) {
|
||||||
|
view.addObject(USER_EXP_TELEMETRY, "off");
|
||||||
|
} else {
|
||||||
|
view.addObject(USER_EXP_TELEMETRY, "on");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get redis bean
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private static RedisCommand getRedis() {
|
||||||
|
if (redis == null) {
|
||||||
|
redis = MainContext.getContext().getBean(RedisCommand.class);
|
||||||
|
}
|
||||||
|
return redis;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
@ -269,7 +269,16 @@ block content
|
|||||||
p 系统菜单的权限控制
|
p 系统菜单的权限控制
|
||||||
p(style='color:#888888;font-size:13px;margin-top:10px;') 默认不启用权限控制,如果选择启用,用户需要授权才能访问需要授权的系统菜单功能,系统管理员账号(admin)不受控制
|
p(style='color:#888888;font-size:13px;margin-top:10px;') 默认不启用权限控制,如果选择启用,用户需要授权才能访问需要授权的系统菜单功能,系统管理员账号(admin)不受控制
|
||||||
.col-lg-4(style='text-align:right;')
|
.col-lg-4(style='text-align:right;')
|
||||||
input(type="checkbox", title="启用", name="auth", value="1", checked= (systemConfig.auth ? 'checked': false))
|
input(type="checkbox", title="启用", name="auth", value="1", checked= (systemConfig.auth == "true" ? 'checked': false))
|
||||||
|
.ukefu-webim-prop
|
||||||
|
.ukefu-webim-tl(style='clear:both;') 加入用户体验计划
|
||||||
|
.box-item
|
||||||
|
.row
|
||||||
|
.col-lg-8
|
||||||
|
p 是否开启
|
||||||
|
p(style='color:#888888;font-size:13px;margin-top:10px;') 反馈功能使用情况,以指导春松客服优化和完善产品功能; 相关数据匿名,不发送敏感数据
|
||||||
|
.col-lg-4(style='text-align:right;')
|
||||||
|
input(type="checkbox", title="启用", name="userExpTelemetrySetting", value="1", checked= (userExpTelemetrySetting ? 'checked': false))
|
||||||
.ukefu-webim-prop(hidden)
|
.ukefu-webim-prop(hidden)
|
||||||
.ukefu-webim-tl(style='clear:both;') 启用语音平台模板配置
|
.ukefu-webim-tl(style='clear:both;') 启用语音平台模板配置
|
||||||
.box-item
|
.box-item
|
||||||
|
@ -35,6 +35,13 @@ html(xmlns='http://www.w3.org/1999/xhtml', xmlns:th='http://www.thymeleaf.org',
|
|||||||
script(language='javascript', src='/js/theme/wonderland.js')
|
script(language='javascript', src='/js/theme/wonderland.js')
|
||||||
script(src='/layui.js')
|
script(src='/layui.js')
|
||||||
script(src='/js/cskefu.js')
|
script(src='/js/cskefu.js')
|
||||||
|
if userExpTelemetry == 'on'
|
||||||
|
script(src='https://www.googletagmanager.com/gtag/js?id=G-SBBX10RKTC' async)
|
||||||
|
script.
|
||||||
|
window.dataLayer = window.dataLayer || [];
|
||||||
|
function gtag(){dataLayer.push(arguments);}
|
||||||
|
gtag('js', new Date());
|
||||||
|
gtag('config', 'G-SBBX10RKTC');
|
||||||
body
|
body
|
||||||
.layui-layout.layui-layout-content
|
.layui-layout.layui-layout-content
|
||||||
.layui-side.layui-bg-black
|
.layui-side.layui-bg-black
|
||||||
|
@ -53,6 +53,15 @@ html(xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" xm
|
|||||||
script(src="http://api.map.baidu.com/api?v=2.0&ak=" + systemConfig.mapkey)
|
script(src="http://api.map.baidu.com/api?v=2.0&ak=" + systemConfig.mapkey)
|
||||||
script(src="/js/echarts.common.min.js")
|
script(src="/js/echarts.common.min.js")
|
||||||
script(language="javascript" src="/js/theme/wonderland.js")
|
script(language="javascript" src="/js/theme/wonderland.js")
|
||||||
|
if userExpTelemetry == 'on'
|
||||||
|
script(src='https://www.googletagmanager.com/gtag/js?id=G-SBBX10RKTC' async)
|
||||||
|
script.
|
||||||
|
window.dataLayer = window.dataLayer || [];
|
||||||
|
function gtag() {
|
||||||
|
dataLayer.push(arguments);
|
||||||
|
}
|
||||||
|
gtag('js', new Date());
|
||||||
|
gtag('config', 'G-SBBX10RKTC');
|
||||||
|
|
||||||
body
|
body
|
||||||
.layui-layout.layui-layout-content
|
.layui-layout.layui-layout-content
|
||||||
|
@ -70,6 +70,16 @@ html
|
|||||||
s.parentNode.insertBefore(hm, s);
|
s.parentNode.insertBefore(hm, s);
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
if userExpTelemetry == 'on'
|
||||||
|
script(src='https://www.googletagmanager.com/gtag/js?id=G-SBBX10RKTC' async)
|
||||||
|
script.
|
||||||
|
window.dataLayer = window.dataLayer || [];
|
||||||
|
function gtag() {
|
||||||
|
dataLayer.push(arguments);
|
||||||
|
}
|
||||||
|
gtag('js', new Date());
|
||||||
|
gtag('config', 'G-SBBX10RKTC');
|
||||||
|
|
||||||
body.login
|
body.login
|
||||||
if extrasLoginBanner != "off"
|
if extrasLoginBanner != "off"
|
||||||
div(style="width: 100%; height:50px; background-color: #2bd99e; padding-top: 0px;display: flex;")
|
div(style="width: 100%; height:50px; background-color: #2bd99e; padding-top: 0px;display: flex;")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user