@@ -24,16 +24,16 @@ export class RoleResourcesService {
2424 * @return {* }
2525 */
2626 async dispatchResourcesApi ( req : RoleResourcesDto ) : Promise < string > {
27- const { roleId } = req ;
27+ const { roleId, type } = req ;
2828 // 处理如果没传递的时候直接清空
2929 if ( ! req . resourceList . length ) {
30- await this . roleResourcesRepository . delete ( { roleId } ) ;
30+ await this . roleResourcesRepository . delete ( { roleId, type } ) ;
3131 return '分配资源成功' ;
3232 }
3333 // 根据当前角色查询之前的资源
3434 const roleResourcesEntity : Pick < RoleResourcesEntity , 'resourcesId' > [ ] =
3535 await this . roleResourcesRepository . find ( {
36- where : { roleId } ,
36+ where : { roleId, type } ,
3737 select : [ 'resourcesId' ] ,
3838 } ) ;
3939 if ( roleResourcesEntity . length ) {
@@ -53,6 +53,7 @@ export class RoleResourcesService {
5353 where : {
5454 roleId : req . roleId ,
5555 resourcesId : In ( roleResourceDeleteList ) ,
56+ type,
5657 } ,
5758 select : [ 'id' ] ,
5859 } ) ;
@@ -68,6 +69,7 @@ export class RoleResourcesService {
6869 return {
6970 resourcesId : item ,
7071 roleId : req . roleId ,
72+ type,
7173 } ;
7274 } ) ;
7375 // 创建
@@ -92,6 +94,7 @@ export class RoleResourcesService {
9294 return {
9395 roleId : req . roleId ,
9496 resourcesId : item ,
97+ type,
9598 } ;
9699 } ) ;
97100 const data1 = this . roleResourcesRepository . create ( data ) ;
@@ -106,12 +109,13 @@ export class RoleResourcesService {
106109 * @LastEditors : 水痕
107110 * @Description : 根据角色获取授权的资源
108111 * @param {number } roleId
112+ * @param {number } type
109113 * @return {* }
110114 */
111- async getResourceByRoleIdApi ( roleId : number ) : Promise < ResourcesEntity [ ] > {
115+ async getResourceByRoleIdApi ( roleId : number , type : number ) : Promise < ResourcesEntity [ ] > {
112116 const roleResourcesEntity : Pick < RoleResourcesEntity , 'resourcesId' > [ ] =
113117 await this . roleResourcesRepository . find ( {
114- where : { roleId } ,
118+ where : { roleId, type } ,
115119 select : [ 'resourcesId' ] ,
116120 } ) ;
117121 const resourceIdList : number [ ] = roleResourcesEntity . map ( ( item ) => item . resourcesId ) ;
0 commit comments