Commit c1fd236c by 周海宝

Merge branch 'dev' into 'master'

Dev

See merge request !6
2 parents 6608df00 d2638498
......@@ -85,4 +85,28 @@ public class DeviceController {
public R instructionIssue(@PathVariable String device_id, @RequestBody String insjson) {
return deviceService.instructionIssue(device_id, insjson);
}
/**
* 获取红外设备下的设备列表
*
* @return
*/
@RequestMapping(value = "/infrareds/{infrared_id}/remotes", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "获取红外设备下面绑定的遥控器列表")
public R findRemotes(@PathVariable String infrared_id) {
return deviceService.findRemotes(infrared_id);
}
/**
* 下发红外指令
*
* @return
*/
@RequestMapping(value = "/infrareds/{infrared_id}/{remote_id}/scenes/command", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "下发红外指令")
public R instructionInfIssue(@PathVariable String infrared_id,@PathVariable String remote_id,@RequestBody String insjson) {
return deviceService.instructionInfIssue(infrared_id,remote_id,insjson);
}
}
......@@ -49,4 +49,16 @@ public class UserController {
public R getUserInfo(@PathVariable String id) {
return userService.getUserInfo(id);
}
/**
* 查询所有用户信息
*
* @return 用户信息
*/
@RequestMapping(value = "/users", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "获取用户列表")
public R getAllUser() {
return userService.getAllUser();
}
}
......@@ -30,6 +30,12 @@ public class DeviceService {
@Value("${tuya.instructionIssue}")
private String instructionIssue;
@Value("${tuya.findRemotes}")
private String findRemotes;
@Value("${tuya.instructionInfIssue}")
private String instructionInfIssue;
@Autowired
private SendRequestService sendRequestService;
......@@ -39,7 +45,7 @@ public class DeviceService {
String result = responseBody.getResult();
return R.ok(result);
}
String errorMessage = responseBody == null ? "调用涂鸦失败" : responseBody.getMessage();
String errorMessage = responseBody == null ? "调用涂鸦失败" : responseBody.getMsg();
return R.error(errorMessage);
}
......@@ -49,7 +55,7 @@ public class DeviceService {
String result = responseBody.getResult();
return R.ok(result);
}
String errorMessage = responseBody == null ? "调用涂鸦失败" : responseBody.getMessage();
String errorMessage = responseBody == null ? "调用涂鸦失败" : responseBody.getMsg();
return R.error(errorMessage);
}
......@@ -59,7 +65,7 @@ public class DeviceService {
String result = responseBody.getResult();
return R.ok(result);
}
String errorMessage = responseBody == null ? "调用涂鸦失败" : responseBody.getMessage();
String errorMessage = responseBody == null ? "调用涂鸦失败" : responseBody.getMsg();
return R.error(errorMessage);
}
......@@ -69,7 +75,7 @@ public class DeviceService {
String result = responseBody.getResult();
return R.ok(result);
}
String errorMessage = responseBody == null ? "调用涂鸦失败" : responseBody.getMessage();
String errorMessage = responseBody == null ? "调用涂鸦失败" : responseBody.getMsg();
return R.error(errorMessage);
}
......@@ -78,8 +84,26 @@ public class DeviceService {
if (responseBody != null && responseBody.isSuccess()) {
return R.ok();
}
String errorMessage = responseBody == null ? "调用涂鸦失败" : responseBody.getMessage();
String errorMessage = responseBody == null ? "调用涂鸦失败" : responseBody.getMsg();
return R.error(errorMessage);
}
public R findRemotes(String infrared_id) {
ResponseBody responseBody = sendRequestService.sendRequestGet(findRemotes.replace("{infrared_id}", infrared_id));
if (responseBody != null && responseBody.isSuccess()) {
String result = responseBody.getResult();
return R.ok(result);
}
String errorMessage = responseBody == null ? "调用涂鸦失败" : responseBody.getMsg();
return R.error(errorMessage);
}
public R instructionInfIssue(String infrared_id, String remote_id, String insjson) {
ResponseBody responseBody = sendRequestService.sendRequestPost(instructionInfIssue.replace("{remote_id}", remote_id).replace("{infrared_id}", infrared_id), insjson);
if (responseBody != null && responseBody.isSuccess()) {
return R.ok();
}
String errorMessage = responseBody == null ? "调用涂鸦失败" : responseBody.getMsg();
return R.error(errorMessage);
}
}
......@@ -2,11 +2,9 @@ package cn.com.glsx.modules.service;
import cn.com.glsx.modules.model.param.ResponseBody;
import cn.com.glsx.modules.model.param.UserBo;
import cn.com.glsx.modules.model.param.UserInfo;
import com.alibaba.fastjson.JSONObject;
import com.glsx.plat.core.web.R;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
......@@ -26,6 +24,9 @@ public class UserService {
@Value("${tuya.getUserInfoUrl}")
private String getUserInfoUrl;
@Value("${tuya.getAllUserUrl}")
private String getAllUserUrl;
@Autowired
private SendRequestService sendRequestService;
......@@ -60,4 +61,18 @@ public class UserService {
return R.error(errorMessage);
}
/**
* 获取所有用户信息
*
*/
public R getAllUser() {
ResponseBody responseBody = sendRequestService.sendRequestGet(getAllUserUrl);
if (responseBody != null && responseBody.isSuccess()) {
String result = responseBody.getResult() + "";
return R.ok(result);
}
String errorMessage = responseBody == null ? "调用涂鸦失败" : responseBody.getMessage();
return R.error(errorMessage);
}
}
......@@ -13,29 +13,6 @@ import javax.xml.bind.annotation.adapters.HexBinaryAdapter;
public class TuyaUtils {
/**
* 获取令牌签名
*
* @param time 时间戳
* @param client_id client_id
* @param secret secret
* @return
*/
public static String getLoginSign(long time, String client_id, String secret) {
String hash=null;
try {
String message = client_id + time;
Mac sha256_HMAC = Mac.getInstance("HmacSHA256");
SecretKeySpec secret_key = new SecretKeySpec(secret.getBytes(), "HmacSHA256");
sha256_HMAC.init(secret_key);
byte[] bytes = sha256_HMAC.doFinal(message.getBytes());
hash = new HexBinaryAdapter().marshal(bytes).toUpperCase();
} catch (Exception e) {
e.printStackTrace();
}
return hash;
}
/**
* 获取业务的签名
*
* @param time 时间戳
......
......@@ -9,7 +9,7 @@ spring.cloud.nacos.config.server-addr=192.168.0.63:8848
#nacos配置id,完整dataId=${spring.cloud.nacos.config.prefix}-${spring.profiles.active}.${file-extension(由新增配置时选的文件类型决定)}
#示例:http://192.168.0.63:8848/nacos/v1/cs/configs?dataId=glsx-rest-admin.properties&group=DEV_GROUP
spring.cloud.nacos.config.group=NESHIELD_DEV_GROUP
spring.cloud.nacos.config.group=DEV_GROUP
#配置prefix,默认值同${spring.application.name}
spring.cloud.nacos.config.prefix=${spring.application.name}
#配置开发环境
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!