mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 12:56:28 +08:00
5.0
This commit is contained in:
@@ -32,7 +32,7 @@ public class ExceptionHandlerController {
|
||||
log.error("报错,code:{}, msg:{}", errorCode.getCode(), errorCode.getMsg(), e);
|
||||
return Result.err(errorCode.getCode(), errorCode.getMsg());
|
||||
}
|
||||
if (e instanceof BizException || e instanceof IllegalArgumentException) {
|
||||
if (e instanceof BizException) {
|
||||
RuntimeException bizException = (RuntimeException) e;
|
||||
return Result.err(bizException.getMessage());
|
||||
}
|
||||
|
@@ -2,7 +2,6 @@ package com.gitee.sop.adminbackend.controller.isv;
|
||||
|
||||
import com.gitee.sop.adminbackend.common.resp.Result;
|
||||
import com.gitee.sop.adminbackend.controller.isv.req.IsvGroupSettingParam;
|
||||
import com.gitee.sop.adminbackend.dao.entity.PermGroup;
|
||||
import com.gitee.sop.adminbackend.service.isv.PermIsvGroupService;
|
||||
import com.gitee.sop.adminbackend.service.isv.dto.IsvGroupSettingDTO;
|
||||
import com.gitee.sop.adminbackend.util.CopyUtil;
|
||||
@@ -32,9 +31,9 @@ public class PermIsvGroupController {
|
||||
* @param isvId isvId
|
||||
* @return 返回影响行数
|
||||
*/
|
||||
@GetMapping("listIsvCode")
|
||||
public Result<List<String>> listIsvGroup(Long isvId) {
|
||||
List<String> permGroups = permIsvGroupService.listIsvGroup(isvId);
|
||||
@GetMapping("listIsvGroupId")
|
||||
public Result<List<Long>> listIsvGroupId(Long isvId) {
|
||||
List<Long> permGroups = permIsvGroupService.listIsvGroupId(isvId);
|
||||
return Result.ok(permGroups);
|
||||
}
|
||||
|
||||
|
@@ -14,6 +14,6 @@ public class IsvGroupSettingParam {
|
||||
@NotNull
|
||||
private Long isvId;
|
||||
|
||||
private List<String> groupCodeList;
|
||||
private List<Long> groupIds;
|
||||
|
||||
}
|
||||
|
@@ -1,7 +1,5 @@
|
||||
package com.gitee.sop.adminbackend.controller.isv.req;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.gitee.fastmybatis.core.query.Operator;
|
||||
import com.gitee.fastmybatis.core.query.annotation.Condition;
|
||||
import com.gitee.fastmybatis.core.query.param.PageParam;
|
||||
@@ -17,12 +15,6 @@ import lombok.EqualsAndHashCode;
|
||||
@Data
|
||||
public class PermGroupParam extends PageParam {
|
||||
|
||||
/**
|
||||
* 分组代码
|
||||
*/
|
||||
@Condition(operator = Operator.like)
|
||||
private String groupCode;
|
||||
|
||||
/**
|
||||
* 分组描述
|
||||
*/
|
||||
|
@@ -25,12 +25,7 @@ public class PermGroup {
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 分组代码
|
||||
*/
|
||||
private String groupCode;
|
||||
|
||||
/**
|
||||
* 角色描述
|
||||
* 分组名称
|
||||
*/
|
||||
private String groupName;
|
||||
|
||||
|
@@ -25,9 +25,9 @@ public class PermGroupPermission {
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 分组表code
|
||||
* 组id
|
||||
*/
|
||||
private String groupCode;
|
||||
private Long groupId;
|
||||
|
||||
/**
|
||||
* api_info.id
|
||||
|
@@ -27,9 +27,9 @@ public class PermIsvGroup {
|
||||
private Long isvId;
|
||||
|
||||
/**
|
||||
* 组code
|
||||
* 组id
|
||||
*/
|
||||
private String groupCode;
|
||||
private Long groupId;
|
||||
|
||||
private LocalDateTime addTime;
|
||||
|
||||
|
@@ -120,30 +120,6 @@ public class IsvInfoService implements LambdaService<IsvInfo, IsvInfoMapper> {
|
||||
}
|
||||
|
||||
|
||||
private void saveIsvRole(IsvInfo isvInfo, List<String> roleCodeList) {
|
||||
Long isvId = isvInfo.getId();
|
||||
permIsvGroupService.deleteByColumn(PermIsvGroup::getIsvId, isvId);
|
||||
|
||||
List<PermIsvGroup> tobeSaveList = roleCodeList.stream()
|
||||
.map(groupCode -> {
|
||||
PermIsvGroup rec = new PermIsvGroup();
|
||||
rec.setIsvId(isvId);
|
||||
rec.setGroupCode(groupCode);
|
||||
return rec;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
permIsvGroupService.saveBatch(tobeSaveList);
|
||||
|
||||
// TODO:同步到网关
|
||||
// try {
|
||||
// routePermissionService.sendIsvRolePermissionMsg(isvInfo.getAppKey(), roleCodeList);
|
||||
// } catch (Exception e) {
|
||||
// log.error("同步角色失败,isvInfo:{}, roleCodeList:{}", isvInfo, roleCodeList);
|
||||
// throw new BizException("同步角色失败,请查看网关日志");
|
||||
// }
|
||||
}
|
||||
|
||||
private IsvKeysGenDTO createIsvKeys(RSATool.KeyFormat keyFormat) throws Exception {
|
||||
IsvKeysGenDTO isvKeysGenDTO = new IsvKeysGenDTO();
|
||||
|
||||
|
@@ -28,10 +28,10 @@ public class PermGroupService implements LambdaService<PermGroup, PermGroupMappe
|
||||
});
|
||||
}
|
||||
|
||||
public Map<String, String> getCodeNameMap(Collection<String> codeList) {
|
||||
public Map<Long, String> getCodeNameMap(Collection<Long> groupIdList) {
|
||||
return this.query()
|
||||
.in(PermGroup::getGroupCode, codeList)
|
||||
.map(PermGroup::getGroupCode, PermGroup::getGroupName);
|
||||
.in(PermGroup::getId, groupIdList)
|
||||
.map(PermGroup::getId, PermGroup::getGroupName);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -45,40 +45,43 @@ public class PermIsvGroupService implements LambdaService<PermIsvGroup, PermIsvG
|
||||
if (list.isEmpty()) {
|
||||
return new HashMap<>();
|
||||
}
|
||||
Set<String> codes = list.stream().map(PermIsvGroup::getGroupCode).collect(Collectors.toSet());
|
||||
Map<String, String> groupCodeMap = permGroupService.getCodeNameMap(codes);
|
||||
Set<Long> groupIds = list.stream().map(PermIsvGroup::getGroupId).collect(Collectors.toSet());
|
||||
Map<Long, String> groupCodeMap = permGroupService.getCodeNameMap(groupIds);
|
||||
return this.query()
|
||||
.in(PermIsvGroup::getIsvId, isvIds)
|
||||
.group(PermIsvGroup::getIsvId,
|
||||
permIsvGroup -> groupCodeMap.getOrDefault(permIsvGroup.getGroupCode(), ""));
|
||||
permIsvGroup -> groupCodeMap.getOrDefault(permIsvGroup.getGroupId(), ""));
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int updateIsvGroup(IsvGroupSettingDTO isvGroupSettingDTO) {
|
||||
// 先删除所有
|
||||
int i = this.deleteByColumn(PermIsvGroup::getIsvId, isvGroupSettingDTO.getIsvId());
|
||||
List<String> groupCodeList = isvGroupSettingDTO.getGroupCodeList();
|
||||
if (CollectionUtils.isEmpty(groupCodeList)) {
|
||||
List<Long> groupIds = isvGroupSettingDTO.getGroupIds();
|
||||
if (CollectionUtils.isEmpty(groupIds)) {
|
||||
return i;
|
||||
}
|
||||
List<PermIsvGroup> saveList = groupCodeList
|
||||
List<PermIsvGroup> saveList = groupIds
|
||||
.stream()
|
||||
.map(groupCode -> {
|
||||
.map(groupId -> {
|
||||
PermIsvGroup permIsvGroup = new PermIsvGroup();
|
||||
permIsvGroup.setIsvId(isvGroupSettingDTO.getIsvId());
|
||||
permIsvGroup.setGroupCode(groupCode);
|
||||
permIsvGroup.setGroupId(groupId);
|
||||
return permIsvGroup;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
return this.saveBatch(saveList);
|
||||
int cnt = this.saveBatch(saveList);
|
||||
// TODO:同步到网关
|
||||
|
||||
return cnt;
|
||||
}
|
||||
|
||||
public List<String> listIsvGroup(Long isvId) {
|
||||
public List<Long> listIsvGroupId(Long isvId) {
|
||||
List<PermIsvGroup> list = this.list(PermIsvGroup::getIsvId, isvId);
|
||||
if (list.isEmpty()) {
|
||||
return new ArrayList<>(0);
|
||||
}
|
||||
return list.stream().map(PermIsvGroup::getGroupCode).distinct().collect(Collectors.toList());
|
||||
return list.stream().map(PermIsvGroup::getGroupId).distinct().collect(Collectors.toList());
|
||||
|
||||
}
|
||||
|
||||
|
@@ -15,7 +15,6 @@ public class IsvGroupSettingDTO {
|
||||
@NotNull
|
||||
private Long isvId;
|
||||
|
||||
@NotEmpty
|
||||
private List<String> groupCodeList;
|
||||
private List<Long> groupIds;
|
||||
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@ const apiUrl: any = createUrl({
|
||||
updateStatus: "/isv/updateStatus",
|
||||
createKeys: "/isv/createKeys",
|
||||
updateKeys: "/isv/updateKeys",
|
||||
listGroup: "perm/isv/group/listIsvCode",
|
||||
listGroup: "perm/isv/group/listIsvGroupId",
|
||||
updateGroup: "perm/isv/group/setting"
|
||||
});
|
||||
|
||||
@@ -104,11 +104,11 @@ export const api: any = {
|
||||
*/
|
||||
updateGroup(
|
||||
isvId: Number,
|
||||
groupCodes: Array<string>
|
||||
groupIds: Array<number>
|
||||
): Promise<Result<KeyStore>> {
|
||||
const data = {
|
||||
isvId: isvId,
|
||||
groupCodeList: groupCodes
|
||||
groupIds: groupIds
|
||||
};
|
||||
return http.post<Result<any>, any>(apiUrl.updateGroup, { data });
|
||||
}
|
||||
|
@@ -156,7 +156,6 @@ actionButtons.value = [
|
||||
{
|
||||
// 启用/禁用
|
||||
text: row => (row.status === StatusEnum.ENABLE ? "禁用" : "启用"),
|
||||
code: "delete",
|
||||
confirm: {
|
||||
message: data => {
|
||||
const opt = data.row.status === StatusEnum.ENABLE ? "禁用" : "启用";
|
||||
|
@@ -11,7 +11,7 @@ import { search } from "@/views/isv/list/index";
|
||||
export const dlgGroupSetting = ref(false);
|
||||
export const settingGroupFormData = ref<any>({
|
||||
isvId: 0,
|
||||
groupCodeList: []
|
||||
groupIds: []
|
||||
});
|
||||
|
||||
const groupList: Ref<OptionsRow[]> = ref([]);
|
||||
@@ -28,7 +28,7 @@ const loadGroup = () => {
|
||||
groupList.value = rows.map(row => {
|
||||
return {
|
||||
label: row.groupName,
|
||||
value: row.groupCode
|
||||
value: row.id
|
||||
};
|
||||
});
|
||||
});
|
||||
@@ -39,7 +39,7 @@ export const groupColumns: PlusColumn[] = [
|
||||
{
|
||||
label: "分组",
|
||||
width: 120,
|
||||
prop: "groupCodeList",
|
||||
prop: "groupIds",
|
||||
valueType: "checkbox",
|
||||
// options推荐写法
|
||||
// 3. 用 computed 返回 ref 的 value
|
||||
@@ -51,7 +51,7 @@ export const settingGroup = (row: any) => {
|
||||
api.listGroup(row.id).then(resp => {
|
||||
settingGroupFormData.value = {
|
||||
isvId: row.id,
|
||||
groupCodeList: resp.data
|
||||
groupIds: resp.data
|
||||
};
|
||||
dlgGroupSetting.value = true;
|
||||
});
|
||||
@@ -60,7 +60,7 @@ export const settingGroup = (row: any) => {
|
||||
export const handleUpdateGroup = () => {
|
||||
const data = settingGroupFormData.value;
|
||||
|
||||
api.updateGroup(data.isvId, data.groupCodeList).then(() => {
|
||||
api.updateGroup(data.isvId, data.groupIds).then(() => {
|
||||
ElMessage({
|
||||
message: "保存成功",
|
||||
type: "success"
|
||||
|
@@ -14,7 +14,6 @@ const isAdd = ref(false);
|
||||
|
||||
// 查询表单对象
|
||||
export const searchFormData = ref({
|
||||
groupCode: "",
|
||||
groupName: "",
|
||||
pageIndex: 1,
|
||||
pageSize: 10
|
||||
@@ -23,11 +22,7 @@ export const searchFormData = ref({
|
||||
// 查询表单字段定义
|
||||
export const searchFormColumns: PlusColumn[] = [
|
||||
{
|
||||
label: "分组代码",
|
||||
prop: "groupCode"
|
||||
},
|
||||
{
|
||||
label: "角色描述",
|
||||
label: "分组描述",
|
||||
prop: "groupName"
|
||||
}
|
||||
];
|
||||
@@ -47,11 +42,7 @@ pageInfo.value.pageSize = 10;
|
||||
// 表格字段定义
|
||||
export const tableColumns: PlusColumn[] = [
|
||||
{
|
||||
label: "分组代码",
|
||||
prop: "groupCode"
|
||||
},
|
||||
{
|
||||
label: "角色描述",
|
||||
label: "分组名称",
|
||||
prop: "groupName"
|
||||
},
|
||||
{
|
||||
@@ -93,7 +84,7 @@ actionButtons.value = [
|
||||
options: { draggable: false }
|
||||
},
|
||||
onConfirm(params: ButtonsCallBackParams) {
|
||||
api.del(params).then(() => {
|
||||
api.del(params.row).then(() => {
|
||||
ElMessage({
|
||||
message: "删除成功",
|
||||
type: "success"
|
||||
@@ -113,25 +104,18 @@ export const dlgTitle = ref("");
|
||||
// 表单值
|
||||
const editFormDataGen = () => {
|
||||
return {
|
||||
groupCode: "",
|
||||
groupName: ""
|
||||
};
|
||||
};
|
||||
export const editFormData = ref<any>(editFormDataGen());
|
||||
export const editFormRules = {
|
||||
groupCode: [{ required: true, message: "请输入角色代码" }],
|
||||
groupName: [{ required: true, message: "请输入角色描述" }]
|
||||
groupName: [{ required: true, message: "请输入分组描述" }]
|
||||
};
|
||||
|
||||
// 表单内容
|
||||
export const editFormColumns: PlusColumn[] = [
|
||||
{
|
||||
label: "分组代码",
|
||||
prop: "groupCode",
|
||||
valueType: "input"
|
||||
},
|
||||
{
|
||||
label: "角色描述",
|
||||
label: "分组名称",
|
||||
prop: "groupName",
|
||||
valueType: "input"
|
||||
}
|
||||
|
Reference in New Issue
Block a user