重构:重构系统管理/角色管理功能

1. 使用抽屉代替对话框
2. 优化数据权限权限范围存储,新增角色和部门关联表
3. 新增角色和菜单关联表
4. 部分细节优化
This commit is contained in:
2023-02-20 00:14:14 +08:00
parent 510f86031f
commit 297fbd3675
28 changed files with 889 additions and 299 deletions

View File

@@ -37,7 +37,7 @@ public @interface CrudRequestMapping {
/**
* API 列表
*/
Api[] api() default {Api.PAGE, Api.GET, Api.CREATE, Api.UPDATE, Api.DELETE, Api.EXPORT};
Api[] api() default {Api.PAGE, Api.GET, Api.ADD, Api.UPDATE, Api.DELETE, Api.EXPORT};
/**
* API 枚举
@@ -62,7 +62,7 @@ public @interface CrudRequestMapping {
/**
* 新增
*/
CREATE,
ADD,
/**
* 修改
*/

View File

@@ -117,8 +117,8 @@ public abstract class BaseController<S extends BaseService<V, D, Q, C>, V, D, Q,
@Operation(summary = "新增数据")
@ResponseBody
@PostMapping
protected R<Long> create(@Validated(BaseRequest.Create.class) @RequestBody C request) {
Long id = baseService.create(request);
protected R<Long> add(@Validated(BaseRequest.Create.class) @RequestBody C request) {
Long id = baseService.add(request);
return R.ok("新增成功", id);
}

View File

@@ -0,0 +1,43 @@
/*
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package top.charles7c.cnadmin.common.base;
import java.util.Collection;
import com.baomidou.mybatisplus.extension.toolkit.Db;
/**
* Mapper 基类
*
* @param <T>
* 实体类
* @author Charles7c
* @since 2023/2/19 20:47
*/
public interface BaseMapper<T> extends com.baomidou.mybatisplus.core.mapper.BaseMapper<T> {
/**
* 批量插入记录
*
* @param entityList
* 实体列表
* @return 是否成功
*/
default boolean insertBatch(Collection<T> entityList) {
return Db.saveBatch(entityList);
}
}

View File

@@ -78,7 +78,7 @@ public interface BaseService<V, D, Q, C extends BaseRequest> {
* 创建信息
* @return 自增 ID
*/
Long create(C request);
Long add(C request);
/**
* 修改

View File

@@ -41,6 +41,7 @@ import com.baomidou.mybatisplus.extension.toolkit.ChainWrappers;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.lang.Opt;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil;
@@ -107,7 +108,7 @@ public abstract class BaseServiceImpl<M extends BaseMapper<T>, T, V, D, Q, C ext
@Override
@Transactional(rollbackFor = Exception.class)
public Long create(C request) {
public Long add(C request) {
if (request == null) {
return 0L;
}
@@ -153,7 +154,7 @@ public abstract class BaseServiceImpl<M extends BaseMapper<T>, T, V, D, Q, C ext
protected <E> List<E> list(Q query, SortQuery sortQuery, Class<E> targetClass) {
QueryWrapper<T> queryWrapper = QueryHelper.build(query);
// 设置排序
Sort sort = sortQuery.getSort();
Sort sort = Opt.ofNullable(sortQuery).orElseGet(SortQuery::new).getSort();
for (Sort.Order order : sort) {
queryWrapper.orderBy(order != null, order.isAscending(), StrUtil.toUnderlineCase(order.getProperty()));
}