All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.gitee.huangguiming.Imcode.service.impl.GroupServiceImpl Maven / Gradle / Ivy

There is a newer version: 1.0.4
Show newest version
package io.gitee.huangguiming.Imcode.service.impl;

import io.gitee.huangguiming.Imcode.exception.IMException;
import io.gitee.huangguiming.Imcode.param.CreateGroupAbstractParam;
import io.gitee.huangguiming.Imcode.param.PullGroupsParam;
import io.gitee.huangguiming.Imcode.responses.IMBashResponse;
import io.gitee.huangguiming.Imcode.responses.IMCreateGroupResponse;
import io.gitee.huangguiming.Imcode.responses.IMGetAllGroupResponses;
import io.gitee.huangguiming.Imcode.service.GroupService;
import io.gitee.huangguiming.Imcode.service.IMService;
import io.gitee.huangguiming.Imcode.utils.GsonParser;
import io.gitee.huangguiming.Imcode.utils.IMGsonBuilder;
import lombok.RequiredArgsConstructor;

import java.util.HashMap;
import java.util.Map;

import static io.gitee.huangguiming.Imcode.apiUrl.IMAPiAddressUrl.Group.*;


@RequiredArgsConstructor
public class GroupServiceImpl implements GroupService {

    private final IMService imService;

    @Override
    public IMGetAllGroupResponses getGroups() throws IMException {
        return IMGetAllGroupResponses.fromJson(this.imService.post(SELECT_ALL_GROUP.getUrl(),"{}"));
    }

    @Override
    public IMGetAllGroupResponses getGroups(PullGroupsParam param) throws IMException {
        return IMGetAllGroupResponses.fromJson(this.imService.post(SELECT_ALL_GROUP.getUrl(),param));
    }

    @Override
    public IMCreateGroupResponse createGroup(CreateGroupAbstractParam param) throws IMException {
       String response = this.imService.post(CREATE_GROUP.getUrl(),param);
       return IMCreateGroupResponse.fromJson(response);
    }

    @Override
    public Integer getLiveOnlineNum(String GroupId) throws IMException {
        Map map = new HashMap<>(1);
        map.put("GroupId",GroupId);
        String response =  this.imService.post(GET_ONLINE_MEMBER_NUM.getUrl(), IMGsonBuilder.create().toJson(map));
        return Integer.valueOf(GsonParser.parse(response).get("OnlineMemberNum").toString());
    }

    @Override
    public String dissolutionGroup(String GroupId) throws IMException {
        Map map = new HashMap<>(1);
        map.put("GroupId",GroupId);
        String response =  this.imService.post(DESTROY_GROUP.getUrl(), IMGsonBuilder.create().toJson(map));
        return GsonParser.parse(response).get("ActionStatus").toString();
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy