xiaoyong931011
2022-09-23 19ab08f041d6773f22594ed393105c623e09f543
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package cc.mrbird.febs.mall.controller;
 
import cc.mrbird.febs.common.entity.FebsConstant;
import cc.mrbird.febs.common.utils.FebsUtil;
import cc.mrbird.febs.mall.entity.MallNewsCategory;
import cc.mrbird.febs.mall.entity.MallNewsInfo;
import cc.mrbird.febs.mall.service.IMallNewsInfoService;
import lombok.RequiredArgsConstructor;
import org.apache.shiro.authz.annotation.RequiresPermissions;
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.bind.annotation.RequestMapping;
 
/**
 * @author wzy
 * @date 2022-05-13
 **/
@Controller("newView")
@RequestMapping(FebsConstant.VIEW_PREFIX + "modules/news")
@RequiredArgsConstructor
public class ViewNewsController {
 
    private final IMallNewsInfoService mallNewsInfoService;
 
    /**
     * 新闻中心-列表
     * @return
     */
    @GetMapping("newsInfoList")
    @RequiresPermissions("newsInfoList:view")
    public String newsInfoList() {
        return FebsUtil.view("modules/news/newsInfoList");
    }
 
    /**
     * 新闻中心-新增
     * @return
     */
    @GetMapping("newsInfoAdd")
    @RequiresPermissions("newsInfoAdd:add")
    public String newsInfoAdd() {
        return FebsUtil.view("modules/news/newsInfoAdd");
    }
 
    /**
     * 新闻中心-详情
     * @param id
     * @param model
     * @return
     */
    @GetMapping("newsInfoUpdate/{id}")
    @RequiresPermissions("newsInfoUpdate:update")
    public String newsInfoUpdate(@PathVariable long id, Model model) {
        MallNewsInfo data = mallNewsInfoService.getNewsInfoById(id);
        model.addAttribute("newsInfo", data);
        return FebsUtil.view("modules/news/newsInfoUpdate");
    }
 
    @GetMapping("newsCategory")
    @RequiresPermissions("news:category:view")
    public String newsCategory() {
        return FebsUtil.view("modules/news/newsCategory");
    }
 
    @GetMapping("addCategory")
    @RequiresPermissions("news:category:add")
    public String addCategory(Long id, Model model) {
        if (id != null) {
            MallNewsCategory obj = mallNewsInfoService.findNewsCategoryById(id);
            model.addAttribute("obj", obj);
        }
        return FebsUtil.view("modules/news/newsCategoryAdd");
    }
 
    @GetMapping("updateCategory/{id}")
    @RequiresPermissions("news:category:update")
    public String updateCategory(@PathVariable Long id, Model model) {
        if (id != null) {
            MallNewsCategory obj = mallNewsInfoService.findNewsCategoryById(id);
            model.addAttribute("obj", obj);
        }
        return FebsUtil.view("modules/news/newsCategoryAdd");
    }
}