Zhiqim Admin(简版的管理台)是从知启蒙管理台分离出来,保留系统参数表、系统菜单表、操作员、操作日志,去除组织、部门、角色等复杂权限功能,仅保留操作员独立权限功能。系统设计时保留ZmrSessionUser和ZmrOperator类,方便以后升级到知启蒙管理台。

森中灵 最后提交于7月前 整理V8.0.6
ThemeMainAction.java2KB
1/*
2 * 版权所有 (C) 2015 知启蒙(ZHIQIM) 保留所有权利。[遇见知启蒙,邂逅框架梦]
3 *
4 * https://zhiqim.org/project/zhiqim_components/zhiqim_admin.htm
5 *
6 * Zhiqim Admin is licensed under Mulan PSL v2.
7 * You can use this software according to the terms and conditions of the Mulan PSL v2.
8 * You may obtain a copy of Mulan PSL v2 at:
9 * http://license.coscl.org.cn/MulanPSL2
10 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
11 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
12 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
13 * See the Mulan PSL v2 for more details.
14 */
15package org.zhiqim.manager.action;
16
17import java.util.ArrayList;
18import java.util.List;
19
20import org.zhiqim.httpd.HttpContext;
21import org.zhiqim.httpd.HttpRequest;
22import org.zhiqim.httpd.context.annotation.AnIntercept;
23import org.zhiqim.httpd.context.core.Action;
24import org.zhiqim.kernel.json.Jsons;
25import org.zhiqim.kernel.util.Validates;
26import org.zhiqim.manager.ZmrConstants;
27import org.zhiqim.manager.dao.ZmrOperatorDao;
28import org.zhiqim.manager.dao.ZmrParamDao;
29
30/**
31 * 更换主页主题风格
32 *
33 * @version v1.0.0 @author zouzhigang 2016-5-28 新建与整理
34 */
35public class ThemeMainAction implements Action, ZmrConstants
36{
37 private List<String> themeNameList;
38
39 @Override
40 public void execute(HttpRequest request) throws Exception
41 {
42 HttpContext context = request.getContext();
43 if (themeNameList == null)
44 {//没数据的情况下第一次加载
45 themeNameList = ThemeIndexAction.loadTheme(request);
46 }
47
48 List<String[]> themeList = new ArrayList<>();
49 for (String name : themeNameList)
50 {
51 String[] template = new String[]{name, context.getRootPath("/ztmpl/zhiqim_manager/"+name+"/preview_main.png")};
52 themeList.add(template);
53  }
54
55 request.setAttribute("themeList", themeList);
56 }
57
58 @AnIntercept("chkZmrLogin")
59 public void update(HttpRequest request) throws Exception
60 {
61 String theme = request.getParameter("theme");
62 if (Validates.isEmpty(theme))
63 {
64 request.setResponseError("请选择一个有效的主题");
65 return;
66 }
67
68 if (!Validates.isContain(themeNameList, theme))
69 {
70 request.setResponseError("请选择一个有效的主题选项");
71 return;
72 }
73
74 ZmrParamDao.doUpdateThemeMain(theme);
75 request.setContextAttribute(ZMR_THEME_MAIN, theme);
76
77 //增加操作日志
78 ZmrOperatorDao.addOperateLog(request, "切换主页主题", Jsons.toString("theme", theme));
79 }
80 }
81