add iot frp
parent
26fac3bc25
commit
24ad57c7d9
@ -0,0 +1,96 @@
|
|||||||
|
package cn.iocoder.yudao.module.iot.controller.admin.frpc;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||||
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.iot.controller.admin.frpc.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.iot.dal.dataobject.frpc.FrpcProxyServerDO;
|
||||||
|
import cn.iocoder.yudao.module.iot.service.frpc.FrpcProxyServerService;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
|
@Tag(name = "管理后台 - 代理服务")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/iot/frpc-proxy-server")
|
||||||
|
@Validated
|
||||||
|
public class FrpcProxyServerController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private FrpcProxyServerService frpcProxyServerService;
|
||||||
|
|
||||||
|
@PostMapping("/create")
|
||||||
|
@Operation(summary = "创建代理服务")
|
||||||
|
@PreAuthorize("@ss.hasPermission('iot:frpc-proxy-server:create')")
|
||||||
|
public CommonResult<Long> createFrpcProxyServer(@Valid @RequestBody FrpcProxyServerSaveReqVO createReqVO) {
|
||||||
|
return success(frpcProxyServerService.createFrpcProxyServer(createReqVO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/update")
|
||||||
|
@Operation(summary = "更新代理服务")
|
||||||
|
@PreAuthorize("@ss.hasPermission('iot:frpc-proxy-server:update')")
|
||||||
|
public CommonResult<Boolean> updateFrpcProxyServer(@Valid @RequestBody FrpcProxyServerSaveReqVO updateReqVO) {
|
||||||
|
frpcProxyServerService.updateFrpcProxyServer(updateReqVO);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/delete")
|
||||||
|
@Operation(summary = "删除代理服务")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true)
|
||||||
|
@PreAuthorize("@ss.hasPermission('iot:frpc-proxy-server:delete')")
|
||||||
|
public CommonResult<Boolean> deleteFrpcProxyServer(@RequestParam("id") Long id) {
|
||||||
|
frpcProxyServerService.deleteFrpcProxyServer(id);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get")
|
||||||
|
@Operation(summary = "获得代理服务")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
|
@PreAuthorize("@ss.hasPermission('iot:frpc-proxy-server:query')")
|
||||||
|
public CommonResult<FrpcProxyServerRespVO> getFrpcProxyServer(@RequestParam("id") Long id) {
|
||||||
|
FrpcProxyServerDO frpcProxyServer = frpcProxyServerService.getFrpcProxyServer(id);
|
||||||
|
return success(BeanUtils.toBean(frpcProxyServer, FrpcProxyServerRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/page")
|
||||||
|
@Operation(summary = "获得代理服务分页")
|
||||||
|
@PreAuthorize("@ss.hasPermission('iot:frpc-proxy-server:query')")
|
||||||
|
public CommonResult<PageResult<FrpcProxyServerRespVO>> getFrpcProxyServerPage(@Valid FrpcProxyServerPageReqVO pageReqVO) {
|
||||||
|
PageResult<FrpcProxyServerDO> pageResult = frpcProxyServerService.getFrpcProxyServerPage(pageReqVO);
|
||||||
|
return success(BeanUtils.toBean(pageResult, FrpcProxyServerRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/export-excel")
|
||||||
|
@Operation(summary = "导出代理服务 Excel")
|
||||||
|
@PreAuthorize("@ss.hasPermission('iot:frpc-proxy-server:export')")
|
||||||
|
@ApiAccessLog(operateType = EXPORT)
|
||||||
|
public void exportFrpcProxyServerExcel(@Valid FrpcProxyServerPageReqVO pageReqVO,
|
||||||
|
HttpServletResponse response) throws IOException {
|
||||||
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||||
|
List<FrpcProxyServerDO> list = frpcProxyServerService.getFrpcProxyServerPage(pageReqVO).getList();
|
||||||
|
// 导出 Excel
|
||||||
|
ExcelUtils.write(response, "代理服务.xls", "数据", FrpcProxyServerRespVO.class,
|
||||||
|
BeanUtils.toBean(list, FrpcProxyServerRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,55 @@
|
|||||||
|
package cn.iocoder.yudao.module.iot.controller.admin.frpc.vo;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 代理服务分页 Request VO")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class FrpcProxyServerPageReqVO extends PageParam {
|
||||||
|
|
||||||
|
@Schema(description = "代理名称", example = "芋艿")
|
||||||
|
private String frpcName;
|
||||||
|
|
||||||
|
@Schema(description = "内网IP")
|
||||||
|
private String localIp;
|
||||||
|
|
||||||
|
@Schema(description = "内网端口")
|
||||||
|
private Integer localPort;
|
||||||
|
|
||||||
|
@Schema(description = "访问后缀")
|
||||||
|
private String suffixPath;
|
||||||
|
|
||||||
|
@Schema(description = "内网状态", example = "1")
|
||||||
|
private String localStatus;
|
||||||
|
|
||||||
|
@Schema(description = "代理服务器", example = "30251")
|
||||||
|
private Long frpsId;
|
||||||
|
|
||||||
|
@Schema(description = "代理端口")
|
||||||
|
private Integer proxyPort;
|
||||||
|
|
||||||
|
@Schema(description = "代理地址")
|
||||||
|
private String proxyAddress;
|
||||||
|
|
||||||
|
@Schema(description = "代理状态", example = "2")
|
||||||
|
private String proxyStatus;
|
||||||
|
|
||||||
|
@Schema(description = "备注", example = "随便")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
@Schema(description = "是否启用")
|
||||||
|
private Boolean isEnable;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间")
|
||||||
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
|
private LocalDateTime[] createTime;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,73 @@
|
|||||||
|
package cn.iocoder.yudao.module.iot.controller.admin.frpc.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.*;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import com.alibaba.excel.annotation.*;
|
||||||
|
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||||
|
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 代理服务 Response VO")
|
||||||
|
@Data
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
public class FrpcProxyServerRespVO {
|
||||||
|
|
||||||
|
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "24857")
|
||||||
|
@ExcelProperty("id")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "代理名称", example = "芋艿")
|
||||||
|
@ExcelProperty("代理名称")
|
||||||
|
private String frpcName;
|
||||||
|
|
||||||
|
@Schema(description = "内网IP")
|
||||||
|
@ExcelProperty("内网IP")
|
||||||
|
private String localIp;
|
||||||
|
|
||||||
|
@Schema(description = "内网端口")
|
||||||
|
@ExcelProperty("内网端口")
|
||||||
|
private Integer localPort;
|
||||||
|
|
||||||
|
@Schema(description = "访问后缀")
|
||||||
|
@ExcelProperty("访问后缀")
|
||||||
|
private String suffixPath;
|
||||||
|
|
||||||
|
@Schema(description = "内网状态", example = "1")
|
||||||
|
@ExcelProperty(value = "内网状态", converter = DictConvert.class)
|
||||||
|
@DictFormat("iot_proxy_server_status") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
|
||||||
|
private String localStatus;
|
||||||
|
|
||||||
|
@Schema(description = "代理服务器", example = "30251")
|
||||||
|
@ExcelProperty("代理服务器")
|
||||||
|
private Long frpsId;
|
||||||
|
|
||||||
|
@Schema(description = "代理端口")
|
||||||
|
@ExcelProperty("代理端口")
|
||||||
|
private Integer proxyPort;
|
||||||
|
|
||||||
|
@Schema(description = "代理地址")
|
||||||
|
@ExcelProperty("代理地址")
|
||||||
|
private String proxyAddress;
|
||||||
|
|
||||||
|
@Schema(description = "代理状态", example = "2")
|
||||||
|
@ExcelProperty(value = "代理状态", converter = DictConvert.class)
|
||||||
|
@DictFormat("iot_proxy_server_status") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
|
||||||
|
private String proxyStatus;
|
||||||
|
|
||||||
|
@Schema(description = "备注", example = "随便")
|
||||||
|
@ExcelProperty("备注")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
@Schema(description = "是否启用", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty(value = "是否启用", converter = DictConvert.class)
|
||||||
|
@DictFormat("infra_boolean_string") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
|
||||||
|
private Boolean isEnable;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("创建时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,49 @@
|
|||||||
|
package cn.iocoder.yudao.module.iot.controller.admin.frpc.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 代理服务新增/修改 Request VO")
|
||||||
|
@Data
|
||||||
|
public class FrpcProxyServerSaveReqVO {
|
||||||
|
|
||||||
|
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "24857")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "代理名称", example = "芋艿")
|
||||||
|
private String frpcName;
|
||||||
|
|
||||||
|
@Schema(description = "内网IP")
|
||||||
|
private String localIp;
|
||||||
|
|
||||||
|
@Schema(description = "内网端口")
|
||||||
|
private Integer localPort;
|
||||||
|
|
||||||
|
@Schema(description = "访问后缀")
|
||||||
|
private String suffixPath;
|
||||||
|
|
||||||
|
@Schema(description = "内网状态", example = "1")
|
||||||
|
private String localStatus;
|
||||||
|
|
||||||
|
@Schema(description = "代理服务器", example = "30251")
|
||||||
|
private Long frpsId;
|
||||||
|
|
||||||
|
@Schema(description = "代理端口")
|
||||||
|
private Integer proxyPort;
|
||||||
|
|
||||||
|
@Schema(description = "代理地址")
|
||||||
|
private String proxyAddress;
|
||||||
|
|
||||||
|
@Schema(description = "代理状态", example = "2")
|
||||||
|
private String proxyStatus;
|
||||||
|
|
||||||
|
@Schema(description = "备注", example = "随便")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
@Schema(description = "是否启用", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotNull(message = "是否启用不能为空")
|
||||||
|
private Boolean isEnable;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,95 @@
|
|||||||
|
package cn.iocoder.yudao.module.iot.controller.admin.frps;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import java.util.*;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||||
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.iot.controller.admin.frps.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.iot.dal.dataobject.frps.FrpsServerDO;
|
||||||
|
import cn.iocoder.yudao.module.iot.service.frps.FrpsServerService;
|
||||||
|
|
||||||
|
@Tag(name = "管理后台 - 代理服务器")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/iot/frps-server")
|
||||||
|
@Validated
|
||||||
|
public class FrpsServerController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private FrpsServerService frpsServerService;
|
||||||
|
|
||||||
|
@PostMapping("/create")
|
||||||
|
@Operation(summary = "创建代理服务器")
|
||||||
|
@PreAuthorize("@ss.hasPermission('iot:frps-server:create')")
|
||||||
|
public CommonResult<Long> createFrpsServer(@Valid @RequestBody FrpsServerSaveReqVO createReqVO) {
|
||||||
|
return success(frpsServerService.createFrpsServer(createReqVO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/update")
|
||||||
|
@Operation(summary = "更新代理服务器")
|
||||||
|
@PreAuthorize("@ss.hasPermission('iot:frps-server:update')")
|
||||||
|
public CommonResult<Boolean> updateFrpsServer(@Valid @RequestBody FrpsServerSaveReqVO updateReqVO) {
|
||||||
|
frpsServerService.updateFrpsServer(updateReqVO);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/delete")
|
||||||
|
@Operation(summary = "删除代理服务器")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true)
|
||||||
|
@PreAuthorize("@ss.hasPermission('iot:frps-server:delete')")
|
||||||
|
public CommonResult<Boolean> deleteFrpsServer(@RequestParam("id") Long id) {
|
||||||
|
frpsServerService.deleteFrpsServer(id);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get")
|
||||||
|
@Operation(summary = "获得代理服务器")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
|
@PreAuthorize("@ss.hasPermission('iot:frps-server:query')")
|
||||||
|
public CommonResult<FrpsServerRespVO> getFrpsServer(@RequestParam("id") Long id) {
|
||||||
|
FrpsServerDO frpsServer = frpsServerService.getFrpsServer(id);
|
||||||
|
return success(BeanUtils.toBean(frpsServer, FrpsServerRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/page")
|
||||||
|
@Operation(summary = "获得代理服务器分页")
|
||||||
|
@PreAuthorize("@ss.hasPermission('iot:frps-server:query')")
|
||||||
|
public CommonResult<PageResult<FrpsServerRespVO>> getFrpsServerPage(@Valid FrpsServerPageReqVO pageReqVO) {
|
||||||
|
PageResult<FrpsServerDO> pageResult = frpsServerService.getFrpsServerPage(pageReqVO);
|
||||||
|
return success(BeanUtils.toBean(pageResult, FrpsServerRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/export-excel")
|
||||||
|
@Operation(summary = "导出代理服务器 Excel")
|
||||||
|
@PreAuthorize("@ss.hasPermission('iot:frps-server:export')")
|
||||||
|
@ApiAccessLog(operateType = EXPORT)
|
||||||
|
public void exportFrpsServerExcel(@Valid FrpsServerPageReqVO pageReqVO,
|
||||||
|
HttpServletResponse response) throws IOException {
|
||||||
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||||
|
List<FrpsServerDO> list = frpsServerService.getFrpsServerPage(pageReqVO).getList();
|
||||||
|
// 导出 Excel
|
||||||
|
ExcelUtils.write(response, "代理服务器.xls", "数据", FrpsServerRespVO.class,
|
||||||
|
BeanUtils.toBean(list, FrpsServerRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,49 @@
|
|||||||
|
package cn.iocoder.yudao.module.iot.controller.admin.frps.vo;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 代理服务器分页 Request VO")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class FrpsServerPageReqVO extends PageParam {
|
||||||
|
|
||||||
|
@Schema(description = "名称", example = "芋艿")
|
||||||
|
private String frpsName;
|
||||||
|
|
||||||
|
@Schema(description = "mac地址")
|
||||||
|
private String hostMac;
|
||||||
|
|
||||||
|
@Schema(description = "操作系统")
|
||||||
|
private String hostOs;
|
||||||
|
|
||||||
|
@Schema(description = "服务IP")
|
||||||
|
private String hostIp;
|
||||||
|
|
||||||
|
@Schema(description = "服务端口")
|
||||||
|
private Integer hostPort;
|
||||||
|
|
||||||
|
@Schema(description = "程序绝对路径")
|
||||||
|
private String frpsPath;
|
||||||
|
|
||||||
|
@Schema(description = "服务状态")
|
||||||
|
private String frpsState;
|
||||||
|
|
||||||
|
@Schema(description = "备注", example = "随便")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
@Schema(description = "是否启用")
|
||||||
|
private Boolean isEnable;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间")
|
||||||
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
|
private LocalDateTime[] createTime;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,64 @@
|
|||||||
|
package cn.iocoder.yudao.module.iot.controller.admin.frps.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.*;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import com.alibaba.excel.annotation.*;
|
||||||
|
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||||
|
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 代理服务器 Response VO")
|
||||||
|
@Data
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
public class FrpsServerRespVO {
|
||||||
|
|
||||||
|
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "18589")
|
||||||
|
@ExcelProperty("id")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "名称", example = "芋艿")
|
||||||
|
@ExcelProperty("名称")
|
||||||
|
private String frpsName;
|
||||||
|
|
||||||
|
@Schema(description = "mac地址")
|
||||||
|
@ExcelProperty("mac地址")
|
||||||
|
private String hostMac;
|
||||||
|
|
||||||
|
@Schema(description = "操作系统")
|
||||||
|
@ExcelProperty("操作系统")
|
||||||
|
private String hostOs;
|
||||||
|
|
||||||
|
@Schema(description = "服务IP")
|
||||||
|
@ExcelProperty("服务IP")
|
||||||
|
private String hostIp;
|
||||||
|
|
||||||
|
@Schema(description = "服务端口")
|
||||||
|
@ExcelProperty("服务端口")
|
||||||
|
private Integer hostPort;
|
||||||
|
|
||||||
|
@Schema(description = "程序绝对路径")
|
||||||
|
@ExcelProperty("程序绝对路径")
|
||||||
|
private String frpsPath;
|
||||||
|
|
||||||
|
@Schema(description = "服务状态")
|
||||||
|
@ExcelProperty(value = "服务状态", converter = DictConvert.class)
|
||||||
|
@DictFormat("iot_proxy_server_status") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
|
||||||
|
private String frpsState;
|
||||||
|
|
||||||
|
@Schema(description = "备注", example = "随便")
|
||||||
|
@ExcelProperty("备注")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
@Schema(description = "是否启用", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty(value = "是否启用", converter = DictConvert.class)
|
||||||
|
@DictFormat("infra_boolean_string") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
|
||||||
|
private Boolean isEnable;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("创建时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,43 @@
|
|||||||
|
package cn.iocoder.yudao.module.iot.controller.admin.frps.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 代理服务器新增/修改 Request VO")
|
||||||
|
@Data
|
||||||
|
public class FrpsServerSaveReqVO {
|
||||||
|
|
||||||
|
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "18589")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "名称", example = "芋艿")
|
||||||
|
private String frpsName;
|
||||||
|
|
||||||
|
@Schema(description = "mac地址")
|
||||||
|
private String hostMac;
|
||||||
|
|
||||||
|
@Schema(description = "操作系统")
|
||||||
|
private String hostOs;
|
||||||
|
|
||||||
|
@Schema(description = "服务IP")
|
||||||
|
private String hostIp;
|
||||||
|
|
||||||
|
@Schema(description = "服务端口")
|
||||||
|
private Integer hostPort;
|
||||||
|
|
||||||
|
@Schema(description = "程序绝对路径")
|
||||||
|
private String frpsPath;
|
||||||
|
|
||||||
|
@Schema(description = "服务状态")
|
||||||
|
private String frpsState;
|
||||||
|
|
||||||
|
@Schema(description = "备注", example = "随便")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
@Schema(description = "是否启用", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotNull(message = "是否启用不能为空")
|
||||||
|
private Boolean isEnable;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,81 @@
|
|||||||
|
package cn.iocoder.yudao.module.iot.dal.dataobject.frpc;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 代理服务 DO
|
||||||
|
*
|
||||||
|
* @author 内蒙必硕
|
||||||
|
*/
|
||||||
|
@TableName("iot_frpc_proxy_server")
|
||||||
|
@KeySequence("iot_frpc_proxy_server_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class FrpcProxyServerDO extends BaseDO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 代理名称
|
||||||
|
*/
|
||||||
|
private String frpcName;
|
||||||
|
/**
|
||||||
|
* 内网IP
|
||||||
|
*/
|
||||||
|
private String localIp;
|
||||||
|
/**
|
||||||
|
* 内网端口
|
||||||
|
*/
|
||||||
|
private Integer localPort;
|
||||||
|
/**
|
||||||
|
* 访问后缀
|
||||||
|
*/
|
||||||
|
private String suffixPath;
|
||||||
|
/**
|
||||||
|
* 内网状态
|
||||||
|
*
|
||||||
|
* 枚举 {@link TODO iot_proxy_server_status 对应的类}
|
||||||
|
*/
|
||||||
|
private String localStatus;
|
||||||
|
/**
|
||||||
|
* 代理服务器
|
||||||
|
*/
|
||||||
|
private Long frpsId;
|
||||||
|
/**
|
||||||
|
* 代理端口
|
||||||
|
*/
|
||||||
|
private Integer proxyPort;
|
||||||
|
/**
|
||||||
|
* 代理地址
|
||||||
|
*/
|
||||||
|
private String proxyAddress;
|
||||||
|
/**
|
||||||
|
* 代理状态
|
||||||
|
*
|
||||||
|
* 枚举 {@link TODO iot_proxy_server_status 对应的类}
|
||||||
|
*/
|
||||||
|
private String proxyStatus;
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
private String remark;
|
||||||
|
/**
|
||||||
|
* 是否启用
|
||||||
|
*
|
||||||
|
* 枚举 {@link TODO infra_boolean_string 对应的类}
|
||||||
|
*/
|
||||||
|
private Boolean isEnable;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,71 @@
|
|||||||
|
package cn.iocoder.yudao.module.iot.dal.dataobject.frps;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 代理服务器 DO
|
||||||
|
*
|
||||||
|
* @author 内蒙必硕
|
||||||
|
*/
|
||||||
|
@TableName("iot_frps_server")
|
||||||
|
@KeySequence("iot_frps_server_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class FrpsServerDO extends BaseDO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 名称
|
||||||
|
*/
|
||||||
|
private String frpsName;
|
||||||
|
/**
|
||||||
|
* mac地址
|
||||||
|
*/
|
||||||
|
private String hostMac;
|
||||||
|
/**
|
||||||
|
* 操作系统
|
||||||
|
*/
|
||||||
|
private String hostOs;
|
||||||
|
/**
|
||||||
|
* 服务IP
|
||||||
|
*/
|
||||||
|
private String hostIp;
|
||||||
|
/**
|
||||||
|
* 服务端口
|
||||||
|
*/
|
||||||
|
private Integer hostPort;
|
||||||
|
/**
|
||||||
|
* 程序绝对路径
|
||||||
|
*/
|
||||||
|
private String frpsPath;
|
||||||
|
/**
|
||||||
|
* 服务状态
|
||||||
|
*
|
||||||
|
* 枚举 {@link TODO iot_proxy_server_status 对应的类}
|
||||||
|
*/
|
||||||
|
private String frpsState;
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
private String remark;
|
||||||
|
/**
|
||||||
|
* 是否启用
|
||||||
|
*
|
||||||
|
* 枚举 {@link TODO infra_boolean_string 对应的类}
|
||||||
|
*/
|
||||||
|
private Boolean isEnable;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,37 @@
|
|||||||
|
package cn.iocoder.yudao.module.iot.dal.mysql.frpc;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import cn.iocoder.yudao.module.iot.dal.dataobject.frpc.FrpcProxyServerDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import cn.iocoder.yudao.module.iot.controller.admin.frpc.vo.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 代理服务 Mapper
|
||||||
|
*
|
||||||
|
* @author 内蒙必硕
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface FrpcProxyServerMapper extends BaseMapperX<FrpcProxyServerDO> {
|
||||||
|
|
||||||
|
default PageResult<FrpcProxyServerDO> selectPage(FrpcProxyServerPageReqVO reqVO) {
|
||||||
|
return selectPage(reqVO, new LambdaQueryWrapperX<FrpcProxyServerDO>()
|
||||||
|
.likeIfPresent(FrpcProxyServerDO::getFrpcName, reqVO.getFrpcName())
|
||||||
|
.eqIfPresent(FrpcProxyServerDO::getLocalIp, reqVO.getLocalIp())
|
||||||
|
.eqIfPresent(FrpcProxyServerDO::getLocalPort, reqVO.getLocalPort())
|
||||||
|
.eqIfPresent(FrpcProxyServerDO::getSuffixPath, reqVO.getSuffixPath())
|
||||||
|
.eqIfPresent(FrpcProxyServerDO::getLocalStatus, reqVO.getLocalStatus())
|
||||||
|
.eqIfPresent(FrpcProxyServerDO::getFrpsId, reqVO.getFrpsId())
|
||||||
|
.eqIfPresent(FrpcProxyServerDO::getProxyPort, reqVO.getProxyPort())
|
||||||
|
.eqIfPresent(FrpcProxyServerDO::getProxyAddress, reqVO.getProxyAddress())
|
||||||
|
.eqIfPresent(FrpcProxyServerDO::getProxyStatus, reqVO.getProxyStatus())
|
||||||
|
.eqIfPresent(FrpcProxyServerDO::getRemark, reqVO.getRemark())
|
||||||
|
.eqIfPresent(FrpcProxyServerDO::getIsEnable, reqVO.getIsEnable())
|
||||||
|
.betweenIfPresent(FrpcProxyServerDO::getCreateTime, reqVO.getCreateTime())
|
||||||
|
.orderByDesc(FrpcProxyServerDO::getId));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,35 @@
|
|||||||
|
package cn.iocoder.yudao.module.iot.dal.mysql.frps;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import cn.iocoder.yudao.module.iot.dal.dataobject.frps.FrpsServerDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import cn.iocoder.yudao.module.iot.controller.admin.frps.vo.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 代理服务器 Mapper
|
||||||
|
*
|
||||||
|
* @author 内蒙必硕
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface FrpsServerMapper extends BaseMapperX<FrpsServerDO> {
|
||||||
|
|
||||||
|
default PageResult<FrpsServerDO> selectPage(FrpsServerPageReqVO reqVO) {
|
||||||
|
return selectPage(reqVO, new LambdaQueryWrapperX<FrpsServerDO>()
|
||||||
|
.likeIfPresent(FrpsServerDO::getFrpsName, reqVO.getFrpsName())
|
||||||
|
.eqIfPresent(FrpsServerDO::getHostMac, reqVO.getHostMac())
|
||||||
|
.eqIfPresent(FrpsServerDO::getHostOs, reqVO.getHostOs())
|
||||||
|
.eqIfPresent(FrpsServerDO::getHostIp, reqVO.getHostIp())
|
||||||
|
.eqIfPresent(FrpsServerDO::getHostPort, reqVO.getHostPort())
|
||||||
|
.eqIfPresent(FrpsServerDO::getFrpsPath, reqVO.getFrpsPath())
|
||||||
|
.eqIfPresent(FrpsServerDO::getFrpsState, reqVO.getFrpsState())
|
||||||
|
.eqIfPresent(FrpsServerDO::getRemark, reqVO.getRemark())
|
||||||
|
.eqIfPresent(FrpsServerDO::getIsEnable, reqVO.getIsEnable())
|
||||||
|
.betweenIfPresent(FrpsServerDO::getCreateTime, reqVO.getCreateTime())
|
||||||
|
.orderByDesc(FrpsServerDO::getId));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,56 @@
|
|||||||
|
package cn.iocoder.yudao.module.iot.service.frpc;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import cn.iocoder.yudao.module.iot.controller.admin.frpc.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.iot.dal.dataobject.frpc.FrpcProxyServerDO;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 代理服务 Service 接口
|
||||||
|
*
|
||||||
|
* @author 内蒙必硕
|
||||||
|
*/
|
||||||
|
public interface FrpcProxyServerService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建代理服务
|
||||||
|
*
|
||||||
|
* @param createReqVO 创建信息
|
||||||
|
* @return 编号
|
||||||
|
*/
|
||||||
|
Long createFrpcProxyServer(@Valid FrpcProxyServerSaveReqVO createReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新代理服务
|
||||||
|
*
|
||||||
|
* @param updateReqVO 更新信息
|
||||||
|
*/
|
||||||
|
void updateFrpcProxyServer(@Valid FrpcProxyServerSaveReqVO updateReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除代理服务
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
*/
|
||||||
|
void deleteFrpcProxyServer(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得代理服务
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
* @return 代理服务
|
||||||
|
*/
|
||||||
|
FrpcProxyServerDO getFrpcProxyServer(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得代理服务分页
|
||||||
|
*
|
||||||
|
* @param pageReqVO 分页查询
|
||||||
|
* @return 代理服务分页
|
||||||
|
*/
|
||||||
|
PageResult<FrpcProxyServerDO> getFrpcProxyServerPage(FrpcProxyServerPageReqVO pageReqVO);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,75 @@
|
|||||||
|
package cn.iocoder.yudao.module.iot.service.frpc;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import cn.iocoder.yudao.module.iot.controller.admin.frpc.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.iot.dal.dataobject.frpc.FrpcProxyServerDO;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.iot.dal.mysql.frpc.FrpcProxyServerMapper;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 代理服务 Service 实现类
|
||||||
|
*
|
||||||
|
* @author 内蒙必硕
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Validated
|
||||||
|
public class FrpcProxyServerServiceImpl implements FrpcProxyServerService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private FrpcProxyServerMapper frpcProxyServerMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long createFrpcProxyServer(FrpcProxyServerSaveReqVO createReqVO) {
|
||||||
|
// 插入
|
||||||
|
FrpcProxyServerDO frpcProxyServer = BeanUtils.toBean(createReqVO, FrpcProxyServerDO.class);
|
||||||
|
frpcProxyServerMapper.insert(frpcProxyServer);
|
||||||
|
// 返回
|
||||||
|
return frpcProxyServer.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateFrpcProxyServer(FrpcProxyServerSaveReqVO updateReqVO) {
|
||||||
|
// 校验存在
|
||||||
|
validateFrpcProxyServerExists(updateReqVO.getId());
|
||||||
|
// 更新
|
||||||
|
FrpcProxyServerDO updateObj = BeanUtils.toBean(updateReqVO, FrpcProxyServerDO.class);
|
||||||
|
frpcProxyServerMapper.updateById(updateObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteFrpcProxyServer(Long id) {
|
||||||
|
// 校验存在
|
||||||
|
validateFrpcProxyServerExists(id);
|
||||||
|
// 删除
|
||||||
|
frpcProxyServerMapper.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateFrpcProxyServerExists(Long id) {
|
||||||
|
if (frpcProxyServerMapper.selectById(id) == null) {
|
||||||
|
throw exception(FRPC_PROXY_SERVER_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FrpcProxyServerDO getFrpcProxyServer(Long id) {
|
||||||
|
return frpcProxyServerMapper.selectById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<FrpcProxyServerDO> getFrpcProxyServerPage(FrpcProxyServerPageReqVO pageReqVO) {
|
||||||
|
return frpcProxyServerMapper.selectPage(pageReqVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,56 @@
|
|||||||
|
package cn.iocoder.yudao.module.iot.service.frps;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import cn.iocoder.yudao.module.iot.controller.admin.frps.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.iot.dal.dataobject.frps.FrpsServerDO;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 代理服务器 Service 接口
|
||||||
|
*
|
||||||
|
* @author 内蒙必硕
|
||||||
|
*/
|
||||||
|
public interface FrpsServerService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建代理服务器
|
||||||
|
*
|
||||||
|
* @param createReqVO 创建信息
|
||||||
|
* @return 编号
|
||||||
|
*/
|
||||||
|
Long createFrpsServer(@Valid FrpsServerSaveReqVO createReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新代理服务器
|
||||||
|
*
|
||||||
|
* @param updateReqVO 更新信息
|
||||||
|
*/
|
||||||
|
void updateFrpsServer(@Valid FrpsServerSaveReqVO updateReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除代理服务器
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
*/
|
||||||
|
void deleteFrpsServer(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得代理服务器
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
* @return 代理服务器
|
||||||
|
*/
|
||||||
|
FrpsServerDO getFrpsServer(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得代理服务器分页
|
||||||
|
*
|
||||||
|
* @param pageReqVO 分页查询
|
||||||
|
* @return 代理服务器分页
|
||||||
|
*/
|
||||||
|
PageResult<FrpsServerDO> getFrpsServerPage(FrpsServerPageReqVO pageReqVO);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,75 @@
|
|||||||
|
package cn.iocoder.yudao.module.iot.service.frps;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import cn.iocoder.yudao.module.iot.controller.admin.frps.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.iot.dal.dataobject.frps.FrpsServerDO;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.iot.dal.mysql.frps.FrpsServerMapper;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 代理服务器 Service 实现类
|
||||||
|
*
|
||||||
|
* @author 内蒙必硕
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Validated
|
||||||
|
public class FrpsServerServiceImpl implements FrpsServerService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private FrpsServerMapper frpsServerMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long createFrpsServer(FrpsServerSaveReqVO createReqVO) {
|
||||||
|
// 插入
|
||||||
|
FrpsServerDO frpsServer = BeanUtils.toBean(createReqVO, FrpsServerDO.class);
|
||||||
|
frpsServerMapper.insert(frpsServer);
|
||||||
|
// 返回
|
||||||
|
return frpsServer.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateFrpsServer(FrpsServerSaveReqVO updateReqVO) {
|
||||||
|
// 校验存在
|
||||||
|
validateFrpsServerExists(updateReqVO.getId());
|
||||||
|
// 更新
|
||||||
|
FrpsServerDO updateObj = BeanUtils.toBean(updateReqVO, FrpsServerDO.class);
|
||||||
|
frpsServerMapper.updateById(updateObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteFrpsServer(Long id) {
|
||||||
|
// 校验存在
|
||||||
|
validateFrpsServerExists(id);
|
||||||
|
// 删除
|
||||||
|
frpsServerMapper.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateFrpsServerExists(Long id) {
|
||||||
|
if (frpsServerMapper.selectById(id) == null) {
|
||||||
|
throw exception(FRPS_SERVER_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FrpsServerDO getFrpsServer(Long id) {
|
||||||
|
return frpsServerMapper.selectById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<FrpsServerDO> getFrpsServerPage(FrpsServerPageReqVO pageReqVO) {
|
||||||
|
return frpsServerMapper.selectPage(pageReqVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,175 @@
|
|||||||
|
package cn.iocoder.yudao.module.iot.service.frpc;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Disabled;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.iot.controller.admin.frpc.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.iot.dal.dataobject.frpc.FrpcProxyServerDO;
|
||||||
|
import cn.iocoder.yudao.module.iot.dal.mysql.frpc.FrpcProxyServerMapper;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Import;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import static cn.hutool.core.util.RandomUtil.*;
|
||||||
|
import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.*;
|
||||||
|
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*;
|
||||||
|
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*;
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link FrpcProxyServerServiceImpl} 的单元测试类
|
||||||
|
*
|
||||||
|
* @author 内蒙必硕
|
||||||
|
*/
|
||||||
|
@Import(FrpcProxyServerServiceImpl.class)
|
||||||
|
public class FrpcProxyServerServiceImplTest extends BaseDbUnitTest {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private FrpcProxyServerServiceImpl frpcProxyServerService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private FrpcProxyServerMapper frpcProxyServerMapper;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCreateFrpcProxyServer_success() {
|
||||||
|
// 准备参数
|
||||||
|
FrpcProxyServerSaveReqVO createReqVO = randomPojo(FrpcProxyServerSaveReqVO.class).setId(null);
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
Long frpcProxyServerId = frpcProxyServerService.createFrpcProxyServer(createReqVO);
|
||||||
|
// 断言
|
||||||
|
assertNotNull(frpcProxyServerId);
|
||||||
|
// 校验记录的属性是否正确
|
||||||
|
FrpcProxyServerDO frpcProxyServer = frpcProxyServerMapper.selectById(frpcProxyServerId);
|
||||||
|
assertPojoEquals(createReqVO, frpcProxyServer, "id");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateFrpcProxyServer_success() {
|
||||||
|
// mock 数据
|
||||||
|
FrpcProxyServerDO dbFrpcProxyServer = randomPojo(FrpcProxyServerDO.class);
|
||||||
|
frpcProxyServerMapper.insert(dbFrpcProxyServer);// @Sql: 先插入出一条存在的数据
|
||||||
|
// 准备参数
|
||||||
|
FrpcProxyServerSaveReqVO updateReqVO = randomPojo(FrpcProxyServerSaveReqVO.class, o -> {
|
||||||
|
o.setId(dbFrpcProxyServer.getId()); // 设置更新的 ID
|
||||||
|
});
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
frpcProxyServerService.updateFrpcProxyServer(updateReqVO);
|
||||||
|
// 校验是否更新正确
|
||||||
|
FrpcProxyServerDO frpcProxyServer = frpcProxyServerMapper.selectById(updateReqVO.getId()); // 获取最新的
|
||||||
|
assertPojoEquals(updateReqVO, frpcProxyServer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateFrpcProxyServer_notExists() {
|
||||||
|
// 准备参数
|
||||||
|
FrpcProxyServerSaveReqVO updateReqVO = randomPojo(FrpcProxyServerSaveReqVO.class);
|
||||||
|
|
||||||
|
// 调用, 并断言异常
|
||||||
|
assertServiceException(() -> frpcProxyServerService.updateFrpcProxyServer(updateReqVO), FRPC_PROXY_SERVER_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDeleteFrpcProxyServer_success() {
|
||||||
|
// mock 数据
|
||||||
|
FrpcProxyServerDO dbFrpcProxyServer = randomPojo(FrpcProxyServerDO.class);
|
||||||
|
frpcProxyServerMapper.insert(dbFrpcProxyServer);// @Sql: 先插入出一条存在的数据
|
||||||
|
// 准备参数
|
||||||
|
Long id = dbFrpcProxyServer.getId();
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
frpcProxyServerService.deleteFrpcProxyServer(id);
|
||||||
|
// 校验数据不存在了
|
||||||
|
assertNull(frpcProxyServerMapper.selectById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDeleteFrpcProxyServer_notExists() {
|
||||||
|
// 准备参数
|
||||||
|
Long id = randomLongId();
|
||||||
|
|
||||||
|
// 调用, 并断言异常
|
||||||
|
assertServiceException(() -> frpcProxyServerService.deleteFrpcProxyServer(id), FRPC_PROXY_SERVER_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||||
|
public void testGetFrpcProxyServerPage() {
|
||||||
|
// mock 数据
|
||||||
|
FrpcProxyServerDO dbFrpcProxyServer = randomPojo(FrpcProxyServerDO.class, o -> { // 等会查询到
|
||||||
|
o.setFrpcName(null);
|
||||||
|
o.setLocalIp(null);
|
||||||
|
o.setLocalPort(null);
|
||||||
|
o.setSuffixPath(null);
|
||||||
|
o.setLocalStatus(null);
|
||||||
|
o.setFrpsId(null);
|
||||||
|
o.setProxyPort(null);
|
||||||
|
o.setProxyAddress(null);
|
||||||
|
o.setProxyStatus(null);
|
||||||
|
o.setRemark(null);
|
||||||
|
o.setIsEnable(null);
|
||||||
|
o.setCreateTime(null);
|
||||||
|
});
|
||||||
|
frpcProxyServerMapper.insert(dbFrpcProxyServer);
|
||||||
|
// 测试 frpcName 不匹配
|
||||||
|
frpcProxyServerMapper.insert(cloneIgnoreId(dbFrpcProxyServer, o -> o.setFrpcName(null)));
|
||||||
|
// 测试 localIp 不匹配
|
||||||
|
frpcProxyServerMapper.insert(cloneIgnoreId(dbFrpcProxyServer, o -> o.setLocalIp(null)));
|
||||||
|
// 测试 localPort 不匹配
|
||||||
|
frpcProxyServerMapper.insert(cloneIgnoreId(dbFrpcProxyServer, o -> o.setLocalPort(null)));
|
||||||
|
// 测试 suffixPath 不匹配
|
||||||
|
frpcProxyServerMapper.insert(cloneIgnoreId(dbFrpcProxyServer, o -> o.setSuffixPath(null)));
|
||||||
|
// 测试 localStatus 不匹配
|
||||||
|
frpcProxyServerMapper.insert(cloneIgnoreId(dbFrpcProxyServer, o -> o.setLocalStatus(null)));
|
||||||
|
// 测试 frpsId 不匹配
|
||||||
|
frpcProxyServerMapper.insert(cloneIgnoreId(dbFrpcProxyServer, o -> o.setFrpsId(null)));
|
||||||
|
// 测试 proxyPort 不匹配
|
||||||
|
frpcProxyServerMapper.insert(cloneIgnoreId(dbFrpcProxyServer, o -> o.setProxyPort(null)));
|
||||||
|
// 测试 proxyAddress 不匹配
|
||||||
|
frpcProxyServerMapper.insert(cloneIgnoreId(dbFrpcProxyServer, o -> o.setProxyAddress(null)));
|
||||||
|
// 测试 proxyStatus 不匹配
|
||||||
|
frpcProxyServerMapper.insert(cloneIgnoreId(dbFrpcProxyServer, o -> o.setProxyStatus(null)));
|
||||||
|
// 测试 remark 不匹配
|
||||||
|
frpcProxyServerMapper.insert(cloneIgnoreId(dbFrpcProxyServer, o -> o.setRemark(null)));
|
||||||
|
// 测试 isEnable 不匹配
|
||||||
|
frpcProxyServerMapper.insert(cloneIgnoreId(dbFrpcProxyServer, o -> o.setIsEnable(null)));
|
||||||
|
// 测试 createTime 不匹配
|
||||||
|
frpcProxyServerMapper.insert(cloneIgnoreId(dbFrpcProxyServer, o -> o.setCreateTime(null)));
|
||||||
|
// 准备参数
|
||||||
|
FrpcProxyServerPageReqVO reqVO = new FrpcProxyServerPageReqVO();
|
||||||
|
reqVO.setFrpcName(null);
|
||||||
|
reqVO.setLocalIp(null);
|
||||||
|
reqVO.setLocalPort(null);
|
||||||
|
reqVO.setSuffixPath(null);
|
||||||
|
reqVO.setLocalStatus(null);
|
||||||
|
reqVO.setFrpsId(null);
|
||||||
|
reqVO.setProxyPort(null);
|
||||||
|
reqVO.setProxyAddress(null);
|
||||||
|
reqVO.setProxyStatus(null);
|
||||||
|
reqVO.setRemark(null);
|
||||||
|
reqVO.setIsEnable(null);
|
||||||
|
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
PageResult<FrpcProxyServerDO> pageResult = frpcProxyServerService.getFrpcProxyServerPage(reqVO);
|
||||||
|
// 断言
|
||||||
|
assertEquals(1, pageResult.getTotal());
|
||||||
|
assertEquals(1, pageResult.getList().size());
|
||||||
|
assertPojoEquals(dbFrpcProxyServer, pageResult.getList().get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,166 @@
|
|||||||
|
package cn.iocoder.yudao.module.iot.service.frps;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Disabled;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.iot.controller.admin.frps.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.iot.dal.dataobject.frps.FrpsServerDO;
|
||||||
|
import cn.iocoder.yudao.module.iot.dal.mysql.frps.FrpsServerMapper;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Import;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import static cn.hutool.core.util.RandomUtil.*;
|
||||||
|
import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.*;
|
||||||
|
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*;
|
||||||
|
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*;
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link FrpsServerServiceImpl} 的单元测试类
|
||||||
|
*
|
||||||
|
* @author 内蒙必硕
|
||||||
|
*/
|
||||||
|
@Import(FrpsServerServiceImpl.class)
|
||||||
|
public class FrpsServerServiceImplTest extends BaseDbUnitTest {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private FrpsServerServiceImpl frpsServerService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private FrpsServerMapper frpsServerMapper;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCreateFrpsServer_success() {
|
||||||
|
// 准备参数
|
||||||
|
FrpsServerSaveReqVO createReqVO = randomPojo(FrpsServerSaveReqVO.class).setId(null);
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
Long frpsServerId = frpsServerService.createFrpsServer(createReqVO);
|
||||||
|
// 断言
|
||||||
|
assertNotNull(frpsServerId);
|
||||||
|
// 校验记录的属性是否正确
|
||||||
|
FrpsServerDO frpsServer = frpsServerMapper.selectById(frpsServerId);
|
||||||
|
assertPojoEquals(createReqVO, frpsServer, "id");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateFrpsServer_success() {
|
||||||
|
// mock 数据
|
||||||
|
FrpsServerDO dbFrpsServer = randomPojo(FrpsServerDO.class);
|
||||||
|
frpsServerMapper.insert(dbFrpsServer);// @Sql: 先插入出一条存在的数据
|
||||||
|
// 准备参数
|
||||||
|
FrpsServerSaveReqVO updateReqVO = randomPojo(FrpsServerSaveReqVO.class, o -> {
|
||||||
|
o.setId(dbFrpsServer.getId()); // 设置更新的 ID
|
||||||
|
});
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
frpsServerService.updateFrpsServer(updateReqVO);
|
||||||
|
// 校验是否更新正确
|
||||||
|
FrpsServerDO frpsServer = frpsServerMapper.selectById(updateReqVO.getId()); // 获取最新的
|
||||||
|
assertPojoEquals(updateReqVO, frpsServer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateFrpsServer_notExists() {
|
||||||
|
// 准备参数
|
||||||
|
FrpsServerSaveReqVO updateReqVO = randomPojo(FrpsServerSaveReqVO.class);
|
||||||
|
|
||||||
|
// 调用, 并断言异常
|
||||||
|
assertServiceException(() -> frpsServerService.updateFrpsServer(updateReqVO), FRPS_SERVER_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDeleteFrpsServer_success() {
|
||||||
|
// mock 数据
|
||||||
|
FrpsServerDO dbFrpsServer = randomPojo(FrpsServerDO.class);
|
||||||
|
frpsServerMapper.insert(dbFrpsServer);// @Sql: 先插入出一条存在的数据
|
||||||
|
// 准备参数
|
||||||
|
Long id = dbFrpsServer.getId();
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
frpsServerService.deleteFrpsServer(id);
|
||||||
|
// 校验数据不存在了
|
||||||
|
assertNull(frpsServerMapper.selectById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDeleteFrpsServer_notExists() {
|
||||||
|
// 准备参数
|
||||||
|
Long id = randomLongId();
|
||||||
|
|
||||||
|
// 调用, 并断言异常
|
||||||
|
assertServiceException(() -> frpsServerService.deleteFrpsServer(id), FRPS_SERVER_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||||
|
public void testGetFrpsServerPage() {
|
||||||
|
// mock 数据
|
||||||
|
FrpsServerDO dbFrpsServer = randomPojo(FrpsServerDO.class, o -> { // 等会查询到
|
||||||
|
o.setFrpsName(null);
|
||||||
|
o.setHostMac(null);
|
||||||
|
o.setHostOs(null);
|
||||||
|
o.setHostIp(null);
|
||||||
|
o.setHostPort(null);
|
||||||
|
o.setFrpsPath(null);
|
||||||
|
o.setFrpsState(null);
|
||||||
|
o.setRemark(null);
|
||||||
|
o.setIsEnable(null);
|
||||||
|
o.setCreateTime(null);
|
||||||
|
});
|
||||||
|
frpsServerMapper.insert(dbFrpsServer);
|
||||||
|
// 测试 frpsName 不匹配
|
||||||
|
frpsServerMapper.insert(cloneIgnoreId(dbFrpsServer, o -> o.setFrpsName(null)));
|
||||||
|
// 测试 hostMac 不匹配
|
||||||
|
frpsServerMapper.insert(cloneIgnoreId(dbFrpsServer, o -> o.setHostMac(null)));
|
||||||
|
// 测试 hostOs 不匹配
|
||||||
|
frpsServerMapper.insert(cloneIgnoreId(dbFrpsServer, o -> o.setHostOs(null)));
|
||||||
|
// 测试 hostIp 不匹配
|
||||||
|
frpsServerMapper.insert(cloneIgnoreId(dbFrpsServer, o -> o.setHostIp(null)));
|
||||||
|
// 测试 hostPort 不匹配
|
||||||
|
frpsServerMapper.insert(cloneIgnoreId(dbFrpsServer, o -> o.setHostPort(null)));
|
||||||
|
// 测试 frpsPath 不匹配
|
||||||
|
frpsServerMapper.insert(cloneIgnoreId(dbFrpsServer, o -> o.setFrpsPath(null)));
|
||||||
|
// 测试 frpsState 不匹配
|
||||||
|
frpsServerMapper.insert(cloneIgnoreId(dbFrpsServer, o -> o.setFrpsState(null)));
|
||||||
|
// 测试 remark 不匹配
|
||||||
|
frpsServerMapper.insert(cloneIgnoreId(dbFrpsServer, o -> o.setRemark(null)));
|
||||||
|
// 测试 isEnable 不匹配
|
||||||
|
frpsServerMapper.insert(cloneIgnoreId(dbFrpsServer, o -> o.setIsEnable(null)));
|
||||||
|
// 测试 createTime 不匹配
|
||||||
|
frpsServerMapper.insert(cloneIgnoreId(dbFrpsServer, o -> o.setCreateTime(null)));
|
||||||
|
// 准备参数
|
||||||
|
FrpsServerPageReqVO reqVO = new FrpsServerPageReqVO();
|
||||||
|
reqVO.setFrpsName(null);
|
||||||
|
reqVO.setHostMac(null);
|
||||||
|
reqVO.setHostOs(null);
|
||||||
|
reqVO.setHostIp(null);
|
||||||
|
reqVO.setHostPort(null);
|
||||||
|
reqVO.setFrpsPath(null);
|
||||||
|
reqVO.setFrpsState(null);
|
||||||
|
reqVO.setRemark(null);
|
||||||
|
reqVO.setIsEnable(null);
|
||||||
|
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
PageResult<FrpsServerDO> pageResult = frpsServerService.getFrpsServerPage(reqVO);
|
||||||
|
// 断言
|
||||||
|
assertEquals(1, pageResult.getTotal());
|
||||||
|
assertEquals(1, pageResult.getList().size());
|
||||||
|
assertPojoEquals(dbFrpsServer, pageResult.getList().get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue