HomeService.java
1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package cn.com.glsx.modules.service;
import cn.com.glsx.common.Constants;
import com.alibaba.fastjson.JSONObject;
import com.glsx.plat.core.web.R;
import com.lumi.opencloud.common.AiotConfig;
import com.lumi.opencloud.common.ResponseMsg;
import com.lumi.opencloud.manager.v1.PositionManager;
import com.lumi.opencloud.model.v1.request.PositionQueryRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
/**
* @author zhouhaibao
* @date 2021/4/20 20:56
*/
@Slf4j
@Service
public class HomeService {
@Value("${aqara.clientId}")
private String clientId;
@Value("${aqara.doapi}")
private String domain;
public R getHome(String token){
AiotConfig aiotConfig = new AiotConfig();
aiotConfig.setAppId(clientId);
aiotConfig.setAccessToken(token);
aiotConfig.setDomain(domain);
ResponseMsg responseMsg = PositionManager.positionQuery(aiotConfig,new PositionQueryRequest());
if (responseMsg != null && Constants.AQARA_RETURN_SUCCESS_CODE == responseMsg.getCode()) {
return R.ok(JSONObject.toJSONString(responseMsg));
}
return R.error(responseMsg.getMessage());
}
}