Browse Source

修复系统管理部分bug

test
smallchill 6 years ago
parent
commit
25ce074e7c
  1. 3
      blade-service/blade-system/src/main/java/org/springblade/system/mapper/RoleMapper.java
  2. 7
      blade-service/blade-system/src/main/java/org/springblade/system/mapper/RoleMapper.xml
  3. 11
      blade-service/blade-system/src/main/java/org/springblade/system/service/impl/RoleServiceImpl.java
  4. 7
      blade-service/blade-user/src/main/java/org/springblade/system/user/controller/UserController.java
  5. 2
      blade-service/blade-user/src/main/java/org/springblade/system/user/mapper/UserMapper.xml
  6. 7
      blade-service/blade-user/src/main/java/org/springblade/system/user/service/IUserService.java
  7. 13
      blade-service/blade-user/src/main/java/org/springblade/system/user/service/impl/UserServiceImpl.java
  8. 68
      doc/sql/bladex-mysql-oauth2-client-upadte.sql
  9. 2
      doc/sql/bladex-saber-mysql.sql
  10. 2
      doc/sql/bladex-sword-mysql.sql

3
blade-service/blade-system/src/main/java/org/springblade/system/mapper/RoleMapper.java

@ -43,8 +43,9 @@ public interface RoleMapper extends BaseMapper<Role> {
* 获取树形节点
*
* @param tenantCode
* @param excludeRole
* @return
*/
List<RoleVO> tree(String tenantCode);
List<RoleVO> tree(String tenantCode, String excludeRole);
}

7
blade-service/blade-system/src/main/java/org/springblade/system/mapper/RoleMapper.xml

@ -32,8 +32,11 @@
<select id="tree" resultMap="treeNodeResultMap">
select id, parent_id, role_name as title, id as 'value', id as 'key' from blade_role where is_deleted = 0
<if test="_parameter!=null">
and tenant_code = #{_parameter}
<if test="param1!=null">
and tenant_code = #{param1}
</if>
<if test="param2!=null">
and role_alias &lt;&gt; #{param2}
</if>
</select>

11
blade-service/blade-system/src/main/java/org/springblade/system/service/impl/RoleServiceImpl.java

@ -20,7 +20,11 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.AllArgsConstructor;
import org.springblade.core.secure.utils.SecureUtil;
import org.springblade.core.tool.constant.RoleConstant;
import org.springblade.core.tool.node.ForestNodeMerger;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.system.entity.Role;
import org.springblade.system.entity.RoleMenu;
import org.springblade.system.mapper.RoleMapper;
@ -53,7 +57,12 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IR
@Override
public List<RoleVO> tree(String tenantCode) {
return ForestNodeMerger.merge(baseMapper.tree(tenantCode));
String userRole = SecureUtil.getUserRole();
String excludeRole = null;
if (!CollectionUtil.contains(Func.toStrArray(userRole), RoleConstant.ADMIN)) {
excludeRole = RoleConstant.ADMIN;
}
return ForestNodeMerger.merge(baseMapper.tree(tenantCode, excludeRole));
}
@Override

7
blade-service/blade-user/src/main/java/org/springblade/system/user/controller/UserController.java

@ -29,7 +29,6 @@ import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.constant.BladeConstant;
import org.springblade.core.tool.utils.DigestUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.system.feign.IDictClient;
import org.springblade.system.user.entity.User;
@ -89,10 +88,7 @@ public class UserController {
@PostMapping("/submit")
@ApiOperation(value = "新增或修改", notes = "传入User", position = 3)
public R submit(@Valid @RequestBody User user) {
if (Func.isNotEmpty(user.getPassword())) {
user.setPassword(DigestUtil.encrypt(user.getPassword()));
}
return R.status(userService.saveOrUpdate(user));
return R.status(userService.submit(user));
}
/**
@ -113,7 +109,6 @@ public class UserController {
return R.status(userService.deleteLogic(Func.toIntList(ids)));
}
/**
* 设置菜单权限
*

2
blade-service/blade-user/src/main/java/org/springblade/system/user/mapper/UserMapper.xml

@ -46,7 +46,7 @@
FROM
blade_user
WHERE
tenant_code = #{param1} and account = #{param2}
tenant_code = #{param1} and account = #{param2} and is_deleted = 0
</select>
<select id="getRoleName" resultType="java.lang.String">

7
blade-service/blade-user/src/main/java/org/springblade/system/user/service/IUserService.java

@ -31,6 +31,13 @@ import java.util.List;
*/
public interface IUserService extends BaseService<User> {
/**
* 新增或修改用户
* @param user
* @return
*/
boolean submit(User user);
/**
* 自定义分页
*

13
blade-service/blade-user/src/main/java/org/springblade/system/user/service/impl/UserServiceImpl.java

@ -19,6 +19,7 @@ package org.springblade.system.user.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.exceptions.ApiException;
import org.springblade.common.constant.CommonConstant;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.tool.utils.DigestUtil;
@ -40,6 +41,18 @@ import java.util.List;
@Service
public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implements IUserService {
@Override
public boolean submit(User user) {
if (Func.isNotEmpty(user.getPassword())) {
user.setPassword(DigestUtil.encrypt(user.getPassword()));
}
Integer cnt = baseMapper.selectCount(Wrappers.<User>query().lambda().eq(User::getTenantCode, user.getTenantCode()).eq(User::getAccount, user.getAccount()));
if (cnt > 0) {
throw new ApiException("当前用户已存在!");
}
return saveOrUpdate(user);
}
@Override
public IPage<User> selectUserPage(IPage<User> page, User user) {
return page.setRecords(baseMapper.selectUserPage(page, user));

68
doc/sql/bladex-mysql-oauth2-client-upadte.sql

@ -1,68 +0,0 @@
/*
Navicat Premium Data Transfer
Source Server : mysql_localhost
Source Server Type : MySQL
Source Server Version : 50723
Source Host : localhost:3306
Source Schema : bladex
Target Server Type : MySQL
Target Server Version : 50723
File Encoding : 65001
Date: 24/03/2019 16:29:29
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for blade_client
-- ----------------------------
DROP TABLE IF EXISTS `blade_client`;
CREATE TABLE `blade_client` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
`client_id` varchar(48) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '客户端id',
`client_secret` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '客户端密钥',
`resource_ids` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '资源集合',
`scope` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '授权范围',
`authorized_grant_types` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '授权类型',
`web_server_redirect_uri` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '回调地址',
`authorities` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '权限',
`access_token_validity` int(11) NOT NULL COMMENT '令牌过期秒数',
`refresh_token_validity` int(11) NOT NULL COMMENT '刷新令牌过期秒数',
`additional_information` varchar(4096) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '附加说明',
`autoapprove` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '自动授权',
`create_user` int(11) NULL DEFAULT NULL COMMENT '创建人',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
`update_user` int(11) NULL DEFAULT NULL COMMENT '修改人',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '修改时间',
`status` int(2) NOT NULL COMMENT '状态',
`is_deleted` int(2) NOT NULL COMMENT '是否已删除',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci;
-- ----------------------------
-- Records of blade_client
-- ----------------------------
BEGIN;
INSERT INTO `blade_client` VALUES (1, 'sword', 'sword_secret', NULL, 'all', 'refresh_token,password,authorization_code', 'http://localhost:8888', NULL, 3600, 604800, NULL, NULL, 1, '2019-03-24 10:40:55', 1, '2019-03-24 10:40:59', 1, 0), (2, 'saber', 'saber_secret', NULL, 'all', 'refresh_token,password,authorization_code', 'http://localhost:8080', NULL, 3600, 604800, NULL, NULL, 1, '2019-03-24 10:42:29', 1, '2019-03-24 10:42:32', 1, 0);
COMMIT;
SET FOREIGN_KEY_CHECKS = 1;
INSERT INTO `blade_menu`(`parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
VALUES (3, 'client', '应用管理', 'menu', '/system/client', NULL, 8, 1, 0, 1, NULL, 0);
set @parentid = (SELECT LAST_INSERT_ID());
INSERT INTO `blade_menu`(`parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
VALUES (@parentid, 'client_add', '新增', 'add', '/system/client/add', 'plus', 1, 2, 1, 1, NULL, 0);
INSERT INTO `blade_menu`(`parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
VALUES (@parentid, 'client_edit', '修改', 'edit', '/system/client/edit', 'form', 2, 2, 2, 2, NULL, 0);
INSERT INTO `blade_menu`(`parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
VALUES (@parentid, 'client_delete', '删除', 'delete', '/api/blade-system/client/remove', 'delete', 3, 2, 3, 3, NULL, 0);
INSERT INTO `blade_menu`(`parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
VALUES (@parentid, 'client_view', '查看', 'view', '/system/client/view', 'file-text', 4, 2, 2, 2, NULL, 0);

2
doc/sql/bladex-saber-mysql.sql

@ -297,7 +297,7 @@ CREATE TABLE `blade_role` (
-- Records of blade_role
-- ----------------------------
BEGIN;
INSERT INTO `blade_role` VALUES (1, '000000', 0, '超级管理员', 1, 'administrator', 0);
INSERT INTO `blade_role` VALUES (1, '000000', 0, '超级管理员', 1, 'administrator', 0), (2, '000000', 0, '用户', 2, 'user', 0);
COMMIT;
-- ----------------------------

2
doc/sql/bladex-sword-mysql.sql

@ -297,7 +297,7 @@ CREATE TABLE `blade_role` (
-- Records of blade_role
-- ----------------------------
BEGIN;
INSERT INTO `blade_role` VALUES (1, '000000', 0, '超级管理员', 1, 'administrator', 0);
INSERT INTO `blade_role` VALUES (1, '000000', 0, '超级管理员', 1, 'administrator', 0), (2, '000000', 0, '用户', 2, 'user', 0);
COMMIT;
-- ----------------------------

Loading…
Cancel
Save