[ Server ] [ Server ] - 增加服务器角色部分的内容

This commit is contained in:
zeaslity
2023-10-08 14:30:17 +08:00
parent 9197031e81
commit 2594514a87
29 changed files with 416 additions and 209 deletions

View File

@@ -67,9 +67,9 @@ func Execute(em *ExecutionMessage) ([]string, error) {
resultLog = append(resultLog, "↓↓↓ 命令 Error 如下 ↓↓↓", err.Error())
}
// debug
commandResult := fmt.Sprintf("Excution Comand are=> %v, Executor Result: %v", realCommand, resultLog)
log.Info(commandResult)
log.Debug(commandResult)
return resultLog, err
}
@@ -119,12 +119,10 @@ func MultiLineCommandExecutor(multiLineCommandExecutor [][]string) ([]string, er
for _, singleLineCommand := range multiLineCommandExecutor {
singleLogs, err := AllOutputCommandExecutor(singleLineCommand)
res = append(res, singleLogs...)
if err != nil {
log.Error(fmt.Sprintf("Execution error ! command is %v, error is %v", singleLineCommand, err))
return res, err
}
}
return res, nil

View File

@@ -10,6 +10,7 @@ import (
var (
user32DLL = syscall.NewLazyDLL("user32.dll")
messageBox = user32DLL.NewProc("MessageBoxW")
)
@@ -24,6 +25,8 @@ func FindPublicIpAddress() {
ip := strings.TrimSpace(string(output))
fmt.Println("公网IP地址:", ip)
fmt.Println("")
}
func CallAgent() {
@@ -46,4 +49,5 @@ func CallAgent() {
}
fmt.Println("MessageBox returned:", ret)
}

View File

@@ -117,8 +117,10 @@ func agentOMHandler(octopusMessage *OctopusMessage) {
func executorOMHandler(octopusMessage *OctopusMessage) {
// 转换类型
executionMsgString := octopusMessage.Content.(string)
// 解析 ExecutionMessage
var executionMessage *executor.ExecutionMessage
err := json.Unmarshal([]byte(executionMsgString), &executionMessage)
if err != nil {
@@ -126,7 +128,7 @@ func executorOMHandler(octopusMessage *OctopusMessage) {
return
}
// 交给后端的实际处理器处理, 再次策略
// 执行命令
resultLog, err := executor.Execute(executionMessage)
if err == nil {
octopusMessage.ResultCode = "200"
@@ -134,15 +136,15 @@ func executorOMHandler(octopusMessage *OctopusMessage) {
octopusMessage.ResultCode = "300"
}
// 消息返回逻辑
// 返回结果
if executionMessage.NeedResultReplay {
// send back the result log
octopusMessage.Result = resultLog
}
// 返回时间
octopusMessage.ACTime = utils.ParseDateTimeTime()
// Send
// 返回结果
octopusMessage.SendToOctopusServer()
}

View File

@@ -54,6 +54,13 @@
<version>1.9.4</version>
</dependency>
<!--最快的类型转换工具-->
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>1.5.5.Final</version>
</dependency>
<!-- add in 2023-02-08 needed for some operation -->
<dependency>
<groupId>org.springframework.cloud</groupId>

View File

@@ -1,4 +1,4 @@
package io.wdd.func.script.service;
package io.wdd.func.auto.service;
import java.util.List;
@@ -11,5 +11,4 @@ public interface FuncService {
List<String> callAppFuncService(String agentTopicName, String appFunctionName, List<String> funcArgs);
}

View File

@@ -1,4 +1,4 @@
package io.wdd.func.script.service;
package io.wdd.func.auto.service;
import io.wdd.rpc.execute.ExecutionMessageType;
import io.wdd.rpc.execute.service.ExecutionService;
@@ -40,9 +40,10 @@ public class FuncServiceImpl implements FuncService {
}
// 归一化调用
private List<String> syncCallFunction(String agentTopicName, ExecutionMessageType emType, String funcName, List<String> funcArgs) {
// 重新构造内容
// 重新构造内容增加Function Name
funcArgs.add(
0,
funcName
@@ -60,7 +61,6 @@ public class FuncServiceImpl implements FuncService {
false
);
return resultLog;
}

View File

@@ -34,13 +34,14 @@ public class ExecutionMessage {
/**
* 用于区分 ExecutionMessage的类型
* BASE APP
* 执行预定义的脚本内容 BASE
* 执行k8s应用相关的内容 APP
*/
@Nullable
private String executionType;
/**
* 执行功能脚本时需要的参数
* 执行 上述预定义脚本 时需要的参数
*/
@Nullable
private List<String> funcContent;
@@ -50,6 +51,7 @@ public class ExecutionMessage {
*/
@Nullable
private List<String> singleLineCommand;
/**
* add in 2023-1-17
* 页面定时脚本任务 需要传递完整的命令列表

View File

@@ -3,10 +3,10 @@ package io.wdd.rpc.execute;
public enum ExecutionMessageType {
// 基础类型,执行基础脚本类
// 执行预定义的脚本内容 BASE
BASE,
// 应用类,执行特定功能
// 执行k8s应用相关的内容 APP
APP,

View File

@@ -7,7 +7,10 @@ public interface ExecutionService {
/**
* 发送 指令 给Agent, 正确错误信息全都会被接收
* ⭐⭐⭐⭐⭐
* 发送命令给Agent, 同步等待处理返回的消息
* 超时等待时间为 COMMAND_MAX_WAIT_TIMEOUT
* 如果为durationTask那么则没有返回结果
*/
ArrayList<String> SendCommandToAgent(
String agentTopicName,

View File

@@ -63,6 +63,7 @@ public class ExecutionServiceImpl implements ExecutionService {
// send the message
oMessageToAgentSender.send(octopusMessage);
// debug
log.debug(
"发送的 matchKey为 {}, 内容为 {}",
GenerateOMessageMatchKey(
@@ -75,7 +76,7 @@ public class ExecutionServiceImpl implements ExecutionService {
// 需要返回结果
if (!durationTask) {
// 等待结果
// countDownLatch的个数约定为1
// countDownLatch的个数约定为1, agent会合并多行命令的结果一并返回
OMessageReplayContent replayContent = WaitFromAgent(
octopusMessage,
1
@@ -85,8 +86,15 @@ public class ExecutionServiceImpl implements ExecutionService {
boolean waitOK = false;
try {
// 2023年10月8日 根据执行的命令数量设定超时等待时间
int commandMaxWaitTimeout = COMMAND_MAX_WAIT_TIMEOUT;
if (commandListComplete.size() > 0) {
commandMaxWaitTimeout = COMMAND_MAX_WAIT_TIMEOUT * commandListComplete.size();
}
waitOK = replayLatch.await(
COMMAND_MAX_WAIT_TIMEOUT,
commandMaxWaitTimeout,
TimeUnit.SECONDS
);

View File

@@ -65,7 +65,7 @@ public class OMessageHandler {
);
//debug
log.info(
log.debug(
"wait from agent map is => {}",
FROM_AGENT_MATCH_TO_AGENT_MAP
);
@@ -141,7 +141,6 @@ public class OMessageHandler {
originOMessage.setResultCode(replayOMessage.getResultCode());
originOMessage.setResult(replayOMessage.getResult());
// 通知等待线程
oMessageReplayContent
.getCountDownLatch()

View File

@@ -49,8 +49,6 @@ public class OMessageToServerListener {
@Resource
RedisTemplate redisTemplate;
@Resource
OMessageHandler oMessageHandler;
@RabbitHandler
@RabbitListener(queues = "${octopus.message.octopus_to_server}"
@@ -99,5 +97,6 @@ public class OMessageToServerListener {
// 将收到的消息,直接存储到 缓存队列中
log.debug("cache the octopus message to inner cache list !");
OCTOPUS_MESSAGE_FROM_AGENT.offer(octopusMessage);
}
}

View File

@@ -0,0 +1,17 @@
package io.wdd.server.beans.mapper;
import io.wdd.server.beans.po.ServerRolePO;
import io.wdd.server.beans.vo.ServerRoleVO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
@Mapper
public interface ServerRoleDTOMapper {
ServerRoleDTOMapper INSTANCE = Mappers.getMapper(ServerRoleDTOMapper.class);
ServerRolePO voToPo(ServerRoleVO serverRoleVO);
ServerRoleVO poToVo(ServerRolePO serverRolePO);
}

View File

@@ -1,7 +1,9 @@
package io.wdd.server.beans.po;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
@@ -17,263 +19,174 @@ public class ServerInfoPO implements Serializable {
/**
* server primary key
*/
@TableId(type = IdType.AUTO)
@TableId(value = "server_id", type = IdType.AUTO)
private Long serverId;
/**
* 建议合并至 provider
*/
@TableField(value = "tenant_name")
private String tenantName;
/**
* octopus message unique key name
*/
@TableField(value = "topic_name")
private String topicName;
/**
* server host name
*/
@TableField(value = "server_name")
private String serverName;
/**
* server public ipv4
*/
@TableField(value = "server_ip_pb_v4")
private String serverIpPbV4;
/**
* server inner ipv4
*/
@TableField(value = "server_ip_in_v4")
private String serverIpInV4;
/**
* server public ipv6
*/
@TableField(value = "server_ip_pb_v6")
private String serverIpPbV6;
/**
* server inner ipv6
*/
@TableField(value = "server_ip_in_v6")
private String serverIpInV6;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
/**
* server register time
*/
@TableField(value = "register_time")
private LocalDateTime registerTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
/**
* expire time
*/
@TableField(value = "expire_time")
private LocalDateTime expireTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@TableField(fill = FieldFill.INSERT)
private LocalDateTime createTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@TableField(fill = FieldFill.INSERT_UPDATE)
/**
*
*/
@TableField(value = "update_time")
private LocalDateTime updateTime;
/**
* 服务器节点的代理类型0代表INTERFACE, 1代表relay2代表external
*
*/
private Integer proxyType;
@TableField(value = "create_time")
private LocalDateTime createTime;
/**
* server location , type City Country
*/
@TableField(value = "location")
private String location;
/**
* server isp manager
*/
@TableField(value = "provider")
private String provider;
/**
* split by ,
*/
private String managePort;
/**
*
*/
@TableField(value = "cpu_brand")
private String cpuBrand;
/**
*
*/
@TableField(value = "cpu_core")
private String cpuCore;
/**
*
*/
@TableField(value = "memory_total")
private String memoryTotal;
/**
*
*/
@TableField(value = "disk_total")
private String diskTotal;
/**
*
*/
@TableField(value = "disk_usage")
private String diskUsage;
/**
*
*/
@TableField(value = "io_speed")
private String ioSpeed;
/**
*
*/
@TableField(value = "tcp_control")
private String tcpControl;
/**
* server virtualization method
*/
@TableField(value = "virtualization")
private String virtualization;
/**
*
*/
@TableField(value = "os_info")
private String osInfo;
/**
*
*/
@TableField(value = "os_kernel_info")
private String osKernelInfo;
/**
* machine uuid from /etc/machineid
*/
@TableField(value = "machine_id")
private String machineId;
/**
* octopus message unique key name
*/
private String topicName;
/**
*
*/
@TableField(value = "comment")
private String comment;
/**
* 0 alive || 1 deleted
*/
@TableField(value = "is_delete")
private Integer isDelete;
/**
* optimistic lock for concurrent
*/
@TableField(value = "version")
private Integer version;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
ServerInfoPO other = (ServerInfoPO) that;
return (this.getServerId() == null ? other.getServerId() == null : this.getServerId().equals(other.getServerId()))
&& (this.getServerName() == null ? other.getServerName() == null : this.getServerName().equals(other.getServerName()))
&& (this.getServerIpPbV4() == null ? other.getServerIpPbV4() == null : this.getServerIpPbV4().equals(other.getServerIpPbV4()))
&& (this.getServerIpInV4() == null ? other.getServerIpInV4() == null : this.getServerIpInV4().equals(other.getServerIpInV4()))
&& (this.getServerIpPbV6() == null ? other.getServerIpPbV6() == null : this.getServerIpPbV6().equals(other.getServerIpPbV6()))
&& (this.getServerIpInV6() == null ? other.getServerIpInV6() == null : this.getServerIpInV6().equals(other.getServerIpInV6()))
&& (this.getRegisterTime() == null ? other.getRegisterTime() == null : this.getRegisterTime().equals(other.getRegisterTime()))
&& (this.getExpireTime() == null ? other.getExpireTime() == null : this.getExpireTime().equals(other.getExpireTime()))
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()))
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
&& (this.getLocation() == null ? other.getLocation() == null : this.getLocation().equals(other.getLocation()))
&& (this.getProvider() == null ? other.getProvider() == null : this.getProvider().equals(other.getProvider()))
&& (this.getManagePort() == null ? other.getManagePort() == null : this.getManagePort().equals(other.getManagePort()))
&& (this.getCpuBrand() == null ? other.getCpuBrand() == null : this.getCpuBrand().equals(other.getCpuBrand()))
&& (this.getCpuCore() == null ? other.getCpuCore() == null : this.getCpuCore().equals(other.getCpuCore()))
&& (this.getMemoryTotal() == null ? other.getMemoryTotal() == null : this.getMemoryTotal().equals(other.getMemoryTotal()))
&& (this.getDiskTotal() == null ? other.getDiskTotal() == null : this.getDiskTotal().equals(other.getDiskTotal()))
&& (this.getDiskUsage() == null ? other.getDiskUsage() == null : this.getDiskUsage().equals(other.getDiskUsage()))
&& (this.getIoSpeed() == null ? other.getIoSpeed() == null : this.getIoSpeed().equals(other.getIoSpeed()))
&& (this.getTcpControl() == null ? other.getTcpControl() == null : this.getTcpControl().equals(other.getTcpControl()))
&& (this.getVirtualization() == null ? other.getVirtualization() == null : this.getVirtualization().equals(other.getVirtualization()))
&& (this.getOsInfo() == null ? other.getOsInfo() == null : this.getOsInfo().equals(other.getOsInfo()))
&& (this.getOsKernelInfo() == null ? other.getOsKernelInfo() == null : this.getOsKernelInfo().equals(other.getOsKernelInfo()))
&& (this.getMachineId() == null ? other.getMachineId() == null : this.getMachineId().equals(other.getMachineId()))
&& (this.getTopicName() == null ? other.getTopicName() == null : this.getTopicName().equals(other.getTopicName()))
&& (this.getComment() == null ? other.getComment() == null : this.getComment().equals(other.getComment()))
&& (this.getIsDelete() == null ? other.getIsDelete() == null : this.getIsDelete().equals(other.getIsDelete()))
&& (this.getVersion() == null ? other.getVersion() == null : this.getVersion().equals(other.getVersion()));
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getServerId() == null) ? 0 : getServerId().hashCode());
result = prime * result + ((getServerName() == null) ? 0 : getServerName().hashCode());
result = prime * result + ((getServerIpPbV4() == null) ? 0 : getServerIpPbV4().hashCode());
result = prime * result + ((getServerIpInV4() == null) ? 0 : getServerIpInV4().hashCode());
result = prime * result + ((getServerIpPbV6() == null) ? 0 : getServerIpPbV6().hashCode());
result = prime * result + ((getServerIpInV6() == null) ? 0 : getServerIpInV6().hashCode());
result = prime * result + ((getRegisterTime() == null) ? 0 : getRegisterTime().hashCode());
result = prime * result + ((getExpireTime() == null) ? 0 : getExpireTime().hashCode());
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
result = prime * result + ((getLocation() == null) ? 0 : getLocation().hashCode());
result = prime * result + ((getProvider() == null) ? 0 : getProvider().hashCode());
result = prime * result + ((getManagePort() == null) ? 0 : getManagePort().hashCode());
result = prime * result + ((getCpuBrand() == null) ? 0 : getCpuBrand().hashCode());
result = prime * result + ((getCpuCore() == null) ? 0 : getCpuCore().hashCode());
result = prime * result + ((getMemoryTotal() == null) ? 0 : getMemoryTotal().hashCode());
result = prime * result + ((getDiskTotal() == null) ? 0 : getDiskTotal().hashCode());
result = prime * result + ((getDiskUsage() == null) ? 0 : getDiskUsage().hashCode());
result = prime * result + ((getIoSpeed() == null) ? 0 : getIoSpeed().hashCode());
result = prime * result + ((getTcpControl() == null) ? 0 : getTcpControl().hashCode());
result = prime * result + ((getVirtualization() == null) ? 0 : getVirtualization().hashCode());
result = prime * result + ((getOsInfo() == null) ? 0 : getOsInfo().hashCode());
result = prime * result + ((getOsKernelInfo() == null) ? 0 : getOsKernelInfo().hashCode());
result = prime * result + ((getMachineId() == null) ? 0 : getMachineId().hashCode());
result = prime * result + ((getTopicName() == null) ? 0 : getTopicName().hashCode());
result = prime * result + ((getComment() == null) ? 0 : getComment().hashCode());
result = prime * result + ((getIsDelete() == null) ? 0 : getIsDelete().hashCode());
result = prime * result + ((getVersion() == null) ? 0 : getVersion().hashCode());
return result;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", serverId=").append(serverId);
sb.append(", serverName=").append(serverName);
sb.append(", serverIpPbV4=").append(serverIpPbV4);
sb.append(", serverIpInV4=").append(serverIpInV4);
sb.append(", serverIpPbV6=").append(serverIpPbV6);
sb.append(", serverIpInV6=").append(serverIpInV6);
sb.append(", registerTime=").append(registerTime);
sb.append(", expireTime=").append(expireTime);
sb.append(", updateTime=").append(updateTime);
sb.append(", createTime=").append(createTime);
sb.append(", location=").append(location);
sb.append(", provider=").append(provider);
sb.append(", managePort=").append(managePort);
sb.append(", cpuBrand=").append(cpuBrand);
sb.append(", cpuCore=").append(cpuCore);
sb.append(", memoryTotal=").append(memoryTotal);
sb.append(", diskTotal=").append(diskTotal);
sb.append(", diskUsage=").append(diskUsage);
sb.append(", ioSpeed=").append(ioSpeed);
sb.append(", tcpControl=").append(tcpControl);
sb.append(", virtualization=").append(virtualization);
sb.append(", osInfo=").append(osInfo);
sb.append(", osKernelInfo=").append(osKernelInfo);
sb.append(", machineId=").append(machineId);
sb.append(", topicName=").append(topicName);
sb.append(", comment=").append(comment);
sb.append(", isDelete=").append(isDelete);
sb.append(", version=").append(version);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
}

View File

@@ -0,0 +1,33 @@
package io.wdd.server.beans.po;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
/**
* @TableName server_role
*/
@TableName(value = "server_role")
@Data
public class ServerRolePO implements Serializable {
@TableField(exist = false)
private static final long serialVersionUID = 1L;
/**
*
*/
@TableId(value = "role_id")
private Long roleId;
/**
* 服务器角色名称
*/
@TableField(value = "role_name")
private String roleName;
/**
* 服务器角色对应的序号
*/
@TableField(value = "role_num")
private Integer roleNum;
}

View File

@@ -0,0 +1,20 @@
package io.wdd.server.beans.vo;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
@Data
public class ServerRoleVO {
/**
* 服务器角色名称
*/
@TableField(value = "role_name")
private String roleName;
/**
* 服务器角色对应的序号
*/
@TableField(value = "role_num")
private Integer roleNum;
}

View File

@@ -0,0 +1,70 @@
package io.wdd.server.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.wdd.common.response.R;
import io.wdd.server.beans.po.ServerRolePO;
import io.wdd.server.beans.vo.ServerRoleVO;
import io.wdd.server.coreService.CoreRoleService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
@RestController
@Api("Octopus Server - 服务器角色信息")
@RequestMapping("/role")
public class RoleController {
@Resource
CoreRoleService roleService;
@GetMapping("/all")
@ApiOperation("角色-获取全部角色信息")
public R<List<ServerRolePO>> roleGetAll(
) {
return R.ok(roleService.roleGetAll());
}
@PostMapping("/create")
@ApiOperation("角色-创建一个角色")
public R<String> roleCreate(
@RequestBody ServerRoleVO serverRoleVO
) {
String result = "创建角色成功!";
if (!roleService.roleCreate(serverRoleVO)) {
result = "创建角色失败!";
}
return R.ok(result);
}
@PostMapping("/update")
@ApiOperation("角色-更新一个角色")
public R<String> roleUpdate(
@RequestBody ServerRolePO serverRolePO
) {
String result = "更新角色成功!";
if (!roleService.roleUpdate(serverRolePO)) {
result = "更新角色失败!";
}
return R.ok(result);
}
@PostMapping("/delete")
@ApiOperation("角色-删除一个角色")
public R<String> roleDelete(
@RequestParam(value = "roleId", name = "角色的Id") @ApiParam(value = "角色的Id") Long roleId
) {
String result = "删除角色成功!";
if (!roleService.roleDelete(roleId)) {
result = "删除角色失败!";
}
return R.ok(result);
}
}

View File

@@ -0,0 +1,19 @@
package io.wdd.server.coreService;
import io.wdd.server.beans.po.ServerRolePO;
import io.wdd.server.beans.vo.ServerRoleVO;
import java.util.List;
public interface CoreRoleService {
// 获取所有的角色
List<ServerRolePO> roleGetAll();
boolean roleCreate(ServerRoleVO serverRoleVO);
boolean roleUpdate(ServerRolePO serverRolePO);
boolean roleDelete(Long roleId);
}

View File

@@ -31,22 +31,22 @@ public interface CoreServerService {
boolean serverDelete(Long serverId, String serverName);
/* app deprecated 2023年10月8日 */
List<AppInfoVO> appGetAll(Long serverId);
AppInfoVO appCreate(Long serverId, AppInfoVO appInfoVO);
boolean appDelete(Long serverId, Long appId);
/* domain deprecated 2023年10月8日 */
List<DomainInfoVO> domainGetAll(Long serverId);
List<DomainInfoVO> domainGetSingle(Long serverId, String domainName, String dnsIP);
boolean domainCreate(Long serverId, DomainInfoVO domainInfoVO);
boolean domainUpdate(DomainInfoPO domainInfoPO);
boolean domainDelete(Long serverId, Long domainId);
}

View File

@@ -0,0 +1,45 @@
package io.wdd.server.coreService.impl;
import io.wdd.server.beans.mapper.ServerRoleDTOMapper;
import io.wdd.server.beans.po.ServerRolePO;
import io.wdd.server.beans.vo.ServerRoleVO;
import io.wdd.server.coreService.CoreRoleService;
import io.wdd.server.service.ServerRoleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service
@Slf4j
public class CoreRoleServiceImpl implements CoreRoleService {
@Resource
ServerRoleService serverRoleService;
@Resource
ServerRoleDTOMapper serverRoleDTOMapper;
@Override
public List<ServerRolePO> roleGetAll() {
return serverRoleService.list();
}
@Override
public boolean roleCreate(ServerRoleVO serverRoleVO) {
ServerRolePO serverRolePO = serverRoleDTOMapper.voToPo(serverRoleVO);
return serverRoleService.save(serverRolePO);
}
@Override
public boolean roleUpdate(ServerRolePO serverRolePO) {
return serverRoleService.saveOrUpdate(serverRolePO);
}
@Override
public boolean roleDelete(Long roleId) {
return serverRoleService.removeById(roleId);
}
}

View File

@@ -1,12 +1,12 @@
package io.wdd.server.mapper;
import io.wdd.server.beans.po.ServerInfoPO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import io.wdd.server.beans.po.ServerInfoPO;
/**
* @author wdd
* @description 针对表【server_info】的数据库操作Mapper
* @createDate 2022-11-30 13:54:40
* @createDate 2023-10-08 11:24:01
* @Entity io.wdd.server.beans.po.ServerInfoPO
*/
public interface ServerInfoMapper extends BaseMapper<ServerInfoPO> {

View File

@@ -0,0 +1,18 @@
package io.wdd.server.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import io.wdd.server.beans.po.ServerRolePO;
/**
* @author wdd
* @description 针对表【server_role】的数据库操作Mapper
* @createDate 2023-10-08 11:33:51
* @Entity io.wdd.server.beans.po.ServerRolePO
*/
public interface ServerRoleMapper extends BaseMapper<ServerRolePO> {
}

View File

@@ -1,12 +1,12 @@
package io.wdd.server.service;
import io.wdd.server.beans.po.ServerInfoPO;
import com.baomidou.mybatisplus.extension.service.IService;
import io.wdd.server.beans.po.ServerInfoPO;
/**
* @author wdd
* @description 针对表【server_info】的数据库操作Service
* @createDate 2022-11-30 13:54:40
* @createDate 2023-10-08 11:24:01
*/
public interface ServerInfoService extends IService<ServerInfoPO> {

View File

@@ -0,0 +1,13 @@
package io.wdd.server.service;
import com.baomidou.mybatisplus.extension.service.IService;
import io.wdd.server.beans.po.ServerRolePO;
/**
* @author wdd
* @description 针对表【server_role】的数据库操作Service
* @createDate 2023-10-08 11:33:51
*/
public interface ServerRoleService extends IService<ServerRolePO> {
}

View File

@@ -2,14 +2,14 @@ package io.wdd.server.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.wdd.server.beans.po.ServerInfoPO;
import io.wdd.server.service.ServerInfoService;
import io.wdd.server.mapper.ServerInfoMapper;
import io.wdd.server.service.ServerInfoService;
import org.springframework.stereotype.Service;
/**
* @author wdd
* @description 针对表【server_info】的数据库操作Service实现
* @createDate 2022-11-30 13:54:40
* @createDate 2023-10-08 11:24:01
*/
@Service
public class ServerInfoServiceImpl extends ServiceImpl<ServerInfoMapper, ServerInfoPO>

View File

@@ -0,0 +1,22 @@
package io.wdd.server.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.wdd.server.beans.po.ServerRolePO;
import io.wdd.server.mapper.ServerRoleMapper;
import io.wdd.server.service.ServerRoleService;
import org.springframework.stereotype.Service;
/**
* @author wdd
* @description 针对表【server_role】的数据库操作Service实现
* @createDate 2023-10-08 11:33:51
*/
@Service
public class ServerRoleServiceImpl extends ServiceImpl<ServerRoleMapper, ServerRolePO>
implements ServerRoleService {
}

View File

@@ -6,6 +6,8 @@
<resultMap id="BaseResultMap" type="io.wdd.server.beans.po.ServerInfoPO">
<id property="serverId" column="server_id" jdbcType="BIGINT"/>
<result property="tenantName" column="tenant_name" jdbcType="VARCHAR"/>
<result property="topicName" column="topic_name" jdbcType="VARCHAR"/>
<result property="serverName" column="server_name" jdbcType="VARCHAR"/>
<result property="serverIpPbV4" column="server_ip_pb_v4" jdbcType="VARCHAR"/>
<result property="serverIpInV4" column="server_ip_in_v4" jdbcType="VARCHAR"/>
@@ -17,7 +19,6 @@
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="location" column="location" jdbcType="VARCHAR"/>
<result property="provider" column="provider" jdbcType="VARCHAR"/>
<result property="managePort" column="manage_port" jdbcType="VARCHAR"/>
<result property="cpuBrand" column="cpu_brand" jdbcType="VARCHAR"/>
<result property="cpuCore" column="cpu_core" jdbcType="VARCHAR"/>
<result property="memoryTotal" column="memory_total" jdbcType="VARCHAR"/>
@@ -29,22 +30,22 @@
<result property="osInfo" column="os_info" jdbcType="VARCHAR"/>
<result property="osKernelInfo" column="os_kernel_info" jdbcType="VARCHAR"/>
<result property="machineId" column="machine_id" jdbcType="VARCHAR"/>
<result property="topicName" column="topic_name" jdbcType="VARCHAR"/>
<result property="comment" column="comment" jdbcType="VARCHAR"/>
<result property="isDelete" column="is_delete" jdbcType="TINYINT"/>
<result property="version" column="version" jdbcType="INTEGER"/>
</resultMap>
<sql id="Base_Column_List">
server_id,server_name,server_ip_pb_v4,
server_ip_in_v4,server_ip_pb_v6,server_ip_in_v6,
register_time,expire_time,update_time,
create_time,location,provider,
manage_port,cpu_brand,cpu_core,
memory_total,disk_total,disk_usage,
io_speed,tcp_control,virtualization,
os_info,os_kernel_info,machine_id,
topic_name,comment,is_delete,
server_id
,tenant_name,topic_name,
server_name,server_ip_pb_v4,server_ip_in_v4,
server_ip_pb_v6,server_ip_in_v6,register_time,
expire_time,update_time,create_time,
location,provider,cpu_brand,
cpu_core,memory_total,disk_total,
disk_usage,io_speed,tcp_control,
virtualization,os_info,os_kernel_info,
machine_id,comment,is_delete,
version
</sql>
</mapper>

View File

@@ -0,0 +1,17 @@
<?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="io.wdd.server.mapper.ServerRoleMapper">
<resultMap id="BaseResultMap" type="io.wdd.server.beans.po.ServerRolePO">
<id property="roleId" column="role_id" jdbcType="BIGINT"/>
<result property="roleName" column="role_name" jdbcType="VARCHAR"/>
<result property="roleNum" column="role_num" jdbcType="TINYINT"/>
</resultMap>
<sql id="Base_Column_List">
role_id
,role_name,role_num
</sql>
</mapper>

View File

@@ -2,9 +2,7 @@
##### environment variables ######
JAVA_OPTS="-Xms128m -Xmx512m -Ddebug=false -Dfile.encoding=utf-8 --spring.profiles.active=k3s --spring.cloud.nacos.config.group=k3s --spring.cloud.nacos.config.server-addr=150.230.198.103:21060 --spring.cloud.nacos.config.extension-configs[0].dataId=common-k3s.yaml --spring.cloud.nacos.config.extension-configs[0].group=k3s"
DependLibFiles=(
JAVA_OPTS="-Xms128m -Xmx512m -Ddebug=false -Dfile.encoding=utf-8 --spring.profiles.active=k3s --spring.cloud.nacos.config.group=k3s --spring.cloud.nacos.config.server-addr=150.230.198.103:21060 --spring.cloud.nacos.config.extension-configs[0].dataId=common-k3s.yaml --spring.cloud.nacos.config.extension-configs[0].group=k3s"DependLibFiles=(
wdd-lib-file.sh
wdd-lib-log.sh
wdd-lib-env.sh