首页>代码>ssh开发在线问卷答题系统,maven多模块搭建,用于java毕设绰绰有余>/WTS/src/wts-authority/src/main/java/com/farm/authority/controller/ActiontreeController.java
001package com.farm.authority.controller;
002 
003import com.farm.authority.domain.Action;
004import com.farm.authority.domain.Actiontree;
005import com.farm.authority.service.ActionServiceInter;
006import com.farm.web.WebUtils;
007import com.farm.web.easyui.EasyUiTreeNode;
008import com.farm.web.easyui.EasyUiUtils;
009 
010import java.util.ArrayList;
011import java.util.List;
012import java.util.Map;
013 
014import javax.annotation.Resource;
015import javax.servlet.http.HttpServletRequest;
016import javax.servlet.http.HttpSession;
017 
018import org.apache.log4j.Logger;
019import org.springframework.stereotype.Controller;
020import org.springframework.web.bind.annotation.RequestMapping;
021import org.springframework.web.bind.annotation.ResponseBody;
022import org.springframework.web.servlet.ModelAndView;
023 
024import com.farm.core.page.RequestMode;
025import com.farm.core.page.ViewMode;
026import com.farm.core.sql.result.DataResult;
027import com.farm.core.sql.query.DBRule;
028import com.farm.core.sql.query.DataQuery;
029import com.farm.core.sql.query.DataQuerys;
030 
031/* *
032 *功能:构造权限控制层
033 *详细:
034 *
035 *版本:v0.1
036 *作者:Farm代码工程自动生成
037 *日期:20141122211253
038 *说明:
039 */
040@RequestMapping("/actiontree")
041@Controller
042public class ActiontreeController extends WebUtils {
043    private final static Logger log = Logger.getLogger(ActiontreeController.class);
044    @Resource
045    ActionServiceInter actionServiceImpl;
046 
047    @RequestMapping("/list")
048    public ModelAndView index(HttpSession session) {
049        return ViewMode.getInstance().returnModelAndView("authority/ActiontreeResult");
050    }
051 
052    @RequestMapping("/icons")
053    public ModelAndView icons(HttpSession session) {
054        return ViewMode.getInstance().returnModelAndView("authority/ActionCssIcon");
055    }
056 
057    @RequestMapping("/actionsPage")
058    public ModelAndView actionsPage(HttpSession session) {
059        return ViewMode.getInstance().returnModelAndView("authority/ActionChoose");
060    }
061 
062    @RequestMapping("/treePage")
063    public ModelAndView treePage(HttpSession session, String ids) {
064        return ViewMode.getInstance().putAttr("ids", ids).returnModelAndView("authority/ActiontreenodeChooseTreeWin");
065    }
066 
067    /**
068     * 查询所有主菜单结果集合
069     *
070     * @return
071     */
072    @RequestMapping("/query")
073    @ResponseBody
074    public Map<String, Object> queryall(DataQuery query, HttpServletRequest request) {
075        try {
076            query = EasyUiUtils.formatGridQuery(request, query);
077            if (query.getQueryRule().size() == 0) {
078                query.addRule(new DBRule("PARENTID", "NONE", "="));
079            }
080            DataResult result = actionServiceImpl.createActiontreeSimpleQuery(query).search();
081            result.runDictionary("1:分类,2:菜单,3:权限", "TYPE");
082            result.runDictionary("1:可用,0:禁用", "STATE");
083            return ViewMode.getInstance().putAttrs(EasyUiUtils.formatGridData(result)).returnObjMode();
084        } catch (Exception e) {
085            log.error(e.getMessage());
086            return ViewMode.getInstance().setError(e.getMessage(), e).returnObjMode();
087        }
088 
089    }
090 
091    /**
092     * 加载页面所有菜单
093     *
094     * @return
095     */
096    @RequestMapping("/queryMenu")
097    @ResponseBody
098    public Map<String, Object> loadAllMenu() {
099        try {
100            DataResult result = actionServiceImpl.searchAllMenu();
101            return ViewMode.getInstance().putAttrs(EasyUiUtils.formatGridData(result)).returnObjMode();
102        } catch (Exception e) {
103            log.error(e.getMessage());
104            return ViewMode.getInstance().setError(e.getMessage(), e).returnObjMode();
105        }
106    }
107 
108    /**
109     * 提交修改数据
110     *
111     * @return
112     */
113    @RequestMapping("/edit")
114    @ResponseBody
115    public Map<String, Object> editSubmit(Actiontree entity, Action action, HttpSession session) {
116        try {
117            entity = actionServiceImpl.editActiontreeEntity(entity, getCurrentUser(session), action.getAuthkey());
118 
119            return ViewMode.getInstance().putAttr("entity", entity).returnObjMode();
120        } catch (Exception e) {
121            log.error(e.getMessage());
122            return ViewMode.getInstance().setError(e.getMessage(), e).returnObjMode();
123        }
124    }
125 
126    /**
127     * 提交新增数据
128     *
129     * @param entity
130     *            表单
131     * @param authkey
132     *            权限uri
133     * @param session
134     * @return
135     */
136    @RequestMapping("/add")
137    @ResponseBody
138    public Map<String, Object> addSubmit(Actiontree entity, String authkey, HttpSession session) {
139        try {
140            entity = actionServiceImpl.insertActiontreeEntity(entity, getCurrentUser(session), authkey);
141            return ViewMode.getInstance().putAttr("entity", entity).returnObjMode();
142        } catch (Exception e) {
143            log.error(e.getMessage());
144            return ViewMode.getInstance().setError(e.getMessage(), e).returnObjMode();
145        }
146    }
147 
148    /**
149     * 删除数据
150     *
151     * @return
152     */
153    @RequestMapping("/del")
154    @ResponseBody
155    public Map<String, Object> delSubmit(String ids, HttpSession session) {
156        try {
157            for (String id : parseIds(ids)) {
158                actionServiceImpl.deleteActiontreeEntity(id, getCurrentUser(session));
159            }
160            return ViewMode.getInstance().returnObjMode();
161        } catch (Exception e) {
162            log.error(e.getMessage());
163            return ViewMode.getInstance().setError(e.getMessage(), e).returnObjMode();
164        }
165    }
166 
167    /**
168     * 显示详细信息(修改或浏览时)
169     *
170     * @return
171     */
172    @RequestMapping("/form")
173    public ModelAndView view(RequestMode pageset, String domain, String ids, String parentid) {
174        ViewMode mode = ViewMode.getInstance();
175        try {
176            Actiontree parent = new Actiontree();
177            Actiontree entity = null;
178            switch (pageset.getOperateType()) {
179            case (1): {// 新增
180                break;
181            }
182            case (0): {// 展示
183                entity = actionServiceImpl.getActiontreeEntity(ids);
184                mode.putAttr("entity", entity);
185                break;
186            }
187            case (2): {// 修改
188                entity = actionServiceImpl.getActiontreeEntity(ids);
189                mode.putAttr("entity", entity);
190                break;
191            }
192            default:
193                break;
194            }
195            if (parentid != null && parentid.trim().length() > 0) {
196                parent = actionServiceImpl.getActiontreeEntity(parentid);
197                mode.putAttr("parent", parent);
198            }
199            if (entity != null && entity.getActionid() != null) {
200                Action treeAction = actionServiceImpl.getActionEntity(entity.getActionid());
201                mode.putAttr("treeAction", treeAction);
202            }
203        } catch (Exception e) {
204            return ViewMode.getInstance().setError(e.getMessage(), e).returnModelAndView("authority/ActiontreeForm");
205        }
206        return mode.putAttr("pageset", pageset).putAttr("domain", domain)
207                .returnModelAndView("authority/ActiontreeForm");
208    }
209 
210    /**
211     * 移动节点
212     *
213     * @return
214     */
215    @RequestMapping("/move")
216    @ResponseBody
217    public Map<String, Object> moveTreeNodeSubmit(String oid, String deid) {
218        try {
219            for (String id : parseIds(oid)) {
220                actionServiceImpl.moveActionTreeNode(id, deid);
221            }
222            return ViewMode.getInstance().returnObjMode();
223        } catch (Exception e) {
224            log.error(e.getMessage());
225            return ViewMode.getInstance().setError(e.getMessage(), e).returnObjMode();
226        }
227    }
228 
229    /**
230     * 加载子节点
231     *
232     * @param id
233     * @param domain
234     * @return
235     */
236    @RequestMapping("/loadtree")
237    @ResponseBody
238    public List<EasyUiTreeNode> loadTreeNode(String id, String domain) {
239        try {
240            return actionServiceImpl.getSyncTree(id, domain);
241        } catch (Exception e) {
242            log.error(e.getMessage());
243            return new ArrayList<EasyUiTreeNode>();
244        }
245    }
246 
247    /**
248     * 加载树节点根据用户权限
249     *
250     * @return
251     */
252    @RequestMapping("/cuserMenus")
253    @ResponseBody
254    public Object loadTreeNodeForCurrentUser(String id, String domain, HttpSession session) {
255        try {
256            DataQuerys.wipeVirus(id);
257            DataQuerys.wipeVirus(domain);
258            List<EasyUiTreeNode> result = actionServiceImpl.searchAsynEasyUiTree(id, domain,
259                    getCurrentUserMenus(session));
260            return result;
261        } catch (Exception e) {
262            log.error(e.getMessage());
263            return ViewMode.getInstance().setError(e.getMessage(), e).returnObjMode();
264        }
265    }
266 
267}
最近下载更多
pokerf  LV5 2023年12月28日
18728748707  LV13 2023年10月19日
lcqlcl  LV11 2023年8月29日
letmesee 2023年5月15日
暂无贡献等级
Laihao  LV10 2023年4月13日
朱朱啊哈  LV16 2023年1月31日
天马行空  LV3 2022年11月14日
yashemao  LV1 2022年11月9日
jerry_mouse  LV6 2022年7月25日
testuser1234567  LV24 2022年5月22日
最近浏览更多
哪里的完整版  LV8 前天
15578157792  LV7 2024年12月10日
surpaasx 2024年11月25日
暂无贡献等级
y_x_happy  LV4 2024年11月1日
半夏bx  LV14 2024年10月1日
pilipala888 2024年9月10日
暂无贡献等级
刘昊然  LV1 2024年7月1日
3334004690  LV10 2024年6月24日
TY0165  LV20 2024年6月21日
865581316LLL  LV6 2024年6月12日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友