feat: tool模块基础crud
This commit is contained in:
@@ -10,14 +10,14 @@
|
||||
* 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
|
||||
* 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
|
||||
*/
|
||||
package org.nl.device.controller;
|
||||
package org.nl.modular.device.controller;
|
||||
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.nl.common.pojo.CommonResult;
|
||||
import org.nl.device.service.dto.DeviceInfo;
|
||||
import org.nl.modular.device.service.dto.DeviceInfo;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -25,7 +25,6 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
@Tag(name = "设备模块")
|
||||
@RestController()
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.nl.device.service.dto;
|
||||
package org.nl.modular.device.service.dto;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -10,14 +10,13 @@
|
||||
* 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
|
||||
* 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
|
||||
*/
|
||||
package org.nl.point;
|
||||
package org.nl.modular.point;
|
||||
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.nl.common.pojo.CommonResult;
|
||||
import org.nl.point.dto.PointStatus;
|
||||
import org.nl.modular.point.dto.PointStatus;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.nl.point.dto;
|
||||
package org.nl.modular.point.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
@@ -21,10 +21,10 @@
|
||||
<groupId>org.openjdk.nashorn</groupId>
|
||||
<artifactId>nashorn-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>nl.sdk</groupId>
|
||||
<artifactId>language</artifactId>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>nl.sdk</groupId>-->
|
||||
<!-- <artifactId>language</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- validation -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
@@ -132,5 +132,11 @@
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>easyexcel</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- sa-token-core -->
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-core</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
@@ -1,59 +1,59 @@
|
||||
////
|
||||
//// Source code recreated from a .class file by IntelliJ IDEA
|
||||
//// (powered by FernFlower decompiler)
|
||||
////
|
||||
//package org.nl.common.localStorage.controller;
|
||||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by FernFlower decompiler)
|
||||
//
|
||||
package org.nl.common.localStorage.controller;
|
||||
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.common.localStorage.service.LocalStorageService;
|
||||
import org.nl.common.localStorage.service.entity.LocalStorage;
|
||||
import org.nl.common.pojo.CommonResult;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping({"/api/localStorage"})
|
||||
@SaIgnore
|
||||
public class LocalStorageController {
|
||||
|
||||
@Autowired
|
||||
private LocalStorageService localStorageService;
|
||||
|
||||
@GetMapping
|
||||
public CommonResult<Object> query(@RequestParam String annex) {
|
||||
List<LocalStorage> list = new ArrayList<>();
|
||||
if (StringUtils.isNotEmpty(annex)){
|
||||
String[] split = annex.split(",");
|
||||
list = localStorageService.listByIds(Arrays.asList(split));
|
||||
}
|
||||
return CommonResult.data(list);
|
||||
}
|
||||
@PostMapping({"/upload"})
|
||||
public CommonResult<Object> upload(@RequestParam MultipartFile file) {
|
||||
LocalStorage localStorage = localStorageService.upload(file);
|
||||
return CommonResult.data(localStorage);
|
||||
}
|
||||
@GetMapping({"/download"})
|
||||
public void download(@RequestParam Long storageId , HttpServletResponse response, HttpServletRequest request) throws IOException {
|
||||
this.localStorageService.downloadFile(this.localStorageService.getById(storageId),request, response);
|
||||
}
|
||||
|
||||
|
||||
@DeleteMapping
|
||||
public CommonResult delete(@RequestBody Long[] ids) {
|
||||
localStorageService.removeByIds(Arrays.asList(ids));
|
||||
return CommonResult.ok();
|
||||
}
|
||||
|
||||
}
|
||||
//import cn.dev33.satoken.annotation.SaIgnore;
|
||||
//import jakarta.servlet.http.HttpServletRequest;
|
||||
//import jakarta.servlet.http.HttpServletResponse;
|
||||
//import org.apache.commons.lang3.StringUtils;
|
||||
//import org.nl.common.localStorage.service.LocalStorageService;
|
||||
//import org.nl.common.localStorage.service.entity.LocalStorage;
|
||||
//import org.nl.common.pojo.CommonResult;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.web.bind.annotation.*;
|
||||
//import org.springframework.web.multipart.MultipartFile;
|
||||
//
|
||||
//
|
||||
//import java.io.IOException;
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.Arrays;
|
||||
//import java.util.List;
|
||||
//
|
||||
//@RestController
|
||||
//@RequestMapping({"/api/localStorage"})
|
||||
//@SaIgnore
|
||||
//public class LocalStorageController {
|
||||
//
|
||||
// @Autowired
|
||||
// private LocalStorageService localStorageService;
|
||||
//
|
||||
// @GetMapping
|
||||
// public CommonResult<Object> query(@RequestParam String annex) {
|
||||
// List<LocalStorage> list = new ArrayList<>();
|
||||
// if (StringUtils.isNotEmpty(annex)){
|
||||
// String[] split = annex.split(",");
|
||||
// list = localStorageService.listByIds(Arrays.asList(split));
|
||||
// }
|
||||
// return CommonResult.data(list);
|
||||
// }
|
||||
// @PostMapping({"/upload"})
|
||||
// public CommonResult<Object> upload(@RequestParam MultipartFile file) {
|
||||
// LocalStorage localStorage = localStorageService.upload(file);
|
||||
// return CommonResult.data(localStorage);
|
||||
// }
|
||||
// @GetMapping({"/download"})
|
||||
// public void download(@RequestParam Long storageId , HttpServletResponse response, HttpServletRequest request) throws IOException {
|
||||
// this.localStorageService.downloadFile(this.localStorageService.getById(storageId),request, response);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @DeleteMapping
|
||||
// public CommonResult delete(@RequestBody Long[] ids) {
|
||||
// localStorageService.removeByIds(Arrays.asList(ids));
|
||||
// return CommonResult.ok();
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
24
nl-plugin-tool-api/pom.xml
Normal file
24
nl-plugin-tool-api/pom.xml
Normal file
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.nl</groupId>
|
||||
<artifactId>nl-tool-platform</artifactId>
|
||||
<version>3.0.0</version>
|
||||
</parent>
|
||||
|
||||
<groupId>org.nl.tool.api</groupId>
|
||||
<artifactId>nl-plugin-tool-api</artifactId>
|
||||
<description>工具类的api模块</description>
|
||||
|
||||
<dependencies>
|
||||
<!-- 每个插件接口都要引入common -->
|
||||
<dependency>
|
||||
<groupId>org.nl</groupId>
|
||||
<artifactId>nl-common</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
22
nl-plugin-tool/pom.xml
Normal file
22
nl-plugin-tool/pom.xml
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.nl</groupId>
|
||||
<artifactId>nl-tool-platform</artifactId>
|
||||
<version>3.0.0</version>
|
||||
</parent>
|
||||
|
||||
<groupId>org.nl.tool</groupId>
|
||||
<artifactId>nl-plugin-tool</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.nl.tool.api</groupId>
|
||||
<artifactId>nl-plugin-tool-api</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Copyright [2022] [https://www.xiaonuo.vip]
|
||||
*
|
||||
* Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Snowy源码头部的版权声明。
|
||||
* 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
|
||||
* 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
|
||||
* 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
|
||||
*/
|
||||
package org.nl.tool.mock.modular.mockconfig.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import org.nl.common.annotation.CommonLog;
|
||||
import org.nl.common.pojo.CommonResult;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.nl.tool.mock.modular.mockconfig.entity.MockConfig;
|
||||
import org.nl.tool.mock.modular.mockconfig.param.MockConfigAddParam;
|
||||
import org.nl.tool.mock.modular.mockconfig.param.MockConfigEditParam;
|
||||
import org.nl.tool.mock.modular.mockconfig.param.MockConfigIdParam;
|
||||
import org.nl.tool.mock.modular.mockconfig.param.MockConfigPageParam;
|
||||
import org.nl.tool.mock.modular.mockconfig.service.MockConfigService;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Mock配置表控制器
|
||||
*
|
||||
* @author liyongde
|
||||
* @date 2026/01/28 17:50
|
||||
*/
|
||||
@Tag(name = "Mock配置表控制器")
|
||||
@RestController
|
||||
@Validated
|
||||
public class MockConfigController {
|
||||
|
||||
@Resource
|
||||
private MockConfigService mockConfigService;
|
||||
|
||||
/**
|
||||
* 获取Mock配置表分页
|
||||
*
|
||||
* @author liyongde
|
||||
* @date 2026/01/28 17:50
|
||||
*/
|
||||
@Operation(summary = "获取Mock配置表分页")
|
||||
@SaCheckPermission("/mock/mockconfig/page")
|
||||
@GetMapping("/mock/mockconfig/page")
|
||||
public CommonResult<Page<MockConfig>> page(MockConfigPageParam mockConfigPageParam) {
|
||||
return CommonResult.data(mockConfigService.page(mockConfigPageParam));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加Mock配置表
|
||||
*
|
||||
* @author liyongde
|
||||
* @date 2026/01/28 17:50
|
||||
*/
|
||||
@Operation(summary = "添加Mock配置表")
|
||||
@CommonLog("添加Mock配置表")
|
||||
@SaCheckPermission("/mock/mockconfig/add")
|
||||
@PostMapping("/mock/mockconfig/add")
|
||||
public CommonResult<String> add(@RequestBody @Valid MockConfigAddParam mockConfigAddParam) {
|
||||
mockConfigService.add(mockConfigAddParam);
|
||||
return CommonResult.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑Mock配置表
|
||||
*
|
||||
* @author liyongde
|
||||
* @date 2026/01/28 17:50
|
||||
*/
|
||||
@Operation(summary = "编辑Mock配置表")
|
||||
@CommonLog("编辑Mock配置表")
|
||||
@SaCheckPermission("/mock/mockconfig/edit")
|
||||
@PostMapping("/mock/mockconfig/edit")
|
||||
public CommonResult<String> edit(@RequestBody @Valid MockConfigEditParam mockConfigEditParam) {
|
||||
mockConfigService.edit(mockConfigEditParam);
|
||||
return CommonResult.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除Mock配置表
|
||||
*
|
||||
* @author liyongde
|
||||
* @date 2026/01/28 17:50
|
||||
*/
|
||||
@Operation(summary = "删除Mock配置表")
|
||||
@CommonLog("删除Mock配置表")
|
||||
@SaCheckPermission("/mock/mockconfig/delete")
|
||||
@PostMapping("/mock/mockconfig/delete")
|
||||
public CommonResult<String> delete(@RequestBody @Valid @NotEmpty(message = "集合不能为空")
|
||||
List<MockConfigIdParam> mockConfigIdParamList) {
|
||||
mockConfigService.delete(mockConfigIdParamList);
|
||||
return CommonResult.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Mock配置表详情
|
||||
*
|
||||
* @author liyongde
|
||||
* @date 2026/01/28 17:50
|
||||
*/
|
||||
@Operation(summary = "获取Mock配置表详情")
|
||||
@SaCheckPermission("/mock/mockconfig/detail")
|
||||
@GetMapping("/mock/mockconfig/detail")
|
||||
public CommonResult<MockConfig> detail(@Valid MockConfigIdParam mockConfigIdParam) {
|
||||
return CommonResult.data(mockConfigService.detail(mockConfigIdParam));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright [2022] [https://www.xiaonuo.vip]
|
||||
*
|
||||
* Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Snowy源码头部的版权声明。
|
||||
* 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
|
||||
* 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
|
||||
* 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
|
||||
*/
|
||||
package org.nl.tool.mock.modular.mockconfig.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Mock配置表实体
|
||||
*
|
||||
* @author liyongde
|
||||
* @date 2026/01/28 17:50
|
||||
**/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("tool_mock_config")
|
||||
public class MockConfig {
|
||||
|
||||
/** 主键ID */
|
||||
@TableId
|
||||
@Schema(description = "主键ID")
|
||||
private String id;
|
||||
|
||||
/** 接口路径,如:/api/user/info */
|
||||
@Schema(description = "接口路径,如:/api/user/info")
|
||||
private String apiPath;
|
||||
|
||||
/** 请求方法:GET, POST, PUT, DELETE */
|
||||
@Schema(description = "请求方法:GET, POST, PUT, DELETE")
|
||||
private String apiMethod;
|
||||
|
||||
/** 返回的JSON数据 */
|
||||
@Schema(description = "返回的JSON数据")
|
||||
private String responseJson;
|
||||
|
||||
/** 是否启用:true-启用,false-禁用 */
|
||||
@Schema(description = "是否启用:true-启用,false-禁用")
|
||||
private Boolean isEnabled;
|
||||
|
||||
/** 创建时间 */
|
||||
@Schema(description = "创建时间")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
|
||||
/** 更新时间 */
|
||||
@Schema(description = "更新时间")
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private Date updateTime;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright [2022] [https://www.xiaonuo.vip]
|
||||
*
|
||||
* Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Snowy源码头部的版权声明。
|
||||
* 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
|
||||
* 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
|
||||
* 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
|
||||
*/
|
||||
package org.nl.tool.mock.modular.mockconfig.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* Mock配置表枚举
|
||||
*
|
||||
* @author liyongde
|
||||
* @date 2026/01/28 17:50
|
||||
**/
|
||||
@Getter
|
||||
public enum MockConfigEnum {
|
||||
|
||||
/** 测试 */
|
||||
TEST("TEST");
|
||||
|
||||
private final String value;
|
||||
|
||||
MockConfigEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright [2022] [https://www.xiaonuo.vip]
|
||||
*
|
||||
* Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Snowy源码头部的版权声明。
|
||||
* 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
|
||||
* 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
|
||||
* 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
|
||||
*/
|
||||
package org.nl.tool.mock.modular.mockconfig.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.nl.tool.mock.modular.mockconfig.entity.MockConfig;
|
||||
|
||||
/**
|
||||
* Mock配置表Mapper接口
|
||||
*
|
||||
* @author liyongde
|
||||
* @date 2026/01/28 17:50
|
||||
**/
|
||||
public interface MockConfigMapper extends BaseMapper<MockConfig> {
|
||||
}
|
||||
@@ -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="org.nl.tool.mock.modular.mockconfig.mapper.MockConfigMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright [2022] [https://www.xiaonuo.vip]
|
||||
*
|
||||
* Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Snowy源码头部的版权声明。
|
||||
* 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
|
||||
* 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
|
||||
* 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
|
||||
*/
|
||||
package org.nl.tool.mock.modular.mockconfig.param;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Mock配置表添加参数
|
||||
*
|
||||
* @author liyongde
|
||||
* @date 2026/01/28 17:50
|
||||
**/
|
||||
@Getter
|
||||
@Setter
|
||||
public class MockConfigAddParam {
|
||||
|
||||
/** 接口路径,如:/api/user/info */
|
||||
@Schema(description = "接口路径,如:/api/user/info")
|
||||
private String apiPath;
|
||||
|
||||
/** 请求方法:GET, POST, PUT, DELETE */
|
||||
@Schema(description = "请求方法:GET, POST, PUT, DELETE")
|
||||
private String apiMethod;
|
||||
|
||||
/** 返回的JSON数据 */
|
||||
@Schema(description = "返回的JSON数据")
|
||||
private String responseJson;
|
||||
|
||||
/** 是否启用:true-启用,false-禁用 */
|
||||
@Schema(description = "是否启用:true-启用,false-禁用")
|
||||
private Boolean isEnabled;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright [2022] [https://www.xiaonuo.vip]
|
||||
*
|
||||
* Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Snowy源码头部的版权声明。
|
||||
* 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
|
||||
* 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
|
||||
* 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
|
||||
*/
|
||||
package org.nl.tool.mock.modular.mockconfig.param;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Mock配置表编辑参数
|
||||
*
|
||||
* @author liyongde
|
||||
* @date 2026/01/28 17:50
|
||||
**/
|
||||
@Getter
|
||||
@Setter
|
||||
public class MockConfigEditParam {
|
||||
|
||||
/** 主键ID */
|
||||
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "id不能为空")
|
||||
private String id;
|
||||
|
||||
/** 接口路径,如:/api/user/info */
|
||||
@Schema(description = "接口路径,如:/api/user/info")
|
||||
private String apiPath;
|
||||
|
||||
/** 请求方法:GET, POST, PUT, DELETE */
|
||||
@Schema(description = "请求方法:GET, POST, PUT, DELETE")
|
||||
private String apiMethod;
|
||||
|
||||
/** 返回的JSON数据 */
|
||||
@Schema(description = "返回的JSON数据")
|
||||
private String responseJson;
|
||||
|
||||
/** 是否启用:true-启用,false-禁用 */
|
||||
@Schema(description = "是否启用:true-启用,false-禁用")
|
||||
private Boolean isEnabled;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright [2022] [https://www.xiaonuo.vip]
|
||||
*
|
||||
* Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Snowy源码头部的版权声明。
|
||||
* 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
|
||||
* 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
|
||||
* 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
|
||||
*/
|
||||
package org.nl.tool.mock.modular.mockconfig.param;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* Mock配置表Id参数
|
||||
*
|
||||
* @author liyongde
|
||||
* @date 2026/01/28 17:50
|
||||
**/
|
||||
@Getter
|
||||
@Setter
|
||||
public class MockConfigIdParam {
|
||||
|
||||
/** 主键ID */
|
||||
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "id不能为空")
|
||||
private String id;
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright [2022] [https://www.xiaonuo.vip]
|
||||
*
|
||||
* Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Snowy源码头部的版权声明。
|
||||
* 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
|
||||
* 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
|
||||
* 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
|
||||
*/
|
||||
package org.nl.tool.mock.modular.mockconfig.param;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Mock配置表查询参数
|
||||
*
|
||||
* @author liyongde
|
||||
* @date 2026/01/28 17:50
|
||||
**/
|
||||
@Getter
|
||||
@Setter
|
||||
public class MockConfigPageParam {
|
||||
|
||||
/** 当前页 */
|
||||
@Schema(description = "当前页码")
|
||||
private Integer current;
|
||||
|
||||
/** 每页条数 */
|
||||
@Schema(description = "每页条数")
|
||||
private Integer size;
|
||||
|
||||
/** 排序字段 */
|
||||
@Schema(description = "排序字段,字段驼峰名称,如:userName")
|
||||
private String sortField;
|
||||
|
||||
/** 排序方式 */
|
||||
@Schema(description = "排序方式,升序:ASCEND;降序:DESCEND")
|
||||
private String sortOrder;
|
||||
|
||||
/** 关键词 */
|
||||
@Schema(description = "关键词")
|
||||
private String searchKey;
|
||||
|
||||
/** 接口路径,如:/api/user/info */
|
||||
@Schema(description = "接口路径,如:/api/user/info")
|
||||
private String apiPath;
|
||||
|
||||
/** 请求方法:GET, POST, PUT, DELETE */
|
||||
@Schema(description = "请求方法:GET, POST, PUT, DELETE")
|
||||
private String apiMethod;
|
||||
|
||||
/** 是否启用:true-启用,false-禁用 */
|
||||
@Schema(description = "是否启用:true-启用,false-禁用")
|
||||
private Boolean isEnabled;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright [2022] [https://www.xiaonuo.vip]
|
||||
*
|
||||
* Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Snowy源码头部的版权声明。
|
||||
* 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
|
||||
* 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
|
||||
* 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
|
||||
*/
|
||||
package org.nl.tool.mock.modular.mockconfig.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.nl.tool.mock.modular.mockconfig.entity.MockConfig;
|
||||
import org.nl.tool.mock.modular.mockconfig.param.MockConfigAddParam;
|
||||
import org.nl.tool.mock.modular.mockconfig.param.MockConfigEditParam;
|
||||
import org.nl.tool.mock.modular.mockconfig.param.MockConfigIdParam;
|
||||
import org.nl.tool.mock.modular.mockconfig.param.MockConfigPageParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Mock配置表Service接口
|
||||
*
|
||||
* @author liyongde
|
||||
* @date 2026/01/28 17:50
|
||||
**/
|
||||
public interface MockConfigService extends IService<MockConfig> {
|
||||
|
||||
/**
|
||||
* 获取Mock配置表分页
|
||||
*
|
||||
* @author liyongde
|
||||
* @date 2026/01/28 17:50
|
||||
*/
|
||||
Page<MockConfig> page(MockConfigPageParam mockConfigPageParam);
|
||||
|
||||
/**
|
||||
* 添加Mock配置表
|
||||
*
|
||||
* @author liyongde
|
||||
* @date 2026/01/28 17:50
|
||||
*/
|
||||
void add(MockConfigAddParam mockConfigAddParam);
|
||||
|
||||
/**
|
||||
* 编辑Mock配置表
|
||||
*
|
||||
* @author liyongde
|
||||
* @date 2026/01/28 17:50
|
||||
*/
|
||||
void edit(MockConfigEditParam mockConfigEditParam);
|
||||
|
||||
/**
|
||||
* 删除Mock配置表
|
||||
*
|
||||
* @author liyongde
|
||||
* @date 2026/01/28 17:50
|
||||
*/
|
||||
void delete(List<MockConfigIdParam> mockConfigIdParamList);
|
||||
|
||||
/**
|
||||
* 获取Mock配置表详情
|
||||
*
|
||||
* @author liyongde
|
||||
* @date 2026/01/28 17:50
|
||||
*/
|
||||
MockConfig detail(MockConfigIdParam mockConfigIdParam);
|
||||
|
||||
/**
|
||||
* 获取Mock配置表详情
|
||||
*
|
||||
* @author liyongde
|
||||
* @date 2026/01/28 17:50
|
||||
**/
|
||||
MockConfig queryEntity(String id);
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright [2022] [https://www.xiaonuo.vip]
|
||||
*
|
||||
* Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Snowy源码头部的版权声明。
|
||||
* 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
|
||||
* 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
|
||||
* 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
|
||||
*/
|
||||
package org.nl.tool.mock.modular.mockconfig.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollStreamUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
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 org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.nl.common.enums.CommonSortOrderEnum;
|
||||
import org.nl.common.exception.CommonException;
|
||||
import org.nl.common.page.CommonPageRequest;
|
||||
import org.nl.tool.mock.modular.mockconfig.entity.MockConfig;
|
||||
import org.nl.tool.mock.modular.mockconfig.mapper.MockConfigMapper;
|
||||
import org.nl.tool.mock.modular.mockconfig.param.MockConfigAddParam;
|
||||
import org.nl.tool.mock.modular.mockconfig.param.MockConfigEditParam;
|
||||
import org.nl.tool.mock.modular.mockconfig.param.MockConfigIdParam;
|
||||
import org.nl.tool.mock.modular.mockconfig.param.MockConfigPageParam;
|
||||
import org.nl.tool.mock.modular.mockconfig.service.MockConfigService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Mock配置表Service接口实现类
|
||||
*
|
||||
* @author liyongde
|
||||
* @date 2026/01/28 17:50
|
||||
**/
|
||||
@Service
|
||||
public class MockConfigServiceImpl extends ServiceImpl<MockConfigMapper, MockConfig> implements MockConfigService {
|
||||
|
||||
@Override
|
||||
public Page<MockConfig> page(MockConfigPageParam mockConfigPageParam) {
|
||||
QueryWrapper<MockConfig> queryWrapper = new QueryWrapper<MockConfig>().checkSqlInjection();
|
||||
if(ObjectUtil.isNotEmpty(mockConfigPageParam.getApiPath())) {
|
||||
queryWrapper.lambda().eq(MockConfig::getApiPath, mockConfigPageParam.getApiPath());
|
||||
}
|
||||
if(ObjectUtil.isNotEmpty(mockConfigPageParam.getApiMethod())) {
|
||||
queryWrapper.lambda().eq(MockConfig::getApiMethod, mockConfigPageParam.getApiMethod());
|
||||
}
|
||||
if(ObjectUtil.isNotEmpty(mockConfigPageParam.getIsEnabled())) {
|
||||
queryWrapper.lambda().eq(MockConfig::getIsEnabled, mockConfigPageParam.getIsEnabled());
|
||||
}
|
||||
if(ObjectUtil.isAllNotEmpty(mockConfigPageParam.getSortField(), mockConfigPageParam.getSortOrder())) {
|
||||
CommonSortOrderEnum.validate(mockConfigPageParam.getSortOrder());
|
||||
queryWrapper.orderBy(true, mockConfigPageParam.getSortOrder().equals(CommonSortOrderEnum.ASC.getValue()),
|
||||
StrUtil.toUnderlineCase(mockConfigPageParam.getSortField()));
|
||||
} else {
|
||||
queryWrapper.lambda().orderByAsc(MockConfig::getId);
|
||||
}
|
||||
return this.page(CommonPageRequest.defaultPage(), queryWrapper);
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void add(MockConfigAddParam mockConfigAddParam) {
|
||||
MockConfig mockConfig = BeanUtil.toBean(mockConfigAddParam, MockConfig.class);
|
||||
this.save(mockConfig);
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void edit(MockConfigEditParam mockConfigEditParam) {
|
||||
MockConfig mockConfig = this.queryEntity(mockConfigEditParam.getId());
|
||||
BeanUtil.copyProperties(mockConfigEditParam, mockConfig);
|
||||
this.updateById(mockConfig);
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void delete(List<MockConfigIdParam> mockConfigIdParamList) {
|
||||
// 执行删除
|
||||
this.removeByIds(CollStreamUtil.toList(mockConfigIdParamList, MockConfigIdParam::getId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public MockConfig detail(MockConfigIdParam mockConfigIdParam) {
|
||||
return this.queryEntity(mockConfigIdParam.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public MockConfig queryEntity(String id) {
|
||||
MockConfig mockConfig = this.getById(id);
|
||||
if(ObjectUtil.isEmpty(mockConfig)) {
|
||||
throw new CommonException("Mock配置表不存在,id值为:{}", id);
|
||||
}
|
||||
return mockConfig;
|
||||
}
|
||||
}
|
||||
@@ -16,23 +16,24 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import org.nl.common.annotation.CommonLog;
|
||||
import org.nl.common.pojo.CommonResult;
|
||||
import org.nl.dev.api.DevConfigApi;
|
||||
import org.nl.dev.modular.file.entity.DevFile;
|
||||
import org.nl.dev.modular.file.enums.DevFileEngineTypeEnum;
|
||||
import org.nl.dev.modular.file.param.DevFileIdParam;
|
||||
import org.nl.dev.modular.file.param.DevFileListParam;
|
||||
import org.nl.dev.modular.file.param.DevFilePageParam;
|
||||
import org.nl.dev.modular.file.param.DevFileUrlListParam;
|
||||
import org.nl.dev.modular.file.service.DevFileService;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.nl.common.annotation.CommonLog;
|
||||
import org.nl.common.pojo.CommonResult;
|
||||
import org.nl.dev.api.DevConfigApi;
|
||||
import org.nl.dev.modular.file.service.DevFileService;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
@@ -262,4 +263,14 @@ public class DevFileController {
|
||||
public CommonResult<List<DevFile>> getFileListByUrlList(@RequestBody @Valid DevFileUrlListParam devFileUrlListParam) {
|
||||
return CommonResult.data(devFileService.getFileListByUrlList(devFileUrlListParam));
|
||||
}
|
||||
|
||||
@Operation(summary = "上传文件")
|
||||
@PostMapping({"/api/localStorage/upload"})
|
||||
public CommonResult<Object> upload(@RequestParam MultipartFile file) {
|
||||
return CommonResult.data(devFileService.upload(file));
|
||||
}
|
||||
@GetMapping({"/api/localStorage/download"})
|
||||
public void download(@RequestParam String storageId , HttpServletResponse response, HttpServletRequest request) throws IOException {
|
||||
this.devFileService.downloadFile(this.devFileService.getById(storageId),request, response);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package org.nl.dev.modular.file.enums;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author: lyd
|
||||
* @date: 2026/1/28
|
||||
*/
|
||||
public enum ReturnTypeEnum {
|
||||
/**
|
||||
* 文件id
|
||||
*/
|
||||
FILE_ID("1"),
|
||||
/**
|
||||
* 下载地址
|
||||
*/
|
||||
DOWNLOAD_URL("2"),
|
||||
/**
|
||||
* 文件对象
|
||||
*/
|
||||
FILE("3");
|
||||
|
||||
private final String code;
|
||||
|
||||
ReturnTypeEnum(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public static ReturnTypeEnum fromCode(String code) {
|
||||
for (ReturnTypeEnum type : values()) {
|
||||
if (type.code.equals(code)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return FILE; // 默认值
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ package org.nl.dev.modular.file.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.nl.dev.modular.file.entity.DevFile;
|
||||
import org.nl.dev.modular.file.param.DevFileIdParam;
|
||||
@@ -104,4 +105,8 @@ public interface DevFileService extends IService<DevFile> {
|
||||
* @date 2022/4/24 21:18
|
||||
*/
|
||||
DevFile queryEntity(String id);
|
||||
|
||||
DevFile upload(MultipartFile file);
|
||||
|
||||
void downloadFile(DevFile file, HttpServletRequest request, HttpServletResponse response);
|
||||
}
|
||||
|
||||
@@ -27,10 +27,12 @@ import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.apache.commons.math3.dfp.DfpField;
|
||||
import org.nl.dev.modular.file.entity.DevFile;
|
||||
import org.nl.dev.modular.file.enums.DevFileEngineTypeEnum;
|
||||
import org.nl.dev.modular.file.enums.ReturnTypeEnum;
|
||||
import org.nl.dev.modular.file.param.DevFileIdParam;
|
||||
import org.nl.dev.modular.file.param.DevFileListParam;
|
||||
import org.nl.dev.modular.file.param.DevFilePageParam;
|
||||
@@ -67,12 +69,12 @@ public class DevFileServiceImpl extends ServiceImpl<DevFileMapper, DevFile> impl
|
||||
|
||||
@Override
|
||||
public String uploadReturnId(String engine, MultipartFile file) {
|
||||
return this.storageFile(engine, file, true);
|
||||
return this.storageFile(engine, file, ReturnTypeEnum.FILE_ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String uploadReturnUrl(String engine, MultipartFile file) {
|
||||
return this.storageFile(engine, file, false);
|
||||
return this.storageFile(engine, file, ReturnTypeEnum.DOWNLOAD_URL);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -127,11 +129,11 @@ public class DevFileServiceImpl extends ServiceImpl<DevFileMapper, DevFile> impl
|
||||
|
||||
/**
|
||||
* 存储文件
|
||||
*
|
||||
* 默认返回实体
|
||||
* @author xuyuxiang
|
||||
* @date 2022/6/16 16:24
|
||||
**/
|
||||
private String storageFile(String engine, MultipartFile file, boolean returnFileId) {
|
||||
private <T> T storageFile(String engine, MultipartFile file, ReturnTypeEnum returnType) {
|
||||
|
||||
// 如果引擎为空,默认使用本地
|
||||
if(ObjectUtil.isEmpty(engine)) {
|
||||
@@ -218,13 +220,11 @@ public class DevFileServiceImpl extends ServiceImpl<DevFileMapper, DevFile> impl
|
||||
|
||||
this.save(devFile);
|
||||
|
||||
// 如果是返回id则返回文件id
|
||||
if(returnFileId) {
|
||||
return fileId;
|
||||
} else {
|
||||
// 否则返回下载地址
|
||||
return downloadUrl;
|
||||
}
|
||||
return switch (returnType) {
|
||||
case FILE_ID -> (T) fileId;
|
||||
case DOWNLOAD_URL -> (T) downloadUrl;
|
||||
case FILE -> (T) devFile;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -277,6 +277,18 @@ public class DevFileServiceImpl extends ServiceImpl<DevFileMapper, DevFile> impl
|
||||
return devFile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DevFile upload(MultipartFile file) {
|
||||
return this.storageFile(DevFileEngineTypeEnum.LOCAL.getValue(), file, ReturnTypeEnum.FILE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadFile(DevFile file, HttpServletRequest request, HttpServletResponse response) {
|
||||
String path = file.getStoragePath();
|
||||
File file2 = new File(path);
|
||||
org.nl.common.util.FileUtil.downloadFile(request, response, file2, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据文件后缀判断是否图片
|
||||
*
|
||||
|
||||
@@ -18,15 +18,13 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.nl.sys.modular.group.entity.SysGroup;
|
||||
import org.nl.sys.modular.org.entity.SysOrg;
|
||||
import org.nl.sys.modular.position.entity.SysPosition;
|
||||
import org.nl.sys.modular.role.entity.SysRole;
|
||||
import org.nl.sys.modular.user.entity.SysUser;
|
||||
import org.nl.sys.modular.user.param.*;
|
||||
import org.nl.sys.modular.user.result.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.nl.sys.modular.user.param.*;
|
||||
import org.nl.sys.modular.user.result.*;
|
||||
import org.nl.sys.modular.org.entity.SysOrg;
|
||||
import org.nl.sys.modular.role.entity.SysRole;
|
||||
import org.nl.sys.modular.user.entity.SysUser;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
28
nl-vue/src/api/mock/mockConfigApi.js
Normal file
28
nl-vue/src/api/mock/mockConfigApi.js
Normal file
@@ -0,0 +1,28 @@
|
||||
import { baseRequest } from '@/utils/request'
|
||||
|
||||
const request = (url, ...arg) => baseRequest(`/mock/mockconfig/` + url, ...arg)
|
||||
|
||||
/**
|
||||
* Mock配置表Api接口管理器
|
||||
*
|
||||
* @author liyongde
|
||||
* @date 2026/01/28 17:50
|
||||
**/
|
||||
export default {
|
||||
// 获取Mock配置表分页
|
||||
mockConfigPage(data) {
|
||||
return request('page', data, 'get')
|
||||
},
|
||||
// 提交Mock配置表表单 edit为true时为编辑,默认为新增
|
||||
mockConfigSubmitForm(data, edit = false) {
|
||||
return request(edit ? 'edit' : 'add', data)
|
||||
},
|
||||
// 删除Mock配置表
|
||||
mockConfigDelete(data) {
|
||||
return request('delete', data)
|
||||
},
|
||||
// 获取Mock配置表详情
|
||||
mockConfigDetail(data) {
|
||||
return request('detail', data, 'get')
|
||||
}
|
||||
}
|
||||
99
nl-vue/src/views/mock/mockconfig/form.vue
Normal file
99
nl-vue/src/views/mock/mockconfig/form.vue
Normal file
@@ -0,0 +1,99 @@
|
||||
<template>
|
||||
<xn-form-container
|
||||
:title="formData.id ? '编辑Mock配置表' : '增加Mock配置表'"
|
||||
:width="700"
|
||||
v-model:open="open"
|
||||
:destroy-on-close="true"
|
||||
@close="onClose"
|
||||
>
|
||||
<a-form ref="formRef" :model="formData" :rules="formRules" layout="horizontal">
|
||||
<a-row :gutter="16">
|
||||
<a-col :span="12">
|
||||
<a-form-item label="接口路径" name="apiPath">
|
||||
<a-input v-model:value="formData.apiPath" placeholder="请输入接口路径,如:/api/user/info" allow-clear />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="请求方法" name="apiMethod">
|
||||
<a-input v-model:value="formData.apiMethod" placeholder="请输入请求方法:GET, POST, PUT, DELETE" allow-clear />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="返回数据:" name="responseJson">
|
||||
<a-input v-model:value="formData.responseJson" placeholder="请输入返回的JSON数据" allow-clear />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="是否启用" name="isEnabled">
|
||||
<a-radio-group
|
||||
v-model:value="formData.isEnabled"
|
||||
placeholder="请选择是否启用"
|
||||
:options="isEnabledOptions"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form>
|
||||
<template #footer>
|
||||
<a-button style="margin-right: 8px" @click="onClose">关闭</a-button>
|
||||
<a-button type="primary" @click="onSubmit" :loading="submitLoading">保存</a-button>
|
||||
</template>
|
||||
</xn-form-container>
|
||||
</template>
|
||||
|
||||
<script setup name="mockConfigForm">
|
||||
import tool from '@/utils/tool'
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
import { required } from '@/utils/formRules'
|
||||
import mockConfigApi from '@/api/mock/mockConfigApi'
|
||||
// 抽屉状态
|
||||
const open = ref(false)
|
||||
const emit = defineEmits({ successful: null })
|
||||
const formRef = ref()
|
||||
// 表单数据
|
||||
const formData = ref({})
|
||||
const submitLoading = ref(false)
|
||||
const isEnabledOptions = ref([])
|
||||
|
||||
// 打开抽屉
|
||||
const onOpen = (record) => {
|
||||
open.value = true
|
||||
if (record) {
|
||||
let recordData = cloneDeep(record)
|
||||
formData.value = Object.assign({}, recordData)
|
||||
}
|
||||
isEnabledOptions.value = tool.dictList('IS_USED')
|
||||
}
|
||||
// 关闭抽屉
|
||||
const onClose = () => {
|
||||
formRef.value.resetFields()
|
||||
formData.value = {}
|
||||
open.value = false
|
||||
}
|
||||
// 默认要校验的
|
||||
const formRules = {
|
||||
}
|
||||
// 验证并提交数据
|
||||
const onSubmit = () => {
|
||||
formRef.value
|
||||
.validate()
|
||||
.then(() => {
|
||||
submitLoading.value = true
|
||||
const formDataParam = cloneDeep(formData.value)
|
||||
mockConfigApi
|
||||
.mockConfigSubmitForm(formDataParam, formDataParam.id)
|
||||
.then(() => {
|
||||
onClose()
|
||||
emit('successful')
|
||||
})
|
||||
.finally(() => {
|
||||
submitLoading.value = false
|
||||
})
|
||||
})
|
||||
.catch(() => {})
|
||||
}
|
||||
// 抛出函数
|
||||
defineExpose({
|
||||
onOpen
|
||||
})
|
||||
</script>
|
||||
164
nl-vue/src/views/mock/mockconfig/index.vue
Normal file
164
nl-vue/src/views/mock/mockconfig/index.vue
Normal file
@@ -0,0 +1,164 @@
|
||||
<template>
|
||||
<a-card :bordered="false">
|
||||
<a-form ref="searchFormRef" name="advanced_search" :model="searchFormState" class="ant-advanced-search-form">
|
||||
<a-row :gutter="24">
|
||||
<a-col :span="6">
|
||||
<a-form-item label="接口路径" name="apiPath">
|
||||
<a-input v-model:value="searchFormState.apiPath" placeholder="请输入接口路径,如:/api/user/info" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="6">
|
||||
<a-form-item label="请求方法" name="apiMethod">
|
||||
<a-input v-model:value="searchFormState.apiMethod" placeholder="请输入请求方法:GET, POST, PUT, DELETE" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="6">
|
||||
<a-form-item label="是否启用" name="isEnabled">
|
||||
<a-select v-model:value="searchFormState.isEnabled" placeholder="请选择是否启用" :options="isEnabledOptions" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="6">
|
||||
<a-button type="primary" @click="tableRef.refresh()">查询</a-button>
|
||||
<a-button style="margin: 0 8px" @click="reset">重置</a-button>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form>
|
||||
<s-table
|
||||
ref="tableRef"
|
||||
:columns="columns"
|
||||
:data="loadData"
|
||||
:alert="options.alert.show"
|
||||
bordered
|
||||
:row-key="(record) => record.id"
|
||||
:tool-config="toolConfig"
|
||||
:row-selection="options.rowSelection"
|
||||
>
|
||||
<template #operator class="table-operator">
|
||||
<a-space>
|
||||
<a-button type="primary" @click="formRef.onOpen()" v-if="hasPerm('mockConfigAdd')">
|
||||
<template #icon><plus-outlined /></template>
|
||||
新增
|
||||
</a-button>
|
||||
<xn-batch-button
|
||||
v-if="hasPerm('mockConfigBatchDelete')"
|
||||
buttonName="批量删除"
|
||||
icon="DeleteOutlined"
|
||||
:selectedRowKeys="selectedRowKeys"
|
||||
@batchCallBack="deleteBatchMockConfig"
|
||||
/>
|
||||
</a-space>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.dataIndex === 'isEnabled'">
|
||||
{{ record.isEnabled ? '启用' : '禁用' }}
|
||||
</template>
|
||||
<template v-if="column.dataIndex === 'action'">
|
||||
<a-space>
|
||||
<a @click="formRef.onOpen(record)" v-if="hasPerm('mockConfigEdit')">编辑</a>
|
||||
<a-divider type="vertical" v-if="hasPerm(['mockConfigEdit', 'mockConfigDelete'], 'and')" />
|
||||
<a-popconfirm title="确定要删除吗?" @confirm="deleteMockConfig(record)">
|
||||
<a-button type="link" danger size="small" v-if="hasPerm('mockConfigDelete')">删除</a-button>
|
||||
</a-popconfirm>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</s-table>
|
||||
</a-card>
|
||||
<Form ref="formRef" @successful="tableRef.refresh()" />
|
||||
</template>
|
||||
|
||||
<script setup name="mockconfig">
|
||||
import tool from '@/utils/tool'
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
import Form from './form.vue'
|
||||
import mockConfigApi from '@/api/mock/mockConfigApi'
|
||||
const searchFormState = ref({})
|
||||
const searchFormRef = ref()
|
||||
const tableRef = ref()
|
||||
const formRef = ref()
|
||||
const toolConfig = { refresh: true, height: true, columnSetting: true, striped: false }
|
||||
const columns = [
|
||||
{
|
||||
title: '接口路径',
|
||||
dataIndex: 'apiPath'
|
||||
},
|
||||
{
|
||||
title: '请求方法',
|
||||
dataIndex: 'apiMethod',
|
||||
width: 80
|
||||
},
|
||||
{
|
||||
title: '返回数据',
|
||||
dataIndex: 'responseJson'
|
||||
},
|
||||
{
|
||||
title: '是否启用',
|
||||
dataIndex: 'isEnabled',
|
||||
width: 80
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
width: 150
|
||||
},
|
||||
{
|
||||
title: '更新时间',
|
||||
dataIndex: 'updateTime',
|
||||
width: 150
|
||||
},
|
||||
]
|
||||
// 操作栏通过权限判断是否显示
|
||||
if (hasPerm(['mockConfigEdit', 'mockConfigDelete'])) {
|
||||
columns.push({
|
||||
title: '操作',
|
||||
dataIndex: 'action',
|
||||
align: 'center',
|
||||
width: 150
|
||||
})
|
||||
}
|
||||
const selectedRowKeys = ref([])
|
||||
// 列表选择配置
|
||||
const options = {
|
||||
// columns数字类型字段加入 needTotal: true 可以勾选自动算账
|
||||
alert: {
|
||||
show: true,
|
||||
clear: () => {
|
||||
selectedRowKeys.value = ref([])
|
||||
}
|
||||
},
|
||||
rowSelection: {
|
||||
onChange: (selectedRowKey, selectedRows) => {
|
||||
selectedRowKeys.value = selectedRowKey
|
||||
}
|
||||
}
|
||||
}
|
||||
const loadData = (parameter) => {
|
||||
const searchFormParam = cloneDeep(searchFormState.value)
|
||||
return mockConfigApi.mockConfigPage(Object.assign(parameter, searchFormParam)).then((data) => {
|
||||
return data
|
||||
})
|
||||
}
|
||||
// 重置
|
||||
const reset = () => {
|
||||
searchFormRef.value.resetFields()
|
||||
tableRef.value.refresh(true)
|
||||
}
|
||||
// 删除
|
||||
const deleteMockConfig = (record) => {
|
||||
let params = [
|
||||
{
|
||||
id: record.id
|
||||
}
|
||||
]
|
||||
mockConfigApi.mockConfigDelete(params).then(() => {
|
||||
tableRef.value.refresh(true)
|
||||
})
|
||||
}
|
||||
// 批量删除
|
||||
const deleteBatchMockConfig = (params) => {
|
||||
mockConfigApi.mockConfigDelete(params).then(() => {
|
||||
tableRef.value.clearRefreshSelected()
|
||||
})
|
||||
}
|
||||
const isEnabledOptions = tool.dictList('IS_USED')
|
||||
</script>
|
||||
@@ -94,6 +94,11 @@
|
||||
<groupId>org.nl</groupId>
|
||||
<artifactId>nl-plugin-sys</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.nl.tool</groupId>
|
||||
<artifactId>nl-plugin-tool</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
25
pom.xml
25
pom.xml
@@ -41,22 +41,23 @@
|
||||
|
||||
<!-- 主启动模块 -->
|
||||
<module>nl-web-app</module>
|
||||
<module>nl-plugin-tool</module>
|
||||
<module>nl-plugin-tool-api</module>
|
||||
</modules>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<!-- 项目管理 -->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.nl</groupId>-->
|
||||
<!-- <artifactId>nl-plugin-pmm</artifactId>-->
|
||||
<!-- <version>${snowy.version}</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.nl</groupId>-->
|
||||
<!-- <artifactId>nl-plugin-pmm-api</artifactId>-->
|
||||
<!-- <version>${snowy.version}</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- snowy-common -->
|
||||
<dependency>
|
||||
<groupId>org.nl.tool</groupId>
|
||||
<artifactId>nl-plugin-tool</artifactId>
|
||||
<version>${snowy.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.nl.tool.api</groupId>
|
||||
<artifactId>nl-plugin-tool-api</artifactId>
|
||||
<version>${snowy.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.nl</groupId>
|
||||
<artifactId>nl-common</artifactId>
|
||||
|
||||
Reference in New Issue
Block a user