소스 검색

新增日志管理功能

jingyuanchao 1 년 전
부모
커밋
b92221365e

+ 18 - 0
project_data/sql/0.1.1/soc/soc.sql

@@ -1300,3 +1300,21 @@ INSERT INTO `iot_alarm_system_field` (`product_type`, `product_name`, `product_p
 INSERT INTO `iot_alarm_system_field` (`product_type`, `product_name`, `product_property`, `product_property_display_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `alarm_rule_property`, `order`) VALUES ('AlarmHostInput_IMDualIdentification', '红外微波双鉴', 'status', '红外微波双鉴', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, 0, 13);
 INSERT INTO `iot_alarm_system_field` (`product_type`, `product_name`, `product_property`, `product_property_display_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `alarm_rule_property`, `order`) VALUES ('AlarmHostInput_Microwave', '微波', 'status', '微波', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, 0, 14);
 INSERT INTO `iot_alarm_system_field` (`product_type`, `product_name`, `product_property`, `product_property_display_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `alarm_rule_property`, `order`) VALUES ('AlarmHostInput_EmergencyButton', '紧急按钮', 'status', '紧急按钮', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, 0, 15);
+
+
+-- 新增日志管理菜单(管理员使用功能)
+INSERT INTO `sys_menu`(`id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `platform_type`, `icon`, `image_path`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (01843936562189307906, '日志管理', 2, 99, 'logManagement', 'system/logManagement/index', NULL, 1, 0, 'C', '0', '0', NULL, '1', 'server', NULL, '超级管理员', '2024-10-09 16:48:29', '', NULL, '');
+drop table if exists `sys_server`;
+CREATE TABLE `sys_server` (
+      `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
+      `server_ip` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '服务器ip',
+      `server_token` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '看门猫token',
+      `server_port` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '看门猫端口',
+      `server_name` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '服务器名称',
+      `remark` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '备注',
+      `create_by` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建者',
+      `create_time` datetime DEFAULT NULL COMMENT '创建时间',
+      `update_by` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '更新者',
+      `update_time` datetime DEFAULT NULL COMMENT '更新时间',
+      PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='服务器维护';

+ 0 - 120
soc-modules/soc-modules-gen/src/main/java/com/xunmei/gen/util/CodeGenerators.java

@@ -1,120 +0,0 @@
-package com.xunmei.gen.util;
-
-
-import com.baomidou.mybatisplus.generator.AutoGenerator;
-import com.baomidou.mybatisplus.generator.InjectionConfig;
-import com.baomidou.mybatisplus.generator.config.*;
-import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class CodeGenerators {
-
-    /**
-     * 读取控制填的内容
-     * @param tip
-     * @return
-     */
-  /*  public static String scanner(String tip) {
-        Scanner scanner = new Scanner(System.in);
-        System.out.println("请输入" + tip + ":");
-        if (scanner.hasNext()) {
-            String ipt = scanner.next();
-            if (ObjectUtils.isNotEmpty(ipt)) {
-                return ipt;
-            }
-        }
-        throw new MybatisPlusException("请输入正确的" + tip + "!");
-    }*/
-
-    public static final String moduleName="com.xunmei.core";
-    public static final String tableNames="iot_alarm_rule,iot_alarm_rule_source,iot_alarm_rule_express,iot_alarm_system_field";
-
-    public static void main(String[] args) {
-        // 代码生成器
-        AutoGenerator mpg = new AutoGenerator();
-        // 全局配置
-        GlobalConfig gc = new GlobalConfig();
-        // System.getProperty("user.dir");
-        String projectPath = "D:\\";
-        //生成文件输出目录
-        gc.setOutputDir(projectPath + "/java");
-        gc.setAuthor("jingYuanChao");
-        //生成代码后,是否打开文件夹
-        gc.setOpen(true);
-        // 实体属性 Swagger2 注解
-        gc.setSwagger2(true);
-        mpg.setGlobalConfig(gc);
-        // 数据源配置
-        DataSourceConfig dsc = new DataSourceConfig();
-       /* dsc.setUrl("jdbc:mysql://39.103.229.41:3306/isp_ah?serverTimezone=Asia/Shanghai&characterEncoding=UTF-8&characterSetResults=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true");
-        dsc.setDriverName("com.mysql.cj.jdbc.Driver");
-        dsc.setUsername("root");
-        dsc.setPassword("jinJie@2021");*/
-        dsc.setUrl("jdbc:mysql://10.87.23.57:3306/soc?serverTimezone=Asia/Shanghai&characterEncoding=UTF-8&characterSetResults=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true");
-        dsc.setDriverName("com.mysql.cj.jdbc.Driver");
-        dsc.setUsername("root");
-        dsc.setPassword("XM_zm2019");
-        mpg.setDataSource(dsc);
-
-
-        // 包配置
-        PackageConfig pc = new PackageConfig();
-        pc.setModuleName(moduleName);
-        pc.setEntity("domain");
-        pc.setMapper("mapper");
-        pc.setService("service");
-        pc.setController("controller");
-        mpg.setPackageInfo(pc);
-        // 自定义配置
-        InjectionConfig cfg = new InjectionConfig() {
-            @Override
-            public void initMap() {
-                // to do nothing
-            }
-        };
-        // 如果模板引擎是 freemarker
-        //String templatePath = "/templates/mapper.xml.ftl";
-        // 自定义输出配置
-        List<FileOutConfig> focList = new ArrayList<>();
-        // 自定义配置会被优先输出
-//        focList.add(new FileOutConfig(templatePath) {
-//            @Override
-//            pub String outputFile(TableInfo tableInfo) {
-//                // 自定义输出文件名 , 如果你 Entity 设置了前后缀、此处注意 xml 的名称会跟着发生变化!!
-//                return projectPath + "/src/main/resources/mapper/" + pc.getModuleName()
-//                        + "/" + tableInfo.getEntityName() + "Mapper" + StringPool.DOT_XML;
-//            }
-//        });
-        cfg.setFileOutConfigList(focList);
-        //这个必须要,需要提供一个默认的
-        mpg.setCfg(cfg);
-
-        // 策略配置
-        StrategyConfig strategy = new StrategyConfig();
-        // 表名生成策略
-        strategy.setNaming(NamingStrategy.underline_to_camel);
-        // 实体字段生成策略
-        strategy.setColumnNaming(NamingStrategy.underline_to_camel);
-        // 需要生成的表
-        strategy.setInclude(tableNames.split(","));
-        // 使用lombook
-        strategy.setEntityLombokModel(true);
-        strategy.setRestControllerStyle(true);
-        // 生成注解
-        strategy.setEntityTableFieldAnnotationEnable(true);
-        // 自动生成实体类继承基类(基类必须已存在)
-        strategy.setTablePrefix("t_","t_app_");
-        //strategy.setSuperEntityClass("com.isp.common.jpa.BaseEntity");
-        // 写于父类中的公共字段
-        //strategy.setSuperEntityColumns("create_time","update_time", "modified_id", "modified_name");
-        mpg.setStrategy(strategy);
-        //mpg.setTemplateEngine(new FreemarkerTemplateEngine());
-        mpg.execute();
-    }
-
-
-
-}

+ 18 - 38
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/controller/SysServerController.java

@@ -1,29 +1,21 @@
 package com.xunmei.system.controller;
 
-import java.util.List;
-import java.io.IOException;
-import javax.servlet.http.HttpServletResponse;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import com.xunmei.common.core.web.controller.BaseController;
+import com.xunmei.common.core.web.domain.AjaxResult;
+import com.xunmei.common.core.web.page.TableDataInfo;
 import com.xunmei.common.log.annotation.Log;
 import com.xunmei.common.log.enums.BusinessType;
-import com.xunmei.common.security.annotation.RequiresPermissions;
 import com.xunmei.system.domain.SysServer;
+import com.xunmei.system.dto.server.SysServerEditDto;
+import com.xunmei.system.dto.server.SysServerPageDto;
 import com.xunmei.system.service.ISysServerService;
-import com.xunmei.common.core.web.controller.BaseController;
-import com.xunmei.common.core.web.domain.AjaxResult;
+import com.xunmei.system.vo.server.SysServerPageVo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.xunmei.common.core.web.page.TableDataInfo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
 
 /**
  * 服务器维护Controller
@@ -42,18 +34,17 @@ public class SysServerController extends BaseController {
      * 查询服务器维护列表
      */
     @ApiOperation(value = "查询SysServer列表")
-    @RequiresPermissions("system:server:list")
+    //@RequiresPermissions("system:server:list")
     @GetMapping("/list")
-    public TableDataInfo<SysServer> list(SysServer sysServer) {
-
-        return sysServerService.selectPage(sysServer);
+    public TableDataInfo<SysServerPageVo> list(SysServerPageDto req) {
+        return sysServerService.selectPage(req);
     }
 
     /**
      * 获取服务器维护详细信息
      */
     @ApiOperation(value = "获取SysServer详细信息")
-    @RequiresPermissions("system:server:query")
+    //@RequiresPermissions("system:server:query")
     @GetMapping(value = "/{id}")
     public AjaxResult getInfo(@PathVariable("id") Long id) {
         return success(sysServerService.selectSysServerById(id));
@@ -63,29 +54,18 @@ public class SysServerController extends BaseController {
      * 新增服务器维护
      */
     @ApiOperation(value = "新增SysServer")
-    @RequiresPermissions("system:server:add")
+    //@RequiresPermissions("system:server:add")
     @Log(title = "服务器维护", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult add(@RequestBody SysServer sysServer) {
-        return toAjax(sysServerService.insertSysServer(sysServer));
-    }
-
-    /**
-     * 修改服务器维护
-     */
-    @ApiOperation(value = "修改SysServer")
-    @RequiresPermissions("system:server:edit")
-    @Log(title = "服务器维护", businessType = BusinessType.UPDATE)
-    @PutMapping
-    public AjaxResult edit(@RequestBody SysServer sysServer) {
-        return toAjax(sysServerService.updateSysServer(sysServer));
+    public AjaxResult edit(@RequestBody @Valid SysServerEditDto req) {
+        return toAjax(sysServerService.editSysServer(req));
     }
 
     /**
      * 删除服务器维护
      */
     @ApiOperation(value = "删除SysServer")
-    @RequiresPermissions("system:server:remove")
+    //@RequiresPermissions("system:server:remove")
     @Log(title = "服务器维护", businessType = BusinessType.DELETE)
     @DeleteMapping("/{ids}")
     public AjaxResult remove(@PathVariable Long[] ids) {

+ 15 - 21
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/domain/SysServer.java

@@ -1,16 +1,16 @@
 package com.xunmei.system.domain;
 
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
-
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
-import com.baomidou.mybatisplus.annotation.IdType;
+import com.xunmei.common.core.web.domain.BaseEntity;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
-import com.xunmei.common.core.web.domain.BaseEntity;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
 
 /**
  * 服务器维护对象 sys_server
@@ -26,35 +26,29 @@ import com.xunmei.common.core.web.domain.BaseEntity;
 public class SysServer extends BaseEntity {
     private static final long serialVersionUID = 1L;
 
-    /**
-     * 主键
-     */
+
+    @TableId
     private Long id;
 
-    /**
-     * 服务器ip
-     */
+    @TableField("server_ip")
     @ApiModelProperty(value = "服务器ip")
     private String serverIp;
 
-    /**
-     * 看门猫token
-     */
+    @TableField("server_token")
+    @ApiModelProperty(value = "看门猫token")
     private String serverToken;
 
-    /**
-     * 看门猫端口
-     */
+    @TableField("server_port")
     @ApiModelProperty(value = "看门猫端口")
     private String serverPort;
 
-    /**
-     * 服务器名称
-     */
+    @TableField("server_name")
     @ApiModelProperty(value = "服务器名称")
     private String serverName;
 
-
+    @TableField("remark")
+    @ApiModelProperty(value = "备注")
+    private String remark;
     @Override
     public String toString() {
         return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)

+ 34 - 0
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/dto/server/SysServerEditDto.java

@@ -0,0 +1,34 @@
+package com.xunmei.system.dto.server;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author jingyuanchao
+ * @date 2024/10/9 16:17
+ */
+@Data
+public class SysServerEditDto {
+
+    private Long id;
+
+    @NotNull(message = "请填写服务器ip")
+    @NotBlank(message = "请填写服务器ip")
+    @ApiModelProperty(value = "服务器ip")
+    private String serverIp;
+
+
+    @NotNull(message = "请填写看门猫端口")
+    @NotBlank(message = "请填写看门猫端口")
+    @ApiModelProperty(value = "看门猫端口")
+    private String serverPort;
+
+    @ApiModelProperty(value = "服务器名称")
+    private String serverName;
+
+    @ApiModelProperty(value = "备注")
+    private String remark;
+}

+ 17 - 0
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/dto/server/SysServerPageDto.java

@@ -0,0 +1,17 @@
+package com.xunmei.system.dto.server;
+
+import com.xunmei.common.core.web.domain.PageRequest;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * @author jingyuanchao
+ * @date 2024/10/9 16:09
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class SysServerPageDto extends PageRequest {
+
+    private String serverName;
+
+}

+ 9 - 3
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/mapper/SysServerMapper.java

@@ -1,10 +1,14 @@
 package com.xunmei.system.mapper;
 
-import java.util.List;
-
-import com.xunmei.system.domain.SysServer;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.xunmei.system.domain.SysServer;
+import com.xunmei.system.dto.server.SysServerPageDto;
+import com.xunmei.system.vo.server.SysServerPageVo;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * 服务器维护Mapper接口
@@ -61,4 +65,6 @@ public interface SysServerMapper extends BaseMapper<SysServer> {
      * @return 结果
      */
     int deleteSysServerByIds(Long[] ids);
+
+    Page<SysServerPageVo> selectPageData(Page<SysServerPageVo> pageRequest, @Param("req") SysServerPageDto req);
 }

+ 6 - 10
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/service/ISysServerService.java

@@ -3,7 +3,9 @@ package com.xunmei.system.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.xunmei.common.core.web.page.TableDataInfo;
 import com.xunmei.system.domain.SysServer;
-import org.springframework.web.bind.annotation.RequestBody;
+import com.xunmei.system.dto.server.SysServerEditDto;
+import com.xunmei.system.dto.server.SysServerPageDto;
+import com.xunmei.system.vo.server.SysServerPageVo;
 
 import java.util.List;
 
@@ -36,15 +38,9 @@ public interface ISysServerService extends IService<SysServer> {
      * @param sysServer 服务器维护
      * @return 结果
      */
-    int insertSysServer(SysServer sysServer);
+    int editSysServer(SysServerEditDto sysServer);
+    boolean checkIpRepeat(String ip,Long id);
 
-    /**
-     * 修改服务器维护
-     *
-     * @param sysServer 服务器维护
-     * @return 结果
-     */
-    int updateSysServer(SysServer sysServer);
 
     /**
      * 批量删除服务器维护
@@ -68,7 +64,7 @@ public interface ISysServerService extends IService<SysServer> {
      * @param sysServer 查询条件对象
      * @return Page
      */
-    TableDataInfo<SysServer> selectPage(SysServer sysServer);
+    TableDataInfo<SysServerPageVo> selectPage(SysServerPageDto req);
 
     /**
      * 获取此服务器下的日志文件

+ 39 - 42
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/service/impl/SysServerServiceImpl.java

@@ -1,27 +1,31 @@
 package com.xunmei.system.service.impl;
 
-import java.util.List;
-
 import cn.hutool.http.HttpResponse;
 import cn.hutool.http.HttpUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson2.JSONArray;
 import com.alibaba.fastjson2.JSONObject;
-import com.alibaba.fastjson2.JSONReader;
+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.xunmei.common.core.util.BeanHelper;
 import com.xunmei.common.core.utils.DateUtils;
+import com.xunmei.common.core.web.page.TableDataInfo;
+import com.xunmei.common.security.utils.SecurityUtils;
+import com.xunmei.system.domain.SysServer;
+import com.xunmei.system.dto.server.SysServerEditDto;
+import com.xunmei.system.dto.server.SysServerPageDto;
+import com.xunmei.system.mapper.SysServerMapper;
+import com.xunmei.system.service.ISysServerService;
 import com.xunmei.system.vo.server.CheckListVo;
+import com.xunmei.system.vo.server.SysServerPageVo;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.Arrays;
-
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.xunmei.common.core.web.page.TableDataInfo;
-import com.xunmei.system.mapper.SysServerMapper;
-import com.xunmei.system.domain.SysServer;
-import com.xunmei.system.service.ISysServerService;
+import java.util.List;
 
 /**
  * 服务器维护Service业务层处理
@@ -36,19 +40,10 @@ public class SysServerServiceImpl extends ServiceImpl<SysServerMapper, SysServer
     private SysServerMapper sysServerMapper;
 
     @Override
-    public TableDataInfo<SysServer> selectPage(SysServer sysServer) {
-        //未删除
-        Page<SysServer> page;
-        //分页
-        if (sysServer.getPageNum() != null && sysServer.getPageSize() != null) {
-            page = new Page<>(sysServer.getPageNum(), sysServer.getPageSize());
-        } else {
-            page = new Page<>();
-        }
-        //查询条件
-        QueryWrapper<SysServer> query = new QueryWrapper<>(sysServer);
+    public TableDataInfo<SysServerPageVo> selectPage(SysServerPageDto req) {
+
         //获取数据
-        page = sysServerMapper.selectPage(page, query);
+        Page<SysServerPageVo> page = sysServerMapper.selectPageData(req.getPageRequest(), req);
         //抓换为TableDataInfo适配前端
         return TableDataInfo.build(page);
 
@@ -60,7 +55,7 @@ public class SysServerServiceImpl extends ServiceImpl<SysServerMapper, SysServer
         SysServer server = this.selectSysServerById(sysServer.getId());
         StringBuffer baseUrl = new StringBuffer("http://");
         baseUrl.append(server.getServerIp()).append(":")
-                        .append(server.getServerPort());
+                .append(server.getServerPort());
         String rootUrl = baseUrl.toString();
 
         String getServices = "/result/list?size=10000&current=1";
@@ -105,28 +100,30 @@ public class SysServerServiceImpl extends ServiceImpl<SysServerMapper, SysServer
         return sysServerMapper.selectList(new QueryWrapper<>(sysServer));
     }
 
-    /**
-     * 新增服务器维护
-     *
-     * @param sysServer 服务器维护
-     * @return 结果
-     */
     @Override
-    public int insertSysServer(SysServer sysServer) {
-        sysServer.setCreateTime(DateUtils.getNowDate());
-        return sysServerMapper.insert(sysServer);
+    public boolean checkIpRepeat(String ip, Long id) {
+        final Long count = lambdaQuery().eq(SysServer::getServerIp, ip).ne(id != null, SysServer::getId, id).count();
+        return count == 0;
     }
 
-    /**
-     * 修改服务器维护
-     *
-     * @param sysServer 服务器维护
-     * @return 结果
-     */
     @Override
-    public int updateSysServer(SysServer sysServer) {
-        sysServer.setUpdateTime(DateUtils.getNowDate());
-        return sysServerMapper.updateById(sysServer);
+    @Transactional(rollbackFor = Exception.class)
+    public int editSysServer(SysServerEditDto req) {
+        if (!checkIpRepeat(req.getServerIp(), req.getId())) {
+            throw new RuntimeException("ip重复");
+        }
+        if (req.getId() == null) {
+            final SysServer sysServer = BeanHelper.copyProperties(req, SysServer.class);
+            sysServer.setCreateTime(DateUtils.getNowDate());
+            sysServer.setUpdateTime(DateUtils.getNowDate());
+            sysServer.setCreateBy(SecurityUtils.getLoginUser().getSysUser().getUsername());
+            sysServer.setUpdateBy(SecurityUtils.getLoginUser().getSysUser().getUsername());
+            return sysServerMapper.insertSysServer(sysServer);
+        }
+        final SysServer server = getById(req.getId());
+        BeanUtils.copyProperties(req, server);
+        server.setUpdateTime(DateUtils.getNowDate());
+        return sysServerMapper.updateById(server);
     }
 
     /**

+ 36 - 0
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/vo/server/SysServerPageVo.java

@@ -0,0 +1,36 @@
+package com.xunmei.system.vo.server;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @author jingyuanchao
+ * @date 2024/10/9 16:11
+ */
+@Data
+public class SysServerPageVo {
+
+    private Long id;
+
+    @ApiModelProperty(value = "服务器ip")
+    private String serverIp;
+
+    @ApiModelProperty(value = "看门猫token")
+    private String serverToken;
+
+    @ApiModelProperty(value = "看门猫端口")
+    private String serverPort;
+
+    @ApiModelProperty(value = "服务器名称")
+    private String serverName;
+
+    @ApiModelProperty(value = "备注")
+    private String remark;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @ApiModelProperty(value = "修改时间")
+    private Date updateTime;
+}

+ 9 - 0
soc-modules/soc-modules-system/src/main/resources/mapper/system/SysServerMapper.xml

@@ -126,4 +126,13 @@
             #{id}
         </foreach>
     </delete>
+
+    <select id="selectPageData" resultType="com.xunmei.system.vo.server.SysServerPageVo">
+        select * from sys_server
+        <where>
+            <if test="req.serverName != null and req.serverName != ''">
+                and server_name like concat('%', #{req.serverName}, '%')
+            </if>
+        </where>
+    </select>
 </mapper>