|
@ -1,11 +1,9 @@ |
|
|
package com.iflytop.handacid.app.controller; |
|
|
package com.iflytop.handacid.app.controller; |
|
|
|
|
|
|
|
|
import com.iflytop.handacid.app.core.state.ChannelState; |
|
|
|
|
|
import com.iflytop.handacid.app.core.state.DeviceState; |
|
|
import com.iflytop.handacid.app.core.state.DeviceState; |
|
|
import com.iflytop.handacid.app.model.bo.SyncOperationsChannel; |
|
|
|
|
|
import com.iflytop.handacid.app.model.dto.SyncOperationsDTO; |
|
|
import com.iflytop.handacid.app.model.dto.SyncOperationsDTO; |
|
|
|
|
|
import com.iflytop.handacid.app.service.DeviceService; |
|
|
import com.iflytop.handacid.common.result.Result; |
|
|
import com.iflytop.handacid.common.result.Result; |
|
|
import com.iflytop.handacid.common.service.SolutionService; |
|
|
|
|
|
import io.swagger.v3.oas.annotations.Operation; |
|
|
import io.swagger.v3.oas.annotations.Operation; |
|
|
import io.swagger.v3.oas.annotations.tags.Tag; |
|
|
import io.swagger.v3.oas.annotations.tags.Tag; |
|
|
import lombok.RequiredArgsConstructor; |
|
|
import lombok.RequiredArgsConstructor; |
|
@ -19,7 +17,7 @@ import org.springframework.web.bind.annotation.*; |
|
|
@Slf4j |
|
|
@Slf4j |
|
|
public class DeviceController { |
|
|
public class DeviceController { |
|
|
private final DeviceState deviceState; |
|
|
private final DeviceState deviceState; |
|
|
private final SolutionService solutionService; |
|
|
|
|
|
|
|
|
private final DeviceService deviceService; |
|
|
|
|
|
|
|
|
@Operation(summary = "获取当前设备状态") |
|
|
@Operation(summary = "获取当前设备状态") |
|
|
@GetMapping("/device-status") |
|
|
@GetMapping("/device-status") |
|
@ -30,12 +28,7 @@ public class DeviceController { |
|
|
@Operation(summary = "同步用户操作") |
|
|
@Operation(summary = "同步用户操作") |
|
|
@PostMapping("/sync") |
|
|
@PostMapping("/sync") |
|
|
public Result<?> syncOperations(@RequestBody SyncOperationsDTO syncOperationsDTO) { |
|
|
public Result<?> syncOperations(@RequestBody SyncOperationsDTO syncOperationsDTO) { |
|
|
deviceState.setMode(syncOperationsDTO.getMode()); |
|
|
|
|
|
for (SyncOperationsChannel syncOperationsChannel : syncOperationsDTO.getChannels()) { |
|
|
|
|
|
ChannelState channelState = deviceState.getChannelStateMap().get(syncOperationsChannel.getChannelCode()); |
|
|
|
|
|
channelState.setSelected(syncOperationsChannel.isSelected()); |
|
|
|
|
|
channelState.setTargetVolume(syncOperationsChannel.getTargetVolume()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
deviceService.syncOperations(syncOperationsDTO); |
|
|
return Result.success(); |
|
|
return Result.success(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |