修改角色 2021年11月9日18:23:08
parent
812126c4de
commit
2bf3d696f7
|
|
@ -0,0 +1,145 @@
|
|||
package com.zhangmeng.admin.manager.controller;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.zhangmeng.admin.manager.service.RoleService;
|
||||
import com.zhangmeng.api.service.admin_manager.RoleControllerApi;
|
||||
import com.zhangmeng.model.base.baseController.BaseController;
|
||||
import com.zhangmeng.model.base.baseUtil.CommonUtil;
|
||||
import com.zhangmeng.model.dto.query.QueryParams;
|
||||
import com.zhangmeng.model.entity.Role;
|
||||
import com.zhangmeng.model.vo.Result;
|
||||
import com.zhangmeng.model.vo.ResultTree;
|
||||
import com.zhangmeng.model.vo.StatusCode;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
import tk.mybatis.mapper.entity.Condition;
|
||||
import tk.mybatis.mapper.entity.Example;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/role")
|
||||
public class RoleController extends BaseController implements RoleControllerApi {
|
||||
|
||||
@Autowired
|
||||
private RoleService roleService;
|
||||
|
||||
@Override
|
||||
@PostMapping("/save")
|
||||
public Result save(@RequestParam @RequestBody Map<String, Object> map) {
|
||||
String roleId = CommonUtil.map_get_value(map, "roleId");
|
||||
boolean flag = false;
|
||||
Role role = null;
|
||||
if (roleId == null || roleId.equals("")) {
|
||||
flag = true;
|
||||
role = new Role();
|
||||
role.setAddTime(new Date());
|
||||
role.setUpdateTime(new Date());
|
||||
role.setDeleteStatus(false);
|
||||
} else {
|
||||
role = this.roleService.findById(Long.parseLong(roleId));
|
||||
}
|
||||
|
||||
String type = CommonUtil.map_get_value(map, "type");
|
||||
if (CommonUtil.isNotNull(type)) {
|
||||
role.setType(CommonUtil.getEnum(type, Role.Type.class));
|
||||
}
|
||||
String roleName = CommonUtil.map_get_value(map, "roleName");
|
||||
if (CommonUtil.isNotNull(roleName)) {
|
||||
role.setRoleName(roleName);
|
||||
}
|
||||
String status = CommonUtil.map_get_value(map, "status");
|
||||
if (CommonUtil.isNotNull(status)) {
|
||||
role.setStatus(CommonUtil.getEnum(status, Role.Status.class));
|
||||
}
|
||||
|
||||
String description = CommonUtil.map_get_value(map, "description");
|
||||
if (CommonUtil.isNotNull(description)) {
|
||||
role.setDescription(description);
|
||||
}
|
||||
|
||||
switch (role.getType()){
|
||||
case Super_Administrator:
|
||||
role.setRoleCode(Role.Type.Super_Administrator.toString());
|
||||
break;
|
||||
case Administrator:
|
||||
role.setRoleCode(Role.Type.Administrator.toString());
|
||||
break;
|
||||
case User:
|
||||
role.setRoleCode(Role.Type.User.toString());
|
||||
break;
|
||||
}
|
||||
String message = null;
|
||||
if (flag) {
|
||||
message = "添加成功";
|
||||
this.roleService.save(role);
|
||||
} else {
|
||||
message = "修改成功";
|
||||
this.roleService.update(role);
|
||||
}
|
||||
return this.success(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping("/list")
|
||||
public Result list(Integer pageNum, Integer pageSize,String roleName,String roleCode) {
|
||||
Condition condition = new Condition(Role.class);
|
||||
Example.Criteria criteria = condition.createCriteria();
|
||||
if (CommonUtil.isNotNull(roleName)){
|
||||
criteria.andEqualTo("roleName",roleName);
|
||||
}
|
||||
|
||||
if (CommonUtil.isNotNull(roleCode)){
|
||||
criteria.andEqualTo("roleCode",roleCode);
|
||||
}
|
||||
PageInfo<Role> pageInfo = this.roleService.findByCondition(new QueryParams(pageNum, pageSize, condition),true);
|
||||
return new Result(true, StatusCode.OK, "重新成功", pageInfo.getTotal(),pageInfo.getList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Describe: 获取角色权限
|
||||
* Param RoleId
|
||||
* Return ResuTree
|
||||
*/
|
||||
@Override
|
||||
@GetMapping("/getRolePower")
|
||||
public ResultTree getRolePower(String roleId) {
|
||||
return dataTree(this.roleService.getRolePermission(roleId));
|
||||
}
|
||||
|
||||
@Override
|
||||
@PostMapping("/delete")
|
||||
public Result delete(String roleId) {
|
||||
if (CommonUtil.isNotNull(roleId) && CommonUtil.isNumeric_ASCII(roleId)) {
|
||||
this.roleService.deleteById(Long.parseLong(roleId));
|
||||
}
|
||||
return this.success("删除成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
@PostMapping("/batchRemove")
|
||||
public Result batchRemove(String ids){
|
||||
if (CommonUtil.isNotNull(ids)){
|
||||
this.roleService.deleteByIds(CommonUtil.firstLastComma(ids));
|
||||
}
|
||||
return this.success("批量删除成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
@PostMapping("/saveRolePower")
|
||||
public Result saveRolePower(@RequestParam @RequestBody String roleId ,@RequestParam @RequestBody String powerIds){
|
||||
if (CommonUtil.isNull(roleId)){
|
||||
return this.failure("roleId不能为空");
|
||||
}
|
||||
if (CommonUtil.isNull(powerIds)){
|
||||
return this.failure("授权的不能为空");
|
||||
}
|
||||
return this.roleService.saveRolePower(Long.parseLong(roleId),powerIds);
|
||||
}
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@ package com.zhangmeng.admin.manager.controller;
|
|||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.zhangmeng.admin.manager.feign.ArticleFeign;
|
||||
import com.zhangmeng.admin.manager.service.PermissionService;
|
||||
import com.zhangmeng.admin.manager.service.RoleService;
|
||||
import com.zhangmeng.admin.manager.service.SysLogService;
|
||||
import com.zhangmeng.admin.manager.service.UserService;
|
||||
import com.zhangmeng.admin.manager.utils.UserUtil;
|
||||
|
|
@ -10,10 +11,7 @@ import com.zhangmeng.model.base.baseController.BaseController;
|
|||
import com.zhangmeng.model.base.baseUtil.CommonUtil;
|
||||
import com.zhangmeng.model.dto.Menu;
|
||||
import com.zhangmeng.model.dto.query.QueryParams;
|
||||
import com.zhangmeng.model.entity.Article;
|
||||
import com.zhangmeng.model.entity.Permission;
|
||||
import com.zhangmeng.model.entity.SysLog;
|
||||
import com.zhangmeng.model.entity.User;
|
||||
import com.zhangmeng.model.entity.*;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.bouncycastle.math.raw.Mod;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -51,6 +49,9 @@ public class UrlRequestController extends BaseController {
|
|||
@Autowired
|
||||
private ArticleFeign articleFeign;
|
||||
|
||||
@Autowired
|
||||
private RoleService roleService;
|
||||
|
||||
//跳转首页
|
||||
@GetMapping({"/login","/"})
|
||||
public ModelAndView login (){
|
||||
|
|
@ -128,4 +129,84 @@ public class UrlRequestController extends BaseController {
|
|||
model.addAttribute("sysLogs",list);
|
||||
return jumpPage("admin/home/home");
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户列表
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/user/index")
|
||||
public ModelAndView user_index(Model model){
|
||||
return this.jumpPage("admin/user/list");
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户添加
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/user/add")
|
||||
public ModelAndView user_add(Model model){
|
||||
return this.jumpPage("admin/user/add");
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户列表
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/user/edit")
|
||||
public ModelAndView user_edit(Model model,String userId){
|
||||
if (userId != null && !userId.equals("")) {
|
||||
User user = this.userService.findById(Long.parseLong(userId));
|
||||
model.addAttribute("user", user);
|
||||
}
|
||||
return this.jumpPage("admin/user/edit");
|
||||
}
|
||||
|
||||
/**
|
||||
* 角色列表
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/role/index")
|
||||
public ModelAndView index() {
|
||||
return this.jumpPage("admin/role/list");
|
||||
}
|
||||
|
||||
/**
|
||||
* 角色添加
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/role/add")
|
||||
public ModelAndView add(Model model) {
|
||||
model.addAttribute("roleStatusList", Role.Status.enumListMap());
|
||||
return this.jumpPage("admin/role/add");
|
||||
}
|
||||
|
||||
@GetMapping("/role/edit")
|
||||
public ModelAndView edit(Model model, String roleId) {
|
||||
if (roleId != null && !roleId.equals("")) {
|
||||
Role role = this.roleService.findById(Long.parseLong(roleId));
|
||||
model.addAttribute("roleTypeList", Role.Type.enumListMap());
|
||||
model.addAttribute("role", role);
|
||||
}
|
||||
return this.jumpPage("admin/role/edit");
|
||||
}
|
||||
|
||||
/**
|
||||
* 授权
|
||||
* @param model
|
||||
* @param roleId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/role/authorize")
|
||||
public ModelAndView authorize(Model model, String roleId) {
|
||||
if (roleId != null && !roleId.equals("")) {
|
||||
Role role = this.roleService.findById(Long.parseLong(roleId));
|
||||
model.addAttribute("roleTypeList", Role.Type.enumListMap());
|
||||
model.addAttribute("role", role);
|
||||
}
|
||||
return this.jumpPage("admin/role/authorize");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ package com.zhangmeng.admin.manager.service;
|
|||
import com.zhangmeng.model.base.baseService.BaseService;
|
||||
import com.zhangmeng.model.entity.Permission;
|
||||
import com.zhangmeng.model.entity.Role;
|
||||
import com.zhangmeng.model.vo.Result;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -16,4 +17,6 @@ import java.util.List;
|
|||
public interface RoleService extends BaseService<Role> {
|
||||
|
||||
List<Permission> getRolePermission(String roleId);
|
||||
|
||||
Result saveRolePower(long parseLong, String powerIds);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,12 @@ import com.zhangmeng.model.base.baseUtil.CommonUtil;
|
|||
import com.zhangmeng.model.entity.Permission;
|
||||
import com.zhangmeng.model.entity.Role;
|
||||
import com.zhangmeng.model.entity.RolePermission;
|
||||
import com.zhangmeng.model.vo.Result;
|
||||
import com.zhangmeng.model.vo.StatusCode;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import tk.mybatis.mapper.entity.Condition;
|
||||
import tk.mybatis.mapper.entity.Example;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
@ -55,4 +59,52 @@ public class RoleServiceImpl extends AbstractBaseServiceImpl<Role> implements Ro
|
|||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result saveRolePower(long roleId, String powerIds) {
|
||||
Role role = this.findById(roleId);
|
||||
if (role != null ){
|
||||
getByRoleId(roleId);
|
||||
String ids = CommonUtil.firstLastComma(powerIds);
|
||||
String[] strings = ids.split(",");
|
||||
for (String id : strings) {
|
||||
is_true(id,roleId);
|
||||
}
|
||||
}
|
||||
return new Result(true, StatusCode.OK,"授权成功");
|
||||
}
|
||||
|
||||
//查询原有的
|
||||
private void getByRoleId(Long roleId){
|
||||
List<RolePermission> rolePermissions = this.rolePermissionService.findByRoleId(roleId);
|
||||
if (rolePermissions.size() > 0 ){
|
||||
for (RolePermission rolePermission : rolePermissions) {
|
||||
if (!rolePermission.getDeleteStatus()){
|
||||
rolePermission.setDeleteStatus(true);
|
||||
this.rolePermissionService.update(rolePermission);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//判断是否存在
|
||||
private void is_true (String id,Long roleId){
|
||||
Condition condition = new Condition(RolePermission.class);
|
||||
Example.Criteria criteria = condition.createCriteria();
|
||||
criteria.andEqualTo("role_id",roleId);
|
||||
criteria.andEqualTo("permission_id",Long.parseLong(id));
|
||||
List<RolePermission> rolePermissions = this.rolePermissionService.findByCondition(condition);
|
||||
if (rolePermissions.size() > 0 ){
|
||||
RolePermission rolePermission = rolePermissions.get(0);
|
||||
if (rolePermission.getDeleteStatus()){
|
||||
rolePermission.setDeleteStatus(false);
|
||||
this.rolePermissionService.update(rolePermission);
|
||||
}
|
||||
}else {
|
||||
RolePermission rolePermission = new RolePermission();
|
||||
rolePermission.setPermission_id(Long.parseLong(id));
|
||||
rolePermission.setRole_id(roleId);
|
||||
this.rolePermissionService.save(rolePermission);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,16 +3,45 @@ var gate_way_url = "http://localhost:9000";
|
|||
//后台管理微服务
|
||||
var admin_manager_url = "mystyle-cloud-admin-manager";
|
||||
//授权微服务
|
||||
var user_oauth_url= "mystyle-cloud-oauth";
|
||||
var user_oauth_url = "mystyle-cloud-oauth";
|
||||
//验证码
|
||||
var v_code = gate_way_url + "/" + admin_manager_url + "/verificationCode/generate";
|
||||
var access_token = localStorage.getItem("access_token");
|
||||
var access_token_url = "?access_token=" + access_token;
|
||||
//获取当前用户
|
||||
var current_user_url = gate_way_url + "/" + admin_manager_url + "/user/current?access_token=" + access_token;
|
||||
var current_user_url = gate_way_url + "/" + admin_manager_url + "/user/current" + access_token_url;
|
||||
//登录地址
|
||||
var login_url = gate_way_url + "/" + user_oauth_url + "/user/login";
|
||||
//首页
|
||||
var admin_manager_index_url= gate_way_url + "/" + admin_manager_url + "/admin/index";
|
||||
var admin_manager_index_url = gate_way_url + "/" + admin_manager_url + "/admin/index";
|
||||
//用户列表
|
||||
var user_list_url = gate_way_url + "/" + admin_manager_url + "/user/list" + access_token_url;
|
||||
//用户添加
|
||||
var user_add_url = gate_way_url + "/" + admin_manager_url + "/user/add" + access_token_url;
|
||||
//用户保存
|
||||
var user_save_url = gate_way_url + "/" + admin_manager_url + "/user/save";
|
||||
//用户修改
|
||||
var user_edit_url = gate_way_url + "/" + admin_manager_url + "/user/edit" + access_token_url;
|
||||
//用户删除
|
||||
var user_del_url = gate_way_url + "/" + admin_manager_url + "/user/delete";
|
||||
//用户批量删除
|
||||
var user_batchRemove_url = gate_way_url + "/" + admin_manager_url + "/user/batchRemove";
|
||||
//-------------------------------------------------------------------------------------------------------------------------
|
||||
//角色列表
|
||||
var role_list_url = gate_way_url + "/" + admin_manager_url + "/role/list" + access_token_url;
|
||||
//角色添加
|
||||
var role_add_url = gate_way_url + "/" + admin_manager_url + "/role/add" + access_token_url;
|
||||
//角色编辑
|
||||
var role_edit_url = gate_way_url + "/" + admin_manager_url + "/role/edit" + access_token_url;
|
||||
//角色保存
|
||||
var role_save_url = gate_way_url + "/" + admin_manager_url + "/role/save";
|
||||
//角色授权
|
||||
var role_authorize_url = gate_way_url + "/" + admin_manager_url + "/role/authorize" + access_token_url;
|
||||
//获取授权
|
||||
var role_getRolePower_url = gate_way_url + "/" + admin_manager_url + "/role/getRolePower" + access_token_url;
|
||||
//保存角色授权
|
||||
var role_saveRolePower_url = gate_way_url + "/" + admin_manager_url + "/role/saveRolePower";
|
||||
|
||||
//页面跳转
|
||||
function postToPage(url, token) {
|
||||
var f = document.createElement('form');
|
||||
|
|
|
|||
|
|
@ -210,13 +210,14 @@ layui.define(['table', 'jquery', 'element'], function(exports) {
|
|||
target = "target='_blank'";
|
||||
className = "";
|
||||
}
|
||||
|
||||
if (item.type == 0) {
|
||||
// 创 建 目 录 结 构
|
||||
content += '<a href="javascript:;" menu-type="' + item.type + '" menu-id="' + item.id + '" href="' + href +
|
||||
'" ' + target + '><i class="' + item.icon + '"></i><span>' + item.title +
|
||||
'</span></a>';
|
||||
} else if (item.type == 1) {
|
||||
content += '<a class="' + className + '" menu-type="' + item.type + '" menu-url="' + item.href + '" menu-id="' +
|
||||
content += '<a class="' + className + '" menu-type="' + item.type + '" menu-url="/' + admin_manager_url +item.href + '" menu-id="' +
|
||||
item.id +
|
||||
'" menu-title="' + item.title + '" href="' + href + '" ' + target + '><i class="' + item.icon +
|
||||
'"></i><span>' + item.title + '</span></a>';
|
||||
|
|
@ -342,7 +343,7 @@ layui.define(['table', 'jquery', 'element'], function(exports) {
|
|||
'"><i class="' + note.icon + '"></i><span>' + note.title + '</span></a>';
|
||||
} else if (note.type == 1) {
|
||||
// 创 建 菜 单 结 构
|
||||
content += '<a ' + target + ' class="' + className + '" menu-type="' + note.type + '" menu-url="' + note.href +
|
||||
content += '<a ' + target + ' class="' + className + '" menu-type="' + note.type + '" menu-url="/'+admin_manager_url + note.href +
|
||||
'" menu-id="' + note.id + '" menu-title="' + note.title + '" menu-icon="' + note.icon + '" href="' + href +
|
||||
'" ><i class="' + note.icon + '"></i><span>' + note.title + '</span></a>';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ logo:
|
|||
## 网站名称
|
||||
title: "MY Style"
|
||||
## 网站图标
|
||||
image: "/system/admin/images/logo.png"
|
||||
image: "/mystyle-cloud-admin-manager/system/admin/images/logo.png"
|
||||
## 菜单配置
|
||||
menu:
|
||||
## 菜单数据来源
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>角色添加</title>
|
||||
<link rel="stylesheet" href="${springMacroRequestContext.contextPath}/system/component/pear/css/pear.css" />
|
||||
<link rel="stylesheet" href="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/component/pear/css/pear.css" />
|
||||
</head>
|
||||
<body>
|
||||
<form class="layui-form" action="">
|
||||
|
|
@ -62,20 +62,19 @@
|
|||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<script src="${springMacroRequestContext.contextPath}/system/component/layui/layui.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/system/component/pear/pear.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/component/layui/layui.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/component/pear/pear.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/admin/js/mystyle-admin.js"></script>
|
||||
<script>
|
||||
layui.use(['form','jquery'],function(){
|
||||
let form = layui.form;
|
||||
let $ = layui.jquery;
|
||||
|
||||
form.on('submit(role-save)', function(data){
|
||||
|
||||
var obj = data.field;
|
||||
obj['token'] = localStorage.getItem("token");
|
||||
|
||||
obj['access_token'] = access_token;
|
||||
$.ajax({
|
||||
url:'/role/save',
|
||||
url:role_save_url,
|
||||
data:obj,
|
||||
type:'post',
|
||||
success:function(result){
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>角色授权</title>
|
||||
<link rel="stylesheet" href="${springMacroRequestContext.contextPath}/system/component/pear/css/pear.css" />
|
||||
<link rel="stylesheet" href="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/component/pear/css/pear.css" />
|
||||
</head>
|
||||
<body>
|
||||
<form class="layui-form" action="">
|
||||
|
|
@ -27,21 +27,18 @@
|
|||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<script src="${springMacroRequestContext.contextPath}/system/component/layui/layui.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/system/component/pear/pear.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/component/layui/layui.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/component/pear/pear.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/admin/js/mystyle-admin.js"></script>
|
||||
<script>
|
||||
layui.use(['dtree', 'form', 'jquery'], function () {
|
||||
let dtree = layui.dtree;
|
||||
let form = layui.form;
|
||||
let $ = layui.jquery;
|
||||
let token = localStorage.getItem("token");
|
||||
dtree.render({
|
||||
elem: "#role-power",
|
||||
method: "get",
|
||||
url: "/role/getRolePower?roleId=${role.id}",
|
||||
headers:{
|
||||
token:token
|
||||
},
|
||||
url: role_getRolePower_url + '&roleId=${role.id}',
|
||||
dataFormat: "list",
|
||||
checkbar: true,
|
||||
skin: "layui",
|
||||
|
|
@ -60,12 +57,12 @@
|
|||
ids = ids.substr(0, ids.length - 1);
|
||||
data.field.roleId = '${role.id}';
|
||||
data.field.powerIds = ids;
|
||||
|
||||
data.field.access_token = access_token;
|
||||
$.ajax({
|
||||
url: '/role/saveRolePower',
|
||||
url: role_saveRolePower_url,
|
||||
data: data.field,
|
||||
dataType: 'json',
|
||||
type: 'put',
|
||||
type: 'post',
|
||||
success: function (result) {
|
||||
if (result.flag) {
|
||||
layer.msg(result.message, {icon: 1, time: 1000}, function () {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>角色修改</title>
|
||||
<link rel="stylesheet" href="${springMacroRequestContext.contextPath}/system/component/pear/css/pear.css"/>
|
||||
<link rel="stylesheet" href="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/component/pear/css/pear.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<form class="layui-form" action="">
|
||||
|
|
@ -28,18 +28,15 @@
|
|||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">状态</label>
|
||||
<div class="layui-input-block">
|
||||
<#if role.status??>
|
||||
<#if role.status == 'Enable'>
|
||||
<input type="radio" name="status" value="0" title="开启" checked>
|
||||
<input type="radio" name="status" value="1" title="关闭">
|
||||
<#else >
|
||||
<input type="radio" name="status" value="0" title="开启">
|
||||
<input type="radio" name="status" value="1" title="关闭" checked>
|
||||
</#if>
|
||||
<#else >
|
||||
<input type="radio" name="status" value="0" title="开启" checked>
|
||||
<input type="radio" name="status" value="1" title="关闭">
|
||||
</#if>
|
||||
|
||||
<#if role.status == 'Enable'>
|
||||
<input type="radio" name="status" value="Enable" title="开启" checked>
|
||||
<input type="radio" name="status" value="DisEnable" title="关闭" >
|
||||
<#else >
|
||||
<input type="radio" name="status" value="Enable" title="开启" >
|
||||
<input type="radio" name="status" value="DisEnable" title="关闭" checked>
|
||||
</#if>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -63,7 +60,7 @@
|
|||
</div>
|
||||
<div class="bottom">
|
||||
<div class="button-container">
|
||||
<button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit="" lay-filter="user-save">
|
||||
<button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit="" lay-filter="role-edit">
|
||||
<i class="layui-icon layui-icon-ok"></i>
|
||||
提交
|
||||
</button>
|
||||
|
|
@ -75,27 +72,25 @@
|
|||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<script src="${springMacroRequestContext.contextPath}/system/component/layui/layui.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/system/component/pear/pear.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/component/layui/layui.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/component/pear/pear.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/admin/js/mystyle-admin.js"></script>
|
||||
<script>
|
||||
layui.use(['form', 'jquery'], function () {
|
||||
let form = layui.form;
|
||||
let $ = layui.jquery;
|
||||
|
||||
form.on('submit(user-save)', function (data) {
|
||||
|
||||
form.on('submit(role-edit)', function (data) {
|
||||
var obj = data.field;
|
||||
obj['token'] = localStorage.getItem("token");
|
||||
|
||||
obj['access_token'] = access_token;
|
||||
$.ajax({
|
||||
url: '/role/save',
|
||||
url: role_save_url,
|
||||
data: obj,
|
||||
type: 'post',
|
||||
success: function (result) {
|
||||
if (result.flag) {
|
||||
layer.msg(result.message, {icon: 1, time: 1000}, function () {
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
|
||||
parent.layui.table.reload("user-table");
|
||||
parent.layui.table.reload("role-table");
|
||||
});
|
||||
} else {
|
||||
layer.msg(result.msg, {icon: 2, time: 1000});
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>角色管理</title>
|
||||
<link href="${springMacroRequestContext.contextPath}/system/component/pear/css/pear.css" rel="stylesheet"/>
|
||||
<link href="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/component/pear/css/pear.css" rel="stylesheet"/>
|
||||
</head>
|
||||
<body class="pear-container">
|
||||
<div class="layui-card">
|
||||
|
|
@ -88,14 +88,14 @@
|
|||
checked="{{ d.id == 10003 ? 'true' : 'false' }}">
|
||||
</script>
|
||||
|
||||
<script src="${springMacroRequestContext.contextPath}/system/component/layui/layui.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/system/component/pear/pear.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/component/layui/layui.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/component/pear/pear.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/admin/js/mystyle-admin.js"></script>
|
||||
<script>
|
||||
layui.use(['table', 'form', 'jquery'], function () {
|
||||
let table = layui.table;
|
||||
let form = layui.form;
|
||||
let $ = layui.jquery;
|
||||
let token = localStorage.getItem("token");
|
||||
let cols = [
|
||||
[
|
||||
{type: 'checkbox'},
|
||||
|
|
@ -139,8 +139,7 @@
|
|||
|
||||
table.render({
|
||||
elem: '#role-table',
|
||||
url: '/role/list',
|
||||
headers: {token: localStorage.getItem("token")},
|
||||
url: role_list_url,
|
||||
page: true,
|
||||
cols: cols,
|
||||
skin: 'line',
|
||||
|
|
@ -207,7 +206,7 @@
|
|||
title: '新增',
|
||||
shade: 0.1,
|
||||
area: ['900px', '600px'],
|
||||
content: '/role/add?token=' + token
|
||||
content: role_add_url
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -217,7 +216,7 @@
|
|||
title: '授权',
|
||||
shade: 0.1,
|
||||
area: ['900px', '600px'],
|
||||
content: '/role/authorize?roleId=' + obj.data.id + '&token=' + token
|
||||
content: role_authorize_url + '&roleId=' + obj.data.id
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -227,7 +226,7 @@
|
|||
title: '修改',
|
||||
shade: 0.1,
|
||||
area: ['900px', '600px'],
|
||||
content: '/role/edit?roleId=' + obj.data.id + '&token=' + token
|
||||
content: role_edit_url + '&roleId=' + obj.data.id
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -239,7 +238,7 @@
|
|||
url: "/role/delete",
|
||||
data: {
|
||||
roleId: obj.data.id,
|
||||
token:token
|
||||
access_token:access_token
|
||||
},
|
||||
type: 'post',
|
||||
success: function (result) {
|
||||
|
|
@ -274,7 +273,7 @@
|
|||
url: "/role/batchRemove",
|
||||
data: {
|
||||
ids:ids,
|
||||
token:token
|
||||
access_token:access_token
|
||||
},
|
||||
type: 'post',
|
||||
success: function (result) {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>用户添加</title>
|
||||
<link rel="stylesheet" href="${springMacroRequestContext.contextPath}/system/component/pear/css/pear.css" />
|
||||
<link rel="stylesheet" href="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/component/pear/css/pear.css" />
|
||||
</head>
|
||||
<body>
|
||||
<form class="layui-form" action="">
|
||||
|
|
@ -81,20 +81,18 @@
|
|||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<script src="${springMacroRequestContext.contextPath}/system/component/layui/layui.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/system/component/pear/pear.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/component/layui/layui.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/component/pear/pear.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/admin/js/mystyle-admin.js"></script>
|
||||
<script>
|
||||
layui.use(['form','jquery'],function(){
|
||||
let form = layui.form;
|
||||
let $ = layui.jquery;
|
||||
|
||||
form.on('submit(user-save)', function(data){
|
||||
|
||||
var obj = data.field;
|
||||
obj['token'] = localStorage.getItem("token");
|
||||
|
||||
obj['access_token'] = access_token;
|
||||
$.ajax({
|
||||
url:'/user/save',
|
||||
url:user_save_url,
|
||||
data:obj,
|
||||
type:'post',
|
||||
success:function(result){
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Title</title>
|
||||
<link rel="stylesheet" href="${springMacroRequestContext.contextPath}/system/component/pear/css/pear.css"/>
|
||||
<link rel="stylesheet" href="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/component/pear/css/pear.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<form class="layui-form" action="">
|
||||
|
|
@ -75,17 +75,18 @@
|
|||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<script src="${springMacroRequestContext.contextPath}/system/component/layui/layui.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/system/component/pear/pear.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/component/layui/layui.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/component/pear/pear.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/admin/js/mystyle-admin.js"></script>
|
||||
<script>
|
||||
layui.use(['form','jquery'],function(){
|
||||
let form = layui.form;
|
||||
let $ = layui.jquery;
|
||||
form.on('submit(user-save)', function(data){
|
||||
var obj = data.field;
|
||||
obj['token'] = localStorage.getItem("token");
|
||||
obj['access_token'] = access_token;
|
||||
$.ajax({
|
||||
url:'/user/save',
|
||||
url:user_save_url,
|
||||
data:obj,
|
||||
type:'post',
|
||||
success:function(result){
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>用户管理</title>
|
||||
<link rel="stylesheet" href="${springMacroRequestContext.contextPath}/system/component/pear/css/pear.css" />
|
||||
<link rel="stylesheet" href="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/component/pear/css/pear.css" />
|
||||
</head>
|
||||
<body class="pear-container">
|
||||
<div class="layui-card">
|
||||
|
|
@ -85,17 +85,15 @@
|
|||
{{layui.util.toDateString(d.addTime, 'yyyy-MM-dd HH:mm:ss')}}
|
||||
</script>
|
||||
|
||||
<script src="${springMacroRequestContext.contextPath}/system/component/layui/layui.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/system/component/pear/pear.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/component/layui/layui.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/component/pear/pear.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/admin/js/mystyle-admin.js"></script>
|
||||
<script>
|
||||
layui.use(['table', 'form', 'jquery','common'], function() {
|
||||
let table = layui.table;
|
||||
let form = layui.form;
|
||||
let $ = layui.jquery;
|
||||
let common = layui.common;
|
||||
|
||||
let token = localStorage.getItem("token");
|
||||
|
||||
let cols = [
|
||||
[{
|
||||
type: 'checkbox'
|
||||
|
|
@ -151,8 +149,7 @@
|
|||
|
||||
table.render({
|
||||
elem: '#user-table',
|
||||
url: '/user/list?token='+ localStorage.getItem("token"),
|
||||
headers: {token: localStorage.getItem("token")},
|
||||
url: user_list_url,
|
||||
page: true,
|
||||
cols: cols,
|
||||
skin: 'line',
|
||||
|
|
@ -218,7 +215,7 @@
|
|||
title: '新增',
|
||||
shade: 0.1,
|
||||
area: [common.isModile()?'100%':'900px', common.isModile()?'100%':'600px'],
|
||||
content: '/user/add?token=' + token
|
||||
content: user_add_url
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -228,7 +225,7 @@
|
|||
title: '修改',
|
||||
shade: 0.1,
|
||||
area: ['900px', '600px'],
|
||||
content: '/user/edit?userId='+obj.data.id+'&token=' + localStorage.getItem("token")
|
||||
content: user_edit_url + "&userId="+ obj.data.id
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -241,10 +238,10 @@
|
|||
layer.close(index);
|
||||
let loading = layer.load();
|
||||
$.ajax({
|
||||
url: "/user/delete",
|
||||
url: user_del_url,
|
||||
data:{
|
||||
userId:obj.data['id'],
|
||||
token:token
|
||||
access_token:access_token
|
||||
},
|
||||
type: 'post',
|
||||
success: function(result) {
|
||||
|
|
@ -268,9 +265,7 @@
|
|||
};
|
||||
|
||||
window.batchRemove = function(obj) {
|
||||
|
||||
var checkIds = common.checkField(obj,'id');
|
||||
|
||||
if (checkIds === "") {
|
||||
layer.msg("未选中数据", {
|
||||
icon: 3,
|
||||
|
|
@ -278,7 +273,6 @@
|
|||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
layer.confirm('确定要删除这些用户', {
|
||||
icon: 3,
|
||||
title: '提示'
|
||||
|
|
@ -286,10 +280,10 @@
|
|||
layer.close(index);
|
||||
let loading = layer.load();
|
||||
$.ajax({
|
||||
url: "/user/batchRemove",
|
||||
url: user_batchRemove_url,
|
||||
data: {
|
||||
ids:checkIds,
|
||||
token:token
|
||||
access_token:access_token
|
||||
},
|
||||
type: 'post',
|
||||
success: function(result) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
package com.zhangmeng.api.service.admin_manager;
|
||||
|
||||
import com.zhangmeng.model.vo.Result;
|
||||
import com.zhangmeng.model.vo.ResultTree;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Api(tags = "角色管理")
|
||||
public interface RoleControllerApi {
|
||||
|
||||
@ApiOperation("角色保存")
|
||||
public Result save(Map<String, Object> map);
|
||||
|
||||
@ApiOperation("角色列表")
|
||||
public Result list(Integer pageNum, Integer pageSize,String roleName,String roleCode);
|
||||
|
||||
@ApiOperation(value = "获取角色权限数据")
|
||||
public ResultTree getRolePower(String roleId);
|
||||
|
||||
@ApiOperation("角色删除")
|
||||
public Result delete(String roleId);
|
||||
|
||||
@ApiOperation("批量删除")
|
||||
public Result batchRemove(String ids);
|
||||
|
||||
@ApiOperation("保存用户授权")
|
||||
public Result saveRolePower(String roleId ,String powerIds);
|
||||
}
|
||||
Loading…
Reference in New Issue