feat(nex-be): 添加桌面镜像功能并调整 gRPC 相关配置
- 新增桌面镜像相关实体类、控制器、服务接口及其实现 - 修改 gRPC 服务配置,将端口改为 50051- 更新 gRPC 消息结构,将 client_mac 改为 client_user - 优化终端操作相关 API,增加启动、重启和快照功能master
parent
144a09a335
commit
b6b4e145c7
|
|
@ -0,0 +1,101 @@
|
||||||
|
package com.unisinsight.project.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.unisinsight.project.entity.dao.ImageDesktop;
|
||||||
|
import com.unisinsight.project.entity.req.ImageDesktopReq;
|
||||||
|
import com.unisinsight.project.entity.res.ImageDesktopRes;
|
||||||
|
import com.unisinsight.project.service.ImageDesktopService;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.unisinsight.project.exception.Result;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import com.unisinsight.project.exception.BaseErrorCode;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import com.unisinsight.project.entity.req.DeleteIdReq;
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 桌面镜像(ImageDesktop)表控制层
|
||||||
|
*
|
||||||
|
* @author ch
|
||||||
|
* @since 2025-08-29 09:23:01
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@Api(tags = "桌面镜像")
|
||||||
|
@Slf4j
|
||||||
|
@RequestMapping("/api/nex/v1/image_desktop")
|
||||||
|
public class ImageDesktopController {
|
||||||
|
/**
|
||||||
|
* 服务对象
|
||||||
|
*/
|
||||||
|
@Resource
|
||||||
|
private ImageDesktopService service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询所有数据
|
||||||
|
*
|
||||||
|
* @param page 分页对象
|
||||||
|
* @param imageDesktop 查询实体
|
||||||
|
* @return 所有数据
|
||||||
|
*/
|
||||||
|
@PostMapping("/select/page")
|
||||||
|
@ApiOperation(value = "分页查询桌面镜像")
|
||||||
|
public Result selectPage(@RequestBody ImageDesktopReq imageDesktopReq) {
|
||||||
|
if (Objects.isNull(imageDesktopReq)) {
|
||||||
|
return Result.errorResult(BaseErrorCode.PARAMS_CHK_ERROR);
|
||||||
|
}
|
||||||
|
log.info("分页查询桌面镜像请求参数为:{}", JSONUtil.toJsonStr(imageDesktopReq));
|
||||||
|
return service.selectPage(imageDesktopReq);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "桌面镜像新增")
|
||||||
|
@PostMapping("/add")
|
||||||
|
public Result<?> insertImageVirtualMachines(@RequestBody ImageDesktopReq imageDesktopReq) {
|
||||||
|
if (Objects.isNull(imageDesktopReq)) {
|
||||||
|
return Result.errorResult(BaseErrorCode.PARAMS_CHK_ERROR);
|
||||||
|
}
|
||||||
|
log.info("桌面镜像新增请求参数为:{}", JSONUtil.toJsonStr(imageDesktopReq));
|
||||||
|
return service.insert(imageDesktopReq);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "桌面镜像修改")
|
||||||
|
@PostMapping("/update")
|
||||||
|
public Result<?> updateUser(@RequestBody ImageDesktopReq imageDesktopReq) {
|
||||||
|
if (Objects.isNull(imageDesktopReq)) {
|
||||||
|
return Result.errorResult(BaseErrorCode.PARAMS_CHK_ERROR);
|
||||||
|
}
|
||||||
|
log.info("桌面镜像修改请求参数为:{}", JSONUtil.toJsonStr(imageDesktopReq));
|
||||||
|
return service.update(imageDesktopReq);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "桌面镜像查询")
|
||||||
|
@PostMapping("/query")
|
||||||
|
public Result<?> queryUser(@RequestBody ImageDesktopReq imageDesktopReq) {
|
||||||
|
if (Objects.isNull(imageDesktopReq)) {
|
||||||
|
return Result.errorResult(BaseErrorCode.PARAMS_CHK_ERROR);
|
||||||
|
}
|
||||||
|
log.info("桌面镜像查询请求参数为:{}", JSONUtil.toJsonStr(imageDesktopReq));
|
||||||
|
return service.query(imageDesktopReq);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "桌面镜像删除")
|
||||||
|
@PostMapping("/delete")
|
||||||
|
public Result<?> delete(@RequestBody DeleteIdReq deleteIdReq) {
|
||||||
|
if (Objects.isNull(deleteIdReq)) {
|
||||||
|
return Result.errorResult(BaseErrorCode.PARAMS_CHK_ERROR);
|
||||||
|
}
|
||||||
|
log.info("桌面镜像删除请求参数为:{}", JSONUtil.toJsonStr(deleteIdReq));
|
||||||
|
return service.delete(deleteIdReq);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -90,7 +90,7 @@ public class ImageVirtualMachinesController {
|
||||||
log.info("镜像虚拟机删除请求参数为:{}", JSONUtil.toJsonStr(deleteIdReq));
|
log.info("镜像虚拟机删除请求参数为:{}", JSONUtil.toJsonStr(deleteIdReq));
|
||||||
return service.delete(deleteIdReq);
|
return service.delete(deleteIdReq);
|
||||||
}
|
}
|
||||||
@ApiOperation(value = "终端删除")
|
@ApiOperation(value = "终端克隆")
|
||||||
@PostMapping("/clone/template")
|
@PostMapping("/clone/template")
|
||||||
public Result<?> cloneTemplate(@RequestBody ImageVirtualMachinesReq req) {
|
public Result<?> cloneTemplate(@RequestBody ImageVirtualMachinesReq req) {
|
||||||
if (Objects.isNull(req)) {
|
if (Objects.isNull(req)) {
|
||||||
|
|
@ -99,6 +99,33 @@ public class ImageVirtualMachinesController {
|
||||||
log.info("镜像虚拟机克隆为模板请求参数为:{}", JSONUtil.toJsonStr(req));
|
log.info("镜像虚拟机克隆为模板请求参数为:{}", JSONUtil.toJsonStr(req));
|
||||||
return service.cloneTemplate(req);
|
return service.cloneTemplate(req);
|
||||||
}
|
}
|
||||||
|
@ApiOperation(value = "终端启动")
|
||||||
|
@PostMapping("/start")
|
||||||
|
public Result<?> start(@RequestBody ImageVirtualMachinesReq req) {
|
||||||
|
if (Objects.isNull(req)) {
|
||||||
|
return Result.errorResult(BaseErrorCode.PARAMS_CHK_ERROR);
|
||||||
|
}
|
||||||
|
log.info("终端启动请求参数为:{}", JSONUtil.toJsonStr(req));
|
||||||
|
return service.cloneTemplate(req);
|
||||||
|
}
|
||||||
|
@ApiOperation(value = "终端重启")
|
||||||
|
@PostMapping("/reboot")
|
||||||
|
public Result<?> reboot(@RequestBody ImageVirtualMachinesReq req) {
|
||||||
|
if (Objects.isNull(req)) {
|
||||||
|
return Result.errorResult(BaseErrorCode.PARAMS_CHK_ERROR);
|
||||||
|
}
|
||||||
|
log.info("终端重启请求参数为:{}", JSONUtil.toJsonStr(req));
|
||||||
|
return service.cloneTemplate(req);
|
||||||
|
}
|
||||||
|
@ApiOperation(value = "终端快照")
|
||||||
|
@PostMapping("/snapshot")
|
||||||
|
public Result<?> snapshot(@RequestBody ImageVirtualMachinesReq req) {
|
||||||
|
if (Objects.isNull(req)) {
|
||||||
|
return Result.errorResult(BaseErrorCode.PARAMS_CHK_ERROR);
|
||||||
|
}
|
||||||
|
log.info("终端快照请求参数为:{}", JSONUtil.toJsonStr(req));
|
||||||
|
return service.cloneTemplate(req);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,141 @@
|
||||||
|
package com.unisinsight.project.entity.dao;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 桌面镜像(ImageDesktop)表实体类
|
||||||
|
*
|
||||||
|
* @author ch
|
||||||
|
* @since 2025-08-29 09:25:39
|
||||||
|
*/
|
||||||
|
@TableName(value = "image_desktop")
|
||||||
|
@Data
|
||||||
|
@ApiModel("桌面镜像")
|
||||||
|
public class ImageDesktop extends Model<ImageDesktop> {
|
||||||
|
/**
|
||||||
|
* ID
|
||||||
|
**/
|
||||||
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
|
@ApiModelProperty("ID")
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 名称
|
||||||
|
**/
|
||||||
|
|
||||||
|
|
||||||
|
@TableField(value = "desktop_name")
|
||||||
|
@ApiModelProperty("名称")
|
||||||
|
private String desktopName;
|
||||||
|
/**
|
||||||
|
* 桌面类型:1:VHD 2:VHDX 3:QCOW2
|
||||||
|
**/
|
||||||
|
|
||||||
|
|
||||||
|
@TableField(value = "desktop_type")
|
||||||
|
@ApiModelProperty("桌面类型:1:VHD 2:VHDX 3:QCOW2")
|
||||||
|
private Integer desktopType;
|
||||||
|
/**
|
||||||
|
* 父镜像id
|
||||||
|
**/
|
||||||
|
|
||||||
|
|
||||||
|
@TableField(value = "image_virtual_id")
|
||||||
|
@ApiModelProperty("父镜像id")
|
||||||
|
private Integer imageVirtualId;
|
||||||
|
/**
|
||||||
|
* 发布状态
|
||||||
|
**/
|
||||||
|
|
||||||
|
|
||||||
|
@TableField(value = "publish_status")
|
||||||
|
@ApiModelProperty("发布状态")
|
||||||
|
private String publishStatus;
|
||||||
|
/**
|
||||||
|
* 操作系统
|
||||||
|
**/
|
||||||
|
|
||||||
|
|
||||||
|
@TableField(value = "os_version")
|
||||||
|
@ApiModelProperty("操作系统")
|
||||||
|
private String osVersion;
|
||||||
|
/**
|
||||||
|
* BT路径
|
||||||
|
**/
|
||||||
|
|
||||||
|
|
||||||
|
@TableField(value = "bt_path")
|
||||||
|
@ApiModelProperty("BT路径")
|
||||||
|
private String btPath;
|
||||||
|
/**
|
||||||
|
* 镜像存储路径
|
||||||
|
**/
|
||||||
|
|
||||||
|
|
||||||
|
@TableField(value = "storage_path")
|
||||||
|
@ApiModelProperty("镜像存储路径")
|
||||||
|
private String storagePath;
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
**/
|
||||||
|
|
||||||
|
|
||||||
|
@TableField(value = "create_time", fill = FieldFill.INSERT)
|
||||||
|
@ApiModelProperty("创建时间")
|
||||||
|
private String createTime;
|
||||||
|
/**
|
||||||
|
* 创建人
|
||||||
|
**/
|
||||||
|
|
||||||
|
|
||||||
|
@TableField(value = "create_user")
|
||||||
|
@ApiModelProperty("创建人")
|
||||||
|
private String createUser;
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
**/
|
||||||
|
|
||||||
|
|
||||||
|
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
|
||||||
|
@ApiModelProperty("更新时间")
|
||||||
|
private String updateTime;
|
||||||
|
/**
|
||||||
|
* 更新人
|
||||||
|
**/
|
||||||
|
|
||||||
|
|
||||||
|
@TableField(value = "update_user")
|
||||||
|
@ApiModelProperty("更新人")
|
||||||
|
private String updateUser;
|
||||||
|
/**
|
||||||
|
* 是否删除:0-否,1-删除
|
||||||
|
**/
|
||||||
|
|
||||||
|
|
||||||
|
@TableField(value = "deleted")
|
||||||
|
@ApiModelProperty("是否删除:0-否,1-删除")
|
||||||
|
private Integer deleted;
|
||||||
|
/**
|
||||||
|
* 描述
|
||||||
|
**/
|
||||||
|
|
||||||
|
|
||||||
|
@TableField(value = "description")
|
||||||
|
@ApiModelProperty("描述")
|
||||||
|
private String description;
|
||||||
|
/**
|
||||||
|
* 发布时间
|
||||||
|
**/
|
||||||
|
|
||||||
|
|
||||||
|
@TableField(value = "publish_time")
|
||||||
|
@ApiModelProperty("发布时间")
|
||||||
|
private String publishTime;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,123 @@
|
||||||
|
package com.unisinsight.project.entity.req;
|
||||||
|
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 桌面镜像(ImageDesktop)表实体类
|
||||||
|
*
|
||||||
|
* @author ch
|
||||||
|
* @since 2025-08-29 09:23:01
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ApiModel("桌面镜像")
|
||||||
|
public class ImageDesktopReq {
|
||||||
|
/**
|
||||||
|
* ID
|
||||||
|
**/
|
||||||
|
@JsonProperty("id")
|
||||||
|
@ApiModelProperty("ID")
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 名称
|
||||||
|
**/
|
||||||
|
@JsonProperty("desktop_name")
|
||||||
|
@ApiModelProperty("名称")
|
||||||
|
private String desktopName;
|
||||||
|
/**
|
||||||
|
* 桌面类型:1:VHD 2:VHDX 3:QCOW2
|
||||||
|
**/
|
||||||
|
@JsonProperty("desktop_type")
|
||||||
|
@ApiModelProperty("桌面类型:1:VHD 2:VHDX 3:QCOW2")
|
||||||
|
private Integer desktopType;
|
||||||
|
/**
|
||||||
|
* 父镜像id
|
||||||
|
**/
|
||||||
|
@JsonProperty("image_virtual_id")
|
||||||
|
@ApiModelProperty("父镜像id")
|
||||||
|
private Integer imageVirtualId;
|
||||||
|
/**
|
||||||
|
* 发布状态
|
||||||
|
**/
|
||||||
|
@JsonProperty("publish_status")
|
||||||
|
@ApiModelProperty("发布状态")
|
||||||
|
private String publishStatus;
|
||||||
|
/**
|
||||||
|
* 操作系统
|
||||||
|
**/
|
||||||
|
@JsonProperty("os_version")
|
||||||
|
@ApiModelProperty("操作系统")
|
||||||
|
private String osVersion;
|
||||||
|
/**
|
||||||
|
* BT路径
|
||||||
|
**/
|
||||||
|
@JsonProperty("bt_path")
|
||||||
|
@ApiModelProperty("BT路径")
|
||||||
|
private String btPath;
|
||||||
|
/**
|
||||||
|
* 镜像存储路径
|
||||||
|
**/
|
||||||
|
@JsonProperty("storage_path")
|
||||||
|
@ApiModelProperty("镜像存储路径")
|
||||||
|
private String storagePath;
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
**/
|
||||||
|
@JsonProperty("create_time")
|
||||||
|
@ApiModelProperty("创建时间")
|
||||||
|
private String createTime;
|
||||||
|
/**
|
||||||
|
* 创建人
|
||||||
|
**/
|
||||||
|
@JsonProperty("create_user")
|
||||||
|
@ApiModelProperty("创建人")
|
||||||
|
private String createUser;
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
**/
|
||||||
|
@JsonProperty("update_time")
|
||||||
|
@ApiModelProperty("更新时间")
|
||||||
|
private String updateTime;
|
||||||
|
/**
|
||||||
|
* 更新人
|
||||||
|
**/
|
||||||
|
@JsonProperty("update_user")
|
||||||
|
@ApiModelProperty("更新人")
|
||||||
|
private String updateUser;
|
||||||
|
/**
|
||||||
|
* 是否删除:0-否,1-删除
|
||||||
|
**/
|
||||||
|
@JsonProperty("deleted")
|
||||||
|
@ApiModelProperty("是否删除:0-否,1-删除")
|
||||||
|
private Integer deleted;
|
||||||
|
/**
|
||||||
|
* 描述
|
||||||
|
**/
|
||||||
|
@JsonProperty("description")
|
||||||
|
@ApiModelProperty("描述")
|
||||||
|
private String description;
|
||||||
|
/**
|
||||||
|
* 发布时间
|
||||||
|
**/
|
||||||
|
@JsonProperty("publish_time")
|
||||||
|
@ApiModelProperty("发布时间")
|
||||||
|
private String publishTime;
|
||||||
|
/**
|
||||||
|
* 查询页
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "查询页", notes = "分页查询时再传")
|
||||||
|
@JsonProperty("page_num")
|
||||||
|
private Integer pageNum;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 每页数量
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "每页数量", notes = "分页查询时再传")
|
||||||
|
@JsonProperty("page_size")
|
||||||
|
private Integer pageSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,112 @@
|
||||||
|
package com.unisinsight.project.entity.res;
|
||||||
|
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 桌面镜像(ImageDesktop)表实体类
|
||||||
|
*
|
||||||
|
* @author ch
|
||||||
|
* @since 2025-08-29 09:23:02
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ApiModel("桌面镜像")
|
||||||
|
public class ImageDesktopRes implements Serializable {
|
||||||
|
/**
|
||||||
|
* ID
|
||||||
|
**/
|
||||||
|
@JsonProperty("id")
|
||||||
|
@ApiModelProperty("ID")
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 名称
|
||||||
|
**/
|
||||||
|
@JsonProperty("desktop_name")
|
||||||
|
@ApiModelProperty("名称")
|
||||||
|
private String desktopName;
|
||||||
|
/**
|
||||||
|
* 桌面类型:1:VHD 2:VHDX 3:QCOW2
|
||||||
|
**/
|
||||||
|
@JsonProperty("desktop_type")
|
||||||
|
@ApiModelProperty("桌面类型:1:VHD 2:VHDX 3:QCOW2")
|
||||||
|
private Integer desktopType;
|
||||||
|
/**
|
||||||
|
* 父镜像id
|
||||||
|
**/
|
||||||
|
@JsonProperty("image_virtual_id")
|
||||||
|
@ApiModelProperty("父镜像id")
|
||||||
|
private Integer imageVirtualId;
|
||||||
|
/**
|
||||||
|
* 发布状态
|
||||||
|
**/
|
||||||
|
@JsonProperty("publish_status")
|
||||||
|
@ApiModelProperty("发布状态")
|
||||||
|
private String publishStatus;
|
||||||
|
/**
|
||||||
|
* 操作系统
|
||||||
|
**/
|
||||||
|
@JsonProperty("os_version")
|
||||||
|
@ApiModelProperty("操作系统")
|
||||||
|
private String osVersion;
|
||||||
|
/**
|
||||||
|
* BT路径
|
||||||
|
**/
|
||||||
|
@JsonProperty("bt_path")
|
||||||
|
@ApiModelProperty("BT路径")
|
||||||
|
private String btPath;
|
||||||
|
/**
|
||||||
|
* 镜像存储路径
|
||||||
|
**/
|
||||||
|
@JsonProperty("storage_path")
|
||||||
|
@ApiModelProperty("镜像存储路径")
|
||||||
|
private String storagePath;
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
**/
|
||||||
|
@JsonProperty("create_time")
|
||||||
|
@ApiModelProperty("创建时间")
|
||||||
|
private String createTime;
|
||||||
|
/**
|
||||||
|
* 创建人
|
||||||
|
**/
|
||||||
|
@JsonProperty("create_user")
|
||||||
|
@ApiModelProperty("创建人")
|
||||||
|
private String createUser;
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
**/
|
||||||
|
@JsonProperty("update_time")
|
||||||
|
@ApiModelProperty("更新时间")
|
||||||
|
private String updateTime;
|
||||||
|
/**
|
||||||
|
* 更新人
|
||||||
|
**/
|
||||||
|
@JsonProperty("update_user")
|
||||||
|
@ApiModelProperty("更新人")
|
||||||
|
private String updateUser;
|
||||||
|
/**
|
||||||
|
* 是否删除:0-否,1-删除
|
||||||
|
**/
|
||||||
|
@JsonProperty("deleted")
|
||||||
|
@ApiModelProperty("是否删除:0-否,1-删除")
|
||||||
|
private Integer deleted;
|
||||||
|
/**
|
||||||
|
* 描述
|
||||||
|
**/
|
||||||
|
@JsonProperty("description")
|
||||||
|
@ApiModelProperty("描述")
|
||||||
|
private String description;
|
||||||
|
/**
|
||||||
|
* 发布时间
|
||||||
|
**/
|
||||||
|
@JsonProperty("publish_time")
|
||||||
|
@ApiModelProperty("发布时间")
|
||||||
|
private String publishTime;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -38,17 +38,17 @@ public final class NotificationProto {
|
||||||
descriptor;
|
descriptor;
|
||||||
static {
|
static {
|
||||||
java.lang.String[] descriptorData = {
|
java.lang.String[] descriptorData = {
|
||||||
"\n\rmessage.proto\"8\n\017RegisterRequest\022\021\n\tcl" +
|
"\n\rmessage.proto\"9\n\017RegisterRequest\022\021\n\tcl" +
|
||||||
"ient_sn\030\001 \001(\t\022\022\n\nclient_mac\030\002 \001(\t\"b\n\023Not" +
|
"ient_sn\030\001 \001(\t\022\023\n\013client_user\030\002 \001(\t\"b\n\023No" +
|
||||||
"ificationMessage\022\014\n\004type\030\001 \001(\t\022\017\n\007conten" +
|
"tificationMessage\022\014\n\004type\030\001 \001(\t\022\017\n\007conte" +
|
||||||
"t\030\002 \001(\t\022\021\n\ttimestamp\030\003 \001(\003\022\014\n\004code\030\004 \001(\005" +
|
"nt\030\002 \001(\t\022\021\n\ttimestamp\030\003 \001(\003\022\014\n\004code\030\004 \001(" +
|
||||||
"\022\013\n\003msg\030\005 \001(\t\"/\n\013MsgResponse\022\017\n\007success\030" +
|
"\005\022\013\n\003msg\030\005 \001(\t\"/\n\013MsgResponse\022\017\n\007success" +
|
||||||
"\001 \001(\010\022\017\n\007message\030\002 \001(\t2\213\001\n\023NotificationS" +
|
"\030\001 \001(\010\022\017\n\007message\030\002 \001(\t2\213\001\n\023Notification" +
|
||||||
"ervice\022:\n\016RegisterStream\022\020.RegisterReque" +
|
"Service\022:\n\016RegisterStream\022\020.RegisterRequ" +
|
||||||
"st\032\024.NotificationMessage0\001\0228\n\016shutdownCl" +
|
"est\032\024.NotificationMessage0\001\0228\n\016shutdownC" +
|
||||||
"ient\022\020.RegisterRequest\032\024.NotificationMes" +
|
"lient\022\020.RegisterRequest\032\024.NotificationMe" +
|
||||||
"sageB<\n%com.unisinsight.project.grpc.gen" +
|
"ssageB<\n%com.unisinsight.project.grpc.ge" +
|
||||||
"erateB\021NotificationProtoP\001b\006proto3"
|
"nerateB\021NotificationProtoP\001b\006proto3"
|
||||||
};
|
};
|
||||||
descriptor = com.google.protobuf.Descriptors.FileDescriptor
|
descriptor = com.google.protobuf.Descriptors.FileDescriptor
|
||||||
.internalBuildGeneratedFileFrom(descriptorData,
|
.internalBuildGeneratedFileFrom(descriptorData,
|
||||||
|
|
@ -59,7 +59,7 @@ public final class NotificationProto {
|
||||||
internal_static_RegisterRequest_fieldAccessorTable = new
|
internal_static_RegisterRequest_fieldAccessorTable = new
|
||||||
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
|
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
|
||||||
internal_static_RegisterRequest_descriptor,
|
internal_static_RegisterRequest_descriptor,
|
||||||
new java.lang.String[] { "ClientSn", "ClientMac", });
|
new java.lang.String[] { "ClientSn", "ClientUser", });
|
||||||
internal_static_NotificationMessage_descriptor =
|
internal_static_NotificationMessage_descriptor =
|
||||||
getDescriptor().getMessageTypes().get(1);
|
getDescriptor().getMessageTypes().get(1);
|
||||||
internal_static_NotificationMessage_fieldAccessorTable = new
|
internal_static_NotificationMessage_fieldAccessorTable = new
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ private static final long serialVersionUID = 0L;
|
||||||
}
|
}
|
||||||
private RegisterRequest() {
|
private RegisterRequest() {
|
||||||
clientSn_ = "";
|
clientSn_ = "";
|
||||||
clientMac_ = "";
|
clientUser_ = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@java.lang.Override
|
@java.lang.Override
|
||||||
|
|
@ -59,7 +59,7 @@ private static final long serialVersionUID = 0L;
|
||||||
case 18: {
|
case 18: {
|
||||||
java.lang.String s = input.readStringRequireUtf8();
|
java.lang.String s = input.readStringRequireUtf8();
|
||||||
|
|
||||||
clientMac_ = s;
|
clientUser_ = s;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
|
|
@ -132,38 +132,38 @@ private static final long serialVersionUID = 0L;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final int CLIENT_MAC_FIELD_NUMBER = 2;
|
public static final int CLIENT_USER_FIELD_NUMBER = 2;
|
||||||
private volatile java.lang.Object clientMac_;
|
private volatile java.lang.Object clientUser_;
|
||||||
/**
|
/**
|
||||||
* <code>string client_mac = 2;</code>
|
* <code>string client_user = 2;</code>
|
||||||
* @return The clientMac.
|
* @return The clientUser.
|
||||||
*/
|
*/
|
||||||
@java.lang.Override
|
@java.lang.Override
|
||||||
public java.lang.String getClientMac() {
|
public java.lang.String getClientUser() {
|
||||||
java.lang.Object ref = clientMac_;
|
java.lang.Object ref = clientUser_;
|
||||||
if (ref instanceof java.lang.String) {
|
if (ref instanceof java.lang.String) {
|
||||||
return (java.lang.String) ref;
|
return (java.lang.String) ref;
|
||||||
} else {
|
} else {
|
||||||
com.google.protobuf.ByteString bs =
|
com.google.protobuf.ByteString bs =
|
||||||
(com.google.protobuf.ByteString) ref;
|
(com.google.protobuf.ByteString) ref;
|
||||||
java.lang.String s = bs.toStringUtf8();
|
java.lang.String s = bs.toStringUtf8();
|
||||||
clientMac_ = s;
|
clientUser_ = s;
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* <code>string client_mac = 2;</code>
|
* <code>string client_user = 2;</code>
|
||||||
* @return The bytes for clientMac.
|
* @return The bytes for clientUser.
|
||||||
*/
|
*/
|
||||||
@java.lang.Override
|
@java.lang.Override
|
||||||
public com.google.protobuf.ByteString
|
public com.google.protobuf.ByteString
|
||||||
getClientMacBytes() {
|
getClientUserBytes() {
|
||||||
java.lang.Object ref = clientMac_;
|
java.lang.Object ref = clientUser_;
|
||||||
if (ref instanceof java.lang.String) {
|
if (ref instanceof java.lang.String) {
|
||||||
com.google.protobuf.ByteString b =
|
com.google.protobuf.ByteString b =
|
||||||
com.google.protobuf.ByteString.copyFromUtf8(
|
com.google.protobuf.ByteString.copyFromUtf8(
|
||||||
(java.lang.String) ref);
|
(java.lang.String) ref);
|
||||||
clientMac_ = b;
|
clientUser_ = b;
|
||||||
return b;
|
return b;
|
||||||
} else {
|
} else {
|
||||||
return (com.google.protobuf.ByteString) ref;
|
return (com.google.protobuf.ByteString) ref;
|
||||||
|
|
@ -187,8 +187,8 @@ private static final long serialVersionUID = 0L;
|
||||||
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(clientSn_)) {
|
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(clientSn_)) {
|
||||||
com.google.protobuf.GeneratedMessageV3.writeString(output, 1, clientSn_);
|
com.google.protobuf.GeneratedMessageV3.writeString(output, 1, clientSn_);
|
||||||
}
|
}
|
||||||
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(clientMac_)) {
|
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(clientUser_)) {
|
||||||
com.google.protobuf.GeneratedMessageV3.writeString(output, 2, clientMac_);
|
com.google.protobuf.GeneratedMessageV3.writeString(output, 2, clientUser_);
|
||||||
}
|
}
|
||||||
unknownFields.writeTo(output);
|
unknownFields.writeTo(output);
|
||||||
}
|
}
|
||||||
|
|
@ -202,8 +202,8 @@ private static final long serialVersionUID = 0L;
|
||||||
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(clientSn_)) {
|
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(clientSn_)) {
|
||||||
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, clientSn_);
|
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, clientSn_);
|
||||||
}
|
}
|
||||||
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(clientMac_)) {
|
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(clientUser_)) {
|
||||||
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, clientMac_);
|
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, clientUser_);
|
||||||
}
|
}
|
||||||
size += unknownFields.getSerializedSize();
|
size += unknownFields.getSerializedSize();
|
||||||
memoizedSize = size;
|
memoizedSize = size;
|
||||||
|
|
@ -222,8 +222,8 @@ private static final long serialVersionUID = 0L;
|
||||||
|
|
||||||
if (!getClientSn()
|
if (!getClientSn()
|
||||||
.equals(other.getClientSn())) return false;
|
.equals(other.getClientSn())) return false;
|
||||||
if (!getClientMac()
|
if (!getClientUser()
|
||||||
.equals(other.getClientMac())) return false;
|
.equals(other.getClientUser())) return false;
|
||||||
if (!unknownFields.equals(other.unknownFields)) return false;
|
if (!unknownFields.equals(other.unknownFields)) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -237,8 +237,8 @@ private static final long serialVersionUID = 0L;
|
||||||
hash = (19 * hash) + getDescriptor().hashCode();
|
hash = (19 * hash) + getDescriptor().hashCode();
|
||||||
hash = (37 * hash) + CLIENT_SN_FIELD_NUMBER;
|
hash = (37 * hash) + CLIENT_SN_FIELD_NUMBER;
|
||||||
hash = (53 * hash) + getClientSn().hashCode();
|
hash = (53 * hash) + getClientSn().hashCode();
|
||||||
hash = (37 * hash) + CLIENT_MAC_FIELD_NUMBER;
|
hash = (37 * hash) + CLIENT_USER_FIELD_NUMBER;
|
||||||
hash = (53 * hash) + getClientMac().hashCode();
|
hash = (53 * hash) + getClientUser().hashCode();
|
||||||
hash = (29 * hash) + unknownFields.hashCode();
|
hash = (29 * hash) + unknownFields.hashCode();
|
||||||
memoizedHashCode = hash;
|
memoizedHashCode = hash;
|
||||||
return hash;
|
return hash;
|
||||||
|
|
@ -374,7 +374,7 @@ private static final long serialVersionUID = 0L;
|
||||||
super.clear();
|
super.clear();
|
||||||
clientSn_ = "";
|
clientSn_ = "";
|
||||||
|
|
||||||
clientMac_ = "";
|
clientUser_ = "";
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
@ -403,7 +403,7 @@ private static final long serialVersionUID = 0L;
|
||||||
public com.unisinsight.project.grpc.generate.RegisterRequest buildPartial() {
|
public com.unisinsight.project.grpc.generate.RegisterRequest buildPartial() {
|
||||||
com.unisinsight.project.grpc.generate.RegisterRequest result = new com.unisinsight.project.grpc.generate.RegisterRequest(this);
|
com.unisinsight.project.grpc.generate.RegisterRequest result = new com.unisinsight.project.grpc.generate.RegisterRequest(this);
|
||||||
result.clientSn_ = clientSn_;
|
result.clientSn_ = clientSn_;
|
||||||
result.clientMac_ = clientMac_;
|
result.clientUser_ = clientUser_;
|
||||||
onBuilt();
|
onBuilt();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -456,8 +456,8 @@ private static final long serialVersionUID = 0L;
|
||||||
clientSn_ = other.clientSn_;
|
clientSn_ = other.clientSn_;
|
||||||
onChanged();
|
onChanged();
|
||||||
}
|
}
|
||||||
if (!other.getClientMac().isEmpty()) {
|
if (!other.getClientUser().isEmpty()) {
|
||||||
clientMac_ = other.clientMac_;
|
clientUser_ = other.clientUser_;
|
||||||
onChanged();
|
onChanged();
|
||||||
}
|
}
|
||||||
this.mergeUnknownFields(other.unknownFields);
|
this.mergeUnknownFields(other.unknownFields);
|
||||||
|
|
@ -565,78 +565,78 @@ private static final long serialVersionUID = 0L;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private java.lang.Object clientMac_ = "";
|
private java.lang.Object clientUser_ = "";
|
||||||
/**
|
/**
|
||||||
* <code>string client_mac = 2;</code>
|
* <code>string client_user = 2;</code>
|
||||||
* @return The clientMac.
|
* @return The clientUser.
|
||||||
*/
|
*/
|
||||||
public java.lang.String getClientMac() {
|
public java.lang.String getClientUser() {
|
||||||
java.lang.Object ref = clientMac_;
|
java.lang.Object ref = clientUser_;
|
||||||
if (!(ref instanceof java.lang.String)) {
|
if (!(ref instanceof java.lang.String)) {
|
||||||
com.google.protobuf.ByteString bs =
|
com.google.protobuf.ByteString bs =
|
||||||
(com.google.protobuf.ByteString) ref;
|
(com.google.protobuf.ByteString) ref;
|
||||||
java.lang.String s = bs.toStringUtf8();
|
java.lang.String s = bs.toStringUtf8();
|
||||||
clientMac_ = s;
|
clientUser_ = s;
|
||||||
return s;
|
return s;
|
||||||
} else {
|
} else {
|
||||||
return (java.lang.String) ref;
|
return (java.lang.String) ref;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* <code>string client_mac = 2;</code>
|
* <code>string client_user = 2;</code>
|
||||||
* @return The bytes for clientMac.
|
* @return The bytes for clientUser.
|
||||||
*/
|
*/
|
||||||
public com.google.protobuf.ByteString
|
public com.google.protobuf.ByteString
|
||||||
getClientMacBytes() {
|
getClientUserBytes() {
|
||||||
java.lang.Object ref = clientMac_;
|
java.lang.Object ref = clientUser_;
|
||||||
if (ref instanceof String) {
|
if (ref instanceof String) {
|
||||||
com.google.protobuf.ByteString b =
|
com.google.protobuf.ByteString b =
|
||||||
com.google.protobuf.ByteString.copyFromUtf8(
|
com.google.protobuf.ByteString.copyFromUtf8(
|
||||||
(java.lang.String) ref);
|
(java.lang.String) ref);
|
||||||
clientMac_ = b;
|
clientUser_ = b;
|
||||||
return b;
|
return b;
|
||||||
} else {
|
} else {
|
||||||
return (com.google.protobuf.ByteString) ref;
|
return (com.google.protobuf.ByteString) ref;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* <code>string client_mac = 2;</code>
|
* <code>string client_user = 2;</code>
|
||||||
* @param value The clientMac to set.
|
* @param value The clientUser to set.
|
||||||
* @return This builder for chaining.
|
* @return This builder for chaining.
|
||||||
*/
|
*/
|
||||||
public Builder setClientMac(
|
public Builder setClientUser(
|
||||||
java.lang.String value) {
|
java.lang.String value) {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
throw new NullPointerException();
|
throw new NullPointerException();
|
||||||
}
|
}
|
||||||
|
|
||||||
clientMac_ = value;
|
clientUser_ = value;
|
||||||
onChanged();
|
onChanged();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* <code>string client_mac = 2;</code>
|
* <code>string client_user = 2;</code>
|
||||||
* @return This builder for chaining.
|
* @return This builder for chaining.
|
||||||
*/
|
*/
|
||||||
public Builder clearClientMac() {
|
public Builder clearClientUser() {
|
||||||
|
|
||||||
clientMac_ = getDefaultInstance().getClientMac();
|
clientUser_ = getDefaultInstance().getClientUser();
|
||||||
onChanged();
|
onChanged();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* <code>string client_mac = 2;</code>
|
* <code>string client_user = 2;</code>
|
||||||
* @param value The bytes for clientMac to set.
|
* @param value The bytes for clientUser to set.
|
||||||
* @return This builder for chaining.
|
* @return This builder for chaining.
|
||||||
*/
|
*/
|
||||||
public Builder setClientMacBytes(
|
public Builder setClientUserBytes(
|
||||||
com.google.protobuf.ByteString value) {
|
com.google.protobuf.ByteString value) {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
throw new NullPointerException();
|
throw new NullPointerException();
|
||||||
}
|
}
|
||||||
checkByteStringIsUtf8(value);
|
checkByteStringIsUtf8(value);
|
||||||
|
|
||||||
clientMac_ = value;
|
clientUser_ = value;
|
||||||
onChanged();
|
onChanged();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,14 +20,14 @@ public interface RegisterRequestOrBuilder extends
|
||||||
getClientSnBytes();
|
getClientSnBytes();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <code>string client_mac = 2;</code>
|
* <code>string client_user = 2;</code>
|
||||||
* @return The clientMac.
|
* @return The clientUser.
|
||||||
*/
|
*/
|
||||||
java.lang.String getClientMac();
|
java.lang.String getClientUser();
|
||||||
/**
|
/**
|
||||||
* <code>string client_mac = 2;</code>
|
* <code>string client_user = 2;</code>
|
||||||
* @return The bytes for clientMac.
|
* @return The bytes for clientUser.
|
||||||
*/
|
*/
|
||||||
com.google.protobuf.ByteString
|
com.google.protobuf.ByteString
|
||||||
getClientMacBytes();
|
getClientUserBytes();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ service NotificationService {
|
||||||
|
|
||||||
message RegisterRequest {
|
message RegisterRequest {
|
||||||
string client_sn = 1;
|
string client_sn = 1;
|
||||||
string client_mac = 2;
|
string client_user = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message NotificationMessage {
|
message NotificationMessage {
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ public class ClientNotificationServiceImpl extends NotificationServiceGrpc.Notif
|
||||||
@Override
|
@Override
|
||||||
public void registerStream(RegisterRequest request, StreamObserver<NotificationMessage> responseObserver) {
|
public void registerStream(RegisterRequest request, StreamObserver<NotificationMessage> responseObserver) {
|
||||||
String clientSn = request.getClientSn();
|
String clientSn = request.getClientSn();
|
||||||
String clientMac = request.getClientMac();
|
String clientUser = request.getClientUser();
|
||||||
|
|
||||||
if (StringUtil.isEmpty(clientSn)) {
|
if (StringUtil.isEmpty(clientSn)) {
|
||||||
NotificationMessage errMsg = NotificationMessage.newBuilder()
|
NotificationMessage errMsg = NotificationMessage.newBuilder()
|
||||||
|
|
@ -64,19 +64,19 @@ public class ClientNotificationServiceImpl extends NotificationServiceGrpc.Notif
|
||||||
return; // 避免继续执行后续逻辑
|
return; // 避免继续执行后续逻辑
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StringUtil.isEmpty(clientMac)) {
|
if (StringUtil.isEmpty(clientUser)) {
|
||||||
NotificationMessage errMsg = NotificationMessage.newBuilder()
|
NotificationMessage errMsg = NotificationMessage.newBuilder()
|
||||||
.setCode(HttpStatus.BAD_REQUEST.value())
|
.setCode(HttpStatus.BAD_REQUEST.value())
|
||||||
.setMsg("client_mac不能为空")
|
.setMsg("client_user不能为空")
|
||||||
.build();
|
.build();
|
||||||
responseObserver.onNext(errMsg);
|
responseObserver.onNext(errMsg);
|
||||||
responseObserver.onCompleted();
|
responseObserver.onCompleted();
|
||||||
return; // 避免继续执行后续逻辑
|
return; // 避免继续执行后续逻辑
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("客户端连接:client_sn:[{}],client_mac: [{}]", clientSn, clientMac);
|
log.info("客户端连接:client_sn:[{}],client_user: [{}]", clientSn, clientUser);
|
||||||
|
|
||||||
addClientConnection(responseObserver, clientSn, clientMac);
|
addClientConnection(responseObserver, clientSn, clientUser);
|
||||||
|
|
||||||
|
|
||||||
responseObserver.onNext(NotificationMessage.newBuilder()
|
responseObserver.onNext(NotificationMessage.newBuilder()
|
||||||
|
|
@ -107,7 +107,7 @@ public class ClientNotificationServiceImpl extends NotificationServiceGrpc.Notif
|
||||||
return remove;
|
return remove;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addClientConnection(StreamObserver<NotificationMessage> responseObserver, String clientId, String clientMac) {
|
private void addClientConnection(StreamObserver<NotificationMessage> responseObserver, String clientId, String clientUser) {
|
||||||
if (clientStreamMap.size() >= MAX_CLIENT_COUNT) {
|
if (clientStreamMap.size() >= MAX_CLIENT_COUNT) {
|
||||||
NotificationMessage errMsg = NotificationMessage.newBuilder()
|
NotificationMessage errMsg = NotificationMessage.newBuilder()
|
||||||
.setCode(HttpStatus.TOO_MANY_REQUESTS.value())
|
.setCode(HttpStatus.TOO_MANY_REQUESTS.value())
|
||||||
|
|
@ -140,7 +140,6 @@ public class ClientNotificationServiceImpl extends NotificationServiceGrpc.Notif
|
||||||
LambdaUpdateWrapper<Device> updateWrapper = new LambdaUpdateWrapper<>();
|
LambdaUpdateWrapper<Device> updateWrapper = new LambdaUpdateWrapper<>();
|
||||||
//在线
|
//在线
|
||||||
updateWrapper.set(Device::getDeviceStatus, 1);
|
updateWrapper.set(Device::getDeviceStatus, 1);
|
||||||
updateWrapper.set(Device::getMacAddr, clientMac);
|
|
||||||
updateWrapper.eq(Device::getDeviceId, clientId);
|
updateWrapper.eq(Device::getDeviceId, clientId);
|
||||||
deviceService.update(updateWrapper);
|
deviceService.update(updateWrapper);
|
||||||
}
|
}
|
||||||
|
|
@ -148,7 +147,7 @@ public class ClientNotificationServiceImpl extends NotificationServiceGrpc.Notif
|
||||||
@Override
|
@Override
|
||||||
public void shutdownClient(RegisterRequest request, StreamObserver<NotificationMessage> responseObserver) {
|
public void shutdownClient(RegisterRequest request, StreamObserver<NotificationMessage> responseObserver) {
|
||||||
String clientSn = request.getClientSn();
|
String clientSn = request.getClientSn();
|
||||||
String clientMac = request.getClientMac();
|
String clientUser = request.getClientUser();
|
||||||
|
|
||||||
if (StringUtil.isEmpty(clientSn)) {
|
if (StringUtil.isEmpty(clientSn)) {
|
||||||
NotificationMessage errMsg = NotificationMessage.newBuilder()
|
NotificationMessage errMsg = NotificationMessage.newBuilder()
|
||||||
|
|
@ -160,16 +159,16 @@ public class ClientNotificationServiceImpl extends NotificationServiceGrpc.Notif
|
||||||
return; // 避免继续执行后续逻辑
|
return; // 避免继续执行后续逻辑
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StringUtil.isEmpty(clientMac)) {
|
if (StringUtil.isEmpty(clientUser)) {
|
||||||
NotificationMessage errMsg = NotificationMessage.newBuilder()
|
NotificationMessage errMsg = NotificationMessage.newBuilder()
|
||||||
.setCode(HttpStatus.BAD_REQUEST.value())
|
.setCode(HttpStatus.BAD_REQUEST.value())
|
||||||
.setMsg("client_mac不能为空")
|
.setMsg("client_user不能为空")
|
||||||
.build();
|
.build();
|
||||||
responseObserver.onNext(errMsg);
|
responseObserver.onNext(errMsg);
|
||||||
responseObserver.onCompleted();
|
responseObserver.onCompleted();
|
||||||
return; // 避免继续执行后续逻辑
|
return; // 避免继续执行后续逻辑
|
||||||
}
|
}
|
||||||
log.info("客户端注销:client_sn:[{}],client_mac: [{}]", clientSn, clientMac);
|
log.info("客户端注销:client_sn:[{}],client_user: [{}]", clientSn, clientUser);
|
||||||
|
|
||||||
// 安全地移除并关闭连接
|
// 安全地移除并关闭连接
|
||||||
StreamObserver<NotificationMessage> notificationStream = removeClientConnection(clientSn);
|
StreamObserver<NotificationMessage> notificationStream = removeClientConnection(clientSn);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.unisinsight.project.mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import com.unisinsight.project.entity.dao.ImageDesktop;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 桌面镜像(ImageDesktop)表数据库访问层
|
||||||
|
*
|
||||||
|
* @author ch
|
||||||
|
* @since 2025-08-29 09:23:02
|
||||||
|
*/
|
||||||
|
public interface ImageDesktopMapper extends BaseMapper<ImageDesktop> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.unisinsight.project.service;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.unisinsight.project.entity.dao.ImageDesktop;
|
||||||
|
import com.unisinsight.project.entity.req.DeleteIdReq;
|
||||||
|
import com.unisinsight.project.entity.req.ImageDesktopReq;
|
||||||
|
import com.unisinsight.project.entity.res.ImageDesktopRes;
|
||||||
|
import com.unisinsight.project.entity.res.PageResult;
|
||||||
|
import com.unisinsight.project.exception.Result;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 桌面镜像(ImageDesktop)表服务接口
|
||||||
|
*
|
||||||
|
* @author ch
|
||||||
|
* @since 2025-08-29 09:23:02
|
||||||
|
*/
|
||||||
|
public interface ImageDesktopService extends IService<ImageDesktop> {
|
||||||
|
Result<PageResult<ImageDesktopRes>> selectPage(ImageDesktopReq imageDesktopReq);
|
||||||
|
|
||||||
|
Result<?> insert(ImageDesktopReq imageDesktopReq);
|
||||||
|
|
||||||
|
Result<?> update(ImageDesktopReq imageDesktopReq);
|
||||||
|
|
||||||
|
Result<?> query(ImageDesktopReq imageDesktopReq);
|
||||||
|
|
||||||
|
Result<?> delete(DeleteIdReq deleteIdReq);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,117 @@
|
||||||
|
package com.unisinsight.project.service.impl;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.unisinsight.project.entity.dao.ImageDesktop;
|
||||||
|
import com.unisinsight.project.entity.req.DeleteIdReq;
|
||||||
|
import com.unisinsight.project.entity.req.ImageDesktopReq;
|
||||||
|
import com.unisinsight.project.entity.res.ImageDesktopRes;
|
||||||
|
import com.unisinsight.project.entity.res.PageResult;
|
||||||
|
import com.unisinsight.project.exception.BaseErrorCode;
|
||||||
|
import com.unisinsight.project.exception.Result;
|
||||||
|
import com.unisinsight.project.mapper.ImageDesktopMapper;
|
||||||
|
import com.unisinsight.project.service.ImageDesktopService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
/**
|
||||||
|
* 桌面镜像(ImageDesktop)表服务实现类
|
||||||
|
*
|
||||||
|
* @author ch
|
||||||
|
* @since 2025-08-29 09:23:02
|
||||||
|
*/
|
||||||
|
@Service("imageDesktopService")
|
||||||
|
public class ImageDesktopServiceImpl extends ServiceImpl<ImageDesktopMapper, ImageDesktop> implements ImageDesktopService {
|
||||||
|
@Resource
|
||||||
|
private ImageDesktopMapper mapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<PageResult<ImageDesktopRes>> selectPage(ImageDesktopReq imageDesktopReq) {
|
||||||
|
Page<ImageDesktop> page = new Page<>(imageDesktopReq.getPageNum(), imageDesktopReq.getPageSize());
|
||||||
|
LambdaQueryWrapper<ImageDesktop> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.orderByAsc(ImageDesktop::getId);
|
||||||
|
Page<ImageDesktop> imageDesktopPage = mapper.selectPage(page, queryWrapper);
|
||||||
|
log.info("分页查询桌面镜像返回:{}", JSONUtil.toJsonStr(imageDesktopPage));
|
||||||
|
if (CollectionUtil.isEmpty(imageDesktopPage.getRecords())) {
|
||||||
|
log.info("分页查询桌面镜像返回为空");
|
||||||
|
return Result.successResult();
|
||||||
|
} else {
|
||||||
|
PageResult<ImageDesktopRes> convert = PageResult.convertIPage(imageDesktopPage, ImageDesktopRes.class);
|
||||||
|
List<ImageDesktopRes> data = convert.getData();
|
||||||
|
convert.setData(data);
|
||||||
|
return Result.successResult(convert);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<?> insert(ImageDesktopReq imageDesktopReq) {
|
||||||
|
ImageDesktop imageDesktop = BeanUtil.copyProperties(imageDesktopReq, ImageDesktop.class);
|
||||||
|
// QueryWrapper<ImageVirtualMachines> queryWrapper = new QueryWrapper<>();
|
||||||
|
// queryWrapper.lambda().eq(ImageVirtualMachines::getImageName, imageVirtualMachines.getImageName());
|
||||||
|
// ImageVirtualMachines selectOne = machinesMapper.selectOne(queryWrapper);
|
||||||
|
// if (ObjectUtils.isNotEmpty(selectOne)) {
|
||||||
|
// return new Result<>("200", "名称重复");
|
||||||
|
// }
|
||||||
|
imageDesktop.setCreateUser("admin");
|
||||||
|
imageDesktop.setUpdateUser("admin");
|
||||||
|
int insert = mapper.insert(imageDesktop);
|
||||||
|
log.info("桌面镜像新增insert:{}", insert);
|
||||||
|
|
||||||
|
if (insert == 1) {
|
||||||
|
return Result.successResult();
|
||||||
|
} else {
|
||||||
|
return Result.errorResult(BaseErrorCode.HTTP_ERROR_CODE_500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<?> update(ImageDesktopReq imageDesktopReq) {
|
||||||
|
ImageDesktop imageDesktop = BeanUtil.copyProperties(imageDesktopReq, ImageDesktop.class);
|
||||||
|
imageDesktop.setUpdateUser("admin");
|
||||||
|
int updated = mapper.updateById(imageDesktop);
|
||||||
|
log.info("桌面镜像修改updated:{}", updated);
|
||||||
|
if (updated == 1) {
|
||||||
|
return Result.successResult();
|
||||||
|
} else {
|
||||||
|
return Result.errorResult(BaseErrorCode.HTTP_ERROR_CODE_500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<?> query(ImageDesktopReq imageDesktopReq) {
|
||||||
|
ImageDesktop imageDesktop = mapper.selectById(imageDesktopReq.getId());
|
||||||
|
|
||||||
|
if (ObjectUtils.isEmpty(imageDesktop)) {
|
||||||
|
log.info("查询桌面镜像返回为空");
|
||||||
|
return Result.successResult();
|
||||||
|
}
|
||||||
|
ImageDesktopRes res = BeanUtil.copyProperties(imageDesktop, ImageDesktopRes.class);
|
||||||
|
log.info("查询桌面镜像返回:{}", JSONUtil.toJsonStr(res));
|
||||||
|
return Result.successResult(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<?> delete(DeleteIdReq deleteIdReq) {
|
||||||
|
int deleted = mapper.deleteById(deleteIdReq.getId());
|
||||||
|
log.info("桌面镜像删除insert:{}", deleted);
|
||||||
|
if (deleted == 1) {
|
||||||
|
return Result.successResult();
|
||||||
|
} else {
|
||||||
|
return Result.errorResult(BaseErrorCode.HTTP_ERROR_CODE_500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -220,7 +220,7 @@ public class ImageVirtualMachinesServiceImpl extends ServiceImpl<ImageVirtualMac
|
||||||
@Override
|
@Override
|
||||||
public Result<?> delete(DeleteIdReq deleteIdReq) {
|
public Result<?> delete(DeleteIdReq deleteIdReq) {
|
||||||
int deleted = machinesMapper.deleteById(deleteIdReq.getId());
|
int deleted = machinesMapper.deleteById(deleteIdReq.getId());
|
||||||
log.info("终端删除insert:{}", deleted);
|
log.info("终端删除delete:{}", deleted);
|
||||||
if (deleted == 1) {
|
if (deleted == 1) {
|
||||||
return Result.successResult();
|
return Result.successResult();
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -230,7 +230,7 @@ public class ImageVirtualMachinesServiceImpl extends ServiceImpl<ImageVirtualMac
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result<?> cloneTemplate(ImageVirtualMachinesReq req) {
|
public Result<?> cloneTemplate(ImageVirtualMachinesReq req) {
|
||||||
//todo 调用镜像生成服务 在生成完毕后生成桌面镜像数据
|
//todo 调用镜像生成服务 在生成完毕后生成桌面镜像数据 桌面镜像加BT
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ mybatis-plus:
|
||||||
grpc:
|
grpc:
|
||||||
server:
|
server:
|
||||||
# 指定Grpc暴露的端口,后续客户端通过这个端口访问
|
# 指定Grpc暴露的端口,后续客户端通过这个端口访问
|
||||||
port: 51051
|
port: 50051
|
||||||
|
|
||||||
# Feign 配置
|
# Feign 配置
|
||||||
feign:
|
feign:
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.unisinsight.project.mapper.ImageDesktopMapper">
|
||||||
|
|
||||||
|
<resultMap type="com.unisinsight.project.entity.dao.ImageDesktop" id="ImageDesktopMap">
|
||||||
|
<result property="id" column="id" jdbcType="INTEGER"/>
|
||||||
|
<result property="desktopName" column="desktop_name" jdbcType="VARCHAR"/>
|
||||||
|
<result property="desktopType" column="desktop_type" jdbcType="INTEGER"/>
|
||||||
|
<result property="imageVirtualId" column="image_virtual_id" jdbcType="INTEGER"/>
|
||||||
|
<result property="publishStatus" column="publish_status" jdbcType="VARCHAR"/>
|
||||||
|
<result property="osVersion" column="os_version" jdbcType="VARCHAR"/>
|
||||||
|
<result property="btPath" column="bt_path" jdbcType="VARCHAR"/>
|
||||||
|
<result property="storagePath" column="storage_path" jdbcType="VARCHAR"/>
|
||||||
|
<result property="createTime" column="create_time" jdbcType="VARCHAR"/>
|
||||||
|
<result property="createUser" column="create_user" jdbcType="VARCHAR"/>
|
||||||
|
<result property="updateTime" column="update_time" jdbcType="VARCHAR"/>
|
||||||
|
<result property="updateUser" column="update_user" jdbcType="VARCHAR"/>
|
||||||
|
<result property="deleted" column="deleted" jdbcType="INTEGER"/>
|
||||||
|
<result property="description" column="description" jdbcType="VARCHAR"/>
|
||||||
|
<result property="publishTime" column="publish_time" jdbcType="TIMESTAMP"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
id, desktop_name, desktop_type, image_virtual_id, publish_status, os_version, bt_path, storage_path, create_time, create_user, update_time, update_user, deleted, description, publish_time
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
|
||||||
|
</mapper>
|
||||||
|
|
||||||
Loading…
Reference in New Issue