Browse Source

跨域

master
sige 2 years ago
parent
commit
02c54afc6c
  1. 16
      src/main/java/com/dreamworks/boditech/configuration/WebConfig.java
  2. 2
      src/main/java/com/dreamworks/boditech/controller/AccountController.java
  3. 20
      src/main/java/com/dreamworks/boditech/controller/DeviceController.java

16
src/main/java/com/dreamworks/boditech/configuration/WebConfig.java

@ -1,2 +1,16 @@
package com.dreamworks.boditech.configuration;public class WebConfig {
package com.dreamworks.boditech.configuration;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebConfig implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowCredentials(true)
.allowedOriginPatterns("*")
.allowedMethods("GET", "POST", "PUT", "DELETE")
.allowedHeaders("*")
.exposedHeaders("*");
}
}

2
src/main/java/com/dreamworks/boditech/controller/AccountController.java

@ -8,9 +8,7 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.Map;
@Controller
public class AccountController extends BaseController {
@Resource

20
src/main/java/com/dreamworks/boditech/controller/DeviceController.java

@ -171,12 +171,26 @@ public class DeviceController extends BaseController {
private Integer initCount = 3;
@ResponseBody
@PostMapping("/api/device/init")
public ApiResponse init() {
this.deviceService.reset(false);
return this.success();
if ( initCount > 0 ) {
this.initCount --;
ApiResponse response = new ApiResponse();
response.success = false;
response.message = "";
response.data = List.of(
Map.of("message","请确认试管帽夹中无试管帽","type","manual"),
Map.of("message","移液枪复位","type","auto"),
Map.of("message","机械臂复位","type","auto"),
Map.of("message","孵育盘复位","type","auto")
);
return response;
} else {
this.initCount = 3;
return this.success();
}
}

Loading…
Cancel
Save