935090232@qq.com
2021-03-18 5d43370b99a03391c9271d04d3f351f0fd734dae
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
package com.matrix.system.common.actions;
 
import com.matrix.core.anotations.RemoveRequestToken;
import com.matrix.core.anotations.SaveRequestToken;
import com.matrix.core.constance.SystemErrorCode;
import com.matrix.core.constance.SystemMessageCode;
import com.matrix.core.exception.GlobleException;
import com.matrix.core.pojo.AjaxResult;
import com.matrix.core.pojo.PaginationVO;
import com.matrix.core.tools.StringUtils;
import com.matrix.core.tools.WebUtil;
import com.matrix.core.web.BaseAction;
import com.matrix.system.common.bean.SysUsers;
import com.matrix.system.common.constance.AppConstance;
import com.matrix.system.common.constance.AppVocabularyCode;
import com.matrix.system.common.service.SysUsersService;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
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.List;
 
/**
 * @author 姜友瑶
 * @description 管理员总action
 * @email 935090232@qq.com
 * @date 2016-06-26
 */
@Controller
@RequestMapping(value = "super")
public class SuperAction extends BaseAction {
    @Autowired
    private SysUsersService sysUsersService;
 
    public static final String BEV = "SYSUSERS_BEV";
 
    /**
     * @param page1
     * @param page2
     * @return 返回类型 String
     *  页面定向方法,每个权限模块公用一个,每个模块共享一个一级路径,已便于进行权限过滤
     * @author:姜友瑶
     * @date 2016年8月31日
     */
    @RequestMapping(value = "/redirect/{page1}/{page2}")
    public String redirect(@PathVariable("page1") String page1, @PathVariable("page2") String page2) {
        return "super/" + page1 + "/" + page2;
    }
 
    /**
     * @param page1
     * @return 返回类型 String
     *  页面定向方法,每个权限模块公用一个,每个模块共享一个一级路径,已便于进行权限过滤
     * @author:姜友瑶
     * @date 2016年8月31日
     */
    @RequestMapping(value = "/redirect/{page1}")
    public String redirect(@PathVariable("page1") String page1) {
        return "super/" + page1;
    }
 
    /**
     * 新增超级管理员
     *
     * @param sysUsers
     * @return
     * @author JIANGYOUYAO
     * @email 935090232@qq.com
     * @date Dec 10, 2017
     */
    @RemoveRequestToken
    @PostMapping(value = "/addSuperUser")
    public @ResponseBody
    AjaxResult addSuperUser(SysUsers sysUsers) {
        int i = sysUsersService.addCompanySuper(sysUsers);
        if (i > 0) {
            return new AjaxResult(AjaxResult.STATUS_SUCCESS, SystemMessageCode.ADD_SUCCES, AppVocabularyCode.ADMIN);
        } else {
            throw new GlobleException(SystemErrorCode.DATA_ADD_FAIL);
        }
    }
 
    /**
     * 修改超级管理员
     *
     * @param sysUsers
     * @return
     * @author JIANGYOUYAO
     * @email 935090232@qq.com
     * @date Dec 10, 2017
     */
    @RemoveRequestToken
    @PostMapping(value = "/modifySuperUser")
    public @ResponseBody
    AjaxResult modifySuperUser(SysUsers sysUsers) {
 
        int i = sysUsersService.modifyByMap(WebUtil.getSessionAttribute(BEV), sysUsers);
        if (i > 0) {
 
            return new AjaxResult(AjaxResult.STATUS_SUCCESS, SystemMessageCode.UPDATE_SUCCES, "管理员");
        } else {
            throw new GlobleException(SystemErrorCode.DATA_UPDATE_FAIL);
        }
    }
 
    /**
     * 进入修改界面
     *
     * @param id
     * @return
     * @author JIANGYOUYAO
     * @email 935090232@qq.com
     * @date Dec 10, 2017
     */
    @SaveRequestToken
    @RequestMapping(value = "/editForm")
    public ModelAndView editForm(Long id) {
        SysUsers sysUsers = new SysUsers();
        ModelAndView mv = new ModelAndView("super/super-form");
        mv.addObject("obj", sysUsers);
        if (id != null) {
            sysUsers = sysUsersService.findById(id);
            //WebUtil.getRequest().setAttribute("obj", sysUsers);
            mv.addObject("obj", sysUsers);
            WebUtil.setSessionAttribute(BEV, sysUsers);
        }
        return mv;
    }
 
    /**
     * 列表显示
     *
     * @param sysUsers
     * @param pageVo
     * @return
     * @author JIANGYOUYAO
     * @email 935090232@qq.com
     * @date Dec 10, 2017
     */
    @RequestMapping(value = "/showList")
    public @ResponseBody
    AjaxResult showList(SysUsers sysUsers, PaginationVO pageVo) {
        sysUsers.setSuUserType(AppConstance.USER_TYPE_ADMIN);
        List<SysUsers> dataList = sysUsersService.findInPage(sysUsers, pageVo);
        AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, dataList, sysUsersService.findTotal(sysUsers));
        return result;
    }
 
    /**
     * 删除
     *
     * @param keys
     * @return
     * @author JIANGYOUYAO
     * @email 935090232@qq.com
     * @date Dec 10, 2017
     */
    @RequestMapping(value = "/del")
    public @ResponseBody
    AjaxResult del(String keys) {
        List<String> ids = StringUtils.strToCollToString(keys, ",");
        int i = sysUsersService.remove(ids);
        if (i > 0) {
            return new AjaxResult(AjaxResult.STATUS_SUCCESS, SystemMessageCode.DELETE_SUCCES, i);
        } else {
            throw new GlobleException(SystemErrorCode.DATA_DELETE_FAIL);
        }
    }
 
}