mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 12:56:28 +08:00
5.0
This commit is contained in:
@@ -2,12 +2,10 @@ package com.gitee.sop.adminbackend.controller.isv;
|
||||
|
||||
import com.gitee.fastmybatis.core.PageInfo;
|
||||
import com.gitee.fastmybatis.core.query.LambdaQuery;
|
||||
import com.gitee.fastmybatis.core.query.param.PageParam;
|
||||
import com.gitee.sop.adminbackend.common.resp.Result;
|
||||
import com.gitee.sop.adminbackend.controller.isv.req.PermGroupApiInfoParam;
|
||||
import com.gitee.sop.adminbackend.controller.isv.req.PermGroupPermissionParam;
|
||||
import com.gitee.sop.adminbackend.dao.entity.ApiInfo;
|
||||
import com.gitee.sop.adminbackend.dao.entity.PermGroupPermission;
|
||||
import com.gitee.sop.adminbackend.service.isv.PermGroupPermissionService;
|
||||
import com.gitee.sop.adminbackend.service.isv.dto.PermGroupPermissionDTO;
|
||||
import com.gitee.sop.adminbackend.util.CopyUtil;
|
||||
@@ -19,7 +17,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
@@ -37,10 +34,10 @@ public class PermGroupPermissionController {
|
||||
* @param param param
|
||||
* @return 返回分页结果
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public Result<List<ApiInfo>> page(@Validated PermGroupApiInfoParam param) {
|
||||
@GetMapping("/page")
|
||||
public Result<PageInfo<ApiInfo>> page(Long groupId, @Validated PermGroupApiInfoParam param) {
|
||||
LambdaQuery<ApiInfo> query = param.toLambdaQuery(ApiInfo.class);
|
||||
List<ApiInfo> apiInfoList = permGroupPermissionService.listGroupApiId(param.getGroupId(), query);
|
||||
PageInfo<ApiInfo> apiInfoList = permGroupPermissionService.pageGroupApiId(groupId, query);
|
||||
return Result.ok(apiInfoList);
|
||||
}
|
||||
|
||||
@@ -51,6 +48,11 @@ public class PermGroupPermissionController {
|
||||
return Result.ok(cnt);
|
||||
}
|
||||
|
||||
@PostMapping("delete")
|
||||
public Result<Integer> delete(@RequestBody @Validated PermGroupPermissionParam param) {
|
||||
int cnt = permGroupPermissionService.delete(param.getGroupId(), param.getApiIdList());
|
||||
return Result.ok(cnt);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -2,19 +2,14 @@ package com.gitee.sop.adminbackend.controller.isv.req;
|
||||
|
||||
import com.gitee.fastmybatis.core.query.Operator;
|
||||
import com.gitee.fastmybatis.core.query.annotation.Condition;
|
||||
import com.gitee.fastmybatis.core.query.param.IParam;
|
||||
import com.gitee.fastmybatis.core.query.param.PageParam;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@Data
|
||||
public class PermGroupApiInfoParam implements IParam {
|
||||
|
||||
@NotNull
|
||||
private Long groupId;
|
||||
public class PermGroupApiInfoParam extends PageParam {
|
||||
|
||||
@Condition(operator = Operator.like)
|
||||
private String apiName;
|
||||
@@ -22,4 +17,6 @@ public class PermGroupApiInfoParam implements IParam {
|
||||
@Condition
|
||||
private Integer status;
|
||||
|
||||
@Condition
|
||||
private Integer isPermission;
|
||||
}
|
||||
|
@@ -19,4 +19,7 @@ public class ApiInfoPageParam extends PageParam {
|
||||
@Condition
|
||||
private Integer status;
|
||||
|
||||
@Condition
|
||||
private Integer isPermission;
|
||||
|
||||
}
|
||||
|
@@ -8,16 +8,13 @@ import com.gitee.sop.adminbackend.dao.entity.PermGroupPermission;
|
||||
import com.gitee.sop.adminbackend.dao.mapper.ApiInfoMapper;
|
||||
import com.gitee.sop.adminbackend.dao.mapper.PermGroupPermissionMapper;
|
||||
import com.gitee.sop.adminbackend.service.isv.dto.PermGroupPermissionDTO;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
@@ -40,29 +37,34 @@ public class PermGroupPermissionService implements LambdaService<PermGroupPermis
|
||||
});
|
||||
}
|
||||
|
||||
public List<ApiInfo> listGroupApiId(Long groupId, LambdaQuery<ApiInfo> query) {
|
||||
public PageInfo<ApiInfo> pageGroupApiId(Long groupId, LambdaQuery<ApiInfo> query) {
|
||||
List<Long> apiIds = this.query()
|
||||
.eq(PermGroupPermission::getGroupId, groupId)
|
||||
.listUniqueValue(PermGroupPermission::getApiId);
|
||||
|
||||
if (apiIds.isEmpty()) {
|
||||
return new ArrayList<>(0);
|
||||
return new PageInfo<>();
|
||||
}
|
||||
|
||||
query.in(ApiInfo::getId, apiIds);
|
||||
|
||||
return apiInfoMapper.list(query);
|
||||
return apiInfoMapper.page(query);
|
||||
}
|
||||
|
||||
public int setting(PermGroupPermissionDTO param) {
|
||||
Long groupId = param.getGroupId();
|
||||
this.deleteByColumn(PermGroupPermission::getGroupId, groupId);
|
||||
|
||||
List<Long> apiIdList = param.getApiIdList();
|
||||
if (CollectionUtils.isEmpty(apiIdList)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
List<Long> existApiIdList = this.query()
|
||||
.eq(PermGroupPermission::getGroupId, groupId)
|
||||
.listUniqueValue(PermGroupPermission::getApiId);
|
||||
|
||||
List<PermGroupPermission> saveList = apiIdList.stream()
|
||||
// 已存在的不添加
|
||||
.filter(apiId -> !existApiIdList.contains(apiId))
|
||||
.map(apiId -> {
|
||||
PermGroupPermission permGroupPermission = new PermGroupPermission();
|
||||
permGroupPermission.setGroupId(groupId);
|
||||
@@ -72,4 +74,11 @@ public class PermGroupPermissionService implements LambdaService<PermGroupPermis
|
||||
.collect(Collectors.toList());
|
||||
return this.saveBatch(saveList);
|
||||
}
|
||||
|
||||
public int delete(Long groupId, Collection<Long> apiIds) {
|
||||
return this.query()
|
||||
.eq(PermGroupPermission::getGroupId, groupId)
|
||||
.in(PermGroupPermission::getApiId, apiIds)
|
||||
.delete();
|
||||
}
|
||||
}
|
||||
|
@@ -1,10 +1,11 @@
|
||||
import { createUrl, http } from "@/utils/http";
|
||||
import type { Result } from "@/model";
|
||||
import type { PageResult, Result } from "@/model";
|
||||
|
||||
// 后端请求接口
|
||||
const apiUrl: any = createUrl({
|
||||
listGroupApiId: "perm/group/permission/list",
|
||||
setting: "perm/group/permission/setting"
|
||||
page: "perm/group/permission/page",
|
||||
setting: "perm/group/permission/setting",
|
||||
del: "perm/group/permission/delete"
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -14,13 +15,10 @@ export const api: any = {
|
||||
/**
|
||||
* 查询分组权限
|
||||
*
|
||||
* @param groupId groupId
|
||||
* @param params params
|
||||
*/
|
||||
listGroupApiId(groupId: number): Promise<Result<any>> {
|
||||
const params = {
|
||||
groupId: groupId
|
||||
};
|
||||
return http.get<Result<any>, any>(apiUrl.listGroupApiId, { params });
|
||||
page(params): Promise<PageResult> {
|
||||
return http.get<PageResult, any>(apiUrl.page, { params });
|
||||
},
|
||||
/**
|
||||
* 设置接口权限
|
||||
@@ -34,5 +32,12 @@ export const api: any = {
|
||||
apiIdList: apiIdList
|
||||
};
|
||||
return http.post<Result<any>, any>(apiUrl.setting, { data });
|
||||
},
|
||||
/**
|
||||
* 删除
|
||||
* @param data 表单内容
|
||||
*/
|
||||
del(data: object) {
|
||||
return http.post<Result<any>, any>(apiUrl.del, { data });
|
||||
}
|
||||
};
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { ref } from "vue";
|
||||
import { type PlusColumn, useTable } from "plus-pro-components";
|
||||
import { type PageInfo, type PlusColumn, useTable } from "plus-pro-components";
|
||||
import { withInstall } from "@pureadmin/utils";
|
||||
import apiSelect from "./index.vue";
|
||||
import { StatusEnum } from "@/model/enums";
|
||||
@@ -15,8 +15,9 @@ export const handleSaveApi = ref((_: Array<number>) => {});
|
||||
export const searchFormData = ref({
|
||||
apiName: "",
|
||||
status: "",
|
||||
isPermission: null,
|
||||
pageIndex: 1,
|
||||
pageSize: 999999
|
||||
pageSize: 10
|
||||
});
|
||||
|
||||
// 查询表单字段定义
|
||||
@@ -48,13 +49,11 @@ export const searchFormColumns: PlusColumn[] = [
|
||||
// ========= table =========
|
||||
|
||||
// 表格对象
|
||||
export const { tableData } = useTable<any[]>();
|
||||
export const { tableData, total, pageInfo } = useTable<any[]>();
|
||||
// 默认每页条数,默认10
|
||||
pageInfo.value.pageSize = 10;
|
||||
|
||||
interface TableRow {
|
||||
id: number;
|
||||
}
|
||||
|
||||
const multipleSelection = ref<TableRow[]>([]);
|
||||
const multipleSelection = ref([]);
|
||||
export const selectable = (row: any) => row.status === StatusEnum.ENABLE;
|
||||
// 表格字段定义
|
||||
export const tableColumns: PlusColumn[] = [
|
||||
@@ -122,18 +121,9 @@ export const tableColumns: PlusColumn[] = [
|
||||
}
|
||||
];
|
||||
|
||||
export const handleAuthApi = apiList => {
|
||||
export const openDlg = () => {
|
||||
dlgApiSelectShow.value = true;
|
||||
const arr = [];
|
||||
for (let apiId of apiList) {
|
||||
for (let row of tableData.value) {
|
||||
if (apiId === row.id) {
|
||||
arr.push(row);
|
||||
}
|
||||
}
|
||||
}
|
||||
multipleSelection.value = arr;
|
||||
console.log(arr);
|
||||
search();
|
||||
};
|
||||
|
||||
export const handleConfirm = () => {
|
||||
@@ -145,8 +135,7 @@ export const handleClose = () => {
|
||||
dlgApiSelectShow.value = false;
|
||||
};
|
||||
|
||||
export const handleSelectionChange = (rows: TableRow[]) => {
|
||||
console.log(rows);
|
||||
export const handleSelectionChange = (rows: any) => {
|
||||
multipleSelection.value = rows;
|
||||
};
|
||||
|
||||
@@ -155,18 +144,29 @@ export const handleSearch = () => {
|
||||
search();
|
||||
};
|
||||
|
||||
// 分页事件
|
||||
export const handlePaginationChange = (_pageInfo: PageInfo): void => {
|
||||
pageInfo.value = _pageInfo;
|
||||
search();
|
||||
};
|
||||
|
||||
// 查询
|
||||
export const search = async () => {
|
||||
try {
|
||||
const { data } = await doSearch();
|
||||
tableData.value = data;
|
||||
tableData.value = data.list;
|
||||
total.value = data.total;
|
||||
} catch (error) {}
|
||||
};
|
||||
// 请求接口
|
||||
const doSearch = async () => {
|
||||
// 查询参数
|
||||
const data = searchFormData.value;
|
||||
return serveApi.listAll(data);
|
||||
// 添加分页参数
|
||||
data.pageIndex = pageInfo.value.page;
|
||||
data.pageSize = pageInfo.value.pageSize;
|
||||
|
||||
return serveApi.page(data);
|
||||
};
|
||||
|
||||
// 页面加载
|
||||
|
@@ -9,7 +9,10 @@ import {
|
||||
handleSearch,
|
||||
searchFormColumns,
|
||||
searchFormData,
|
||||
tableData
|
||||
tableData,
|
||||
pageInfo,
|
||||
total,
|
||||
handlePaginationChange
|
||||
} from "@/components/ApiSelect/index";
|
||||
</script>
|
||||
|
||||
@@ -40,7 +43,14 @@ import {
|
||||
:selectionTableColumnProps="{
|
||||
selectable: selectable
|
||||
}"
|
||||
:pagination="{
|
||||
total,
|
||||
modelValue: pageInfo,
|
||||
pageSizeList: [10, 20, 50, 100],
|
||||
align: 'right'
|
||||
}"
|
||||
adaptive
|
||||
@paginationChange="handlePaginationChange"
|
||||
@selection-change="handleSelectionChange"
|
||||
/>
|
||||
</el-card>
|
||||
|
@@ -6,8 +6,6 @@ import {
|
||||
} from "plus-pro-components";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { api } from "@/api/permGroup";
|
||||
import { api as permApi } from "@/api/permGroupPermission";
|
||||
import { handleSaveApi, handleClose } from "@/components/ApiSelect";
|
||||
import { searchTable } from "@/views/isv/perm/permGroupApi";
|
||||
|
||||
const isAdd = ref(false);
|
||||
@@ -29,17 +27,6 @@ export const searchFormColumns: PlusColumn[] = [
|
||||
|
||||
// ========= table =========
|
||||
|
||||
handleSaveApi.value = apiIdList => {
|
||||
const groupId = selectedGroupId.value;
|
||||
if (groupId > 0) {
|
||||
permApi.setting(groupId, apiIdList).then(() => {
|
||||
ElMessage.success("保存成功");
|
||||
handleClose();
|
||||
search();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// 表格对象
|
||||
export const { tableData, buttons: actionButtons } = useTable<any[]>();
|
||||
|
||||
@@ -61,12 +48,6 @@ actionButtons.value = [
|
||||
props: {
|
||||
type: "primary"
|
||||
},
|
||||
// onClick: withModifiers((params: ButtonsCallBackParams) => {
|
||||
// isAdd.value = false;
|
||||
// editFormData.value = Object.assign({}, params.row);
|
||||
// dlgTitle.value = "修改";
|
||||
// dlgShow.value = true;
|
||||
// }, ['stop', 'self']),
|
||||
onClick(params: ButtonsCallBackParams) {
|
||||
params.e.stopPropagation();
|
||||
isAdd.value = false;
|
||||
|
@@ -1,9 +1,21 @@
|
||||
import { ref } from "vue";
|
||||
import { type PlusColumn, useTable } from "plus-pro-components";
|
||||
import {
|
||||
type ButtonsCallBackParams,
|
||||
type PageInfo,
|
||||
type PlusColumn,
|
||||
useTable
|
||||
} from "plus-pro-components";
|
||||
import { withInstall } from "@pureadmin/utils";
|
||||
import permGroupApi from "./permGroupApi.vue";
|
||||
import { StatusEnum } from "@/model/enums";
|
||||
import { api as serveApi } from "@/api/serveApi";
|
||||
import { api as permApi, api } from "@/api/permGroupPermission";
|
||||
import {
|
||||
handleClose,
|
||||
handleSaveApi,
|
||||
openDlg,
|
||||
searchFormData as apiSearFormData
|
||||
} from "@/components/ApiSelect";
|
||||
import { ElMessage } from "element-plus";
|
||||
|
||||
// ========= search form =========
|
||||
|
||||
@@ -11,7 +23,9 @@ import { api as serveApi } from "@/api/serveApi";
|
||||
export const searchFormData = ref({
|
||||
groupId: 0,
|
||||
apiName: "",
|
||||
status: ""
|
||||
status: "",
|
||||
pageIndex: 1,
|
||||
pageSize: 10
|
||||
});
|
||||
|
||||
// 查询表单字段定义
|
||||
@@ -42,9 +56,26 @@ export const searchFormColumns: PlusColumn[] = [
|
||||
|
||||
// ========= table =========
|
||||
|
||||
// 表格对象
|
||||
export const { tableData } = useTable<any[]>();
|
||||
handleSaveApi.value = apiIdList => {
|
||||
const groupId = searchFormData.value.groupId;
|
||||
if (groupId > 0) {
|
||||
permApi.setting(groupId, apiIdList).then(() => {
|
||||
ElMessage.success("保存成功");
|
||||
handleClose();
|
||||
search();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// 表格对象
|
||||
export const {
|
||||
tableData,
|
||||
total,
|
||||
pageInfo,
|
||||
buttons: actionButtons
|
||||
} = useTable<any[]>();
|
||||
// 默认每页条数,默认10
|
||||
pageInfo.value.pageSize = 10;
|
||||
// 表格字段定义
|
||||
export const tableColumns: PlusColumn[] = [
|
||||
{
|
||||
@@ -110,6 +141,35 @@ export const tableColumns: PlusColumn[] = [
|
||||
]
|
||||
}
|
||||
];
|
||||
// 表格按钮定义
|
||||
actionButtons.value = [
|
||||
{
|
||||
// 删除
|
||||
text: "删除",
|
||||
code: "delete",
|
||||
props: {
|
||||
type: "danger"
|
||||
},
|
||||
confirm: {
|
||||
options: { draggable: false }
|
||||
},
|
||||
onConfirm(params: ButtonsCallBackParams) {
|
||||
const data = {
|
||||
groupId: searchFormData.value.groupId,
|
||||
apiIdList: [params.row.id]
|
||||
};
|
||||
api.del(data).then(() => {
|
||||
ElMessage.success("删除成功");
|
||||
search();
|
||||
});
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
export const handleOpenDlg = () => {
|
||||
apiSearFormData.value.isPermission = 1;
|
||||
openDlg();
|
||||
};
|
||||
|
||||
export const searchTable = groupId => {
|
||||
searchFormData.value.groupId = groupId;
|
||||
@@ -121,18 +181,29 @@ export const handleSearch = () => {
|
||||
search();
|
||||
};
|
||||
|
||||
// 分页事件
|
||||
export const handlePaginationChange = (_pageInfo: PageInfo): void => {
|
||||
pageInfo.value = _pageInfo;
|
||||
search();
|
||||
};
|
||||
|
||||
// 查询
|
||||
export const search = async () => {
|
||||
try {
|
||||
const { data } = await doSearch();
|
||||
tableData.value = data;
|
||||
tableData.value = data.list;
|
||||
total.value = data.total;
|
||||
} catch (error) {}
|
||||
};
|
||||
// 请求接口
|
||||
const doSearch = async () => {
|
||||
// 查询参数
|
||||
const data = searchFormData.value;
|
||||
return serveApi.listAll(data);
|
||||
// 添加分页参数
|
||||
data.pageIndex = pageInfo.value.page;
|
||||
data.pageSize = pageInfo.value.pageSize;
|
||||
|
||||
return api.page(data);
|
||||
};
|
||||
|
||||
const PermGroupApi = withInstall(permGroupApi);
|
||||
|
@@ -4,9 +4,14 @@ import {
|
||||
handleSearch,
|
||||
searchFormColumns,
|
||||
searchFormData,
|
||||
tableData
|
||||
tableData,
|
||||
total,
|
||||
pageInfo,
|
||||
handleOpenDlg,
|
||||
handlePaginationChange
|
||||
} from "./permGroupApi";
|
||||
import { ApiSelect } from "@/components/ApiSelect/index";
|
||||
import { actionButtons } from "./permGroupApi";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -21,7 +26,22 @@ import { ApiSelect } from "@/components/ApiSelect/index";
|
||||
@search="handleSearch"
|
||||
/>
|
||||
</template>
|
||||
<PlusTable :columns="tableColumns" :table-data="tableData" adaptive />
|
||||
<PlusTable
|
||||
:columns="tableColumns"
|
||||
:table-data="tableData"
|
||||
:action-bar="{ buttons: actionButtons, width: 80 }"
|
||||
:pagination="{
|
||||
total,
|
||||
modelValue: pageInfo,
|
||||
pageSizeList: [10, 20, 50, 100],
|
||||
align: 'right'
|
||||
}"
|
||||
@paginationChange="handlePaginationChange"
|
||||
>
|
||||
<template #title>
|
||||
<el-button type="primary" @click="handleOpenDlg">授权接口</el-button>
|
||||
</template>
|
||||
</PlusTable>
|
||||
<ApiSelect />
|
||||
</el-card>
|
||||
</template>
|
||||
|
@@ -213,7 +213,6 @@ actionButtons.value = [
|
||||
};
|
||||
api.updateStatus(data).then(() => {
|
||||
ElMessage.success("修改成功");
|
||||
dlgShow.value = false;
|
||||
search();
|
||||
});
|
||||
}
|
||||
@@ -234,7 +233,7 @@ const editFormDataGen = () => {
|
||||
status: 1,
|
||||
isPermission: 0,
|
||||
description: "",
|
||||
regSource: 1,
|
||||
regSource: RegSource.CUSTOM,
|
||||
isNeedToken: 0
|
||||
};
|
||||
};
|
||||
|
Reference in New Issue
Block a user