From a5c951fbd8100b3a7a1b521fde2bd45a7701eb5a Mon Sep 17 00:00:00 2001 From: wenchaogong Date: Tue, 7 Sep 2021 08:13:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0ISC(=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E7=AE=A1=E6=8E=A7=E6=A8=A1=E5=9D=97)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 10 +- ruoyi-admin/pom.xml | 6 + .../ruoyi/common/constant/IscConstants.java | 11 + .../com/ruoyi/common/utils/FullPathUtils.java | 87 ++++ ruoyi-isc/pom.xml | 21 + .../controller/IscServiceCateController.java | 140 ++++++ .../isc/controller/IscServiceController.java | 112 +++++ .../java/com/ruoyi/isc/domain/IscService.java | 132 ++++++ .../com/ruoyi/isc/domain/IscServiceCate.java | 101 ++++ .../com/ruoyi/isc/domain/bo/IscServiceBo.java | 132 ++++++ .../ruoyi/isc/domain/bo/IscServiceCateBo.java | 71 +++ .../ruoyi/isc/domain/vo/IscServiceCateVo.java | 84 ++++ .../com/ruoyi/isc/domain/vo/IscServiceVo.java | 139 ++++++ .../isc/mapper/IscServiceCateMapper.java | 16 + .../ruoyi/isc/mapper/IscServiceMapper.java | 16 + .../isc/service/IIscServiceCateService.java | 67 +++ .../ruoyi/isc/service/IIscServiceService.java | 56 +++ .../impl/IscServiceCateServiceImpl.java | 158 +++++++ .../service/impl/IscServiceServiceImpl.java | 127 +++++ .../mapper/isc/IscServiceCateMapper.xml | 22 + .../resources/mapper/isc/IscServiceMapper.xml | 31 ++ ruoyi-ui/src/api/isc/cate.js | 52 ++ ruoyi-ui/src/api/isc/service.js | 44 ++ ruoyi-ui/src/views/isc/cate/index.vue | 314 ++++++++++++ ruoyi-ui/src/views/isc/service/index.vue | 446 ++++++++++++++++++ sql/isc.sql | 217 +++++++++ 26 files changed, 2611 insertions(+), 1 deletion(-) create mode 100644 ruoyi-common/src/main/java/com/ruoyi/common/constant/IscConstants.java create mode 100644 ruoyi-common/src/main/java/com/ruoyi/common/utils/FullPathUtils.java create mode 100644 ruoyi-isc/pom.xml create mode 100644 ruoyi-isc/src/main/java/com/ruoyi/isc/controller/IscServiceCateController.java create mode 100644 ruoyi-isc/src/main/java/com/ruoyi/isc/controller/IscServiceController.java create mode 100644 ruoyi-isc/src/main/java/com/ruoyi/isc/domain/IscService.java create mode 100644 ruoyi-isc/src/main/java/com/ruoyi/isc/domain/IscServiceCate.java create mode 100644 ruoyi-isc/src/main/java/com/ruoyi/isc/domain/bo/IscServiceBo.java create mode 100644 ruoyi-isc/src/main/java/com/ruoyi/isc/domain/bo/IscServiceCateBo.java create mode 100644 ruoyi-isc/src/main/java/com/ruoyi/isc/domain/vo/IscServiceCateVo.java create mode 100644 ruoyi-isc/src/main/java/com/ruoyi/isc/domain/vo/IscServiceVo.java create mode 100644 ruoyi-isc/src/main/java/com/ruoyi/isc/mapper/IscServiceCateMapper.java create mode 100644 ruoyi-isc/src/main/java/com/ruoyi/isc/mapper/IscServiceMapper.java create mode 100644 ruoyi-isc/src/main/java/com/ruoyi/isc/service/IIscServiceCateService.java create mode 100644 ruoyi-isc/src/main/java/com/ruoyi/isc/service/IIscServiceService.java create mode 100644 ruoyi-isc/src/main/java/com/ruoyi/isc/service/impl/IscServiceCateServiceImpl.java create mode 100644 ruoyi-isc/src/main/java/com/ruoyi/isc/service/impl/IscServiceServiceImpl.java create mode 100644 ruoyi-isc/src/main/resources/mapper/isc/IscServiceCateMapper.xml create mode 100644 ruoyi-isc/src/main/resources/mapper/isc/IscServiceMapper.xml create mode 100644 ruoyi-ui/src/api/isc/cate.js create mode 100644 ruoyi-ui/src/api/isc/service.js create mode 100644 ruoyi-ui/src/views/isc/cate/index.vue create mode 100644 ruoyi-ui/src/views/isc/service/index.vue create mode 100644 sql/isc.sql diff --git a/pom.xml b/pom.xml index a34db942c..7dcbfcc50 100644 --- a/pom.xml +++ b/pom.xml @@ -261,13 +261,20 @@ ${ruoyi-vue-plus.version} - + com.ruoyi ruoyi-oss ${ruoyi-vue-plus.version} + + + com.ruoyi + ruoyi-isc + ${ruoyi-vue-plus.version} + + com.ruoyi @@ -288,6 +295,7 @@ ruoyi-demo ruoyi-extend ruoyi-oss + ruoyi-isc pom diff --git a/ruoyi-admin/pom.xml b/ruoyi-admin/pom.xml index 4b2807305..79196245e 100644 --- a/ruoyi-admin/pom.xml +++ b/ruoyi-admin/pom.xml @@ -54,6 +54,12 @@ ruoyi-generator + + + com.ruoyi + ruoyi-isc + + com.ruoyi diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/constant/IscConstants.java b/ruoyi-common/src/main/java/com/ruoyi/common/constant/IscConstants.java new file mode 100644 index 000000000..6a15e6334 --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/constant/IscConstants.java @@ -0,0 +1,11 @@ +package com.ruoyi.common.constant; + +public class IscConstants { + + /** 待审核 */ + public static final String AUDIT_WAIT = "0"; + + /** 待审核 */ + public static final String ONLINE_STATUS_ON = "1"; + +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/FullPathUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/FullPathUtils.java new file mode 100644 index 000000000..861ecf311 --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/FullPathUtils.java @@ -0,0 +1,87 @@ +package com.ruoyi.common.utils; + +public final class FullPathUtils { + + public static final int FULL_PATH_LENGTH = 30; + public static final int FULL_PATH_LEVEL_LENGTH = 3; + public static final char REPEAT_CHAR = '0'; + public static final char REPEAT_CHAR_MAX = '9'; + + /** + * 生成 FULL_PATH + * + * @param parentFullPath 父级full_path (可空) + * @param maxFullPath 同级最大 full_path(可空) + * @return + */ + public static String genFullPath(String parentFullPath, String maxFullPath) + { + int maxNum = 0; + String parentPath = StringUtils.EMPTY; + if (StringUtils.isNotBlank(maxFullPath)) + { + int start = maxFullPath.length() - FULL_PATH_LEVEL_LENGTH; + int end = maxFullPath.length() - 1; + int temp = 0; + while (start > -1) + { + temp = Integer.parseInt(maxFullPath.substring(start, end)); + if (temp > 0) + { + parentPath = maxFullPath.substring(0, start); + break; + } + end = start; + start -= FULL_PATH_LEVEL_LENGTH; + } + maxNum = temp; + } else if (StringUtils.isNotBlank(parentFullPath)) + { + parentPath = getParentPath(parentFullPath); + } + int repeat = FULL_PATH_LENGTH - parentPath.length() - FULL_PATH_LEVEL_LENGTH; + String suffix = StringUtils.repeat(REPEAT_CHAR, repeat); + return String.format("%s%03d%s", parentPath, ++maxNum, suffix); + } + + /** + * 根据FULL_PATH 获取最大 子FULL_PATH + * + * @param fullPath + */ + public static String genMaxFullPath(String fullPath) + { + String parentPath = StringUtils.EMPTY; + if (StringUtils.isNotBlank(fullPath)) + { + parentPath = getParentPath(fullPath); + } + int repeat = FULL_PATH_LENGTH - parentPath.length(); + String suffix = StringUtils.repeat(REPEAT_CHAR_MAX, repeat); + return parentPath + suffix; + } + + /** + * 获取父 Path + * + * @param fullPath + * @return + */ + private static String getParentPath(String fullPath) + { + int temp; + int start = fullPath.length() - FULL_PATH_LEVEL_LENGTH; + int end = fullPath.length() - 1; + while (start > -1) + { + temp = Integer.parseInt(fullPath.substring(start, end)); + if (temp > 0) + { + return fullPath.substring(0, end); + } + end = start; + start -= FULL_PATH_LEVEL_LENGTH; + } + return StringUtils.EMPTY; + } +} diff --git a/ruoyi-isc/pom.xml b/ruoyi-isc/pom.xml new file mode 100644 index 000000000..10478d172 --- /dev/null +++ b/ruoyi-isc/pom.xml @@ -0,0 +1,21 @@ + + + + ruoyi-vue-plus + com.ruoyi + 3.0.0 + + 4.0.0 + + ruoyi-isc + + + + com.ruoyi + ruoyi-system + + + + \ No newline at end of file diff --git a/ruoyi-isc/src/main/java/com/ruoyi/isc/controller/IscServiceCateController.java b/ruoyi-isc/src/main/java/com/ruoyi/isc/controller/IscServiceCateController.java new file mode 100644 index 000000000..ef4c9d224 --- /dev/null +++ b/ruoyi-isc/src/main/java/com/ruoyi/isc/controller/IscServiceCateController.java @@ -0,0 +1,140 @@ +package com.ruoyi.isc.controller; + +import java.util.List; +import java.util.Arrays; +import java.util.concurrent.TimeUnit; + +import cn.hutool.core.lang.tree.Tree; +import cn.hutool.core.lang.tree.TreeUtil; +import cn.hutool.core.lang.tree.parser.NodeParser; +import com.ruoyi.common.core.domain.entity.SysMenu; +import com.ruoyi.common.utils.TreeUtils; +import com.ruoyi.isc.domain.IscServiceCate; +import lombok.RequiredArgsConstructor; + +import javax.servlet.http.HttpServletResponse; +import javax.validation.constraints.*; + +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import org.springframework.validation.annotation.Validated; +import com.ruoyi.common.annotation.RepeatSubmit; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.validate.AddGroup; +import com.ruoyi.common.core.validate.EditGroup; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.isc.domain.vo.IscServiceCateVo; +import com.ruoyi.isc.domain.bo.IscServiceCateBo; +import com.ruoyi.isc.service.IIscServiceCateService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; + +/** + * 服务分类Controller + * + * @author wenchao gong + * @date 2021-08-22 + */ +@Validated +@Api(value = "服务分类控制器", tags = {"服务分类管理"}) +@RequiredArgsConstructor(onConstructor_ = @Autowired) +@RestController +@RequestMapping("/isc/cate") +public class IscServiceCateController extends BaseController { + + private final IIscServiceCateService cateService; + + /** + * 查询服务分类列表 + */ + @ApiOperation("查询服务分类列表") + @PreAuthorize("@ss.hasPermi('isc:cate:list')") + @GetMapping("/list") + public AjaxResult> list(@Validated IscServiceCateBo bo) + { + List list = cateService.queryList(bo); + return AjaxResult.success(list); + } + + /** + * 获取分类下拉树列表 + */ + @GetMapping("/treeselect") + public AjaxResult treeselect() + { + List cates = cateService.selectCateList(); + return AjaxResult.success(TreeUtils.build(cates, (cate, tree) -> { + tree.setId(cate.getCateId()); + tree.setParentId(cate.getParentId()); + tree.setName(cate.getCateName()); + tree.setWeight(cate.getOrderNum()); + tree.putExtra("fullPath", cate.getFullPath()); + })); + } + + /** + * 导出服务分类列表 + */ + @ApiOperation("导出服务分类列表") + @PreAuthorize("@ss.hasPermi('isc:cate:export')") + @Log(title = "服务分类", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public void export(@Validated IscServiceCateBo bo, HttpServletResponse response) + { + List list = cateService.queryList(bo); + ExcelUtil.exportExcel(list, "服务分类", IscServiceCateVo.class, response); + } + + /** + * 获取服务分类详细信息 + */ + @ApiOperation("获取服务分类详细信息") + @PreAuthorize("@ss.hasPermi('isc:cate:query')") + @GetMapping("/{cateId}") + public AjaxResult getInfo(@NotNull(message = "主键不能为空") @PathVariable("cateId") Long cateId) + { + return AjaxResult.success(cateService.queryById(cateId)); + } + + /** + * 新增服务分类 + */ + @ApiOperation("新增服务分类") + @PreAuthorize("@ss.hasPermi('isc:cate:add')") + @Log(title = "服务分类", businessType = BusinessType.INSERT) + @RepeatSubmit() + @PostMapping() + public AjaxResult add(@Validated(AddGroup.class) @RequestBody IscServiceCateBo bo) + { + return toAjax(cateService.insertByBo(bo) ? 1 : 0); + } + + /** + * 修改服务分类 + */ + @ApiOperation("修改服务分类") + @PreAuthorize("@ss.hasPermi('isc:cate:edit')") + @Log(title = "服务分类", businessType = BusinessType.UPDATE) + @RepeatSubmit() + @PutMapping() + public AjaxResult edit(@Validated(EditGroup.class) @RequestBody IscServiceCateBo bo) + { + return toAjax(cateService.updateByBo(bo) ? 1 : 0); + } + + /** + * 删除服务分类 + */ + @ApiOperation("删除服务分类") + @PreAuthorize("@ss.hasPermi('isc:cate:remove')") + @Log(title = "服务分类", businessType = BusinessType.DELETE) + @DeleteMapping("/{cateIds}") + public AjaxResult remove(@NotEmpty(message = "主键不能为空") @PathVariable Long[] cateIds) + { + return toAjax(cateService.deleteWithValidByIds(Arrays.asList(cateIds), true) ? 1 : 0); + } +} diff --git a/ruoyi-isc/src/main/java/com/ruoyi/isc/controller/IscServiceController.java b/ruoyi-isc/src/main/java/com/ruoyi/isc/controller/IscServiceController.java new file mode 100644 index 000000000..2b5ad9fd3 --- /dev/null +++ b/ruoyi-isc/src/main/java/com/ruoyi/isc/controller/IscServiceController.java @@ -0,0 +1,112 @@ +package com.ruoyi.isc.controller; + +import java.util.List; +import java.util.Arrays; +import java.util.concurrent.TimeUnit; + +import lombok.RequiredArgsConstructor; +import javax.servlet.http.HttpServletResponse; +import javax.validation.constraints.*; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import org.springframework.validation.annotation.Validated; +import com.ruoyi.common.annotation.RepeatSubmit; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.validate.AddGroup; +import com.ruoyi.common.core.validate.EditGroup; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.isc.domain.vo.IscServiceVo; +import com.ruoyi.isc.domain.bo.IscServiceBo; +import com.ruoyi.isc.service.IIscServiceService; +import com.ruoyi.common.core.page.TableDataInfo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; + +/** + * 服务信息Controller + * + * @author ruoyi + * @date 2021-08-22 + */ +@Validated +@Api(value = "服务信息控制器", tags = {"服务信息管理"}) +@RequiredArgsConstructor(onConstructor_ = @Autowired) +@RestController +@RequestMapping("/isc/service") +public class IscServiceController extends BaseController { + + private final IIscServiceService iIscServiceService; + + /** + * 查询服务信息列表 + */ + @ApiOperation("查询服务信息列表") + @PreAuthorize("@ss.hasPermi('isc:service:list')") + @GetMapping("/list") + public TableDataInfo list(@Validated IscServiceBo bo) { + return iIscServiceService.queryPageList(bo); + } + + /** + * 导出服务信息列表 + */ + @ApiOperation("导出服务信息列表") + @PreAuthorize("@ss.hasPermi('isc:service:export')") + @Log(title = "服务信息", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public void export(@Validated IscServiceBo bo, HttpServletResponse response) { + List list = iIscServiceService.queryList(bo); + ExcelUtil.exportExcel(list, "服务信息", IscServiceVo.class, response); + } + + /** + * 获取服务信息详细信息 + */ + @ApiOperation("获取服务信息详细信息") + @PreAuthorize("@ss.hasPermi('isc:service:query')") + @GetMapping("/{serviceId}") + public AjaxResult getInfo(@NotNull(message = "主键不能为空") + @PathVariable("serviceId") Long serviceId) { + return AjaxResult.success(iIscServiceService.queryById(serviceId)); + } + + /** + * 新增服务信息 + */ + @ApiOperation("新增服务信息") + @PreAuthorize("@ss.hasPermi('isc:service:add')") + @Log(title = "服务信息", businessType = BusinessType.INSERT) + @RepeatSubmit() + @PostMapping() + public AjaxResult add(@Validated(AddGroup.class) @RequestBody IscServiceBo bo) { + return toAjax(iIscServiceService.insertByBo(bo) ? 1 : 0); + } + + /** + * 修改服务信息 + */ + @ApiOperation("修改服务信息") + @PreAuthorize("@ss.hasPermi('isc:service:edit')") + @Log(title = "服务信息", businessType = BusinessType.UPDATE) + @RepeatSubmit() + @PutMapping() + public AjaxResult edit(@Validated(EditGroup.class) @RequestBody IscServiceBo bo) { + return toAjax(iIscServiceService.updateByBo(bo) ? 1 : 0); + } + + /** + * 删除服务信息 + */ + @ApiOperation("删除服务信息") + @PreAuthorize("@ss.hasPermi('isc:service:remove')") + @Log(title = "服务信息" , businessType = BusinessType.DELETE) + @DeleteMapping("/{serviceIds}") + public AjaxResult remove(@NotEmpty(message = "主键不能为空") + @PathVariable Long[] serviceIds) { + return toAjax(iIscServiceService.deleteWithValidByIds(Arrays.asList(serviceIds), true) ? 1 : 0); + } +} diff --git a/ruoyi-isc/src/main/java/com/ruoyi/isc/domain/IscService.java b/ruoyi-isc/src/main/java/com/ruoyi/isc/domain/IscService.java new file mode 100644 index 000000000..8eb1fd211 --- /dev/null +++ b/ruoyi-isc/src/main/java/com/ruoyi/isc/domain/IscService.java @@ -0,0 +1,132 @@ +package com.ruoyi.isc.domain; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; +import java.io.Serializable; +import java.util.Date; +import java.math.BigDecimal; + +/** + * 服务信息对象 isc_service + * + * @author ruoyi + * @date 2021-08-22 + */ +@Data +@NoArgsConstructor +@Accessors(chain = true) +@TableName("isc_service") +public class IscService implements Serializable { + + private static final long serialVersionUID=1L; + + + /** + * 服务ID + */ + @TableId(value = "service_id") + private Long serviceId; + + /** + * 服务名称 + */ + private String serviceName; + + /** + * 服务地址 + */ + private String serviceAddr; + + /** + * 探活地址 + */ + private String probeActiveAddr; + + /** + * 请求方式(默认GET) + */ + private String requestMethod; + + /** + * 备注 + */ + private String remark; + + /** + * 跨域标志(Y是 N否) + */ + private String corsFlag; + + /** + * 隐藏参数 + */ + private String hiddenParams; + + /** + * 是否在线(0离线 1在线) + */ + private String onlineStatus; + + /** + * 审核状态(0待审核 1审核通过 2驳回) + */ + private String status; + + /** + * JSON文档 + */ + private String apiDoc; + + /** + * 审核意见 + */ + private String auditMind; + + /** + * 服务状态(0启用 1停用) + */ + private String enabled; + + /** + * 服务分类全路径 + */ + private String cateFullPath; + + /** + * 用户ID + */ + private Long userId; + + /** + * 创建者 + */ + @TableField(fill = FieldFill.INSERT) + private String createBy; + + /** + * 创建时间 + */ + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + /** + * 更新者 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + private String updateBy; + + /** + * 更新时间 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + private Date updateTime; + + /** + * 删除标志(0代表存在 2代表删除) + */ + @TableLogic + private String delFlag; + +} diff --git a/ruoyi-isc/src/main/java/com/ruoyi/isc/domain/IscServiceCate.java b/ruoyi-isc/src/main/java/com/ruoyi/isc/domain/IscServiceCate.java new file mode 100644 index 000000000..0abc1fd75 --- /dev/null +++ b/ruoyi-isc/src/main/java/com/ruoyi/isc/domain/IscServiceCate.java @@ -0,0 +1,101 @@ +package com.ruoyi.isc.domain; + +import com.baomidou.mybatisplus.annotation.*; +import com.ruoyi.common.core.domain.entity.SysMenu; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Date; +import java.math.BigDecimal; +import java.util.List; + +/** + * 服务分类对象 isc_service_cate + * + * @author wenchao gong + * @date 2021-08-22 + */ +@Data +@NoArgsConstructor +@Accessors(chain = true) +@TableName("isc_service_cate") +public class IscServiceCate implements Serializable { + + private static final long serialVersionUID=1L; + + + /** + * 分类ID + */ + @TableId(value = "cate_id") + private Long cateId; + + /** + * 父分类ID + */ + private Long parentId; + + /** + * 分类名称 + */ + private String cateName; + + /** + * 搜索全路径 + */ + private String fullPath; + + /** + * 服务状态(0启用 1停用) + */ + private String enabled; + + /** + * 创建者 + */ + @TableField(fill = FieldFill.INSERT) + private String createBy; + + /** + * 显示顺序 + */ + private Long orderNum; + + /** + * 创建时间 + */ + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + /** + * 更新者 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + private String updateBy; + + /** + * 更新时间 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + private Date updateTime; + + /** + * 删除标志(0代表存在 2代表删除) + */ + @TableLogic + private String delFlag; + + /** + * 备注 + */ + private String remark; + + /** + * 子分类 + */ + @TableField(exist = false) + private List children = new ArrayList(); + +} diff --git a/ruoyi-isc/src/main/java/com/ruoyi/isc/domain/bo/IscServiceBo.java b/ruoyi-isc/src/main/java/com/ruoyi/isc/domain/bo/IscServiceBo.java new file mode 100644 index 000000000..8a2aa60b6 --- /dev/null +++ b/ruoyi-isc/src/main/java/com/ruoyi/isc/domain/bo/IscServiceBo.java @@ -0,0 +1,132 @@ +package com.ruoyi.isc.domain.bo; + +import com.ruoyi.common.core.validate.AddGroup; +import com.ruoyi.common.core.validate.EditGroup; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import javax.validation.constraints.*; + +import java.util.Date; + +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 服务信息业务对象 isc_service + * + * @author ruoyi + * @date 2021-08-22 + */ + +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel("服务信息业务对象") +public class IscServiceBo extends BaseEntity { + + /** + * 服务名称 + */ + @ApiModelProperty(value = "服务名称", required = true) + @NotBlank(message = "服务名称不能为空", groups = { AddGroup.class, EditGroup.class }) + private String serviceName; + + /** + * 服务地址 + */ + @ApiModelProperty(value = "服务地址", required = true) + @NotBlank(message = "服务地址不能为空", groups = { AddGroup.class, EditGroup.class }) + private String serviceAddr; + + /** + * 探活地址 + */ + @ApiModelProperty(value = "探活地址", required = true) + @NotBlank(message = "探活地址不能为空", groups = { AddGroup.class, EditGroup.class }) + private String probeActiveAddr; + + /** + * 请求方式(默认GET) + */ + @ApiModelProperty(value = "请求方式(默认GET)", required = true) + @NotBlank(message = "请求方式(默认GET)不能为空", groups = { AddGroup.class, EditGroup.class }) + private String requestMethod; + + /** + * 跨域标志(Y是 N否) + */ + @ApiModelProperty(value = "跨域标志(Y是 N否)", required = true) + @NotBlank(message = "跨域标志(Y是 N否)不能为空", groups = { AddGroup.class, EditGroup.class }) + private String corsFlag; + + /** + * 隐藏参数 + */ + @ApiModelProperty(value = "隐藏参数") + private String hiddenParams; + + /** + * 是否在线(0离线 1在线) + */ + @ApiModelProperty(value = "是否在线(0离线 1在线)") + private String onlineStatus; + + /** + * 审核状态(0待审核 1审核通过 2驳回) + */ + @ApiModelProperty(value = "审核状态(0待审核 1审核通过 2驳回)") + private String status; + + /** + * JSON文档 + */ + @ApiModelProperty(value = "JSON文档", required = true) + @NotBlank(message = "JSON文档不能为空", groups = { AddGroup.class, EditGroup.class }) + private String apiDoc; + + /** + * 服务状态(0启用 1停用) + */ + @ApiModelProperty(value = "服务状态(0启用 1停用)", required = true) + @NotBlank(message = "服务状态(0启用 1停用)不能为空", groups = { AddGroup.class, EditGroup.class }) + private String enabled; + + /** + * 服务分类 + */ + @ApiModelProperty(value = "服务分类", required = true) + @NotNull(message = "服务分类不能为空", groups = { AddGroup.class, EditGroup.class }) + private String cateFullPath; + + /** + * 用户ID + */ + @ApiModelProperty(value = "用户ID", required = true) + private Long userId; + + + /** + * 分页大小 + */ + @ApiModelProperty("分页大小") + private Integer pageSize; + + /** + * 当前页数 + */ + @ApiModelProperty("当前页数") + private Integer pageNum; + + /** + * 排序列 + */ + @ApiModelProperty("排序列") + private String orderByColumn; + + /** + * 排序的方向desc或者asc + */ + @ApiModelProperty(value = "排序的方向", example = "asc,desc") + private String isAsc; + +} diff --git a/ruoyi-isc/src/main/java/com/ruoyi/isc/domain/bo/IscServiceCateBo.java b/ruoyi-isc/src/main/java/com/ruoyi/isc/domain/bo/IscServiceCateBo.java new file mode 100644 index 000000000..5cc7b1df3 --- /dev/null +++ b/ruoyi-isc/src/main/java/com/ruoyi/isc/domain/bo/IscServiceCateBo.java @@ -0,0 +1,71 @@ +package com.ruoyi.isc.domain.bo; + +import com.ruoyi.common.core.validate.AddGroup; +import com.ruoyi.common.core.validate.EditGroup; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import javax.validation.constraints.*; + +import java.util.Date; + +import com.ruoyi.common.core.domain.TreeEntity; + +/** + * 服务分类业务对象 isc_service_cate + * + * @author wenchao gong + * @date 2021-08-22 + */ + +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel("服务分类业务对象") +public class IscServiceCateBo extends TreeEntity { + + /** + * 分类ID + */ + @ApiModelProperty(value = "分类ID") + private Long cateId; + + /** + * 分类名称 + */ + @ApiModelProperty(value = "分类名称") + private String cateName; + + /** + * 服务状态(0启用 1停用) + */ + @ApiModelProperty(value = "服务状态(0启用 1停用)", required = true) + @NotBlank(message = "服务状态(0启用 1停用)不能为空", groups = { AddGroup.class, EditGroup.class }) + private String enabled; + + + /** + * 分页大小 + */ + @ApiModelProperty("分页大小") + private Integer pageSize; + + /** + * 当前页数 + */ + @ApiModelProperty("当前页数") + private Integer pageNum; + + /** + * 排序列 + */ + @ApiModelProperty("排序列") + private String orderByColumn; + + /** + * 排序的方向desc或者asc + */ + @ApiModelProperty(value = "排序的方向", example = "asc,desc") + private String isAsc; + +} diff --git a/ruoyi-isc/src/main/java/com/ruoyi/isc/domain/vo/IscServiceCateVo.java b/ruoyi-isc/src/main/java/com/ruoyi/isc/domain/vo/IscServiceCateVo.java new file mode 100644 index 000000000..78322128b --- /dev/null +++ b/ruoyi-isc/src/main/java/com/ruoyi/isc/domain/vo/IscServiceCateVo.java @@ -0,0 +1,84 @@ +package com.ruoyi.isc.domain.vo; + +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import com.ruoyi.common.annotation.ExcelDictFormat; +import com.ruoyi.common.convert.ExcelDictConvert; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.util.Date; + + + +/** + * 服务分类视图对象 isc_service_cate + * + * @author wenchao gong + * @date 2021-08-22 + */ +@Data +@ApiModel("服务分类视图对象") +@ExcelIgnoreUnannotated +public class IscServiceCateVo { + + private static final long serialVersionUID = 1L; + + /** + * 分类ID + */ + @ApiModelProperty("分类ID") + private Long cateId; + + /** + * 父分类ID + */ + @ExcelProperty(value = "父分类ID") + @ApiModelProperty("父分类ID") + private Long parentId; + + /** + * 分类名称 + */ + @ExcelProperty(value = "分类名称") + @ApiModelProperty("分类名称") + private String cateName; + + /** + * 服务状态(0启用 1停用) + */ + @ExcelProperty(value = "服务状态", converter = ExcelDictConvert.class) + @ExcelDictFormat(dictType = "sys_normal_disable") + @ApiModelProperty("服务状态(0启用 1停用)") + private String enabled; + + /** + * 显示顺序 + */ + @ExcelProperty(value = "显示顺序") + @ApiModelProperty("显示顺序") + private Long orderNum; + + /** + * 更新者 + */ + @ExcelProperty(value = "更新者") + @ApiModelProperty("更新者") + private String updateBy; + + /** + * 更新时间 + */ + @ExcelProperty(value = "更新时间") + @ApiModelProperty("更新时间") + private Date updateTime; + + /** + * 备注 + */ + @ExcelProperty(value = "备注") + @ApiModelProperty("备注") + private String remark; + + +} diff --git a/ruoyi-isc/src/main/java/com/ruoyi/isc/domain/vo/IscServiceVo.java b/ruoyi-isc/src/main/java/com/ruoyi/isc/domain/vo/IscServiceVo.java new file mode 100644 index 000000000..cde19b64b --- /dev/null +++ b/ruoyi-isc/src/main/java/com/ruoyi/isc/domain/vo/IscServiceVo.java @@ -0,0 +1,139 @@ +package com.ruoyi.isc.domain.vo; + +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import com.ruoyi.common.annotation.ExcelDictFormat; +import com.ruoyi.common.convert.ExcelDictConvert; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.util.Date; + + + +/** + * 服务信息视图对象 isc_service + * + * @author ruoyi + * @date 2021-08-22 + */ +@Data +@ApiModel("服务信息视图对象") +@ExcelIgnoreUnannotated +public class IscServiceVo { + + private static final long serialVersionUID = 1L; + + /** + * 服务ID + */ + @ApiModelProperty("服务ID") + private Long serviceId; + + /** + * 服务名称 + */ + @ExcelProperty(value = "服务名称") + @ApiModelProperty("服务名称") + private String serviceName; + + /** + * 服务地址 + */ + @ExcelProperty(value = "服务地址") + @ApiModelProperty("服务地址") + private String serviceAddr; + + /** + * 探活地址 + */ + @ExcelProperty(value = "探活地址") + @ApiModelProperty("探活地址") + private String probeActiveAddr; + + /** + * 请求方式(默认GET) + */ + @ExcelProperty(value = "请求方式") + @ApiModelProperty("请求方式(默认GET)") + private String requestMethod; + + /** + * 备注 + */ + @ApiModelProperty("备注") + private String remark; + + /** + * 跨域标志(Y是 N否) + */ + @ExcelProperty(value = "跨域标志") + @ApiModelProperty("跨域标志(Y是 N否)") + private String corsFlag; + + /** + * 隐藏参数 + */ + @ExcelProperty(value = "隐藏参数") + @ApiModelProperty("隐藏参数") + private String hiddenParams; + + /** + * JSON文档 + */ + @ApiModelProperty("JSON文档") + private String apiDoc; + + /** + * 是否在线(0离线 1在线) + */ + @ExcelProperty(value = "是否在线", converter = ExcelDictConvert.class) + @ExcelDictFormat(dictType = "isc_online_status") + @ApiModelProperty("是否在线(0离线 1在线)") + private String onlineStatus; + + /** + * 审核状态(0待审核 1审核通过 2驳回) + */ + @ExcelProperty(value = "审核状态", converter = ExcelDictConvert.class) + @ExcelDictFormat(dictType = "sys_audit_status") + @ApiModelProperty("审核状态(0待审核 1审核通过 2驳回)") + private String status; + + /** + * 服务状态(0启用 1停用) + */ + @ExcelProperty(value = "服务状态", converter = ExcelDictConvert.class) + @ExcelDictFormat(dictType = "sys_normal_disable") + @ApiModelProperty("服务状态(0启用 1停用)") + private String enabled; + + /** + * 服务分类 + */ + @ApiModelProperty("服务分类") + private String cateFullPath; + + /** + * 服务分类名称 + */ + @ExcelProperty(value = "服务分类名称") + @ApiModelProperty("服务分类名称") + private String cateName; + + /** + * 更新人 + */ + @ExcelProperty(value = "更新人") + @ApiModelProperty("更新人") + private String updateBy; + + /** + * 更新时间 + */ + @ExcelProperty(value = "更新时间") + @ApiModelProperty("更新时间") + private String updateTime; + + +} diff --git a/ruoyi-isc/src/main/java/com/ruoyi/isc/mapper/IscServiceCateMapper.java b/ruoyi-isc/src/main/java/com/ruoyi/isc/mapper/IscServiceCateMapper.java new file mode 100644 index 000000000..7a48fb445 --- /dev/null +++ b/ruoyi-isc/src/main/java/com/ruoyi/isc/mapper/IscServiceCateMapper.java @@ -0,0 +1,16 @@ +package com.ruoyi.isc.mapper; + +import com.ruoyi.isc.domain.IscServiceCate; +import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus; +import com.ruoyi.common.core.mybatisplus.cache.MybatisPlusRedisCache; +import org.apache.ibatis.annotations.CacheNamespace; + +/** + * 服务分类Mapper接口 + * + * @author wenchao gong + * @date 2021-08-22 + */ +public interface IscServiceCateMapper extends BaseMapperPlus { + +} diff --git a/ruoyi-isc/src/main/java/com/ruoyi/isc/mapper/IscServiceMapper.java b/ruoyi-isc/src/main/java/com/ruoyi/isc/mapper/IscServiceMapper.java new file mode 100644 index 000000000..b0bcaac36 --- /dev/null +++ b/ruoyi-isc/src/main/java/com/ruoyi/isc/mapper/IscServiceMapper.java @@ -0,0 +1,16 @@ +package com.ruoyi.isc.mapper; + +import com.ruoyi.isc.domain.IscService; +import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus; +import com.ruoyi.common.core.mybatisplus.cache.MybatisPlusRedisCache; +import org.apache.ibatis.annotations.CacheNamespace; + +/** + * 服务信息Mapper接口 + * + * @author ruoyi + * @date 2021-08-22 + */ +public interface IscServiceMapper extends BaseMapperPlus { + +} diff --git a/ruoyi-isc/src/main/java/com/ruoyi/isc/service/IIscServiceCateService.java b/ruoyi-isc/src/main/java/com/ruoyi/isc/service/IIscServiceCateService.java new file mode 100644 index 000000000..ef594999c --- /dev/null +++ b/ruoyi-isc/src/main/java/com/ruoyi/isc/service/IIscServiceCateService.java @@ -0,0 +1,67 @@ +package com.ruoyi.isc.service; + +import com.ruoyi.common.core.domain.entity.SysMenu; +import com.ruoyi.isc.domain.IscServiceCate; +import com.ruoyi.isc.domain.vo.IscServiceCateVo; +import com.ruoyi.isc.domain.bo.IscServiceCateBo; +import com.ruoyi.common.core.mybatisplus.core.IServicePlus; + +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * 服务分类Service接口 + * + * @author wenchao gong + * @date 2021-08-22 + */ +public interface IIscServiceCateService extends IServicePlus { + /** + * 查询单个 + * @return + */ + IscServiceCateVo queryById(Long cateId); + + + /** + * 查询列表 + */ + List queryList(IscServiceCateBo bo); + + /** + * 根据新增业务对象插入服务分类 + * @param bo 服务分类新增业务对象 + * @return + */ + Boolean insertByBo(IscServiceCateBo bo); + + /** + * 根据编辑业务对象修改服务分类 + * @param bo 服务分类编辑业务对象 + * @return + */ + Boolean updateByBo(IscServiceCateBo bo); + + /** + * 校验并删除数据 + * @param ids 主键集合 + * @param isValid 是否校验,true-删除前校验,false-不校验 + * @return + */ + Boolean deleteWithValidByIds(Collection ids, Boolean isValid); + + /** + * 获取分类信息 + * @return 分类列表 + */ + List selectCateList(); + + /** + * 批量获取分类名称 + * @param fullPathList + * @return + */ + Map batchCateName(Set fullPathList); +} diff --git a/ruoyi-isc/src/main/java/com/ruoyi/isc/service/IIscServiceService.java b/ruoyi-isc/src/main/java/com/ruoyi/isc/service/IIscServiceService.java new file mode 100644 index 000000000..6ce05c419 --- /dev/null +++ b/ruoyi-isc/src/main/java/com/ruoyi/isc/service/IIscServiceService.java @@ -0,0 +1,56 @@ +package com.ruoyi.isc.service; + +import com.ruoyi.isc.domain.IscService; +import com.ruoyi.isc.domain.vo.IscServiceVo; +import com.ruoyi.isc.domain.bo.IscServiceBo; +import com.ruoyi.common.core.mybatisplus.core.IServicePlus; +import com.ruoyi.common.core.page.TableDataInfo; + +import java.util.Collection; +import java.util.List; + +/** + * 服务信息Service接口 + * + * @author ruoyi + * @date 2021-08-22 + */ +public interface IIscServiceService extends IServicePlus { + /** + * 查询单个 + * @return + */ + IscServiceVo queryById(Long serviceId); + + /** + * 查询列表 + */ + TableDataInfo queryPageList(IscServiceBo bo); + + /** + * 查询列表 + */ + List queryList(IscServiceBo bo); + + /** + * 根据新增业务对象插入服务信息 + * @param bo 服务信息新增业务对象 + * @return + */ + Boolean insertByBo(IscServiceBo bo); + + /** + * 根据编辑业务对象修改服务信息 + * @param bo 服务信息编辑业务对象 + * @return + */ + Boolean updateByBo(IscServiceBo bo); + + /** + * 校验并删除数据 + * @param ids 主键集合 + * @param isValid 是否校验,true-删除前校验,false-不校验 + * @return + */ + Boolean deleteWithValidByIds(Collection ids, Boolean isValid); +} diff --git a/ruoyi-isc/src/main/java/com/ruoyi/isc/service/impl/IscServiceCateServiceImpl.java b/ruoyi-isc/src/main/java/com/ruoyi/isc/service/impl/IscServiceCateServiceImpl.java new file mode 100644 index 000000000..06d581d40 --- /dev/null +++ b/ruoyi-isc/src/main/java/com/ruoyi/isc/service/impl/IscServiceCateServiceImpl.java @@ -0,0 +1,158 @@ +package com.ruoyi.isc.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; +import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.utils.FullPathUtils; +import com.ruoyi.common.utils.StringUtils; +import org.springframework.stereotype.Service; +import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.ruoyi.isc.domain.bo.IscServiceCateBo; +import com.ruoyi.isc.domain.vo.IscServiceCateVo; +import com.ruoyi.isc.domain.IscServiceCate; +import com.ruoyi.isc.mapper.IscServiceCateMapper; +import com.ruoyi.isc.service.IIscServiceCateService; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 服务分类Service业务层处理 + * + * @author wenchao gong + * @date 2021-08-22 + */ +@Service +public class IscServiceCateServiceImpl extends ServicePlusImpl implements IIscServiceCateService { + + @Override + public IscServiceCateVo queryById(Long cateId){ + return getVoById(cateId); + } + + + @Override + public List queryList(IscServiceCateBo bo) { + return listVo(buildQueryWrapper(bo)); + } + + private LambdaQueryWrapper buildQueryWrapper(IscServiceCateBo bo) { + Map params = bo.getParams(); + LambdaQueryWrapper lqw = Wrappers.lambdaQuery(); + lqw.like(StringUtils.isNotBlank(bo.getCateName()), IscServiceCate::getCateName, bo.getCateName()); + lqw.eq(StringUtils.isNotBlank(bo.getEnabled()), IscServiceCate::getEnabled, bo.getEnabled()); + return lqw; + } + + @Override + public Boolean insertByBo(IscServiceCateBo bo) { + IscServiceCate add = BeanUtil.toBean(bo, IscServiceCate.class); + validEntityBeforeSave(add); + add.setFullPath(getFullPath(bo.getParentId())); + return save(add); + } + + /** + * 通过父ID生成 FULL_PATH + * @param parentId + * @return + */ + private String getFullPath(Long parentId) + { + final boolean isRoot = parentId == 0L; + IscServiceCate cate = getOne(Wrappers.lambdaQuery() + .select(IscServiceCate::getCateId, IscServiceCate::getFullPath) + .eq(isRoot, IscServiceCate::getParentId, 0L).and(!isRoot, w -> w + .eq(IscServiceCate::getParentId, parentId) + .or() + .eq(IscServiceCate::getCateId, parentId)) + .orderByDesc(IscServiceCate::getFullPath) + .last("LIMIT 1")); + String parentFullPath = null; + String maxFullPath = null; + if(Objects.nonNull(cate)){ + if(cate.getCateId().intValue() == parentId) + { + parentFullPath = cate.getFullPath(); + }else{ + maxFullPath = cate.getFullPath(); + } + } + final String fullPath = FullPathUtils.genFullPath(parentFullPath, maxFullPath); + return fullPath; + } + + @Override + public Boolean updateByBo(IscServiceCateBo bo) { + IscServiceCate update = BeanUtil.toBean(bo, IscServiceCate.class); + validEntityBeforeSave(update); + return updateById(update); + } + + /** + * 保存前的数据校验 + * + * @param entity 实体类数据 + */ + private void validEntityBeforeSave(IscServiceCate entity){ + //TODO 做一些数据校验,如唯一约束 + } + + @Override + public Boolean deleteWithValidByIds(Collection ids, Boolean isValid) { + if(isValid){ + //TODO 做一些业务上的校验,判断是否需要校验 + } + return removeByIds(ids); + } + + @Override + public List selectCateList() + { + return list(Wrappers.lambdaQuery() + .eq(IscServiceCate::getEnabled, UserConstants.DICT_NORMAL) + .orderByAsc(IscServiceCate::getParentId) + .orderByAsc(IscServiceCate::getOrderNum)); + } + + @Override + public Map batchCateName(Set fullPathList) + { + Map results = new HashMap<>(); + if(CollectionUtils.isEmpty(fullPathList)) { + return results; + } + final List list = list(Wrappers.lambdaQuery() + .select(IscServiceCate::getCateId, IscServiceCate::getCateName, IscServiceCate::getFullPath, IscServiceCate::getParentId) + .in(IscServiceCate::getFullPath, fullPathList)); + Map cateNameMap = batchCateName(list); + for (IscServiceCate cate : list) + { + results.put(cate.getFullPath(), cateNameMap.get(cate.getCateId())); + } + return results; + } + + private Map batchCateName(List list) { + Map results = new HashMap<>(); + final Set parentIds = list.stream().filter(m -> m.getParentId() != 0L).map(IscServiceCate::getParentId).collect(Collectors.toSet()); + if(CollectionUtils.isNotEmpty(parentIds)) { + final List parentList = list(Wrappers.lambdaQuery() + .select(IscServiceCate::getCateId, IscServiceCate::getCateName, IscServiceCate::getFullPath, IscServiceCate::getParentId) + .in(IscServiceCate::getCateId, parentIds)); + results.putAll(batchCateName(parentList)); + } + for (IscServiceCate cate : list) + { + final String parentName = results.get(cate.getParentId()); + if(StringUtils.isBlank(parentName)) { + results.put(cate.getCateId(), cate.getCateName()); + }else{ + results.put(cate.getCateId(), String.format("%s/%s", parentName, cate.getCateName())); + } + } + return results; + } +} diff --git a/ruoyi-isc/src/main/java/com/ruoyi/isc/service/impl/IscServiceServiceImpl.java b/ruoyi-isc/src/main/java/com/ruoyi/isc/service/impl/IscServiceServiceImpl.java new file mode 100644 index 000000000..2361eeffd --- /dev/null +++ b/ruoyi-isc/src/main/java/com/ruoyi/isc/service/impl/IscServiceServiceImpl.java @@ -0,0 +1,127 @@ +package com.ruoyi.isc.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.ruoyi.common.constant.IscConstants; +import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; +import com.ruoyi.common.core.page.PagePlus; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.utils.FullPathUtils; +import com.ruoyi.common.utils.PageUtils; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.isc.domain.IscService; +import com.ruoyi.isc.domain.bo.IscServiceBo; +import com.ruoyi.isc.domain.vo.IscServiceVo; +import com.ruoyi.isc.mapper.IscServiceMapper; +import com.ruoyi.isc.service.IIscServiceCateService; +import com.ruoyi.isc.service.IIscServiceService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * 服务信息Service业务层处理 + * + * @author ruoyi + * @date 2021-08-22 + */ +@Service +public class IscServiceServiceImpl extends ServicePlusImpl implements IIscServiceService { + + @Resource + private IIscServiceCateService cateService; + + @Override + public IscServiceVo queryById(Long serviceId) + { + return getVoById(serviceId); + } + + @Override + public TableDataInfo queryPageList(IscServiceBo bo) + { + PagePlus result = pageVo(PageUtils.buildPagePlus(), buildQueryWrapper(bo)); + genVoInfo(result.getRecordsVo()); + return PageUtils.buildDataInfo(result); + } + + @Override + public List queryList(IscServiceBo bo) + { + final List results = listVo(buildQueryWrapper(bo)); + return results; + } + + private void genVoInfo(List results) + { + if (CollectionUtils.isNotEmpty(results)) + { + Map cateNameMap = cateService.batchCateName(results.stream() + .map(IscServiceVo::getCateFullPath).collect(Collectors.toSet())); + for (IscServiceVo result : results) + { + result.setCateName(cateNameMap.get(result.getCateFullPath())); + } + } + } + + private LambdaQueryWrapper buildQueryWrapper(IscServiceBo bo) + { + Map params = bo.getParams(); + LambdaQueryWrapper lqw = Wrappers.lambdaQuery(); + lqw.like(StringUtils.isNotBlank(bo.getServiceName()), IscService::getServiceName, bo.getServiceName()); + lqw.eq(StringUtils.isNotBlank(bo.getOnlineStatus()), IscService::getOnlineStatus, bo.getOnlineStatus()); + lqw.eq(StringUtils.isNotBlank(bo.getStatus()), IscService::getStatus, bo.getStatus()); + lqw.eq(StringUtils.isNotBlank(bo.getEnabled()), IscService::getEnabled, bo.getEnabled()); + lqw.ge(StringUtils.isNotBlank(bo.getCateFullPath()), IscService::getCateFullPath, bo.getCateFullPath()); + lqw.le(StringUtils.isNotBlank(bo.getCateFullPath()), IscService::getCateFullPath, FullPathUtils.genMaxFullPath(bo.getCateFullPath())); + lqw.eq(bo.getUserId() != null, IscService::getUserId, bo.getUserId()); + return lqw; + } + + @Override + public Boolean insertByBo(IscServiceBo bo) + { + IscService add = BeanUtil.toBean(bo, IscService.class); + validEntityBeforeSave(add); + add.setUserId(SecurityUtils.getUserId()); + add.setOnlineStatus(IscConstants.ONLINE_STATUS_ON); + add.setStatus(IscConstants.AUDIT_WAIT); + return save(add); + } + + @Override + public Boolean updateByBo(IscServiceBo bo) + { + IscService update = BeanUtil.toBean(bo, IscService.class); + validEntityBeforeSave(update); + return updateById(update); + } + + /** + * 保存前的数据校验 + * + * @param entity 实体类数据 + */ + private void validEntityBeforeSave(IscService entity) + { + //TODO 做一些数据校验,如唯一约束 + } + + @Override + public Boolean deleteWithValidByIds(Collection ids, Boolean isValid) + { + if (isValid) + { + //TODO 做一些业务上的校验,判断是否需要校验 + } + return removeByIds(ids); + } +} diff --git a/ruoyi-isc/src/main/resources/mapper/isc/IscServiceCateMapper.xml b/ruoyi-isc/src/main/resources/mapper/isc/IscServiceCateMapper.xml new file mode 100644 index 000000000..930f4e20e --- /dev/null +++ b/ruoyi-isc/src/main/resources/mapper/isc/IscServiceCateMapper.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/ruoyi-isc/src/main/resources/mapper/isc/IscServiceMapper.xml b/ruoyi-isc/src/main/resources/mapper/isc/IscServiceMapper.xml new file mode 100644 index 000000000..df021ab28 --- /dev/null +++ b/ruoyi-isc/src/main/resources/mapper/isc/IscServiceMapper.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ruoyi-ui/src/api/isc/cate.js b/ruoyi-ui/src/api/isc/cate.js new file mode 100644 index 000000000..7c503e4d8 --- /dev/null +++ b/ruoyi-ui/src/api/isc/cate.js @@ -0,0 +1,52 @@ +import request from '@/utils/request' + +// 查询服务分类列表 +export function listCate(query) { + return request({ + url: '/isc/cate/list', + method: 'get', + params: query + }) +} + +// 查询服务分类详细 +export function getCate(cateId) { + return request({ + url: '/isc/cate/' + cateId, + method: 'get' + }) +} + +// 新增服务分类 +export function addCate(data) { + return request({ + url: '/isc/cate', + method: 'post', + data: data + }) +} + +// 修改服务分类 +export function updateCate(data) { + return request({ + url: '/isc/cate', + method: 'put', + data: data + }) +} + +// 删除服务分类 +export function delCate(cateId) { + return request({ + url: '/isc/cate/' + cateId, + method: 'delete' + }) +} + +// 查询服务分类下拉树结构 +export function treeselect() { + return request({ + url: '/isc/cate/treeselect', + method: 'get' + }) +} diff --git a/ruoyi-ui/src/api/isc/service.js b/ruoyi-ui/src/api/isc/service.js new file mode 100644 index 000000000..e181459bc --- /dev/null +++ b/ruoyi-ui/src/api/isc/service.js @@ -0,0 +1,44 @@ +import request from '@/utils/request' + +// 查询服务信息列表 +export function listService(query) { + return request({ + url: '/isc/service/list', + method: 'get', + params: query + }) +} + +// 查询服务信息详细 +export function getService(serviceId) { + return request({ + url: '/isc/service/' + serviceId, + method: 'get' + }) +} + +// 新增服务信息 +export function addService(data) { + return request({ + url: '/isc/service', + method: 'post', + data: data + }) +} + +// 修改服务信息 +export function updateService(data) { + return request({ + url: '/isc/service', + method: 'put', + data: data + }) +} + +// 删除服务信息 +export function delService(serviceId) { + return request({ + url: '/isc/service/' + serviceId, + method: 'delete' + }) +} diff --git a/ruoyi-ui/src/views/isc/cate/index.vue b/ruoyi-ui/src/views/isc/cate/index.vue new file mode 100644 index 000000000..451ee6d75 --- /dev/null +++ b/ruoyi-ui/src/views/isc/cate/index.vue @@ -0,0 +1,314 @@ + + + diff --git a/ruoyi-ui/src/views/isc/service/index.vue b/ruoyi-ui/src/views/isc/service/index.vue new file mode 100644 index 000000000..d3647593d --- /dev/null +++ b/ruoyi-ui/src/views/isc/service/index.vue @@ -0,0 +1,446 @@ + + + diff --git a/sql/isc.sql b/sql/isc.sql new file mode 100644 index 000000000..675151f5b --- /dev/null +++ b/sql/isc.sql @@ -0,0 +1,217 @@ +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for isc_app_service +-- ---------------------------- +DROP TABLE IF EXISTS `isc_app_service`; +CREATE TABLE `isc_app_service` ( + `service_app_id` bigint NOT NULL AUTO_INCREMENT COMMENT '应用服务ID', + `service_id` bigint NULL DEFAULT NULL COMMENT '服务ID', + `application_id` bigint NULL DEFAULT NULL COMMENT '应用ID', + `user_id` bigint NULL DEFAULT NULL COMMENT '用户ID', + `enabled` char(1) NOT NULL COMMENT '启用状态(0启用 1停用)', + `apply_type` char(1) DEFAULT NULL COMMENT '申请类型(0申请 1续期)', + `status` char(1) DEFAULT NULL COMMENT '审核状态(0待审核 1审核通过 2驳回)', + `virtual_addr` varchar(255) DEFAULT NULL COMMENT '虚拟地址', + `end_time` datetime(0) NULL DEFAULT NULL COMMENT '到期时间', + `quota_days` int NULL DEFAULT NULL COMMENT '天配额', + `quota_hours` int NULL DEFAULT NULL COMMENT '小时配额', + `quota_minutes` int NULL DEFAULT NULL COMMENT '分钟配额', + `quota_seconds` int NULL DEFAULT NULL COMMENT '秒配额', + `create_by` varchar(64) DEFAULT '' COMMENT '创建者', + `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间', + `update_by` varchar(64) DEFAULT '' COMMENT '更新者', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间', + `del_flag` char(1) DEFAULT '0' COMMENT '删除标志(0代表存在 2代表删除)', + PRIMARY KEY (`service_app_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 1 COMMENT = '应用服务信息'; + +-- ---------------------------- +-- Records of isc_app_service +-- ---------------------------- +BEGIN; +COMMIT; + +-- ---------------------------- +-- Table structure for isc_app_service_apply +-- ---------------------------- +DROP TABLE IF EXISTS `isc_app_service_apply`; +CREATE TABLE `isc_app_service_apply` ( + `apply_id` bigint NOT NULL AUTO_INCREMENT COMMENT '申请ID', + `service_app_id` bigint NOT NULL COMMENT '应用服务ID', + `apply_type` char(1) DEFAULT NULL COMMENT '申请类型(0申请 1续期)', + `status` char(1) DEFAULT NULL COMMENT '审核状态(0待审核 1审核通过 2驳回)', + `audit_mind` varchar(255) DEFAULT NULL COMMENT '审核意见', + `renewal_duration` int NULL DEFAULT NULL COMMENT '续期时长(单位月)', + `quota_days` int NULL DEFAULT NULL COMMENT '天配额', + `quota_hours` int NULL DEFAULT NULL COMMENT '小时配额', + `quota_minutes` int NULL DEFAULT NULL COMMENT '分钟配额', + `quota_seconds` int NULL DEFAULT NULL COMMENT '秒配额', + `create_by` varchar(64) DEFAULT '' COMMENT '创建者', + `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间', + `update_by` varchar(64) DEFAULT '' COMMENT '更新者', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间', + `del_flag` char(1) DEFAULT '0' COMMENT '删除标志(0代表存在 2代表删除)', + `remark` varchar(500) DEFAULT NULL COMMENT '备注', + PRIMARY KEY (`apply_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 1 COMMENT = '应用服务申请信息'; + +-- ---------------------------- +-- Records of isc_app_service_apply +-- ---------------------------- +BEGIN; +COMMIT; + +-- ---------------------------- +-- Table structure for isc_application +-- ---------------------------- +DROP TABLE IF EXISTS `isc_application`; +CREATE TABLE `isc_application` ( + `application_id` bigint NOT NULL AUTO_INCREMENT COMMENT '应用ID', + `application_name` varchar(255) NOT NULL COMMENT '应用名称', + `access_key` varchar(32) NOT NULL COMMENT '应用密钥', + `user_id` bigint NOT NULL COMMENT '用户ID', + `create_by` varchar(64) DEFAULT '' COMMENT '创建者', + `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间', + `update_by` varchar(64) DEFAULT '' COMMENT '更新者', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间', + `del_flag` char(1) DEFAULT '0' COMMENT '删除标志(0代表存在 2代表删除)', + `remark` varchar(500) DEFAULT NULL COMMENT '备注', + PRIMARY KEY (`application_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 1 COMMENT = '应用信息'; + +-- ---------------------------- +-- Records of isc_application +-- ---------------------------- +BEGIN; +COMMIT; + +-- ---------------------------- +-- Table structure for isc_service +-- ---------------------------- +DROP TABLE IF EXISTS `isc_service`; +CREATE TABLE `isc_service` ( + `service_id` bigint NOT NULL AUTO_INCREMENT COMMENT '服务ID', + `service_name` varchar(255) NOT NULL COMMENT '服务名称', + `service_addr` varchar(255) NOT NULL COMMENT '服务地址', + `probe_active_addr` varchar(255) DEFAULT NULL COMMENT '探活地址', + `request_method` varchar(10) DEFAULT NULL COMMENT '请求方式(默认GET)', + `remark` varchar(500) DEFAULT NULL COMMENT '备注', + `cors_flag` char(1) DEFAULT NULL COMMENT '跨域标志(Y是 N否)', + `hidden_params` varchar(500) DEFAULT NULL COMMENT '隐藏参数', + `api_doc` text COMMENT 'JSON文档', + `online_status` char(1) DEFAULT NULL COMMENT '是否在线(0离线 1在线)', + `status` char(1) DEFAULT NULL COMMENT '审核状态(0待审核 1审核通过 2驳回)', + `audit_mind` varchar(255) DEFAULT NULL COMMENT '审核意见', + `enabled` char(1) NOT NULL COMMENT '服务状态(0启用 1停用)', + `cate_full_path` varchar(30) DEFAULT NULL COMMENT '服务分类全路径', + `user_id` bigint NOT NULL COMMENT '用户ID', + `create_by` varchar(64) DEFAULT '' COMMENT '创建者', + `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间', + `update_by` varchar(64) DEFAULT '' COMMENT '更新者', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间', + `del_flag` char(1) DEFAULT '0' COMMENT '删除标志(0代表存在 2代表删除)', + PRIMARY KEY (`service_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 1 COMMENT = '服务信息'; + +-- ---------------------------- +-- Records of isc_service +-- ---------------------------- +BEGIN; +INSERT INTO `isc_service` VALUES (1, '测试', 'https://www.baidu.com/', 'https://www.baidu.com/', 'GET', NULL, 'Y', NULL, '{}', '1', '0', NULL, '0', '001000000000000000000000000000', 1, 'admin', '2021-09-05 22:47:41', 'admin', '2021-09-05 22:47:41', '0'); +COMMIT; + +-- ---------------------------- +-- Table structure for isc_service_cate +-- ---------------------------- +DROP TABLE IF EXISTS `isc_service_cate`; +CREATE TABLE `isc_service_cate` ( + `cate_id` bigint NOT NULL AUTO_INCREMENT COMMENT '分类ID', + `parent_id` bigint NULL DEFAULT NULL COMMENT '父分类ID', + `cate_name` varchar(64) DEFAULT NULL COMMENT '分类名称', + `full_path` varchar(30) DEFAULT NULL COMMENT '搜索全路径', + `enabled` char(1) NOT NULL COMMENT '服务状态(0启用 1停用)', + `order_num` int NULL DEFAULT 0 COMMENT '显示顺序', + `create_by` varchar(64) DEFAULT '' COMMENT '创建者', + `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间', + `update_by` varchar(64) DEFAULT '' COMMENT '更新者', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间', + `del_flag` char(1) DEFAULT '0' COMMENT '删除标志(0代表存在 2代表删除)', + `remark` varchar(500) DEFAULT NULL COMMENT '备注', + PRIMARY KEY (`cate_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 4 COMMENT = '服务分类'; + +-- ---------------------------- +-- Records of isc_service_cate +-- ---------------------------- +BEGIN; +INSERT INTO `isc_service_cate` VALUES (10, 0, 'API服务', '001000000000000000000000000000', '0', 10, 'admin', '2021-09-04 23:35:13', 'admin', '2021-09-04 23:35:13', '0', NULL), (11, 0, '地图服务', '002000000000000000000000000000', '0', 20, 'admin', '2021-09-04 23:35:37', 'admin', '2021-09-04 23:35:37', '0', NULL), (12, 0, '数据服务', '003000000000000000000000000000', '0', 30, 'admin', '2021-09-04 23:36:01', 'admin', '2021-09-04 23:36:01', '0', NULL), (13, 11, 'WFS服务', '002001000000000000000000000000', '0', 10, 'admin', '2021-09-04 23:36:26', 'admin', '2021-09-04 23:36:26', '0', NULL); +COMMIT; + +-- ---------------------------- +-- Table structure for isc_service_log_count +-- ---------------------------- +DROP TABLE IF EXISTS `isc_service_log_count`; +CREATE TABLE `isc_service_log_count` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '唯一标识', + `service_id` bigint NOT NULL COMMENT '服务ID', + `count_date` date NOT NULL COMMENT '统计日期', + `total_num` bigint NOT NULL COMMENT '调用次数', + `avg_time` bigint NULL DEFAULT NULL COMMENT '平均响应时间', + `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 1 COMMENT = '服务每日统计'; + +-- ---------------------------- +-- Records of isc_service_log_count +-- ---------------------------- +BEGIN; +COMMIT; + +-- ---------------------------- +-- Table structure for isc_service_log_detail +-- ---------------------------- +DROP TABLE IF EXISTS `isc_service_log_detail`; +CREATE TABLE `isc_service_log_detail` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '日志ID', + `service_id` bigint NOT NULL COMMENT '服务ID', + `application_id` bigint NOT NULL COMMENT '应用ID', + `user_id` bigint NOT NULL COMMENT '用户ID', + `request_ip` varchar(64) DEFAULT NULL COMMENT '调用IP', + `begin_time` timestamp(0) NULL DEFAULT NULL COMMENT '开始时间', + `end_time` timestamp(0) NULL DEFAULT NULL COMMENT '结束时间', + `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间', + `remark` varchar(500) DEFAULT NULL COMMENT '备注信息', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 1 COMMENT = '服务调用日志'; + +-- ---------------------------- +-- Records of isc_service_log_detail +-- ---------------------------- +BEGIN; +COMMIT; + +-- ---------------------------- +-- Table structure for isc_service_log_user_count +-- ---------------------------- +DROP TABLE IF EXISTS `isc_service_log_user_count`; +CREATE TABLE `isc_service_log_user_count` ( + `id` int NOT NULL AUTO_INCREMENT COMMENT '唯一标识', + `service_id` bigint NOT NULL COMMENT '服务ID', + `application_id` bigint NOT NULL COMMENT '应用ID', + `user_id` bigint NOT NULL COMMENT '用户ID', + `count_date` date NULL DEFAULT NULL COMMENT '统计日期', + `total_num` bigint NULL DEFAULT NULL COMMENT '调用次数', + `avg_time` bigint NULL DEFAULT NULL COMMENT '平均响应时间', + `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 1 COMMENT = '服务日志用户统计'; + +-- ---------------------------- +-- Records of isc_service_log_user_count +-- ---------------------------- +BEGIN; +COMMIT; + +SET FOREIGN_KEY_CHECKS = 1;