mirror of https://github.com/jeecgboot/jeecg-boot
commit
bd83b994bc
|
@ -8,6 +8,8 @@ import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
||||||
import org.springframework.http.converter.StringHttpMessageConverter;
|
import org.springframework.http.converter.StringHttpMessageConverter;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -30,6 +32,10 @@ public class RestUtil {
|
||||||
// 微服务版集成企业微信单点登录
|
// 微服务版集成企业微信单点登录
|
||||||
// 因为微服务版没有端口号,导致 SpringContextUtils.getDomain() 方法获取的域名的端口号变成了:-1所以出问题了,只需要把这个-1给去掉就可以了。
|
// 因为微服务版没有端口号,导致 SpringContextUtils.getDomain() 方法获取的域名的端口号变成了:-1所以出问题了,只需要把这个-1给去掉就可以了。
|
||||||
String port=":-1";
|
String port=":-1";
|
||||||
|
//单元测试导致无端口号的问题
|
||||||
|
if (!domain.endsWith(port)){
|
||||||
|
checkAndAddPort();
|
||||||
|
}
|
||||||
if (domain.endsWith(port)) {
|
if (domain.endsWith(port)) {
|
||||||
domain = domain.substring(0, domain.length() - 3);
|
domain = domain.substring(0, domain.length() - 3);
|
||||||
}
|
}
|
||||||
|
@ -37,12 +43,31 @@ public class RestUtil {
|
||||||
return domain;
|
return domain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void checkAndAddPort() {
|
||||||
|
try {
|
||||||
|
URL url = new URL(domain);
|
||||||
|
int port = url.getPort();
|
||||||
|
if (port == -1) {
|
||||||
|
domain = domain+":"+getPort();
|
||||||
|
}
|
||||||
|
} catch (MalformedURLException e) {
|
||||||
|
log.warn("获取端口号异常");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static String getPath() {
|
private static String getPath() {
|
||||||
if (path == null) {
|
if (path == null) {
|
||||||
path = SpringContextUtils.getApplicationContext().getEnvironment().getProperty("server.servlet.context-path");
|
path = SpringContextUtils.getApplicationContext().getEnvironment().getProperty("server.servlet.context-path");
|
||||||
}
|
}
|
||||||
return oConvertUtils.getString(path);
|
return oConvertUtils.getString(path);
|
||||||
}
|
}
|
||||||
|
private static String getPort() {
|
||||||
|
String property = SpringContextUtils.getApplicationContext().getEnvironment().getProperty("server.port");
|
||||||
|
if (StringUtils.isEmpty(property)||"0".equals(property)) {
|
||||||
|
property = "8080";
|
||||||
|
}
|
||||||
|
return oConvertUtils.getString(property);
|
||||||
|
}
|
||||||
|
|
||||||
public static String getBaseUrl() {
|
public static String getBaseUrl() {
|
||||||
String basepath = getDomain() + getPath();
|
String basepath = getDomain() + getPath();
|
||||||
|
|
|
@ -162,7 +162,7 @@ public class OpenApiController extends JeecgController<OpenApi, OpenApiService>
|
||||||
String method = openApi.getRequestMethod();
|
String method = openApi.getRequestMethod();
|
||||||
String appkey = request.getHeader("appkey");
|
String appkey = request.getHeader("appkey");
|
||||||
OpenApiAuth openApiAuth = openApiAuthService.getByAppkey(appkey);
|
OpenApiAuth openApiAuth = openApiAuthService.getByAppkey(appkey);
|
||||||
SysUser systemUser = sysUserService.getById(openApiAuth.getSystemUserId());
|
SysUser systemUser = sysUserService.getUserByName(openApiAuth.getCreateBy());
|
||||||
String token = this.getToken(systemUser.getUsername(), systemUser.getPassword());
|
String token = this.getToken(systemUser.getUsername(), systemUser.getPassword());
|
||||||
httpHeaders.put("X-Access-Token", Lists.newArrayList(token));
|
httpHeaders.put("X-Access-Token", Lists.newArrayList(token));
|
||||||
httpHeaders.put("Content-Type",Lists.newArrayList("application/json"));
|
httpHeaders.put("Content-Type",Lists.newArrayList("application/json"));
|
||||||
|
|
|
@ -1,35 +1,22 @@
|
||||||
package org.jeecg.modules.openapi.controller;
|
package org.jeecg.modules.openapi.controller;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
||||||
import org.jeecg.common.api.vo.Result;
|
import org.jeecg.common.api.vo.Result;
|
||||||
import org.jeecg.common.system.base.controller.JeecgController;
|
import org.jeecg.common.system.base.controller.JeecgController;
|
||||||
import org.jeecg.modules.openapi.entity.OpenApiPermission;
|
import org.jeecg.modules.openapi.entity.OpenApiPermission;
|
||||||
import org.jeecg.modules.openapi.service.OpenApiPermissionService;
|
import org.jeecg.modules.openapi.service.OpenApiPermissionService;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/openapi/permission")
|
@RequestMapping("/openapi/permission")
|
||||||
public class OpenApiPermissionController extends JeecgController<OpenApiPermission, OpenApiPermissionService> {
|
public class OpenApiPermissionController extends JeecgController<OpenApiPermission, OpenApiPermissionService> {
|
||||||
|
|
||||||
@PostMapping("add")
|
@PostMapping("add")
|
||||||
public Result add(@RequestBody OpenApiPermission openApiPermission) {
|
public Result add(@RequestBody OpenApiPermission openApiPermission) {
|
||||||
List<String> list = Arrays.asList(openApiPermission.getApiId().split(","));
|
service.add(openApiPermission);
|
||||||
if (CollectionUtil.isNotEmpty(list)) {
|
|
||||||
list.forEach(l->{
|
|
||||||
OpenApiPermission saveApiPermission = new OpenApiPermission();
|
|
||||||
saveApiPermission.setApiId(l);
|
|
||||||
saveApiPermission.setApiAuthId(openApiPermission.getApiAuthId());
|
|
||||||
service.save(saveApiPermission);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return Result.ok("保存成功");
|
return Result.ok("保存成功");
|
||||||
}
|
}
|
||||||
@GetMapping("/list")
|
@GetMapping("/getOpenApi")
|
||||||
public Result list( String apiAuthId) {
|
public Result<?> getOpenApi( String apiAuthId) {
|
||||||
return Result.ok(service.list(Wrappers.<OpenApiPermission>lambdaQuery().eq(OpenApiPermission::getApiAuthId,apiAuthId)));
|
return service.getOpenApi(apiAuthId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,4 +97,9 @@ public class OpenApi implements Serializable {
|
||||||
* 更新时间
|
* 更新时间
|
||||||
*/
|
*/
|
||||||
private Date updateTime;
|
private Date updateTime;
|
||||||
|
/**
|
||||||
|
* 历史已选接口
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String ifCheckBox = "0";
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package org.jeecg.modules.openapi.service;
|
package org.jeecg.modules.openapi.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import org.jeecg.common.api.vo.Result;
|
||||||
|
import org.jeecg.modules.openapi.entity.OpenApi;
|
||||||
import org.jeecg.modules.openapi.entity.OpenApiPermission;
|
import org.jeecg.modules.openapi.entity.OpenApiPermission;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -10,4 +12,8 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
public interface OpenApiPermissionService extends IService<OpenApiPermission> {
|
public interface OpenApiPermissionService extends IService<OpenApiPermission> {
|
||||||
List<OpenApiPermission> findByAuthId(String authId);
|
List<OpenApiPermission> findByAuthId(String authId);
|
||||||
|
|
||||||
|
Result<?> getOpenApi(String apiAuthId);
|
||||||
|
|
||||||
|
void add(OpenApiPermission openApiPermission);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +1,67 @@
|
||||||
package org.jeecg.modules.openapi.service.impl;
|
package org.jeecg.modules.openapi.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.jeecg.common.api.vo.Result;
|
||||||
|
import org.jeecg.modules.openapi.entity.OpenApi;
|
||||||
import org.jeecg.modules.openapi.entity.OpenApiPermission;
|
import org.jeecg.modules.openapi.entity.OpenApiPermission;
|
||||||
import org.jeecg.modules.openapi.mapper.OpenApiPermissionMapper;
|
import org.jeecg.modules.openapi.mapper.OpenApiPermissionMapper;
|
||||||
import org.jeecg.modules.openapi.service.OpenApiPermissionService;
|
import org.jeecg.modules.openapi.service.OpenApiPermissionService;
|
||||||
|
import org.jeecg.modules.openapi.service.OpenApiService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.Collections;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @date 2024/12/19 17:44
|
* @date 2024/12/19 17:44
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class OpenApiPermissionServiceImpl extends ServiceImpl<OpenApiPermissionMapper, OpenApiPermission> implements OpenApiPermissionService {
|
public class OpenApiPermissionServiceImpl extends ServiceImpl<OpenApiPermissionMapper, OpenApiPermission> implements OpenApiPermissionService {
|
||||||
|
@Resource
|
||||||
|
private OpenApiService openApiService;
|
||||||
@Override
|
@Override
|
||||||
public List<OpenApiPermission> findByAuthId(String authId) {
|
public List<OpenApiPermission> findByAuthId(String authId) {
|
||||||
return baseMapper.selectList(Wrappers.lambdaQuery(OpenApiPermission.class).eq(OpenApiPermission::getApiAuthId, authId));
|
return baseMapper.selectList(Wrappers.lambdaQuery(OpenApiPermission.class).eq(OpenApiPermission::getApiAuthId, authId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<?> getOpenApi(String apiAuthId) {
|
||||||
|
List<OpenApi> openApis = openApiService.list();
|
||||||
|
if (CollectionUtil.isEmpty(openApis)) {
|
||||||
|
return Result.error("接口不存在");
|
||||||
|
}
|
||||||
|
List<OpenApiPermission> openApiPermissions = baseMapper.selectList(Wrappers.<OpenApiPermission>lambdaQuery().eq(OpenApiPermission::getApiAuthId, apiAuthId));
|
||||||
|
if (CollectionUtil.isNotEmpty(openApiPermissions)) {
|
||||||
|
Map<String, OpenApi> openApiMap = openApis.stream().collect(Collectors.toMap(OpenApi::getId, o -> o));
|
||||||
|
for (OpenApiPermission openApiPermission : openApiPermissions) {
|
||||||
|
OpenApi openApi = openApiMap.get(openApiPermission.getApiId());
|
||||||
|
if (openApi!=null) {
|
||||||
|
openApi.setIfCheckBox("1");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Result.ok(openApis);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void add(OpenApiPermission openApiPermission) {
|
||||||
|
this.remove(Wrappers.<OpenApiPermission>lambdaQuery().eq(OpenApiPermission::getApiAuthId, openApiPermission.getApiAuthId()));
|
||||||
|
List<String> list = Arrays.asList(openApiPermission.getApiId().split(","));
|
||||||
|
if (CollectionUtil.isNotEmpty(list)) {
|
||||||
|
list.forEach(l->{
|
||||||
|
if (StrUtil.isNotEmpty(l)){
|
||||||
|
OpenApiPermission saveApiPermission = new OpenApiPermission();
|
||||||
|
saveApiPermission.setApiId(l);
|
||||||
|
saveApiPermission.setApiAuthId(openApiPermission.getApiAuthId());
|
||||||
|
this.save(saveApiPermission);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
package org.jeecg.modules.openapi.test;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import org.jeecg.JeecgSystemApplication;
|
||||||
|
import org.junit.jupiter.api.Assertions;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.test.web.servlet.MockMvc;
|
||||||
|
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
|
||||||
|
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||||
|
|
||||||
|
|
||||||
|
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT,classes = JeecgSystemApplication.class)
|
||||||
|
@AutoConfigureMockMvc
|
||||||
|
public class SampleOpenApiTest {
|
||||||
|
@Autowired
|
||||||
|
private MockMvc mockMvc;
|
||||||
|
@Test
|
||||||
|
public void test() throws Exception {
|
||||||
|
String url = "/openapi/call/wYAu6xwg";
|
||||||
|
MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders.get(url)
|
||||||
|
.param("id","a7d7e77e06c84325a40932163adcdaa6")
|
||||||
|
.header("appkey","ak-8CVxh8aYRkzZ0Z2u")
|
||||||
|
.header("signature","3ec15caeaf9b6281d0ab825795f61e2d")
|
||||||
|
.header("timestamp","1747403650402");
|
||||||
|
String result = mockMvc.perform(requestBuilder).andReturn().getResponse().getContentAsString();
|
||||||
|
JSONObject jsonObject = JSON.parseObject(result);
|
||||||
|
Assertions.assertEquals(true, jsonObject.getBoolean("success"));
|
||||||
|
System.out.println(jsonObject);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,7 +9,7 @@ enum Api {
|
||||||
edit='/openapi/auth/edit',
|
edit='/openapi/auth/edit',
|
||||||
apiList= '/openapi/list',
|
apiList= '/openapi/list',
|
||||||
genAKSK = '/openapi/auth/genAKSK',
|
genAKSK = '/openapi/auth/genAKSK',
|
||||||
permissionList='/openapi/permission/list',
|
permissionList='/openapi/permission/getOpenApi',
|
||||||
permissionAdd='/openapi/permission/add',
|
permissionAdd='/openapi/permission/add',
|
||||||
deleteOne = '/openapi/auth/delete',
|
deleteOne = '/openapi/auth/delete',
|
||||||
deleteBatch = '/openapi/auth/deleteBatch',
|
deleteBatch = '/openapi/auth/deleteBatch',
|
||||||
|
|
|
@ -33,7 +33,7 @@ export const columns: BasicColumn[] = [
|
||||||
{
|
{
|
||||||
title: '关联系统用户名',
|
title: '关联系统用户名',
|
||||||
align: "center",
|
align: "center",
|
||||||
dataIndex: 'systemUserId_dictText',
|
dataIndex: 'createBy',
|
||||||
|
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
@ -43,7 +43,7 @@ export const superQuerySchema = {
|
||||||
name: {title: '授权名称',order: 0,view: 'text', type: 'string',},
|
name: {title: '授权名称',order: 0,view: 'text', type: 'string',},
|
||||||
ak: {title: 'AK',order: 1,view: 'text', type: 'string',},
|
ak: {title: 'AK',order: 1,view: 'text', type: 'string',},
|
||||||
sk: {title: 'SK',order: 2,view: 'text', type: 'string',},
|
sk: {title: 'SK',order: 2,view: 'text', type: 'string',},
|
||||||
createBy: {title: '创建人',order: 3,view: 'text', type: 'string',},
|
createBy: {title: '关联系统用户名',order: 3,view: 'text', type: 'string',},
|
||||||
createTime: {title: '创建时间',order: 4,view: 'datetime', type: 'string',},
|
createTime: {title: '创建时间',order: 4,view: 'datetime', type: 'string',},
|
||||||
systemUserId: {title: '关联系统用户名',order: 5,view: 'text', type: 'string',},
|
// systemUserId: {title: '关联系统用户名',order: 5,view: 'text', type: 'string',},
|
||||||
};
|
};
|
||||||
|
|
|
@ -11,9 +11,9 @@
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :lg="6">
|
<a-col :lg="6">
|
||||||
<a-form-item name="systemUserId">
|
<a-form-item name="createBy">
|
||||||
<template #label><span title="关联系统用户名">关联系统用户名</span></template>
|
<template #label><span title="关联系统用户名">关联系统用户名</span></template>
|
||||||
<JSearchSelect dict="sys_user,username,id" v-model:value="queryParam.systemUserId" placeholder="请输入关联系统用户名" allow-clear ></JSearchSelect>
|
<JSearchSelect dict="sys_user,username,username" v-model:value="queryParam.createBy" placeholder="请输入关联系统用户名" allow-clear ></JSearchSelect>
|
||||||
<!-- <a-input placeholder="请输入关联系统用户名" v-model:value="queryParam.systemUserId" allow-clear ></a-input>-->
|
<!-- <a-input placeholder="请输入关联系统用户名" v-model:value="queryParam.systemUserId" allow-clear ></a-input>-->
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
|
@ -62,6 +62,7 @@
|
||||||
<template v-slot:bodyCell="{ column, record, index, text }">
|
<template v-slot:bodyCell="{ column, record, index, text }">
|
||||||
</template>
|
</template>
|
||||||
</BasicTable>
|
</BasicTable>
|
||||||
|
|
||||||
<!-- 表单区域 -->
|
<!-- 表单区域 -->
|
||||||
<OpenApiAuthModal ref="registerModal" @success="handleSuccess"></OpenApiAuthModal>
|
<OpenApiAuthModal ref="registerModal" @success="handleSuccess"></OpenApiAuthModal>
|
||||||
<AuthModal ref="authModal" @success="handleSuccess"></AuthModal>
|
<AuthModal ref="authModal" @success="handleSuccess"></AuthModal>
|
||||||
|
@ -73,11 +74,19 @@
|
||||||
import { BasicTable, TableAction } from '/@/components/Table';
|
import { BasicTable, TableAction } from '/@/components/Table';
|
||||||
import { useListPage } from '/@/hooks/system/useListPage';
|
import { useListPage } from '/@/hooks/system/useListPage';
|
||||||
import { columns, superQuerySchema } from './OpenApiAuth.data';
|
import { columns, superQuerySchema } from './OpenApiAuth.data';
|
||||||
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './OpenApiAuth.api';
|
import {
|
||||||
|
list,
|
||||||
|
deleteOne,
|
||||||
|
batchDelete,
|
||||||
|
getImportUrl,
|
||||||
|
getExportUrl,
|
||||||
|
getGenAKSK
|
||||||
|
} from "./OpenApiAuth.api";
|
||||||
import OpenApiAuthModal from './components/OpenApiAuthModal.vue'
|
import OpenApiAuthModal from './components/OpenApiAuthModal.vue'
|
||||||
import AuthModal from './components/AuthModal.vue'
|
import AuthModal from './components/AuthModal.vue'
|
||||||
import { useUserStore } from '/@/store/modules/user';
|
import { useUserStore } from '/@/store/modules/user';
|
||||||
import JSearchSelect from "../../components/Form/src/jeecg/components/JSearchSelect.vue";
|
import JSearchSelect from "../../components/Form/src/jeecg/components/JSearchSelect.vue";
|
||||||
|
import { saveOrUpdate } from "@/views/openapi/OpenApi.api";
|
||||||
|
|
||||||
const formRef = ref();
|
const formRef = ref();
|
||||||
const queryParam = reactive<any>({});
|
const queryParam = reactive<any>({});
|
||||||
|
@ -157,9 +166,23 @@
|
||||||
*/
|
*/
|
||||||
function handleEdit(record: Recordable) {
|
function handleEdit(record: Recordable) {
|
||||||
registerModal.value.disableSubmit = false;
|
registerModal.value.disableSubmit = false;
|
||||||
|
registerModal.value.authDrawerOpen = true;
|
||||||
registerModal.value.edit(record);
|
registerModal.value.edit(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重置事件
|
||||||
|
* @param record
|
||||||
|
*/
|
||||||
|
async function handleReset(record: Recordable) {
|
||||||
|
const AKSKObj = await getGenAKSK({});
|
||||||
|
record.ak = AKSKObj[0];
|
||||||
|
record.sk = AKSKObj[1];
|
||||||
|
saveOrUpdate(record,true);
|
||||||
|
// handleSuccess;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 详情
|
* 详情
|
||||||
*/
|
*/
|
||||||
|
@ -200,8 +223,12 @@
|
||||||
auth: 'openapi:open_api_auth:edit'
|
auth: 'openapi:open_api_auth:edit'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '编辑',
|
label: '重置',
|
||||||
onClick: handleEdit.bind(null, record),
|
popConfirm: {
|
||||||
|
title: '是否重置AK,SK',
|
||||||
|
confirm: handleReset.bind(null, record),
|
||||||
|
placement: 'topLeft',
|
||||||
|
},
|
||||||
auth: 'openapi:open_api_auth:edit'
|
auth: 'openapi:open_api_auth:edit'
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const [registerTable, { reload, collapseAll, updateTableDataRecord, findTableDataRecord, getDataSource }, { rowSelection, selectedRowKeys }] =
|
const [registerTable, { reload, collapseAll, updateTableDataRecord, findTableDataRecord, getDataSource,setSelectedRowKeys }, { rowSelection, selectedRowKeys,selectedRows }] =
|
||||||
tableContext;
|
tableContext;
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
|
@ -85,13 +85,18 @@
|
||||||
formData.apiAuthId = record.id;
|
formData.apiAuthId = record.id;
|
||||||
// 获取当前已授权的项目
|
// 获取当前已授权的项目
|
||||||
getPermissionList({ apiAuthId: record.id }).then((res) => {
|
getPermissionList({ apiAuthId: record.id }).then((res) => {
|
||||||
if (res && res.length > 0) {
|
if (res.length > 0) {
|
||||||
let list = res.result.records || res.result;
|
let list = res;
|
||||||
let ids = [];
|
let ids = [];
|
||||||
list.forEach((item) => {
|
list.forEach((item) => {
|
||||||
|
if(item.ifCheckBox == "1"){
|
||||||
|
selectedRowKeys.value.push(item.id)
|
||||||
|
selectedRows.value.push(item)
|
||||||
|
setSelectedRowKeys(selectedRowKeys.value);
|
||||||
|
}
|
||||||
ids.push(item.apiId);
|
ids.push(item.apiId);
|
||||||
});
|
});
|
||||||
selectedRowKeys.value = ids;
|
// selectedRowKeys.value = ids;
|
||||||
formData.apiIdList = ids;
|
formData.apiIdList = ids;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -102,8 +107,8 @@
|
||||||
* 提交数据
|
* 提交数据
|
||||||
*/
|
*/
|
||||||
async function submitForm() {
|
async function submitForm() {
|
||||||
if(selectedRowKeys.value.length === 0)
|
// if(selectedRowKeys.value.length === 0)
|
||||||
return emit('ok');
|
// return emit('ok');
|
||||||
try {
|
try {
|
||||||
// 触发表单验证
|
// 触发表单验证
|
||||||
await validate();
|
await validate();
|
||||||
|
@ -131,6 +136,7 @@
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
createMessage.success(res.message);
|
createMessage.success(res.message);
|
||||||
emit('ok');
|
emit('ok');
|
||||||
|
cleanData()
|
||||||
} else {
|
} else {
|
||||||
createMessage.warning(res.message);
|
createMessage.warning(res.message);
|
||||||
}
|
}
|
||||||
|
@ -139,11 +145,16 @@
|
||||||
confirmLoading.value = false;
|
confirmLoading.value = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
const cleanData = () => {
|
||||||
|
selectedRows.value = []
|
||||||
|
selectedRowKeys.value = []
|
||||||
|
}
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
add,
|
add,
|
||||||
edit,
|
edit,
|
||||||
submitForm,
|
submitForm,
|
||||||
|
cleanData
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,27 @@
|
||||||
<template>
|
<template>
|
||||||
<j-modal :title="title" :width="width" :visible="visible" @ok="handleOk" :okButtonProps="{ class: { 'jee-hidden': disableSubmit } }" @cancel="handleCancel" cancelText="关闭">
|
<!-- <j-modal :title="title" :width="width" :visible="visible" @ok="handleOk" :okButtonProps="{ class: { 'jee-hidden': disableSubmit } }" @cancel="handleCancel" cancelText="关闭">-->
|
||||||
|
<div style="position: relative;">
|
||||||
|
<a-drawer
|
||||||
|
v-model:open="authDrawerOpen"
|
||||||
|
class="custom-class"
|
||||||
|
root-class-name="root-class-name"
|
||||||
|
:root-style="{ color: 'blue' }"
|
||||||
|
style="color: red"
|
||||||
|
title="Basic Drawer"
|
||||||
|
placement="right"
|
||||||
|
:width="800"
|
||||||
|
@after-open-change="authDrawerOpenChange"
|
||||||
|
>
|
||||||
<AuthForm ref="registerForm" @ok="submitCallback" :formDisabled="disableSubmit" :formBpm="false"></AuthForm>
|
<AuthForm ref="registerForm" @ok="submitCallback" :formDisabled="disableSubmit" :formBpm="false"></AuthForm>
|
||||||
</j-modal>
|
<a-button type="primary" style="position: absolute;bottom: 2%;right: 2%" @click="handleOk">确定</a-button>
|
||||||
|
</a-drawer>
|
||||||
|
</div>
|
||||||
|
<!-- </j-modal>-->
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, nextTick, defineExpose } from 'vue';
|
import { ref, nextTick, defineExpose } from 'vue';
|
||||||
import AuthForm from './AuthForm.vue'
|
import AuthForm from './AuthForm.vue';
|
||||||
import JModal from '/@/components/Modal/src/JModal/JModal.vue';
|
import JModal from '/@/components/Modal/src/JModal/JModal.vue';
|
||||||
|
|
||||||
const title = ref<string>('');
|
const title = ref<string>('');
|
||||||
|
@ -16,6 +31,12 @@
|
||||||
const registerForm = ref();
|
const registerForm = ref();
|
||||||
const emit = defineEmits(['register', 'success']);
|
const emit = defineEmits(['register', 'success']);
|
||||||
|
|
||||||
|
const authDrawerOpen = ref(false);
|
||||||
|
const authDrawerOpenChange = (val: any) => {
|
||||||
|
if(!val)
|
||||||
|
registerForm.value.cleanData()
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增
|
* 新增
|
||||||
*/
|
*/
|
||||||
|
@ -34,6 +55,7 @@
|
||||||
function edit(record) {
|
function edit(record) {
|
||||||
title.value = disableSubmit.value ? '详情' : '授权';
|
title.value = disableSubmit.value ? '详情' : '授权';
|
||||||
visible.value = true;
|
visible.value = true;
|
||||||
|
authDrawerOpen.value = true;
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
registerForm.value.edit(record);
|
registerForm.value.edit(record);
|
||||||
});
|
});
|
||||||
|
@ -59,6 +81,7 @@
|
||||||
*/
|
*/
|
||||||
function handleCancel() {
|
function handleCancel() {
|
||||||
visible.value = false;
|
visible.value = false;
|
||||||
|
authDrawerOpen.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
|
|
|
@ -19,11 +19,11 @@
|
||||||
<a-input v-model:value="formData.sk" placeholder="请输入SK" disabled allow-clear ></a-input>
|
<a-input v-model:value="formData.sk" placeholder="请输入SK" disabled allow-clear ></a-input>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="24">
|
<!-- <a-col :span="24">-->
|
||||||
<a-form-item label="关联系统用户名" v-bind="validateInfos.systemUserId" id="OpenApiAuthForm-systemUserId" name="systemUserId">
|
<!-- <a-form-item label="关联系统用户名" v-bind="validateInfos.systemUserId" id="OpenApiAuthForm-systemUserId" name="systemUserId">-->
|
||||||
<JSearchSelect dict="sys_user,username,id" v-model:value="formData.systemUserId" placeholder="请输入关联系统用户名" allow-clear ></JSearchSelect>
|
<!-- <JSearchSelect dict="sys_user,username,id" v-model:value="formData.systemUserId" placeholder="请输入关联系统用户名" allow-clear ></JSearchSelect>-->
|
||||||
</a-form-item>
|
<!-- </a-form-item>-->
|
||||||
</a-col>
|
<!-- </a-col>-->
|
||||||
</a-row>
|
</a-row>
|
||||||
</a-form>
|
</a-form>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<j-modal :title="title" :width="width" :visible="visible" @ok="handleOk" :okButtonProps="{ class: { 'jee-hidden': disableSubmit } }" @cancel="handleCancel" cancelText="关闭">
|
<j-modal :title="title" :width="width" :maxHeight="200" :visible="visible" @ok="handleOk" :okButtonProps="{ class: { 'jee-hidden': disableSubmit } }" @cancel="handleCancel" cancelText="关闭">
|
||||||
<OpenApiAuthForm ref="registerForm" @ok="submitCallback" :title="title" :formDisabled="disableSubmit" :formBpm="false"></OpenApiAuthForm>
|
<OpenApiAuthForm ref="registerForm" @ok="submitCallback" :title="title" :formDisabled="disableSubmit" :formBpm="false"></OpenApiAuthForm>
|
||||||
</j-modal>
|
</j-modal>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -75,10 +75,11 @@
|
||||||
});
|
});
|
||||||
//表单配置
|
//表单配置
|
||||||
const [registerForm, { setProps, resetFields, setFieldsValue, validate }] = useForm({
|
const [registerForm, { setProps, resetFields, setFieldsValue, validate }] = useForm({
|
||||||
labelWidth: 150,
|
labelWidth: 100,
|
||||||
schemas: formSchema,
|
schemas: formSchema,
|
||||||
showActionButtonGroup: false,
|
showActionButtonGroup: false,
|
||||||
baseColProps: { span: 24 },
|
baseColProps: { span: 24 },
|
||||||
|
wrapperCol: { span: 24 },
|
||||||
});
|
});
|
||||||
//表单赋值
|
//表单赋值
|
||||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||||
|
|
Loading…
Reference in New Issue