Skip to content

Commit

Permalink
功能完善
Browse files Browse the repository at this point in the history
  • Loading branch information
penggle committed May 2, 2017
1 parent 5e40eaf commit 3ffb2f1
Show file tree
Hide file tree
Showing 14 changed files with 473 additions and 136 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
Expand Down Expand Up @@ -39,8 +37,6 @@
@RestController
public class AdminResourceMgtController extends BaseController {

private static final Logger logger = LoggerFactory.getLogger(AdminResourceMgtController.class);

private AbstractXTreeBuilder<Long, AdminResource> resourceTreeBuilder = new AdminResourceTreeBuilder();

private TreeNodeConverter<AdminResource,Map<String,Object>> resourceTreeNodeConverter = new AdminResourceTreeNodeConverter();
Expand All @@ -56,7 +52,6 @@ public class AdminResourceMgtController extends BaseController {
*/
@RequestMapping(value="/admin/resource/available")
public Object getAvailableResources(HttpServletRequest request, HttpServletResponse response) {
logger.info(">>> 获取可用的资源树结构");
List<AdminResource> allResourceList = adminResourceService.getAllResourceList(null);
List<Map<String,Object>> dataList = resourceTreeBuilder.buildObjectTree(GlobalConstants.DEFAULT_ADMIN_ROOT_RESOURCE_ID, allResourceList, resourceTreeNodeConverter);
return genSuccessResult(dataList);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
package com.certusnet.xproject.admin.web.controller;

import static org.springframework.web.bind.annotation.RequestMethod.POST;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.certusnet.xproject.admin.consts.em.AdminRoleTypeEnum;
import com.certusnet.xproject.admin.model.AdminRole;
import com.certusnet.xproject.admin.model.AdminUser;
import com.certusnet.xproject.admin.service.AdminResourceService;
import com.certusnet.xproject.admin.service.AdminRoleService;
import com.certusnet.xproject.admin.web.LoginToken;
import com.certusnet.xproject.common.support.OrderBy;
import com.certusnet.xproject.common.support.Pager;
import com.certusnet.xproject.common.util.DateTimeUtils;
import com.certusnet.xproject.common.web.BaseController;
import com.certusnet.xproject.common.web.shiro.ShiroUtils;

/**
* 管理后台-角色管理Controller
*
* @author pengpeng
* @date 2017年4月11日 下午3:35:34
* @version 1.0
*/
@RestController
public class AdminRoleMgtController extends BaseController {

@Resource(name="adminResourceFacadeService")
private AdminResourceService adminResourceService;

@Resource(name="adminRoleFacadeService")
private AdminRoleService adminRoleService;

/**
* 查询角色列表
* @param request
* @param response
* @param roleQueryForm
* @param orderBy
* @param pager
* @return
*/
@RequestMapping(value="/admin/role/list")
public Object listRole(HttpServletRequest request, HttpServletResponse response, AdminRole roleQueryForm, OrderBy orderBy, Pager pager) {
List<AdminRole> roleList = adminRoleService.getRoleList(roleQueryForm, pager, orderBy);
return genSuccessResult(roleList);
}

/**
* 新增角色
* @param request
* @param response
* @param roleAddForm
* @return
*/
@RequestMapping(value="/admin/role/add/submit", method=POST)
public Object addRole(HttpServletRequest request, HttpServletResponse response, @RequestBody AdminRole roleAddForm) {
LoginToken<AdminUser> loginToken = ShiroUtils.getSessionAttribute(LoginToken.LOGIN_TOKEN_SESSION_KEY);
roleAddForm.setCreateTime(DateTimeUtils.formatNow());
roleAddForm.setCreateBy(loginToken.getLoginId());
roleAddForm.setRoleType(AdminRoleTypeEnum.ADMIN_ROLE_TYPE_NORMAL.getTypeCode());
adminRoleService.createRole(roleAddForm);
return genSuccessResult("保存成功!", null);
}

/**
* 修改角色
* @param request
* @param response
* @param roleEditForm
* @return
*/
@RequestMapping(value="/admin/role/edit/submit", method=POST)
public Object editRole(HttpServletRequest request, HttpServletResponse response, @RequestBody AdminRole roleEditForm) {
LoginToken<AdminUser> loginToken = ShiroUtils.getSessionAttribute(LoginToken.LOGIN_TOKEN_SESSION_KEY);
roleEditForm.setUpdateTime(DateTimeUtils.formatNow());
roleEditForm.setUpdateBy(loginToken.getLoginId());
adminRoleService.updateRole(roleEditForm);
return genSuccessResult("保存成功!", null);
}

/**
* 删除角色
* @param request
* @param response
* @param id
* @return
*/
@RequestMapping(value="/admin/role/del")
public Object delRole(HttpServletRequest request, HttpServletResponse response, Long id) {
adminRoleService.deleteRoleById(id);
return genSuccessResult("删除成功!", null);
}

}
3 changes: 2 additions & 1 deletion xproject-admin/src/main/webapp/admin/resource/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
</el-breadcrumb>
<div class="el-container-content">
<div style="height:34px;padding:0 0 15px 0;">
<el-button type="primary" icon="fa-refresh" @click="refreshResourceTree">刷新资源树</el-button>
<el-button type="primary" icon="fa-refresh" @click="refreshResourceTree(1000)">刷新资源树</el-button>
</div>
<div class="el-tree-loading" v-loading="loadingResourceTreeDataList" element-loading-text="拼命加载中..." element-loading-class="el-loading-mask-opacity" :class="{loading: loadingResourceTreeDataList}">
<el-tree :style="fixedTreeHeightStyle" :data="resourceTreeDataList" :props="defaultProps" :show-checkbox="true" :default-expand-all="true" :expand-on-click-node="false" :check-strictly="true" :render-content="renderResourceTreeNode"></el-tree>
Expand Down Expand Up @@ -228,6 +228,7 @@
</div>
</div>
</div>
<script type="text/javascript" src="../../resources/js/polyfill.min.js"></script>
<script type="text/javascript" src="../../resources/js/vue.min.js"></script>
<script type="text/javascript" src="../../resources/js/vue.pageloading.js"></script>
<script type="text/javascript" src="../../resources/js/vue-router.min.js"></script>
Expand Down
84 changes: 84 additions & 0 deletions xproject-admin/src/main/webapp/admin/role/list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="keywords" content="">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>角色管理</title>
<meta name="renderer" content="webkit">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Pragma" content="no-cache">
<link rel="shortcut icon" href="../../resources/images/favicon.ico">
<link rel="stylesheet" type="text/css" href="../../resources/components/element-ui/theme-default/element.min.css">
<link rel="stylesheet" type="text/css" href="../../resources/components/element-ui/theme-default/element.custom.css">
<link rel="stylesheet" type="text/css" href="../../resources/components/element-ui/theme-default/font-awesome.min.css">
<style type="text/css">
</style>
</head>
<body>
<div id="app" class="el-container el-hidden">
<div class="el-container-inner">
<el-breadcrumb class="el-breadcrumb-admin" separator="/">
<i class="el-icon-fa-home"></i>
<el-breadcrumb-item>系统管理</el-breadcrumb-item>
<el-breadcrumb-item>角色管理</el-breadcrumb-item>
</el-breadcrumb>
<div class="el-container-content">
<h3 class="el-title">
<label>角色查询</label>
</h3>
<div class="el-search-form">
<el-form ref="roleQueryForm" :model="roleQueryForm">
<el-row>
<el-col :span="8">
<el-form-item label="角色名称" label-width="140px" prop="roleName">
<el-input v-model="roleQueryForm.roleName" :maxlength="20"></el-input>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="角色代码" label-width="140px" prop="roleCode">
<el-input v-model="roleQueryForm.roleCode" :maxlength="50"></el-input>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item class="el-align-center">
<el-button @click="resetQueryForm" icon="fa-undo">重 置</el-button>&nbsp;&nbsp;&nbsp;&nbsp;
<el-button type="primary" @click="queryRoleList(1000)" icon="fa-search">查 询</el-button>
</el-form-item>
</el-col>
</el-row>
</el-form>
</div>
<div class="el-search-list">
<el-table v-loading="loadingRoleList" element-loading-text="拼命加载中..." element-loading-class="el-loading-mask-opacity" :class="{loading: loadingRoleList}" :data="roleList" :default-sort="roleQuerySort" @sort-change="onRoleQuerySortChange" style="width:100%;" class="el-table-primary el-table-sortable" empty-text="暂无数据">
<el-table-column label="#" type="index" width="40"></el-table-column>
<el-table-column label="角色名称" prop="roleName" width="160" sortable="custom"></el-table-column>
<el-table-column label="角色代码" prop="roleCode" width="150" sortable="custom"></el-table-column>
<el-table-column label="角色类型" prop="roleType" width="120" align="center" :formatter="formatRoleType" sortable="custom"></el-table-column>
<el-table-column label="角色描述" prop="description"></el-table-column>
<el-table-column label="创建时间" prop="createTime" width="100" align="center" sortable="custom"></el-table-column>
<el-table-column label="操作" width="120" align="center">
<template scope="scope">
<el-button class="el-padding-no" type="text" size="small">查看</el-button>
<el-button class="el-padding-no" type="text" size="small">编辑</el-button>
</template>
</el-table-column>
</el-table>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="../../resources/js/polyfill.min.js"></script>
<script type="text/javascript" src="../../resources/js/vue.min.js"></script>
<script type="text/javascript" src="../../resources/js/vue.pageloading.js"></script>
<script type="text/javascript" src="../../resources/js/vue-router.min.js"></script>
<script type="text/javascript" src="../../resources/js/axios.min.js"></script>
<script type="text/javascript" src="../../resources/components/element-ui/element.min.js"></script>
<script type="text/javascript" src="../../resources/components/element-ui/element.extensional.js"></script>
<script type="text/javascript" src="../../resources/scripts/common.js"></script>
<script type="text/javascript" src="../../resources/scripts/admin/role/list.js"></script>
</body>
</html>
Loading

0 comments on commit 3ffb2f1

Please sign in to comment.