RenderController.java 6.9 KB
Newer Older
Y
yadong.zhang 已提交
1 2 3 4 5 6 7
package com.zyd.blog.controller;

/**
 * 页面渲染相关 -- 页面跳转
 *
 * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
 * @version 1.0
8
 * @website https://docs.zhyd.me
Y
yadong.zhang 已提交
9 10 11
 * @date 2018/4/24 14:37
 * @since 1.0
 */
12

Y
yadong.zhang 已提交
13
import com.zyd.blog.business.annotation.BussinessLog;
Y
yadong.zhang 已提交
14 15
import com.zyd.blog.business.entity.Article;
import com.zyd.blog.business.service.BizArticleService;
16
import com.zyd.blog.business.service.SysConfigService;
17
import com.zyd.blog.core.BlogHunterConfigProvider;
18
import com.zyd.blog.core.websocket.server.ZydWebsocketServer;
Y
yadong.zhang 已提交
19
import com.zyd.blog.util.ResultUtil;
20 21
import me.zhyd.hunter.config.platform.Platform;
import me.zhyd.hunter.enums.ExitWayEnum;
22 23 24
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.authz.annotation.RequiresRoles;
25
import org.apache.shiro.authz.annotation.RequiresUser;
Y
yadong.zhang 已提交
26
import org.springframework.beans.factory.annotation.Autowired;
Y
yadong.zhang 已提交
27 28 29 30 31 32 33 34 35 36 37
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.servlet.ModelAndView;

/**
 * 页面跳转类
 *
 * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
 * @version 1.0
38
 * @website https://docs.zhyd.me
Y
yadong.zhang 已提交
39 40 41 42 43 44
 * @date 2018/4/24 14:37
 * @since 1.0
 */
@Controller
public class RenderController {

Y
yadong.zhang 已提交
45 46
    @Autowired
    private BizArticleService articleService;
47 48
    @Autowired
    private ZydWebsocketServer websocketServer;
49 50
    @Autowired
    private BlogHunterConfigProvider blogHunterConfigProvider;
Y
yadong.zhang 已提交
51

52
    @RequiresAuthentication
Y
yadong.zhang 已提交
53
    @BussinessLog("进入首页")
Y
yadong.zhang 已提交
54
    @GetMapping(value = {""})
Y
yadong.zhang 已提交
55 56 57 58
    public ModelAndView home() {
        return ResultUtil.view("index");
    }

59
    @RequiresPermissions("users")
Y
yadong.zhang 已提交
60 61 62 63 64 65
    @BussinessLog("进入用户列表页")
    @GetMapping("/users")
    public ModelAndView user() {
        return ResultUtil.view("user/list");
    }

66
    @RequiresPermissions("resources")
Y
yadong.zhang 已提交
67 68 69 70 71 72
    @BussinessLog("进入资源列表页")
    @GetMapping("/resources")
    public ModelAndView resources() {
        return ResultUtil.view("resources/list");
    }

73
    @RequiresPermissions("roles")
Y
yadong.zhang 已提交
74 75 76 77 78 79
    @BussinessLog("进入角色列表页")
    @GetMapping("/roles")
    public ModelAndView roles() {
        return ResultUtil.view("role/list");
    }

80
    @RequiresPermissions("articles")
Y
yadong.zhang 已提交
81 82 83 84 85 86
    @BussinessLog("进入文章列表页")
    @GetMapping("/articles")
    public ModelAndView articles() {
        return ResultUtil.view("article/list");
    }

87
    @RequiresPermissions("article:publish")
智布道's avatar
智布道 已提交
88
    @BussinessLog(value = "进入发表文章页[html]")
Y
yadong.zhang 已提交
89 90 91 92 93
    @GetMapping("/article/publish")
    public ModelAndView publish() {
        return ResultUtil.view("article/publish");
    }

Y
yadong.zhang 已提交
94
    @RequiresPermissions("article:publish")
智布道's avatar
智布道 已提交
95
    @BussinessLog(value = "进入发表文章页[markdown]")
Y
yadong.zhang 已提交
96 97 98 99 100 101
    @GetMapping("/article/publishMd")
    public ModelAndView publishMd() {
        return ResultUtil.view("article/publish-md");
    }

    @RequiresPermissions("article:publish")
智布道's avatar
智布道 已提交
102
    @BussinessLog(value = "进入修改文章页[id={1}]")
Y
yadong.zhang 已提交
103 104 105
    @GetMapping("/article/update/{id}")
    public ModelAndView edit(@PathVariable("id") Long id, Model model) {
        model.addAttribute("id", id);
Y
yadong.zhang 已提交
106
        Article article = articleService.getByPrimaryKey(id);
107
        if (article.getIsMarkdown()) {
Y
yadong.zhang 已提交
108 109
            return ResultUtil.view("article/publish-md");
        }
Y
yadong.zhang 已提交
110 111 112
        return ResultUtil.view("article/publish");
    }

113
    @RequiresPermissions("types")
Y
yadong.zhang 已提交
114 115 116 117 118 119
    @BussinessLog("进入分类列表页")
    @GetMapping("/article/types")
    public ModelAndView types() {
        return ResultUtil.view("article/types");
    }

120
    @RequiresPermissions("tags")
Y
yadong.zhang 已提交
121 122 123 124 125 126
    @BussinessLog("进入标签列表页")
    @GetMapping("/article/tags")
    public ModelAndView tags() {
        return ResultUtil.view("article/tags");
    }

127
    @RequiresPermissions("links")
Y
yadong.zhang 已提交
128 129 130 131 132 133
    @BussinessLog("进入链接页")
    @GetMapping("/links")
    public ModelAndView links() {
        return ResultUtil.view("link/list");
    }

134
    @RequiresPermissions("comments")
Y
yadong.zhang 已提交
135 136 137 138 139 140
    @BussinessLog("进入评论页")
    @GetMapping("/comments")
    public ModelAndView comments() {
        return ResultUtil.view("comment/list");
    }

141
    @RequiresPermissions("notices")
Y
yadong.zhang 已提交
142 143 144 145 146 147
    @BussinessLog("进入系统通知页")
    @GetMapping("/notices")
    public ModelAndView notices() {
        return ResultUtil.view("notice/list");
    }

148
    @RequiresRoles("role:root")
Y
yadong.zhang 已提交
149 150 151 152 153 154
    @BussinessLog("进入系统配置页")
    @GetMapping("/config")
    public ModelAndView config() {
        return ResultUtil.view("config");
    }

155
    @RequiresPermissions("templates")
Y
yadong.zhang 已提交
156 157 158 159 160 161
    @BussinessLog("进入模板管理页")
    @GetMapping("/templates")
    public ModelAndView templates() {
        return ResultUtil.view("template/list");
    }

162
    @RequiresPermissions("updateLogs")
Y
yadong.zhang 已提交
163 164 165 166 167 168
    @BussinessLog("进入更新记录管理页")
    @GetMapping("/updates")
    public ModelAndView updates() {
        return ResultUtil.view("update/list");
    }

169
    @RequiresPermissions("icons")
智布道's avatar
智布道 已提交
170
    @BussinessLog(value = "进入icons页")
Y
yadong.zhang 已提交
171 172
    @GetMapping("/icons")
    public ModelAndView icons(Model model) {
173
        return ResultUtil.view("other/icons");
Y
yadong.zhang 已提交
174 175
    }

176
    @RequiresPermissions("shiro")
智布道's avatar
智布道 已提交
177
    @BussinessLog(value = "进入shiro示例页")
Y
yadong.zhang 已提交
178 179
    @GetMapping("/shiro")
    public ModelAndView shiro(Model model) {
180 181 182 183 184 185 186 187
        return ResultUtil.view("other/shiro");
    }

    @RequiresUser
    @BussinessLog("进入编辑器测试用例页面")
    @GetMapping("/editor")
    public ModelAndView editor(Model model) {
        return ResultUtil.view("other/editor");
Y
yadong.zhang 已提交
188
    }
189 190

    @RequiresPermissions("notice")
191
    @BussinessLog("进入通知管理页")
192 193 194
    @GetMapping("/notice")
    public ModelAndView notice(Model model) {
        model.addAttribute("online", websocketServer.getOnlineUserCount());
195
        return ResultUtil.view("laboratory/notification");
196
    }
197 198 199 200 201

    @RequiresUser
    @BussinessLog("进入搬运工页面")
    @GetMapping("/remover")
    public ModelAndView remover(Model model) {
智布道's avatar
智布道 已提交
202
        model.addAttribute("exitWayList", ExitWayEnum.values());
203
        model.addAttribute("spiderConfig", blogHunterConfigProvider.getBlogHunterConfig());
204
        model.addAttribute("platforms", Platform.values());
205
        return ResultUtil.view("laboratory/remover");
206
    }
207 208 209 210 211 212 213

    @RequiresPermissions("files")
    @BussinessLog("进入文件管理页面")
    @GetMapping("/files")
    public ModelAndView files(Model model) {
        return ResultUtil.view("file/list");
    }
214 215 216 217 218 219 220

    @RequiresPermissions("socials")
    @BussinessLog("进入社会化登录配置管理页面")
    @GetMapping("/socials")
    public ModelAndView socials(Model model) {
        return ResultUtil.view("social/list");
    }
221 222 223 224 225 226 227

    @RequiresPermissions("page")
    @BussinessLog("进入配置自定义页面")
    @GetMapping("/page")
    public ModelAndView page(Model model) {
        return ResultUtil.view("page/page");
    }
Y
yadong.zhang 已提交
228
}