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