Skip to content

Commit

Permalink
Merge pull request #91 from ZhouYixun/beta2
Browse files Browse the repository at this point in the history
rc
  • Loading branch information
ZhouYixun authored Dec 9, 2021
2 parents 2529e41 + 9a54232 commit 3f89662
Show file tree
Hide file tree
Showing 22 changed files with 314 additions and 135 deletions.
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ services:
ports:
- "8094:8094"
sonic-server-controller:
image: "zhouyixun/sonic-server-controller:v1.2.0-beta3"
image: "zhouyixun/sonic-server-controller:v1.2.0-rc"
environment:
- PROFILE=prod
- EUREKA_URL=http://sonic:sonic@sonic-server-eureka:9090/eureka/
Expand Down Expand Up @@ -68,7 +68,7 @@ services:
- sonic-server-eureka
- sonic-server-gateway
sonic-server-task:
image: "zhouyixun/sonic-server-task:v1.2.0-beta2"
image: "zhouyixun/sonic-server-task:v1.2.0-rc"
environment:
- PROFILE=prod
- EUREKA_URL=http://sonic:sonic@sonic-server-eureka:9090/eureka/
Expand All @@ -81,7 +81,7 @@ services:
- sonic-server-eureka
- sonic-server-gateway
sonic-server-transport:
image: "zhouyixun/sonic-server-transport:v1.2.0-beta2"
image: "zhouyixun/sonic-server-transport:v1.2.0-rc"
environment:
- PROFILE=prod
- EUREKA_URL=http://sonic:sonic@sonic-server-eureka:9090/eureka/
Expand Down
38 changes: 19 additions & 19 deletions sonic-server-bus/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,23 @@
</dependency>
</dependencies>

<!-- <build>-->
<!-- <plugins>-->
<!-- &lt;!&ndash; 只作为公共依赖,不需要打包 &ndash;&gt;-->
<!-- <plugin>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-maven-plugin</artifactId>-->
<!-- <configuration>-->
<!-- <skip>true</skip>-->
<!-- </configuration>-->
<!-- </plugin>-->
<!-- <plugin>-->
<!-- <groupId>com.spotify</groupId>-->
<!-- <artifactId>docker-maven-plugin</artifactId>-->
<!-- <configuration>-->
<!-- <skipDocker>true</skipDocker>-->
<!-- </configuration>-->
<!-- </plugin>-->
<!-- </plugins>-->
<!-- </build>-->
<build>
<plugins>
<!-- 只作为公共依赖,不需要打包 -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<configuration>
<skipDocker>true</skipDocker>
</configuration>
</plugin>
</plugins>
</build>
</project>
2 changes: 1 addition & 1 deletion sonic-server-controller/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<modelVersion>4.0.0</modelVersion>

<artifactId>sonic-server-controller</artifactId>
<version>v1.2.0-beta3</version>
<version>v1.2.0-rc</version>
<packaging>jar</packaging>

<!-- 依赖列表 -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.sonic.common.http.RespEnum;
import com.sonic.common.http.RespModel;
import com.sonic.controller.models.Devices;
import com.sonic.controller.models.http.DevicePwdChange;
import com.sonic.controller.models.http.DeviceDetailChange;
import com.sonic.controller.models.http.UpdateDeviceImg;
import com.sonic.controller.services.DevicesService;
import io.swagger.annotations.Api;
Expand All @@ -30,15 +30,21 @@ public class DevicesController {

@WebAspect
@ApiOperation(value = "修改设备安装密码", notes = "修改对应设备id的安装密码")
@PutMapping("/savePwd")
public RespModel savePwd(@Validated @RequestBody DevicePwdChange devicePwdChange) {
if (devicesService.savePwd(devicePwdChange)) {
@PutMapping("/saveDetail")
public RespModel saveDetail(@Validated @RequestBody DeviceDetailChange deviceDetailChange) {
if (devicesService.saveDetail(deviceDetailChange)) {
return new RespModel(RespEnum.UPDATE_OK);
} else {
return new RespModel(3000, "保存异常!");
}
}

@PutMapping("/updateUser")
public RespModel updateUser(@RequestBody JSONObject jsonObject) {
devicesService.updateUser(jsonObject);
return new RespModel(RespEnum.UPDATE_OK);
}

@WebAspect
@ApiOperation(value = "修改设备图片", notes = "修改对应设备id的图片")
@PutMapping("/updateImg")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,24 @@ public RespModel runSuite(@RequestParam(name = "id") int id
return testSuitesService.runSuite(id, strike);
}

@WebAspect
@ApiOperation(value = "停止测试套件运行", notes = "停止测试套件运行")
@ApiImplicitParam(name = "resultId", value = "测试结果Id", dataTypeClass = Integer.class)
@GetMapping("/forceStopSuite")
public RespModel<String> forceStopSuite(@RequestParam(name = "resultId") int resultId
, HttpServletRequest request) {
String strike = "SYSTEM";
if (request.getHeader("SonicToken") != null) {
String token = request.getHeader("SonicToken");
String userName = jwtTokenTool.getUserName(token);
if (userName != null) {
strike = userName;
}
}
return testSuitesService.forceStopSuite(resultId, strike);
}


@WebAspect
@ApiOperation(value = "删除测试套件", notes = "删除指定id的测试套件")
@ApiImplicitParam(name = "id", value = "测试套件id", dataTypeClass = Integer.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public class Devices {
int id;
@ApiModelProperty(value = "设备名称", example = "My HUAWEI")
String name;
@ApiModelProperty(value = "设备备注", example = "My HUAWEI")
String nickName;
@ApiModelProperty(value = "型号", example = "HUAWEI MATE 40")
String model;
@ApiModelProperty(value = "序列号", example = "random")
Expand All @@ -45,6 +47,8 @@ public class Devices {
@JsonIgnore
@JSONField(serialize = false)
Set<TestSuites> testSuites;
@ApiModelProperty(value = "设备占用者")
String user;

public Devices() {
}
Expand All @@ -57,6 +61,14 @@ public void setId(int id) {
this.id = id;
}

public String getNickName() {
return nickName;
}

public void setNickName(String nickName) {
this.nickName = nickName;
}

public String getName() {
return name;
}
Expand Down Expand Up @@ -161,11 +173,21 @@ public void setTestSuites(Set<TestSuites> testSuites) {
this.testSuites = testSuites;
}


public String getUser() {
return user;
}

public void setUser(String user) {
this.user = user;
}

@Override
public String toString() {
return "Devices{" +
"id=" + id +
", name='" + name + '\'' +
", nickName='" + nickName + '\'' +
", model='" + model + '\'' +
", udId='" + udId + '\'' +
", status='" + status + '\'' +
Expand All @@ -177,6 +199,7 @@ public String toString() {
", manufacturer='" + manufacturer + '\'' +
", password='" + password + '\'' +
", imgUrl='" + imgUrl + '\'' +
", user='" + user + '\'' +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public class Elements {
@NotNull
@ApiModelProperty(value = "控件类型", required = true, example = "xpath")
String eleType;
@Lob
@Basic(fetch = FetchType.LAZY)
@NotNull
@ApiModelProperty(value = "控件值", required = true, example = "//@[text()='home']")
String eleValue;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,41 +1,53 @@
package com.sonic.controller.models.http;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Positive;

@ApiModel("更新设备密码请求模型")
public class DevicePwdChange {
@Positive
@ApiModelProperty(value = "设备id", required = true, example = "1")
private int id;
@NotNull
@ApiModelProperty(value = "设备安装密码", required = true, example = "123456")
private String password;

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}

@Override
public String toString() {
return "DevicePwdChange{" +
"id=" + id +
", password='" + password + '\'' +
'}';
}
}
package com.sonic.controller.models.http;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Positive;

@ApiModel("更新设备详情请求模型")
public class DeviceDetailChange {
@Positive
@ApiModelProperty(value = "设备id", required = true, example = "1")
private int id;
@NotNull
@ApiModelProperty(value = "设备安装密码", required = true, example = "123456")
private String password;
@NotNull
@ApiModelProperty(value = "设备备注", required = true, example = "123456")
private String nickName;

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}

public String getNickName() {
return nickName;
}

public void setNickName(String nickName) {
this.nickName = nickName;
}

@Override
public String toString() {
return "DeviceDetailChange{" +
"id=" + id +
", password='" + password + '\'' +
", nickName='" + nickName + '\'' +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.alibaba.fastjson.JSONObject;
import com.sonic.controller.models.Devices;
import com.sonic.controller.models.http.DevicePwdChange;
import com.sonic.controller.models.http.DeviceDetailChange;
import com.sonic.controller.models.http.UpdateDeviceImg;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
Expand All @@ -15,7 +15,9 @@
* @date 2021/8/16 22:51
*/
public interface DevicesService {
boolean savePwd(DevicePwdChange devicePwdChange);
boolean saveDetail(DeviceDetailChange deviceDetailChange);

void updateUser(JSONObject jsonObject);

void updateImg(UpdateDeviceImg updateDeviceImg);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public interface TestSuitesService {

boolean delete(int id);

RespModel<String> forceStopSuite(int id, String strike);

void save(TestSuites testSuites);

Page<TestSuites> findByProjectId(int projectId, String name, Pageable pageable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
import com.alibaba.fastjson.JSONObject;
import com.sonic.controller.dao.DevicesRepository;
import com.sonic.controller.models.Devices;
import com.sonic.controller.models.http.DevicePwdChange;
import com.sonic.controller.models.Users;
import com.sonic.controller.models.http.DeviceDetailChange;
import com.sonic.controller.models.http.UpdateDeviceImg;
import com.sonic.controller.models.interfaces.DeviceStatus;
import com.sonic.controller.models.interfaces.PlatformType;
import com.sonic.controller.services.DevicesService;
import com.sonic.controller.services.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
Expand All @@ -29,19 +31,31 @@
public class DevicesServiceImpl implements DevicesService {
@Autowired
private DevicesRepository devicesRepository;
@Autowired
private UsersService usersService;

@Override
public boolean savePwd(DevicePwdChange devicePwdChange) {
if (devicesRepository.existsById(devicePwdChange.getId())) {
Devices devices = devicesRepository.findById(devicePwdChange.getId()).get();
devices.setPassword(devicePwdChange.getPassword());
public boolean saveDetail(DeviceDetailChange deviceDetailChange) {
if (devicesRepository.existsById(deviceDetailChange.getId())) {
Devices devices = devicesRepository.findById(deviceDetailChange.getId()).get();
devices.setNickName(deviceDetailChange.getNickName());
devices.setPassword(deviceDetailChange.getPassword());
devicesRepository.save(devices);
return true;
} else {
return false;
}
}

@Override
public void updateUser(JSONObject jsonObject) {
Users users = usersService.getUserInfo(jsonObject.getString("token"));
Devices devices = findByAgentIdAndUdId(jsonObject.getInteger("agentId"),
jsonObject.getString("udId"));
devices.setUser(users.getUserName());
save(devices);
}

@Override
public void updateImg(UpdateDeviceImg updateDeviceImg) {
if (devicesRepository.existsById(updateDeviceImg.getId())) {
Expand Down
Loading

0 comments on commit 3f89662

Please sign in to comment.