jyy
2022-04-15 f57554f7da5e4d05b4b4bab99bf49ac9ca8c2038
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
package com.matrix.system.common.actions;
 
import com.matrix.core.pojo.AjaxResult;
import com.matrix.core.pojo.PaginationVO;
import com.matrix.core.tools.WebUtil;
import com.matrix.core.web.BaseAction;
import com.matrix.system.common.bean.SysFunction;
import com.matrix.system.common.constance.AppConstance;
import com.matrix.system.common.constance.AppVocabularyCode;
import com.matrix.system.common.service.SysButtonService;
import com.matrix.system.common.service.SysFunctionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
 
import java.util.Arrays;
 
/**
 *  系统功能管理
 * @author:姜友瑶
 * @date 2016年11月16日
 */
@Controller
@RequestMapping(value = "admin/sysFunction")
public class SysFunctionAction extends BaseAction {
 
    @Autowired
    private SysFunctionService sysFunctionService;
 
    @Autowired
    private SysButtonService sysBtnService;
 
    public static final String BEV = "SYSFUNCTION_BEV";
 
    /**
     * 列表显示
     * 
     * @author JIANGYOUYAO
     * @email 935090232@qq.com
     * @date 2016年12月10日
     * @param sysFunction
     * @param pageVo
     * @return
     */
    @RequestMapping(value = "/showList")
    public @ResponseBody AjaxResult showList(SysFunction sysFunction, PaginationVO pageVo) {
        return showList(sysFunctionService, sysFunction, pageVo);
    }
 
    /**
     * 显示所有功能
     * 
     * @author JIANGYOUYAO
     * @email 935090232@qq.com
     * @date Dec 10, 2017
     * @return
     */
    @RequestMapping(value = "/all")
    public @ResponseBody AjaxResult all() {
        return new AjaxResult(AjaxResult.STATUS_SUCCESS, sysFunctionService.findByModel(null));
    }
 
    /**
     * 
     *  修改查询function,在session保存旧值
     * @author:姜友瑶
     * @param sysFunction
     * @param pageVo
     * @return 返回类型 AjaxResult
     * @date 2016年11月16日
     */
    @RequestMapping(value = "/findById")
    public @ResponseBody AjaxResult findById(SysFunction sysFunction) {
        sysFunction = sysFunctionService.findById(String.valueOf(sysFunction.getFnId()));
        WebUtil.setSessionAttribute(BEV, sysFunction);
        return new AjaxResult(AjaxResult.STATUS_SUCCESS, Arrays.asList(sysFunction));
    }
 
    /**
     * 新增或者修改页面
     * 
     * @author JIANGYOUYAO
     * @email 935090232@qq.com
     * @date Dec 10, 2017
     * @param sysFunction
     * @return
     */
    @RequestMapping(value = "/addFunction")
    public @ResponseBody AjaxResult addFunction(SysFunction sysFunction) {
        return add(sysFunctionService, sysFunction, AppVocabularyCode.FUNCTION);
    }
 
    /**
     * 更新功能
     * 
     * @author JIANGYOUYAO
     * @email 935090232@qq.com
     * @date Dec 10, 2017
     * @param sysFunction
     * @return
     */
    @PostMapping(value = "/modifyFunction")
    public @ResponseBody AjaxResult modifyFunction(SysFunction sysFunction) {
        AjaxResult result = modify(sysFunctionService, WebUtil.getSessionAttribute(BEV), sysFunction,
                AppVocabularyCode.FUNCTION);
        // 因为页面是一直打开的需要存新的值
        WebUtil.setSessionAttribute(BEV, sysFunction);
        return result;
    }
 
    /**
     * 启用功能
     * 
     * @author JIANGYOUYAO
     * @email 935090232@qq.com
     * @date Dec 10, 2017
     * @param fnId
     * @return
     */
    @RequestMapping(value = "/enableFunction")
    public @ResponseBody AjaxResult enableFunction(Long fnId) {
        sysFunctionService.setIsDisable(fnId, AppConstance.IS_N);
        return new AjaxResult(AjaxResult.STATUS_SUCCESS, "功能启用成功");
    }
 
    /**
     * 禁用功能
     * 
     * @author JIANGYOUYAO
     * @email 935090232@qq.com
     * @date Dec 10, 2017
     * @param fnId
     * @return
     */
    @RequestMapping(value = "/disEnableFunction")
    public @ResponseBody AjaxResult disEnableFunction(Long fnId) {
        sysFunctionService.setIsDisable(fnId, AppConstance.IS_Y);
        return new AjaxResult(AjaxResult.STATUS_SUCCESS, "功能禁用成功");
    }
 
    /**
     * 进入修改界面
     * 
     * @author JIANGYOUYAO
     * @email 935090232@qq.com
     * @date Dec 10, 2017
     * @param id
     * @return
     */
    @RequestMapping(value = "/editForm")
    public ModelAndView editForm(String id) {
        ModelAndView mv =new ModelAndView("developer/sysFunction-form");
        SysFunction sysFunction  = new SysFunction();
        mv.addObject("obj", sysFunction);
        if (id != null) {
            sysFunction = sysFunctionService.findById(id);
            // 查询出所有的按钮
            mv.addObject("obj", sysFunction);
            //WebUtil.setRequestAttribute("obj", sysFunction);
            WebUtil.setSessionAttribute(BEV, sysFunction);
        }
        //WebUtil.setRequestAttribute("btnList", sysBtnService.findByModel(null));
        mv.addObject("btnList", sysBtnService.findByModel(null));
        return mv;
    }
 
    /**
     * 删除功能
     * 
     * @author JIANGYOUYAO
     * @email 935090232@qq.com
     * @date Dec 10, 2017
     * @param fnId
     * @return
     */
    @RequestMapping(value = "/del")
    public @ResponseBody AjaxResult del(String fnId) {
        return remove(sysFunctionService, fnId);
    }
 
}