diff --git a/springboot/src/main/java/com/sincre/springboot/ApiModel/TuYaAirCondition.java b/springboot/src/main/java/com/sincre/springboot/ApiModel/TuYaAirCondition.java new file mode 100644 index 0000000..cf806bd --- /dev/null +++ b/springboot/src/main/java/com/sincre/springboot/ApiModel/TuYaAirCondition.java @@ -0,0 +1,100 @@ +package com.sincre.springboot.ApiModel; + +import com.fasterxml.jackson.annotation.JsonInclude; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@ApiModel +public class TuYaAirCondition { + + @ApiModelProperty(name = "remote_index",value="遥控器索引",required = true) + private String remote_index; + @ApiModelProperty(name = "remote_id",value="遥控器标识",required = true) + private String remote_id; + + /** + * 开关(1:开,0:关) + */ + @ApiModelProperty(name = "power",value="开关(1:开,0:关)",required = true) + private String power; + /** + * 模式(0:制冷,1:制热,2:自动,3:送风,4:除湿) + */ + @ApiModelProperty(name = "power",value="开关(1:开,0:关)") + private String mode; + + /** + * 温度(16-30) + */ + @ApiModelProperty(name = "temp",value="温度(16-30)") + private String temp; + + /** + * 风速(0:自动,1:低,2:中,3:高) + */ + @ApiModelProperty(name = "wind",value = "风速(0:自动,1:低,2:中,3:高)") + private String wind; + + public String getRemote_index() { + return remote_index; + } + + public void setRemote_index(String remote_index) { + this.remote_index = remote_index; + } + + public String getRemote_id() { + return remote_id; + } + + public void setRemote_id(String remote_id) { + this.remote_id = remote_id; + } + + public String getPower() { + return power; + } + + public void setPower(String power) { + this.power = power; + } + + public String getMode() { + return mode; + } + + public void setMode(String mode) { + this.mode = mode; + } + + public String getTemp() { + return temp; + } + + public void setTemp(String temp) { + this.temp = temp; + } + + public String getWind() { + return wind; + } + + public void setWind(String wind) { + this.wind = wind; + } + + public String getSwing() { + return swing; + } + + public void setSwing(String swing) { + this.swing = swing; + } + + /** + * 风向(暂时不支持) + */ + @ApiModelProperty(name = "swing",value = "风向(暂时不支持)") + private String swing; +} diff --git a/springboot/src/main/java/com/sincre/springboot/ApiModel/TuYaInfrared.java b/springboot/src/main/java/com/sincre/springboot/ApiModel/TuYaInfrared.java index d1ecb0c..4cebed1 100644 --- a/springboot/src/main/java/com/sincre/springboot/ApiModel/TuYaInfrared.java +++ b/springboot/src/main/java/com/sincre/springboot/ApiModel/TuYaInfrared.java @@ -1,14 +1,21 @@ package com.sincre.springboot.ApiModel; import com.fasterxml.jackson.annotation.JsonInclude; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; /** * 红外所需要的类 */ @JsonInclude(JsonInclude.Include.NON_EMPTY) +@ApiModel public class TuYaInfrared { + /** + * 类型ID + */ + @ApiModelProperty(name = "category_id",value = "类型ID") private String category_id; public String getCategory_id() { @@ -27,6 +34,7 @@ public class TuYaInfrared { this.category_name = category_name; } + public String getBrand_id() { return brand_id; } @@ -51,14 +59,34 @@ public class TuYaInfrared { this.remote_index = remote_index; } - + /** + * 类型名称 + */ + @ApiModelProperty(name = "category_name",value = "类型名称") private String category_name; + /** + * 商品标识 + * @return + */ + @ApiModelProperty(name = "brand_id",value = "商标标识") private String brand_id; + /** + * 商品名称 + */ + @ApiModelProperty(name="brand_name",value = "商品名称") private String brand_name; + /** + * 遥控索引 + */ + @ApiModelProperty(name="remote_index",value = "遥控索引") private String remote_index; + /** + * 遥控标识 + */ + @ApiModelProperty(name = "remote_id",value = "遥控标识") private String remote_id; public String getRemote_id() { @@ -77,5 +105,9 @@ public class TuYaInfrared { this.remote_name = remote_name; } + /** + * 遥控名称 + */ + @ApiModelProperty(name = "remote_name",value = "遥控名称") private String remote_name; } diff --git a/springboot/src/main/java/com/sincre/springboot/common/ServerResponse.java b/springboot/src/main/java/com/sincre/springboot/common/ServerResponse.java index 2cf674a..23bee05 100644 --- a/springboot/src/main/java/com/sincre/springboot/common/ServerResponse.java +++ b/springboot/src/main/java/com/sincre/springboot/common/ServerResponse.java @@ -2,6 +2,8 @@ package com.sincre.springboot.common; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.io.Serializable; @@ -10,24 +12,28 @@ import java.io.Serializable; * Created by Ziv */ @JsonInclude(JsonInclude.Include.NON_EMPTY) - +@ApiModel public class ServerResponse implements Serializable { /** * 分页时用到的总数量 */ + @ApiModelProperty(name="total",value = "分页时用到的总数量,当返回的是集合对象的时候,才有该值,否者该值不存在") private String total; /** * 操作状态码 */ + @ApiModelProperty(name="code",value = "操作状态码") private int code; /** * 状态信息 */ + @ApiModelProperty(name="msg",value = "状态信息") private String msg; /** * 返回的数据包 */ + @ApiModelProperty(name="data",value = "返回的数据包") private T data; private ServerResponse(int code) { diff --git a/springboot/src/main/java/com/sincre/springboot/controller/TuYaYunController.java b/springboot/src/main/java/com/sincre/springboot/controller/TuYaYunController.java index 9367dec..77a4678 100644 --- a/springboot/src/main/java/com/sincre/springboot/controller/TuYaYunController.java +++ b/springboot/src/main/java/com/sincre/springboot/controller/TuYaYunController.java @@ -440,6 +440,45 @@ public class TuYaYunController { TuYaResResult tuYaResResult = JSON.parseObject(result,TuYaResResult.class); return ResultUtils.getInstance().returnResultTuYa(tuYaResResult); } + + @ApiOperation("同步空调当前状态") + @ApiImplicitParams({ + @ApiImplicitParam(name="infrared_id",value = "设备ID",required = true,paramType = "path"), + @ApiImplicitParam(name="remote_id",value = "设备ID",required = true,paramType = "path") + }) + @GetMapping("{infrared_id}/getHWAirStatus/{remote_id}") + public ServerResponse getHWAirStatus(@PathVariable String infrared_id,@PathVariable String remote_id){ + + String apiUrl = String.format("/v1.0/infrareds/%s/remotes/%s/ac/status",infrared_id,remote_id); + Map map = headContent(); + String result = ApiHelper.doGet(TuYaCloudService.TuYaOpenUrl + apiUrl,map); + TuYaResResult tuYaResResult = JSON.parseObject(result,TuYaResResult.class); + return ResultUtils.getInstance().returnResultTuYa(tuYaResResult); + } + + @ApiOperation("下发空调红外码") + @ApiImplicitParam(name="infrared_id",value = "设备ID",required = true,paramType = "path") + @PostMapping("{infrared_id}/addAirCode") + public ServerResponse addAirCode(@RequestBody TuYaAirCondition tuYaAirCondition,@PathVariable String infrared_id){ + + if(StringUtils.isBlank(infrared_id)||tuYaAirCondition==null){ + return ServerResponse.createByErrorCodeMessage(400,"参数错误"); + } + else{ + if(StringUtils.isBlank(tuYaAirCondition.getRemote_id())||StringUtils.isBlank(tuYaAirCondition.getRemote_index())){ + return ServerResponse.createByErrorCodeMessage(400,"参数错误"); + } + } + String apiUrl = String.format("/v1.0/infrareds/%s/ac/send-keys",infrared_id); + Map map = headContent(); + + String json = JSON.toJSONString(tuYaAirCondition); + String result = ApiHelper.doPost(TuYaCloudService.TuYaOpenUrl + apiUrl,map,json); + TuYaResResult tuYaResResult = JSON.parseObject(result,TuYaResResult.class); + return ResultUtils.getInstance().returnResultTuYa(tuYaResResult); + } + + /** * 请求头的参数 * @return -- libgit2 0.21.0