72 lines
2.1 KiB
Java
72 lines
2.1 KiB
Java
|
package com.ruoyi.device.app;
|
||
|
|
||
|
import com.ruoyi.common.core.controller.BaseController;
|
||
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||
|
import com.ruoyi.device.domain.AsDevice;
|
||
|
import com.ruoyi.device.domain.AsWateringRecord;
|
||
|
import com.ruoyi.device.service.IAsDeviceService;
|
||
|
import com.ruoyi.device.service.IAsUserService;
|
||
|
import com.ruoyi.device.service.IAsWateringRecordService;
|
||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||
|
import org.springframework.web.bind.annotation.RestController;
|
||
|
|
||
|
import javax.annotation.Resource;
|
||
|
import java.util.List;
|
||
|
|
||
|
/**
|
||
|
* 用户信息
|
||
|
*
|
||
|
* @author ruoyi
|
||
|
*/
|
||
|
@RestController
|
||
|
@RequestMapping("/app")
|
||
|
public class AppController extends BaseController
|
||
|
{
|
||
|
@Resource
|
||
|
private IAsUserService asUserService;
|
||
|
|
||
|
@Resource
|
||
|
private IAsWateringRecordService asWateringRecordService;
|
||
|
|
||
|
@Autowired
|
||
|
private IAsDeviceService asDeviceService;
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 根据登录用户获取绑定设备
|
||
|
*/
|
||
|
@GetMapping("/getDeviceInfoByUser")
|
||
|
public AjaxResult list(Long userId)
|
||
|
{
|
||
|
AsDevice device = asUserService.selectDeviceInfoByUser(userId);
|
||
|
return AjaxResult.success(device);
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 滑动浇水
|
||
|
*/
|
||
|
@GetMapping(value = "/watering/{deviceId}/{wateringSwitch}")
|
||
|
public AjaxResult watering(@PathVariable("deviceId") Long deviceId,@PathVariable("wateringSwitch") Integer wateringSwitch)
|
||
|
{
|
||
|
AsDevice device = asDeviceService.selectAsDeviceByDeviceId(deviceId);
|
||
|
return asDeviceService.watering(device,wateringSwitch);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 根据设备id获取更多浇水记录
|
||
|
*/
|
||
|
@GetMapping("/getWateringRecord")
|
||
|
public TableDataInfo wateringRecord(String deviceId)
|
||
|
{
|
||
|
startPage();
|
||
|
List<AsWateringRecord> asWateringRecords = asWateringRecordService.selectAsWateringRecordList(AsWateringRecord.builder().deviceId(Long.parseLong(deviceId)).build());
|
||
|
return getDataTable(asWateringRecords);
|
||
|
}
|
||
|
|
||
|
}
|