7 changed files with 301 additions and 0 deletions
			
			
		| @ -0,0 +1,158 @@@@ -0,0 +1,158 @@ | ||||
| package cc.niushuai.bastionserver.modules.server.controller; | ||||
| 
 | ||||
| import cc.niushuai.bastionserver.common.api.vo.Result; | ||||
| import cc.niushuai.bastionserver.common.aspect.annotation.AutoLog; | ||||
| import cc.niushuai.bastionserver.common.base.controller.BaseController; | ||||
| import cc.niushuai.bastionserver.common.system.query.QueryGenerator; | ||||
| import cc.niushuai.bastionserver.modules.server.entity.ServerInfo; | ||||
| import cc.niushuai.bastionserver.modules.server.service.ServerInfoService; | ||||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | ||||
| import com.baomidou.mybatisplus.core.metadata.IPage; | ||||
| import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | ||||
| import io.swagger.annotations.Api; | ||||
| import io.swagger.annotations.ApiOperation; | ||||
| import lombok.extern.slf4j.Slf4j; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
| import org.springframework.web.servlet.ModelAndView; | ||||
| 
 | ||||
| import javax.annotation.Resource; | ||||
| import javax.servlet.http.HttpServletRequest; | ||||
| import javax.servlet.http.HttpServletResponse; | ||||
| import java.util.Arrays; | ||||
| 
 | ||||
| /** | ||||
|  * 服务器信息 | ||||
|  * | ||||
|  * @author: niushuai233 | ||||
|  * @date: 2023-01-03 16:20:46 | ||||
|  */ | ||||
| @Slf4j | ||||
| @Api(tags = "服务器信息") | ||||
| @RestController | ||||
| @RequestMapping("/server/serverInfo") | ||||
| public class ServerInfoController extends BaseController<ServerInfo, ServerInfoService> { | ||||
| 
 | ||||
|     @Resource | ||||
|     private ServerInfoService serverInfoService; | ||||
| 
 | ||||
|     /** | ||||
|      * 分页列表查询 | ||||
|      * | ||||
|      * @param serverInfo | ||||
|      * @param pageNo | ||||
|      * @param pageSize | ||||
|      * @param req | ||||
|      * @return | ||||
|      */ | ||||
|     @AutoLog(value = "服务器信息-分页列表查询") | ||||
|     @ApiOperation(value = "服务器信息-分页列表查询", notes = "服务器信息-分页列表查询") | ||||
|     @GetMapping(value = "/list") | ||||
|     public Result<?> queryPageList(ServerInfo serverInfo, | ||||
|                                    @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, | ||||
|                                    @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, | ||||
|                                    HttpServletRequest req) { | ||||
|         QueryWrapper<ServerInfo> queryWrapper = QueryGenerator.initQueryWrapper(serverInfo, req.getParameterMap()); | ||||
|         Page<ServerInfo> page = new Page<ServerInfo>(pageNo, pageSize); | ||||
|         IPage<ServerInfo> pageList = serverInfoService.page(page, queryWrapper); | ||||
|         return Result.OK(pageList); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 添加 | ||||
|      * | ||||
|      * @param serverInfo | ||||
|      * @return | ||||
|      */ | ||||
|     @AutoLog(value = "服务器信息-添加") | ||||
|     @ApiOperation(value = "服务器信息-添加", notes = "服务器信息-添加") | ||||
|     @PostMapping(value = "/add") | ||||
|     public Result<?> add(@RequestBody ServerInfo serverInfo) { | ||||
| 
 | ||||
|         exists(serverInfo, ServerInfo::getId, ServerInfo::getIp); | ||||
| 
 | ||||
|         serverInfoService.save(serverInfo); | ||||
|         return Result.OK("添加成功!"); | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * 编辑 | ||||
|      * | ||||
|      * @param serverInfo | ||||
|      * @return | ||||
|      */ | ||||
|     @AutoLog(value = "服务器信息-编辑") | ||||
|     @ApiOperation(value = "服务器信息-编辑", notes = "服务器信息-编辑") | ||||
|     @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST}) | ||||
|     public Result<?> edit(@RequestBody ServerInfo serverInfo) { | ||||
|         exists(serverInfo, ServerInfo::getId, ServerInfo::getIp); | ||||
|         serverInfoService.updateById(serverInfo); | ||||
|         return Result.OK("编辑成功!"); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 通过id删除 | ||||
|      * | ||||
|      * @param id | ||||
|      * @return | ||||
|      */ | ||||
|     @AutoLog(value = "服务器信息-通过id删除") | ||||
|     @ApiOperation(value = "服务器信息-通过id删除", notes = "服务器信息-通过id删除") | ||||
|     @DeleteMapping(value = "/delete") | ||||
|     public Result<?> delete(@RequestParam(name = "id", required = true) String id) { | ||||
|         serverInfoService.removeById(id); | ||||
|         return Result.OK("删除成功!"); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 批量删除 | ||||
|      * | ||||
|      * @param ids | ||||
|      * @return | ||||
|      */ | ||||
|     @AutoLog(value = "服务器信息-批量删除") | ||||
|     @ApiOperation(value = "服务器信息-批量删除", notes = "服务器信息-批量删除") | ||||
|     @DeleteMapping(value = "/deleteBatch") | ||||
|     public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) { | ||||
|         this.serverInfoService.removeByIds(Arrays.asList(ids.split(","))); | ||||
|         return Result.OK("批量删除成功!"); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 通过id查询 | ||||
|      * | ||||
|      * @param id | ||||
|      * @return | ||||
|      */ | ||||
|     @AutoLog(value = "服务器信息-通过id查询") | ||||
|     @ApiOperation(value = "服务器信息-通过id查询", notes = "服务器信息-通过id查询") | ||||
|     @GetMapping(value = "/queryById") | ||||
|     public Result<?> queryById(@RequestParam(name = "id", required = true) String id) { | ||||
|         ServerInfo serverInfo = serverInfoService.getById(id); | ||||
|         return Result.OK(serverInfo); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 导出excel | ||||
|      * | ||||
|      * @param request | ||||
|      * @param serverInfo | ||||
|      */ | ||||
|     @RequestMapping(value = "/exportXls") | ||||
|     public ModelAndView exportXls(HttpServletRequest request, ServerInfo serverInfo) { | ||||
|         return super.exportXls(request, serverInfo, ServerInfo.class, "服务器信息"); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 通过excel导入数据 | ||||
|      * | ||||
|      * @param request | ||||
|      * @param response | ||||
|      * @return | ||||
|      */ | ||||
|     @RequestMapping(value = "/importExcel", method = RequestMethod.POST) | ||||
|     public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { | ||||
|         return super.importExcel(request, response, ServerInfo.class); | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,88 @@@@ -0,0 +1,88 @@ | ||||
| package cc.niushuai.bastionserver.modules.server.entity; | ||||
| 
 | ||||
| import cc.niushuai.bastionserver.common.base.entity.BaseEntity; | ||||
| import com.baomidou.mybatisplus.annotation.IdType; | ||||
| import com.baomidou.mybatisplus.annotation.TableId; | ||||
| import com.baomidou.mybatisplus.annotation.TableLogic; | ||||
| import com.baomidou.mybatisplus.annotation.TableName; | ||||
| import com.fasterxml.jackson.annotation.JsonFormat; | ||||
| import io.swagger.annotations.ApiModel; | ||||
| import io.swagger.annotations.ApiModelProperty; | ||||
| import lombok.Data; | ||||
| import lombok.EqualsAndHashCode; | ||||
| import lombok.experimental.Accessors; | ||||
| import org.jeecgframework.poi.excel.annotation.Excel; | ||||
| import org.springframework.format.annotation.DateTimeFormat; | ||||
| 
 | ||||
| import java.util.Date; | ||||
| 
 | ||||
| /** | ||||
|  * 服务器信息 | ||||
|  * | ||||
|  * @author: niushuai233 | ||||
|  * @date: 2023-01-03 16:20:46 | ||||
|  */ | ||||
| @Data | ||||
| @TableName("bas_server_info") | ||||
| @EqualsAndHashCode(callSuper = false) | ||||
| @Accessors(chain = true) | ||||
| @ApiModel(value = "bas_server_info对象", description = "服务器信息") | ||||
| public class ServerInfo extends BaseEntity { | ||||
| 
 | ||||
|     /** | ||||
|      * 企业id | ||||
|      */ | ||||
|     @Excel(name = "企业id", width = 15) | ||||
|     @ApiModelProperty(value = "企业id") | ||||
|     private String tenantId; | ||||
|     /** | ||||
|      * 服务器名称 | ||||
|      */ | ||||
|     @Excel(name = "服务器名称", width = 15) | ||||
|     @ApiModelProperty(value = "服务器名称") | ||||
|     private String name; | ||||
|     /** | ||||
|      * ip或域名 | ||||
|      */ | ||||
|     @Excel(name = "ip或域名", width = 15) | ||||
|     @ApiModelProperty(value = "ip或域名") | ||||
|     private String ip; | ||||
|     /** | ||||
|      * ssh端口号 1-65535 | ||||
|      */ | ||||
|     @Excel(name = "ssh端口号 1-65535", width = 15) | ||||
|     @ApiModelProperty(value = "ssh端口号 1-65535") | ||||
|     private Integer port; | ||||
|     /** | ||||
|      * 用户名 加密 | ||||
|      */ | ||||
|     @Excel(name = "用户名 加密", width = 15) | ||||
|     @ApiModelProperty(value = "用户名 加密") | ||||
|     private String user; | ||||
|     /** | ||||
|      * 密码 加密 | ||||
|      */ | ||||
|     @Excel(name = "密码 加密", width = 15) | ||||
|     @ApiModelProperty(value = "密码 加密") | ||||
|     private String password; | ||||
|     /** | ||||
|      * 备注 | ||||
|      */ | ||||
|     @Excel(name = "备注", width = 15) | ||||
|     @ApiModelProperty(value = "备注") | ||||
|     private String remark; | ||||
| 
 | ||||
|     /** | ||||
|      * 状态 0禁用 1启用 | ||||
|      */ | ||||
|     @Excel(name = "状态", width = 15) | ||||
|     @ApiModelProperty(value = "状态") | ||||
|     private Integer status; | ||||
| 
 | ||||
|     /** | ||||
|      * 是否删除 0否 1是 默认否 | ||||
|      */ | ||||
|     @ApiModelProperty(value = "是否删除 0否 1是 默认否") | ||||
|     @TableLogic | ||||
|     private Integer deleted; | ||||
| } | ||||
| @ -0,0 +1,14 @@@@ -0,0 +1,14 @@ | ||||
| package cc.niushuai.bastionserver.modules.server.mapper; | ||||
| 
 | ||||
| import cc.niushuai.bastionserver.modules.server.entity.ServerInfo; | ||||
| import com.baomidou.mybatisplus.core.mapper.BaseMapper; | ||||
| 
 | ||||
| /** | ||||
|  * 服务器信息 | ||||
|  * | ||||
|  * @author: niushuai233 | ||||
|  * @date: 2023-01-03 16:20:46 | ||||
|  */ | ||||
| public interface ServerInfoMapper extends BaseMapper<ServerInfo> { | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,5 @@@@ -0,0 +1,5 @@ | ||||
| <?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="cc.niushuai.bastionserver.modules.server.mapper.ServerInfoMapper"> | ||||
| 
 | ||||
| </mapper> | ||||
| @ -0,0 +1,14 @@@@ -0,0 +1,14 @@ | ||||
| package cc.niushuai.bastionserver.modules.server.service; | ||||
| 
 | ||||
| import cc.niushuai.bastionserver.common.base.service.BaseService; | ||||
| import cc.niushuai.bastionserver.modules.server.entity.ServerInfo; | ||||
| 
 | ||||
| /** | ||||
|  * 服务器信息 | ||||
|  * | ||||
|  * @author: niushuai233 | ||||
|  * @date: 2023-01-03 16:20:46 | ||||
|  */ | ||||
| public interface ServerInfoService extends BaseService<ServerInfo> { | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,20 @@@@ -0,0 +1,20 @@ | ||||
| package cc.niushuai.bastionserver.modules.server.service.impl; | ||||
| 
 | ||||
| import cc.niushuai.bastionserver.common.base.service.impl.BaseServiceImpl; | ||||
| import cc.niushuai.bastionserver.modules.server.entity.ServerInfo; | ||||
| import cc.niushuai.bastionserver.modules.server.mapper.ServerInfoMapper; | ||||
| import cc.niushuai.bastionserver.modules.server.service.ServerInfoService; | ||||
| import org.springframework.stereotype.Service; | ||||
| import org.springframework.transaction.annotation.Transactional; | ||||
| 
 | ||||
| /** | ||||
|  * 服务器信息 | ||||
|  * | ||||
|  * @author: niushuai233 | ||||
|  * @date: 2023-01-03 16:20:46 | ||||
|  */ | ||||
| @Service | ||||
| @Transactional(rollbackFor = Exception.class) | ||||
| public class ServerInfoServiceImpl extends BaseServiceImpl<ServerInfoMapper, ServerInfo> implements ServerInfoService { | ||||
| 
 | ||||
| } | ||||
					Loading…
					
					
				
		Reference in new issue