WindChat/windchat-admin/src/main/java/com/windchat/im/web/admin/service/impl/GroupManageService.java

88 lines
2.9 KiB
Java
Raw Normal View History

2019-07-29 23:42:16 +08:00
/**
2020-10-21 23:35:02 +08:00
* Copyright 2018-2028 WindChat Group
*
2019-07-29 23:42:16 +08:00
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
2020-10-21 23:35:02 +08:00
*
* http://www.apache.org/licenses/LICENSE-2.0
*
2019-07-29 23:42:16 +08:00
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
2019-11-27 23:33:33 +08:00
package com.windchat.im.web.admin.service.impl;
2019-07-29 23:42:16 +08:00
import java.util.List;
import java.util.Set;
2019-11-27 23:33:33 +08:00
import com.windchat.im.web.admin.service.IGroupService;
2019-07-29 23:42:16 +08:00
import org.springframework.stereotype.Service;
2019-11-27 23:36:54 +08:00
import com.windchat.im.business.dao.UserGroupDao;
import com.windchat.im.business.impl.site.SiteConfig;
2019-07-31 23:12:30 +08:00
import com.windchat.im.storage.bean.GroupMemberBean;
import com.windchat.im.storage.bean.GroupProfileBean;
import com.windchat.im.storage.bean.SimpleGroupBean;
2019-07-29 23:42:16 +08:00
/**
* @author Sam{@link an.guoyue254@gmail.com}
* @since 2018-04-17 18:59:24
*/
@Service("groupManageService")
public class GroupManageService implements IGroupService {
@Override
public GroupProfileBean getGroupProfile(String siteGroupId) {
GroupProfileBean groupProfile = UserGroupDao.getInstance().getGroupProfile(siteGroupId);
groupProfile.setDefaultState(isUserDefaultGroup(groupProfile.getGroupId()) ? 1 : 0);
return groupProfile;
}
private boolean isUserDefaultGroup(String siteGroupId) {
Set<String> defaultGroups = SiteConfig.getUserDefaultGroups();
if (defaultGroups != null && defaultGroups.size() > 0) {
return defaultGroups.contains(siteGroupId);
}
return false;
}
@Override
public boolean updateGroupProfile(GroupProfileBean bean) {
return UserGroupDao.getInstance().updateGroupProfile(bean);
}
@Override
public List<SimpleGroupBean> getGroupList(int pageNum, int pageSize) {
return UserGroupDao.getInstance().getGroupList(pageNum, pageSize);
}
@Override
public List<GroupMemberBean> getGroupMembers(String siteGroupId, int pageNum, int pageSize) {
return UserGroupDao.getInstance().getGroupMemberList(siteGroupId, pageNum, pageSize);
}
@Override
public List<GroupMemberBean> getNonGroupMembers(String siteGroupId, int pageNum, int pageSize) {
return UserGroupDao.getInstance().getNonGroupMemberList(siteGroupId, pageNum, pageSize);
}
@Override
public boolean addGroupMembers(String siteGroupId, List<String> newMemberList) {
return UserGroupDao.getInstance().addGroupMember(null, siteGroupId, newMemberList);
}
@Override
public boolean removeGroupMembers(String siteGroupId, List<String> groupMemberList) {
return UserGroupDao.getInstance().deleteGroupMember(siteGroupId, groupMemberList);
}
@Override
public boolean dismissGroup(String siteGroupId) {
return UserGroupDao.getInstance().deleteGroup(siteGroupId);
}
}