mirror of https://github.com/certd/certd
chore:
parent
de43391e4c
commit
c222b702c3
|
@ -55,7 +55,7 @@ export default defineComponent({
|
|||
async function refreshTarget(value) {
|
||||
selectedId.value = value;
|
||||
if (value > 0) {
|
||||
target.value = await api.GetObj(value);
|
||||
target.value = await api.GetSimpleInfo(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,14 @@ export function createAccessApi(from = "user") {
|
|||
});
|
||||
},
|
||||
|
||||
async GetSimpleInfo(id: number) {
|
||||
return await request({
|
||||
url: apiPrefix + "/simpleInfo",
|
||||
method: "post",
|
||||
params: { id }
|
||||
});
|
||||
},
|
||||
|
||||
async GetSecretPlain(id: number, key: string) {
|
||||
return await request({
|
||||
url: apiPrefix + "/getSecretPlain",
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { ALL, Body, Controller, Inject, Post, Provide, Query } from '@midwayjs/core';
|
||||
import { Constants, CrudController } from '@certd/lib-server';
|
||||
import { AccessService } from '../../modules/pipeline/service/access-service.js';
|
||||
import { AuthService } from '../../modules/sys/authority/service/auth-service.js';
|
||||
|
||||
/**
|
||||
* 授权
|
||||
|
@ -10,6 +11,8 @@ import { AccessService } from '../../modules/pipeline/service/access-service.js'
|
|||
export class AccessController extends CrudController<AccessService> {
|
||||
@Inject()
|
||||
service: AccessService;
|
||||
@Inject()
|
||||
authService: AuthService;
|
||||
|
||||
getService(): AccessService {
|
||||
return this.service;
|
||||
|
@ -84,4 +87,11 @@ export class AccessController extends CrudController<AccessService> {
|
|||
}
|
||||
return this.ok(dict);
|
||||
}
|
||||
|
||||
@Post('/simpleInfo', { summary: Constants.per.authOnly })
|
||||
async simpleInfo(@Query('id') id: number) {
|
||||
await this.authService.checkEntityUserId(this.ctx, this.service, id);
|
||||
const res = await this.service.getSimpleInfo(id);
|
||||
return this.ok(res);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -107,6 +107,18 @@ export class AccessService extends BaseService<AccessEntity> {
|
|||
return await super.update(param);
|
||||
}
|
||||
|
||||
async getSimpleInfo(id: number) {
|
||||
const entity = await this.info(id);
|
||||
if (entity == null) {
|
||||
throw new ValidateException('该授权配置不存在,请确认是否已被删除');
|
||||
}
|
||||
return {
|
||||
id: entity.id,
|
||||
name: entity.name,
|
||||
userId: entity.userId,
|
||||
};
|
||||
}
|
||||
|
||||
async getAccessById(id: any, checkUserId: boolean, userId?: number): Promise<any> {
|
||||
const entity = await this.info(id);
|
||||
if (entity == null) {
|
||||
|
|
|
@ -27,6 +27,7 @@ export class AuthService {
|
|||
}
|
||||
}
|
||||
|
||||
//管理员有权限查看其他用户的数据
|
||||
async checkEntityUserId(ctx: any, service: any, id: any = 0, userKey = 'userId') {
|
||||
const isAdmin = await this.isAdmin(ctx);
|
||||
if (isAdmin) {
|
||||
|
|
Loading…
Reference in New Issue