Skip to content

Commit

Permalink
system
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangmrit committed May 27, 2019
1 parent a09ebc4 commit 5783ab5
Show file tree
Hide file tree
Showing 32 changed files with 1,716 additions and 537 deletions.
21 changes: 17 additions & 4 deletions src/api/manage.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,33 @@ const api = {
role: '/role',
service: '/service',
permission: '/permission',
permissionNoPager: '/permission/no-pager',
permissionAll: '/permission/all',
orgTree: '/org/tree'
}

export default api

export function getUserList (parameter) {
return axios({
url: api.user,
url: api.user + '/list',
method: 'get',
params: parameter
})
}

export function getRoleList (parameter) {
return axios({
url: api.role,
url: api.role + '/list',
method: 'get',
params: parameter
})
}
export function getRoleAll () {
return axios({
url: api.role + '/all',
method: 'get'
})
}

export function getServiceList (parameter) {
return axios({
Expand All @@ -35,9 +41,16 @@ export function getServiceList (parameter) {
})
}

export function getPermissionAll (parameter) {
return axios({
url: api.permissionAll,
method: 'get',
params: parameter
})
}
export function getPermissions (parameter) {
return axios({
url: api.permissionNoPager,
url: api.permission + '/list',
method: 'get',
params: parameter
})
Expand Down
22 changes: 12 additions & 10 deletions src/components/Table/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,17 @@ export default {
// eslint-disable-next-line
if ((typeof result === 'object' || typeof result === 'function') && typeof result.then === 'function') {
result.then(r => {
this.localPagination = Object.assign({}, this.localPagination, {
current: r.pageNo, // 返回结果中的当前分页数
total: r.totalCount, // 返回结果中的总记录数
showSizeChanger: this.showSizeChanger,
pageSize: (pagination && pagination.pageSize) ||
this.localPagination.pageSize
})
if (this.localPagination) {
this.localPagination = Object.assign({}, this.localPagination, {
current: r.pageNo, // 返回结果中的当前分页数
total: r.totalCount, // 返回结果中的总记录数
showSizeChanger: this.showSizeChanger,
pageSize: (pagination && pagination.pageSize) ||
this.localPagination.pageSize
})
}
// 为防止删除数据后导致页面当前页面数据长度为 0 ,自动翻页到上一页
if (r.data.length === 0 && this.localPagination.current > 1) {
if (r.rows.length === 0 && this.localPagination.current > 1) {
this.localPagination.current--
this.loadData()
return
Expand All @@ -170,8 +172,8 @@ export default {
// 这里用于判断接口是否有返回 r.totalCount 或 this.showPagination = false
// 当情况满足时,表示数据不满足分页大小,关闭 table 分页功能

(!this.showPagination || !r.totalCount && this.showPagination === 'auto') && (this.localPagination.hideOnSinglePage = true)
this.localDataSource = r.data // 返回结果中的数组数据
(!this.showPagination || !r.totalCount && this.showPagination === 'auto') && (this.localPagination = false)
this.localDataSource = r.rows // 返回结果中的数组数据
this.localLoading = false
})
}
Expand Down
29 changes: 29 additions & 0 deletions src/directive/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import Vue from 'vue'
import store from '@/store'

/** 权限指令**/

Vue.directive('has', {
bind: function (el, binding) {
if (!Vue.prototype.$_has(binding.value)) {
el.parentNode && el.parentNode.removeChild(el) || (el.style.display = 'none')
}
}
})

// 权限检查方法
Vue.prototype.$_has = function (value) {
// 获取用户按钮权限
let isExist = false
const dynamicButtons = store.getters.buttons
if (dynamicButtons === undefined || dynamicButtons === null || dynamicButtons.length < 1) {
return isExist
}
dynamicButtons.forEach(button => {
if (button.resources === value) {
isExist = true
return isExist
}
})
return isExist
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
package com.zmr.wind.modules.sys.controller;

import java.util.List;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
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 com.zmr.wind.common.base.BaseController;
import com.zmr.wind.common.page.TableDataInfo;
import com.zmr.wind.core.annotation.Log;
import com.zmr.wind.core.bean.R;
import com.zmr.wind.core.enums.BusinessType;
import com.zmr.wind.modules.sys.entity.Config;
import com.zmr.wind.modules.sys.service.IConfigService;

/**
* 参数配置 信息操作处理
*
* @author zmr
* @date 2019-05-08
*/
@Controller
@RequestMapping("/sys/config")
public class ConfigController extends BaseController
{
private String prefix = "sys/config";

@Autowired
private IConfigService configService;

@RequiresPermissions("sys:config:view")
@GetMapping()
public String config()
{
return prefix + "/config";
}

/**
* 查询参数配置列表
*/
@RequiresPermissions("sys:config:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(Config config)
{
startPage();
List<Config> list = configService.findList(config);
return getDataTable(list);
}

/**
* 新增参数配置
*/
@GetMapping("/add")
public String add()
{
return prefix + "/add";
}

/**
* 新增保存参数配置
*/
@RequiresPermissions("sys:config:add")
@Log(title = "参数配置", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public R addSave(Config config)
{
return toAjax(configService.save(config));
}

/**
* 修改参数配置
*/
@GetMapping("/edit/{configId}")
public String edit(@PathVariable("configId") Integer configId, ModelMap mmap)
{
Config config = configService.findById(configId);
mmap.put("config", config);
return prefix + "/edit";
}

/**
* 修改保存参数配置
*/
@RequiresPermissions("sys:config:edit")
@Log(title = "参数配置", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public R editSave(Config config)
{
return toAjax(configService.update(config));
}

/**
* 删除参数配置
*/
@RequiresPermissions("sys:config:remove")
@Log(title = "参数配置", businessType = BusinessType.DELETE)
@PostMapping( "/remove")
@ResponseBody
public R remove(String ids)
{
return toAjax(configService.deleteByIds(ids));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
package com.zmr.wind.modules.sys.controller;

import java.util.List;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
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 com.zmr.wind.common.base.BaseController;
import com.zmr.wind.common.page.TableDataInfo;
import com.zmr.wind.core.annotation.Log;
import com.zmr.wind.core.bean.R;
import com.zmr.wind.core.enums.BusinessType;
import com.zmr.wind.modules.sys.entity.Notice;
import com.zmr.wind.modules.sys.service.INoticeService;

/**
* 通知公告 信息操作处理
*
* @author zmr
* @date 2019-05-08
*/
@Controller
@RequestMapping("/sys/notice")
public class NoticeController extends BaseController
{
private String prefix = "sys/notice";

@Autowired
private INoticeService noticeService;

@RequiresPermissions("sys:notice:view")
@GetMapping()
public String notice()
{
return prefix + "/notice";
}

/**
* 查询通知公告列表
*/
@RequiresPermissions("sys:notice:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(Notice notice)
{
startPage();
List<Notice> list = noticeService.findList(notice);
return getDataTable(list);
}

/**
* 新增通知公告
*/
@GetMapping("/add")
public String add()
{
return prefix + "/add";
}

/**
* 新增保存通知公告
*/
@RequiresPermissions("sys:notice:add")
@Log(title = "通知公告", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public R addSave(Notice notice)
{
return toAjax(noticeService.save(notice));
}

/**
* 修改通知公告
*/
@GetMapping("/edit/{noticeId}")
public String edit(@PathVariable("noticeId") Integer noticeId, ModelMap mmap)
{
Notice notice = noticeService.findById(noticeId);
mmap.put("notice", notice);
return prefix + "/edit";
}

/**
* 修改保存通知公告
*/
@RequiresPermissions("sys:notice:edit")
@Log(title = "通知公告", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public R editSave(Notice notice)
{
return toAjax(noticeService.update(notice));
}

/**
* 删除通知公告
*/
@RequiresPermissions("sys:notice:remove")
@Log(title = "通知公告", businessType = BusinessType.DELETE)
@PostMapping( "/remove")
@ResponseBody
public R remove(String ids)
{
return toAjax(noticeService.deleteByIds(ids));
}

}
Loading

0 comments on commit 5783ab5

Please sign in to comment.