기능 추가 :: 새그룹 추가 로직 구현.
This commit is contained in:
parent
46753d2f67
commit
f3f8059564
|
@ -17,6 +17,7 @@ import { UserInfo, GroupDetailData } from '@ucap-webmessenger/protocol-sync';
|
||||||
import * as AppStore from '@app/store';
|
import * as AppStore from '@app/store';
|
||||||
import * as ChatStore from '@app/store/messenger/chat';
|
import * as ChatStore from '@app/store/messenger/chat';
|
||||||
import * as QueryStore from '@app/store/messenger/query';
|
import * as QueryStore from '@app/store/messenger/query';
|
||||||
|
import * as SyncStore from '@app/store/messenger/sync';
|
||||||
import { NGXLogger } from 'ngx-logger';
|
import { NGXLogger } from 'ngx-logger';
|
||||||
import { Company } from '@ucap-webmessenger/api-external';
|
import { Company } from '@ucap-webmessenger/api-external';
|
||||||
import { SessionStorageService } from '@ucap-webmessenger/web-storage';
|
import { SessionStorageService } from '@ucap-webmessenger/web-storage';
|
||||||
|
@ -174,14 +175,20 @@ export class GroupComponent implements OnInit, OnDestroy {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!!result && !!result.choice && result.choice) {
|
if (!!result && !!result.choice && result.choice) {
|
||||||
this.logger.debug(result);
|
|
||||||
if (
|
if (
|
||||||
!!result.selectedUserList &&
|
!!result.selectedUserList &&
|
||||||
result.selectedUserList.length > 0
|
result.selectedUserList.length > 0 &&
|
||||||
|
result.groupName.trim().length > 0
|
||||||
) {
|
) {
|
||||||
// const userSeqs: number[] = [];
|
const userSeqs: number[] = [];
|
||||||
// result.selectedUserList.map(user => userSeqs.push(user.seq));
|
result.selectedUserList.map(user => userSeqs.push(user.seq));
|
||||||
// this.store.dispatch(ChatStore.openRoom({ userSeqList: userSeqs }));
|
|
||||||
|
this.store.dispatch(
|
||||||
|
SyncStore.createGroupAndBuddy({
|
||||||
|
groupName: result.groupName,
|
||||||
|
trgtUserSeq: userSeqs
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,7 +130,6 @@ export class OrganizationComponent implements OnInit {
|
||||||
isChecked: boolean;
|
isChecked: boolean;
|
||||||
userInfo: UserInfo | UserInfoSS | UserInfoF | UserInfoDN;
|
userInfo: UserInfo | UserInfoSS | UserInfoF | UserInfoDN;
|
||||||
}) {
|
}) {
|
||||||
console.log(this.selectedUserList);
|
|
||||||
this.checkUser.emit(params);
|
this.checkUser.emit(params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,15 @@ import {
|
||||||
InfoRequest
|
InfoRequest
|
||||||
} from '@ucap-webmessenger/protocol-room';
|
} from '@ucap-webmessenger/protocol-room';
|
||||||
import { Info } from '@ucap-webmessenger/protocol-event';
|
import { Info } from '@ucap-webmessenger/protocol-event';
|
||||||
|
import {
|
||||||
|
AddResponse as GroupAddResponse,
|
||||||
|
UpdateRequest as GroupUpdateRequest,
|
||||||
|
UpdateResponse as GroupUpdateResponse
|
||||||
|
} from '@ucap-webmessenger/protocol-group';
|
||||||
|
import {
|
||||||
|
AddRequest as BuddyAddRequest,
|
||||||
|
AddResponse as BuddyAddResponse
|
||||||
|
} from '@ucap-webmessenger/protocol-buddy';
|
||||||
|
|
||||||
export const buddy2 = createAction(
|
export const buddy2 = createAction(
|
||||||
'[Messenger::Sync] Buddy2',
|
'[Messenger::Sync] Buddy2',
|
||||||
|
@ -101,3 +110,72 @@ export const updateUnreadCount = createAction(
|
||||||
noReadCnt?: number;
|
noReadCnt?: number;
|
||||||
}>()
|
}>()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/** 새그룹(Only Group) 추가 */
|
||||||
|
export const createGroup = createAction(
|
||||||
|
'[Messenger::Sync] Group Create',
|
||||||
|
props<{
|
||||||
|
groupName: string;
|
||||||
|
}>()
|
||||||
|
);
|
||||||
|
|
||||||
|
export const createGroupSuccess = createAction(
|
||||||
|
'[Messenger::Sync] Group Create Success',
|
||||||
|
props<GroupAddResponse>()
|
||||||
|
);
|
||||||
|
|
||||||
|
export const createGroupFailure = createAction(
|
||||||
|
'[Messenger::Sync] Group Create Failure',
|
||||||
|
props<{ error: any }>()
|
||||||
|
);
|
||||||
|
|
||||||
|
/** 새그룹 추가 & 그룹원 추가 */
|
||||||
|
export const createGroupAndBuddy = createAction(
|
||||||
|
'[Messenger::Sync] Group & Buddy Create',
|
||||||
|
props<{
|
||||||
|
groupName: string;
|
||||||
|
trgtUserSeq: number[];
|
||||||
|
}>()
|
||||||
|
);
|
||||||
|
|
||||||
|
export const createGroupAndBuddySuccess = createAction(
|
||||||
|
'[Messenger::Sync] Group & Buddy Create Success',
|
||||||
|
props<GroupAddResponse>()
|
||||||
|
);
|
||||||
|
|
||||||
|
export const createGroupAndBuddyFailure = createAction(
|
||||||
|
'[Messenger::Sync] Group & Buddy Create Failure',
|
||||||
|
props<{ error: any }>()
|
||||||
|
);
|
||||||
|
|
||||||
|
/** 동료 추가 */
|
||||||
|
export const addBuddy = createAction(
|
||||||
|
'[Messenger::Sync] Buddy Add',
|
||||||
|
props<BuddyAddRequest>()
|
||||||
|
);
|
||||||
|
|
||||||
|
export const addBuddySuccess = createAction(
|
||||||
|
'[Messenger::Sync] Buddy Add Success',
|
||||||
|
props<BuddyAddResponse>()
|
||||||
|
);
|
||||||
|
|
||||||
|
export const addBuddyFailure = createAction(
|
||||||
|
'[Messenger::Sync] Buddy Add Failure',
|
||||||
|
props<{ error: any }>()
|
||||||
|
);
|
||||||
|
|
||||||
|
/** 그룹원 업데이트 */
|
||||||
|
export const updateGroup = createAction(
|
||||||
|
'[Messenger::Sync] Group Update',
|
||||||
|
props<GroupUpdateRequest>()
|
||||||
|
);
|
||||||
|
|
||||||
|
export const updateGroupSuccess = createAction(
|
||||||
|
'[Messenger::Sync] Group Update Success',
|
||||||
|
props<GroupUpdateResponse>()
|
||||||
|
);
|
||||||
|
|
||||||
|
export const updateGroupFailure = createAction(
|
||||||
|
'[Messenger::Sync] Group Update Failure',
|
||||||
|
props<{ error: any }>()
|
||||||
|
);
|
||||||
|
|
|
@ -13,7 +13,7 @@ import {
|
||||||
} from 'rxjs/operators';
|
} from 'rxjs/operators';
|
||||||
|
|
||||||
import { Store, select } from '@ngrx/store';
|
import { Store, select } from '@ngrx/store';
|
||||||
|
import { Dictionary } from '@ngrx/entity';
|
||||||
import { NGXLogger } from 'ngx-logger';
|
import { NGXLogger } from 'ngx-logger';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
@ -29,10 +29,18 @@ import {
|
||||||
updateRoomForNewEventMessage,
|
updateRoomForNewEventMessage,
|
||||||
refreshRoom,
|
refreshRoom,
|
||||||
refreshRoomFailure,
|
refreshRoomFailure,
|
||||||
refreshRoomSuccess
|
refreshRoomSuccess,
|
||||||
|
createGroup,
|
||||||
|
createGroupSuccess,
|
||||||
|
createGroupFailure,
|
||||||
|
createGroupAndBuddy,
|
||||||
|
addBuddy,
|
||||||
|
addBuddyFailure,
|
||||||
|
updateGroup,
|
||||||
|
updateGroupFailure
|
||||||
} from './actions';
|
} from './actions';
|
||||||
import { SessionStorageService } from '@ucap-webmessenger/web-storage';
|
import { SessionStorageService } from '@ucap-webmessenger/web-storage';
|
||||||
|
import { LoginInfo, KEY_LOGIN_INFO } from '@app/types';
|
||||||
import {
|
import {
|
||||||
SyncProtocolService,
|
SyncProtocolService,
|
||||||
SSVC_TYPE_SYNC_BUDDY2_DATA,
|
SSVC_TYPE_SYNC_BUDDY2_DATA,
|
||||||
|
@ -53,7 +61,6 @@ import {
|
||||||
RoomUserDetailData,
|
RoomUserDetailData,
|
||||||
RoomResponse
|
RoomResponse
|
||||||
} from '@ucap-webmessenger/protocol-sync';
|
} from '@ucap-webmessenger/protocol-sync';
|
||||||
import { regViewSuccess } from '@app/store/messenger/option';
|
|
||||||
import {
|
import {
|
||||||
RoomInfo,
|
RoomInfo,
|
||||||
UserInfoShort,
|
UserInfoShort,
|
||||||
|
@ -67,12 +74,19 @@ import {
|
||||||
UserData,
|
UserData,
|
||||||
SSVC_TYPE_ROOM_INFO_RES
|
SSVC_TYPE_ROOM_INFO_RES
|
||||||
} from '@ucap-webmessenger/protocol-room';
|
} from '@ucap-webmessenger/protocol-room';
|
||||||
import { LoginInfo, KEY_LOGIN_INFO } from '@app/types';
|
import { LoginResponse } from '@ucap-webmessenger/protocol-authentication';
|
||||||
|
import {
|
||||||
|
GroupProtocolService,
|
||||||
|
AddResponse as GroupAddResponse,
|
||||||
|
UpdateResponse as GroupUpdateResponse
|
||||||
|
} from '@ucap-webmessenger/protocol-group';
|
||||||
|
import {
|
||||||
|
BuddyProtocolService,
|
||||||
|
AddResponse as BuddyAddResponse
|
||||||
|
} from '@ucap-webmessenger/protocol-buddy';
|
||||||
|
|
||||||
import * as ChatStore from '@app/store/messenger/chat';
|
import * as ChatStore from '@app/store/messenger/chat';
|
||||||
import * as RoomStore from '@app/store/messenger/room';
|
import * as RoomStore from '@app/store/messenger/room';
|
||||||
import { Dictionary } from '@ngrx/entity';
|
|
||||||
import { LoginResponse } from '@ucap-webmessenger/protocol-authentication';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class Effects {
|
export class Effects {
|
||||||
|
@ -390,11 +404,128 @@ export class Effects {
|
||||||
{ dispatch: false }
|
{ dispatch: false }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
createGroup$ = createEffect(() =>
|
||||||
|
this.actions$.pipe(
|
||||||
|
ofType(createGroup),
|
||||||
|
map(action => action.groupName),
|
||||||
|
exhaustMap(req => {
|
||||||
|
return this.groupProtocolService
|
||||||
|
.add({
|
||||||
|
groupName: req
|
||||||
|
})
|
||||||
|
.pipe(
|
||||||
|
map((res: GroupAddResponse) => {
|
||||||
|
return createGroupSuccess(res);
|
||||||
|
}),
|
||||||
|
catchError(error => of(createGroupFailure({ error })))
|
||||||
|
);
|
||||||
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
createGroupAndBuddy$ = createEffect(() =>
|
||||||
|
this.actions$.pipe(
|
||||||
|
ofType(createGroupAndBuddy),
|
||||||
|
withLatestFrom(
|
||||||
|
this.store.pipe(
|
||||||
|
select(
|
||||||
|
(state: any) =>
|
||||||
|
state.messenger.sync.buddy2.entities as Dictionary<UserInfo>
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
exhaustMap(([action, buddyList]) => {
|
||||||
|
return this.groupProtocolService
|
||||||
|
.add({
|
||||||
|
groupName: action.groupName
|
||||||
|
})
|
||||||
|
.pipe(
|
||||||
|
map((res: GroupAddResponse) => {
|
||||||
|
return createGroupSuccess(res);
|
||||||
|
}),
|
||||||
|
tap(res => {
|
||||||
|
if (!!action.trgtUserSeq && action.trgtUserSeq.length > 0) {
|
||||||
|
// 그룹원으로 추가할 대상이 유입.
|
||||||
|
|
||||||
|
// STEP 1 : 그룹원으로 등록될 대상중 Buddy 등록해야 하는 인원 수집.
|
||||||
|
const addBuddyList: number[] = [];
|
||||||
|
action.trgtUserSeq.forEach(item => {
|
||||||
|
if (!buddyList[item]) {
|
||||||
|
addBuddyList.push(item);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (addBuddyList.length > 0) {
|
||||||
|
this.logger.debug('add : ', addBuddyList);
|
||||||
|
this.store.dispatch(addBuddy({ userSeqs: addBuddyList }));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.logger.debug('group buddy : ', action.trgtUserSeq);
|
||||||
|
this.store.dispatch(
|
||||||
|
updateGroup({
|
||||||
|
// 0: 동료그룹SEQ(n)
|
||||||
|
groupSeq: res.groupSeq,
|
||||||
|
groupName: res.groupName,
|
||||||
|
userSeqs: action.trgtUserSeq
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
catchError(error => of(createGroupFailure({ error })))
|
||||||
|
);
|
||||||
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
addBuddy$ = createEffect(() =>
|
||||||
|
this.actions$.pipe(
|
||||||
|
ofType(addBuddy),
|
||||||
|
withLatestFrom(
|
||||||
|
this.store.pipe(
|
||||||
|
select((state: any) => state.messenger.sync.buddy2.syncDate as string)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
exhaustMap(([req, syncDate]) =>
|
||||||
|
this.buddyProtocolService.add(req).pipe(
|
||||||
|
map((res: BuddyAddResponse) => {
|
||||||
|
return buddy2({
|
||||||
|
syncDate
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
catchError(error => of(addBuddyFailure({ error })))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
updateGroup$ = createEffect(() =>
|
||||||
|
this.actions$.pipe(
|
||||||
|
ofType(updateGroup),
|
||||||
|
withLatestFrom(
|
||||||
|
this.store.pipe(
|
||||||
|
select((state: any) => state.messenger.sync.group2.syncDate as string)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
exhaustMap(([req, syncDate]) =>
|
||||||
|
this.groupProtocolService.update2(req).pipe(
|
||||||
|
map((res: GroupUpdateResponse) => {
|
||||||
|
return group2({
|
||||||
|
syncDate
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
catchError(error => of(updateGroupFailure({ error })))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private actions$: Actions,
|
private actions$: Actions,
|
||||||
private store: Store<any>,
|
private store: Store<any>,
|
||||||
private syncProtocolService: SyncProtocolService,
|
private syncProtocolService: SyncProtocolService,
|
||||||
private roomProtocolService: RoomProtocolService,
|
private roomProtocolService: RoomProtocolService,
|
||||||
|
private groupProtocolService: GroupProtocolService,
|
||||||
|
private buddyProtocolService: BuddyProtocolService,
|
||||||
private sessionStorageService: SessionStorageService,
|
private sessionStorageService: SessionStorageService,
|
||||||
private logger: NGXLogger
|
private logger: NGXLogger
|
||||||
) {}
|
) {}
|
||||||
|
|
|
@ -13,11 +13,14 @@ import {
|
||||||
roomSuccess,
|
roomSuccess,
|
||||||
updateRoomForNewEventMessage,
|
updateRoomForNewEventMessage,
|
||||||
refreshRoomSuccess,
|
refreshRoomSuccess,
|
||||||
updateUnreadCount
|
updateUnreadCount,
|
||||||
|
createGroupSuccess,
|
||||||
|
addBuddySuccess
|
||||||
} from './actions';
|
} from './actions';
|
||||||
import {
|
import {
|
||||||
RoomUserDetailData,
|
RoomUserDetailData,
|
||||||
RoomUserData
|
RoomUserData,
|
||||||
|
GroupDetailData
|
||||||
} from '@ucap-webmessenger/protocol-sync';
|
} from '@ucap-webmessenger/protocol-sync';
|
||||||
|
|
||||||
import * as AuthenticationStore from '@app/store/account/authentication';
|
import * as AuthenticationStore from '@app/store/account/authentication';
|
||||||
|
@ -29,7 +32,7 @@ export const reducer = createReducer(
|
||||||
on(buddy2Success, (state, action) => {
|
on(buddy2Success, (state, action) => {
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
buddy2: adapterBuddy2.addAll(action.buddyList, {
|
buddy2: adapterBuddy2.upsertMany(action.buddyList, {
|
||||||
...state.buddy2,
|
...state.buddy2,
|
||||||
syncDate: action.syncDate
|
syncDate: action.syncDate
|
||||||
})
|
})
|
||||||
|
@ -39,7 +42,7 @@ export const reducer = createReducer(
|
||||||
on(group2Success, (state, action) => {
|
on(group2Success, (state, action) => {
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
group2: adapterGroup2.addAll(action.groupList, {
|
group2: adapterGroup2.upsertMany(action.groupList, {
|
||||||
...state.group2,
|
...state.group2,
|
||||||
syncDate: action.syncDate
|
syncDate: action.syncDate
|
||||||
})
|
})
|
||||||
|
@ -185,9 +188,19 @@ export const reducer = createReducer(
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
|
|
||||||
on(AuthenticationStore.logout, (state, action) => {
|
/** 새 그룹 추가. */
|
||||||
|
on(createGroupSuccess, (state, action) => {
|
||||||
|
const groupInfo: GroupDetailData = {
|
||||||
|
seq: action.groupSeq,
|
||||||
|
name: action.groupName,
|
||||||
|
isActive: true,
|
||||||
|
userSeqs: []
|
||||||
|
};
|
||||||
return {
|
return {
|
||||||
...initialState
|
...state,
|
||||||
|
group2: adapterGroup2.addOne(groupInfo, {
|
||||||
|
...state.group2
|
||||||
|
})
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user